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