X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FLibrary%2FPiDxeS3BootScriptLib%2FBootScriptExecute.c;h=b865d4452fc823ee681a02bfdb695ce6e7c366a2;hb=16f6922709952c7ad468dcdee6ef94b3e5a3cd90;hp=914e7a518c28e811b97043789253b3ba8bed7dc9;hpb=30f804978a0073ea57612bbab39773adc8b85458;p=mirror_edk2.git
diff --git a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c
index 914e7a518c..b865d4452f 100644
--- a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c
+++ b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c
@@ -1,7 +1,7 @@
/** @file
- Interpret and execute the S3 data in S3 boot script.
+ Interpret and execute the S3 data in S3 boot script.
- Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials
are licensed and made available under the terms and conditions
@@ -15,107 +15,6 @@
**/
#include "InternalBootScriptLib.h"
-/**
- Checks the parameter of SmbusExecute().
-
- This function checks the input parameters of SmbusExecute(). If the input parameters are valid
- for certain SMBus bus protocol, it will return EFI_SUCCESS; otherwise, it will return certain
- error code based on the input SMBus bus protocol.
-
- @param SmBusAddress Address that encodes the SMBUS Slave Address, SMBUS Command, SMBUS Data Length,
- and PEC.
- @param Operation Signifies which particular SMBus hardware protocol instance that
- it will use to execute the SMBus transactions. This SMBus
- hardware protocol is defined by the SMBus Specification and is
- not related to EFI.
- @param Length Signifies the number of bytes that this operation will do. The
- maximum number of bytes can be revision specific and operation
- specific. This field will contain the actual number of bytes that
- are executed for this operation. Not all operations require this
- argument.
- @param Buffer Contains the value of data to execute to the SMBus slave device.
- Not all operations require this argument. The length of this
- buffer is identified by Length.
-
- @retval EFI_SUCCESS All the parameters are valid for the corresponding SMBus bus
- protocol.
- @retval EFI_INVALID_PARAMETER Operation is not defined in EFI_SMBUS_OPERATION.
- @retval EFI_INVALID_PARAMETER Length/Buffer is NULL for operations except for EfiSmbusQuickRead
- and EfiSmbusQuickWrite. Length is outside the range of valid
- values.
- @retval EFI_UNSUPPORTED The SMBus operation or PEC is not supported.
- @retval EFI_BUFFER_TOO_SMALL Buffer is not sufficient for this operation.
-
-**/
-EFI_STATUS
-CheckParameters (
- IN UINTN SmBusAddress,
- IN EFI_SMBUS_OPERATION Operation,
- IN OUT UINTN *Length,
- IN OUT VOID *Buffer
- )
-{
- EFI_STATUS Status;
- UINTN RequiredLen;
- EFI_SMBUS_DEVICE_COMMAND Command;
- BOOLEAN PecCheck;
-
- Command = SMBUS_LIB_COMMAND (SmBusAddress);
- PecCheck = SMBUS_LIB_PEC (SmBusAddress);
- //
- // Set default value to be 2:
- // for SmbusReadWord, SmbusWriteWord and SmbusProcessCall.
- //
- RequiredLen = 2;
- Status = EFI_SUCCESS;
- switch (Operation) {
- case EfiSmbusQuickRead:
- case EfiSmbusQuickWrite:
- if (PecCheck || Command != 0) {
- return EFI_UNSUPPORTED;
- }
- break;
- case EfiSmbusReceiveByte:
- case EfiSmbusSendByte:
- if (Command != 0) {
- return EFI_UNSUPPORTED;
- }
- //
- // Cascade to check length parameter.
- //
- case EfiSmbusReadByte:
- case EfiSmbusWriteByte:
- RequiredLen = 1;
- //
- // Cascade to check length parameter.
- //
- case EfiSmbusReadWord:
- case EfiSmbusWriteWord:
- case EfiSmbusProcessCall:
- if (Buffer == NULL || Length == NULL) {
- return EFI_INVALID_PARAMETER;
- } else if (*Length < RequiredLen) {
- Status = EFI_BUFFER_TOO_SMALL;
- }
- *Length = RequiredLen;
- break;
- case EfiSmbusReadBlock:
- case EfiSmbusWriteBlock:
- if ((Buffer == NULL) ||
- (Length == NULL) ||
- (*Length < MIN_SMBUS_BLOCK_LEN) ||
- (*Length > MAX_SMBUS_BLOCK_LEN)) {
- return EFI_INVALID_PARAMETER;
- }
- break;
- case EfiSmbusBWBRProcessCall:
- return EFI_UNSUPPORTED;
- default:
- return EFI_INVALID_PARAMETER;
- }
- return Status;
-}
-
/**
Executes an SMBus operation to an SMBus controller. Returns when either the command has been
executed or an error is encountered in doing the operation.
@@ -124,7 +23,7 @@ CheckParameters (
Management Bus (SMBus) Specification. The resulting transaction will be either that the SMBus
slave devices accept this transaction or that this function returns with error.
- @param SmbusAddress Address that encodes the SMBUS Slave Address, SMBUS Command, SMBUS Data Length,
+ @param SmbusAddress Address that encodes the SMBUS Slave Address, SMBUS Command, SMBUS Data Length,
and PEC.
@param Operation Signifies which particular SMBus hardware protocol instance that
it will use to execute the SMBus transactions. This SMBus
@@ -166,14 +65,8 @@ SmbusExecute (
)
{
EFI_STATUS Status;
- UINTN WorkBufferLen;
UINT8 WorkBuffer[MAX_SMBUS_BLOCK_LEN];
- Status = CheckParameters (SmbusAddress, Operation, Length, Buffer);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
switch (Operation) {
case EfiSmbusQuickRead:
DEBUG ((EFI_D_INFO, "EfiSmbusQuickRead - 0x%08x\n", SmbusAddress));
@@ -185,15 +78,15 @@ SmbusExecute (
break;
case EfiSmbusReceiveByte:
DEBUG ((EFI_D_INFO, "EfiSmbusReceiveByte - 0x%08x\n", SmbusAddress));
- *(UINT8 *) Buffer = SmBusReceiveByte (SmbusAddress, &Status);
+ SmBusReceiveByte (SmbusAddress, &Status);
break;
case EfiSmbusSendByte:
- DEBUG ((EFI_D_INFO, "EfiSmbusReceiveByte - 0x%08x (0x%02x)\n", SmbusAddress, (UINTN)*(UINT8 *) Buffer));
+ DEBUG ((EFI_D_INFO, "EfiSmbusSendByte - 0x%08x (0x%02x)\n", SmbusAddress, (UINTN)*(UINT8 *) Buffer));
SmBusSendByte (SmbusAddress, *(UINT8 *) Buffer, &Status);
break;
case EfiSmbusReadByte:
DEBUG ((EFI_D_INFO, "EfiSmbusReadByte - 0x%08x\n", SmbusAddress));
- *(UINT8 *) Buffer = SmBusReadDataByte (SmbusAddress, &Status);
+ SmBusReadDataByte (SmbusAddress, &Status);
break;
case EfiSmbusWriteByte:
DEBUG ((EFI_D_INFO, "EfiSmbusWriteByte - 0x%08x (0x%02x)\n", SmbusAddress, (UINTN)*(UINT8 *) Buffer));
@@ -201,44 +94,33 @@ SmbusExecute (
break;
case EfiSmbusReadWord:
DEBUG ((EFI_D_INFO, "EfiSmbusReadWord - 0x%08x\n", SmbusAddress));
- *(UINT16 *) Buffer = SmBusReadDataWord (SmbusAddress, &Status);
+ SmBusReadDataWord (SmbusAddress, &Status);
break;
case EfiSmbusWriteWord:
- DEBUG ((EFI_D_INFO, "EfiSmbusWriteByte - 0x%08x (0x%04x)\n", SmbusAddress, (UINTN)*(UINT16 *) Buffer));
+ DEBUG ((EFI_D_INFO, "EfiSmbusWriteWord - 0x%08x (0x%04x)\n", SmbusAddress, (UINTN)*(UINT16 *) Buffer));
SmBusWriteDataWord (SmbusAddress, *(UINT16 *) Buffer, &Status);
break;
case EfiSmbusProcessCall:
DEBUG ((EFI_D_INFO, "EfiSmbusProcessCall - 0x%08x (0x%04x)\n", SmbusAddress, (UINTN)*(UINT16 *) Buffer));
- *(UINT16 *) Buffer = SmBusProcessCall (SmbusAddress, *(UINT16 *) Buffer, &Status);
+ SmBusProcessCall (SmbusAddress, *(UINT16 *) Buffer, &Status);
break;
case EfiSmbusReadBlock:
DEBUG ((EFI_D_INFO, "EfiSmbusReadBlock - 0x%08x\n", SmbusAddress));
- WorkBufferLen = SmBusReadBlock (SmbusAddress, WorkBuffer, &Status);
- if (!EFI_ERROR (Status)) {
- //
- // Read block transaction is complete successfully, and then
- // check whether the output buffer is large enough.
- //
- if (*Length >= WorkBufferLen) {
- CopyMem (Buffer, WorkBuffer, WorkBufferLen);
- } else {
- Status = EFI_BUFFER_TOO_SMALL;
- }
- *Length = WorkBufferLen;
- }
+ SmBusReadBlock (SmbusAddress, WorkBuffer, &Status);
break;
case EfiSmbusWriteBlock:
- DEBUG ((EFI_D_INFO, "EfiSmbusWriteBlock - 0x%08x (0x%04x)\n", SmbusAddress, (UINTN)*(UINT16 *) Buffer));
- SmBusWriteBlock ((SmbusAddress + SMBUS_LIB_ADDRESS (0, 0, (*Length), FALSE)) , Buffer, &Status);
+ DEBUG ((EFI_D_INFO, "EfiSmbusWriteBlock - 0x%08x\n", SmbusAddress));
+ SmBusWriteBlock ((SmbusAddress + SMBUS_LIB_ADDRESS (0, 0, (*Length), FALSE)), Buffer, &Status);
break;
case EfiSmbusBWBRProcessCall:
- //
- // BUGBUG: Should this case be handled?
- //
+ DEBUG ((EFI_D_INFO, "EfiSmbusBWBRProcessCall - 0x%08x\n", SmbusAddress));
+ SmBusBlockProcessCall ((SmbusAddress + SMBUS_LIB_ADDRESS (0, 0, (*Length), FALSE)), Buffer, WorkBuffer, &Status);
break;
+ default:
+ return EFI_INVALID_PARAMETER;
}
- return Status;
+ return Status;
}
/**
@@ -248,7 +130,7 @@ SmbusExecute (
@param Width Width of the operation.
@param Address Address of the operation.
@param AddressStride Instride for stepping input buffer.
- @param BufferStride Outstride for stepping output buffer.
+ @param BufferStride Outstride for stepping output buffer.
@retval EFI_SUCCESS Successful translation.
@retval EFI_INVALID_PARAMETER Width or Address is invalid.
@@ -288,18 +170,18 @@ BuildLoopData (
/**
Perform IO read operation
-
+
@param[in] Width Width of the operation.
@param[in] Address Address of the operation.
@param[in] Count Count of the number of accesses to perform.
- @param[out] Buffer Pointer to the buffer to read from I/O space.
+ @param[out] Buffer Pointer to the buffer to read from I/O space.
@retval EFI_SUCCESS The data was written to the EFI System.
@retval EFI_INVALID_PARAMETER Width is invalid for this EFI System.
Buffer is NULL.
The Buffer is not aligned for the given Width.
- Address is outside the legal range of I/O ports.
-
+ Address is outside the legal range of I/O ports.
+
**/
EFI_STATUS
ScriptIoRead (
@@ -392,18 +274,18 @@ ScriptIoRead (
/**
Perform IO write operation
-
+
@param[in] Width Width of the operation.
@param[in] Address Address of the operation.
@param[in] Count Count of the number of accesses to perform.
- @param[in] Buffer Pointer to the buffer to write to I/O space.
+ @param[in] Buffer Pointer to the buffer to write to I/O space.
@retval EFI_SUCCESS The data was written to the EFI System.
@retval EFI_INVALID_PARAMETER Width is invalid for this EFI System.
Buffer is NULL.
The Buffer is not aligned for the given Width.
- Address is outside the legal range of I/O ports.
-
+ Address is outside the legal range of I/O ports.
+
**/
EFI_STATUS
ScriptIoWrite (
@@ -440,11 +322,11 @@ ScriptIoWrite (
case S3BootScriptWidthUint8:
DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint8 - 0x%08x (0x%02x)\n", (UINTN)Address, (UINTN)*In.Uint8));
IoWrite8 ((UINTN) Address, *In.Uint8);
- break;
+ break;
case S3BootScriptWidthFifoUint8:
DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x (0x%02x)\n", (UINTN)OriginalAddress, (UINTN)*In.Uint8));
IoWrite8 ((UINTN) OriginalAddress, *In.Uint8);
- break;
+ break;
case S3BootScriptWidthFillUint8:
DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%08x (0x%02x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint8));
IoWrite8 ((UINTN) Address, *OriginalIn.Uint8);
@@ -452,11 +334,11 @@ ScriptIoWrite (
case S3BootScriptWidthUint16:
DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint16 - 0x%08x (0x%04x)\n", (UINTN)Address, (UINTN)*In.Uint16));
IoWrite16 ((UINTN) Address, *In.Uint16);
- break;
+ break;
case S3BootScriptWidthFifoUint16:
DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint16 - 0x%08x (0x%04x)\n", (UINTN)OriginalAddress, (UINTN)*In.Uint16));
IoWrite16 ((UINTN) OriginalAddress, *In.Uint16);
- break;
+ break;
case S3BootScriptWidthFillUint16:
DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint16 - 0x%08x (0x%04x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint16));
IoWrite16 ((UINTN) Address, *OriginalIn.Uint16);
@@ -464,7 +346,7 @@ ScriptIoWrite (
case S3BootScriptWidthUint32:
DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint32 - 0x%08x (0x%08x)\n", (UINTN)Address, (UINTN)*In.Uint32));
IoWrite32 ((UINTN) Address, *In.Uint32);
- break;
+ break;
case S3BootScriptWidthFifoUint32:
DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint32 - 0x%08x (0x%08x)\n", (UINTN)OriginalAddress, (UINTN)*In.Uint32));
IoWrite32 ((UINTN) OriginalAddress, *In.Uint32);
@@ -476,11 +358,11 @@ ScriptIoWrite (
case S3BootScriptWidthUint64:
DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint64 - 0x%08x (0x%016lx)\n", (UINTN)Address, *In.Uint64));
IoWrite64 ((UINTN) Address, *In.Uint64);
- break;
+ break;
case S3BootScriptWidthFifoUint64:
DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint64 - 0x%08x (0x%016lx)\n", (UINTN)OriginalAddress, *In.Uint64));
IoWrite64 ((UINTN) OriginalAddress, *In.Uint64);
- break;
+ break;
case S3BootScriptWidthFillUint64:
DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint64 - 0x%08x (0x%016lx)\n", (UINTN)Address, *OriginalIn.Uint64));
IoWrite64 ((UINTN) Address, *OriginalIn.Uint64);
@@ -489,25 +371,25 @@ ScriptIoWrite (
return EFI_INVALID_PARAMETER;
}
}
-
+
return EFI_SUCCESS;
}
/**
Interprete the boot script node with EFI_BOOT_SCRIPT_IO_WRITE OP code.
-
+
@param Script Pointer to the node which is to be interpreted.
@retval EFI_SUCCESS The data was written to the EFI System.
@retval EFI_INVALID_PARAMETER Width is invalid for this EFI System.
Buffer is NULL.
The Buffer is not aligned for the given Width.
- Address is outside the legal range of I/O ports.
-
+ Address is outside the legal range of I/O ports.
+
**/
EFI_STATUS
BootScriptExecuteIoWrite (
- IN UINT8 *Script
+ IN UINT8 *Script
)
{
S3_BOOT_SCRIPT_LIB_WIDTH Width;
@@ -515,7 +397,7 @@ BootScriptExecuteIoWrite (
UINTN Count;
VOID *Buffer;
EFI_BOOT_SCRIPT_IO_WRITE IoWrite;
-
+
CopyMem ((VOID*)&IoWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_IO_WRITE));
Width = (S3_BOOT_SCRIPT_LIB_WIDTH) IoWrite.Width;
Address = IoWrite.Address;
@@ -527,19 +409,19 @@ BootScriptExecuteIoWrite (
}
/**
Perform memory read operation
-
+
@param Width Width of the operation.
@param Address Address of the operation.
@param Count Count of the number of accesses to perform.
- @param Buffer Pointer to the buffer read from memory.
+ @param Buffer Pointer to the buffer read from memory.
@retval EFI_SUCCESS The data was written to the EFI System.
@retval EFI_INVALID_PARAMETER Width is invalid for this EFI System.
Buffer is NULL.
The Buffer is not aligned for the given Width.
- @retval EFI_UNSUPPORTED The address range specified by Address, Width, and Count
- is not valid for this EFI System.
-
+ @retval EFI_UNSUPPORTED The address range specified by Address, Width, and Count
+ is not valid for this EFI System.
+
**/
EFI_STATUS
ScriptMemoryRead (
@@ -626,19 +508,19 @@ ScriptMemoryRead (
}
/**
Perform memory write operation
-
+
@param Width Width of the operation.
@param Address Address of the operation.
@param Count Count of the number of accesses to perform.
- @param Buffer Pointer to the buffer write to memory.
+ @param Buffer Pointer to the buffer write to memory.
@retval EFI_SUCCESS The data was written to the EFI System.
@retval EFI_INVALID_PARAMETER Width is invalid for this EFI System.
Buffer is NULL.
The Buffer is not aligned for the given Width.
- @retval EFI_UNSUPPORTED The address range specified by Address, Width, and Count
- is not valid for this EFI System.
-
+ @retval EFI_UNSUPPORTED The address range specified by Address, Width, and Count
+ is not valid for this EFI System.
+
**/
EFI_STATUS
ScriptMemoryWrite (
@@ -650,7 +532,7 @@ ScriptMemoryWrite (
{
EFI_STATUS Status;
UINTN AddressStride;
- UINT64 OriginalAddress;
+ UINT64 OriginalAddress;
UINTN BufferStride;
PTR In;
PTR OriginalIn;
@@ -665,17 +547,17 @@ ScriptMemoryWrite (
// Loop for each iteration and move the data
//
OriginalAddress = Address;
- OriginalIn.Buf = In.Buf;
+ OriginalIn.Buf = In.Buf;
for (; Count > 0; Count--, Address += AddressStride, In.Buf += BufferStride) {
switch (Width) {
case S3BootScriptWidthUint8:
DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint8 - 0x%08x (0x%02x)\n", (UINTN)Address, (UINTN)*In.Uint8));
MmioWrite8 ((UINTN) Address, *In.Uint8);
- break;
+ break;
case S3BootScriptWidthFifoUint8:
DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x (0x%02x)\n", (UINTN)OriginalAddress, (UINTN)*In.Uint8));
MmioWrite8 ((UINTN) OriginalAddress, *In.Uint8);
- break;
+ break;
case S3BootScriptWidthFillUint8:
DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%08x (0x%02x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint8));
MmioWrite8 ((UINTN) Address, *OriginalIn.Uint8);
@@ -683,11 +565,11 @@ ScriptMemoryWrite (
case S3BootScriptWidthUint16:
DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint16 - 0x%08x (0x%04x)\n", (UINTN)Address, (UINTN)*In.Uint16));
MmioWrite16 ((UINTN) Address, *In.Uint16);
- break;
+ break;
case S3BootScriptWidthFifoUint16:
DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint16 - 0x%08x (0x%04x)\n", (UINTN)OriginalAddress, (UINTN)*In.Uint16));
MmioWrite16 ((UINTN) OriginalAddress, *In.Uint16);
- break;
+ break;
case S3BootScriptWidthFillUint16:
DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint16 - 0x%08x (0x%04x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint16));
MmioWrite16 ((UINTN) Address, *OriginalIn.Uint16);
@@ -695,11 +577,11 @@ ScriptMemoryWrite (
case S3BootScriptWidthUint32:
DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint32 - 0x%08x (0x%08x)\n", (UINTN)Address, (UINTN)*In.Uint32));
MmioWrite32 ((UINTN) Address, *In.Uint32);
- break;
+ break;
case S3BootScriptWidthFifoUint32:
DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint32 - 0x%08x (0x%08x)\n", (UINTN)OriginalAddress, (UINTN)*In.Uint32));
MmioWrite32 ((UINTN) OriginalAddress, *In.Uint32);
- break;
+ break;
case S3BootScriptWidthFillUint32:
DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint32 - 0x%08x (0x%08x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint32));
MmioWrite32 ((UINTN) Address, *OriginalIn.Uint32);
@@ -707,11 +589,11 @@ ScriptMemoryWrite (
case S3BootScriptWidthUint64:
DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint64 - 0x%08x (0x%016lx)\n", (UINTN)Address, *In.Uint64));
MmioWrite64 ((UINTN) Address, *In.Uint64);
- break;
+ break;
case S3BootScriptWidthFifoUint64:
DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint64 - 0x%08x (0x%016lx)\n", (UINTN)OriginalAddress, *In.Uint64));
MmioWrite64 ((UINTN) OriginalAddress, *In.Uint64);
- break;
+ break;
case S3BootScriptWidthFillUint64:
DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint64 - 0x%08x (0x%016lx)\n", (UINTN)Address, *OriginalIn.Uint64));
MmioWrite64 ((UINTN) Address, *OriginalIn.Uint64);
@@ -726,14 +608,14 @@ ScriptMemoryWrite (
Interprete the boot script node with EFI_BOOT_SCRIPT_MEM_WRITE OP code.
@param[in] Script Pointer to the node which is to be interpreted.
-
+
@retval EFI_SUCCESS The data was written to the EFI System.
@retval EFI_INVALID_PARAMETER Width is invalid for this EFI System.
Buffer is NULL.
The Buffer is not aligned for the given Width.
- @retval EFI_UNSUPPORTED The address range specified by Address, Width, and Count
- is not valid for this EFI System.
-
+ @retval EFI_UNSUPPORTED The address range specified by Address, Width, and Count
+ is not valid for this EFI System.
+
**/
EFI_STATUS
BootScriptExecuteMemoryWrite (
@@ -745,7 +627,7 @@ BootScriptExecuteMemoryWrite (
UINT64 Address;
UINTN Count;
EFI_BOOT_SCRIPT_MEM_WRITE MemWrite;
-
+
CopyMem((VOID*)&MemWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_MEM_WRITE));
Width = (S3_BOOT_SCRIPT_LIB_WIDTH)MemWrite.Width;
Address = MemWrite.Address;
@@ -754,23 +636,26 @@ BootScriptExecuteMemoryWrite (
DEBUG ((EFI_D_INFO, "BootScriptExecuteMemoryWrite - 0x%08x, 0x%08x, 0x%08x\n", (UINTN)Address, Count, (UINTN)Width));
return ScriptMemoryWrite (Width,Address, Count, Buffer);
-
-}
+
+}
/**
- Performance PCI configuration read operation
+ Performance PCI configuration 2 read operation
@param Width Width of the operation.
+ @param Segment Pci segment number
@param Address Address of the operation.
@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_INVALID_PARAMETER if Width is not defined
-
+ @retval EFI_INVALID_PARAMETER if Width is not defined
+ @note A known Limitations in the implementation which is 64bits operations are not supported.
+
**/
EFI_STATUS
-ScriptPciCfgRead (
+ScriptPciCfg2Read (
IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT16 Segment,
IN UINT64 Address,
IN UINTN Count,
OUT VOID *Buffer
@@ -780,11 +665,11 @@ ScriptPciCfgRead (
UINTN AddressStride;
UINTN BufferStride;
PTR Out;
- UINTN PciAddress;
+ UINT64 PciAddress;
Out.Buf = (UINT8 *) Buffer;
- PciAddress = PCI_ADDRESS_ENCODE (Address);
+ PciAddress = PCI_ADDRESS_ENCODE (Segment, Address);
Status = BuildLoopData (Width, PciAddress, &AddressStride, &BufferStride);
if (EFI_ERROR (Status)) {
@@ -796,42 +681,42 @@ ScriptPciCfgRead (
for (; Count > 0; Count--, PciAddress += AddressStride, Out.Buf += BufferStride) {
switch (Width) {
case S3BootScriptWidthUint8:
- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint8 - 0x%08x\n", PciAddress));
- *Out.Uint8 = PciRead8 (PciAddress);
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint8 - 0x%016lx\n", PciAddress));
+ *Out.Uint8 = PciSegmentRead8 (PciAddress);
break;
case S3BootScriptWidthFifoUint8:
- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x\n", PciAddress));
- *Out.Uint8 = PciRead8 (PciAddress);
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint8 - 0x%016lx\n", PciAddress));
+ *Out.Uint8 = PciSegmentRead8 (PciAddress);
break;
case S3BootScriptWidthFillUint8:
- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%08x\n", PciAddress));
- *Out.Uint8 = PciRead8 (PciAddress);
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%016lx\n", PciAddress));
+ *Out.Uint8 = PciSegmentRead8 (PciAddress);
break;
case S3BootScriptWidthUint16:
- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint16 - 0x%08x\n", PciAddress));
- *Out.Uint16 = PciRead16 (PciAddress);
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint16 - 0x%016lx\n", PciAddress));
+ *Out.Uint16 = PciSegmentRead16 (PciAddress);
break;
case S3BootScriptWidthFifoUint16:
- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint16 - 0x%08x\n", PciAddress));
- *Out.Uint16 = PciRead16 (PciAddress);
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint16 - 0x%016lx\n", PciAddress));
+ *Out.Uint16 = PciSegmentRead16 (PciAddress);
break;
case S3BootScriptWidthFillUint16:
- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint16 - 0x%08x\n", PciAddress));
- *Out.Uint16 = PciRead16 (PciAddress);
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint16 - 0x%016lx\n", PciAddress));
+ *Out.Uint16 = PciSegmentRead16 (PciAddress);
break;
case S3BootScriptWidthUint32:
- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint32 - 0x%08x\n", PciAddress));
- *Out.Uint32 = PciRead32 (PciAddress);
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint32 - 0x%016lx\n", PciAddress));
+ *Out.Uint32 = PciSegmentRead32 (PciAddress);
break;
case S3BootScriptWidthFifoUint32:
- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint32 - 0x%08x\n", PciAddress));
- *Out.Uint32 = PciRead32 (PciAddress);
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint32 - 0x%016lx\n", PciAddress));
+ *Out.Uint32 = PciSegmentRead32 (PciAddress);
break;
case S3BootScriptWidthFillUint32:
- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint32 - 0x%08x\n", PciAddress));
- *Out.Uint32 = PciRead32 (PciAddress);
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint32 - 0x%016lx\n", PciAddress));
+ *Out.Uint32 = PciSegmentRead32 (PciAddress);
break;
default:
@@ -842,20 +727,23 @@ ScriptPciCfgRead (
}
/**
- Performance PCI configuration write operation
+ Performance PCI configuration 2 write operation
@param Width Width of the operation.
+ @param Segment Pci segment number
@param Address Address of the operation.
@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_INVALID_PARAMETER if Width is not defined
-
+ @retval EFI_INVALID_PARAMETER if Width is not defined
+ @note A known Limitations in the implementation which is 64bits operations are not supported.
+
**/
EFI_STATUS
-ScriptPciCfgWrite (
+ScriptPciCfg2Write (
IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT16 Segment,
IN UINT64 Address,
IN UINTN Count,
IN VOID *Buffer
@@ -864,14 +752,14 @@ ScriptPciCfgWrite (
EFI_STATUS Status;
UINTN AddressStride;
UINTN BufferStride;
- UINTN OriginalPciAddress;
+ UINT64 OriginalPciAddress;
PTR In;
PTR OriginalIn;
- UINTN PciAddress;
+ UINT64 PciAddress;
In.Buf = (UINT8 *) Buffer;
- PciAddress = PCI_ADDRESS_ENCODE (Address);
+ PciAddress = PCI_ADDRESS_ENCODE (Segment, Address);
Status = BuildLoopData (Width, PciAddress, &AddressStride, &BufferStride);
if (EFI_ERROR (Status)) {
@@ -885,40 +773,40 @@ ScriptPciCfgWrite (
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;
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint8 - 0x%016lx (0x%02x)\n", PciAddress, (UINTN)*In.Uint8));
+ PciSegmentWrite8 (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;
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint8 - 0x%016lx (0x%02x)\n", OriginalPciAddress, (UINTN)*In.Uint8));
+ PciSegmentWrite8 (OriginalPciAddress, *In.Uint8);
+ break;
case S3BootScriptWidthFillUint8:
- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%08x (0x%02x)\n", PciAddress, (UINTN)*OriginalIn.Uint8));
- PciWrite8 (PciAddress, *OriginalIn.Uint8);
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%016lx (0x%02x)\n", PciAddress, (UINTN)*OriginalIn.Uint8));
+ PciSegmentWrite8 (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;
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint16 - 0x%016lx (0x%04x)\n", PciAddress, (UINTN)*In.Uint16));
+ PciSegmentWrite16 (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;
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint16 - 0x%016lx (0x%04x)\n", OriginalPciAddress, (UINTN)*In.Uint16));
+ PciSegmentWrite16 (OriginalPciAddress, *In.Uint16);
+ break;
case S3BootScriptWidthFillUint16:
- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint16 - 0x%08x (0x%04x)\n", PciAddress, (UINTN)*OriginalIn.Uint16));
- PciWrite16 (PciAddress, *OriginalIn.Uint16);
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint16 - 0x%016lx (0x%04x)\n", PciAddress, (UINTN)*OriginalIn.Uint16));
+ PciSegmentWrite16 (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;
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint32 - 0x%016lx (0x%08x)\n", PciAddress, (UINTN)*In.Uint32));
+ PciSegmentWrite32 (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;
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint32 - 0x%016lx (0x%08x)\n", OriginalPciAddress, (UINTN)*In.Uint32));
+ PciSegmentWrite32 (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);
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint32 - 0x%016lx (0x%08x)\n", (UINTN)PciAddress, (UINTN)*OriginalIn.Uint32));
+ PciSegmentWrite32 (PciAddress, *OriginalIn.Uint32);
break;
default:
return EFI_INVALID_PARAMETER;
@@ -927,10 +815,9 @@ ScriptPciCfgWrite (
return EFI_SUCCESS;
}
/**
- Performance PCI configuration 2 read operation
-
+ Performance PCI configuration read operation
+
@param Width Width of the operation.
- @param Segment Pci segment number
@param Address Address of the operation.
@param Count Count of the number of accesses to perform.
@param Buffer Pointer to the buffer to read from PCI config space.
@@ -940,27 +827,22 @@ ScriptPciCfgWrite (
Buffer is NULL.
The Buffer is not aligned for the given Width.
Address is outside the legal range of I/O ports.
- @note A known Limitations in the implementation which is the 'Segment' parameter is assumed as
- Zero, or else, assert.
+
**/
EFI_STATUS
-ScriptPciCfg2Read (
+ScriptPciCfgRead (
IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT16 Segment,
IN UINT64 Address,
IN UINTN Count,
OUT VOID *Buffer
)
{
- ASSERT (Segment==0);
-
- return ScriptPciCfgRead (Width, Address, Count, Buffer);
+ return ScriptPciCfg2Read (Width, 0, Address, Count, Buffer);
}
/**
- Performance PCI configuration 2 write operation
-
+ Performance PCI configuration write operation
+
@param Width Width of the operation.
- @param Segment Pci segment number
@param Address Address of the operation.
@param Count Count of the number of accesses to perform.
@param Buffer Pointer to the buffer to write to PCI config space.
@@ -970,28 +852,24 @@ ScriptPciCfg2Read (
Buffer is NULL.
The Buffer is not aligned for the given Width.
Address is outside the legal range of I/O ports.
- @note A known Limitations in the implementation which is the 'Segment' parameter is assumed as
- Zero, or else, assert.
-
+
**/
EFI_STATUS
EFIAPI
-ScriptPciCfg2Write (
+ScriptPciCfgWrite (
IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT16 Segment,
IN UINT64 Address,
IN UINTN Count,
IN VOID *Buffer
)
{
- ASSERT (Segment==0);
- return ScriptPciCfgWrite (Width, Address, Count, Buffer);
+ return ScriptPciCfg2Write (Width, 0, Address, Count, Buffer);
}
/**
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
+
@retval EFI_SUCCESS The operation was executed successfully
**/
EFI_STATUS
@@ -1012,13 +890,13 @@ BootScriptExecutePciCfgWrite (
Count = PciCfgWrite.Count;
Buffer = Script + sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE);
- DEBUG ((EFI_D_INFO, "BootScriptExecutePciCfgWrite - 0x%08x, 0x%08x, 0x%08x\n", PCI_ADDRESS_ENCODE (Address), Count, (UINTN)Width));
+ DEBUG ((EFI_D_INFO, "BootScriptExecutePciCfgWrite - 0x%016lx, 0x%08x, 0x%08x\n", PCI_ADDRESS_ENCODE (0, Address), Count, (UINTN)Width));
return ScriptPciCfgWrite (Width, Address, Count, Buffer);
}
/**
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 OrMask Mask value for 'or' operation
@@ -1035,9 +913,9 @@ BootScriptExecuteIoReadWrite (
EFI_STATUS Status;
UINT64 Data;
EFI_BOOT_SCRIPT_IO_READ_WRITE IoReadWrite;
-
+
Data = 0;
-
+
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, AndMask, OrMask));
@@ -1062,7 +940,7 @@ BootScriptExecuteIoReadWrite (
/**
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 OrMask Mask value for 'or' operation
@@ -1079,13 +957,13 @@ BootScriptExecuteMemoryReadWrite (
EFI_STATUS Status;
UINT64 Data;
EFI_BOOT_SCRIPT_MEM_READ_WRITE MemReadWrite;
-
+
Data = 0;
-
+
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, AndMask, OrMask));
-
+
Status = ScriptMemoryRead (
(S3_BOOT_SCRIPT_LIB_WIDTH) MemReadWrite.Width,
MemReadWrite.Address,
@@ -1106,7 +984,7 @@ BootScriptExecuteMemoryReadWrite (
/**
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 OrMask Mask value for 'or' operation
@@ -1123,11 +1001,13 @@ BootScriptExecutePciCfgReadWrite (
EFI_STATUS Status;
UINT64 Data;
EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE PciCfgReadWrite;
-
+
+ Data = 0;
+
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", PCI_ADDRESS_ENCODE (PciCfgReadWrite.Address), AndMask, OrMask));
-
+ DEBUG ((EFI_D_INFO, "BootScriptExecutePciCfgReadWrite - 0x%016lx, 0x%016lx, 0x%016lx\n", PCI_ADDRESS_ENCODE (0, PciCfgReadWrite.Address), AndMask, OrMask));
+
Status = ScriptPciCfgRead (
(S3_BOOT_SCRIPT_LIB_WIDTH) PciCfgReadWrite.Width,
PciCfgReadWrite.Address,
@@ -1152,11 +1032,11 @@ BootScriptExecutePciCfgReadWrite (
/**
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
+
@retval EFI_SUCCESS The operation was executed successfully
@retval EFI_UNSUPPORTED Cannot locate smbus ppi or occur error of script execution
- @retval Others Result of script execution
+ @retval Others Result of script execution
**/
EFI_STATUS
BootScriptExecuteSmbusExecute (
@@ -1166,7 +1046,7 @@ BootScriptExecuteSmbusExecute (
UINTN SmBusAddress;
UINTN DataSize;
EFI_BOOT_SCRIPT_SMBUS_EXECUTE SmbusExecuteEntry;
-
+
CopyMem ((VOID*)&SmbusExecuteEntry, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_SMBUS_EXECUTE ));
DEBUG ((EFI_D_INFO, "BootScriptExecuteSmbusExecute - 0x%08x, 0x%08x\n", (UINTN)SmbusExecuteEntry.SmBusAddress, (UINTN)SmbusExecuteEntry.Operation));
@@ -1183,8 +1063,8 @@ BootScriptExecuteSmbusExecute (
/**
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
+
@retval EFI_SUCCESS The operation was executed successfully
**/
EFI_STATUS
@@ -1193,7 +1073,7 @@ BootScriptExecuteStall (
)
{
EFI_BOOT_SCRIPT_STALL Stall;
-
+
CopyMem ((VOID*)&Stall, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_STALL));
DEBUG ((EFI_D_INFO, "BootScriptExecuteStall - 0x%08x\n", (UINTN)Stall.Duration));
@@ -1203,8 +1083,8 @@ BootScriptExecuteStall (
}
/**
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
**/
EFI_STATUS
@@ -1215,7 +1095,7 @@ BootScriptExecuteDispatch (
EFI_STATUS Status;
DISPATCH_ENTRYPOINT_FUNC EntryFunc;
EFI_BOOT_SCRIPT_DISPATCH ScriptDispatch;
-
+
CopyMem ((VOID*)&ScriptDispatch, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_DISPATCH));
EntryFunc = (DISPATCH_ENTRYPOINT_FUNC) (UINTN) (ScriptDispatch.EntryPoint);
@@ -1228,7 +1108,7 @@ BootScriptExecuteDispatch (
/**
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
**/
EFI_STATUS
@@ -1239,11 +1119,11 @@ BootScriptExecuteDispatch2 (
EFI_STATUS Status;
DISPATCH_ENTRYPOINT_FUNC EntryFunc;
EFI_BOOT_SCRIPT_DISPATCH_2 ScriptDispatch2;
-
+
CopyMem ((VOID*)&ScriptDispatch2, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_DISPATCH_2));
DEBUG ((EFI_D_INFO, "BootScriptExecuteDispatch2 - 0x%08x(0x%08x)\n", (UINTN)ScriptDispatch2.EntryPoint, (UINTN)ScriptDispatch2.Context));
-
+
EntryFunc = (DISPATCH_ENTRYPOINT_FUNC) (UINTN) (ScriptDispatch2.EntryPoint);
Status = EntryFunc (NULL, (VOID *) (UINTN) ScriptDispatch2.Context);
@@ -1253,11 +1133,11 @@ BootScriptExecuteDispatch2 (
/**
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 OrMask Mask value for 'or' operation
-
- @retval EFI_DEVICE_ERROR Data polled from memory does not equal to
+
+ @retval EFI_DEVICE_ERROR Data polled from memory does not equal to
the epecting data within the Loop Times.
@retval EFI_SUCCESS The operation was executed successfully
**/
@@ -1265,15 +1145,15 @@ EFI_STATUS
BootScriptExecuteMemPoll (
IN UINT8 *Script,
IN UINT64 AndMask,
- IN UINT64 OrMask
+ IN UINT64 OrMask
)
{
-
+
UINT64 Data;
UINT64 LoopTimes;
EFI_STATUS Status;
EFI_BOOT_SCRIPT_MEM_POLL MemPoll;
-
+
CopyMem ((VOID*)&MemPoll, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_MEM_POLL));
DEBUG ((EFI_D_INFO, "BootScriptExecuteMemPoll - 0x%08x, 0x%016lx, 0x%016lx\n", (UINTN)MemPoll.Address, AndMask, OrMask));
@@ -1290,7 +1170,7 @@ BootScriptExecuteMemPoll (
}
for (LoopTimes = 0; LoopTimes < MemPoll.LoopTimes; LoopTimes++) {
- NanoSecondDelay ((UINTN)MemPoll.Duration);
+ MicroSecondDelay ((UINTN)MemPoll.Duration);
Data = 0;
Status = ScriptMemoryRead (
@@ -1314,8 +1194,8 @@ BootScriptExecuteMemPoll (
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.
- @param Script The pointer of node in boot script table
-
+ @param Script The pointer of node in boot script table
+
**/
VOID
BootScriptExecuteInformation (
@@ -1340,10 +1220,10 @@ BootScriptExecuteInformation (
}
/**
- Execute the boot script to interpret the Label information.
+ Execute the boot script to interpret the Label information.
+
+ @param Script The pointer of node in boot script table
- @param Script The pointer of node in boot script table
-
**/
VOID
BootScriptExecuteLabel (
@@ -1369,7 +1249,7 @@ BootScriptExecuteLabel (
/**
calculate the mask value for 'and' and 'or' operation
- @param ScriptHeader The pointer of header of node in boot script table
+ @param ScriptHeader The pointer of header of node in boot script table
@param AndMask The Mask value for 'and' operation
@param OrMask The Mask value for 'or' operation
@param Script Pointer to the entry.
@@ -1401,32 +1281,32 @@ CheckAndOrMask (
case EFI_BOOT_SCRIPT_MEM_POLL_OPCODE:
Size = sizeof (EFI_BOOT_SCRIPT_MEM_POLL);
break;
-
+
case EFI_BOOT_SCRIPT_IO_POLL_OPCODE:
Size = sizeof (EFI_BOOT_SCRIPT_IO_POLL);
- break;
-
+ break;
+
case EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE:
Size = sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE);
break;
-
+
case EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE:
Size = sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL);
break;
-
+
case EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE:
Size = sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_POLL);
break;
-
+
default:
return;
}
-
+
DataPtr = Script + Size;
switch (ScriptHeader->Width) {
case S3BootScriptWidthUint8:
- *AndMask = (UINT64) *(DataPtr + 1);
+ *AndMask = (UINT64) (*(UINT8*) (DataPtr + 1));
*OrMask = (UINT64) (*DataPtr);
break;
@@ -1454,11 +1334,11 @@ CheckAndOrMask (
/**
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 OrMask Mask value for 'or' operation
-
- @retval EFI_DEVICE_ERROR Data polled from memory does not equal to
+
+ @retval EFI_DEVICE_ERROR Data polled from memory does not equal to
the epecting data within the Loop Times.
@retval EFI_SUCCESS The operation was executed successfully
**/
@@ -1473,7 +1353,7 @@ BootScriptExecuteIoPoll (
UINT64 Data;
UINT64 LoopTimes;
EFI_BOOT_SCRIPT_IO_POLL IoPoll;
-
+
CopyMem ((VOID*)&IoPoll, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_IO_POLL));
DEBUG ((EFI_D_INFO, "BootScriptExecuteIoPoll - 0x%08x, 0x%016lx, 0x%016lx\n", (UINTN)IoPoll.Address, AndMask, OrMask));
@@ -1499,7 +1379,7 @@ BootScriptExecuteIoPoll (
);
if ((!EFI_ERROR (Status)) &&(Data & AndMask) == OrMask) {
return EFI_SUCCESS;
- }
+ }
}
if (LoopTimes < IoPoll.Delay) {
@@ -1527,7 +1407,7 @@ BootScriptExecutePciCfg2Write (
UINT64 Address;
UINTN Count;
EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE PciCfg2Write;
-
+
CopyMem ((VOID*)&PciCfg2Write, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE));
Width = (S3_BOOT_SCRIPT_LIB_WIDTH)PciCfg2Write.Width;
@@ -1536,14 +1416,14 @@ BootScriptExecutePciCfg2Write (
Count = PciCfg2Write.Count;
Buffer = Script + sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE);
- DEBUG ((EFI_D_INFO, "BootScriptExecutePciCfg2Write - 0x%04x, 0x%08x, 0x%08x, 0x%08x\n", Segment, PCI_ADDRESS_ENCODE (Address), Count, (UINTN)Width));
+ DEBUG ((EFI_D_INFO, "BootScriptExecutePciCfg2Write - 0x%016lx, 0x%08x, 0x%08x\n", PCI_ADDRESS_ENCODE (Segment, Address), Count, (UINTN)Width));
return ScriptPciCfg2Write (Width, Segment, Address, Count, Buffer);
}
/**
Interprete the boot script node with EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE OP code.
-
+
@param Script The pointer of S3 boot script
@param AndMask Mask value for 'and' operation
@param OrMask Mask value for 'or' operation
@@ -1561,10 +1441,13 @@ BootScriptExecutePciCfg2ReadWrite (
UINT64 Data;
EFI_STATUS Status;
EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE PciCfg2ReadWrite;
+
+ Data = 0;
+
CopyMem ((VOID*)&PciCfg2ReadWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE));
- DEBUG ((EFI_D_INFO, "BootScriptExecutePciCfg2ReadWrite - 0x%04x, 0x%08x, 0x%016lx, 0x%016lx\n", PciCfg2ReadWrite.Segment, PCI_ADDRESS_ENCODE (PciCfg2ReadWrite.Address), AndMask, OrMask));
-
+ DEBUG ((EFI_D_INFO, "BootScriptExecutePciCfg2ReadWrite - 0x%016lx, 0x%016lx, 0x%016lx\n", PCI_ADDRESS_ENCODE (PciCfg2ReadWrite.Segment, PciCfg2ReadWrite.Address), AndMask, OrMask));
+
Status = ScriptPciCfg2Read (
(S3_BOOT_SCRIPT_LIB_WIDTH) PciCfg2ReadWrite.Width,
PciCfg2ReadWrite.Segment,
@@ -1588,20 +1471,20 @@ BootScriptExecutePciCfg2ReadWrite (
}
/**
Interprete the boot script node with EFI_BOOT_SCRIPT_PCI_CONFIG_POLL OP code.
-
+
@param Script The pointer of S3 boot script
@param AndMask Mask value for 'and' operation
@param OrMask Mask value for 'or' operation
@retval EFI_SUCCESS The operation was executed successfully
- @retval EFI_DEVICE_ERROR Data polled from Pci configuration space does not equal to
+ @retval EFI_DEVICE_ERROR Data polled from Pci configuration space does not equal to
epecting data within the Loop Times.
**/
EFI_STATUS
BootScriptPciCfgPoll (
IN UINT8 *Script,
IN UINT64 AndMask,
- IN UINT64 OrMask
+ IN UINT64 OrMask
)
{
UINT64 Data;
@@ -1610,8 +1493,8 @@ BootScriptPciCfgPoll (
EFI_BOOT_SCRIPT_PCI_CONFIG_POLL PciCfgPoll;
CopyMem ((VOID*)&PciCfgPoll, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG_POLL));
- DEBUG ((EFI_D_INFO, "BootScriptPciCfgPoll - 0x%08x, 0x%016lx, 0x%016lx\n", PCI_ADDRESS_ENCODE (PciCfgPoll.Address), AndMask, OrMask));
-
+ DEBUG ((EFI_D_INFO, "BootScriptPciCfgPoll - 0x%016lx, 0x%016lx, 0x%016lx\n", PCI_ADDRESS_ENCODE (0, PciCfgPoll.Address), AndMask, OrMask));
+
Data = 0;
Status = ScriptPciCfgRead (
(S3_BOOT_SCRIPT_LIB_WIDTH) PciCfgPoll.Width,
@@ -1647,13 +1530,13 @@ BootScriptPciCfgPoll (
/**
Interprete the boot script node with EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL OP code.
-
+
@param Script The pointer of S3 Boot Script
@param AndMask Mask value for 'and' operation
@param OrMask Mask value for 'or' operation
@retval EFI_SUCCESS The operation was executed successfully
- @retval EFI_DEVICE_ERROR Data polled from Pci configuration space does not equal to
+ @retval EFI_DEVICE_ERROR Data polled from Pci configuration space does not equal to
epecting data within the Loop Times.
**/
@@ -1661,7 +1544,7 @@ EFI_STATUS
BootScriptPciCfg2Poll (
IN UINT8 *Script,
IN UINT64 AndMask,
- IN UINT64 OrMask
+ IN UINT64 OrMask
)
{
EFI_STATUS Status;
@@ -1672,8 +1555,8 @@ BootScriptPciCfg2Poll (
Data = 0;
CopyMem ((VOID*)&PciCfg2Poll, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL));
- DEBUG ((EFI_D_INFO, "BootScriptPciCfg2Poll - 0x%04x, 0x%08x, 0x%016lx, 0x%016lx\n", PciCfg2Poll.Segment, PCI_ADDRESS_ENCODE (PciCfg2Poll.Address), AndMask, OrMask));
-
+ DEBUG ((EFI_D_INFO, "BootScriptPciCfg2Poll - 0x%016lx, 0x%016lx, 0x%016lx\n", PCI_ADDRESS_ENCODE (PciCfg2Poll.Segment, PciCfg2Poll.Address), AndMask, OrMask));
+
Status = ScriptPciCfg2Read (
(S3_BOOT_SCRIPT_LIB_WIDTH) PciCfg2Poll.Width,
PciCfg2Poll.Segment,
@@ -1691,7 +1574,7 @@ BootScriptPciCfg2Poll (
Data = 0;
Status = ScriptPciCfg2Read (
(S3_BOOT_SCRIPT_LIB_WIDTH) PciCfg2Poll.Width,
- PciCfg2Poll.Segment,
+ PciCfg2Poll.Segment,
PciCfg2Poll.Address,
1,
&Data
@@ -1706,18 +1589,15 @@ BootScriptPciCfg2Poll (
} else {
return EFI_DEVICE_ERROR;
}
-
+
}
/**
Executes the S3 boot script table.
-
+
@retval RETURN_SUCCESS The boot script table was executed successfully.
- @retval RETURN_UNSUPPORTED Invalid script table or opcode.
-
- @note A known Limitations in the implementation: When interpreting the opcode EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE
- EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE and EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE, the 'Segment' parameter is assumed as
- Zero, or else, assert.
+ @retval RETURN_UNSUPPORTED Invalid script table or opcode.
+
**/
RETURN_STATUS
EFIAPI
@@ -1734,7 +1614,7 @@ S3BootScriptExecute (
EFI_BOOT_SCRIPT_COMMON_HEADER ScriptHeader;
EFI_BOOT_SCRIPT_TABLE_HEADER TableHeader;
Script = mS3BootScriptTablePtr->TableBase;
- if (Script != 0) {
+ if (Script != 0) {
CopyMem ((VOID*)&TableHeader, Script, sizeof(EFI_BOOT_SCRIPT_TABLE_HEADER));
} else {
return EFI_INVALID_PARAMETER;
@@ -1746,7 +1626,7 @@ S3BootScriptExecute (
}
DEBUG ((EFI_D_INFO, "TableHeader - 0x%08x\n", Script));
-
+
StartAddress = (UINTN) Script;
TableLength = TableHeader.TableLength;
Script = Script + TableHeader.Length;
@@ -1754,11 +1634,12 @@ S3BootScriptExecute (
AndMask = 0;
OrMask = 0;
+ DEBUG ((EFI_D_INFO, "TableHeader.Version - 0x%04x\n", (UINTN)TableHeader.Version));
DEBUG ((EFI_D_INFO, "TableHeader.TableLength - 0x%08x\n", (UINTN)TableLength));
while ((UINTN) Script < (UINTN) (StartAddress + TableLength)) {
DEBUG ((EFI_D_INFO, "ExecuteBootScript - %08x\n", (UINTN)Script));
-
+
CopyMem ((VOID*)&ScriptHeader, Script, sizeof(EFI_BOOT_SCRIPT_COMMON_HEADER));
switch (ScriptHeader.OpCode) {
@@ -1823,7 +1704,7 @@ S3BootScriptExecute (
case EFI_BOOT_SCRIPT_INFORMATION_OPCODE:
DEBUG ((EFI_D_INFO, "EFI_BOOT_SCRIPT_INFORMATION_OPCODE\n"));
BootScriptExecuteInformation (Script);
- break;
+ break;
case S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE:
DEBUG ((EFI_D_INFO, "S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE\n"));
@@ -1854,21 +1735,21 @@ S3BootScriptExecute (
DEBUG ((EFI_D_INFO, "EFI_BOOT_SCRIPT_MEM_POLL_OPCODE\n"));
CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);
Status = BootScriptExecuteMemPoll (Script, AndMask, OrMask);
-
+
break;
-
+
case EFI_BOOT_SCRIPT_IO_POLL_OPCODE:
DEBUG ((EFI_D_INFO, "EFI_BOOT_SCRIPT_IO_POLL_OPCODE\n"));
CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);
Status = BootScriptExecuteIoPoll (Script, AndMask, OrMask);
break;
-
+
case EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE:
DEBUG ((EFI_D_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE\n"));
CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);
Status = BootScriptPciCfgPoll (Script, AndMask, OrMask);
break;
-
+
case EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE:
DEBUG ((EFI_D_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE\n"));
CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);