2007-09-19 08:15:43 +02:00
|
|
|
/** @file
|
|
|
|
I/O Library. This file has compiler specifics for ICC as there
|
|
|
|
is no ANSI C standard for doing IO.
|
|
|
|
|
2008-09-11 10:59:52 +02:00
|
|
|
Copyright (c) 2006 - 2008, Intel Corporation<BR> All rights
|
2007-09-19 08:15:43 +02:00
|
|
|
reserved. This program and the accompanying materials are
|
|
|
|
licensed and made available under the terms and conditions of the BSD License
|
|
|
|
which accompanies this distribution. The full text of the license may be found at
|
|
|
|
http://opensource.org/licenses/bsd-license.php
|
|
|
|
|
|
|
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
#include "BaseIoLibIntrinsicInternal.h"
|
|
|
|
|
|
|
|
/**
|
|
|
|
Reads an 8-bit I/O port.
|
|
|
|
|
|
|
|
Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned.
|
|
|
|
This function must guarantee that all I/O read and write operations are
|
|
|
|
serialized.
|
|
|
|
|
|
|
|
If 8-bit I/O port operations are not supported, then ASSERT().
|
|
|
|
|
|
|
|
@param Port The I/O port to read.
|
|
|
|
|
2008-12-10 07:13:43 +01:00
|
|
|
@return The value read.
|
2007-09-19 08:15:43 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
UINT8
|
|
|
|
EFIAPI
|
|
|
|
IoRead8 (
|
|
|
|
IN UINTN Port
|
|
|
|
)
|
|
|
|
{
|
|
|
|
UINT8 Data;
|
|
|
|
|
|
|
|
__asm {
|
|
|
|
mov dx, word ptr [Port]
|
|
|
|
in al, dx
|
|
|
|
|
|
|
|
mov Data, al
|
|
|
|
}
|
|
|
|
return Data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Writes an 8-bit I/O port.
|
|
|
|
|
|
|
|
Writes the 8-bit I/O port specified by Port with the value specified by Value
|
|
|
|
and returns Value. This function must guarantee that all I/O read and write
|
|
|
|
operations are serialized.
|
|
|
|
|
|
|
|
If 8-bit I/O port operations are not supported, then ASSERT().
|
|
|
|
|
|
|
|
@param Port The I/O port to write.
|
|
|
|
@param Value The value to write to the I/O port.
|
|
|
|
|
2008-12-10 07:13:43 +01:00
|
|
|
@return The value written the I/O port.
|
2007-09-19 08:15:43 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
UINT8
|
|
|
|
EFIAPI
|
|
|
|
IoWrite8 (
|
|
|
|
IN UINTN Port,
|
|
|
|
IN UINT8 Value
|
|
|
|
)
|
|
|
|
{
|
|
|
|
__asm {
|
|
|
|
mov al, byte ptr [Value]
|
|
|
|
mov dx, word ptr [Port]
|
|
|
|
out dx, al
|
|
|
|
}
|
|
|
|
return Value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Reads a 16-bit I/O port.
|
|
|
|
|
|
|
|
Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned.
|
|
|
|
This function must guarantee that all I/O read and write operations are
|
|
|
|
serialized.
|
|
|
|
|
|
|
|
If 16-bit I/O port operations are not supported, then ASSERT().
|
2008-12-10 07:13:43 +01:00
|
|
|
If Port is not aligned on a 16-bit boundary, then ASSERT().
|
2007-09-19 08:15:43 +02:00
|
|
|
|
|
|
|
@param Port The I/O port to read.
|
|
|
|
|
2008-12-10 07:13:43 +01:00
|
|
|
@return The value read.
|
2007-09-19 08:15:43 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
UINT16
|
|
|
|
EFIAPI
|
|
|
|
IoRead16 (
|
|
|
|
IN UINTN Port
|
|
|
|
)
|
|
|
|
{
|
|
|
|
UINT16 Data;
|
|
|
|
|
|
|
|
ASSERT ((Port & 1) == 0);
|
|
|
|
|
|
|
|
__asm {
|
|
|
|
mov dx, word ptr [Port]
|
|
|
|
in ax, dx
|
|
|
|
mov word ptr [Data], ax
|
|
|
|
}
|
|
|
|
|
|
|
|
return Data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Writes a 16-bit I/O port.
|
|
|
|
|
|
|
|
Writes the 16-bit I/O port specified by Port with the value specified by Value
|
|
|
|
and returns Value. This function must guarantee that all I/O read and write
|
|
|
|
operations are serialized.
|
|
|
|
|
|
|
|
If 16-bit I/O port operations are not supported, then ASSERT().
|
2008-12-10 07:13:43 +01:00
|
|
|
If Port is not aligned on a 16-bit boundary, then ASSERT().
|
|
|
|
|
2007-09-19 08:15:43 +02:00
|
|
|
@param Port The I/O port to write.
|
|
|
|
@param Value The value to write to the I/O port.
|
|
|
|
|
2008-12-10 07:13:43 +01:00
|
|
|
@return The value written the I/O port.
|
2007-09-19 08:15:43 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
UINT16
|
|
|
|
EFIAPI
|
|
|
|
IoWrite16 (
|
|
|
|
IN UINTN Port,
|
|
|
|
IN UINT16 Value
|
|
|
|
)
|
|
|
|
{
|
|
|
|
ASSERT ((Port & 1) == 0);
|
|
|
|
|
|
|
|
__asm {
|
|
|
|
mov ax, word ptr [Value]
|
|
|
|
mov dx, word ptr [Port]
|
|
|
|
out dx, ax
|
|
|
|
}
|
|
|
|
|
|
|
|
return Value;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Reads a 32-bit I/O port.
|
|
|
|
|
|
|
|
Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned.
|
|
|
|
This function must guarantee that all I/O read and write operations are
|
|
|
|
serialized.
|
|
|
|
|
|
|
|
If 32-bit I/O port operations are not supported, then ASSERT().
|
2008-12-10 07:13:43 +01:00
|
|
|
If Port is not aligned on a 32-bit boundary, then ASSERT().
|
|
|
|
|
2007-09-19 08:15:43 +02:00
|
|
|
@param Port The I/O port to read.
|
|
|
|
|
2008-12-10 07:13:43 +01:00
|
|
|
@return The value read.
|
2007-09-19 08:15:43 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
UINT32
|
|
|
|
EFIAPI
|
|
|
|
IoRead32 (
|
|
|
|
IN UINTN Port
|
|
|
|
)
|
|
|
|
{
|
|
|
|
UINT32 Data;
|
|
|
|
|
|
|
|
ASSERT ((Port & 3) == 0);
|
|
|
|
|
|
|
|
__asm {
|
|
|
|
mov dx, word ptr [Port]
|
|
|
|
in eax, dx
|
|
|
|
mov dword ptr [Data], eax
|
|
|
|
}
|
|
|
|
|
|
|
|
return Data;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Writes a 32-bit I/O port.
|
|
|
|
|
|
|
|
Writes the 32-bit I/O port specified by Port with the value specified by Value
|
|
|
|
and returns Value. This function must guarantee that all I/O read and write
|
|
|
|
operations are serialized.
|
|
|
|
|
|
|
|
If 32-bit I/O port operations are not supported, then ASSERT().
|
2008-12-10 07:13:43 +01:00
|
|
|
If Port is not aligned on a 32-bit boundary, then ASSERT().
|
|
|
|
|
2007-09-19 08:15:43 +02:00
|
|
|
@param Port The I/O port to write.
|
|
|
|
@param Value The value to write to the I/O port.
|
|
|
|
|
2008-12-10 07:13:43 +01:00
|
|
|
@return The value written the I/O port.
|
2007-09-19 08:15:43 +02:00
|
|
|
|
|
|
|
**/
|
|
|
|
UINT32
|
|
|
|
EFIAPI
|
|
|
|
IoWrite32 (
|
2008-12-10 07:13:43 +01:00
|
|
|
IN UINTN Port,
|
|
|
|
IN UINT32 Value
|
2007-09-19 08:15:43 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
ASSERT ((Port & 3) == 0);
|
|
|
|
|
|
|
|
__asm {
|
|
|
|
mov eax, dword ptr [Value]
|
|
|
|
mov dx, word ptr [Port]
|
|
|
|
out dx, eax
|
|
|
|
}
|
|
|
|
|
|
|
|
return Value;
|
|
|
|
}
|
|
|
|
|