-/** @file\r
- I/O Library. This file has compiler specifics for ICC as there\r
- is no ANSI C standard for doing IO.\r
-\r
- Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
- SPDX-License-Identifier: BSD-2-Clause-Patent\r
-\r
-**/\r
-\r
-#include "BaseIoLibIntrinsicInternal.h"\r
-\r
-/**\r
- Reads an 8-bit I/O port.\r
-\r
- Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned.\r
- This function must guarantee that all I/O read and write operations are\r
- serialized.\r
-\r
- If 8-bit I/O port operations are not supported, then ASSERT().\r
-\r
- @param Port The I/O port to read.\r
-\r
- @return The value read.\r
-\r
-**/\r
-UINT8\r
-EFIAPI\r
-IoRead8 (\r
- IN UINTN Port\r
- )\r
-{\r
- UINT8 Data;\r
-\r
- __asm {\r
- mov dx, word ptr [Port]\r
- in al, dx\r
-\r
- mov Data, al\r
- }\r
- return Data;\r
-}\r
-\r
-/**\r
- Writes an 8-bit I/O port.\r
-\r
- Writes the 8-bit I/O port specified by Port with the value specified by Value\r
- and returns Value. This function must guarantee that all I/O read and write\r
- operations are serialized.\r
-\r
- If 8-bit I/O port operations are not supported, then ASSERT().\r
-\r
- @param Port The I/O port to write.\r
- @param Value The value to write to the I/O port.\r
-\r
- @return The value written the I/O port.\r
-\r
-**/\r
-UINT8\r
-EFIAPI\r
-IoWrite8 (\r
- IN UINTN Port,\r
- IN UINT8 Value\r
- )\r
-{\r
- __asm {\r
- mov al, byte ptr [Value]\r
- mov dx, word ptr [Port]\r
- out dx, al\r
- }\r
- return Value;\r
-}\r
-\r
-/**\r
- Reads a 16-bit I/O port.\r
-\r
- Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned.\r
- This function must guarantee that all I/O read and write operations are\r
- serialized.\r
-\r
- If 16-bit I/O port operations are not supported, then ASSERT().\r
- If Port is not aligned on a 16-bit boundary, then ASSERT().\r
-\r
- @param Port The I/O port to read.\r
-\r
- @return The value read.\r
-\r
-**/\r
-UINT16\r
-EFIAPI\r
-IoRead16 (\r
- IN UINTN Port\r
- )\r
-{\r
- UINT16 Data;\r
-\r
- ASSERT ((Port & 1) == 0);\r
-\r
- __asm {\r
- mov dx, word ptr [Port]\r
- in ax, dx\r
- mov word ptr [Data], ax\r
- }\r
-\r
- return Data;\r
-}\r
-\r
-/**\r
- Writes a 16-bit I/O port.\r
-\r
- Writes the 16-bit I/O port specified by Port with the value specified by Value\r
- and returns Value. This function must guarantee that all I/O read and write\r
- operations are serialized.\r
-\r
- If 16-bit I/O port operations are not supported, then ASSERT().\r
- If Port is not aligned on a 16-bit boundary, then ASSERT().\r
-\r
- @param Port The I/O port to write.\r
- @param Value The value to write to the I/O port.\r
-\r
- @return The value written the I/O port.\r
-\r
-**/\r
-UINT16\r
-EFIAPI\r
-IoWrite16 (\r
- IN UINTN Port,\r
- IN UINT16 Value\r
- )\r
-{\r
- ASSERT ((Port & 1) == 0);\r
-\r
- __asm {\r
- mov ax, word ptr [Value]\r
- mov dx, word ptr [Port]\r
- out dx, ax\r
- }\r
-\r
- return Value;\r
-}\r
-\r
-/**\r
- Reads a 32-bit I/O port.\r
-\r
- Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned.\r
- This function must guarantee that all I/O read and write operations are\r
- serialized.\r
-\r
- If 32-bit I/O port operations are not supported, then ASSERT().\r
- If Port is not aligned on a 32-bit boundary, then ASSERT().\r
-\r
- @param Port The I/O port to read.\r
-\r
- @return The value read.\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-IoRead32 (\r
- IN UINTN Port\r
- )\r
-{\r
- UINT32 Data;\r
-\r
- ASSERT ((Port & 3) == 0);\r
-\r
- __asm {\r
- mov dx, word ptr [Port]\r
- in eax, dx\r
- mov dword ptr [Data], eax\r
- }\r
-\r
- return Data;\r
-}\r
-\r
-/**\r
- Writes a 32-bit I/O port.\r
-\r
- Writes the 32-bit I/O port specified by Port with the value specified by Value\r
- and returns Value. This function must guarantee that all I/O read and write\r
- operations are serialized.\r
-\r
- If 32-bit I/O port operations are not supported, then ASSERT().\r
- If Port is not aligned on a 32-bit boundary, then ASSERT().\r
-\r
- @param Port The I/O port to write.\r
- @param Value The value to write to the I/O port.\r
-\r
- @return The value written the I/O port.\r
-\r
-**/\r
-UINT32\r
-EFIAPI\r
-IoWrite32 (\r
- IN UINTN Port,\r
- IN UINT32 Value\r
- )\r
-{\r
- ASSERT ((Port & 3) == 0);\r
-\r
- __asm {\r
- mov eax, dword ptr [Value]\r
- mov dx, word ptr [Port]\r
- out dx, eax\r
- }\r
-\r
- return Value;\r
-}\r
-\r