]>
Commit | Line | Data |
---|---|---|
878ddf1f | 1 | /** @file\r |
2 | I/O Library. This file has compiler specifics for Microsft C as there is no\r | |
3 | ANSI C standard for doing IO.\r | |
4 | \r | |
5 | MSC - uses intrinsic functions and the optimize will remove the function call\r | |
6 | overhead.\r | |
7 | \r | |
8 | We don't advocate putting compiler specifics in libraries or drivers but there\r | |
9 | is no other way to make this work.\r | |
10 | \r | |
11 | Copyright (c) 2006, Intel Corporation<BR>\r | |
12 | All rights reserved. This program and the accompanying materials\r | |
13 | are licensed and made available under the terms and conditions of the BSD License\r | |
14 | which accompanies this distribution. The full text of the license may be found at\r | |
15 | http://opensource.org/licenses/bsd-license.php\r | |
16 | \r | |
17 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
18 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
19 | \r | |
20 | Module Name: IoLibMsc.c\r | |
21 | \r | |
22 | **/\r | |
23 | \r | |
24 | \r | |
25 | #if _MSC_EXTENSIONS\r | |
26 | \r | |
27 | //\r | |
28 | // Microsoft Visual Studio 7.1 Function Prototypes for I/O Intrinsics\r | |
29 | //\r | |
30 | int _inp (unsigned short port);\r | |
31 | unsigned short _inpw (unsigned short port);\r | |
32 | unsigned long _inpd (unsigned short port);\r | |
33 | int _outp (unsigned short port, int databyte );\r | |
34 | unsigned short _outpw(unsigned short port, unsigned short dataword );\r | |
35 | unsigned long _outpd(unsigned short port, unsigned long dataword );\r | |
36 | \r | |
37 | #pragma intrinsic(_inp)\r | |
38 | #pragma intrinsic(_inpw)\r | |
39 | #pragma intrinsic(_inpd)\r | |
40 | #pragma intrinsic(_outp)\r | |
41 | #pragma intrinsic(_outpw)\r | |
42 | #pragma intrinsic(_outpd)\r | |
43 | \r | |
44 | \r | |
45 | /**\r | |
46 | Reads an 8-bit I/O port.\r | |
47 | \r | |
48 | Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned.\r | |
49 | This function must guarantee that all I/O read and write operations are\r | |
50 | serialized.\r | |
51 | \r | |
52 | If 8-bit I/O port operations are not supported, then ASSERT().\r | |
53 | \r | |
54 | @param Port The I/O port to read.\r | |
55 | \r | |
56 | @return The value read.\r | |
57 | \r | |
58 | **/\r | |
59 | UINT8\r | |
60 | EFIAPI\r | |
61 | IoRead8 (\r | |
62 | IN UINTN Port\r | |
63 | )\r | |
64 | {\r | |
65 | return (UINT8)_inp ((UINT16)Port);\r | |
66 | }\r | |
67 | \r | |
68 | /**\r | |
69 | Writes an 8-bit I/O port.\r | |
70 | \r | |
71 | Writes the 8-bit I/O port specified by Port with the value specified by Value\r | |
72 | and returns Value. This function must guarantee that all I/O read and write\r | |
73 | operations are serialized.\r | |
74 | \r | |
75 | If 8-bit I/O port operations are not supported, then ASSERT().\r | |
76 | \r | |
77 | @param Port The I/O port to write.\r | |
78 | @param Value The value to write to the I/O port.\r | |
79 | \r | |
80 | @return The value written the I/O port.\r | |
81 | \r | |
82 | **/\r | |
83 | UINT8\r | |
84 | EFIAPI\r | |
85 | IoWrite8 (\r | |
86 | IN UINTN Port,\r | |
87 | IN UINT8 Value\r | |
88 | )\r | |
89 | {\r | |
90 | return (UINT8)_outp ((UINT16)Port, Value);\r | |
91 | }\r | |
92 | \r | |
93 | /**\r | |
94 | Reads a 16-bit I/O port.\r | |
95 | \r | |
96 | Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned.\r | |
97 | This function must guarantee that all I/O read and write operations are\r | |
98 | serialized.\r | |
99 | \r | |
100 | If 16-bit I/O port operations are not supported, then ASSERT().\r | |
101 | \r | |
102 | @param Port The I/O port to read.\r | |
103 | \r | |
104 | @return The value read.\r | |
105 | \r | |
106 | **/\r | |
107 | UINT16\r | |
108 | EFIAPI\r | |
109 | IoRead16 (\r | |
110 | IN UINTN Port\r | |
111 | )\r | |
112 | {\r | |
113 | ASSERT ((Port & 1) == 0);\r | |
114 | return _inpw((UINT16)Port);\r | |
115 | }\r | |
116 | \r | |
117 | /**\r | |
118 | Writes a 16-bit I/O port.\r | |
119 | \r | |
120 | Writes the 16-bit I/O port specified by Port with the value specified by Value\r | |
121 | and returns Value. This function must guarantee that all I/O read and write\r | |
122 | operations are serialized.\r | |
123 | \r | |
124 | If 16-bit I/O port operations are not supported, then ASSERT().\r | |
125 | \r | |
126 | @param Port The I/O port to write.\r | |
127 | @param Value The value to write to the I/O port.\r | |
128 | \r | |
129 | @return The value written the I/O port.\r | |
130 | \r | |
131 | **/\r | |
132 | UINT16\r | |
133 | EFIAPI\r | |
134 | IoWrite16 (\r | |
135 | IN UINTN Port,\r | |
136 | IN UINT16 Value\r | |
137 | )\r | |
138 | {\r | |
139 | ASSERT ((Port & 1) == 0);\r | |
140 | return _outpw ((UINT16)Port, Value);\r | |
141 | }\r | |
142 | \r | |
143 | /**\r | |
144 | Reads a 32-bit I/O port.\r | |
145 | \r | |
146 | Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned.\r | |
147 | This function must guarantee that all I/O read and write operations are\r | |
148 | serialized.\r | |
149 | \r | |
150 | If 32-bit I/O port operations are not supported, then ASSERT().\r | |
151 | \r | |
152 | @param Port The I/O port to read.\r | |
153 | \r | |
154 | @return The value read.\r | |
155 | \r | |
156 | **/\r | |
157 | UINT32\r | |
158 | EFIAPI\r | |
159 | IoRead32 (\r | |
160 | IN UINTN Port\r | |
161 | )\r | |
162 | {\r | |
163 | ASSERT ((Port & 3) == 0);\r | |
164 | return _inpd((UINT16)Port);\r | |
165 | }\r | |
166 | \r | |
167 | /**\r | |
168 | Writes a 32-bit I/O port.\r | |
169 | \r | |
170 | Writes the 32-bit I/O port specified by Port with the value specified by Value\r | |
171 | and returns Value. This function must guarantee that all I/O read and write\r | |
172 | operations are serialized.\r | |
173 | \r | |
174 | If 32-bit I/O port operations are not supported, then ASSERT().\r | |
175 | \r | |
176 | @param Port The I/O port to write.\r | |
177 | @param Value The value to write to the I/O port.\r | |
178 | \r | |
179 | @return The value written the I/O port.\r | |
180 | \r | |
181 | **/\r | |
182 | UINT32\r | |
183 | EFIAPI\r | |
184 | IoWrite32 (\r | |
185 | IN UINTN Port,\r | |
186 | IN UINT32 Value\r | |
187 | )\r | |
188 | {\r | |
189 | ASSERT ((Port & 3) == 0);\r | |
190 | return _outpd ((UINT16)Port, Value);\r | |
191 | }\r | |
192 | \r | |
193 | #endif\r |