source: svn/branches/kctv/newcon3bcm2_21bu/magnum/basemodules/reg/breg_sims.c

Last change on this file was 2, checked in by phkim, 11 years ago

1.phkim

  1. revision copy newcon3sk r27
  • Property svn:executable set to *
File size: 2.8 KB
Line 
1/***************************************************************************
2 *         Copyright (c) 2003-2007, Broadcom Corporation
3 *         All Rights Reserved
4 *         Confidential Property of Broadcom Corporation
5 *
6 *      THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE
7 *      AGREEMENT  BETWEEN THE USER AND BROADCOM.  YOU HAVE NO RIGHT TO USE OR
8 *      EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT.
9 *
10 * $brcm_Workfile: breg_sims.c $
11 * $brcm_Revision: Hydra_Software_Devel/2 $
12 * $brcm_Date: 10/16/07 2:24p $
13 *
14 * Module Description:
15 *
16 * Revision History:
17 *
18 * $brcm_Log: /magnum/basemodules/reg/breg_sims.c $
19 *
20 * Hydra_Software_Devel/2   10/16/07 2:24p jessem
21 * PR 36129: Change BCHIPIF_xxx to IKOS_Client_xxx.
22 *
23 * Hydra_Software_Devel/1   3/31/07 6:25p shyam
24 * PR 29285 : Added linuxclient support for simulations/emulation
25 *
26 *
27 ***************************************************************************/
28#include "bstd.h"
29
30#include "bkni.h"
31
32#include "breg_mem.h"
33#include "client.h"
34
35#if BDBG_DEBUG_BUILD
36typedef struct BREG_Impl
37{
38        uintptr_t BaseAddr; /* BaseAddr shall be the first member to keep it run-time compatible with the release builds */
39        size_t MaxRegOffset;
40}BREG_Impl;
41#endif
42
43void BREG_Open( BREG_Handle *pRegHandle, void *Address, size_t MaxRegOffset )
44{
45        *pRegHandle = (BREG_Handle)BKNI_Malloc( sizeof(BREG_Impl) );
46        BDBG_ASSERT(*pRegHandle != NULL );
47
48#if BDBG_DEBUG_BUILD
49        (*pRegHandle)->MaxRegOffset = MaxRegOffset;
50#else
51        BSTD_UNUSED(MaxRegOffset);
52#endif
53        (*pRegHandle)->BaseAddr = (uintptr_t)Address;
54}
55
56void BREG_Close( BREG_Handle RegHandle )
57{
58        BDBG_ASSERT(RegHandle != NULL );
59        BKNI_Free(RegHandle);
60}
61
62/* compile the register access functions even for the release build */
63#undef  BREG_Write32
64#undef  BREG_Write16
65#undef  BREG_Write8
66
67#undef  BREG_Read32
68#undef  BREG_Read16
69#undef  BREG_Read8
70
71
72uint32_t BREG_Read32(BREG_Handle RegHandle, uint32_t reg)
73{
74        uint32_t data ;
75
76        BDBG_ASSERT(reg < RegHandle->MaxRegOffset);
77        IKOS_Client_ReadRegister(reg, &data);
78        return data ;
79}
80
81uint16_t BREG_Read16(BREG_Handle RegHandle, uint32_t reg)
82{
83        BDBG_ASSERT(reg < RegHandle->MaxRegOffset);
84        BDBG_ASSERT(0);
85        return *((volatile uint16_t *)(RegHandle->BaseAddr+reg));
86}
87
88uint8_t BREG_Read8(BREG_Handle RegHandle, uint32_t reg)
89{
90        BDBG_ASSERT(reg < RegHandle->MaxRegOffset);
91        BDBG_ASSERT(0);
92        return *((volatile uint8_t *)(RegHandle->BaseAddr+reg));
93}
94
95void BREG_Write32(BREG_Handle RegHandle, uint32_t reg, uint32_t data)
96{
97        BDBG_ASSERT(reg < RegHandle->MaxRegOffset);
98        IKOS_Client_WriteRegister(reg, data) ;
99}
100
101void BREG_Write16(BREG_Handle RegHandle, uint32_t reg, uint16_t data)
102{
103        BSTD_UNUSED(data);
104        BDBG_ASSERT(reg < RegHandle->MaxRegOffset);
105        BDBG_ASSERT(0);
106}
107
108void BREG_Write8(BREG_Handle RegHandle, uint32_t reg, uint8_t data)
109{
110        BSTD_UNUSED(data);
111        BDBG_ASSERT(reg < RegHandle->MaxRegOffset);
112        BDBG_ASSERT(0);
113}
114
115
116/* End of File */
117
Note: See TracBrowser for help on using the repository browser.