1. Update IoRead to support UINT64 also.
2. To be consistent, update PciCfgRead to support full S3BootScriptWidth(Uint8, FifoUint8 and FullUint8) like PciCfgWrite. 3. Use BuildLoopData() to get the addressStride and BufferStride to do PCI CFG operations. 4. Correct, refine and enhance some comments and debug messages. Signed-off-by: Star Zeng <star.zeng@intel.com> Reviewed-by: Jiewen Yao <jiewen.yao@intel.com> git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13987 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
		@@ -287,7 +287,7 @@ BuildLoopData (
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
  Translates boot script to MDE library interface.
 | 
					  Perform IO read operation
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  @param[in]  Width   Width of the operation.
 | 
					  @param[in]  Width   Width of the operation.
 | 
				
			||||||
  @param[in]  Address Address of the operation.
 | 
					  @param[in]  Address Address of the operation.
 | 
				
			||||||
@@ -331,25 +331,56 @@ ScriptIoRead (
 | 
				
			|||||||
    switch (Width) {
 | 
					    switch (Width) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    case S3BootScriptWidthUint8:
 | 
					    case S3BootScriptWidthUint8:
 | 
				
			||||||
 | 
					      DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint8 - 0x%08x\n", (UINTN) Address));
 | 
				
			||||||
 | 
					      *Out.Uint8 = IoRead8 ((UINTN) Address);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
    case S3BootScriptWidthFifoUint8:
 | 
					    case S3BootScriptWidthFifoUint8:
 | 
				
			||||||
 | 
					      DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x\n", (UINTN) Address));
 | 
				
			||||||
 | 
					      *Out.Uint8 = IoRead8 ((UINTN) Address);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
    case S3BootScriptWidthFillUint8:
 | 
					    case S3BootScriptWidthFillUint8:
 | 
				
			||||||
      DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint8Read - 0x%08x\n", Address));
 | 
					      DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%08x\n", (UINTN) Address));
 | 
				
			||||||
      *Out.Uint8 = IoRead8 ((UINTN) Address);
 | 
					      *Out.Uint8 = IoRead8 ((UINTN) Address);
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    case S3BootScriptWidthUint16:
 | 
					    case S3BootScriptWidthUint16:
 | 
				
			||||||
 | 
					      DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint16 - 0x%08x\n", (UINTN) Address));
 | 
				
			||||||
 | 
					      *Out.Uint16 = IoRead16 ((UINTN) Address);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
    case S3BootScriptWidthFifoUint16:
 | 
					    case S3BootScriptWidthFifoUint16:
 | 
				
			||||||
 | 
					      DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint16 - 0x%08x\n", (UINTN) Address));
 | 
				
			||||||
 | 
					      *Out.Uint16 = IoRead16 ((UINTN) Address);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
    case S3BootScriptWidthFillUint16:
 | 
					    case S3BootScriptWidthFillUint16:
 | 
				
			||||||
      DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint16Read - 0x%08x\n", Address));
 | 
					      DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint16 - 0x%08x\n", (UINTN) Address));
 | 
				
			||||||
      *Out.Uint16 = IoRead16 ((UINTN) Address);
 | 
					      *Out.Uint16 = IoRead16 ((UINTN) Address);
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    case S3BootScriptWidthUint32:
 | 
					    case S3BootScriptWidthUint32:
 | 
				
			||||||
    case S3BootScriptWidthFifoUint32:
 | 
					      DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint32 - 0x%08x\n", (UINTN) Address));
 | 
				
			||||||
    case S3BootScriptWidthFillUint32:
 | 
					 | 
				
			||||||
      DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint32Read - 0x%08x\n", Address));
 | 
					 | 
				
			||||||
      *Out.Uint32 = IoRead32 ((UINTN) Address);
 | 
					      *Out.Uint32 = IoRead32 ((UINTN) Address);
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
 | 
					    case S3BootScriptWidthFifoUint32:
 | 
				
			||||||
 | 
					      DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint32 - 0x%08x\n", (UINTN) Address));
 | 
				
			||||||
 | 
					      *Out.Uint32 = IoRead32 ((UINTN) Address);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    case S3BootScriptWidthFillUint32:
 | 
				
			||||||
 | 
					      DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint32 - 0x%08x\n", (UINTN) Address));
 | 
				
			||||||
 | 
					      *Out.Uint32 = IoRead32 ((UINTN) Address);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    case S3BootScriptWidthUint64:
 | 
				
			||||||
 | 
					      DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint64 - 0x%08x\n", (UINTN) Address));
 | 
				
			||||||
 | 
					      *Out.Uint64 = IoRead64 ((UINTN) Address);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    case S3BootScriptWidthFifoUint64:
 | 
				
			||||||
 | 
					      DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint64 - 0x%08x\n", (UINTN) Address));
 | 
				
			||||||
 | 
					      *Out.Uint64 = IoRead64 ((UINTN) Address);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    case S3BootScriptWidthFillUint64:
 | 
				
			||||||
 | 
					      DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint64 - 0x%08x\n", (UINTN) Address));
 | 
				
			||||||
 | 
					      *Out.Uint64 = IoRead64 ((UINTN) Address);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    default:
 | 
					    default:
 | 
				
			||||||
      return EFI_INVALID_PARAMETER;
 | 
					      return EFI_INVALID_PARAMETER;
 | 
				
			||||||
@@ -360,7 +391,7 @@ ScriptIoRead (
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
  Perform a write operation
 | 
					  Perform IO write operation
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  @param[in]  Width Width of the operation.
 | 
					  @param[in]  Width Width of the operation.
 | 
				
			||||||
  @param[in]  Address Address of the operation.
 | 
					  @param[in]  Address Address of the operation.
 | 
				
			||||||
@@ -463,7 +494,7 @@ ScriptIoWrite (
 | 
				
			|||||||
  return EFI_SUCCESS;
 | 
					  return EFI_SUCCESS;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
  Interprete the IO write entry in S3 boot script and perform the write operation
 | 
					  Interprete the boot script node with EFI_BOOT_SCRIPT_IO_WRITE OP code.
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  @param Script       Pointer to the node which is to be interpreted.
 | 
					  @param Script       Pointer to the node which is to be interpreted.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -490,7 +521,8 @@ BootScriptExecuteIoWrite (
 | 
				
			|||||||
  Address = IoWrite.Address;
 | 
					  Address = IoWrite.Address;
 | 
				
			||||||
  Count = IoWrite.Count;
 | 
					  Count = IoWrite.Count;
 | 
				
			||||||
  Buffer = Script + sizeof (EFI_BOOT_SCRIPT_IO_WRITE);
 | 
					  Buffer = Script + sizeof (EFI_BOOT_SCRIPT_IO_WRITE);
 | 
				
			||||||
  
 | 
					
 | 
				
			||||||
 | 
					  DEBUG ((EFI_D_INFO, "BootScriptExecuteIoWrite - 0x%08x, 0x%08x, 0x%08x\n", (UINTN)Address, Count, (UINTN)Width));
 | 
				
			||||||
  return ScriptIoWrite(Width, Address, Count, Buffer);
 | 
					  return ScriptIoWrite(Width, Address, Count, Buffer);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
@@ -534,32 +566,56 @@ ScriptMemoryRead (
 | 
				
			|||||||
  for (; Count > 0; Count--, Address += AddressStride, Out.Buf += BufferStride) {
 | 
					  for (; Count > 0; Count--, Address += AddressStride, Out.Buf += BufferStride) {
 | 
				
			||||||
    switch (Width) {
 | 
					    switch (Width) {
 | 
				
			||||||
    case S3BootScriptWidthUint8:
 | 
					    case S3BootScriptWidthUint8:
 | 
				
			||||||
    case S3BootScriptWidthFifoUint8:
 | 
					 | 
				
			||||||
    case S3BootScriptWidthFillUint8:
 | 
					 | 
				
			||||||
      DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint8 - 0x%08x\n", (UINTN)Address));
 | 
					      DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint8 - 0x%08x\n", (UINTN)Address));
 | 
				
			||||||
      *Out.Uint8 = MmioRead8 ((UINTN) Address);
 | 
					      *Out.Uint8 = MmioRead8 ((UINTN) Address);
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
 | 
					    case S3BootScriptWidthFifoUint8:
 | 
				
			||||||
 | 
					      DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x\n", (UINTN)Address));
 | 
				
			||||||
 | 
					      *Out.Uint8 = MmioRead8 ((UINTN) Address);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    case S3BootScriptWidthFillUint8:
 | 
				
			||||||
 | 
					      DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%08x\n", (UINTN)Address));
 | 
				
			||||||
 | 
					      *Out.Uint8 = MmioRead8 ((UINTN) Address);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    case S3BootScriptWidthUint16:
 | 
					    case S3BootScriptWidthUint16:
 | 
				
			||||||
    case S3BootScriptWidthFifoUint16:
 | 
					 | 
				
			||||||
    case S3BootScriptWidthFillUint16:
 | 
					 | 
				
			||||||
      DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint16 - 0x%08x\n", (UINTN)Address));
 | 
					      DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint16 - 0x%08x\n", (UINTN)Address));
 | 
				
			||||||
      *Out.Uint16 = MmioRead16 ((UINTN) Address);
 | 
					      *Out.Uint16 = MmioRead16 ((UINTN) Address);
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
 | 
					    case S3BootScriptWidthFifoUint16:
 | 
				
			||||||
 | 
					      DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint16 - 0x%08x\n", (UINTN)Address));
 | 
				
			||||||
 | 
					      *Out.Uint16 = MmioRead16 ((UINTN) Address);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    case S3BootScriptWidthFillUint16:
 | 
				
			||||||
 | 
					      DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint16 - 0x%08x\n", (UINTN)Address));
 | 
				
			||||||
 | 
					      *Out.Uint16 = MmioRead16 ((UINTN) Address);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    case S3BootScriptWidthUint32:
 | 
					    case S3BootScriptWidthUint32:
 | 
				
			||||||
    case S3BootScriptWidthFifoUint32:
 | 
					 | 
				
			||||||
    case S3BootScriptWidthFillUint32:
 | 
					 | 
				
			||||||
      DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint32 - 0x%08x\n", (UINTN)Address));
 | 
					      DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint32 - 0x%08x\n", (UINTN)Address));
 | 
				
			||||||
      *Out.Uint32 = MmioRead32 ((UINTN) Address);
 | 
					      *Out.Uint32 = MmioRead32 ((UINTN) Address);
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
 | 
					    case S3BootScriptWidthFifoUint32:
 | 
				
			||||||
 | 
					      DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint32 - 0x%08x\n", (UINTN)Address));
 | 
				
			||||||
 | 
					      *Out.Uint32 = MmioRead32 ((UINTN) Address);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    case S3BootScriptWidthFillUint32:
 | 
				
			||||||
 | 
					      DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint32 - 0x%08x\n", (UINTN)Address));
 | 
				
			||||||
 | 
					      *Out.Uint32 = MmioRead32 ((UINTN) Address);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    case S3BootScriptWidthUint64:
 | 
					    case S3BootScriptWidthUint64:
 | 
				
			||||||
    case S3BootScriptWidthFifoUint64:
 | 
					 | 
				
			||||||
    case S3BootScriptWidthFillUint64:
 | 
					 | 
				
			||||||
      DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint64 - 0x%08x\n", (UINTN)Address));
 | 
					      DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint64 - 0x%08x\n", (UINTN)Address));
 | 
				
			||||||
      *Out.Uint64 = MmioRead64 ((UINTN) Address);
 | 
					      *Out.Uint64 = MmioRead64 ((UINTN) Address);
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
 | 
					    case S3BootScriptWidthFifoUint64:
 | 
				
			||||||
 | 
					      DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint64 - 0x%08x\n", (UINTN)Address));
 | 
				
			||||||
 | 
					      *Out.Uint64 = MmioRead64 ((UINTN) Address);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    case S3BootScriptWidthFillUint64:
 | 
				
			||||||
 | 
					      DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint64 - 0x%08x\n", (UINTN)Address));
 | 
				
			||||||
 | 
					      *Out.Uint64 = MmioRead64 ((UINTN) Address);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    default:
 | 
					    default:
 | 
				
			||||||
      return EFI_UNSUPPORTED;
 | 
					      return EFI_UNSUPPORTED;
 | 
				
			||||||
@@ -569,7 +625,7 @@ ScriptMemoryRead (
 | 
				
			|||||||
  return EFI_SUCCESS;
 | 
					  return EFI_SUCCESS;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
  Translates boot script to MDE library interface.
 | 
					  Perform memory write operation
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  @param   Width   Width of the operation.
 | 
					  @param   Width   Width of the operation.
 | 
				
			||||||
  @param   Address Address of the operation.
 | 
					  @param   Address Address of the operation.
 | 
				
			||||||
@@ -696,16 +752,17 @@ BootScriptExecuteMemoryWrite (
 | 
				
			|||||||
  Count   = MemWrite.Count;
 | 
					  Count   = MemWrite.Count;
 | 
				
			||||||
  Buffer  = Script + sizeof(EFI_BOOT_SCRIPT_MEM_WRITE);
 | 
					  Buffer  = Script + sizeof(EFI_BOOT_SCRIPT_MEM_WRITE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  DEBUG ((EFI_D_INFO, "BootScriptExecuteMemoryWrite - 0x%08x, 0x%08x, 0x%08x\n", (UINTN)Address, (UINTN)Count, (UINTN)Width));
 | 
					  DEBUG ((EFI_D_INFO, "BootScriptExecuteMemoryWrite - 0x%08x, 0x%08x, 0x%08x\n", (UINTN)Address, Count, (UINTN)Width));
 | 
				
			||||||
  return ScriptMemoryWrite (Width,Address, Count,  Buffer);
 | 
					  return ScriptMemoryWrite (Width,Address, Count,  Buffer);
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
}  
 | 
					}  
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
  Translates boot script to MDE library interface for PCI configuration read operation
 | 
					  Performance PCI configuration read operation
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @param  Width   Width of the operation.
 | 
					  @param  Width   Width of the operation.
 | 
				
			||||||
  @param  Address Address of the operation.
 | 
					  @param  Address Address of the operation.
 | 
				
			||||||
  @param  Buffer  Pointer to the buffer reaf from PCI config space
 | 
					  @param  Count   Count of the number of accesses to perform.
 | 
				
			||||||
 | 
					  @param  Buffer  Pointer to the buffer read from PCI config space
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  @retval EFI_SUCCESS The read succeed.
 | 
					  @retval EFI_SUCCESS The read succeed.
 | 
				
			||||||
  @retval EFI_INVALID_PARAMETER if Width is not defined  
 | 
					  @retval EFI_INVALID_PARAMETER if Width is not defined  
 | 
				
			||||||
@@ -715,37 +772,82 @@ EFI_STATUS
 | 
				
			|||||||
ScriptPciCfgRead (
 | 
					ScriptPciCfgRead (
 | 
				
			||||||
  IN  S3_BOOT_SCRIPT_LIB_WIDTH    Width,
 | 
					  IN  S3_BOOT_SCRIPT_LIB_WIDTH    Width,
 | 
				
			||||||
  IN  UINT64                       Address,
 | 
					  IN  UINT64                       Address,
 | 
				
			||||||
 | 
					  IN  UINTN                        Count,
 | 
				
			||||||
  OUT VOID                        *Buffer
 | 
					  OUT VOID                        *Buffer
 | 
				
			||||||
  )
 | 
					  )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
 | 
					  EFI_STATUS  Status;
 | 
				
			||||||
 | 
					  UINTN       AddressStride;
 | 
				
			||||||
 | 
					  UINTN       BufferStride;
 | 
				
			||||||
 | 
					  PTR         Out;
 | 
				
			||||||
 | 
					  UINTN       PciAddress;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Out.Buf = (UINT8 *) Buffer;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  PciAddress = PCI_ADDRESS_ENCODE (Address);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  Status = BuildLoopData (Width, PciAddress, &AddressStride, &BufferStride);
 | 
				
			||||||
 | 
					  if (EFI_ERROR (Status)) {
 | 
				
			||||||
 | 
					    return Status;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
 | 
					  // Loop for each iteration and move the data
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
 | 
					  for (; Count > 0; Count--, PciAddress += AddressStride, Out.Buf += BufferStride) {
 | 
				
			||||||
    switch (Width) {
 | 
					    switch (Width) {
 | 
				
			||||||
    case S3BootScriptWidthUint8:
 | 
					    case S3BootScriptWidthUint8:
 | 
				
			||||||
      DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint8 - 0x%016lx\n", Address));
 | 
					      DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint8 - 0x%08x\n", PciAddress));
 | 
				
			||||||
      * (UINT8 *) Buffer = PciRead8 (PCI_ADDRESS_ENCODE(Address));
 | 
					      *Out.Uint8 = PciRead8 (PciAddress);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    case S3BootScriptWidthFifoUint8:
 | 
				
			||||||
 | 
					      DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x\n", PciAddress));
 | 
				
			||||||
 | 
					      *Out.Uint8 = PciRead8 (PciAddress);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    case S3BootScriptWidthFillUint8:
 | 
				
			||||||
 | 
					      DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%08x\n", PciAddress));
 | 
				
			||||||
 | 
					      *Out.Uint8 = PciRead8 (PciAddress);
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    case S3BootScriptWidthUint16:
 | 
					    case S3BootScriptWidthUint16:
 | 
				
			||||||
      DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint16 - 0x%016lx\n", Address));
 | 
					      DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint16 - 0x%08x\n", PciAddress));
 | 
				
			||||||
      * (UINT16 *) Buffer = PciRead16 (PCI_ADDRESS_ENCODE(Address));
 | 
					      *Out.Uint16 = PciRead16 (PciAddress);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    case S3BootScriptWidthFifoUint16:
 | 
				
			||||||
 | 
					      DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint16 - 0x%08x\n", PciAddress));
 | 
				
			||||||
 | 
					      *Out.Uint16 = PciRead16 (PciAddress);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    case S3BootScriptWidthFillUint16:
 | 
				
			||||||
 | 
					      DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint16 - 0x%08x\n", PciAddress));
 | 
				
			||||||
 | 
					      *Out.Uint16 = PciRead16 (PciAddress);
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    case S3BootScriptWidthUint32:
 | 
					    case S3BootScriptWidthUint32:
 | 
				
			||||||
      DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint32 - 0x%016lx\n", Address));
 | 
					      DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint32 - 0x%08x\n", PciAddress));
 | 
				
			||||||
      * (UINT32 *) Buffer = PciRead32 (PCI_ADDRESS_ENCODE(Address));
 | 
					      *Out.Uint32 = PciRead32 (PciAddress);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    case S3BootScriptWidthFifoUint32:
 | 
				
			||||||
 | 
					      DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint32 - 0x%08x\n", PciAddress));
 | 
				
			||||||
 | 
					      *Out.Uint32 = PciRead32 (PciAddress);
 | 
				
			||||||
 | 
					      break;
 | 
				
			||||||
 | 
					    case S3BootScriptWidthFillUint32:
 | 
				
			||||||
 | 
					      DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint32 - 0x%08x\n", PciAddress));
 | 
				
			||||||
 | 
					      *Out.Uint32 = PciRead32 (PciAddress);
 | 
				
			||||||
      break;
 | 
					      break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    default:
 | 
					    default:
 | 
				
			||||||
      return EFI_INVALID_PARAMETER;
 | 
					      return EFI_INVALID_PARAMETER;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
    return EFI_SUCCESS;
 | 
					  return EFI_SUCCESS;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
  Translates boot script to MDE library interface for PCI configuration write operation
 | 
					  Performance PCI configuration write operation
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @param  Width   Width of the operation.
 | 
					  @param  Width   Width of the operation.
 | 
				
			||||||
  @param  Address Address of the operation.
 | 
					  @param  Address Address of the operation.
 | 
				
			||||||
  @param  Buffer  Pointer to the buffer reaf from PCI config space
 | 
					  @param  Count   Count of the number of accesses to perform.
 | 
				
			||||||
 | 
					  @param  Buffer  Pointer to the buffer write to PCI config space
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  @retval EFI_SUCCESS The write succeed.
 | 
					  @retval EFI_SUCCESS The write succeed.
 | 
				
			||||||
  @retval EFI_INVALID_PARAMETER if Width is not defined  
 | 
					  @retval EFI_INVALID_PARAMETER if Width is not defined  
 | 
				
			||||||
@@ -755,40 +857,83 @@ EFI_STATUS
 | 
				
			|||||||
ScriptPciCfgWrite (
 | 
					ScriptPciCfgWrite (
 | 
				
			||||||
  IN  S3_BOOT_SCRIPT_LIB_WIDTH     Width,
 | 
					  IN  S3_BOOT_SCRIPT_LIB_WIDTH     Width,
 | 
				
			||||||
  IN  UINT64                       Address,
 | 
					  IN  UINT64                       Address,
 | 
				
			||||||
  OUT VOID                         *Buffer
 | 
					  IN  UINTN                        Count,
 | 
				
			||||||
 | 
					  IN  VOID                         *Buffer
 | 
				
			||||||
  )
 | 
					  )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  switch (Width) {
 | 
					  EFI_STATUS  Status;
 | 
				
			||||||
    case S3BootScriptWidthUint8:
 | 
					  UINTN       AddressStride;
 | 
				
			||||||
    case S3BootScriptWidthFifoUint8:
 | 
					  UINTN       BufferStride;
 | 
				
			||||||
    case S3BootScriptWidthFillUint8:      
 | 
					  UINTN       OriginalPciAddress;
 | 
				
			||||||
      DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint8 - 0x%016lx (0x%02x)\n", Address, (UINTN)*(UINT8 *) Buffer));
 | 
					  PTR         In;
 | 
				
			||||||
      PciWrite8 (PCI_ADDRESS_ENCODE(Address), *(UINT8 *) Buffer);
 | 
					  PTR         OriginalIn;
 | 
				
			||||||
      break;
 | 
					  UINTN       PciAddress;
 | 
				
			||||||
    case S3BootScriptWidthUint16:
 | 
					
 | 
				
			||||||
    case S3BootScriptWidthFifoUint16:
 | 
					  In.Buf = (UINT8 *) Buffer;
 | 
				
			||||||
    case S3BootScriptWidthFillUint16:       
 | 
					
 | 
				
			||||||
      DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint16 - 0x%016lx (0x%04x)\n", Address, (UINTN)*(UINT16 *) Buffer));
 | 
					  PciAddress = PCI_ADDRESS_ENCODE (Address);
 | 
				
			||||||
      PciWrite16 (PCI_ADDRESS_ENCODE(Address), *(UINT16 *) Buffer);
 | 
					
 | 
				
			||||||
      break;
 | 
					  Status = BuildLoopData (Width, PciAddress, &AddressStride, &BufferStride);
 | 
				
			||||||
    case S3BootScriptWidthUint32:
 | 
					  if (EFI_ERROR (Status)) {
 | 
				
			||||||
    case S3BootScriptWidthFifoUint32:
 | 
					    return Status;
 | 
				
			||||||
    case S3BootScriptWidthFillUint32:       
 | 
					 | 
				
			||||||
      DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint32 - 0x%016lx (0x%08x)\n", Address, (UINTN)*(UINT32 *) Buffer));
 | 
					 | 
				
			||||||
      PciWrite32 (PCI_ADDRESS_ENCODE(Address), *(UINT32 *) Buffer);
 | 
					 | 
				
			||||||
      break;
 | 
					 | 
				
			||||||
    default:
 | 
					 | 
				
			||||||
      return EFI_INVALID_PARAMETER;
 | 
					 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
    return EFI_SUCCESS;
 | 
					  //
 | 
				
			||||||
 | 
					  // Loop for each iteration and move the data
 | 
				
			||||||
 | 
					  //
 | 
				
			||||||
 | 
					  OriginalPciAddress = PciAddress;
 | 
				
			||||||
 | 
					  OriginalIn.Buf = In.Buf;
 | 
				
			||||||
 | 
					  for (; Count > 0; Count--, PciAddress += AddressStride, In.Buf += BufferStride) {
 | 
				
			||||||
 | 
					    switch (Width) {
 | 
				
			||||||
 | 
					      case S3BootScriptWidthUint8:
 | 
				
			||||||
 | 
					        DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint8 - 0x%08x (0x%02x)\n", PciAddress, (UINTN)*In.Uint8));
 | 
				
			||||||
 | 
					        PciWrite8 (PciAddress, *In.Uint8);
 | 
				
			||||||
 | 
					        break;      
 | 
				
			||||||
 | 
					      case S3BootScriptWidthFifoUint8:
 | 
				
			||||||
 | 
					        DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x (0x%02x)\n", OriginalPciAddress, (UINTN)*In.Uint8));
 | 
				
			||||||
 | 
					        PciWrite8 (OriginalPciAddress, *In.Uint8);
 | 
				
			||||||
 | 
					        break;      
 | 
				
			||||||
 | 
					      case S3BootScriptWidthFillUint8:
 | 
				
			||||||
 | 
					        DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%08x (0x%02x)\n", PciAddress, (UINTN)*OriginalIn.Uint8));
 | 
				
			||||||
 | 
					        PciWrite8 (PciAddress, *OriginalIn.Uint8);
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					      case S3BootScriptWidthUint16:
 | 
				
			||||||
 | 
					        DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint16 - 0x%08x (0x%04x)\n", PciAddress, (UINTN)*In.Uint16));
 | 
				
			||||||
 | 
					        PciWrite16 (PciAddress, *In.Uint16);
 | 
				
			||||||
 | 
					        break;      
 | 
				
			||||||
 | 
					      case S3BootScriptWidthFifoUint16:
 | 
				
			||||||
 | 
					        DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint16 - 0x%08x (0x%04x)\n", OriginalPciAddress, (UINTN)*In.Uint16));
 | 
				
			||||||
 | 
					        PciWrite16 (OriginalPciAddress, *In.Uint16);
 | 
				
			||||||
 | 
					        break;      
 | 
				
			||||||
 | 
					      case S3BootScriptWidthFillUint16:
 | 
				
			||||||
 | 
					        DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint16 - 0x%08x (0x%04x)\n", PciAddress, (UINTN)*OriginalIn.Uint16));
 | 
				
			||||||
 | 
					        PciWrite16 (PciAddress, *OriginalIn.Uint16);
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					      case S3BootScriptWidthUint32:
 | 
				
			||||||
 | 
					        DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint32 - 0x%08x (0x%08x)\n", PciAddress, (UINTN)*In.Uint32));
 | 
				
			||||||
 | 
					        PciWrite32 (PciAddress, *In.Uint32);
 | 
				
			||||||
 | 
					        break;      
 | 
				
			||||||
 | 
					      case S3BootScriptWidthFifoUint32:
 | 
				
			||||||
 | 
					        DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint32 - 0x%08x (0x%08x)\n", OriginalPciAddress, (UINTN)*In.Uint32));
 | 
				
			||||||
 | 
					        PciWrite32 (OriginalPciAddress, *In.Uint32);
 | 
				
			||||||
 | 
					        break;      
 | 
				
			||||||
 | 
					      case S3BootScriptWidthFillUint32:
 | 
				
			||||||
 | 
					        DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint32 - 0x%08x (0x%08x)\n", (UINTN)PciAddress, (UINTN)*OriginalIn.Uint32));
 | 
				
			||||||
 | 
					        PciWrite32 (PciAddress, *OriginalIn.Uint32);
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
 | 
					      default:
 | 
				
			||||||
 | 
					        return EFI_INVALID_PARAMETER;
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  return EFI_SUCCESS;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
  Perform pci configure 2 read operation.
 | 
					  Performance PCI configuration 2 read operation
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  @param     Width                      Width of the operation.
 | 
					  @param     Width                      Width of the operation.
 | 
				
			||||||
  @param     Segment                    Pci segment number
 | 
					  @param     Segment                    Pci segment number
 | 
				
			||||||
  @param     Address                    Address of the operation.
 | 
					  @param     Address                    Address of the operation.
 | 
				
			||||||
  @param     Buffer                     Pointer to the buffer to write to I/O space.  
 | 
					  @param     Count                      Count of the number of accesses to perform.
 | 
				
			||||||
 | 
					  @param     Buffer                     Pointer to the buffer to read from PCI config space.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @retval    EFI_SUCCESS                The data was written to the EFI System.
 | 
					  @retval    EFI_SUCCESS                The data was written to the EFI System.
 | 
				
			||||||
  @retval    EFI_INVALID_PARAMETER      Width is invalid for this EFI System.
 | 
					  @retval    EFI_INVALID_PARAMETER      Width is invalid for this EFI System.
 | 
				
			||||||
@@ -803,20 +948,22 @@ ScriptPciCfg2Read (
 | 
				
			|||||||
  IN  S3_BOOT_SCRIPT_LIB_WIDTH    Width,
 | 
					  IN  S3_BOOT_SCRIPT_LIB_WIDTH    Width,
 | 
				
			||||||
  IN  UINT16                   Segment,  
 | 
					  IN  UINT16                   Segment,  
 | 
				
			||||||
  IN  UINT64                   Address,
 | 
					  IN  UINT64                   Address,
 | 
				
			||||||
 | 
					  IN  UINTN                    Count,
 | 
				
			||||||
  OUT VOID                     *Buffer
 | 
					  OUT VOID                     *Buffer
 | 
				
			||||||
  )
 | 
					  )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  ASSERT (Segment==0);
 | 
					  ASSERT (Segment==0);
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  return ScriptPciCfgRead (Width, Address, Buffer);
 | 
					  return ScriptPciCfgRead (Width, Address, Count, Buffer);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
  Perform pci configure write operation.
 | 
					  Performance PCI configuration 2 write operation
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  @param     Width                      Width of the operation.
 | 
					  @param     Width                      Width of the operation.
 | 
				
			||||||
  @param     Segment                    Pci segment number
 | 
					  @param     Segment                    Pci segment number
 | 
				
			||||||
  @param     Address                    Address of the operation.
 | 
					  @param     Address                    Address of the operation.
 | 
				
			||||||
  @param     Buffer                     Pointer to the buffer to write to I/O space.  
 | 
					  @param     Count                      Count of the number of accesses to perform.
 | 
				
			||||||
 | 
					  @param     Buffer                     Pointer to the buffer to write to PCI config space.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @retval    EFI_SUCCESS                The data was written to the EFI System.
 | 
					  @retval    EFI_SUCCESS                The data was written to the EFI System.
 | 
				
			||||||
  @retval    EFI_INVALID_PARAMETER      Width is invalid for this EFI System.
 | 
					  @retval    EFI_INVALID_PARAMETER      Width is invalid for this EFI System.
 | 
				
			||||||
@@ -833,14 +980,15 @@ ScriptPciCfg2Write (
 | 
				
			|||||||
  IN  S3_BOOT_SCRIPT_LIB_WIDTH    Width,
 | 
					  IN  S3_BOOT_SCRIPT_LIB_WIDTH    Width,
 | 
				
			||||||
  IN  UINT16                   Segment,  
 | 
					  IN  UINT16                   Segment,  
 | 
				
			||||||
  IN  UINT64                   Address,
 | 
					  IN  UINT64                   Address,
 | 
				
			||||||
  OUT VOID                     *Buffer
 | 
					  IN  UINTN                    Count,
 | 
				
			||||||
 | 
					  IN  VOID                     *Buffer
 | 
				
			||||||
  )
 | 
					  )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  ASSERT (Segment==0);
 | 
					  ASSERT (Segment==0);
 | 
				
			||||||
  return ScriptPciCfgWrite (Width, Address, Buffer);
 | 
					  return ScriptPciCfgWrite (Width, Address, Count, Buffer);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
  Perform Pci configuration Write operation.
 | 
					  Interprete the boot script node with EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE OP code.
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  @param  Script        The pointer of typed node in boot script table 
 | 
					  @param  Script        The pointer of typed node in boot script table 
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
@@ -851,50 +999,24 @@ BootScriptExecutePciCfgWrite (
 | 
				
			|||||||
  IN UINT8                    *Script
 | 
					  IN UINT8                    *Script
 | 
				
			||||||
  )
 | 
					  )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  EFI_STATUS  Status;
 | 
					  VOID                              *Buffer;
 | 
				
			||||||
  UINT8       *Buffer;
 | 
					  S3_BOOT_SCRIPT_LIB_WIDTH          Width;
 | 
				
			||||||
  UINTN       DataWidth;
 | 
					  UINT64                            Address;
 | 
				
			||||||
  UINTN       Index;
 | 
					  UINTN                             Count;
 | 
				
			||||||
  UINT64      PciAddress;
 | 
					  EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE  PciCfgWrite;
 | 
				
			||||||
  UINT8       Reg;
 | 
					 | 
				
			||||||
  EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE  PciConfigWrite;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  CopyMem ((VOID*)&PciConfigWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE));
 | 
					  CopyMem ((VOID*)&PciCfgWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE));
 | 
				
			||||||
  Status      = EFI_SUCCESS;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  PciAddress  = PciConfigWrite.Address;
 | 
					  Width   = (S3_BOOT_SCRIPT_LIB_WIDTH)PciCfgWrite.Width;
 | 
				
			||||||
  DataWidth   = (UINT32)(0x01 << (PciConfigWrite.Width));
 | 
					  Address = PciCfgWrite.Address;
 | 
				
			||||||
  Buffer      = Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE);
 | 
					  Count   = PciCfgWrite.Count;
 | 
				
			||||||
 | 
					  Buffer  = Script + sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  DEBUG ((EFI_D_INFO, "BootScriptExecutePciCfgWrite - 0x%08x, 0x%08x, 0x%08x\n", (UINTN)PciAddress, (UINTN)PciConfigWrite.Count, (UINTN)DataWidth));
 | 
					  DEBUG ((EFI_D_INFO, "BootScriptExecutePciCfgWrite - 0x%08x, 0x%08x, 0x%08x\n", PCI_ADDRESS_ENCODE (Address), Count, (UINTN)Width));
 | 
				
			||||||
 | 
					  return ScriptPciCfgWrite (Width, Address, Count, Buffer);
 | 
				
			||||||
  for (Index = 0; Index < PciConfigWrite.Count; Index++) {
 | 
					 | 
				
			||||||
    Status = ScriptPciCfgWrite (
 | 
					 | 
				
			||||||
               (S3_BOOT_SCRIPT_LIB_WIDTH) PciConfigWrite.Width,
 | 
					 | 
				
			||||||
               PciAddress,
 | 
					 | 
				
			||||||
               Buffer
 | 
					 | 
				
			||||||
               );
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
   if ( S3BootScriptWidthFillUint8 !=  PciConfigWrite.Width ||
 | 
					 | 
				
			||||||
        S3BootScriptWidthFillUint16 != PciConfigWrite.Width || 
 | 
					 | 
				
			||||||
        S3BootScriptWidthFillUint32 != PciConfigWrite.Width ||
 | 
					 | 
				
			||||||
        S3BootScriptWidthFillUint64 != PciConfigWrite.Width){
 | 
					 | 
				
			||||||
      Reg         = (UINT8) ((UINT8) PciAddress + DataWidth);
 | 
					 | 
				
			||||||
      PciAddress  = (PciAddress & 0xFFFFFFFFFFFFFF00ULL) + Reg;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (S3BootScriptWidthFifoUint8 != PciConfigWrite.Width ||
 | 
					 | 
				
			||||||
        S3BootScriptWidthFifoUint16 != PciConfigWrite.Width || 
 | 
					 | 
				
			||||||
        S3BootScriptWidthFifoUint32 != PciConfigWrite.Width ||
 | 
					 | 
				
			||||||
        S3BootScriptWidthFifoUint64 != PciConfigWrite.Width) {
 | 
					 | 
				
			||||||
      Buffer += DataWidth;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
  return Status;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
  Excute the script to perform IO modification operation.
 | 
					  Interprete the boot script node with EFI_BOOT_SCRIPT_IO_READ_WRITE OP code.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @param Script   The pointer of typed node in boot script table 
 | 
					  @param Script   The pointer of typed node in boot script table 
 | 
				
			||||||
  @param AndMask  Mask value for 'and' operation
 | 
					  @param AndMask  Mask value for 'and' operation
 | 
				
			||||||
@@ -918,7 +1040,7 @@ BootScriptExecuteIoReadWrite (
 | 
				
			|||||||
  
 | 
					  
 | 
				
			||||||
  CopyMem((VOID*)&IoReadWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_IO_READ_WRITE));
 | 
					  CopyMem((VOID*)&IoReadWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_IO_READ_WRITE));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  DEBUG ((EFI_D_INFO, "BootScriptExecuteIoReadWrite - 0x%08x, 0x%016lx, 0x%016lx\n", (UINTN)IoReadWrite.Address, (UINT64)AndMask, (UINT64)OrMask));
 | 
					  DEBUG ((EFI_D_INFO, "BootScriptExecuteIoReadWrite - 0x%08x, 0x%016lx, 0x%016lx\n", (UINTN)IoReadWrite.Address, AndMask, OrMask));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Status = ScriptIoRead (
 | 
					  Status = ScriptIoRead (
 | 
				
			||||||
             (S3_BOOT_SCRIPT_LIB_WIDTH) IoReadWrite.Width,
 | 
					             (S3_BOOT_SCRIPT_LIB_WIDTH) IoReadWrite.Width,
 | 
				
			||||||
@@ -938,7 +1060,7 @@ BootScriptExecuteIoReadWrite (
 | 
				
			|||||||
  return Status;
 | 
					  return Status;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
  Excute the script to perform memory modification operation.
 | 
					  Interprete the boot script node with EFI_BOOT_SCRIPT_MEM_READ_WRITE OP code.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @param Script    The pointer of typed node in boot script table 
 | 
					  @param Script    The pointer of typed node in boot script table 
 | 
				
			||||||
  @param AndMask   Mask value for 'and' operation
 | 
					  @param AndMask   Mask value for 'and' operation
 | 
				
			||||||
@@ -962,7 +1084,7 @@ BootScriptExecuteMemoryReadWrite (
 | 
				
			|||||||
  
 | 
					  
 | 
				
			||||||
  CopyMem((VOID*)&MemReadWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_MEM_READ_WRITE));
 | 
					  CopyMem((VOID*)&MemReadWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_MEM_READ_WRITE));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  DEBUG ((EFI_D_INFO, "BootScriptExecuteMemoryReadWrite - 0x%08x, 0x%016lx, 0x%016lx\n", (UINTN)MemReadWrite.Address, (UINT64)AndMask, (UINT64)OrMask));
 | 
					  DEBUG ((EFI_D_INFO, "BootScriptExecuteMemoryReadWrite - 0x%08x, 0x%016lx, 0x%016lx\n", (UINTN)MemReadWrite.Address, AndMask, OrMask));
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  Status = ScriptMemoryRead (
 | 
					  Status = ScriptMemoryRead (
 | 
				
			||||||
             (S3_BOOT_SCRIPT_LIB_WIDTH) MemReadWrite.Width,
 | 
					             (S3_BOOT_SCRIPT_LIB_WIDTH) MemReadWrite.Width,
 | 
				
			||||||
@@ -982,7 +1104,7 @@ BootScriptExecuteMemoryReadWrite (
 | 
				
			|||||||
  return Status;
 | 
					  return Status;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
  Excute the script to perform PCI IO modification operation.
 | 
					  Interprete the boot script node with EFI_BOOT_SCRIPT_PCI_CFG_READ_WRITE OP code.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @param Script   The pointer of typed node in boot script table 
 | 
					  @param Script   The pointer of typed node in boot script table 
 | 
				
			||||||
  @param AndMask  Mask value for 'and' operation
 | 
					  @param AndMask  Mask value for 'and' operation
 | 
				
			||||||
@@ -1004,11 +1126,12 @@ BootScriptExecutePciCfgReadWrite (
 | 
				
			|||||||
  
 | 
					  
 | 
				
			||||||
  CopyMem((VOID*)&PciCfgReadWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE));
 | 
					  CopyMem((VOID*)&PciCfgReadWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  DEBUG ((EFI_D_INFO, "BootScriptExecutePciCfgReadWrite - 0x%08x, 0x%016lx, 0x%016lx\n", (UINTN)PciCfgReadWrite.Address, (UINT64)AndMask, (UINT64)OrMask));
 | 
					  DEBUG ((EFI_D_INFO, "BootScriptExecutePciCfgReadWrite - 0x%08x, 0x%016lx, 0x%016lx\n", PCI_ADDRESS_ENCODE (PciCfgReadWrite.Address), AndMask, OrMask));
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  Status = ScriptPciCfgRead (
 | 
					  Status = ScriptPciCfgRead (
 | 
				
			||||||
             (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfgReadWrite.Width,
 | 
					             (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfgReadWrite.Width,
 | 
				
			||||||
             PciCfgReadWrite.Address,
 | 
					             PciCfgReadWrite.Address,
 | 
				
			||||||
 | 
					             1,
 | 
				
			||||||
             &Data
 | 
					             &Data
 | 
				
			||||||
             );
 | 
					             );
 | 
				
			||||||
  if (EFI_ERROR (Status)) {
 | 
					  if (EFI_ERROR (Status)) {
 | 
				
			||||||
@@ -1020,13 +1143,14 @@ BootScriptExecutePciCfgReadWrite (
 | 
				
			|||||||
  Status = ScriptPciCfgWrite (
 | 
					  Status = ScriptPciCfgWrite (
 | 
				
			||||||
             (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfgReadWrite.Width,
 | 
					             (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfgReadWrite.Width,
 | 
				
			||||||
             PciCfgReadWrite.Address,
 | 
					             PciCfgReadWrite.Address,
 | 
				
			||||||
 | 
					             1,
 | 
				
			||||||
             &Data
 | 
					             &Data
 | 
				
			||||||
             );
 | 
					             );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  return Status;
 | 
					  return Status;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
  To Execute SMBUS command. 
 | 
					  Interprete the boot script node with EFI_BOOT_SCRIPT_SMBUS_EXECUTE OP code.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @param Script  The pointer of typed node in boot script table 
 | 
					  @param Script  The pointer of typed node in boot script table 
 | 
				
			||||||
 
 | 
					 
 | 
				
			||||||
@@ -1057,7 +1181,7 @@ BootScriptExecuteSmbusExecute (
 | 
				
			|||||||
           );
 | 
					           );
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
  Execute stall operation in boot script table.
 | 
					  Interprete the boot script node with EFI_BOOT_SCRIPT_STALL OP code.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @param Script      The pointer of typed node in boot script table 
 | 
					  @param Script      The pointer of typed node in boot script table 
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
@@ -1078,10 +1202,10 @@ BootScriptExecuteStall (
 | 
				
			|||||||
  return EFI_SUCCESS;
 | 
					  return EFI_SUCCESS;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
 To execute assigned function.
 | 
					  Interprete the boot script node with EFI_BOOT_SCRIPT_DISPATCH OP code.
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
 @param Script  The pointer of typed node in boot script table 
 | 
					  @param Script  The pointer of typed node in boot script table 
 | 
				
			||||||
 @retval EFI_SUCCESS  The operation was executed successfully
 | 
					  @retval EFI_SUCCESS  The operation was executed successfully
 | 
				
			||||||
**/
 | 
					**/
 | 
				
			||||||
EFI_STATUS
 | 
					EFI_STATUS
 | 
				
			||||||
BootScriptExecuteDispatch (
 | 
					BootScriptExecuteDispatch (
 | 
				
			||||||
@@ -1102,7 +1226,7 @@ BootScriptExecuteDispatch (
 | 
				
			|||||||
  return Status;
 | 
					  return Status;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
  Execute dispach2 opertion code which is to invoke a spcified function with one parameter. 
 | 
					  Interprete the boot script node with EFI_BOOT_SCRIPT_DISPATCH_2 OP code.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @param  Script       The pointer of typed node in boot script table 
 | 
					  @param  Script       The pointer of typed node in boot script table 
 | 
				
			||||||
  @retval EFI_SUCCESS  The operation was executed successfully
 | 
					  @retval EFI_SUCCESS  The operation was executed successfully
 | 
				
			||||||
@@ -1127,7 +1251,7 @@ BootScriptExecuteDispatch2 (
 | 
				
			|||||||
  return Status;
 | 
					  return Status;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
  Excute the script to poll memory.
 | 
					  Interprete the boot script node with EFI_BOOT_SCRIPT_MEM_POLL OP code.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @param  Script  The pointer of typed node in boot script table 
 | 
					  @param  Script  The pointer of typed node in boot script table 
 | 
				
			||||||
  @param  AndMask  Mask value for 'and' operation
 | 
					  @param  AndMask  Mask value for 'and' operation
 | 
				
			||||||
@@ -1152,7 +1276,7 @@ BootScriptExecuteMemPoll (
 | 
				
			|||||||
  
 | 
					  
 | 
				
			||||||
  CopyMem ((VOID*)&MemPoll, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_MEM_POLL));
 | 
					  CopyMem ((VOID*)&MemPoll, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_MEM_POLL));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  DEBUG ((EFI_D_INFO, "BootScriptExecuteMemPoll - 0x%08x\n", (UINTN)MemPoll.Address));
 | 
					  DEBUG ((EFI_D_INFO, "BootScriptExecuteMemPoll - 0x%08x, 0x%016lx, 0x%016lx\n", (UINTN)MemPoll.Address, AndMask, OrMask));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Data = 0;
 | 
					  Data = 0;
 | 
				
			||||||
  Status = ScriptMemoryRead (
 | 
					  Status = ScriptMemoryRead (
 | 
				
			||||||
@@ -1187,7 +1311,7 @@ BootScriptExecuteMemPoll (
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
  Execute the boot script to interpret the  Store arbitrary information. 
 | 
					  Execute the boot script to interpret the Store arbitrary information.
 | 
				
			||||||
  This opcode is a no-op on dispatch and is only used for debugging script issues.
 | 
					  This opcode is a no-op on dispatch and is only used for debugging script issues.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @param Script       The pointer of node in boot script table 
 | 
					  @param Script       The pointer of node in boot script table 
 | 
				
			||||||
@@ -1328,7 +1452,7 @@ CheckAndOrMask (
 | 
				
			|||||||
  return;
 | 
					  return;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
  Excute the script to poll Io port for some time
 | 
					  Interprete the boot script node with EFI_BOOT_SCRIPT_IO_POLL OP code.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @param  Script  The pointer of typed node in boot script table 
 | 
					  @param  Script  The pointer of typed node in boot script table 
 | 
				
			||||||
  @param  AndMask  Mask value for 'and' operation
 | 
					  @param  AndMask  Mask value for 'and' operation
 | 
				
			||||||
@@ -1352,7 +1476,7 @@ BootScriptExecuteIoPoll (
 | 
				
			|||||||
  
 | 
					  
 | 
				
			||||||
  CopyMem ((VOID*)&IoPoll, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_IO_POLL));
 | 
					  CopyMem ((VOID*)&IoPoll, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_IO_POLL));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  DEBUG ((EFI_D_INFO, "BootScriptExecuteIoPoll - 0x%08x\n", (UINTN)IoPoll.Address));
 | 
					  DEBUG ((EFI_D_INFO, "BootScriptExecuteIoPoll - 0x%08x, 0x%016lx, 0x%016lx\n", (UINTN)IoPoll.Address, AndMask, OrMask));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  Data = 0;
 | 
					  Data = 0;
 | 
				
			||||||
  Status = ScriptIoRead (
 | 
					  Status = ScriptIoRead (
 | 
				
			||||||
@@ -1385,7 +1509,7 @@ BootScriptExecuteIoPoll (
 | 
				
			|||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
  Perform Pci configuration Write operation.
 | 
					  Interprete the boot script node with EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE OP code.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  @param    Script              The pointer of S3 boot script
 | 
					  @param    Script              The pointer of S3 boot script
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -1397,52 +1521,28 @@ BootScriptExecutePciCfg2Write (
 | 
				
			|||||||
  IN UINT8             *Script
 | 
					  IN UINT8             *Script
 | 
				
			||||||
  )
 | 
					  )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
  UINT8       Reg;
 | 
					  VOID                              *Buffer;
 | 
				
			||||||
  UINT8       *Buffer;
 | 
					  S3_BOOT_SCRIPT_LIB_WIDTH          Width;
 | 
				
			||||||
  UINTN       DataWidth;
 | 
					  UINT16                            Segment;
 | 
				
			||||||
  UINTN       Index;
 | 
					  UINT64                            Address;
 | 
				
			||||||
  UINT16      Segment;
 | 
					  UINTN                             Count;
 | 
				
			||||||
  UINT64      PciAddress;
 | 
					  EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE PciCfg2Write;
 | 
				
			||||||
  EFI_STATUS  Status;
 | 
					 | 
				
			||||||
  EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE  PciCfg2Write;
 | 
					 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  CopyMem ((VOID*)&PciCfg2Write, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE));
 | 
					  CopyMem ((VOID*)&PciCfg2Write, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE));
 | 
				
			||||||
  Status      = EFI_SUCCESS;
 | 
					 | 
				
			||||||
  Segment     = PciCfg2Write.Segment;
 | 
					 | 
				
			||||||
  PciAddress  = PciCfg2Write.Address;
 | 
					 | 
				
			||||||
  DataWidth   = (UINT32)(0x01 << (PciCfg2Write.Width));
 | 
					 | 
				
			||||||
  Buffer      = Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
  DEBUG ((EFI_D_INFO, "BootScriptExecutePciCfg2Write - 0x%08x\n", (UINTN)PciAddress));
 | 
					  Width   = (S3_BOOT_SCRIPT_LIB_WIDTH)PciCfg2Write.Width;
 | 
				
			||||||
 | 
					  Segment = PciCfg2Write.Segment;
 | 
				
			||||||
 | 
					  Address = PciCfg2Write.Address;
 | 
				
			||||||
 | 
					  Count   = PciCfg2Write.Count;
 | 
				
			||||||
 | 
					  Buffer  = Script + sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  for (Index = 0; Index < PciCfg2Write.Count; Index++) {
 | 
					  DEBUG ((EFI_D_INFO, "BootScriptExecutePciCfg2Write - 0x%04x, 0x%08x, 0x%08x, 0x%08x\n", Segment, PCI_ADDRESS_ENCODE (Address), Count, (UINTN)Width));
 | 
				
			||||||
    Status = ScriptPciCfg2Write (
 | 
					  return ScriptPciCfg2Write (Width, Segment, Address, Count, Buffer);
 | 
				
			||||||
               (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfg2Write.Width,
 | 
					 | 
				
			||||||
               Segment,
 | 
					 | 
				
			||||||
               PciAddress,
 | 
					 | 
				
			||||||
               Buffer
 | 
					 | 
				
			||||||
               );
 | 
					 | 
				
			||||||
    if (S3BootScriptWidthFillUint8  != PciCfg2Write.Width ||
 | 
					 | 
				
			||||||
        S3BootScriptWidthFillUint16 != PciCfg2Write.Width || 
 | 
					 | 
				
			||||||
        S3BootScriptWidthFillUint32 != PciCfg2Write.Width ||
 | 
					 | 
				
			||||||
        S3BootScriptWidthFillUint64 != PciCfg2Write.Width){
 | 
					 | 
				
			||||||
      Reg         = (UINT8) ((UINT8) PciAddress + DataWidth);
 | 
					 | 
				
			||||||
      PciAddress  = (PciAddress & 0xFFFFFFFFFFFFFF00ULL) + Reg;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    if (S3BootScriptWidthFifoUint8  != PciCfg2Write.Width ||
 | 
					 | 
				
			||||||
        S3BootScriptWidthFifoUint16 != PciCfg2Write.Width || 
 | 
					 | 
				
			||||||
        S3BootScriptWidthFifoUint32 != PciCfg2Write.Width ||
 | 
					 | 
				
			||||||
        S3BootScriptWidthFifoUint64 != PciCfg2Write.Width) {
 | 
					 | 
				
			||||||
      Buffer += DataWidth;
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
  }
 | 
					 | 
				
			||||||
  return Status;
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
  Perform pci configuration read & Write operation.
 | 
					  Interprete the boot script node with EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE OP code.
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  @param     Script                     The pointer of S3 boot script
 | 
					  @param     Script                     The pointer of S3 boot script
 | 
				
			||||||
  @param     AndMask                    Mask value for 'and' operation
 | 
					  @param     AndMask                    Mask value for 'and' operation
 | 
				
			||||||
@@ -1463,12 +1563,13 @@ BootScriptExecutePciCfg2ReadWrite (
 | 
				
			|||||||
  EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE PciCfg2ReadWrite;
 | 
					  EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE PciCfg2ReadWrite;
 | 
				
			||||||
  CopyMem ((VOID*)&PciCfg2ReadWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE));
 | 
					  CopyMem ((VOID*)&PciCfg2ReadWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  DEBUG ((EFI_D_INFO, "BootScriptExecutePciCfg2ReadWrite - 0x%08x\n", (UINTN)PciCfg2ReadWrite.Address));
 | 
					  DEBUG ((EFI_D_INFO, "BootScriptExecutePciCfg2ReadWrite - 0x%04x, 0x%08x, 0x%016lx, 0x%016lx\n", PciCfg2ReadWrite.Segment, PCI_ADDRESS_ENCODE (PciCfg2ReadWrite.Address), AndMask, OrMask));
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  Status = ScriptPciCfg2Read (
 | 
					  Status = ScriptPciCfg2Read (
 | 
				
			||||||
             (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfg2ReadWrite.Width,
 | 
					             (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfg2ReadWrite.Width,
 | 
				
			||||||
             PciCfg2ReadWrite.Segment,
 | 
					             PciCfg2ReadWrite.Segment,
 | 
				
			||||||
             PciCfg2ReadWrite.Address,
 | 
					             PciCfg2ReadWrite.Address,
 | 
				
			||||||
 | 
					             1,
 | 
				
			||||||
             &Data
 | 
					             &Data
 | 
				
			||||||
             );
 | 
					             );
 | 
				
			||||||
  if (EFI_ERROR (Status)) {
 | 
					  if (EFI_ERROR (Status)) {
 | 
				
			||||||
@@ -1480,12 +1581,13 @@ BootScriptExecutePciCfg2ReadWrite (
 | 
				
			|||||||
             (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfg2ReadWrite.Width,
 | 
					             (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfg2ReadWrite.Width,
 | 
				
			||||||
             PciCfg2ReadWrite.Segment,
 | 
					             PciCfg2ReadWrite.Segment,
 | 
				
			||||||
             PciCfg2ReadWrite.Address,
 | 
					             PciCfg2ReadWrite.Address,
 | 
				
			||||||
 | 
					             1,
 | 
				
			||||||
             &Data
 | 
					             &Data
 | 
				
			||||||
             );
 | 
					             );
 | 
				
			||||||
  return Status;
 | 
					  return Status;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
  To perform poll pci configure operation.
 | 
					  Interprete the boot script node with EFI_BOOT_SCRIPT_PCI_CONFIG_POLL OP code.
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  @param     Script                     The pointer of S3 boot script
 | 
					  @param     Script                     The pointer of S3 boot script
 | 
				
			||||||
  @param     AndMask                    Mask value for 'and' operation
 | 
					  @param     AndMask                    Mask value for 'and' operation
 | 
				
			||||||
@@ -1508,12 +1610,13 @@ BootScriptPciCfgPoll (
 | 
				
			|||||||
  EFI_BOOT_SCRIPT_PCI_CONFIG_POLL PciCfgPoll;
 | 
					  EFI_BOOT_SCRIPT_PCI_CONFIG_POLL PciCfgPoll;
 | 
				
			||||||
  CopyMem ((VOID*)&PciCfgPoll, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG_POLL));
 | 
					  CopyMem ((VOID*)&PciCfgPoll, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG_POLL));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  DEBUG ((EFI_D_INFO, "BootScriptPciCfgPoll - 0x%08x\n", (UINTN)PciCfgPoll.Address));
 | 
					  DEBUG ((EFI_D_INFO, "BootScriptPciCfgPoll - 0x%08x, 0x%016lx, 0x%016lx\n", PCI_ADDRESS_ENCODE (PciCfgPoll.Address), AndMask, OrMask));
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  Data = 0;
 | 
					  Data = 0;
 | 
				
			||||||
  Status = ScriptPciCfgRead (
 | 
					  Status = ScriptPciCfgRead (
 | 
				
			||||||
             (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfgPoll.Width,
 | 
					             (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfgPoll.Width,
 | 
				
			||||||
             PciCfgPoll.Address,
 | 
					             PciCfgPoll.Address,
 | 
				
			||||||
 | 
					             1,
 | 
				
			||||||
             &Data
 | 
					             &Data
 | 
				
			||||||
             );
 | 
					             );
 | 
				
			||||||
  if ((!EFI_ERROR (Status)) &&(Data & AndMask) == OrMask) {
 | 
					  if ((!EFI_ERROR (Status)) &&(Data & AndMask) == OrMask) {
 | 
				
			||||||
@@ -1526,6 +1629,7 @@ BootScriptPciCfgPoll (
 | 
				
			|||||||
    Status = ScriptPciCfgRead (
 | 
					    Status = ScriptPciCfgRead (
 | 
				
			||||||
               (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfgPoll.Width,
 | 
					               (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfgPoll.Width,
 | 
				
			||||||
               PciCfgPoll.Address,
 | 
					               PciCfgPoll.Address,
 | 
				
			||||||
 | 
					               1,
 | 
				
			||||||
               &Data
 | 
					               &Data
 | 
				
			||||||
               );
 | 
					               );
 | 
				
			||||||
    if ((!EFI_ERROR (Status)) &&
 | 
					    if ((!EFI_ERROR (Status)) &&
 | 
				
			||||||
@@ -1542,7 +1646,7 @@ BootScriptPciCfgPoll (
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
/**
 | 
					/**
 | 
				
			||||||
  To perform poll pci configure operation.
 | 
					  Interprete the boot script node with EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL OP code.
 | 
				
			||||||
  
 | 
					  
 | 
				
			||||||
  @param     Script                     The pointer of S3 Boot Script
 | 
					  @param     Script                     The pointer of S3 Boot Script
 | 
				
			||||||
  @param     AndMask                    Mask value for 'and' operation
 | 
					  @param     AndMask                    Mask value for 'and' operation
 | 
				
			||||||
@@ -1568,12 +1672,13 @@ BootScriptPciCfg2Poll (
 | 
				
			|||||||
  Data = 0;
 | 
					  Data = 0;
 | 
				
			||||||
  CopyMem ((VOID*)&PciCfg2Poll, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL));
 | 
					  CopyMem ((VOID*)&PciCfg2Poll, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  DEBUG ((EFI_D_INFO, "BootScriptPciCfg2Poll - 0x%08x\n", (UINTN)PciCfg2Poll.Address));
 | 
					  DEBUG ((EFI_D_INFO, "BootScriptPciCfg2Poll - 0x%04x, 0x%08x, 0x%016lx, 0x%016lx\n", PciCfg2Poll.Segment, PCI_ADDRESS_ENCODE (PciCfg2Poll.Address), AndMask, OrMask));
 | 
				
			||||||
 
 | 
					 
 | 
				
			||||||
  Status = ScriptPciCfg2Read (
 | 
					  Status = ScriptPciCfg2Read (
 | 
				
			||||||
             (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfg2Poll.Width,
 | 
					             (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfg2Poll.Width,
 | 
				
			||||||
             PciCfg2Poll.Segment,
 | 
					             PciCfg2Poll.Segment,
 | 
				
			||||||
             PciCfg2Poll.Address,
 | 
					             PciCfg2Poll.Address,
 | 
				
			||||||
 | 
					             1,
 | 
				
			||||||
             &Data
 | 
					             &Data
 | 
				
			||||||
             );
 | 
					             );
 | 
				
			||||||
  if ((!EFI_ERROR (Status)) && (Data & AndMask) == OrMask) {
 | 
					  if ((!EFI_ERROR (Status)) && (Data & AndMask) == OrMask) {
 | 
				
			||||||
@@ -1588,6 +1693,7 @@ BootScriptPciCfg2Poll (
 | 
				
			|||||||
               (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfg2Poll.Width,
 | 
					               (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfg2Poll.Width,
 | 
				
			||||||
               PciCfg2Poll.Segment,               
 | 
					               PciCfg2Poll.Segment,               
 | 
				
			||||||
               PciCfg2Poll.Address,
 | 
					               PciCfg2Poll.Address,
 | 
				
			||||||
 | 
					               1,
 | 
				
			||||||
               &Data
 | 
					               &Data
 | 
				
			||||||
               );
 | 
					               );
 | 
				
			||||||
    if ((!EFI_ERROR (Status)) &&  (Data & AndMask) == OrMask) {
 | 
					    if ((!EFI_ERROR (Status)) &&  (Data & AndMask) == OrMask) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user