UefiCpuPkg: Modify CpuIo2Dxe to use new IoLib library

The Fifo routines from the UefiCpuPkg/CpuIo2Dxe driver have been
moved to the new BaseIoLibIntrinsic (IoLib class) library.

Cc: Jeff Fan <jeff.fan@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Brijesh Singh <brijesh.singh@amd.com>
Signed-off-by: Leo Duran  <leo.duran@amd.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Jeff Fan <jeff.fan@intel.com>
This commit is contained in:
Leo Duran 2017-01-14 04:09:52 +08:00 committed by Liming Gao
parent 19c6d9feaa
commit 200b4223f0
7 changed files with 10 additions and 717 deletions

View File

@ -2,6 +2,8 @@
Produces the CPU I/O 2 Protocol.
Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>
Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
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
@ -13,7 +15,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "CpuIo2Dxe.h"
#include "IoFifo.h"
//
// Handle for the CPU I/O 2 Protocol
@ -412,7 +413,9 @@ CpuIoServiceRead (
OutStride = mOutStride[Width];
OperationWidth = (EFI_CPU_IO_PROTOCOL_WIDTH) (Width & 0x03);
#if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
//
// Fifo operations supported for (mInStride[Width] == 0)
//
if (InStride == 0) {
switch (OperationWidth) {
case EfiCpuIoWidthUint8:
@ -433,7 +436,6 @@ CpuIoServiceRead (
break;
}
}
#endif
for (Uint8Buffer = Buffer; Count > 0; Address += InStride, Uint8Buffer += OutStride, Count--) {
if (OperationWidth == EfiCpuIoWidthUint8) {
@ -518,7 +520,9 @@ CpuIoServiceWrite (
OutStride = mOutStride[Width];
OperationWidth = (EFI_CPU_IO_PROTOCOL_WIDTH) (Width & 0x03);
#if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
//
// Fifo operations supported for (mInStride[Width] == 0)
//
if (InStride == 0) {
switch (OperationWidth) {
case EfiCpuIoWidthUint8:
@ -539,7 +543,6 @@ CpuIoServiceWrite (
break;
}
}
#endif
for (Uint8Buffer = (UINT8 *)Buffer; Count > 0; Address += InStride, Uint8Buffer += OutStride, Count--) {
if (OperationWidth == EfiCpuIoWidthUint8) {

View File

@ -2,6 +2,8 @@
# Produces the CPU I/O 2 Protocol by using the services of the I/O Library.
#
# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
# Copyright (c) 2017, AMD Incorporated. All rights reserved.<BR>
#
# 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
@ -30,15 +32,6 @@
[Sources]
CpuIo2Dxe.c
CpuIo2Dxe.h
IoFifo.h
[Sources.IA32]
Ia32/IoFifo.nasm
Ia32/IoFifo.asm
[Sources.X64]
X64/IoFifo.nasm
X64/IoFifo.asm
[Packages]
MdePkg/MdePkg.dec

View File

@ -1,140 +0,0 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
;
; 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.
;
;------------------------------------------------------------------------------
.586P
.model flat,C
.code
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; IoReadFifo8 (
; IN UINTN Port,
; IN UINTN Size,
; IN VOID *Buffer
; );
;------------------------------------------------------------------------------
IoReadFifo8 PROC
push edi
cld
mov dx, [esp + 8]
mov ecx, [esp + 12]
mov edi, [esp + 16]
rep insb
pop edi
ret
IoReadFifo8 ENDP
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; IoReadFifo16 (
; IN UINTN Port,
; IN UINTN Size,
; IN VOID *Buffer
; );
;------------------------------------------------------------------------------
IoReadFifo16 PROC
push edi
cld
mov dx, [esp + 8]
mov ecx, [esp + 12]
mov edi, [esp + 16]
rep insw
pop edi
ret
IoReadFifo16 ENDP
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; IoReadFifo32 (
; IN UINTN Port,
; IN UINTN Size,
; IN VOID *Buffer
; );
;------------------------------------------------------------------------------
IoReadFifo32 PROC
push edi
cld
mov dx, [esp + 8]
mov ecx, [esp + 12]
mov edi, [esp + 16]
rep insd
pop edi
ret
IoReadFifo32 ENDP
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; IoWriteFifo8 (
; IN UINTN Port,
; IN UINTN Size,
; IN VOID *Buffer
; );
;------------------------------------------------------------------------------
IoWriteFifo8 PROC
push esi
cld
mov dx, [esp + 8]
mov ecx, [esp + 12]
mov esi, [esp + 16]
rep outsb
pop esi
ret
IoWriteFifo8 ENDP
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; IoWriteFifo16 (
; IN UINTN Port,
; IN UINTN Size,
; IN VOID *Buffer
; );
;------------------------------------------------------------------------------
IoWriteFifo16 PROC
push esi
cld
mov dx, [esp + 8]
mov ecx, [esp + 12]
mov esi, [esp + 16]
rep outsw
pop esi
ret
IoWriteFifo16 ENDP
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; IoWriteFifo32 (
; IN UINTN Port,
; IN UINTN Size,
; IN VOID *Buffer
; );
;------------------------------------------------------------------------------
IoWriteFifo32 PROC
push esi
cld
mov dx, [esp + 8]
mov ecx, [esp + 12]
mov esi, [esp + 16]
rep outsd
pop esi
ret
IoWriteFifo32 ENDP
END

View File

@ -1,136 +0,0 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
;
; 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.
;
;------------------------------------------------------------------------------
SECTION .text
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; IoReadFifo8 (
; IN UINTN Port,
; IN UINTN Size,
; IN VOID *Buffer
; );
;------------------------------------------------------------------------------
global ASM_PFX(IoReadFifo8)
ASM_PFX(IoReadFifo8):
push edi
cld
mov dx, [esp + 8]
mov ecx, [esp + 12]
mov edi, [esp + 16]
rep insb
pop edi
ret
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; IoReadFifo16 (
; IN UINTN Port,
; IN UINTN Size,
; IN VOID *Buffer
; );
;------------------------------------------------------------------------------
global ASM_PFX(IoReadFifo16)
ASM_PFX(IoReadFifo16):
push edi
cld
mov dx, [esp + 8]
mov ecx, [esp + 12]
mov edi, [esp + 16]
rep insw
pop edi
ret
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; IoReadFifo32 (
; IN UINTN Port,
; IN UINTN Size,
; IN VOID *Buffer
; );
;------------------------------------------------------------------------------
global ASM_PFX(IoReadFifo32)
ASM_PFX(IoReadFifo32):
push edi
cld
mov dx, [esp + 8]
mov ecx, [esp + 12]
mov edi, [esp + 16]
rep insd
pop edi
ret
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; IoWriteFifo8 (
; IN UINTN Port,
; IN UINTN Size,
; IN VOID *Buffer
; );
;------------------------------------------------------------------------------
global ASM_PFX(IoWriteFifo8)
ASM_PFX(IoWriteFifo8):
push esi
cld
mov dx, [esp + 8]
mov ecx, [esp + 12]
mov esi, [esp + 16]
rep outsb
pop esi
ret
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; IoWriteFifo16 (
; IN UINTN Port,
; IN UINTN Size,
; IN VOID *Buffer
; );
;------------------------------------------------------------------------------
global ASM_PFX(IoWriteFifo16)
ASM_PFX(IoWriteFifo16):
push esi
cld
mov dx, [esp + 8]
mov ecx, [esp + 12]
mov esi, [esp + 16]
rep outsw
pop esi
ret
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; IoWriteFifo32 (
; IN UINTN Port,
; IN UINTN Size,
; IN VOID *Buffer
; );
;------------------------------------------------------------------------------
global ASM_PFX(IoWriteFifo32)
ASM_PFX(IoWriteFifo32):
push esi
cld
mov dx, [esp + 8]
mov ecx, [esp + 12]
mov esi, [esp + 16]
rep outsd
pop esi
ret

View File

@ -1,176 +0,0 @@
/** @file
I/O FIFO routines
Copyright (c) 2008 - 2012, Intel Corporation. All rights reserved.<BR>
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.
**/
#ifndef _IO_FIFO_H_INCLUDED_
#define _IO_FIFO_H_INCLUDED_
/**
Reads an 8-bit I/O port fifo into a block of memory.
Reads the 8-bit I/O fifo port specified by Port.
The port is read Count times, and the read data is
stored in the provided Buffer.
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.
@param Count The number of times to read I/O port.
@param Buffer The buffer to store the read data into.
**/
VOID
EFIAPI
IoReadFifo8 (
IN UINTN Port,
IN UINTN Count,
OUT VOID *Buffer
);
/**
Reads a 16-bit I/O port fifo into a block of memory.
Reads the 16-bit I/O fifo port specified by Port.
The port is read Count times, and the read data is
stored in the provided Buffer.
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().
@param Port The I/O port to read.
@param Count The number of times to read I/O port.
@param Buffer The buffer to store the read data into.
**/
VOID
EFIAPI
IoReadFifo16 (
IN UINTN Port,
IN UINTN Count,
OUT VOID *Buffer
);
/**
Reads a 32-bit I/O port fifo into a block of memory.
Reads the 32-bit I/O fifo port specified by Port.
The port is read Count times, and the read data is
stored in the provided Buffer.
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().
@param Port The I/O port to read.
@param Count The number of times to read I/O port.
@param Buffer The buffer to store the read data into.
**/
VOID
EFIAPI
IoReadFifo32 (
IN UINTN Port,
IN UINTN Count,
OUT VOID *Buffer
);
/**
Writes a block of memory into an 8-bit I/O port fifo.
Writes the 8-bit I/O fifo port specified by Port.
The port is written Count times, and the write data is
retrieved from the provided Buffer.
This function must guarantee that all I/O write 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 Count The number of times to write I/O port.
@param Buffer The buffer to store the write data into.
**/
VOID
EFIAPI
IoWriteFifo8 (
IN UINTN Port,
IN UINTN Count,
OUT VOID *Buffer
);
/**
Writes a block of memory into a 16-bit I/O port fifo.
Writes the 16-bit I/O fifo port specified by Port.
The port is written Count times, and the write data is
retrieved from the provided Buffer.
This function must guarantee that all I/O write and write operations are
serialized.
If 16-bit I/O port operations are not supported, then ASSERT().
@param Port The I/O port to write.
@param Count The number of times to write I/O port.
@param Buffer The buffer to store the write data into.
**/
VOID
EFIAPI
IoWriteFifo16 (
IN UINTN Port,
IN UINTN Count,
OUT VOID *Buffer
);
/**
Writes a block of memory into a 32-bit I/O port fifo.
Writes the 32-bit I/O fifo port specified by Port.
The port is written Count times, and the write data is
retrieved from the provided Buffer.
This function must guarantee that all I/O write and write operations are
serialized.
If 32-bit I/O port operations are not supported, then ASSERT().
@param Port The I/O port to write.
@param Count The number of times to write I/O port.
@param Buffer The buffer to store the write data into.
**/
VOID
EFIAPI
IoWriteFifo32 (
IN UINTN Port,
IN UINTN Count,
OUT VOID *Buffer
);
#endif

View File

@ -1,126 +0,0 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
;
; 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.
;
;------------------------------------------------------------------------------
.code
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; IoReadFifo8 (
; IN UINTN Port, // rcx
; IN UINTN Size, // rdx
; IN VOID *Buffer // r8
; );
;------------------------------------------------------------------------------
IoReadFifo8 PROC
cld
xchg rcx, rdx
xchg rdi, r8 ; rdi: buffer address; r8: save rdi
rep insb
mov rdi, r8 ; restore rdi
ret
IoReadFifo8 ENDP
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; IoReadFifo16 (
; IN UINTN Port, // rcx
; IN UINTN Size, // rdx
; IN VOID *Buffer // r8
; );
;------------------------------------------------------------------------------
IoReadFifo16 PROC
cld
xchg rcx, rdx
xchg rdi, r8 ; rdi: buffer address; r8: save rdi
rep insw
mov rdi, r8 ; restore rdi
ret
IoReadFifo16 ENDP
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; IoReadFifo32 (
; IN UINTN Port, // rcx
; IN UINTN Size, // rdx
; IN VOID *Buffer // r8
; );
;------------------------------------------------------------------------------
IoReadFifo32 PROC
cld
xchg rcx, rdx
xchg rdi, r8 ; rdi: buffer address; r8: save rdi
rep insd
mov rdi, r8 ; restore rdi
ret
IoReadFifo32 ENDP
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; IoWriteFifo8 (
; IN UINTN Port, // rcx
; IN UINTN Size, // rdx
; IN VOID *Buffer // r8
; );
;------------------------------------------------------------------------------
IoWriteFifo8 PROC
cld
xchg rcx, rdx
xchg rsi, r8 ; rsi: buffer address; r8: save rsi
rep outsb
mov rsi, r8 ; restore rsi
ret
IoWriteFifo8 ENDP
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; IoWriteFifo16 (
; IN UINTN Port, // rcx
; IN UINTN Size, // rdx
; IN VOID *Buffer // r8
; );
;------------------------------------------------------------------------------
IoWriteFifo16 PROC
cld
xchg rcx, rdx
xchg rsi, r8 ; rsi: buffer address; r8: save rsi
rep outsw
mov rsi, r8 ; restore rsi
ret
IoWriteFifo16 ENDP
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; IoWriteFifo32 (
; IN UINTN Port, // rcx
; IN UINTN Size, // rdx
; IN VOID *Buffer // r8
; );
;------------------------------------------------------------------------------
IoWriteFifo32 PROC
cld
xchg rcx, rdx
xchg rsi, r8 ; rsi: buffer address; r8: save rsi
rep outsd
mov rsi, r8 ; restore rsi
ret
IoWriteFifo32 ENDP
END

View File

@ -1,125 +0,0 @@
;------------------------------------------------------------------------------
;
; Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
;
; 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.
;
;------------------------------------------------------------------------------
DEFAULT REL
SECTION .text
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; IoReadFifo8 (
; IN UINTN Port, // rcx
; IN UINTN Size, // rdx
; IN VOID *Buffer // r8
; );
;------------------------------------------------------------------------------
global ASM_PFX(IoReadFifo8)
ASM_PFX(IoReadFifo8):
cld
xchg rcx, rdx
xchg rdi, r8 ; rdi: buffer address; r8: save rdi
rep insb
mov rdi, r8 ; restore rdi
ret
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; IoReadFifo16 (
; IN UINTN Port, // rcx
; IN UINTN Size, // rdx
; IN VOID *Buffer // r8
; );
;------------------------------------------------------------------------------
global ASM_PFX(IoReadFifo16)
ASM_PFX(IoReadFifo16):
cld
xchg rcx, rdx
xchg rdi, r8 ; rdi: buffer address; r8: save rdi
rep insw
mov rdi, r8 ; restore rdi
ret
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; IoReadFifo32 (
; IN UINTN Port, // rcx
; IN UINTN Size, // rdx
; IN VOID *Buffer // r8
; );
;------------------------------------------------------------------------------
global ASM_PFX(IoReadFifo32)
ASM_PFX(IoReadFifo32):
cld
xchg rcx, rdx
xchg rdi, r8 ; rdi: buffer address; r8: save rdi
rep insd
mov rdi, r8 ; restore rdi
ret
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; IoWriteFifo8 (
; IN UINTN Port, // rcx
; IN UINTN Size, // rdx
; IN VOID *Buffer // r8
; );
;------------------------------------------------------------------------------
global ASM_PFX(IoWriteFifo8)
ASM_PFX(IoWriteFifo8):
cld
xchg rcx, rdx
xchg rsi, r8 ; rsi: buffer address; r8: save rsi
rep outsb
mov rsi, r8 ; restore rsi
ret
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; IoWriteFifo16 (
; IN UINTN Port, // rcx
; IN UINTN Size, // rdx
; IN VOID *Buffer // r8
; );
;------------------------------------------------------------------------------
global ASM_PFX(IoWriteFifo16)
ASM_PFX(IoWriteFifo16):
cld
xchg rcx, rdx
xchg rsi, r8 ; rsi: buffer address; r8: save rsi
rep outsw
mov rsi, r8 ; restore rsi
ret
;------------------------------------------------------------------------------
; VOID
; EFIAPI
; IoWriteFifo32 (
; IN UINTN Port, // rcx
; IN UINTN Size, // rdx
; IN VOID *Buffer // r8
; );
;------------------------------------------------------------------------------
global ASM_PFX(IoWriteFifo32)
ASM_PFX(IoWriteFifo32):
cld
xchg rcx, rdx
xchg rsi, r8 ; rsi: buffer address; r8: save rsi
rep outsd
mov rsi, r8 ; restore rsi
ret