]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | /** @file\r |
2 | Common I/O Library routines.\r | |
3 | \r | |
4 | Copyright (c) 2006, Intel Corporation<BR>\r | |
5 | All rights reserved. This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
12 | \r | |
13 | Module Name: IoLib.c\r | |
14 | \r | |
15 | **/\r | |
16 | \r | |
17 | /**\r | |
18 | Reads a 64-bit I/O port.\r | |
19 | \r | |
20 | Reads the 64-bit I/O port specified by Port. The 64-bit read value is returned.\r | |
21 | This function must guarantee that all I/O read and write operations are\r | |
22 | serialized.\r | |
23 | \r | |
24 | If 64-bit I/O port operations are not supported, then ASSERT().\r | |
25 | \r | |
26 | @param Port The I/O port to read.\r | |
27 | \r | |
28 | @return The value read.\r | |
29 | \r | |
30 | **/\r | |
31 | UINT64\r | |
32 | EFIAPI\r | |
33 | IoRead64 (\r | |
34 | IN UINTN Port\r | |
35 | )\r | |
36 | {\r | |
37 | ASSERT (FALSE);\r | |
38 | return 0;\r | |
39 | }\r | |
40 | \r | |
41 | /**\r | |
42 | Writes a 64-bit I/O port.\r | |
43 | \r | |
44 | Writes the 64-bit I/O port specified by Port with the value specified by Value\r | |
45 | and returns Value. This function must guarantee that all I/O read and write\r | |
46 | operations are serialized.\r | |
47 | \r | |
48 | If 64-bit I/O port operations are not supported, then ASSERT().\r | |
49 | \r | |
50 | @param Port The I/O port to write.\r | |
51 | @param Value The value to write to the I/O port.\r | |
52 | \r | |
53 | @return The value written the I/O port.\r | |
54 | \r | |
55 | **/\r | |
56 | UINT64\r | |
57 | EFIAPI\r | |
58 | IoWrite64 (\r | |
59 | IN UINTN Port,\r | |
60 | IN UINT64 Value\r | |
61 | )\r | |
62 | {\r | |
63 | ASSERT (FALSE);\r | |
64 | return 0;\r | |
65 | }\r | |
66 | \r | |
67 | /**\r | |
68 | Reads an 8-bit MMIO register.\r | |
69 | \r | |
70 | Reads the 8-bit MMIO register specified by Address. The 8-bit read value is\r | |
71 | returned. This function must guarantee that all MMIO read and write\r | |
72 | operations are serialized.\r | |
73 | \r | |
74 | If 8-bit MMIO register operations are not supported, then ASSERT().\r | |
75 | \r | |
76 | @param Address The MMIO register to read.\r | |
77 | \r | |
78 | @return The value read.\r | |
79 | \r | |
80 | **/\r | |
81 | UINT8\r | |
82 | EFIAPI\r | |
83 | MmioRead8 (\r | |
84 | IN UINTN Address\r | |
85 | )\r | |
86 | {\r | |
87 | return *(volatile UINT8*)Address;\r | |
88 | }\r | |
89 | \r | |
90 | /**\r | |
91 | Writes an 8-bit MMIO register.\r | |
92 | \r | |
93 | Writes the 8-bit MMIO register specified by Address with the value specified\r | |
94 | by Value and returns Value. This function must guarantee that all MMIO read\r | |
95 | and write operations are serialized.\r | |
96 | \r | |
97 | If 8-bit MMIO register operations are not supported, then ASSERT().\r | |
98 | \r | |
99 | @param Address The MMIO register to write.\r | |
100 | @param Value The value to write to the MMIO register.\r | |
101 | \r | |
102 | **/\r | |
103 | UINT8\r | |
104 | EFIAPI\r | |
105 | MmioWrite8 (\r | |
106 | IN UINTN Address,\r | |
107 | IN UINT8 Value\r | |
108 | )\r | |
109 | {\r | |
110 | return *(volatile UINT8*)Address = Value;\r | |
111 | }\r | |
112 | \r | |
113 | /**\r | |
114 | Reads a 16-bit MMIO register.\r | |
115 | \r | |
116 | Reads the 16-bit MMIO register specified by Address. The 16-bit read value is\r | |
117 | returned. This function must guarantee that all MMIO read and write\r | |
118 | operations are serialized.\r | |
119 | \r | |
120 | If 16-bit MMIO register operations are not supported, then ASSERT().\r | |
121 | \r | |
122 | @param Address The MMIO register to read.\r | |
123 | \r | |
124 | @return The value read.\r | |
125 | \r | |
126 | **/\r | |
127 | UINT16\r | |
128 | EFIAPI\r | |
129 | MmioRead16 (\r | |
130 | IN UINTN Address\r | |
131 | )\r | |
132 | {\r | |
133 | ASSERT ((Address & 1) == 0);\r | |
134 | return *(volatile UINT16*)Address;\r | |
135 | }\r | |
136 | \r | |
137 | /**\r | |
138 | Writes a 16-bit MMIO register.\r | |
139 | \r | |
140 | Writes the 16-bit MMIO register specified by Address with the value specified\r | |
141 | by Value and returns Value. This function must guarantee that all MMIO read\r | |
142 | and write operations are serialized.\r | |
143 | \r | |
144 | If 16-bit MMIO register operations are not supported, then ASSERT().\r | |
145 | \r | |
146 | @param Address The MMIO register to write.\r | |
147 | @param Value The value to write to the MMIO register.\r | |
148 | \r | |
149 | **/\r | |
150 | UINT16\r | |
151 | EFIAPI\r | |
152 | MmioWrite16 (\r | |
153 | IN UINTN Address,\r | |
154 | IN UINT16 Value\r | |
155 | )\r | |
156 | {\r | |
157 | ASSERT ((Address & 1) == 0);\r | |
158 | return *(volatile UINT16*)Address = Value;\r | |
159 | }\r | |
160 | \r | |
161 | /**\r | |
162 | Reads a 32-bit MMIO register.\r | |
163 | \r | |
164 | Reads the 32-bit MMIO register specified by Address. The 32-bit read value is\r | |
165 | returned. This function must guarantee that all MMIO read and write\r | |
166 | operations are serialized.\r | |
167 | \r | |
168 | If 32-bit MMIO register operations are not supported, then ASSERT().\r | |
169 | \r | |
170 | @param Address The MMIO register to read.\r | |
171 | \r | |
172 | @return The value read.\r | |
173 | \r | |
174 | **/\r | |
175 | UINT32\r | |
176 | EFIAPI\r | |
177 | MmioRead32 (\r | |
178 | IN UINTN Address\r | |
179 | )\r | |
180 | {\r | |
181 | ASSERT ((Address & 3) == 0);\r | |
182 | return *(volatile UINT32*)Address;\r | |
183 | }\r | |
184 | \r | |
185 | /**\r | |
186 | Writes a 32-bit MMIO register.\r | |
187 | \r | |
188 | Writes the 32-bit MMIO register specified by Address with the value specified\r | |
189 | by Value and returns Value. This function must guarantee that all MMIO read\r | |
190 | and write operations are serialized.\r | |
191 | \r | |
192 | If 32-bit MMIO register operations are not supported, then ASSERT().\r | |
193 | \r | |
194 | @param Address The MMIO register to write.\r | |
195 | @param Value The value to write to the MMIO register.\r | |
196 | \r | |
197 | **/\r | |
198 | UINT32\r | |
199 | EFIAPI\r | |
200 | MmioWrite32 (\r | |
201 | IN UINTN Address,\r | |
202 | IN UINT32 Value\r | |
203 | )\r | |
204 | {\r | |
205 | ASSERT ((Address & 3) == 0);\r | |
206 | return *(volatile UINT32*)Address = Value;\r | |
207 | }\r | |
208 | \r | |
209 | /**\r | |
210 | Reads a 64-bit MMIO register.\r | |
211 | \r | |
212 | Reads the 64-bit MMIO register specified by Address. The 64-bit read value is\r | |
213 | returned. This function must guarantee that all MMIO read and write\r | |
214 | operations are serialized.\r | |
215 | \r | |
216 | If 64-bit MMIO register operations are not supported, then ASSERT().\r | |
217 | \r | |
218 | @param Address The MMIO register to read.\r | |
219 | \r | |
220 | @return The value read.\r | |
221 | \r | |
222 | **/\r | |
223 | UINT64\r | |
224 | EFIAPI\r | |
225 | MmioRead64 (\r | |
226 | IN UINTN Address\r | |
227 | )\r | |
228 | {\r | |
229 | ASSERT ((Address & 7) == 0);\r | |
230 | return *(volatile UINT64*)Address;\r | |
231 | }\r | |
232 | \r | |
233 | /**\r | |
234 | Writes a 64-bit MMIO register.\r | |
235 | \r | |
236 | Writes the 64-bit MMIO register specified by Address with the value specified\r | |
237 | by Value and returns Value. This function must guarantee that all MMIO read\r | |
238 | and write operations are serialized.\r | |
239 | \r | |
240 | If 64-bit MMIO register operations are not supported, then ASSERT().\r | |
241 | \r | |
242 | @param Address The MMIO register to write.\r | |
243 | @param Value The value to write to the MMIO register.\r | |
244 | \r | |
245 | **/\r | |
246 | UINT64\r | |
247 | EFIAPI\r | |
248 | MmioWrite64 (\r | |
249 | IN UINTN Address,\r | |
250 | IN UINT64 Value\r | |
251 | )\r | |
252 | {\r | |
253 | ASSERT ((Address & 7) == 0);\r | |
254 | return *(volatile UINT64*)Address = Value;\r | |
255 | }\r |