1 | /** @file
|
---|
2 | Unaligned port I/O. This file has compiler specifics for Microsoft C as there
|
---|
3 | is no ANSI C standard for doing IO.
|
---|
4 |
|
---|
5 | Based on IoLibMsc.c
|
---|
6 |
|
---|
7 | Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
|
---|
8 | This program and the accompanying materials are licensed and made available
|
---|
9 | under the terms and conditions of the BSD License which accompanies this
|
---|
10 | distribution. The full text of the license may be found at
|
---|
11 | http://opensource.org/licenses/bsd-license.php.
|
---|
12 |
|
---|
13 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
---|
14 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
---|
15 |
|
---|
16 | **/
|
---|
17 |
|
---|
18 |
|
---|
19 | #include "UnalignedIoInternal.h"
|
---|
20 |
|
---|
21 | unsigned long _inpd (unsigned short port);
|
---|
22 | unsigned long _outpd (unsigned short port, unsigned long dataword );
|
---|
23 | void _ReadWriteBarrier (void);
|
---|
24 |
|
---|
25 | /**
|
---|
26 | Performs a 32-bit write to the specified, possibly unaligned I/O-type
|
---|
27 | address.
|
---|
28 |
|
---|
29 | Writes the 32-bit I/O port specified by Port with the value specified by
|
---|
30 | Value and returns Value. This function must guarantee that all I/O read and
|
---|
31 | write operations are serialized.
|
---|
32 |
|
---|
33 | If 32-bit unaligned I/O port operations are not supported, then ASSERT().
|
---|
34 |
|
---|
35 | @param[in] Port I/O port address
|
---|
36 | @param[in] Value 32-bit word to write
|
---|
37 |
|
---|
38 | @return The value written to the I/O port.
|
---|
39 |
|
---|
40 | **/
|
---|
41 | UINT32
|
---|
42 | UnalignedIoWrite32 (
|
---|
43 | IN UINTN Port,
|
---|
44 | IN UINT32 Value
|
---|
45 | )
|
---|
46 | {
|
---|
47 | _ReadWriteBarrier ();
|
---|
48 | _outpd ((UINT16)Port, Value);
|
---|
49 | _ReadWriteBarrier ();
|
---|
50 | return Value;
|
---|
51 | }
|
---|
52 |
|
---|
53 | /**
|
---|
54 | Reads a 32-bit word from the specified, possibly unaligned I/O-type address.
|
---|
55 |
|
---|
56 | Reads the 32-bit I/O port specified by Port. The 32-bit read value is
|
---|
57 | returned. This function must guarantee that all I/O read and write operations
|
---|
58 | are serialized.
|
---|
59 |
|
---|
60 | If 32-bit unaligned I/O port operations are not supported, then ASSERT().
|
---|
61 |
|
---|
62 | @param[in] Port The I/O port to read.
|
---|
63 |
|
---|
64 | @return The value read.
|
---|
65 |
|
---|
66 | **/
|
---|
67 | UINT32
|
---|
68 | UnalignedIoRead32 (
|
---|
69 | IN UINTN Port
|
---|
70 | )
|
---|
71 | {
|
---|
72 | UINT32 Value;
|
---|
73 |
|
---|
74 | _ReadWriteBarrier ();
|
---|
75 | Value = _inpd ((UINT16)Port);
|
---|
76 | _ReadWriteBarrier ();
|
---|
77 | return Value;
|
---|
78 | }
|
---|