|
1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #ifndef __ASSPREG_H__ |
|
17 #define __ASSPREG_H__ |
|
18 |
|
19 /** |
|
20 @publishedPartner |
|
21 @prototype |
|
22 |
|
23 A class that exports ASSP register access functionality to |
|
24 device drivers and other kernel-side code. |
|
25 |
|
26 Although Symbian OS defines this class, it does not implement all |
|
27 the functions within it. An implementation for each of the register |
|
28 modification functions defined by this class must be provided by |
|
29 the baseport. |
|
30 */ |
|
31 class AsspRegister |
|
32 { |
|
33 public: |
|
34 |
|
35 /** |
|
36 Return the contents of an 8-bit register. |
|
37 |
|
38 @param aAddr The address of the register to be read. |
|
39 @return The contents of the register. |
|
40 @pre Can be called in any context. |
|
41 */ |
|
42 static inline TUint8 Read8(TLinAddr aAddr) |
|
43 { return *(volatile TUint8*)aAddr; } |
|
44 |
|
45 /** |
|
46 Store a new value in an 8-bit register. This will change |
|
47 the entire contents of the register concerned. |
|
48 |
|
49 @param aAddr The address of the register to be written. |
|
50 @param aValue The new value to be written to the register. |
|
51 @pre Can be called in any context. |
|
52 */ |
|
53 static inline void Write8(TLinAddr aAddr, TUint8 aValue) |
|
54 { *(volatile TUint8*)aAddr = aValue; } |
|
55 |
|
56 /** |
|
57 Modify the contents of an 8-bit register. |
|
58 |
|
59 @param aAddr The address of the register to be modified. |
|
60 @param aClearMask A mask of the bits to be cleared in the register. |
|
61 @param aSetMask A mask of the bits to be set in the register after the clear. |
|
62 @pre Can be called in any context. |
|
63 */ |
|
64 IMPORT_C static void Modify8(TLinAddr aAddr, TUint8 aClearMask, TUint8 aSetMask); |
|
65 |
|
66 /** |
|
67 Return the contents of an 16-bit register. |
|
68 |
|
69 @param aAddr The address of the register to be read. |
|
70 @return The contents of the register. |
|
71 @pre Can be called in any context. |
|
72 */ |
|
73 static inline TUint16 Read16(TLinAddr aAddr) |
|
74 { return *(volatile TUint16*)aAddr; } |
|
75 |
|
76 /** |
|
77 Store a new value in a 16-bit register. This will change |
|
78 the entire contents of the register concerned. |
|
79 |
|
80 @param aAddr The address of the register to be written. |
|
81 @param aValue The new value to be written to the register. |
|
82 @pre Can be called in any context. |
|
83 */ |
|
84 static inline void Write16(TLinAddr aAddr, TUint16 aValue) |
|
85 { *(volatile TUint16*)aAddr = aValue; } |
|
86 |
|
87 /** |
|
88 Modify the contents of a 16-bit register. |
|
89 |
|
90 @param aAddr The address of the register to be modified. |
|
91 @param aClearMask A mask of the bits to be cleared in the register. |
|
92 @param aSetMask A mask of the bits to be set in the register after the clear. |
|
93 @pre Can be called in any context. |
|
94 */ |
|
95 IMPORT_C static void Modify16(TLinAddr aAddr, TUint16 aClearMask, TUint16 aSetMask); |
|
96 |
|
97 /** |
|
98 Return the contents of a 32-bit register. |
|
99 |
|
100 @param aAddr The address of the register to be read. |
|
101 @return The contents of the register. |
|
102 @pre Can be called in any context. |
|
103 */ |
|
104 static inline TUint32 Read32(TLinAddr aAddr) |
|
105 { return *(volatile TUint32*)aAddr; } |
|
106 |
|
107 /** |
|
108 Store a new value in a 32-bit register. This will change |
|
109 the entire contents of the register concerned. |
|
110 |
|
111 @param aAddr The address of the register to be written. |
|
112 @param aValue The new value to be written to the register. |
|
113 @pre Can be called in any context. |
|
114 */ |
|
115 static inline void Write32(TLinAddr aAddr, TUint32 aValue) |
|
116 { *(volatile TUint32*)aAddr = aValue; } |
|
117 |
|
118 /** |
|
119 Modify the contents of a 32-bit register. |
|
120 |
|
121 @param aAddr The address of the register to be modified. |
|
122 @param aClearMask A mask of the bits to be cleared in the register. |
|
123 @param aSetMask A mask of the bits to be set in the register after the clear. |
|
124 @pre Can be called in any context. |
|
125 */ |
|
126 IMPORT_C static void Modify32(TLinAddr aAddr, TUint32 aClearMask, TUint32 aSetMask); |
|
127 |
|
128 /** |
|
129 Return the contents of a 64-bit register. |
|
130 |
|
131 @param aAddr The address of the register to be read. |
|
132 @return The contents of the register. |
|
133 @pre Can be called in any context. |
|
134 */ |
|
135 IMPORT_C static TUint64 Read64(TLinAddr aAddr); |
|
136 |
|
137 /** |
|
138 Store a new value in a 64-bit register. This will change |
|
139 the entire contents of the register concerned. |
|
140 |
|
141 @param aAddr The address of the register to be written. |
|
142 @param aValue The new value to be written to the register. |
|
143 @pre Can be called in any context. |
|
144 */ |
|
145 IMPORT_C static void Write64(TLinAddr aAddr, TUint64 aValue); |
|
146 |
|
147 /** |
|
148 Modify the contents of a 64-bit register. |
|
149 |
|
150 @param aAddr The address of the register to be modified. |
|
151 @param aClearMask A mask of the bits to be cleared in the register. |
|
152 @param aSetMask A mask of the bits to be set in the register after the clear. |
|
153 @pre Can be called in any context. |
|
154 */ |
|
155 IMPORT_C static void Modify64(TLinAddr aAddr, TUint64 aClearMask, TUint64 aSetMask); |
|
156 }; |
|
157 |
|
158 #endif |