2 I/O Library. This file has compiler specifics for Microsft C as there is no
3 ANSI C standard for doing IO.
5 MSC - uses intrinsic functions and the optimize will remove the function call
8 We don't advocate putting compiler specifics in libraries or drivers but there
9 is no other way to make this work.
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
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.
20 Module Name: IoLibMsc.c
28 // Microsoft Visual Studio 7.1 Function Prototypes for I/O Intrinsics
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
);
37 #pragma intrinsic(_inp)
38 #pragma intrinsic(_inpw)
39 #pragma intrinsic(_inpd)
40 #pragma intrinsic(_outp)
41 #pragma intrinsic(_outpw)
42 #pragma intrinsic(_outpd)
46 Reads an 8-bit I/O port.
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
52 If 8-bit I/O port operations are not supported, then ASSERT().
54 @param Port The I/O port to read.
56 @return The value read.
65 return (UINT8
)_inp ((UINT16
)Port
);
69 Writes an 8-bit I/O port.
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.
75 If 8-bit I/O port operations are not supported, then ASSERT().
77 @param Port The I/O port to write.
78 @param Value The value to write to the I/O port.
80 @return The value written the I/O port.
90 return (UINT8
)_outp ((UINT16
)Port
, Value
);
94 Reads a 16-bit I/O port.
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
100 If 16-bit I/O port operations are not supported, then ASSERT().
102 @param Port The I/O port to read.
104 @return The value read.
113 ASSERT ((Port
& 1) == 0);
114 return _inpw((UINT16
)Port
);
118 Writes a 16-bit I/O port.
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.
124 If 16-bit I/O port operations are not supported, then ASSERT().
126 @param Port The I/O port to write.
127 @param Value The value to write to the I/O port.
129 @return The value written the I/O port.
139 ASSERT ((Port
& 1) == 0);
140 return _outpw ((UINT16
)Port
, Value
);
144 Reads a 32-bit I/O port.
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
150 If 32-bit I/O port operations are not supported, then ASSERT().
152 @param Port The I/O port to read.
154 @return The value read.
163 ASSERT ((Port
& 3) == 0);
164 return _inpd((UINT16
)Port
);
168 Writes a 32-bit I/O port.
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.
174 If 32-bit I/O port operations are not supported, then ASSERT().
176 @param Port The I/O port to write.
177 @param Value The value to write to the I/O port.
179 @return The value written the I/O port.
189 ASSERT ((Port
& 3) == 0);
190 return _outpd ((UINT16
)Port
, Value
);