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