]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Code refinement.
authorxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 13 Jul 2010 03:08:54 +0000 (03:08 +0000)
committerxli24 <xli24@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 13 Jul 2010 03:08:54 +0000 (03:08 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10647 6f19259b-4bc3-4df7-8a09-765794883524

14 files changed:
UefiCpuPkg/CpuDxe/CpuDxe.c
UefiCpuPkg/CpuDxe/CpuDxe.h
UefiCpuPkg/CpuDxe/CpuGdt.c
UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.c
UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.h [new file with mode: 0644]
UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.inf
UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.c
UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.h [new file with mode: 0644]
UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.inf
UefiCpuPkg/CpuIoPei/CpuIoPei.c
UefiCpuPkg/CpuIoPei/CpuIoPei.h [new file with mode: 0644]
UefiCpuPkg/CpuIoPei/CpuIoPei.inf
UefiCpuPkg/Include/Library/MtrrLib.h
UefiCpuPkg/Library/MtrrLib/MtrrLib.c

index 66955c3f199a7d7591c1c0868cc8888229e06fa3..454659150fea14c883dab6b18246ad2706535a3a 100644 (file)
@@ -136,7 +136,7 @@ CommonExceptionHandler (
     "!!!! IA32 Exception Type - %08x !!!!\n",\r
     InterruptType\r
     ));\r
-  if (mErrorCodeFlag & (1 << InterruptType)) {\r
+  if ((mErrorCodeFlag & (1 << InterruptType)) != 0) {\r
     DEBUG ((\r
       EFI_D_ERROR,\r
       "ExceptionData - %08x\n",\r
@@ -217,7 +217,7 @@ CommonExceptionHandler (
     "!!!! X64 Exception Type - %016lx !!!!\n",\r
     (UINT64)InterruptType\r
     ));\r
-  if (mErrorCodeFlag & (1 << InterruptType)) {\r
+  if ((mErrorCodeFlag & (1 << InterruptType)) != 0) {\r
     DEBUG ((\r
       EFI_D_ERROR,\r
       "ExceptionData - %016lx\n",\r
@@ -676,11 +676,11 @@ InitializeMtrrMask (
 }\r
 \r
 /**\r
-  Gets GCD Mem Space type from MTRR Type\r
+  Gets GCD Mem Space type from MTRR Type.\r
 \r
-  This function gets GCD Mem Space type from MTRR Type\r
+  This function gets GCD Mem Space type from MTRR Type.\r
 \r
-  @param  MtrrAttribute  MTRR memory type\r
+  @param  MtrrAttributes  MTRR memory type\r
 \r
   @return GCD Mem Space type\r
 \r
@@ -1009,7 +1009,6 @@ RefreshGcdMemoryAttributes (
   Initialize Interrupt Descriptor Table for interrupt handling.\r
 \r
 **/\r
-STATIC\r
 VOID\r
 InitInterruptDescriptorTable (\r
   VOID\r
index 91ae2b598ac384aea303f26ca578c327edb5c4fc..d42f82e0bda6ea9cc1939041f0f5a59bfa6840cf 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   CPU DXE Module.\r
 \r
-  Copyright (c) 2008 - 2009, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2008 - 2010, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -12,8 +12,8 @@
 \r
 **/\r
 \r
-#ifndef _CPU_DXE_H\r
-#define _CPU_DXE_H\r
+#ifndef _CPU_DXE_H_\r
+#define _CPU_DXE_H_\r
 \r
 #include <PiDxe.h>\r
 \r
                                        )\r
 \r
 \r
-//\r
-// Function declarations\r
-//\r
+/**\r
+  Flush CPU data cache. If the instruction cache is fully coherent\r
+  with all DMA operations then function can just return EFI_SUCCESS.\r
+\r
+  @param  This              Protocol instance structure\r
+  @param  Start             Physical address to start flushing from.\r
+  @param  Length            Number of bytes to flush. Round up to chipset\r
+                            granularity.\r
+  @param  FlushType         Specifies the type of flush operation to perform.\r
+\r
+  @retval EFI_SUCCESS       If cache was flushed\r
+  @retval EFI_UNSUPPORTED   If flush type is not supported.\r
+  @retval EFI_DEVICE_ERROR  If requested range could not be flushed.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 CpuFlushCpuDataCache (\r
@@ -54,18 +66,46 @@ CpuFlushCpuDataCache (
   IN EFI_CPU_FLUSH_TYPE        FlushType\r
   );\r
 \r
+/**\r
+  Enables CPU interrupts.\r
+\r
+  @param  This              Protocol instance structure\r
+\r
+  @retval EFI_SUCCESS       If interrupts were enabled in the CPU\r
+  @retval EFI_DEVICE_ERROR  If interrupts could not be enabled on the CPU.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 CpuEnableInterrupt (\r
   IN EFI_CPU_ARCH_PROTOCOL     *This\r
   );\r
 \r
+/**\r
+  Disables CPU interrupts.\r
+\r
+  @param  This              Protocol instance structure\r
+\r
+  @retval EFI_SUCCESS       If interrupts were disabled in the CPU.\r
+  @retval EFI_DEVICE_ERROR  If interrupts could not be disabled on the CPU.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 CpuDisableInterrupt (\r
   IN EFI_CPU_ARCH_PROTOCOL     *This\r
   );\r
 \r
+/**\r
+  Return the state of interrupts.\r
+\r
+  @param  This                   Protocol instance structure\r
+  @param  State                  Pointer to the CPU's current interrupt state\r
+\r
+  @retval EFI_SUCCESS            If interrupts were disabled in the CPU.\r
+  @retval EFI_INVALID_PARAMETER  State is NULL.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 CpuGetInterruptState (\r
@@ -73,6 +113,18 @@ CpuGetInterruptState (
   OUT BOOLEAN                   *State\r
   );\r
 \r
+/**\r
+  Generates an INIT to the CPU.\r
+\r
+  @param  This              Protocol instance structure\r
+  @param  InitType          Type of CPU INIT to perform\r
+\r
+  @retval EFI_SUCCESS       If CPU INIT occurred. This value should never be\r
+                            seen.\r
+  @retval EFI_DEVICE_ERROR  If CPU INIT failed.\r
+  @retval EFI_UNSUPPORTED   Requested type of CPU INIT not supported.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 CpuInit (\r
@@ -80,6 +132,26 @@ CpuInit (
   IN EFI_CPU_INIT_TYPE         InitType\r
   );\r
 \r
+/**\r
+  Registers a function to be called from the CPU interrupt handler.\r
+\r
+  @param  This                   Protocol instance structure\r
+  @param  InterruptType          Defines which interrupt to hook. IA-32\r
+                                 valid range is 0x00 through 0xFF\r
+  @param  InterruptHandler       A pointer to a function of type\r
+                                 EFI_CPU_INTERRUPT_HANDLER that is called\r
+                                 when a processor interrupt occurs.  A null\r
+                                 pointer is an error condition.\r
+\r
+  @retval EFI_SUCCESS            If handler installed or uninstalled.\r
+  @retval EFI_ALREADY_STARTED    InterruptHandler is not NULL, and a handler\r
+                                 for InterruptType was previously installed.\r
+  @retval EFI_INVALID_PARAMETER  InterruptHandler is NULL, and a handler for\r
+                                 InterruptType was not previously installed.\r
+  @retval EFI_UNSUPPORTED        The interrupt specified by InterruptType\r
+                                 is not supported.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 CpuRegisterInterruptHandler (\r
@@ -88,6 +160,29 @@ CpuRegisterInterruptHandler (
   IN EFI_CPU_INTERRUPT_HANDLER     InterruptHandler\r
   );\r
 \r
+/**\r
+  Returns a timer value from one of the CPU's internal timers. There is no\r
+  inherent time interval between ticks but is a function of the CPU frequency.\r
+\r
+  @param  This                - Protocol instance structure.\r
+  @param  TimerIndex          - Specifies which CPU timer is requested.\r
+  @param  TimerValue          - Pointer to the returned timer value.\r
+  @param  TimerPeriod         - A pointer to the amount of time that passes\r
+                                in femtoseconds (10-15) for each increment\r
+                                of TimerValue. If TimerValue does not\r
+                                increment at a predictable rate, then 0 is\r
+                                returned.  The amount of time that has\r
+                                passed between two calls to GetTimerValue()\r
+                                can be calculated with the formula\r
+                                (TimerValue2 - TimerValue1) * TimerPeriod.\r
+                                This parameter is optional and may be NULL.\r
+\r
+  @retval EFI_SUCCESS           - If the CPU timer count was returned.\r
+  @retval EFI_UNSUPPORTED       - If the CPU does not have any readable timers.\r
+  @retval EFI_DEVICE_ERROR      - If an error occurred while reading the timer.\r
+  @retval EFI_INVALID_PARAMETER - TimerIndex is not valid or TimerValue is NULL.\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 CpuGetTimerValue (\r
@@ -97,6 +192,22 @@ CpuGetTimerValue (
   OUT UINT64                      *TimerPeriod OPTIONAL\r
   );\r
 \r
+/**\r
+  Set memory cacheability attributes for given range of memeory.\r
+\r
+  @param  This                   Protocol instance structure\r
+  @param  BaseAddress            Specifies the start address of the\r
+                                 memory range\r
+  @param  Length                 Specifies the length of the memory range\r
+  @param  Attributes             The memory cacheability for the memory range\r
+\r
+  @retval EFI_SUCCESS            If the cacheability of that memory range is\r
+                                 set successfully\r
+  @retval EFI_UNSUPPORTED        If the desired operation cannot be done\r
+  @retval EFI_INVALID_PARAMETER  The input parameter is not correct,\r
+                                 such as Length = 0\r
+\r
+**/\r
 EFI_STATUS\r
 EFIAPI\r
 CpuSetMemoryAttributes (\r
@@ -106,29 +217,57 @@ CpuSetMemoryAttributes (
   IN UINT64                     Attributes\r
   );\r
 \r
+/**\r
+  Label of base address of IDT vector 0.\r
+\r
+  This is just a label of base address of IDT vector 0.\r
+\r
+**/\r
 VOID\r
 EFIAPI\r
 AsmIdtVector00 (\r
   VOID\r
   );\r
 \r
+/**\r
+  Initializes the pointer to the external interrupt vector table.\r
+\r
+  @param  VectorTable  Address of the external interrupt vector table.\r
+\r
+**/\r
 VOID\r
 EFIAPI\r
 InitializeExternalVectorTablePtr (\r
   EFI_CPU_INTERRUPT_HANDLER  *VectorTable\r
   );\r
 \r
+/**\r
+  Initialize Global Descriptor Table.\r
+\r
+**/\r
 VOID\r
 InitGlobalDescriptorTable (\r
   VOID\r
   );\r
 \r
+/**\r
+  Sets the code selector (CS).\r
+\r
+  @param  Selector  Value of code selector.\r
+\r
+**/\r
 VOID\r
 EFIAPI\r
 SetCodeSelector (\r
   UINT16 Selector\r
   );\r
 \r
+/**\r
+  Sets the data selector (DS).\r
+\r
+  @param  Selector  Value of data selector.\r
+\r
+**/\r
 VOID\r
 EFIAPI\r
 SetDataSelectors (\r
index 188cdb52b2d433ba4ce76aab210be4998bf9bb34..2fe27ad64eebd2eac48ad5ffcecf05b97a5b2a5b 100644 (file)
@@ -2,7 +2,7 @@
   C based implemention of IA32 interrupt handling only\r
   requiring a minimal assembly interrupt entry point.\r
 \r
-  Copyright (c) 2006 - 2009, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
 // Global Descriptor Entry structures\r
 //\r
 \r
-typedef\r
-struct _GDT_ENTRY {\r
-  UINT16 limit15_0;\r
-  UINT16 base15_0;\r
-  UINT8  base23_16;\r
-  UINT8  type;\r
-  UINT8  limit19_16_and_flags;\r
-  UINT8  base31_24;\r
+typedef struct _GDT_ENTRY {\r
+  UINT16 Limit15_0;\r
+  UINT16 Base15_0;\r
+  UINT8  Base23_16;\r
+  UINT8  Type;\r
+  UINT8  Limit19_16_and_flags;\r
+  UINT8  Base31_24;\r
 } GDT_ENTRY;\r
 \r
 typedef\r
@@ -162,11 +161,12 @@ STATIC GDT_ENTRIES GdtTemplate = {
 };\r
 \r
 /**\r
-  Initialize Global Descriptor Table\r
+  Initialize Global Descriptor Table.\r
 \r
 **/\r
 VOID\r
 InitGlobalDescriptorTable (\r
+  VOID\r
   )\r
 {\r
   GDT_ENTRIES *gdt;\r
index c183748eea5c4f34d079dd76b291f59d52620b93..fd4b2e8524d0db8dcb9cb80e6c9710888f7a9cbd 100644 (file)
@@ -12,59 +12,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 \r
-#include <PiDxe.h>\r
-\r
-#include <Protocol/CpuIo2.h>\r
-\r
-#include <Library/BaseLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/IoLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-\r
-#define MAX_IO_PORT_ADDRESS   0xFFFF\r
-\r
-//\r
-// Function Prototypes\r
-//\r
-EFI_STATUS\r
-EFIAPI\r
-CpuMemoryServiceRead (\r
-  IN  EFI_CPU_IO2_PROTOCOL       *This,\r
-  IN  EFI_CPU_IO_PROTOCOL_WIDTH  Width,\r
-  IN  UINT64                     Address,\r
-  IN  UINTN                      Count,\r
-  OUT VOID                       *Buffer\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-CpuMemoryServiceWrite (\r
-  IN EFI_CPU_IO2_PROTOCOL       *This,\r
-  IN EFI_CPU_IO_PROTOCOL_WIDTH  Width,\r
-  IN UINT64                     Address,\r
-  IN UINTN                      Count,\r
-  IN VOID                       *Buffer\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-CpuIoServiceRead (\r
-  IN  EFI_CPU_IO2_PROTOCOL       *This,\r
-  IN  EFI_CPU_IO_PROTOCOL_WIDTH  Width,\r
-  IN  UINT64                     Address,\r
-  IN  UINTN                      Count,\r
-  OUT VOID                       *Buffer\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-CpuIoServiceWrite (\r
-  IN EFI_CPU_IO2_PROTOCOL       *This,\r
-  IN EFI_CPU_IO_PROTOCOL_WIDTH  Width,\r
-  IN UINT64                     Address,\r
-  IN UINTN                      Count,\r
-  IN VOID                       *Buffer\r
-  );\r
+#include "CpuIo2Dxe.h"\r
 \r
 //\r
 // Handle for the CPU I/O 2 Protocol\r
diff --git a/UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.h b/UefiCpuPkg/CpuIo2Dxe/CpuIo2Dxe.h
new file mode 100644 (file)
index 0000000..7d00da1
--- /dev/null
@@ -0,0 +1,225 @@
+/** @file\r
+  Internal include file for the CPU I/O 2 Protocol.\r
+\r
+Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+**/\r
+\r
+#ifndef _CPU_IO2_DXE_H_\r
+#define _CPU_IO2_DXE_H_\r
+\r
+#include <PiDxe.h>\r
+\r
+#include <Protocol/CpuIo2.h>\r
+\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/IoLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+\r
+#define MAX_IO_PORT_ADDRESS   0xFFFF\r
+\r
+/**\r
+  Reads memory-mapped registers.\r
+\r
+  The I/O operations are carried out exactly as requested. The caller is responsible \r
+  for satisfying any alignment and I/O width restrictions that a PI System on a \r
+  platform might require. For example on some platforms, width requests of \r
+  EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will \r
+  be handled by the driver.\r
+  \r
+  If Width is EfiCpuIoWidthUint8, EfiCpuIoWidthUint16, EfiCpuIoWidthUint32, \r
+  or EfiCpuIoWidthUint64, then both Address and Buffer are incremented for \r
+  each of the Count operations that is performed.\r
+  \r
+  If Width is EfiCpuIoWidthFifoUint8, EfiCpuIoWidthFifoUint16, \r
+  EfiCpuIoWidthFifoUint32, or EfiCpuIoWidthFifoUint64, then only Buffer is \r
+  incremented for each of the Count operations that is performed. The read or \r
+  write operation is performed Count times on the same Address.\r
+  \r
+  If Width is EfiCpuIoWidthFillUint8, EfiCpuIoWidthFillUint16, \r
+  EfiCpuIoWidthFillUint32, or EfiCpuIoWidthFillUint64, then only Address is \r
+  incremented for each of the Count operations that is performed. The read or \r
+  write operation is performed Count times from the first element of Buffer.\r
+  \r
+  @param[in]  This     A pointer to the EFI_CPU_IO2_PROTOCOL instance.\r
+  @param[in]  Width    Signifies the width of the I/O or Memory operation.\r
+  @param[in]  Address  The base address of the I/O operation. \r
+  @param[in]  Count    The number of I/O operations to perform. The number of \r
+                       bytes moved is Width size * Count, starting at Address.\r
+  @param[out] Buffer   For read operations, the destination buffer to store the results.\r
+                       For write operations, the source buffer from which to write data.\r
+\r
+  @retval EFI_SUCCESS            The data was read from or written to the PI system.\r
+  @retval EFI_INVALID_PARAMETER  Width is invalid for this PI system.\r
+  @retval EFI_INVALID_PARAMETER  Buffer is NULL.\r
+  @retval EFI_UNSUPPORTED        The Buffer is not aligned for the given Width.\r
+  @retval EFI_UNSUPPORTED        The address range specified by Address, Width, \r
+                                 and Count is not valid for this PI system.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CpuMemoryServiceRead (\r
+  IN  EFI_CPU_IO2_PROTOCOL       *This,\r
+  IN  EFI_CPU_IO_PROTOCOL_WIDTH  Width,\r
+  IN  UINT64                     Address,\r
+  IN  UINTN                      Count,\r
+  OUT VOID                       *Buffer\r
+  );\r
+\r
+/**\r
+  Writes memory-mapped registers.\r
+\r
+  The I/O operations are carried out exactly as requested. The caller is responsible \r
+  for satisfying any alignment and I/O width restrictions that a PI System on a \r
+  platform might require. For example on some platforms, width requests of \r
+  EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will \r
+  be handled by the driver.\r
+  \r
+  If Width is EfiCpuIoWidthUint8, EfiCpuIoWidthUint16, EfiCpuIoWidthUint32, \r
+  or EfiCpuIoWidthUint64, then both Address and Buffer are incremented for \r
+  each of the Count operations that is performed.\r
+  \r
+  If Width is EfiCpuIoWidthFifoUint8, EfiCpuIoWidthFifoUint16, \r
+  EfiCpuIoWidthFifoUint32, or EfiCpuIoWidthFifoUint64, then only Buffer is \r
+  incremented for each of the Count operations that is performed. The read or \r
+  write operation is performed Count times on the same Address.\r
+  \r
+  If Width is EfiCpuIoWidthFillUint8, EfiCpuIoWidthFillUint16, \r
+  EfiCpuIoWidthFillUint32, or EfiCpuIoWidthFillUint64, then only Address is \r
+  incremented for each of the Count operations that is performed. The read or \r
+  write operation is performed Count times from the first element of Buffer.\r
+  \r
+  @param[in]  This     A pointer to the EFI_CPU_IO2_PROTOCOL instance.\r
+  @param[in]  Width    Signifies the width of the I/O or Memory operation.\r
+  @param[in]  Address  The base address of the I/O operation. \r
+  @param[in]  Count    The number of I/O operations to perform. The number of \r
+                       bytes moved is Width size * Count, starting at Address.\r
+  @param[in]  Buffer   For read operations, the destination buffer to store the results.\r
+                       For write operations, the source buffer from which to write data.\r
+\r
+  @retval EFI_SUCCESS            The data was read from or written to the PI system.\r
+  @retval EFI_INVALID_PARAMETER  Width is invalid for this PI system.\r
+  @retval EFI_INVALID_PARAMETER  Buffer is NULL.\r
+  @retval EFI_UNSUPPORTED        The Buffer is not aligned for the given Width.\r
+  @retval EFI_UNSUPPORTED        The address range specified by Address, Width, \r
+                                 and Count is not valid for this PI system.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CpuMemoryServiceWrite (\r
+  IN EFI_CPU_IO2_PROTOCOL       *This,\r
+  IN EFI_CPU_IO_PROTOCOL_WIDTH  Width,\r
+  IN UINT64                     Address,\r
+  IN UINTN                      Count,\r
+  IN VOID                       *Buffer\r
+  );\r
+\r
+/**\r
+  Reads I/O registers.\r
+\r
+  The I/O operations are carried out exactly as requested. The caller is responsible \r
+  for satisfying any alignment and I/O width restrictions that a PI System on a \r
+  platform might require. For example on some platforms, width requests of \r
+  EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will \r
+  be handled by the driver.\r
+  \r
+  If Width is EfiCpuIoWidthUint8, EfiCpuIoWidthUint16, EfiCpuIoWidthUint32, \r
+  or EfiCpuIoWidthUint64, then both Address and Buffer are incremented for \r
+  each of the Count operations that is performed.\r
+  \r
+  If Width is EfiCpuIoWidthFifoUint8, EfiCpuIoWidthFifoUint16, \r
+  EfiCpuIoWidthFifoUint32, or EfiCpuIoWidthFifoUint64, then only Buffer is \r
+  incremented for each of the Count operations that is performed. The read or \r
+  write operation is performed Count times on the same Address.\r
+  \r
+  If Width is EfiCpuIoWidthFillUint8, EfiCpuIoWidthFillUint16, \r
+  EfiCpuIoWidthFillUint32, or EfiCpuIoWidthFillUint64, then only Address is \r
+  incremented for each of the Count operations that is performed. The read or \r
+  write operation is performed Count times from the first element of Buffer.\r
+  \r
+  @param[in]  This     A pointer to the EFI_CPU_IO2_PROTOCOL instance.\r
+  @param[in]  Width    Signifies the width of the I/O or Memory operation.\r
+  @param[in]  Address  The base address of the I/O operation. \r
+  @param[in]  Count    The number of I/O operations to perform. The number of \r
+                       bytes moved is Width size * Count, starting at Address.\r
+  @param[out] Buffer   For read operations, the destination buffer to store the results.\r
+                       For write operations, the source buffer from which to write data.\r
+\r
+  @retval EFI_SUCCESS            The data was read from or written to the PI system.\r
+  @retval EFI_INVALID_PARAMETER  Width is invalid for this PI system.\r
+  @retval EFI_INVALID_PARAMETER  Buffer is NULL.\r
+  @retval EFI_UNSUPPORTED        The Buffer is not aligned for the given Width.\r
+  @retval EFI_UNSUPPORTED        The address range specified by Address, Width, \r
+                                 and Count is not valid for this PI system.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CpuIoServiceRead (\r
+  IN  EFI_CPU_IO2_PROTOCOL       *This,\r
+  IN  EFI_CPU_IO_PROTOCOL_WIDTH  Width,\r
+  IN  UINT64                     Address,\r
+  IN  UINTN                      Count,\r
+  OUT VOID                       *Buffer\r
+  );\r
+\r
+/**\r
+  Write I/O registers.\r
+\r
+  The I/O operations are carried out exactly as requested. The caller is responsible \r
+  for satisfying any alignment and I/O width restrictions that a PI System on a \r
+  platform might require. For example on some platforms, width requests of \r
+  EfiCpuIoWidthUint64 do not work. Misaligned buffers, on the other hand, will \r
+  be handled by the driver.\r
+  \r
+  If Width is EfiCpuIoWidthUint8, EfiCpuIoWidthUint16, EfiCpuIoWidthUint32, \r
+  or EfiCpuIoWidthUint64, then both Address and Buffer are incremented for \r
+  each of the Count operations that is performed.\r
+  \r
+  If Width is EfiCpuIoWidthFifoUint8, EfiCpuIoWidthFifoUint16, \r
+  EfiCpuIoWidthFifoUint32, or EfiCpuIoWidthFifoUint64, then only Buffer is \r
+  incremented for each of the Count operations that is performed. The read or \r
+  write operation is performed Count times on the same Address.\r
+  \r
+  If Width is EfiCpuIoWidthFillUint8, EfiCpuIoWidthFillUint16, \r
+  EfiCpuIoWidthFillUint32, or EfiCpuIoWidthFillUint64, then only Address is \r
+  incremented for each of the Count operations that is performed. The read or \r
+  write operation is performed Count times from the first element of Buffer.\r
+  \r
+  @param[in]  This     A pointer to the EFI_CPU_IO2_PROTOCOL instance.\r
+  @param[in]  Width    Signifies the width of the I/O or Memory operation.\r
+  @param[in]  Address  The base address of the I/O operation. \r
+  @param[in]  Count    The number of I/O operations to perform. The number of \r
+                       bytes moved is Width size * Count, starting at Address.\r
+  @param[in]  Buffer   For read operations, the destination buffer to store the results.\r
+                       For write operations, the source buffer from which to write data.\r
+\r
+  @retval EFI_SUCCESS            The data was read from or written to the PI system.\r
+  @retval EFI_INVALID_PARAMETER  Width is invalid for this PI system.\r
+  @retval EFI_INVALID_PARAMETER  Buffer is NULL.\r
+  @retval EFI_UNSUPPORTED        The Buffer is not aligned for the given Width.\r
+  @retval EFI_UNSUPPORTED        The address range specified by Address, Width, \r
+                                 and Count is not valid for this PI system.\r
+                                 \r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CpuIoServiceWrite (\r
+  IN EFI_CPU_IO2_PROTOCOL       *This,\r
+  IN EFI_CPU_IO_PROTOCOL_WIDTH  Width,\r
+  IN UINT64                     Address,\r
+  IN UINTN                      Count,\r
+  IN VOID                       *Buffer\r
+  );\r
+\r
+#endif\r
index 7698c3b690622aeaaafacb53bd110ea9d6ea8639..0f7f13869d601fea9876422f6644b44ce3e4275d 100644 (file)
@@ -29,7 +29,8 @@
 \r
 [Sources]\r
   CpuIo2Dxe.c\r
-\r
+  CpuIo2Dxe.h\r
+  \r
 [Packages]\r
   MdePkg/MdePkg.dec\r
 \r
index bcf3964d89aeee65c0137117843ddd32a42b2d3f..1c172a096c858bbb58e50b0a61c962c8ce6be48e 100644 (file)
@@ -12,60 +12,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 \r
-#include <PiSmm.h>\r
-\r
-#include <Protocol/SmmCpuIo2.h>\r
-\r
-#include <Library/BaseLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/IoLib.h>\r
-#include <Library/SmmServicesTableLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-\r
-#define MAX_IO_PORT_ADDRESS   0xFFFF\r
-\r
-//\r
-// Function Prototypes\r
-//\r
-EFI_STATUS\r
-EFIAPI\r
-CpuMemoryServiceRead (\r
-  IN  CONST EFI_SMM_CPU_IO2_PROTOCOL  *This,\r
-  IN  EFI_SMM_IO_WIDTH                Width,\r
-  IN  UINT64                          Address,\r
-  IN  UINTN                           Count,\r
-  OUT VOID                            *Buffer\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-CpuMemoryServiceWrite (\r
-  IN CONST EFI_SMM_CPU_IO2_PROTOCOL  *This,\r
-  IN EFI_SMM_IO_WIDTH                Width,\r
-  IN UINT64                          Address,\r
-  IN UINTN                           Count,\r
-  IN VOID                            *Buffer\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-CpuIoServiceRead (\r
-  IN  CONST EFI_SMM_CPU_IO2_PROTOCOL  *This,\r
-  IN  EFI_SMM_IO_WIDTH                Width,\r
-  IN  UINT64                          Address,\r
-  IN  UINTN                           Count,\r
-  OUT VOID                            *Buffer\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-CpuIoServiceWrite (\r
-  IN CONST EFI_SMM_CPU_IO2_PROTOCOL  *This,\r
-  IN EFI_SMM_IO_WIDTH                Width,\r
-  IN UINT64                          Address,\r
-  IN UINTN                           Count,\r
-  IN VOID                            *Buffer\r
-  );\r
+#include "CpuIo2Smm.h"\r
 \r
 //\r
 // Handle for the SMM CPU I/O Protocol\r
@@ -104,7 +51,7 @@ UINT8 mStride[] = {
   @param[in]  Address        The base address of the I/O operations.  The caller is \r
                              responsible for aligning the Address if required. \r
   @param[in]  Count          The number of I/O operations to perform.\r
-  @param[out] Buffer         For read operations, the destination buffer to store \r
+  @param[in]  Buffer         For read operations, the destination buffer to store \r
                              the results.  For write operations, the source buffer \r
                              from which to write data.\r
 \r
@@ -443,7 +390,7 @@ SmmCpuIo2Initialize (
   IN EFI_HANDLE        ImageHandle,\r
   IN EFI_SYSTEM_TABLE  *SystemTable\r
   )\r
- {\r
+{\r
   EFI_STATUS  Status;\r
 \r
   //\r
diff --git a/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.h b/UefiCpuPkg/CpuIo2Smm/CpuIo2Smm.h
new file mode 100644 (file)
index 0000000..5a09259
--- /dev/null
@@ -0,0 +1,162 @@
+/** @file\r
+  Internal include file for the SMM CPU I/O Protocol.\r
+\r
+Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+**/\r
+\r
+#ifndef _CPU_IO2_SMM_H_\r
+#define _CPU_IO2_SMM_H_\r
+\r
+#include <PiSmm.h>\r
+\r
+#include <Protocol/SmmCpuIo2.h>\r
+\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/IoLib.h>\r
+#include <Library/SmmServicesTableLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+\r
+#define MAX_IO_PORT_ADDRESS   0xFFFF\r
+\r
+/**\r
+  Reads memory-mapped registers.\r
+\r
+  The I/O operations are carried out exactly as requested.  The caller is \r
+  responsible for any alignment and I/O width issues that the bus, device, \r
+  platform, or type of I/O might require.\r
+\r
+  @param[in]  This     The EFI_SMM_CPU_IO2_PROTOCOL instance.\r
+  @param[in]  Width    Signifies the width of the I/O operations.\r
+  @param[in]  Address  The base address of the I/O operations.  The caller is \r
+                       responsible for aligning the Address if required. \r
+  @param[in]  Count    The number of I/O operations to perform.\r
+  @param[out] Buffer   For read operations, the destination buffer to store \r
+                       the results.  For write operations, the source buffer \r
+                       from which to write data.\r
+\r
+  @retval EFI_SUCCESS            The data was read from or written to the device.\r
+  @retval EFI_UNSUPPORTED        The Address is not valid for this system.\r
+  @retval EFI_INVALID_PARAMETER  Width or Count, or both, were invalid.\r
+  @retval EFI_OUT_OF_RESOURCES   The request could not be completed due to a \r
+                                 lack of resources\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CpuMemoryServiceRead (\r
+  IN  CONST EFI_SMM_CPU_IO2_PROTOCOL  *This,\r
+  IN  EFI_SMM_IO_WIDTH                Width,\r
+  IN  UINT64                          Address,\r
+  IN  UINTN                           Count,\r
+  OUT VOID                            *Buffer\r
+  );\r
+\r
+/**\r
+  Writes memory-mapped registers.\r
+\r
+  The I/O operations are carried out exactly as requested.  The caller is \r
+  responsible for any alignment and I/O width issues that the bus, device, \r
+  platform, or type of I/O might require.\r
+\r
+  @param[in]  This     The EFI_SMM_CPU_IO2_PROTOCOL instance.\r
+  @param[in]  Width    Signifies the width of the I/O operations.\r
+  @param[in]  Address  The base address of the I/O operations.  The caller is \r
+                       responsible for aligning the Address if required. \r
+  @param[in]  Count    The number of I/O operations to perform.\r
+  @param[in]  Buffer   For read operations, the destination buffer to store \r
+                       the results.  For write operations, the source buffer \r
+                       from which to write data.\r
+\r
+  @retval EFI_SUCCESS            The data was read from or written to the device.\r
+  @retval EFI_UNSUPPORTED        The Address is not valid for this system.\r
+  @retval EFI_INVALID_PARAMETER  Width or Count, or both, were invalid.\r
+  @retval EFI_OUT_OF_RESOURCES   The request could not be completed due to a \r
+                                 lack of resources\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CpuMemoryServiceWrite (\r
+  IN CONST EFI_SMM_CPU_IO2_PROTOCOL  *This,\r
+  IN EFI_SMM_IO_WIDTH                Width,\r
+  IN UINT64                          Address,\r
+  IN UINTN                           Count,\r
+  IN VOID                            *Buffer\r
+  );\r
+\r
+/**\r
+  Reads I/O registers.\r
+\r
+  The I/O operations are carried out exactly as requested.  The caller is \r
+  responsible for any alignment and I/O width issues that the bus, device, \r
+  platform, or type of I/O might require.\r
+\r
+  @param[in]  This     The EFI_SMM_CPU_IO2_PROTOCOL instance.\r
+  @param[in]  Width    Signifies the width of the I/O operations.\r
+  @param[in]  Address  The base address of the I/O operations.  The caller is \r
+                       responsible for aligning the Address if required. \r
+  @param[in]  Count    The number of I/O operations to perform.\r
+  @param[out] Buffer   For read operations, the destination buffer to store \r
+                       the results.  For write operations, the source buffer \r
+                       from which to write data.\r
+\r
+  @retval EFI_SUCCESS            The data was read from or written to the device.\r
+  @retval EFI_UNSUPPORTED        The Address is not valid for this system.\r
+  @retval EFI_INVALID_PARAMETER  Width or Count, or both, were invalid.\r
+  @retval EFI_OUT_OF_RESOURCES   The request could not be completed due to a \r
+                                 lack of resources\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CpuIoServiceRead (\r
+  IN  CONST EFI_SMM_CPU_IO2_PROTOCOL  *This,\r
+  IN  EFI_SMM_IO_WIDTH                Width,\r
+  IN  UINT64                          Address,\r
+  IN  UINTN                           Count,\r
+  OUT VOID                            *Buffer\r
+  );\r
+\r
+/**\r
+  Write I/O registers.\r
+\r
+  The I/O operations are carried out exactly as requested.  The caller is \r
+  responsible for any alignment and I/O width issues that the bus, device, \r
+  platform, or type of I/O might require.\r
+\r
+  @param[in]  This     The EFI_SMM_CPU_IO2_PROTOCOL instance.\r
+  @param[in]  Width    Signifies the width of the I/O operations.\r
+  @param[in]  Address  The base address of the I/O operations.  The caller is \r
+                       responsible for aligning the Address if required. \r
+  @param[in]  Count    The number of I/O operations to perform.\r
+  @param[in]  Buffer   For read operations, the destination buffer to store \r
+                       the results.  For write operations, the source buffer \r
+                       from which to write data.\r
+\r
+  @retval EFI_SUCCESS            The data was read from or written to the device.\r
+  @retval EFI_UNSUPPORTED        The Address is not valid for this system.\r
+  @retval EFI_INVALID_PARAMETER  Width or Count, or both, were invalid.\r
+  @retval EFI_OUT_OF_RESOURCES   The request could not be completed due to a \r
+                                 lack of resources\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CpuIoServiceWrite (\r
+  IN CONST EFI_SMM_CPU_IO2_PROTOCOL  *This,\r
+  IN EFI_SMM_IO_WIDTH                Width,\r
+  IN UINT64                          Address,\r
+  IN UINTN                           Count,\r
+  IN VOID                            *Buffer\r
+  );\r
+\r
+#endif\r
index a952460650d946d7095b993f00f8f2dbc60e63c8..e77b61f65526b20204088e9b9b5962703e47d3ac 100644 (file)
@@ -28,6 +28,7 @@
 \r
 [Sources]\r
   CpuIo2Smm.c\r
+  CpuIo2Smm.h\r
   \r
 [Packages]\r
   MdePkg/MdePkg.dec\r
index c94abe8e007666018586e700b1a593cc8af85f41..67b79053935710f1c2deb2a403cc45bfc5b0cceb 100644 (file)
@@ -12,200 +12,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 **/\r
 \r
-#include <PiDxe.h>\r
+#include "CpuIoPei.h"\r
 \r
-#include <Ppi/CpuIo.h>\r
-\r
-#include <Library/BaseLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/IoLib.h>\r
-#include <Library/PeiServicesLib.h>\r
-\r
-#define MAX_IO_PORT_ADDRESS   0xFFFF\r
-\r
-//\r
-// Function Prototypes\r
-//\r
-EFI_STATUS\r
-EFIAPI\r
-CpuMemoryServiceRead (\r
-  IN  CONST EFI_PEI_SERVICES    **PeiServices,\r
-  IN  CONST EFI_PEI_CPU_IO_PPI  *This,\r
-  IN  EFI_PEI_CPU_IO_PPI_WIDTH  Width,\r
-  IN  UINT64                    Address,\r
-  IN  UINTN                     Count,\r
-  OUT VOID                      *Buffer\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-CpuMemoryServiceWrite (\r
-  IN CONST EFI_PEI_SERVICES    **PeiServices,\r
-  IN CONST EFI_PEI_CPU_IO_PPI  *This,\r
-  IN EFI_PEI_CPU_IO_PPI_WIDTH  Width,\r
-  IN UINT64                    Address,\r
-  IN UINTN                     Count,\r
-  IN VOID                      *Buffer\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-CpuIoServiceRead (\r
-  IN  CONST EFI_PEI_SERVICES    **PeiServices,\r
-  IN  CONST EFI_PEI_CPU_IO_PPI  *This,\r
-  IN  EFI_PEI_CPU_IO_PPI_WIDTH  Width,\r
-  IN  UINT64                    Address,\r
-  IN  UINTN                     Count,\r
-  OUT VOID                      *Buffer\r
-  );\r
-\r
-EFI_STATUS\r
-EFIAPI\r
-CpuIoServiceWrite (\r
-  IN CONST EFI_PEI_SERVICES    **PeiServices,\r
-  IN CONST EFI_PEI_CPU_IO_PPI  *This,\r
-  IN EFI_PEI_CPU_IO_PPI_WIDTH  Width,\r
-  IN UINT64                    Address,\r
-  IN UINTN                     Count,\r
-  IN VOID                      *Buffer\r
-  );\r
-\r
-UINT8\r
-EFIAPI\r
-CpuIoRead8 (\r
-  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
-  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
-  IN  UINT64                      Address\r
-  );\r
-\r
-UINT16\r
-EFIAPI\r
-CpuIoRead16 (\r
-  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
-  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
-  IN  UINT64                      Address\r
-  );\r
-\r
-UINT32\r
-EFIAPI\r
-CpuIoRead32 (\r
-  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
-  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
-  IN  UINT64                      Address\r
-  );\r
-\r
-UINT64\r
-EFIAPI\r
-CpuIoRead64 (\r
-  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
-  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
-  IN  UINT64                      Address\r
-  );\r
-\r
-VOID\r
-EFIAPI\r
-CpuIoWrite8 (\r
-  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
-  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
-  IN  UINT64                      Address,\r
-  IN  UINT8                       Data\r
-  );\r
-\r
-VOID\r
-EFIAPI\r
-CpuIoWrite16 (\r
-  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
-  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
-  IN  UINT64                      Address,\r
-  IN  UINT16                      Data\r
-  );\r
-\r
-VOID\r
-EFIAPI\r
-CpuIoWrite32 (\r
-  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
-  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
-  IN  UINT64                      Address,\r
-  IN  UINT32                      Data\r
-  );\r
-\r
-VOID\r
-EFIAPI\r
-CpuIoWrite64 (\r
-  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
-  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
-  IN  UINT64                      Address,\r
-  IN  UINT64                      Data\r
-  );\r
-\r
-UINT8\r
-EFIAPI\r
-CpuMemRead8 (\r
-  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
-  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
-  IN  UINT64                      Address\r
-  );\r
-\r
-UINT16\r
-EFIAPI\r
-CpuMemRead16 (\r
-  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
-  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
-  IN  UINT64                      Address\r
-  );\r
-\r
-UINT32\r
-EFIAPI\r
-CpuMemRead32 (\r
-  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
-  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
-  IN  UINT64                      Address\r
-  );\r
-\r
-UINT64\r
-EFIAPI\r
-CpuMemRead64 (\r
-  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
-  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
-  IN  UINT64                      Address\r
-  );\r
-\r
-VOID\r
-EFIAPI\r
-CpuMemWrite8 (\r
-  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
-  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
-  IN  UINT64                      Address,\r
-  IN  UINT8                       Data\r
-  );\r
-\r
-VOID\r
-EFIAPI\r
-CpuMemWrite16 (\r
-  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
-  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
-  IN  UINT64                      Address,\r
-  IN  UINT16                      Data\r
-  );\r
-\r
-VOID\r
-EFIAPI\r
-CpuMemWrite32 (\r
-  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
-  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
-  IN  UINT64                      Address,\r
-  IN  UINT32                      Data\r
-  );\r
-\r
-VOID\r
-EFIAPI\r
-CpuMemWrite64 (\r
-  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
-  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
-  IN  UINT64                      Address,\r
-  IN  UINT64                      Data\r
-  );\r
-  \r
 //\r
 // Instance of CPU I/O PPI\r
 //\r
diff --git a/UefiCpuPkg/CpuIoPei/CpuIoPei.h b/UefiCpuPkg/CpuIoPei/CpuIoPei.h
new file mode 100644 (file)
index 0000000..052f0e3
--- /dev/null
@@ -0,0 +1,448 @@
+/** @file\r
+  Internal include file for the CPU I/O PPI.\r
+\r
+Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+This program and the accompanying materials                          \r
+are licensed and made available under the terms and conditions of the BSD License         \r
+which accompanies this distribution.  The full text of the license may be found at        \r
+http://opensource.org/licenses/bsd-license.php                                            \r
+                                                                                          \r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     \r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             \r
+\r
+**/\r
+\r
+#ifndef _CPU_IO2_PEI_H_\r
+#define _CPU_IO2_PEI_H_\r
+\r
+#include <PiDxe.h>\r
+\r
+#include <Ppi/CpuIo.h>\r
+\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/IoLib.h>\r
+#include <Library/PeiServicesLib.h>\r
+\r
+#define MAX_IO_PORT_ADDRESS   0xFFFF\r
+\r
+/**\r
+  Reads memory-mapped registers.\r
+\r
+  @param[in]  PeiServices  An indirect pointer to the PEI Services Table\r
+                           published by the PEI Foundation.\r
+  @param[in]  This         Pointer to local data for the interface.\r
+  @param[in]  Width        The width of the access. Enumerated in bytes.\r
+  @param[in]  Address      The physical address of the access.\r
+  @param[in]  Count        The number of accesses to perform.\r
+  @param[out] Buffer       A pointer to the buffer of data.\r
+\r
+  @retval EFI_SUCCESS            The function completed successfully.\r
+  @retval EFI_INVALID_PARAMETER  Width is invalid for this EFI system.\r
+  @retval EFI_INVALID_PARAMETER  Buffer is NULL.\r
+  @retval EFI_UNSUPPORTED        The address range specified by Address, Width, \r
+                                 and Count is not valid for this EFI system.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CpuMemoryServiceRead (\r
+  IN  CONST EFI_PEI_SERVICES    **PeiServices,\r
+  IN  CONST EFI_PEI_CPU_IO_PPI  *This,\r
+  IN  EFI_PEI_CPU_IO_PPI_WIDTH  Width,\r
+  IN  UINT64                    Address,\r
+  IN  UINTN                     Count,\r
+  OUT VOID                      *Buffer\r
+  );\r
+\r
+/**\r
+  Writes memory-mapped registers.\r
+\r
+  @param[in]  PeiServices  An indirect pointer to the PEI Services Table\r
+                           published by the PEI Foundation.\r
+  @param[in]  This         Pointer to local data for the interface.\r
+  @param[in]  Width        The width of the access. Enumerated in bytes.\r
+  @param[in]  Address      The physical address of the access.\r
+  @param[in]  Count        The number of accesses to perform.\r
+  @param[in]  Buffer       A pointer to the buffer of data.\r
+\r
+  @retval EFI_SUCCESS            The function completed successfully.\r
+  @retval EFI_INVALID_PARAMETER  Width is invalid for this EFI system.\r
+  @retval EFI_INVALID_PARAMETER  Buffer is NULL.\r
+  @retval EFI_UNSUPPORTED        The address range specified by Address, Width, \r
+                                 and Count is not valid for this EFI system.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CpuMemoryServiceWrite (\r
+  IN CONST EFI_PEI_SERVICES    **PeiServices,\r
+  IN CONST EFI_PEI_CPU_IO_PPI  *This,\r
+  IN EFI_PEI_CPU_IO_PPI_WIDTH  Width,\r
+  IN UINT64                    Address,\r
+  IN UINTN                     Count,\r
+  IN VOID                      *Buffer\r
+  );\r
+\r
+/**\r
+  Reads I/O registers.\r
+\r
+  @param[in]  PeiServices  An indirect pointer to the PEI Services Table\r
+                           published by the PEI Foundation.\r
+  @param[in]  This         Pointer to local data for the interface.\r
+  @param[in]  Width        The width of the access. Enumerated in bytes.\r
+  @param[in]  Address      The physical address of the access.\r
+  @param[in]  Count        The number of accesses to perform.\r
+  @param[out] Buffer       A pointer to the buffer of data.\r
+\r
+  @retval EFI_SUCCESS            The function completed successfully.\r
+  @retval EFI_INVALID_PARAMETER  Width is invalid for this EFI system.\r
+  @retval EFI_INVALID_PARAMETER  Buffer is NULL.\r
+  @retval EFI_UNSUPPORTED        The address range specified by Address, Width, \r
+                                 and Count is not valid for this EFI system.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CpuIoServiceRead (\r
+  IN  CONST EFI_PEI_SERVICES    **PeiServices,\r
+  IN  CONST EFI_PEI_CPU_IO_PPI  *This,\r
+  IN  EFI_PEI_CPU_IO_PPI_WIDTH  Width,\r
+  IN  UINT64                    Address,\r
+  IN  UINTN                     Count,\r
+  OUT VOID                      *Buffer\r
+  );\r
+\r
+/**\r
+  Write I/O registers.\r
+\r
+  @param[in]  PeiServices  An indirect pointer to the PEI Services Table\r
+                           published by the PEI Foundation.\r
+  @param[in]  This         Pointer to local data for the interface.\r
+  @param[in]  Width        The width of the access. Enumerated in bytes.\r
+  @param[in]  Address      The physical address of the access.\r
+  @param[in]  Count        The number of accesses to perform.\r
+  @param[in]  Buffer       A pointer to the buffer of data.\r
+\r
+  @retval EFI_SUCCESS            The function completed successfully.\r
+  @retval EFI_INVALID_PARAMETER  Width is invalid for this EFI system.\r
+  @retval EFI_INVALID_PARAMETER  Buffer is NULL.\r
+  @retval EFI_UNSUPPORTED        The address range specified by Address, Width, \r
+                                 and Count is not valid for this EFI system.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CpuIoServiceWrite (\r
+  IN CONST EFI_PEI_SERVICES    **PeiServices,\r
+  IN CONST EFI_PEI_CPU_IO_PPI  *This,\r
+  IN EFI_PEI_CPU_IO_PPI_WIDTH  Width,\r
+  IN UINT64                    Address,\r
+  IN UINTN                     Count,\r
+  IN VOID                      *Buffer\r
+  );\r
+\r
+/**\r
+  8-bit I/O read operations.\r
+\r
+  @param[in] PeiServices  An indirect pointer to the PEI Services Table published \r
+                          by the PEI Foundation.\r
+  @param[in] This         Pointer to local data for the interface.\r
+  @param[in] Address      The physical address of the access.\r
+\r
+  @return  An 8-bit value returned from the I/O space.\r
+**/\r
+UINT8\r
+EFIAPI\r
+CpuIoRead8 (\r
+  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
+  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
+  IN  UINT64                      Address\r
+  );\r
+\r
+/**\r
+  16-bit I/O read operations.\r
+\r
+  @param[in] PeiServices  An indirect pointer to the PEI Services Table published \r
+                          by the PEI Foundation.\r
+  @param[in] This         Pointer to local data for the interface.\r
+  @param[in] Address      The physical address of the access.\r
+\r
+  @return  A 16-bit value returned from the I/O space.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+CpuIoRead16 (\r
+  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
+  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
+  IN  UINT64                      Address\r
+  );\r
+\r
+/**\r
+  32-bit I/O read operations.\r
+\r
+  @param[in] PeiServices  An indirect pointer to the PEI Services Table published \r
+                          by the PEI Foundation.\r
+  @param[in] This         Pointer to local data for the interface.\r
+  @param[in] Address      The physical address of the access.\r
+\r
+  @return  A 32-bit value returned from the I/O space.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+CpuIoRead32 (\r
+  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
+  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
+  IN  UINT64                      Address\r
+  );\r
+\r
+/**\r
+  64-bit I/O read operations.\r
+\r
+  @param[in] PeiServices  An indirect pointer to the PEI Services Table published \r
+                          by the PEI Foundation.\r
+  @param[in] This         Pointer to local data for the interface.\r
+  @param[in] Address      The physical address of the access.\r
+\r
+  @return  A 64-bit value returned from the I/O space.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+CpuIoRead64 (\r
+  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
+  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
+  IN  UINT64                      Address\r
+  );\r
+\r
+/**\r
+  8-bit I/O write operations.\r
+\r
+  @param[in] PeiServices  An indirect pointer to the PEI Services Table published \r
+                          by the PEI Foundation.\r
+  @param[in] This         Pointer to local data for the interface.\r
+  @param[in] Address      The physical address of the access.\r
+  @param[in] Data         The data to write.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+CpuIoWrite8 (\r
+  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
+  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
+  IN  UINT64                      Address,\r
+  IN  UINT8                       Data\r
+  );\r
+\r
+/**\r
+  16-bit I/O write operations.\r
+\r
+  @param[in] PeiServices  An indirect pointer to the PEI Services Table published \r
+                          by the PEI Foundation.\r
+  @param[in] This         Pointer to local data for the interface.\r
+  @param[in] Address      The physical address of the access.\r
+  @param[in] Data         The data to write.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+CpuIoWrite16 (\r
+  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
+  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
+  IN  UINT64                      Address,\r
+  IN  UINT16                      Data\r
+  );\r
+\r
+/**\r
+  32-bit I/O write operations.\r
+\r
+  @param[in] PeiServices  An indirect pointer to the PEI Services Table published \r
+                          by the PEI Foundation.\r
+  @param[in] This         Pointer to local data for the interface.\r
+  @param[in] Address      The physical address of the access.\r
+  @param[in] Data         The data to write.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+CpuIoWrite32 (\r
+  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
+  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
+  IN  UINT64                      Address,\r
+  IN  UINT32                      Data\r
+  );\r
+\r
+/**\r
+  64-bit I/O write operations.\r
+\r
+  @param[in] PeiServices  An indirect pointer to the PEI Services Table published \r
+                          by the PEI Foundation.\r
+  @param[in] This         Pointer to local data for the interface.\r
+  @param[in] Address      The physical address of the access.\r
+  @param[in] Data         The data to write.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+CpuIoWrite64 (\r
+  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
+  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
+  IN  UINT64                      Address,\r
+  IN  UINT64                      Data\r
+  );\r
+\r
+/**\r
+  8-bit memory read operations.\r
+\r
+  @param[in] PeiServices  An indirect pointer to the PEI Services Table published \r
+                          by the PEI Foundation.\r
+  @param[in] This         Pointer to local data for the interface.\r
+  @param[in] Address      The physical address of the access.\r
+\r
+  @return  An 8-bit value returned from the memory space.\r
+\r
+**/\r
+UINT8\r
+EFIAPI\r
+CpuMemRead8 (\r
+  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
+  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
+  IN  UINT64                      Address\r
+  );\r
+\r
+/**\r
+  16-bit memory read operations.\r
+\r
+  @param[in] PeiServices  An indirect pointer to the PEI Services Table published \r
+                          by the PEI Foundation.\r
+  @param[in] This         Pointer to local data for the interface.\r
+  @param[in] Address      The physical address of the access.\r
+\r
+  @return  A 16-bit value returned from the memory space.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+CpuMemRead16 (\r
+  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
+  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
+  IN  UINT64                      Address\r
+  );\r
+\r
+/**\r
+  32-bit memory read operations.\r
+\r
+  @param[in] PeiServices  An indirect pointer to the PEI Services Table published \r
+                          by the PEI Foundation.\r
+  @param[in] This         Pointer to local data for the interface.\r
+  @param[in] Address      The physical address of the access.\r
+\r
+  @return  A 32-bit value returned from the memory space.\r
+\r
+**/\r
+UINT32\r
+EFIAPI\r
+CpuMemRead32 (\r
+  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
+  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
+  IN  UINT64                      Address\r
+  );\r
+\r
+/**\r
+  64-bit memory read operations.\r
+\r
+  @param[in] PeiServices  An indirect pointer to the PEI Services Table published \r
+                          by the PEI Foundation.\r
+  @param[in] This         Pointer to local data for the interface.\r
+  @param[in] Address      The physical address of the access.\r
+\r
+  @return  A 64-bit value returned from the memory space.\r
+\r
+**/\r
+UINT64\r
+EFIAPI\r
+CpuMemRead64 (\r
+  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
+  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
+  IN  UINT64                      Address\r
+  );\r
+\r
+/**\r
+  8-bit memory write operations.\r
+\r
+  @param[in] PeiServices  An indirect pointer to the PEI Services Table published \r
+                          by the PEI Foundation.\r
+  @param[in] This         Pointer to local data for the interface.\r
+  @param[in] Address      The physical address of the access.\r
+  @param[in] Data         The data to write.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+CpuMemWrite8 (\r
+  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
+  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
+  IN  UINT64                      Address,\r
+  IN  UINT8                       Data\r
+  );\r
+\r
+/**\r
+  16-bit memory write operations.\r
+\r
+  @param[in] PeiServices  An indirect pointer to the PEI Services Table published \r
+                          by the PEI Foundation.\r
+  @param[in] This         Pointer to local data for the interface.\r
+  @param[in] Address      The physical address of the access.\r
+  @param[in] Data         The data to write.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+CpuMemWrite16 (\r
+  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
+  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
+  IN  UINT64                      Address,\r
+  IN  UINT16                      Data\r
+  );\r
+\r
+/**\r
+  32-bit memory write operations.\r
+\r
+  @param[in] PeiServices  An indirect pointer to the PEI Services Table published \r
+                          by the PEI Foundation.\r
+  @param[in] This         Pointer to local data for the interface.\r
+  @param[in] Address      The physical address of the access.\r
+  @param[in] Data         The data to write.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+CpuMemWrite32 (\r
+  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
+  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
+  IN  UINT64                      Address,\r
+  IN  UINT32                      Data\r
+  );\r
+\r
+/**\r
+  64-bit memory write operations.\r
+\r
+  @param[in] PeiServices  An indirect pointer to the PEI Services Table published \r
+                          by the PEI Foundation.\r
+  @param[in] This         Pointer to local data for the interface.\r
+  @param[in] Address      The physical address of the access.\r
+  @param[in] Data         The data to write.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+CpuMemWrite64 (\r
+  IN  CONST EFI_PEI_SERVICES      **PeiServices,\r
+  IN  CONST EFI_PEI_CPU_IO_PPI    *This,\r
+  IN  UINT64                      Address,\r
+  IN  UINT64                      Data\r
+  );\r
+  \r
+#endif\r
index ec89a4e4eb921e16843b0e1dfeac817abf7a1dc1..616e108b1377c6f8c94927914a7e59a50e25a169 100644 (file)
@@ -29,7 +29,8 @@
 \r
 [Sources]\r
   CpuIoPei.c\r
-\r
+  CpuIoPei.h\r
+  \r
 [Packages]\r
   MdePkg/MdePkg.dec\r
 \r
index f0c604d6b3913a8ec5c989b8f4fe1db4059ad166..d24f10f36b9cb1adc96b0990e8a156bd37560cdd 100644 (file)
@@ -315,6 +315,7 @@ MtrrGetMemoryAttributeInVariableMtrr (
 VOID\r
 EFIAPI\r
 MtrrDebugPrintAllMtrrs (\r
+  VOID\r
   );\r
 \r
 /**\r
index 2bf0ce74bb5e5f17ae9b1df516b7b9db9effc5b7..1f2604ab8b9fecd5a4f6ed1be92e187d2882be49 100644 (file)
@@ -23,7 +23,6 @@
 //\r
 // This table defines the offset, base and length of the fixed MTRRs\r
 //\r
-STATIC\r
 FIXED_MTRR    MtrrLibFixedMtrrTable[] = {\r
   {\r
     MTRR_LIB_IA32_MTRR_FIX64K_00000,\r
@@ -552,7 +551,7 @@ Power2MaxMemory (
 {\r
   UINT64  Result;\r
 \r
-  if (RShiftU64 (MemoryLength, 32)) {\r
+  if (RShiftU64 (MemoryLength, 32) != 0) {\r
     Result = LShiftU64 (\r
                (UINT64) GetPowerOfTwo32 (\r
                           (UINT32) RShiftU64 (MemoryLength, 32)\r
@@ -624,7 +623,6 @@ GetDirection (
   @param  VariableMtrr   The array to shadow variable MTRRs content\r
 \r
 **/\r
-STATIC\r
 VOID\r
 InvalidateMtrr (\r
    IN     VARIABLE_MTRR      *VariableMtrr\r
@@ -638,7 +636,7 @@ InvalidateMtrr (
   Index = 0;\r
   VariableMtrrCount = GetVariableMtrrCount ();\r
   while (Index < VariableMtrrCount) {\r
-    if (VariableMtrr[Index].Valid == FALSE && VariableMtrr[Index].Used == TRUE ) {\r
+    if (!VariableMtrr[Index].Valid && VariableMtrr[Index].Used) {\r
        AsmWriteMsr64 (VariableMtrr[Index].Msr, 0);\r
        AsmWriteMsr64 (VariableMtrr[Index].Msr + 1, 0);\r
        VariableMtrr[Index].Used = FALSE;\r
@@ -661,7 +659,6 @@ InvalidateMtrr (
   @param  MtrrValidAddressMask  The valid address mask for MTRR\r
 \r
 **/\r
-STATIC\r
 VOID\r
 ProgramVariableMtrr (\r
   IN UINTN                    MtrrNumber,\r
@@ -703,7 +700,6 @@ ProgramVariableMtrr (
   @return The enum item in MTRR_MEMORY_CACHE_TYPE\r
 \r
 **/\r
-STATIC\r
 MTRR_MEMORY_CACHE_TYPE\r
 GetMemoryCacheTypeFromMtrrType (\r
   IN UINT64                MtrrType\r
@@ -738,7 +734,6 @@ GetMemoryCacheTypeFromMtrrType (
   @param  MtrrValidAddressMask  The valid address mask for the MTRR\r
 \r
 **/\r
-STATIC\r
 VOID\r
 MtrrLibInitializeMtrrMask (\r
   OUT UINT64 *MtrrValidBitsMask,\r
@@ -1452,7 +1447,9 @@ MtrrSetAllMtrrs (
   This function prints all MTRRs for debugging.\r
 **/\r
 VOID\r
+EFIAPI\r
 MtrrDebugPrintAllMtrrs (\r
+  VOID\r
   )\r
 {\r
   DEBUG_CODE (\r