From 8c7f0932d6a9649bad1c0d9318473b5652b808ec Mon Sep 17 00:00:00 2001 From: qhuang8 Date: Tue, 3 Feb 2009 00:45:16 +0000 Subject: [PATCH] Clean up CpuIoDxe: 1. Remove the assembly files by using IoLib in MdePkg. 2. Remove the unused DXS file. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@7402 6f19259b-4bc3-4df7-8a09-765794883524 --- DuetPkg/CpuIoDxe/CpuIo.c | 13 +- DuetPkg/CpuIoDxe/CpuIo.h | 1 + DuetPkg/CpuIoDxe/CpuIo.inf | 9 -- DuetPkg/CpuIoDxe/CpuIoAccess.h | 214 ------------------------- DuetPkg/CpuIoDxe/Ia32/CpuIoAccess.asm | 120 -------------- DuetPkg/CpuIoDxe/Ia32/CpuIoAccessGNU.c | 134 ---------------- DuetPkg/CpuIoDxe/Ia32CpuIo.dxs | 26 --- DuetPkg/CpuIoDxe/X64/CpuIoAccess.asm | 111 ------------- 8 files changed, 7 insertions(+), 621 deletions(-) delete mode 100644 DuetPkg/CpuIoDxe/CpuIoAccess.h delete mode 100644 DuetPkg/CpuIoDxe/Ia32/CpuIoAccess.asm delete mode 100644 DuetPkg/CpuIoDxe/Ia32/CpuIoAccessGNU.c delete mode 100644 DuetPkg/CpuIoDxe/Ia32CpuIo.dxs delete mode 100644 DuetPkg/CpuIoDxe/X64/CpuIoAccess.asm diff --git a/DuetPkg/CpuIoDxe/CpuIo.c b/DuetPkg/CpuIoDxe/CpuIo.c index 11a21360f7..729f556e46 100644 --- a/DuetPkg/CpuIoDxe/CpuIo.c +++ b/DuetPkg/CpuIoDxe/CpuIo.c @@ -23,7 +23,6 @@ Abstract: --*/ #include "CpuIo.h" -#include "CpuIoAccess.h" #define IA32_MAX_IO_ADDRESS 0xFFFF @@ -313,19 +312,19 @@ Returns: switch (Width) { case EfiCpuIoWidthUint8: for (; Count > 0; Count--, Buffer.buf += OutStride, Address += InStride) { - *Buffer.ui8 = CpuIoRead8 ((UINT16) Address); + *Buffer.ui8 = IoRead8 ((UINTN) Address); } break; case EfiCpuIoWidthUint16: for (; Count > 0; Count--, Buffer.buf += OutStride, Address += InStride) { - *Buffer.ui16 = CpuIoRead16 ((UINT16) Address); + *Buffer.ui16 = IoRead16 ((UINTN) Address); } break; case EfiCpuIoWidthUint32: for (; Count > 0; Count--, Buffer.buf += OutStride, Address += InStride) { - *Buffer.ui32 = CpuIoRead32 ((UINT16) Address); + *Buffer.ui32 = IoRead32 ((UINTN) Address); } break; @@ -406,19 +405,19 @@ Returns: switch (Width) { case EfiCpuIoWidthUint8: for (; Count > 0; Count--, Buffer.buf += OutStride, Address += InStride) { - CpuIoWrite8 ((UINT16) Address, *Buffer.ui8); + IoWrite8 ((UINTN) Address, *Buffer.ui8); } break; case EfiCpuIoWidthUint16: for (; Count > 0; Count--, Buffer.buf += OutStride, Address += InStride) { - CpuIoWrite16 ((UINT16) Address, *Buffer.ui16); + IoWrite16 ((UINTN) Address, *Buffer.ui16); } break; case EfiCpuIoWidthUint32: for (; Count > 0; Count--, Buffer.buf += OutStride, Address += InStride) { - CpuIoWrite32 ((UINT16) Address, *Buffer.ui32); + IoWrite32 ((UINTN) Address, *Buffer.ui32); } break; diff --git a/DuetPkg/CpuIoDxe/CpuIo.h b/DuetPkg/CpuIoDxe/CpuIo.h index 2facb53ad8..350d80cf44 100644 --- a/DuetPkg/CpuIoDxe/CpuIo.h +++ b/DuetPkg/CpuIoDxe/CpuIo.h @@ -32,6 +32,7 @@ Abstract: #include #include +#include typedef union { UINT8 volatile *buf; diff --git a/DuetPkg/CpuIoDxe/CpuIo.inf b/DuetPkg/CpuIoDxe/CpuIo.inf index b99e23cc41..f9d50f618d 100644 --- a/DuetPkg/CpuIoDxe/CpuIo.inf +++ b/DuetPkg/CpuIoDxe/CpuIo.inf @@ -44,15 +44,6 @@ [Sources.common] CpuIo.c CpuIo.h - CpuIoAccess.h - -[Sources.IA32] - Ia32/CpuIoAccess.asm | MSFT - Ia32/CpuIoAccess.asm | INTEL - Ia32/CpuIoAccessGNU.c | GCC - -[Sources.X64] - X64/CpuIoAccess.asm [Protocols] gEfiCpuIoProtocolGuid diff --git a/DuetPkg/CpuIoDxe/CpuIoAccess.h b/DuetPkg/CpuIoDxe/CpuIoAccess.h deleted file mode 100644 index ec596b645f..0000000000 --- a/DuetPkg/CpuIoDxe/CpuIoAccess.h +++ /dev/null @@ -1,214 +0,0 @@ -/*++ -# -# Copyright (c) 2004, Intel Corporation -# All rights 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. - - -Module Name: - - CpuIoAccess.h - -Abstract: - ---*/ - -#ifndef _CPU_IO_ACCESS_H -#define _CPU_IO_ACCESS_H - - -UINT8 -EFIAPI -CpuIoRead8 ( - IN UINT16 Port - ) -/*++ - -Routine Description: - - GC_TODO: Add function description - -Arguments: - - Port - GC_TODO: add argument description - -Returns: - - GC_TODO: add return values - ---*/ -; - -/*++ -Routine Description: - Cpu I/O read port -Arguments: - Port: - Port number to read -Returns: - Return read 8 bit value ---*/ -UINT16 -EFIAPI -CpuIoRead16 ( - IN UINT16 Port - ) -/*++ - -Routine Description: - - GC_TODO: Add function description - -Arguments: - - Port - GC_TODO: add argument description - -Returns: - - GC_TODO: add return values - ---*/ -; - -/*++ -Routine Description: - Cpu I/O read port -Arguments: - Port: - Port number to read -Returns: - Return read 16 bit value ---*/ -UINT32 -EFIAPI -CpuIoRead32 ( - IN UINT16 Port - ) -/*++ - -Routine Description: - - GC_TODO: Add function description - -Arguments: - - Port - GC_TODO: add argument description - -Returns: - - GC_TODO: add return values - ---*/ -; - -/*++ -Routine Description: - Cpu I/O read port -Arguments: - Port: - Port number to read -Returns: - Return read 32 bit value ---*/ -VOID -EFIAPI -CpuIoWrite8 ( - IN UINT16 Port, - IN UINT32 Data - ) -/*++ - -Routine Description: - - GC_TODO: Add function description - -Arguments: - - Port - GC_TODO: add argument description - Data - GC_TODO: add argument description - -Returns: - - GC_TODO: add return values - ---*/ -; - -/*++ -Routine Description: - Cpu I/O write 8 bit data to port -Arguments: - Port: - Port number to read - Data: - Data to write to the Port -Returns: - None ---*/ -VOID -EFIAPI -CpuIoWrite16 ( - IN UINT16 Port, - IN UINT32 Data - ) -/*++ - -Routine Description: - - GC_TODO: Add function description - -Arguments: - - Port - GC_TODO: add argument description - Data - GC_TODO: add argument description - -Returns: - - GC_TODO: add return values - ---*/ -; - -/*++ -Routine Description: - Cpu I/O write 16 bit data to port -Arguments: - Port: - Port number to read - Data: - Data to write to the Port -Returns: - None ---*/ -VOID -EFIAPI -CpuIoWrite32 ( - IN UINT16 Port, - IN UINT32 Data - ) -/*++ - -Routine Description: - - GC_TODO: Add function description - -Arguments: - - Port - GC_TODO: add argument description - Data - GC_TODO: add argument description - -Returns: - - GC_TODO: add return values - ---*/ -; - -/*++ -Routine Description: - Cpu I/O write 32 bit data to port -Arguments: - Port: - Port number to read - Data: - Data to write to the Port -Returns: - None ---*/ -#endif diff --git a/DuetPkg/CpuIoDxe/Ia32/CpuIoAccess.asm b/DuetPkg/CpuIoDxe/Ia32/CpuIoAccess.asm deleted file mode 100644 index 07b14ea554..0000000000 --- a/DuetPkg/CpuIoDxe/Ia32/CpuIoAccess.asm +++ /dev/null @@ -1,120 +0,0 @@ - title CpuIoAccess.asm -;------------------------------------------------------------------------------ -;* -;* Copyright (c) 2005, Intel Corporation -;* All rights 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. -;* -;* Module Name: -;* CpuIoAccess.asm -;* -;* Abstract: -;* Supports IA32 CPU IO operation -;* -;------------------------------------------------------------------------------ -; -; -;------------------------------------------------------------------------------ - - .686 - .MODEL FLAT,C - .CODE - - -UINT8 TYPEDEF BYTE -UINT16 TYPEDEF WORD -UINT32 TYPEDEF DWORD -UINT64 TYPEDEF QWORD -UINTN TYPEDEF UINT32 - - - -;------------------------------------------------------------------------------ -; UINT8 -; CpuIoRead8 ( -; IN UINT16 Port -; ) -;------------------------------------------------------------------------------ -CpuIoRead8 PROC PUBLIC Port:UINT16 - mov dx, Port - in al, dx - ret -CpuIoRead8 ENDP - -;------------------------------------------------------------------------------ -; UINT16 -; CpuIoRead16 ( -; IN UINT16 Port -; ) -;------------------------------------------------------------------------------ -CpuIoRead16 PROC PUBLIC Port:UINT16 - mov dx, Port - in ax, dx - ret -CpuIoRead16 ENDP - -;------------------------------------------------------------------------------ -; UINT32 -; CpuIoRead32 ( -; IN UINT16 Port -; ) -;------------------------------------------------------------------------------ -CpuIoRead32 PROC PUBLIC Port:UINT16 - mov dx, Port - in eax, dx - ret -CpuIoRead32 ENDP - - - -;------------------------------------------------------------------------------ -; VOID -; CpuIoWrite8 ( -; IN UINT16 Port, -; IN UINT32 Data -; ) -;------------------------------------------------------------------------------ -CpuIoWrite8 PROC PUBLIC Port:UINT16, Data:UINT32 - mov eax, Data - mov dx, Port - out dx, al - ret -CpuIoWrite8 ENDP - - -;------------------------------------------------------------------------------ -; VOID -; CpuIoWrite16 ( -; IN UINT16 Port, -; IN UINT32 Data -; ) -;------------------------------------------------------------------------------ -CpuIoWrite16 PROC PUBLIC Port:UINT16, Data:UINT32 - mov eax, Data - mov dx, Port - out dx, ax - ret -CpuIoWrite16 ENDP - - -;------------------------------------------------------------------------------ -; VOID -; CpuIoWrite32 ( -; IN UINT16 Port, -; IN UINT32 Data -; ) -;------------------------------------------------------------------------------ -CpuIoWrite32 PROC PUBLIC Port:UINT16, Data:UINT32 - mov eax, Data - mov dx, Port - out dx, eax - ret -CpuIoWrite32 ENDP - - -END \ No newline at end of file diff --git a/DuetPkg/CpuIoDxe/Ia32/CpuIoAccessGNU.c b/DuetPkg/CpuIoDxe/Ia32/CpuIoAccessGNU.c deleted file mode 100644 index 592eb0fdfb..0000000000 --- a/DuetPkg/CpuIoDxe/Ia32/CpuIoAccessGNU.c +++ /dev/null @@ -1,134 +0,0 @@ -/* This file is only used when not able to compile the MASM CpuIoAccess.asm - NOTE: Compiling with -fomit-frame-pointer would get you to roughly the exact - same code as the MASM file although GCC will typically include movzbl %al, %eax - or movzwl %ax, %eax instructions on the read functions such that the entire - eax result register will be valid, not just the lowest 8 or 16 bits. - */ -#ifdef __GNUC__ - -/* A quick note about GCC inline asm and the GNU assembler: - When gas encounters an instruction with a suffix (e.g. inb, inw, or inl vs. just in) it will - warn if the operand corresponding to the suffix is not of the correct size and will assume you - meant what you said when you specified the suffix. - - Because GCC does not enable us to see whether it is replacing %0 with %al, %ax, or %eax it is - helpful to have the assembler warn us that GCC is making an incorrect assumption. The actual - in or out instruction will always be generated correctly in this case since the assembler is - correct in assuming we meant what we said when we specified the suffix. However, GCC might - generate incorrect surrounding code. For example, if we were to incorrectly specify the - output size of an in instruction as UINT32, GCC would potentially fail to issue movz(b|w)l after - it under the assumption that the in instruction filled the entire eax register and not just - the al or ax portion. - - GCC determines which size of register to use based on the C data type. So for in instructions - the interesting type is that of the automatic variable named Data which is specified as an - output operand to the inline assembly statement. For example: - - UINT8 Data; - asm ( "inb %1, %0" - : "=a"(Data) - : "d"(Port) - ); - return Data; - - In this case, GCC will replace %0 with %al. If Data had been specified as UINT16, it would replace - %0 with %ax, and for UINT32 with %eax. - - Likewise in the case of IA32 out instructions, GCC will replace %0 with the appropriately sized - register based on the size of the input operand. There is one gotcha though. The CpuIoWrite - series of functions all use UINT32 as the type of the second (Data) argument. This means that - for GCC to output the correct register size we must cast it appropriately. - - The Port number is always a UINT16 so GCC will always ouput %dx. - */ - -#include "CpuIoAccess.h" - -UINT8 -EFIAPI -CpuIoRead8 ( - IN UINT16 Port - ) -{ - UINT8 Data; - asm ( "inb %1, %0" - : "=a"(Data) - : "d"(Port) - ); - return Data; -} - -UINT16 -EFIAPI -CpuIoRead16 ( - IN UINT16 Port - ) -{ - UINT16 Data; - asm ( "inw %1, %0" - : "=a"(Data) - : "d"(Port) - ); - return Data; -} - -UINT32 -EFIAPI -CpuIoRead32 ( - IN UINT16 Port - ) -{ - UINT32 Data; - asm ( "inl %1, %0" - : "=a"(Data) - : "d"(Port) - ); - return Data; -} - -VOID -EFIAPI -CpuIoWrite8 ( - IN UINT16 Port, - IN UINT32 Data - ) -{ - asm ( "outb %1, %0" - : /* No outputs */ - : "d"(Port) - , "a"((UINT8)Data) - ); -} - -VOID -EFIAPI -CpuIoWrite16 ( - IN UINT16 Port, - IN UINT32 Data - ) -{ - asm ( "outw %1, %0" - : /* No outputs */ - : "d"(Port) - , "a"((UINT16)Data) - ); -} - -VOID -EFIAPI -CpuIoWrite32 ( - IN UINT16 Port, - IN UINT32 Data - ) -{ - asm ( "outl %1, %0" - : /* No outputs */ - : "d"(Port) - /* NOTE: Cast is technically unnecessary but we use it to illustrate - that we always want to output a UINT32 and never anything else. - */ - , "a"((UINT32)Data) - ); -} - -#endif /* def __GNUC__ */ diff --git a/DuetPkg/CpuIoDxe/Ia32CpuIo.dxs b/DuetPkg/CpuIoDxe/Ia32CpuIo.dxs deleted file mode 100644 index 874f333985..0000000000 --- a/DuetPkg/CpuIoDxe/Ia32CpuIo.dxs +++ /dev/null @@ -1,26 +0,0 @@ -/*++ - -Copyright (c) 2004, Intel Corporation -All rights 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. - -Module Name: - Ia32CpuIo.dxs - -Abstract: - - Dependency expression source file. - ---*/ - -#include "EfiDepex.h" - - -DEPENDENCY_START - TRUE -DEPENDENCY_END diff --git a/DuetPkg/CpuIoDxe/X64/CpuIoAccess.asm b/DuetPkg/CpuIoDxe/X64/CpuIoAccess.asm deleted file mode 100644 index fa71762877..0000000000 --- a/DuetPkg/CpuIoDxe/X64/CpuIoAccess.asm +++ /dev/null @@ -1,111 +0,0 @@ - title CpuIoAccess.asm - -;------------------------------------------------------------------------------ -;* -;* Copyright (c) 2005 - 2007, Intel Corporation -;* All rights 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. -;* -;* Module Name: -;* CpuIoAccess.asm -;* -;* Abstract: -;* Supports x64 CPU IO operation -;* -;------------------------------------------------------------------------------ -; -; -; -; Abstract: -; -; -;------------------------------------------------------------------------------ - -.CODE - -;------------------------------------------------------------------------------ -; UINT8 -; CpuIoRead8 ( -; UINT16 Port // rcx -; ) -;------------------------------------------------------------------------------ -CpuIoRead8 PROC PUBLIC - xor eax, eax - mov dx, cx - in al, dx - ret -CpuIoRead8 ENDP - -;------------------------------------------------------------------------------ -; VOID -; CpuIoWrite8 ( -; UINT16 Port, // rcx -; UINT32 Data // rdx -; ) -;------------------------------------------------------------------------------ -CpuIoWrite8 PROC PUBLIC - mov eax, edx - mov dx, cx - out dx, al - ret -CpuIoWrite8 ENDP - -;------------------------------------------------------------------------------ -; UINT16 -; CpuIoRead16 ( -; UINT16 Port // rcx -; ) -;------------------------------------------------------------------------------ -CpuIoRead16 PROC PUBLIC - xor eax, eax - mov dx, cx - in ax, dx - ret -CpuIoRead16 ENDP - -;------------------------------------------------------------------------------ -; VOID -; CpuIoWrite16 ( -; UINT16 Port, // rcx -; UINT32 Data // rdx -; ) -;------------------------------------------------------------------------------ -CpuIoWrite16 PROC PUBLIC - mov eax, edx - mov dx, cx - out dx, ax - ret -CpuIoWrite16 ENDP - -;------------------------------------------------------------------------------ -; UINT32 -; CpuIoRead32 ( -; UINT16 Port // rcx -; ) -;------------------------------------------------------------------------------ -CpuIoRead32 PROC PUBLIC - mov dx, cx - in eax, dx - ret -CpuIoRead32 ENDP - -;------------------------------------------------------------------------------ -; VOID -; CpuIoWrite32 ( -; UINT16 Port, // rcx -; UINT32 Data // rdx -; ) -;------------------------------------------------------------------------------ -CpuIoWrite32 PROC PUBLIC - mov eax, edx - mov dx, cx - out dx, eax - ret -CpuIoWrite32 ENDP - -END -- 2.39.2