summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Library/PiDxeS3BootScriptLib
diff options
context:
space:
mode:
Diffstat (limited to 'MdeModulePkg/Library/PiDxeS3BootScriptLib')
-rw-r--r--MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c1196
-rw-r--r--MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptInternalFormat.h187
-rw-r--r--MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c1244
-rw-r--r--MdeModulePkg/Library/PiDxeS3BootScriptLib/InternalBootScriptLib.h50
4 files changed, 1393 insertions, 1284 deletions
diff --git a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c
index f7fb787cd5..279daefac1 100644
--- a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c
+++ b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptExecute.c
@@ -51,14 +51,14 @@
**/
EFI_STATUS
InternalSmbusExecute (
- IN UINTN SmbusAddress,
- IN EFI_SMBUS_OPERATION Operation,
- IN OUT UINTN *Length,
- IN OUT VOID *Buffer
+ IN UINTN SmbusAddress,
+ IN EFI_SMBUS_OPERATION Operation,
+ IN OUT UINTN *Length,
+ IN OUT VOID *Buffer
)
{
- EFI_STATUS Status;
- UINT8 WorkBuffer[MAX_SMBUS_BLOCK_LEN];
+ EFI_STATUS Status;
+ UINT8 WorkBuffer[MAX_SMBUS_BLOCK_LEN];
switch (Operation) {
case EfiSmbusQuickRead:
@@ -74,28 +74,28 @@ InternalSmbusExecute (
SmBusReceiveByte (SmbusAddress, &Status);
break;
case EfiSmbusSendByte:
- DEBUG ((DEBUG_INFO, "EfiSmbusSendByte - 0x%08x (0x%02x)\n", SmbusAddress, (UINTN)*(UINT8 *) Buffer));
- SmBusSendByte (SmbusAddress, *(UINT8 *) Buffer, &Status);
+ DEBUG ((DEBUG_INFO, "EfiSmbusSendByte - 0x%08x (0x%02x)\n", SmbusAddress, (UINTN)*(UINT8 *)Buffer));
+ SmBusSendByte (SmbusAddress, *(UINT8 *)Buffer, &Status);
break;
case EfiSmbusReadByte:
DEBUG ((DEBUG_INFO, "EfiSmbusReadByte - 0x%08x\n", SmbusAddress));
SmBusReadDataByte (SmbusAddress, &Status);
break;
case EfiSmbusWriteByte:
- DEBUG ((DEBUG_INFO, "EfiSmbusWriteByte - 0x%08x (0x%02x)\n", SmbusAddress, (UINTN)*(UINT8 *) Buffer));
- SmBusWriteDataByte (SmbusAddress, *(UINT8 *) Buffer, &Status);
+ DEBUG ((DEBUG_INFO, "EfiSmbusWriteByte - 0x%08x (0x%02x)\n", SmbusAddress, (UINTN)*(UINT8 *)Buffer));
+ SmBusWriteDataByte (SmbusAddress, *(UINT8 *)Buffer, &Status);
break;
case EfiSmbusReadWord:
DEBUG ((DEBUG_INFO, "EfiSmbusReadWord - 0x%08x\n", SmbusAddress));
SmBusReadDataWord (SmbusAddress, &Status);
break;
case EfiSmbusWriteWord:
- DEBUG ((DEBUG_INFO, "EfiSmbusWriteWord - 0x%08x (0x%04x)\n", SmbusAddress, (UINTN)*(UINT16 *) Buffer));
- SmBusWriteDataWord (SmbusAddress, *(UINT16 *) Buffer, &Status);
+ DEBUG ((DEBUG_INFO, "EfiSmbusWriteWord - 0x%08x (0x%04x)\n", SmbusAddress, (UINTN)*(UINT16 *)Buffer));
+ SmBusWriteDataWord (SmbusAddress, *(UINT16 *)Buffer, &Status);
break;
case EfiSmbusProcessCall:
- DEBUG ((DEBUG_INFO, "EfiSmbusProcessCall - 0x%08x (0x%04x)\n", SmbusAddress, (UINTN)*(UINT16 *) Buffer));
- SmBusProcessCall (SmbusAddress, *(UINT16 *) Buffer, &Status);
+ DEBUG ((DEBUG_INFO, "EfiSmbusProcessCall - 0x%08x (0x%04x)\n", SmbusAddress, (UINTN)*(UINT16 *)Buffer));
+ SmBusProcessCall (SmbusAddress, *(UINT16 *)Buffer, &Status);
break;
case EfiSmbusReadBlock:
DEBUG ((DEBUG_INFO, "EfiSmbusReadBlock - 0x%08x\n", SmbusAddress));
@@ -130,31 +130,31 @@ InternalSmbusExecute (
**/
EFI_STATUS
BuildLoopData (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
IN UINT64 Address,
OUT UINTN *AddressStride,
OUT UINTN *BufferStride
)
{
- UINTN AlignMask;
+ UINTN AlignMask;
if (Width >= S3BootScriptWidthMaximum) {
return EFI_INVALID_PARAMETER;
}
- *AddressStride = (UINT32)(1 << (Width & 0x03));
- *BufferStride = *AddressStride;
+ *AddressStride = (UINT32)(1 << (Width & 0x03));
+ *BufferStride = *AddressStride;
- AlignMask = *AddressStride - 1;
+ AlignMask = *AddressStride - 1;
if ((Address & AlignMask) != 0) {
return EFI_INVALID_PARAMETER;
}
- if (Width >= S3BootScriptWidthFifoUint8 && Width <= S3BootScriptWidthFifoUint64) {
+ if ((Width >= S3BootScriptWidthFifoUint8) && (Width <= S3BootScriptWidthFifoUint64)) {
*AddressStride = 0;
}
- if (Width >= S3BootScriptWidthFillUint8 && Width <= S3BootScriptWidthFillUint64) {
+ if ((Width >= S3BootScriptWidthFillUint8) && (Width <= S3BootScriptWidthFillUint64)) {
*BufferStride = 0;
}
@@ -178,10 +178,10 @@ BuildLoopData (
**/
EFI_STATUS
ScriptIoRead (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- OUT VOID *Buffer
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ OUT VOID *Buffer
)
{
EFI_STATUS Status;
@@ -189,7 +189,7 @@ ScriptIoRead (
UINTN BufferStride;
PTR Out;
- Out.Buf = (UINT8 *) Buffer;
+ Out.Buf = (UINT8 *)Buffer;
if (Address > MAX_IO_ADDRESS) {
return EFI_INVALID_PARAMETER;
@@ -199,66 +199,66 @@ ScriptIoRead (
if (EFI_ERROR (Status)) {
return Status;
}
+
//
// Loop for each iteration and move the data
//
- for (; Count > 0; Count--, Address += AddressStride, Out.Buf += BufferStride) {
+ for ( ; Count > 0; Count--, Address += AddressStride, Out.Buf += BufferStride) {
switch (Width) {
+ case S3BootScriptWidthUint8:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint8 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint8 = IoRead8 ((UINTN)Address);
+ break;
+ case S3BootScriptWidthFifoUint8:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint8 = IoRead8 ((UINTN)Address);
+ break;
+ case S3BootScriptWidthFillUint8:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint8 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint8 = IoRead8 ((UINTN)Address);
+ break;
- case S3BootScriptWidthUint8:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint8 - 0x%08x\n", (UINTN) Address));
- *Out.Uint8 = IoRead8 ((UINTN) Address);
- break;
- case S3BootScriptWidthFifoUint8:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x\n", (UINTN) Address));
- *Out.Uint8 = IoRead8 ((UINTN) Address);
- break;
- case S3BootScriptWidthFillUint8:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint8 - 0x%08x\n", (UINTN) Address));
- *Out.Uint8 = IoRead8 ((UINTN) Address);
- break;
-
- case S3BootScriptWidthUint16:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint16 - 0x%08x\n", (UINTN) Address));
- *Out.Uint16 = IoRead16 ((UINTN) Address);
- break;
- case S3BootScriptWidthFifoUint16:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint16 - 0x%08x\n", (UINTN) Address));
- *Out.Uint16 = IoRead16 ((UINTN) Address);
- break;
- case S3BootScriptWidthFillUint16:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint16 - 0x%08x\n", (UINTN) Address));
- *Out.Uint16 = IoRead16 ((UINTN) Address);
- break;
+ case S3BootScriptWidthUint16:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint16 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint16 = IoRead16 ((UINTN)Address);
+ break;
+ case S3BootScriptWidthFifoUint16:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint16 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint16 = IoRead16 ((UINTN)Address);
+ break;
+ case S3BootScriptWidthFillUint16:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint16 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint16 = IoRead16 ((UINTN)Address);
+ break;
- case S3BootScriptWidthUint32:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint32 - 0x%08x\n", (UINTN) Address));
- *Out.Uint32 = IoRead32 ((UINTN) Address);
- break;
- case S3BootScriptWidthFifoUint32:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint32 - 0x%08x\n", (UINTN) Address));
- *Out.Uint32 = IoRead32 ((UINTN) Address);
- break;
- case S3BootScriptWidthFillUint32:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint32 - 0x%08x\n", (UINTN) Address));
- *Out.Uint32 = IoRead32 ((UINTN) Address);
- break;
+ case S3BootScriptWidthUint32:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint32 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint32 = IoRead32 ((UINTN)Address);
+ break;
+ case S3BootScriptWidthFifoUint32:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint32 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint32 = IoRead32 ((UINTN)Address);
+ break;
+ case S3BootScriptWidthFillUint32:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint32 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint32 = IoRead32 ((UINTN)Address);
+ break;
- case S3BootScriptWidthUint64:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint64 - 0x%08x\n", (UINTN) Address));
- *Out.Uint64 = IoRead64 ((UINTN) Address);
- break;
- case S3BootScriptWidthFifoUint64:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint64 - 0x%08x\n", (UINTN) Address));
- *Out.Uint64 = IoRead64 ((UINTN) Address);
- break;
- case S3BootScriptWidthFillUint64:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint64 - 0x%08x\n", (UINTN) Address));
- *Out.Uint64 = IoRead64 ((UINTN) Address);
- break;
+ case S3BootScriptWidthUint64:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint64 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint64 = IoRead64 ((UINTN)Address);
+ break;
+ case S3BootScriptWidthFifoUint64:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint64 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint64 = IoRead64 ((UINTN)Address);
+ break;
+ case S3BootScriptWidthFillUint64:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint64 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint64 = IoRead64 ((UINTN)Address);
+ break;
- default:
- return EFI_INVALID_PARAMETER;
+ default:
+ return EFI_INVALID_PARAMETER;
}
}
@@ -283,9 +283,9 @@ ScriptIoRead (
EFI_STATUS
ScriptIoWrite (
IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- IN VOID *Buffer
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN VOID *Buffer
)
{
EFI_STATUS Status;
@@ -295,7 +295,7 @@ ScriptIoWrite (
PTR In;
PTR OriginalIn;
- In.Buf = (UINT8 *) Buffer;
+ In.Buf = (UINT8 *)Buffer;
if (Address > MAX_IO_ADDRESS) {
return EFI_INVALID_PARAMETER;
@@ -305,69 +305,70 @@ ScriptIoWrite (
if (EFI_ERROR (Status)) {
return Status;
}
+
//
// Loop for each iteration and move the data
//
OriginalAddress = Address;
- OriginalIn.Buf = In.Buf;
- for (; Count > 0; Count--, Address += AddressStride, In.Buf += BufferStride) {
+ OriginalIn.Buf = In.Buf;
+ for ( ; Count > 0; Count--, Address += AddressStride, In.Buf += BufferStride) {
switch (Width) {
case S3BootScriptWidthUint8:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint8 - 0x%08x (0x%02x)\n", (UINTN)Address, (UINTN)*In.Uint8));
- IoWrite8 ((UINTN) Address, *In.Uint8);
+ IoWrite8 ((UINTN)Address, *In.Uint8);
break;
case S3BootScriptWidthFifoUint8:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x (0x%02x)\n", (UINTN)OriginalAddress, (UINTN)*In.Uint8));
- IoWrite8 ((UINTN) OriginalAddress, *In.Uint8);
+ IoWrite8 ((UINTN)OriginalAddress, *In.Uint8);
break;
case S3BootScriptWidthFillUint8:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint8 - 0x%08x (0x%02x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint8));
- IoWrite8 ((UINTN) Address, *OriginalIn.Uint8);
+ IoWrite8 ((UINTN)Address, *OriginalIn.Uint8);
break;
case S3BootScriptWidthUint16:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint16 - 0x%08x (0x%04x)\n", (UINTN)Address, (UINTN)*In.Uint16));
- IoWrite16 ((UINTN) Address, *In.Uint16);
+ IoWrite16 ((UINTN)Address, *In.Uint16);
break;
case S3BootScriptWidthFifoUint16:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint16 - 0x%08x (0x%04x)\n", (UINTN)OriginalAddress, (UINTN)*In.Uint16));
- IoWrite16 ((UINTN) OriginalAddress, *In.Uint16);
+ IoWrite16 ((UINTN)OriginalAddress, *In.Uint16);
break;
case S3BootScriptWidthFillUint16:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint16 - 0x%08x (0x%04x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint16));
- IoWrite16 ((UINTN) Address, *OriginalIn.Uint16);
+ IoWrite16 ((UINTN)Address, *OriginalIn.Uint16);
break;
case S3BootScriptWidthUint32:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint32 - 0x%08x (0x%08x)\n", (UINTN)Address, (UINTN)*In.Uint32));
- IoWrite32 ((UINTN) Address, *In.Uint32);
+ IoWrite32 ((UINTN)Address, *In.Uint32);
break;
case S3BootScriptWidthFifoUint32:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint32 - 0x%08x (0x%08x)\n", (UINTN)OriginalAddress, (UINTN)*In.Uint32));
- IoWrite32 ((UINTN) OriginalAddress, *In.Uint32);
+ IoWrite32 ((UINTN)OriginalAddress, *In.Uint32);
break;
case S3BootScriptWidthFillUint32:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint32 - 0x%08x (0x%08x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint32));
- IoWrite32 ((UINTN) Address, *OriginalIn.Uint32);
+ IoWrite32 ((UINTN)Address, *OriginalIn.Uint32);
break;
case S3BootScriptWidthUint64:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint64 - 0x%08x (0x%016lx)\n", (UINTN)Address, *In.Uint64));
- IoWrite64 ((UINTN) Address, *In.Uint64);
+ IoWrite64 ((UINTN)Address, *In.Uint64);
break;
case S3BootScriptWidthFifoUint64:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint64 - 0x%08x (0x%016lx)\n", (UINTN)OriginalAddress, *In.Uint64));
- IoWrite64 ((UINTN) OriginalAddress, *In.Uint64);
+ IoWrite64 ((UINTN)OriginalAddress, *In.Uint64);
break;
case S3BootScriptWidthFillUint64:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint64 - 0x%08x (0x%016lx)\n", (UINTN)Address, *OriginalIn.Uint64));
- IoWrite64 ((UINTN) Address, *OriginalIn.Uint64);
+ IoWrite64 ((UINTN)Address, *OriginalIn.Uint64);
break;
default:
return EFI_INVALID_PARAMETER;
}
}
-
return EFI_SUCCESS;
}
+
/**
Interpret the boot script node with EFI_BOOT_SCRIPT_IO_WRITE OP code.
@@ -382,24 +383,25 @@ ScriptIoWrite (
**/
EFI_STATUS
BootScriptExecuteIoWrite (
- IN UINT8 *Script
+ IN UINT8 *Script
)
{
- S3_BOOT_SCRIPT_LIB_WIDTH Width;
- UINT64 Address;
- UINTN Count;
+ S3_BOOT_SCRIPT_LIB_WIDTH Width;
+ UINT64 Address;
+ UINTN Count;
VOID *Buffer;
- EFI_BOOT_SCRIPT_IO_WRITE IoWrite;
+ 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;
+ CopyMem ((VOID *)&IoWrite, (VOID *)Script, sizeof (EFI_BOOT_SCRIPT_IO_WRITE));
+ Width = (S3_BOOT_SCRIPT_LIB_WIDTH)IoWrite.Width;
Address = IoWrite.Address;
- Count = IoWrite.Count;
- Buffer = Script + sizeof (EFI_BOOT_SCRIPT_IO_WRITE);
+ Count = IoWrite.Count;
+ Buffer = Script + sizeof (EFI_BOOT_SCRIPT_IO_WRITE);
DEBUG ((DEBUG_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);
}
+
/**
Perform memory read operation
@@ -418,10 +420,10 @@ BootScriptExecuteIoWrite (
**/
EFI_STATUS
ScriptMemoryRead (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- IN OUT VOID *Buffer
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
)
{
EFI_STATUS Status;
@@ -431,74 +433,76 @@ ScriptMemoryRead (
Out.Buf = Buffer;
- Status = BuildLoopData (Width, Address, &AddressStride, &BufferStride);
+ Status = BuildLoopData (Width, Address, &AddressStride, &BufferStride);
if (EFI_ERROR (Status)) {
return Status;
}
+
//
// Loop for each iteration and move the data
//
- for (; Count > 0; Count--, Address += AddressStride, Out.Buf += BufferStride) {
+ for ( ; Count > 0; Count--, Address += AddressStride, Out.Buf += BufferStride) {
switch (Width) {
- case S3BootScriptWidthUint8:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint8 - 0x%08x\n", (UINTN)Address));
- *Out.Uint8 = MmioRead8 ((UINTN) Address);
- break;
- case S3BootScriptWidthFifoUint8:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x\n", (UINTN)Address));
- *Out.Uint8 = MmioRead8 ((UINTN) Address);
- break;
- case S3BootScriptWidthFillUint8:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint8 - 0x%08x\n", (UINTN)Address));
- *Out.Uint8 = MmioRead8 ((UINTN) Address);
- break;
+ case S3BootScriptWidthUint8:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint8 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint8 = MmioRead8 ((UINTN)Address);
+ break;
+ case S3BootScriptWidthFifoUint8:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint8 = MmioRead8 ((UINTN)Address);
+ break;
+ case S3BootScriptWidthFillUint8:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint8 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint8 = MmioRead8 ((UINTN)Address);
+ break;
- case S3BootScriptWidthUint16:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint16 - 0x%08x\n", (UINTN)Address));
- *Out.Uint16 = MmioRead16 ((UINTN) Address);
- break;
- case S3BootScriptWidthFifoUint16:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint16 - 0x%08x\n", (UINTN)Address));
- *Out.Uint16 = MmioRead16 ((UINTN) Address);
- break;
- case S3BootScriptWidthFillUint16:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint16 - 0x%08x\n", (UINTN)Address));
- *Out.Uint16 = MmioRead16 ((UINTN) Address);
- break;
+ case S3BootScriptWidthUint16:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint16 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint16 = MmioRead16 ((UINTN)Address);
+ break;
+ case S3BootScriptWidthFifoUint16:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint16 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint16 = MmioRead16 ((UINTN)Address);
+ break;
+ case S3BootScriptWidthFillUint16:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint16 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint16 = MmioRead16 ((UINTN)Address);
+ break;
- case S3BootScriptWidthUint32:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint32 - 0x%08x\n", (UINTN)Address));
- *Out.Uint32 = MmioRead32 ((UINTN) Address);
- break;
- case S3BootScriptWidthFifoUint32:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint32 - 0x%08x\n", (UINTN)Address));
- *Out.Uint32 = MmioRead32 ((UINTN) Address);
- break;
- case S3BootScriptWidthFillUint32:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint32 - 0x%08x\n", (UINTN)Address));
- *Out.Uint32 = MmioRead32 ((UINTN) Address);
- break;
+ case S3BootScriptWidthUint32:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint32 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint32 = MmioRead32 ((UINTN)Address);
+ break;
+ case S3BootScriptWidthFifoUint32:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint32 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint32 = MmioRead32 ((UINTN)Address);
+ break;
+ case S3BootScriptWidthFillUint32:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint32 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint32 = MmioRead32 ((UINTN)Address);
+ break;
- case S3BootScriptWidthUint64:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint64 - 0x%08x\n", (UINTN)Address));
- *Out.Uint64 = MmioRead64 ((UINTN) Address);
- break;
- case S3BootScriptWidthFifoUint64:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint64 - 0x%08x\n", (UINTN)Address));
- *Out.Uint64 = MmioRead64 ((UINTN) Address);
- break;
- case S3BootScriptWidthFillUint64:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint64 - 0x%08x\n", (UINTN)Address));
- *Out.Uint64 = MmioRead64 ((UINTN) Address);
- break;
+ case S3BootScriptWidthUint64:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint64 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint64 = MmioRead64 ((UINTN)Address);
+ break;
+ case S3BootScriptWidthFifoUint64:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint64 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint64 = MmioRead64 ((UINTN)Address);
+ break;
+ case S3BootScriptWidthFillUint64:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint64 - 0x%08x\n", (UINTN)Address));
+ *Out.Uint64 = MmioRead64 ((UINTN)Address);
+ break;
- default:
- return EFI_UNSUPPORTED;
+ default:
+ return EFI_UNSUPPORTED;
}
}
return EFI_SUCCESS;
}
+
/**
Perform memory write operation
@@ -517,10 +521,10 @@ ScriptMemoryRead (
**/
EFI_STATUS
ScriptMemoryWrite (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- IN OUT VOID *Buffer
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
)
{
EFI_STATUS Status;
@@ -530,73 +534,76 @@ ScriptMemoryWrite (
PTR In;
PTR OriginalIn;
- In.Buf = Buffer;
+ In.Buf = Buffer;
- Status = BuildLoopData (Width, Address, &AddressStride, &BufferStride);
+ Status = BuildLoopData (Width, Address, &AddressStride, &BufferStride);
if (EFI_ERROR (Status)) {
return Status;
}
+
//
// Loop for each iteration and move the data
//
OriginalAddress = Address;
- OriginalIn.Buf = In.Buf;
- for (; Count > 0; Count--, Address += AddressStride, In.Buf += BufferStride) {
+ OriginalIn.Buf = In.Buf;
+ for ( ; Count > 0; Count--, Address += AddressStride, In.Buf += BufferStride) {
switch (Width) {
case S3BootScriptWidthUint8:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint8 - 0x%08x (0x%02x)\n", (UINTN)Address, (UINTN)*In.Uint8));
- MmioWrite8 ((UINTN) Address, *In.Uint8);
+ MmioWrite8 ((UINTN)Address, *In.Uint8);
break;
case S3BootScriptWidthFifoUint8:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x (0x%02x)\n", (UINTN)OriginalAddress, (UINTN)*In.Uint8));
- MmioWrite8 ((UINTN) OriginalAddress, *In.Uint8);
+ MmioWrite8 ((UINTN)OriginalAddress, *In.Uint8);
break;
case S3BootScriptWidthFillUint8:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint8 - 0x%08x (0x%02x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint8));
- MmioWrite8 ((UINTN) Address, *OriginalIn.Uint8);
+ MmioWrite8 ((UINTN)Address, *OriginalIn.Uint8);
break;
case S3BootScriptWidthUint16:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint16 - 0x%08x (0x%04x)\n", (UINTN)Address, (UINTN)*In.Uint16));
- MmioWrite16 ((UINTN) Address, *In.Uint16);
+ MmioWrite16 ((UINTN)Address, *In.Uint16);
break;
case S3BootScriptWidthFifoUint16:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint16 - 0x%08x (0x%04x)\n", (UINTN)OriginalAddress, (UINTN)*In.Uint16));
- MmioWrite16 ((UINTN) OriginalAddress, *In.Uint16);
+ MmioWrite16 ((UINTN)OriginalAddress, *In.Uint16);
break;
case S3BootScriptWidthFillUint16:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint16 - 0x%08x (0x%04x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint16));
- MmioWrite16 ((UINTN) Address, *OriginalIn.Uint16);
+ MmioWrite16 ((UINTN)Address, *OriginalIn.Uint16);
break;
case S3BootScriptWidthUint32:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint32 - 0x%08x (0x%08x)\n", (UINTN)Address, (UINTN)*In.Uint32));
- MmioWrite32 ((UINTN) Address, *In.Uint32);
+ MmioWrite32 ((UINTN)Address, *In.Uint32);
break;
case S3BootScriptWidthFifoUint32:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint32 - 0x%08x (0x%08x)\n", (UINTN)OriginalAddress, (UINTN)*In.Uint32));
- MmioWrite32 ((UINTN) OriginalAddress, *In.Uint32);
+ MmioWrite32 ((UINTN)OriginalAddress, *In.Uint32);
break;
case S3BootScriptWidthFillUint32:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint32 - 0x%08x (0x%08x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint32));
- MmioWrite32 ((UINTN) Address, *OriginalIn.Uint32);
+ MmioWrite32 ((UINTN)Address, *OriginalIn.Uint32);
break;
case S3BootScriptWidthUint64:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint64 - 0x%08x (0x%016lx)\n", (UINTN)Address, *In.Uint64));
- MmioWrite64 ((UINTN) Address, *In.Uint64);
+ MmioWrite64 ((UINTN)Address, *In.Uint64);
break;
case S3BootScriptWidthFifoUint64:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint64 - 0x%08x (0x%016lx)\n", (UINTN)OriginalAddress, *In.Uint64));
- MmioWrite64 ((UINTN) OriginalAddress, *In.Uint64);
+ MmioWrite64 ((UINTN)OriginalAddress, *In.Uint64);
break;
case S3BootScriptWidthFillUint64:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint64 - 0x%08x (0x%016lx)\n", (UINTN)Address, *OriginalIn.Uint64));
- MmioWrite64 ((UINTN) Address, *OriginalIn.Uint64);
+ MmioWrite64 ((UINTN)Address, *OriginalIn.Uint64);
break;
default:
return EFI_UNSUPPORTED;
}
}
+
return EFI_SUCCESS;
}
+
/**
Interpret the boot script node with EFI_BOOT_SCRIPT_MEM_WRITE OP code.
@@ -612,25 +619,25 @@ ScriptMemoryWrite (
**/
EFI_STATUS
BootScriptExecuteMemoryWrite (
- IN UINT8 *Script
+ IN UINT8 *Script
)
{
- VOID *Buffer;
- S3_BOOT_SCRIPT_LIB_WIDTH Width;
- UINT64 Address;
- UINTN Count;
+ VOID *Buffer;
+ S3_BOOT_SCRIPT_LIB_WIDTH Width;
+ UINT64 Address;
+ UINTN Count;
EFI_BOOT_SCRIPT_MEM_WRITE MemWrite;
- CopyMem((VOID*)&MemWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_MEM_WRITE));
+ CopyMem ((VOID *)&MemWrite, (VOID *)Script, sizeof (EFI_BOOT_SCRIPT_MEM_WRITE));
Width = (S3_BOOT_SCRIPT_LIB_WIDTH)MemWrite.Width;
Address = MemWrite.Address;
Count = MemWrite.Count;
- Buffer = Script + sizeof(EFI_BOOT_SCRIPT_MEM_WRITE);
+ Buffer = Script + sizeof (EFI_BOOT_SCRIPT_MEM_WRITE);
DEBUG ((DEBUG_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);
}
+
/**
Performance PCI configuration 2 read operation
@@ -647,11 +654,11 @@ BootScriptExecuteMemoryWrite (
**/
EFI_STATUS
ScriptPciCfg2Read (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT16 Segment,
- IN UINT64 Address,
- IN UINTN Count,
- OUT VOID *Buffer
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT16 Segment,
+ IN UINT64 Address,
+ IN UINTN Count,
+ OUT VOID *Buffer
)
{
EFI_STATUS Status;
@@ -660,7 +667,7 @@ ScriptPciCfg2Read (
PTR Out;
UINT64 PciAddress;
- Out.Buf = (UINT8 *) Buffer;
+ Out.Buf = (UINT8 *)Buffer;
PciAddress = PCI_ADDRESS_ENCODE (Segment, Address);
@@ -668,54 +675,56 @@ ScriptPciCfg2Read (
if (EFI_ERROR (Status)) {
return Status;
}
+
//
// Loop for each iteration and move the data
//
- for (; Count > 0; Count--, PciAddress += AddressStride, Out.Buf += BufferStride) {
+ for ( ; Count > 0; Count--, PciAddress += AddressStride, Out.Buf += BufferStride) {
switch (Width) {
- case S3BootScriptWidthUint8:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint8 - 0x%016lx\n", PciAddress));
- *Out.Uint8 = PciSegmentRead8 (PciAddress);
- break;
- case S3BootScriptWidthFifoUint8:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint8 - 0x%016lx\n", PciAddress));
- *Out.Uint8 = PciSegmentRead8 (PciAddress);
- break;
- case S3BootScriptWidthFillUint8:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint8 - 0x%016lx\n", PciAddress));
- *Out.Uint8 = PciSegmentRead8 (PciAddress);
- break;
+ case S3BootScriptWidthUint8:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint8 - 0x%016lx\n", PciAddress));
+ *Out.Uint8 = PciSegmentRead8 (PciAddress);
+ break;
+ case S3BootScriptWidthFifoUint8:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint8 - 0x%016lx\n", PciAddress));
+ *Out.Uint8 = PciSegmentRead8 (PciAddress);
+ break;
+ case S3BootScriptWidthFillUint8:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint8 - 0x%016lx\n", PciAddress));
+ *Out.Uint8 = PciSegmentRead8 (PciAddress);
+ break;
- case S3BootScriptWidthUint16:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint16 - 0x%016lx\n", PciAddress));
- *Out.Uint16 = PciSegmentRead16 (PciAddress);
- break;
- case S3BootScriptWidthFifoUint16:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint16 - 0x%016lx\n", PciAddress));
- *Out.Uint16 = PciSegmentRead16 (PciAddress);
- break;
- case S3BootScriptWidthFillUint16:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint16 - 0x%016lx\n", PciAddress));
- *Out.Uint16 = PciSegmentRead16 (PciAddress);
- break;
+ case S3BootScriptWidthUint16:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint16 - 0x%016lx\n", PciAddress));
+ *Out.Uint16 = PciSegmentRead16 (PciAddress);
+ break;
+ case S3BootScriptWidthFifoUint16:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint16 - 0x%016lx\n", PciAddress));
+ *Out.Uint16 = PciSegmentRead16 (PciAddress);
+ break;
+ case S3BootScriptWidthFillUint16:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint16 - 0x%016lx\n", PciAddress));
+ *Out.Uint16 = PciSegmentRead16 (PciAddress);
+ break;
- case S3BootScriptWidthUint32:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint32 - 0x%016lx\n", PciAddress));
- *Out.Uint32 = PciSegmentRead32 (PciAddress);
- break;
- case S3BootScriptWidthFifoUint32:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint32 - 0x%016lx\n", PciAddress));
- *Out.Uint32 = PciSegmentRead32 (PciAddress);
- break;
- case S3BootScriptWidthFillUint32:
- DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint32 - 0x%016lx\n", PciAddress));
- *Out.Uint32 = PciSegmentRead32 (PciAddress);
- break;
+ case S3BootScriptWidthUint32:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint32 - 0x%016lx\n", PciAddress));
+ *Out.Uint32 = PciSegmentRead32 (PciAddress);
+ break;
+ case S3BootScriptWidthFifoUint32:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFifoUint32 - 0x%016lx\n", PciAddress));
+ *Out.Uint32 = PciSegmentRead32 (PciAddress);
+ break;
+ case S3BootScriptWidthFillUint32:
+ DEBUG ((DEBUG_INFO, "S3BootScriptWidthFillUint32 - 0x%016lx\n", PciAddress));
+ *Out.Uint32 = PciSegmentRead32 (PciAddress);
+ break;
- default:
- return EFI_INVALID_PARAMETER;
+ default:
+ return EFI_INVALID_PARAMETER;
}
}
+
return EFI_SUCCESS;
}
@@ -735,11 +744,11 @@ ScriptPciCfg2Read (
**/
EFI_STATUS
ScriptPciCfg2Write (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT16 Segment,
- IN UINT64 Address,
- IN UINTN Count,
- IN VOID *Buffer
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT16 Segment,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN VOID *Buffer
)
{
EFI_STATUS Status;
@@ -750,7 +759,7 @@ ScriptPciCfg2Write (
PTR OriginalIn;
UINT64 PciAddress;
- In.Buf = (UINT8 *) Buffer;
+ In.Buf = (UINT8 *)Buffer;
PciAddress = PCI_ADDRESS_ENCODE (Segment, Address);
@@ -758,12 +767,13 @@ ScriptPciCfg2Write (
if (EFI_ERROR (Status)) {
return Status;
}
+
//
// Loop for each iteration and move the data
//
OriginalPciAddress = PciAddress;
- OriginalIn.Buf = In.Buf;
- for (; Count > 0; Count--, PciAddress += AddressStride, In.Buf += BufferStride) {
+ OriginalIn.Buf = In.Buf;
+ for ( ; Count > 0; Count--, PciAddress += AddressStride, In.Buf += BufferStride) {
switch (Width) {
case S3BootScriptWidthUint8:
DEBUG ((DEBUG_INFO, "S3BootScriptWidthUint8 - 0x%016lx (0x%02x)\n", PciAddress, (UINTN)*In.Uint8));
@@ -805,8 +815,10 @@ ScriptPciCfg2Write (
return EFI_INVALID_PARAMETER;
}
}
+
return EFI_SUCCESS;
}
+
/**
Performance PCI configuration read operation
@@ -824,14 +836,15 @@ ScriptPciCfg2Write (
**/
EFI_STATUS
ScriptPciCfgRead (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- OUT VOID *Buffer
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ OUT VOID *Buffer
)
{
return ScriptPciCfg2Read (Width, 0, Address, Count, Buffer);
}
+
/**
Performance PCI configuration write operation
@@ -850,14 +863,15 @@ ScriptPciCfgRead (
EFI_STATUS
EFIAPI
ScriptPciCfgWrite (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- IN VOID *Buffer
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN VOID *Buffer
)
{
return ScriptPciCfg2Write (Width, 0, Address, Count, Buffer);
}
+
/**
Interpret the boot script node with EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE OP code.
@@ -867,7 +881,7 @@ ScriptPciCfgWrite (
**/
EFI_STATUS
BootScriptExecutePciCfgWrite (
- IN UINT8 *Script
+ IN UINT8 *Script
)
{
VOID *Buffer;
@@ -876,16 +890,17 @@ BootScriptExecutePciCfgWrite (
UINTN Count;
EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE PciCfgWrite;
- CopyMem ((VOID*)&PciCfgWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE));
+ CopyMem ((VOID *)&PciCfgWrite, (VOID *)Script, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE));
Width = (S3_BOOT_SCRIPT_LIB_WIDTH)PciCfgWrite.Width;
Address = PciCfgWrite.Address;
Count = PciCfgWrite.Count;
- Buffer = Script + sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE);
+ Buffer = Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE);
DEBUG ((DEBUG_INFO, "BootScriptExecutePciCfgWrite - 0x%016lx, 0x%08x, 0x%08x\n", PCI_ADDRESS_ENCODE (0, Address), Count, (UINTN)Width));
return ScriptPciCfgWrite (Width, Address, Count, Buffer);
}
+
/**
Interpret the boot script node with EFI_BOOT_SCRIPT_IO_READ_WRITE OP code.
@@ -897,39 +912,41 @@ BootScriptExecutePciCfgWrite (
**/
EFI_STATUS
BootScriptExecuteIoReadWrite (
- IN UINT8 *Script,
- IN UINT64 AndMask,
- IN UINT64 OrMask
+ IN UINT8 *Script,
+ IN UINT64 AndMask,
+ IN UINT64 OrMask
)
{
- EFI_STATUS Status;
- UINT64 Data;
- EFI_BOOT_SCRIPT_IO_READ_WRITE IoReadWrite;
+ 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));
+ CopyMem ((VOID *)&IoReadWrite, (VOID *)Script, sizeof (EFI_BOOT_SCRIPT_IO_READ_WRITE));
DEBUG ((DEBUG_INFO, "BootScriptExecuteIoReadWrite - 0x%08x, 0x%016lx, 0x%016lx\n", (UINTN)IoReadWrite.Address, AndMask, OrMask));
Status = ScriptIoRead (
- (S3_BOOT_SCRIPT_LIB_WIDTH) IoReadWrite.Width,
+ (S3_BOOT_SCRIPT_LIB_WIDTH)IoReadWrite.Width,
IoReadWrite.Address,
1,
&Data
);
if (!EFI_ERROR (Status)) {
- Data = (Data & AndMask) | OrMask;
+ Data = (Data & AndMask) | OrMask;
Status = ScriptIoWrite (
- (S3_BOOT_SCRIPT_LIB_WIDTH) IoReadWrite.Width,
+ (S3_BOOT_SCRIPT_LIB_WIDTH)IoReadWrite.Width,
IoReadWrite.Address,
1,
&Data
);
}
+
return Status;
}
+
/**
Interpret the boot script node with EFI_BOOT_SCRIPT_MEM_READ_WRITE OP code.
@@ -941,39 +958,41 @@ BootScriptExecuteIoReadWrite (
**/
EFI_STATUS
BootScriptExecuteMemoryReadWrite (
- IN UINT8 *Script,
- IN UINT64 AndMask,
- IN UINT64 OrMask
+ IN UINT8 *Script,
+ IN UINT64 AndMask,
+ IN UINT64 OrMask
)
{
- EFI_STATUS Status;
- UINT64 Data;
+ 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));
+ CopyMem ((VOID *)&MemReadWrite, (VOID *)Script, sizeof (EFI_BOOT_SCRIPT_MEM_READ_WRITE));
DEBUG ((DEBUG_INFO, "BootScriptExecuteMemoryReadWrite - 0x%08x, 0x%016lx, 0x%016lx\n", (UINTN)MemReadWrite.Address, AndMask, OrMask));
Status = ScriptMemoryRead (
- (S3_BOOT_SCRIPT_LIB_WIDTH) MemReadWrite.Width,
+ (S3_BOOT_SCRIPT_LIB_WIDTH)MemReadWrite.Width,
MemReadWrite.Address,
1,
&Data
);
if (!EFI_ERROR (Status)) {
- Data = (Data & AndMask) | OrMask;
+ Data = (Data & AndMask) | OrMask;
Status = ScriptMemoryWrite (
- (S3_BOOT_SCRIPT_LIB_WIDTH) MemReadWrite.Width,
+ (S3_BOOT_SCRIPT_LIB_WIDTH)MemReadWrite.Width,
MemReadWrite.Address,
1,
&Data
);
}
+
return Status;
}
+
/**
Interpret the boot script node with EFI_BOOT_SCRIPT_PCI_CFG_READ_WRITE OP code.
@@ -985,24 +1004,24 @@ BootScriptExecuteMemoryReadWrite (
**/
EFI_STATUS
BootScriptExecutePciCfgReadWrite (
- IN UINT8 *Script,
- IN UINT64 AndMask,
- IN UINT64 OrMask
+ IN UINT8 *Script,
+ IN UINT64 AndMask,
+ IN UINT64 OrMask
)
{
- EFI_STATUS Status;
- UINT64 Data;
+ 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));
+ CopyMem ((VOID *)&PciCfgReadWrite, (VOID *)Script, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE));
DEBUG ((DEBUG_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,
+ (S3_BOOT_SCRIPT_LIB_WIDTH)PciCfgReadWrite.Width,
PciCfgReadWrite.Address,
1,
&Data
@@ -1014,7 +1033,7 @@ BootScriptExecutePciCfgReadWrite (
Data = (Data & AndMask) | OrMask;
Status = ScriptPciCfgWrite (
- (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfgReadWrite.Width,
+ (S3_BOOT_SCRIPT_LIB_WIDTH)PciCfgReadWrite.Width,
PciCfgReadWrite.Address,
1,
&Data
@@ -1022,6 +1041,7 @@ BootScriptExecutePciCfgReadWrite (
return Status;
}
+
/**
Interpret the boot script node with EFI_BOOT_SCRIPT_SMBUS_EXECUTE OP code.
@@ -1033,26 +1053,27 @@ BootScriptExecutePciCfgReadWrite (
**/
EFI_STATUS
BootScriptExecuteSmbusExecute (
- IN UINT8 *Script
+ IN UINT8 *Script
)
{
- UINTN SmBusAddress;
- UINTN DataSize;
- EFI_BOOT_SCRIPT_SMBUS_EXECUTE SmbusExecuteEntry;
+ UINTN SmBusAddress;
+ UINTN DataSize;
+ EFI_BOOT_SCRIPT_SMBUS_EXECUTE SmbusExecuteEntry;
- CopyMem ((VOID*)&SmbusExecuteEntry, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_SMBUS_EXECUTE ));
+ CopyMem ((VOID *)&SmbusExecuteEntry, (VOID *)Script, sizeof (EFI_BOOT_SCRIPT_SMBUS_EXECUTE));
DEBUG ((DEBUG_INFO, "BootScriptExecuteSmbusExecute - 0x%08x, 0x%08x\n", (UINTN)SmbusExecuteEntry.SmBusAddress, (UINTN)SmbusExecuteEntry.Operation));
SmBusAddress = (UINTN)SmbusExecuteEntry.SmBusAddress;
- DataSize = (UINTN) SmbusExecuteEntry.DataSize;
+ DataSize = (UINTN)SmbusExecuteEntry.DataSize;
return InternalSmbusExecute (
SmBusAddress,
- (EFI_SMBUS_OPERATION) SmbusExecuteEntry.Operation,
+ (EFI_SMBUS_OPERATION)SmbusExecuteEntry.Operation,
&DataSize,
Script + sizeof (EFI_BOOT_SCRIPT_SMBUS_EXECUTE)
);
}
+
/**
Interpret the boot script node with EFI_BOOT_SCRIPT_STALL OP code.
@@ -1062,18 +1083,19 @@ BootScriptExecuteSmbusExecute (
**/
EFI_STATUS
BootScriptExecuteStall (
- IN UINT8 *Script
+ IN UINT8 *Script
)
{
- EFI_BOOT_SCRIPT_STALL Stall;
+ EFI_BOOT_SCRIPT_STALL Stall;
- CopyMem ((VOID*)&Stall, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_STALL));
+ CopyMem ((VOID *)&Stall, (VOID *)Script, sizeof (EFI_BOOT_SCRIPT_STALL));
DEBUG ((DEBUG_INFO, "BootScriptExecuteStall - 0x%08x\n", (UINTN)Stall.Duration));
- MicroSecondDelay ((UINTN) Stall.Duration);
+ MicroSecondDelay ((UINTN)Stall.Duration);
return EFI_SUCCESS;
}
+
/**
Interpret the boot script node with EFI_BOOT_SCRIPT_DISPATCH OP code.
@@ -1082,22 +1104,23 @@ BootScriptExecuteStall (
**/
EFI_STATUS
BootScriptExecuteDispatch (
- IN UINT8 *Script
+ IN UINT8 *Script
)
{
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);
+ CopyMem ((VOID *)&ScriptDispatch, (VOID *)Script, sizeof (EFI_BOOT_SCRIPT_DISPATCH));
+ EntryFunc = (DISPATCH_ENTRYPOINT_FUNC)(UINTN)(ScriptDispatch.EntryPoint);
DEBUG ((DEBUG_INFO, "BootScriptExecuteDispatch - 0x%08x\n", (UINTN)ScriptDispatch.EntryPoint));
- Status = EntryFunc (NULL, NULL);
+ Status = EntryFunc (NULL, NULL);
return Status;
}
+
/**
Interpret the boot script node with EFI_BOOT_SCRIPT_DISPATCH_2 OP code.
@@ -1106,23 +1129,24 @@ BootScriptExecuteDispatch (
**/
EFI_STATUS
BootScriptExecuteDispatch2 (
- IN UINT8 *Script
+ IN UINT8 *Script
)
{
- EFI_STATUS Status;
- DISPATCH_ENTRYPOINT_FUNC EntryFunc;
+ EFI_STATUS Status;
+ DISPATCH_ENTRYPOINT_FUNC EntryFunc;
EFI_BOOT_SCRIPT_DISPATCH_2 ScriptDispatch2;
- CopyMem ((VOID*)&ScriptDispatch2, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_DISPATCH_2));
+ CopyMem ((VOID *)&ScriptDispatch2, (VOID *)Script, sizeof (EFI_BOOT_SCRIPT_DISPATCH_2));
DEBUG ((DEBUG_INFO, "BootScriptExecuteDispatch2 - 0x%08x(0x%08x)\n", (UINTN)ScriptDispatch2.EntryPoint, (UINTN)ScriptDispatch2.Context));
- EntryFunc = (DISPATCH_ENTRYPOINT_FUNC) (UINTN) (ScriptDispatch2.EntryPoint);
+ EntryFunc = (DISPATCH_ENTRYPOINT_FUNC)(UINTN)(ScriptDispatch2.EntryPoint);
- Status = EntryFunc (NULL, (VOID *) (UINTN) ScriptDispatch2.Context);
+ Status = EntryFunc (NULL, (VOID *)(UINTN)ScriptDispatch2.Context);
return Status;
}
+
/**
Interpret the boot script node with EFI_BOOT_SCRIPT_MEM_POLL OP code.
@@ -1136,45 +1160,44 @@ BootScriptExecuteDispatch2 (
**/
EFI_STATUS
BootScriptExecuteMemPoll (
- IN UINT8 *Script,
- IN UINT64 AndMask,
- IN UINT64 OrMask
+ IN UINT8 *Script,
+ IN UINT64 AndMask,
+ IN UINT64 OrMask
)
{
+ UINT64 Data;
+ UINT64 LoopTimes;
+ EFI_STATUS Status;
+ EFI_BOOT_SCRIPT_MEM_POLL MemPoll;
- UINT64 Data;
- UINT64 LoopTimes;
- EFI_STATUS Status;
- EFI_BOOT_SCRIPT_MEM_POLL MemPoll;
-
- CopyMem ((VOID*)&MemPoll, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_MEM_POLL));
+ CopyMem ((VOID *)&MemPoll, (VOID *)Script, sizeof (EFI_BOOT_SCRIPT_MEM_POLL));
DEBUG ((DEBUG_INFO, "BootScriptExecuteMemPoll - 0x%08x, 0x%016lx, 0x%016lx\n", (UINTN)MemPoll.Address, AndMask, OrMask));
- Data = 0;
+ Data = 0;
Status = ScriptMemoryRead (
- (S3_BOOT_SCRIPT_LIB_WIDTH) MemPoll.Width,
- MemPoll.Address,
- 1,
- &Data
- );
- if ((!EFI_ERROR (Status)) && (Data & AndMask) == OrMask) {
+ (S3_BOOT_SCRIPT_LIB_WIDTH)MemPoll.Width,
+ MemPoll.Address,
+ 1,
+ &Data
+ );
+ if ((!EFI_ERROR (Status)) && ((Data & AndMask) == OrMask)) {
return EFI_SUCCESS;
}
for (LoopTimes = 0; LoopTimes < MemPoll.LoopTimes; LoopTimes++) {
MicroSecondDelay ((UINTN)MemPoll.Duration);
- Data = 0;
+ Data = 0;
Status = ScriptMemoryRead (
- (S3_BOOT_SCRIPT_LIB_WIDTH) MemPoll.Width,
+ (S3_BOOT_SCRIPT_LIB_WIDTH)MemPoll.Width,
MemPoll.Address,
1,
&Data
);
- if ((!EFI_ERROR (Status)) && (Data & AndMask) == OrMask) {
- return EFI_SUCCESS;
- }
+ if ((!EFI_ERROR (Status)) && ((Data & AndMask) == OrMask)) {
+ return EFI_SUCCESS;
+ }
}
if (LoopTimes < MemPoll.LoopTimes) {
@@ -1183,6 +1206,7 @@ BootScriptExecuteMemPoll (
return EFI_DEVICE_ERROR;
}
}
+
/**
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.
@@ -1192,23 +1216,24 @@ BootScriptExecuteMemPoll (
**/
VOID
BootScriptExecuteInformation (
- IN UINT8 *Script
+ IN UINT8 *Script
)
{
- UINT32 Index;
- EFI_BOOT_SCRIPT_INFORMATION Information;
- UINT8 *InformationData;
+ UINT32 Index;
+ EFI_BOOT_SCRIPT_INFORMATION Information;
+ UINT8 *InformationData;
- CopyMem ((VOID*)&Information, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_INFORMATION));
+ CopyMem ((VOID *)&Information, (VOID *)Script, sizeof (EFI_BOOT_SCRIPT_INFORMATION));
InformationData = Script + sizeof (EFI_BOOT_SCRIPT_INFORMATION);
- DEBUG ((DEBUG_INFO, "BootScriptExecuteInformation - 0x%08x\n", (UINTN) InformationData));
+ DEBUG ((DEBUG_INFO, "BootScriptExecuteInformation - 0x%08x\n", (UINTN)InformationData));
DEBUG ((DEBUG_INFO, "BootScriptInformation: "));
for (Index = 0; Index < Information.InformationLength; Index++) {
DEBUG ((DEBUG_INFO, "%02x ", InformationData[Index]));
}
+
DEBUG ((DEBUG_INFO, "\n"));
}
@@ -1220,23 +1245,24 @@ BootScriptExecuteInformation (
**/
VOID
BootScriptExecuteLabel (
- IN UINT8 *Script
+ IN UINT8 *Script
)
{
- UINT32 Index;
- EFI_BOOT_SCRIPT_INFORMATION Information;
- UINT8 *InformationData;
+ UINT32 Index;
+ EFI_BOOT_SCRIPT_INFORMATION Information;
+ UINT8 *InformationData;
- CopyMem ((VOID*)&Information, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_INFORMATION));
+ CopyMem ((VOID *)&Information, (VOID *)Script, sizeof (EFI_BOOT_SCRIPT_INFORMATION));
InformationData = Script + sizeof (EFI_BOOT_SCRIPT_INFORMATION);
- DEBUG ((DEBUG_INFO, "BootScriptExecuteLabel - 0x%08x\n", (UINTN) InformationData));
+ DEBUG ((DEBUG_INFO, "BootScriptExecuteLabel - 0x%08x\n", (UINTN)InformationData));
DEBUG ((DEBUG_INFO, "BootScriptLabel: "));
for (Index = 0; Index < Information.InformationLength; Index++) {
DEBUG ((DEBUG_INFO, "%02x ", InformationData[Index]));
}
+
DEBUG ((DEBUG_INFO, "\n"));
}
@@ -1251,79 +1277,80 @@ BootScriptExecuteLabel (
VOID
CheckAndOrMask (
IN EFI_BOOT_SCRIPT_COMMON_HEADER *ScriptHeader,
- OUT UINT64 *AndMask,
- OUT UINT64 *OrMask,
- IN UINT8 *Script
+ OUT UINT64 *AndMask,
+ OUT UINT64 *OrMask,
+ IN UINT8 *Script
)
{
- UINT8 *DataPtr;
- UINTN Size;
+ UINT8 *DataPtr;
+ UINTN Size;
switch (ScriptHeader->OpCode) {
- case EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE:
- Size = sizeof (EFI_BOOT_SCRIPT_IO_READ_WRITE);
- break;
-
- case EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE:
- Size = sizeof (EFI_BOOT_SCRIPT_MEM_READ_WRITE);
- break;
-
- case EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE:
- Size = sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE);
- break;
- 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;
-
- 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;
+ case EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE:
+ Size = sizeof (EFI_BOOT_SCRIPT_IO_READ_WRITE);
+ break;
+
+ case EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE:
+ Size = sizeof (EFI_BOOT_SCRIPT_MEM_READ_WRITE);
+ break;
+
+ case EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE:
+ Size = sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE);
+ break;
+ 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;
+
+ 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) (*(UINT8*) (DataPtr + 1));
- *OrMask = (UINT64) (*DataPtr);
- break;
-
- case S3BootScriptWidthUint16:
- *AndMask = (UINT64) (*(UINT16 *) (DataPtr + 2));
- *OrMask = (UINT64) (*(UINT16 *) DataPtr);
- break;
-
- case S3BootScriptWidthUint32:
- *AndMask = (UINT64) (*(UINT32 *) (DataPtr + 4));
- *OrMask = (UINT64) (*(UINT32 *) DataPtr);
- break;
-
- case S3BootScriptWidthUint64:
- *AndMask = (UINT64) (*(UINT64 *) (DataPtr + 8));
- *OrMask = (UINT64) (*(UINT64 *) DataPtr);
- break;
-
- default:
- break;
+ case S3BootScriptWidthUint8:
+ *AndMask = (UINT64)(*(UINT8 *)(DataPtr + 1));
+ *OrMask = (UINT64)(*DataPtr);
+ break;
+
+ case S3BootScriptWidthUint16:
+ *AndMask = (UINT64)(*(UINT16 *)(DataPtr + 2));
+ *OrMask = (UINT64)(*(UINT16 *)DataPtr);
+ break;
+
+ case S3BootScriptWidthUint32:
+ *AndMask = (UINT64)(*(UINT32 *)(DataPtr + 4));
+ *OrMask = (UINT64)(*(UINT32 *)DataPtr);
+ break;
+
+ case S3BootScriptWidthUint64:
+ *AndMask = (UINT64)(*(UINT64 *)(DataPtr + 8));
+ *OrMask = (UINT64)(*(UINT64 *)DataPtr);
+ break;
+
+ default:
+ break;
}
return;
}
+
/**
Interpret the boot script node with EFI_BOOT_SCRIPT_IO_POLL OP code.
@@ -1337,40 +1364,41 @@ CheckAndOrMask (
**/
EFI_STATUS
BootScriptExecuteIoPoll (
- IN UINT8 *Script,
- IN UINT64 AndMask,
- IN UINT64 OrMask
+ IN UINT8 *Script,
+ IN UINT64 AndMask,
+ IN UINT64 OrMask
)
{
- EFI_STATUS Status;
- UINT64 Data;
- UINT64 LoopTimes;
- EFI_BOOT_SCRIPT_IO_POLL IoPoll;
+ EFI_STATUS Status;
+ UINT64 Data;
+ UINT64 LoopTimes;
+ EFI_BOOT_SCRIPT_IO_POLL IoPoll;
- CopyMem ((VOID*)&IoPoll, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_IO_POLL));
+ CopyMem ((VOID *)&IoPoll, (VOID *)Script, sizeof (EFI_BOOT_SCRIPT_IO_POLL));
DEBUG ((DEBUG_INFO, "BootScriptExecuteIoPoll - 0x%08x, 0x%016lx, 0x%016lx\n", (UINTN)IoPoll.Address, AndMask, OrMask));
- Data = 0;
+ Data = 0;
Status = ScriptIoRead (
- (S3_BOOT_SCRIPT_LIB_WIDTH) IoPoll.Width,
+ (S3_BOOT_SCRIPT_LIB_WIDTH)IoPoll.Width,
IoPoll.Address,
1,
&Data
);
- if ((!EFI_ERROR (Status)) && (Data & AndMask) == OrMask) {
+ if ((!EFI_ERROR (Status)) && ((Data & AndMask) == OrMask)) {
return EFI_SUCCESS;
}
+
for (LoopTimes = 0; LoopTimes < IoPoll.Delay; LoopTimes++) {
NanoSecondDelay (100);
- Data = 0;
+ Data = 0;
Status = ScriptIoRead (
- (S3_BOOT_SCRIPT_LIB_WIDTH) IoPoll.Width,
+ (S3_BOOT_SCRIPT_LIB_WIDTH)IoPoll.Width,
IoPoll.Address,
1,
&Data
);
- if ((!EFI_ERROR (Status)) &&(Data & AndMask) == OrMask) {
+ if ((!EFI_ERROR (Status)) && ((Data & AndMask) == OrMask)) {
return EFI_SUCCESS;
}
}
@@ -1381,6 +1409,7 @@ BootScriptExecuteIoPoll (
return EFI_DEVICE_ERROR;
}
}
+
/**
Interpret the boot script node with EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE OP code.
@@ -1391,29 +1420,28 @@ BootScriptExecuteIoPoll (
**/
EFI_STATUS
BootScriptExecutePciCfg2Write (
- IN UINT8 *Script
+ IN UINT8 *Script
)
{
- VOID *Buffer;
- S3_BOOT_SCRIPT_LIB_WIDTH Width;
- UINT16 Segment;
- UINT64 Address;
- UINTN Count;
- EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE PciCfg2Write;
+ VOID *Buffer;
+ S3_BOOT_SCRIPT_LIB_WIDTH Width;
+ UINT16 Segment;
+ UINT64 Address;
+ UINTN Count;
+ 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));
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);
+ Buffer = Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE);
DEBUG ((DEBUG_INFO, "BootScriptExecutePciCfg2Write - 0x%016lx, 0x%08x, 0x%08x\n", PCI_ADDRESS_ENCODE (Segment, Address), Count, (UINTN)Width));
return ScriptPciCfg2Write (Width, Segment, Address, Count, Buffer);
}
-
/**
Interpret the boot script node with EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE OP code.
@@ -1426,23 +1454,23 @@ BootScriptExecutePciCfg2Write (
**/
EFI_STATUS
BootScriptExecutePciCfg2ReadWrite (
- IN UINT8 *Script,
- IN UINT64 AndMask,
- IN UINT64 OrMask
+ IN UINT8 *Script,
+ IN UINT64 AndMask,
+ IN UINT64 OrMask
)
{
- UINT64 Data;
- EFI_STATUS Status;
- EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE PciCfg2ReadWrite;
+ 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));
+ CopyMem ((VOID *)&PciCfg2ReadWrite, (VOID *)Script, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE));
DEBUG ((DEBUG_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,
+ (S3_BOOT_SCRIPT_LIB_WIDTH)PciCfg2ReadWrite.Width,
PciCfg2ReadWrite.Segment,
PciCfg2ReadWrite.Address,
1,
@@ -1452,9 +1480,9 @@ BootScriptExecutePciCfg2ReadWrite (
return Status;
}
- Data = (Data & AndMask) | OrMask;
+ Data = (Data & AndMask) | OrMask;
Status = ScriptPciCfg2Write (
- (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfg2ReadWrite.Width,
+ (S3_BOOT_SCRIPT_LIB_WIDTH)PciCfg2ReadWrite.Width,
PciCfg2ReadWrite.Segment,
PciCfg2ReadWrite.Address,
1,
@@ -1462,6 +1490,7 @@ BootScriptExecutePciCfg2ReadWrite (
);
return Status;
}
+
/**
Interpret the boot script node with EFI_BOOT_SCRIPT_PCI_CONFIG_POLL OP code.
@@ -1475,41 +1504,43 @@ BootScriptExecutePciCfg2ReadWrite (
**/
EFI_STATUS
BootScriptPciCfgPoll (
- IN UINT8 *Script,
- IN UINT64 AndMask,
- IN UINT64 OrMask
+ IN UINT8 *Script,
+ IN UINT64 AndMask,
+ IN UINT64 OrMask
)
{
- UINT64 Data;
- UINT64 LoopTimes;
- EFI_STATUS Status;
- EFI_BOOT_SCRIPT_PCI_CONFIG_POLL PciCfgPoll;
- CopyMem ((VOID*)&PciCfgPoll, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG_POLL));
+ UINT64 Data;
+ UINT64 LoopTimes;
+ EFI_STATUS Status;
+ EFI_BOOT_SCRIPT_PCI_CONFIG_POLL PciCfgPoll;
+
+ CopyMem ((VOID *)&PciCfgPoll, (VOID *)Script, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_POLL));
DEBUG ((DEBUG_INFO, "BootScriptPciCfgPoll - 0x%016lx, 0x%016lx, 0x%016lx\n", PCI_ADDRESS_ENCODE (0, PciCfgPoll.Address), AndMask, OrMask));
- Data = 0;
+ Data = 0;
Status = ScriptPciCfgRead (
- (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfgPoll.Width,
+ (S3_BOOT_SCRIPT_LIB_WIDTH)PciCfgPoll.Width,
PciCfgPoll.Address,
1,
&Data
);
- if ((!EFI_ERROR (Status)) &&(Data & AndMask) == OrMask) {
+ if ((!EFI_ERROR (Status)) && ((Data & AndMask) == OrMask)) {
return EFI_SUCCESS;
}
for (LoopTimes = 0; LoopTimes < PciCfgPoll.Delay; LoopTimes++) {
NanoSecondDelay (100);
- Data = 0;
+ Data = 0;
Status = ScriptPciCfgRead (
- (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfgPoll.Width,
+ (S3_BOOT_SCRIPT_LIB_WIDTH)PciCfgPoll.Width,
PciCfgPoll.Address,
1,
&Data
);
if ((!EFI_ERROR (Status)) &&
- (Data & AndMask) == OrMask) {
+ ((Data & AndMask) == OrMask))
+ {
return EFI_SUCCESS;
}
}
@@ -1535,44 +1566,44 @@ BootScriptPciCfgPoll (
**/
EFI_STATUS
BootScriptPciCfg2Poll (
- IN UINT8 *Script,
- IN UINT64 AndMask,
- IN UINT64 OrMask
+ IN UINT8 *Script,
+ IN UINT64 AndMask,
+ IN UINT64 OrMask
)
{
- EFI_STATUS Status;
- UINT64 Data;
- UINT64 LoopTimes;
- EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL PciCfg2Poll;
+ EFI_STATUS Status;
+ UINT64 Data;
+ UINT64 LoopTimes;
+ EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL PciCfg2Poll;
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 ((DEBUG_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,
+ (S3_BOOT_SCRIPT_LIB_WIDTH)PciCfg2Poll.Width,
PciCfg2Poll.Segment,
PciCfg2Poll.Address,
1,
&Data
);
- if ((!EFI_ERROR (Status)) && (Data & AndMask) == OrMask) {
+ if ((!EFI_ERROR (Status)) && ((Data & AndMask) == OrMask)) {
return EFI_SUCCESS;
}
for (LoopTimes = 0; LoopTimes < PciCfg2Poll.Delay; LoopTimes++) {
NanoSecondDelay (100);
- Data = 0;
+ Data = 0;
Status = ScriptPciCfg2Read (
- (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfg2Poll.Width,
+ (S3_BOOT_SCRIPT_LIB_WIDTH)PciCfg2Poll.Width,
PciCfg2Poll.Segment,
PciCfg2Poll.Address,
1,
&Data
);
- if ((!EFI_ERROR (Status)) && (Data & AndMask) == OrMask) {
+ if ((!EFI_ERROR (Status)) && ((Data & AndMask) == OrMask)) {
return EFI_SUCCESS;
}
}
@@ -1582,7 +1613,6 @@ BootScriptPciCfg2Poll (
} else {
return EFI_DEVICE_ERROR;
}
-
}
/**
@@ -1598,17 +1628,18 @@ S3BootScriptExecute (
VOID
)
{
- EFI_STATUS Status;
- UINT8* Script;
- UINTN StartAddress;
- UINT32 TableLength;
- UINT64 AndMask;
- UINT64 OrMask;
+ EFI_STATUS Status;
+ UINT8 *Script;
+ UINTN StartAddress;
+ UINT32 TableLength;
+ UINT64 AndMask;
+ UINT64 OrMask;
EFI_BOOT_SCRIPT_COMMON_HEADER ScriptHeader;
EFI_BOOT_SCRIPT_TABLE_HEADER TableHeader;
+
Script = mS3BootScriptTablePtr->TableBase;
if (Script != 0) {
- CopyMem ((VOID*)&TableHeader, Script, sizeof(EFI_BOOT_SCRIPT_TABLE_HEADER));
+ CopyMem ((VOID *)&TableHeader, Script, sizeof (EFI_BOOT_SCRIPT_TABLE_HEADER));
} else {
return EFI_INVALID_PARAMETER;
}
@@ -1620,145 +1651,144 @@ S3BootScriptExecute (
DEBUG ((DEBUG_INFO, "TableHeader - 0x%08x\n", Script));
- StartAddress = (UINTN) Script;
- TableLength = TableHeader.TableLength;
- Script = Script + TableHeader.Length;
- Status = EFI_SUCCESS;
- AndMask = 0;
- OrMask = 0;
+ StartAddress = (UINTN)Script;
+ TableLength = TableHeader.TableLength;
+ Script = Script + TableHeader.Length;
+ Status = EFI_SUCCESS;
+ AndMask = 0;
+ OrMask = 0;
DEBUG ((DEBUG_INFO, "TableHeader.Version - 0x%04x\n", (UINTN)TableHeader.Version));
DEBUG ((DEBUG_INFO, "TableHeader.TableLength - 0x%08x\n", (UINTN)TableLength));
- while ((UINTN) Script < (UINTN) (StartAddress + TableLength)) {
+ while ((UINTN)Script < (UINTN)(StartAddress + TableLength)) {
DEBUG ((DEBUG_INFO, "ExecuteBootScript - %08x\n", (UINTN)Script));
- CopyMem ((VOID*)&ScriptHeader, Script, sizeof(EFI_BOOT_SCRIPT_COMMON_HEADER));
+ CopyMem ((VOID *)&ScriptHeader, Script, sizeof (EFI_BOOT_SCRIPT_COMMON_HEADER));
switch (ScriptHeader.OpCode) {
+ case EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE:
+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE\n"));
+ Status = BootScriptExecuteMemoryWrite (Script);
+ break;
- case EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE:
- DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE\n"));
- Status = BootScriptExecuteMemoryWrite (Script);
- break;
-
- case EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE:
- DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE\n"));
- CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);
- Status = BootScriptExecuteMemoryReadWrite (
- Script,
- AndMask,
- OrMask
- );
- break;
+ case EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE:
+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE\n"));
+ CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);
+ Status = BootScriptExecuteMemoryReadWrite (
+ Script,
+ AndMask,
+ OrMask
+ );
+ break;
- case EFI_BOOT_SCRIPT_IO_WRITE_OPCODE:
- DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_IO_WRITE_OPCODE\n"));
- Status = BootScriptExecuteIoWrite (Script);
- break;
+ case EFI_BOOT_SCRIPT_IO_WRITE_OPCODE:
+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_IO_WRITE_OPCODE\n"));
+ Status = BootScriptExecuteIoWrite (Script);
+ break;
- case EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE:
- DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE\n"));
- Status = BootScriptExecutePciCfgWrite (Script);
- break;
+ case EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE:
+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE\n"));
+ Status = BootScriptExecutePciCfgWrite (Script);
+ break;
- case EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE:
- DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE\n"));
- CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);
- Status = BootScriptExecutePciCfgReadWrite (
- Script,
- AndMask,
- OrMask
- );
- break;
- case EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE:
- DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE\n"));
- Status = BootScriptExecutePciCfg2Write (Script);
- break;
+ case EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE:
+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE\n"));
+ CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);
+ Status = BootScriptExecutePciCfgReadWrite (
+ Script,
+ AndMask,
+ OrMask
+ );
+ break;
+ case EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE:
+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE\n"));
+ Status = BootScriptExecutePciCfg2Write (Script);
+ break;
- case EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE:
- DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE\n"));
- CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);
- Status = BootScriptExecutePciCfg2ReadWrite (
- Script,
- AndMask,
- OrMask
- );
- break;
- case EFI_BOOT_SCRIPT_DISPATCH_OPCODE:
- DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_DISPATCH_OPCODE\n"));
- Status = BootScriptExecuteDispatch (Script);
- break;
+ case EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE:
+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE\n"));
+ CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);
+ Status = BootScriptExecutePciCfg2ReadWrite (
+ Script,
+ AndMask,
+ OrMask
+ );
+ break;
+ case EFI_BOOT_SCRIPT_DISPATCH_OPCODE:
+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_DISPATCH_OPCODE\n"));
+ Status = BootScriptExecuteDispatch (Script);
+ break;
- case EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE:
- DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE\n"));
- Status = BootScriptExecuteDispatch2 (Script);
- break;
+ case EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE:
+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE\n"));
+ Status = BootScriptExecuteDispatch2 (Script);
+ break;
- case EFI_BOOT_SCRIPT_INFORMATION_OPCODE:
- DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_INFORMATION_OPCODE\n"));
- BootScriptExecuteInformation (Script);
- break;
+ case EFI_BOOT_SCRIPT_INFORMATION_OPCODE:
+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_INFORMATION_OPCODE\n"));
+ BootScriptExecuteInformation (Script);
+ break;
- case S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE:
- DEBUG ((DEBUG_INFO, "S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE\n"));
- DEBUG ((DEBUG_INFO, "S3BootScriptDone - %r\n", EFI_SUCCESS));
- return EFI_SUCCESS;
+ case S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE:
+ DEBUG ((DEBUG_INFO, "S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE\n"));
+ DEBUG ((DEBUG_INFO, "S3BootScriptDone - %r\n", EFI_SUCCESS));
+ return EFI_SUCCESS;
+
+ case EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE:
+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE\n"));
+ CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);
+ Status = BootScriptExecuteIoReadWrite (
+ Script,
+ AndMask,
+ OrMask
+ );
+ break;
- case EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE:
- DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE\n"));
- CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);
- Status = BootScriptExecuteIoReadWrite (
- Script,
- AndMask,
- OrMask
- );
- break;
+ case EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE:
+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE\n"));
+ Status = BootScriptExecuteSmbusExecute (Script);
+ break;
- case EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE:
- DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE\n"));
- Status = BootScriptExecuteSmbusExecute (Script);
- break;
+ case EFI_BOOT_SCRIPT_STALL_OPCODE:
+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_STALL_OPCODE\n"));
+ Status = BootScriptExecuteStall (Script);
+ break;
- case EFI_BOOT_SCRIPT_STALL_OPCODE:
- DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_STALL_OPCODE\n"));
- Status = BootScriptExecuteStall (Script);
- break;
+ case EFI_BOOT_SCRIPT_MEM_POLL_OPCODE:
+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_MEM_POLL_OPCODE\n"));
+ CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);
+ Status = BootScriptExecuteMemPoll (Script, AndMask, OrMask);
- case EFI_BOOT_SCRIPT_MEM_POLL_OPCODE:
- DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_MEM_POLL_OPCODE\n"));
- CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);
- Status = BootScriptExecuteMemPoll (Script, AndMask, OrMask);
+ break;
- break;
+ case EFI_BOOT_SCRIPT_IO_POLL_OPCODE:
+ DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_IO_POLL_OPCODE\n"));
+ CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);
+ Status = BootScriptExecuteIoPoll (Script, AndMask, OrMask);
+ break;
- case EFI_BOOT_SCRIPT_IO_POLL_OPCODE:
- DEBUG ((DEBUG_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 ((DEBUG_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_CONFIG_POLL_OPCODE:
- DEBUG ((DEBUG_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 ((DEBUG_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE\n"));
+ CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);
+ Status = BootScriptPciCfg2Poll (Script, AndMask, OrMask);
+ break;
- case EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE:
- DEBUG ((DEBUG_INFO, "EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE\n"));
- CheckAndOrMask (&ScriptHeader, &AndMask, &OrMask, Script);
- Status = BootScriptPciCfg2Poll (Script, AndMask, OrMask);
- break;
-
- case S3_BOOT_SCRIPT_LIB_LABEL_OPCODE:
- //
- // For label
- //
- DEBUG ((DEBUG_INFO, "S3_BOOT_SCRIPT_LIB_LABEL_OPCODE\n"));
- BootScriptExecuteLabel (Script);
- break;
- default:
- DEBUG ((DEBUG_INFO, "S3BootScriptDone - %r\n", EFI_UNSUPPORTED));
- return EFI_UNSUPPORTED;
+ case S3_BOOT_SCRIPT_LIB_LABEL_OPCODE:
+ //
+ // For label
+ //
+ DEBUG ((DEBUG_INFO, "S3_BOOT_SCRIPT_LIB_LABEL_OPCODE\n"));
+ BootScriptExecuteLabel (Script);
+ break;
+ default:
+ DEBUG ((DEBUG_INFO, "S3BootScriptDone - %r\n", EFI_UNSUPPORTED));
+ return EFI_UNSUPPORTED;
}
if (EFI_ERROR (Status)) {
@@ -1766,7 +1796,7 @@ S3BootScriptExecute (
return Status;
}
- Script = Script + ScriptHeader.Length;
+ Script = Script + ScriptHeader.Length;
}
DEBUG ((DEBUG_INFO, "S3BootScriptDone - %r\n", Status));
diff --git a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptInternalFormat.h b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptInternalFormat.h
index 85bc8af39b..cf49368303 100644
--- a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptInternalFormat.h
+++ b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptInternalFormat.h
@@ -18,164 +18,163 @@
//
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
+ UINT16 OpCode;
+ UINT8 Length;
} EFI_BOOT_SCRIPT_GENERIC_HEADER;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- UINT16 Version;
- UINT32 TableLength;
- UINT16 Reserved[2];
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT16 Version;
+ UINT32 TableLength;
+ UINT16 Reserved[2];
} EFI_BOOT_SCRIPT_TABLE_HEADER;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- UINT32 Width;
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 Width;
} EFI_BOOT_SCRIPT_COMMON_HEADER;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- UINT32 Width;
- UINT32 Count;
- UINT64 Address;
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 Width;
+ UINT32 Count;
+ UINT64 Address;
} EFI_BOOT_SCRIPT_IO_WRITE;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- UINT32 Width;
- UINT64 Address;
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 Width;
+ UINT64 Address;
} EFI_BOOT_SCRIPT_IO_READ_WRITE;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- UINT32 Width;
- UINT32 Count;
- UINT64 Address;
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 Width;
+ UINT32 Count;
+ UINT64 Address;
} EFI_BOOT_SCRIPT_MEM_WRITE;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- UINT32 Width;
- UINT64 Address;
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 Width;
+ UINT64 Address;
} EFI_BOOT_SCRIPT_MEM_READ_WRITE;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- UINT32 Width;
- UINT32 Count;
- UINT64 Address;
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 Width;
+ UINT32 Count;
+ UINT64 Address;
} EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- UINT32 Width;
- UINT32 Count;
- UINT64 Address;
- UINT16 Segment;
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 Width;
+ UINT32 Count;
+ UINT64 Address;
+ UINT16 Segment;
} EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- UINT32 Width;
- UINT64 Address;
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 Width;
+ UINT64 Address;
} EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- UINT32 Width;
- UINT64 Address;
- UINT16 Segment;
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 Width;
+ UINT64 Address;
+ UINT16 Segment;
} EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- UINT64 SmBusAddress;
- UINT32 Operation;
- UINT32 DataSize;
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT64 SmBusAddress;
+ UINT32 Operation;
+ UINT32 DataSize;
} EFI_BOOT_SCRIPT_SMBUS_EXECUTE;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- UINT64 Duration;
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT64 Duration;
} EFI_BOOT_SCRIPT_STALL;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- EFI_PHYSICAL_ADDRESS EntryPoint;
+ UINT16 OpCode;
+ UINT8 Length;
+ EFI_PHYSICAL_ADDRESS EntryPoint;
} EFI_BOOT_SCRIPT_DISPATCH;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- EFI_PHYSICAL_ADDRESS EntryPoint;
- EFI_PHYSICAL_ADDRESS Context;
+ UINT16 OpCode;
+ UINT8 Length;
+ EFI_PHYSICAL_ADDRESS EntryPoint;
+ EFI_PHYSICAL_ADDRESS Context;
} EFI_BOOT_SCRIPT_DISPATCH_2;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- UINT32 Width;
- UINT64 Address;
- UINT64 Duration;
- UINT64 LoopTimes;
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 Width;
+ UINT64 Address;
+ UINT64 Duration;
+ UINT64 LoopTimes;
} EFI_BOOT_SCRIPT_MEM_POLL;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- UINT32 InformationLength;
-// UINT8 InformationData[InformationLength];
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 InformationLength;
+ // UINT8 InformationData[InformationLength];
} EFI_BOOT_SCRIPT_INFORMATION;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- UINT32 Width;
- UINT64 Address;
- UINT64 Delay;
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 Width;
+ UINT64 Address;
+ UINT64 Delay;
} EFI_BOOT_SCRIPT_IO_POLL;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- UINT32 Width;
- UINT64 Address;
- UINT64 Delay;
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 Width;
+ UINT64 Address;
+ UINT64 Delay;
} EFI_BOOT_SCRIPT_PCI_CONFIG_POLL;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
- UINT32 Width;
- UINT64 Address;
- UINT16 Segment;
- UINT64 Delay;
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 Width;
+ UINT64 Address;
+ UINT16 Segment;
+ UINT64 Delay;
} EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL;
typedef struct {
- UINT16 OpCode;
- UINT8 Length;
+ UINT16 OpCode;
+ UINT8 Length;
} EFI_BOOT_SCRIPT_TERMINATE;
-
#pragma pack()
-#define BOOT_SCRIPT_NODE_MAX_LENGTH 1024
+#define BOOT_SCRIPT_NODE_MAX_LENGTH 1024
-#define BOOT_SCRIPT_TABLE_VERSION 0x0001
+#define BOOT_SCRIPT_TABLE_VERSION 0x0001
#endif
diff --git a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
index 20378502c8..f8d4983d81 100644
--- a/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
+++ b/MdeModulePkg/Library/PiDxeS3BootScriptLib/BootScriptSave.c
@@ -94,37 +94,37 @@
**/
-SCRIPT_TABLE_PRIVATE_DATA *mS3BootScriptTablePtr;
+SCRIPT_TABLE_PRIVATE_DATA *mS3BootScriptTablePtr;
//
// Allocate SMM copy because we can not use mS3BootScriptTablePtr after SmmReadyToLock in InSmm.
//
-SCRIPT_TABLE_PRIVATE_DATA *mS3BootScriptTableSmmPtr;
+SCRIPT_TABLE_PRIVATE_DATA *mS3BootScriptTableSmmPtr;
-EFI_GUID mBootScriptDataGuid = {
+EFI_GUID mBootScriptDataGuid = {
0xaea6b965, 0xdcf5, 0x4311, { 0xb4, 0xb8, 0xf, 0x12, 0x46, 0x44, 0x94, 0xd2 }
};
-EFI_GUID mBootScriptDataBootTimeGuid = {
+EFI_GUID mBootScriptDataBootTimeGuid = {
0xb5af1d7a, 0xb8cf, 0x4eb3, { 0x89, 0x25, 0xa8, 0x20, 0xe1, 0x6b, 0x68, 0x7d }
};
-EFI_GUID mBootScriptTableBaseGuid = {
+EFI_GUID mBootScriptTableBaseGuid = {
0x1810ab4a, 0x2314, 0x4df6, { 0x81, 0xeb, 0x67, 0xc6, 0xec, 0x5, 0x85, 0x91 }
};
-EFI_GUID mBootScriptSmmPrivateDataGuid = {
+EFI_GUID mBootScriptSmmPrivateDataGuid = {
0x627ee2da, 0x3bf9, 0x439b, { 0x92, 0x9f, 0x2e, 0xe, 0x6e, 0x9d, 0xba, 0x62 }
};
-EFI_EVENT mEventDxeSmmReadyToLock = NULL;
-VOID *mRegistrationSmmExitBootServices = NULL;
-VOID *mRegistrationSmmLegacyBoot = NULL;
-VOID *mRegistrationSmmReadyToLock = NULL;
-BOOLEAN mS3BootScriptTableAllocated = FALSE;
-BOOLEAN mS3BootScriptTableSmmAllocated = FALSE;
-EFI_SMM_SYSTEM_TABLE2 *mBootScriptSmst = NULL;
-BOOLEAN mS3BootScriptAcpiS3Enable = TRUE;
+EFI_EVENT mEventDxeSmmReadyToLock = NULL;
+VOID *mRegistrationSmmExitBootServices = NULL;
+VOID *mRegistrationSmmLegacyBoot = NULL;
+VOID *mRegistrationSmmReadyToLock = NULL;
+BOOLEAN mS3BootScriptTableAllocated = FALSE;
+BOOLEAN mS3BootScriptTableSmmAllocated = FALSE;
+EFI_SMM_SYSTEM_TABLE2 *mBootScriptSmst = NULL;
+BOOLEAN mS3BootScriptAcpiS3Enable = TRUE;
/**
This is an internal function to add a terminate node the entry, recalculate the table
@@ -132,14 +132,15 @@ BOOLEAN mS3BootScriptAcpiS3Enable = TRUE;
@return the base address of the boot script table.
**/
-UINT8*
+UINT8 *
S3BootScriptInternalCloseTable (
VOID
)
{
- UINT8 *S3TableBase;
- EFI_BOOT_SCRIPT_TERMINATE ScriptTerminate;
- EFI_BOOT_SCRIPT_TABLE_HEADER *ScriptTableInfo;
+ UINT8 *S3TableBase;
+ EFI_BOOT_SCRIPT_TERMINATE ScriptTerminate;
+ EFI_BOOT_SCRIPT_TABLE_HEADER *ScriptTableInfo;
+
S3TableBase = mS3BootScriptTablePtr->TableBase;
if (S3TableBase == NULL) {
@@ -148,20 +149,19 @@ S3BootScriptInternalCloseTable (
//
return S3TableBase;
}
+
//
// Append the termination entry.
//
- ScriptTerminate.OpCode = S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE;
- ScriptTerminate.Length = (UINT8) sizeof (EFI_BOOT_SCRIPT_TERMINATE);
+ ScriptTerminate.OpCode = S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE;
+ ScriptTerminate.Length = (UINT8)sizeof (EFI_BOOT_SCRIPT_TERMINATE);
CopyMem (mS3BootScriptTablePtr->TableBase + mS3BootScriptTablePtr->TableLength, &ScriptTerminate, sizeof (EFI_BOOT_SCRIPT_TERMINATE));
//
// fill the table length
//
- ScriptTableInfo = (EFI_BOOT_SCRIPT_TABLE_HEADER*)(mS3BootScriptTablePtr->TableBase);
+ ScriptTableInfo = (EFI_BOOT_SCRIPT_TABLE_HEADER *)(mS3BootScriptTablePtr->TableBase);
ScriptTableInfo->TableLength = mS3BootScriptTablePtr->TableLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE);
-
-
return S3TableBase;
//
// NOTE: Here we did NOT adjust the mS3BootScriptTablePtr->TableLength to
@@ -180,7 +180,7 @@ SaveBootScriptDataToLockBox (
VOID
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Save whole memory copy into LockBox.
@@ -203,7 +203,7 @@ SaveBootScriptDataToLockBox (
Status = SaveLockBox (
&mBootScriptTableBaseGuid,
(VOID *)&mS3BootScriptTablePtr->TableBase,
- sizeof(mS3BootScriptTablePtr->TableBase)
+ sizeof (mS3BootScriptTablePtr->TableBase)
);
ASSERT_EFI_ERROR (Status);
@@ -225,8 +225,8 @@ S3BootScriptEventCallBack (
IN VOID *Context
)
{
- EFI_STATUS Status;
- VOID *Interface;
+ EFI_STATUS Status;
+ VOID *Interface;
//
// Try to locate it because EfiCreateProtocolNotifyEvent will trigger it once when registration.
@@ -238,7 +238,7 @@ S3BootScriptEventCallBack (
&Interface
);
if (EFI_ERROR (Status)) {
- return ;
+ return;
}
//
@@ -295,7 +295,7 @@ S3BootScriptSmmEventCallBack (
// Save a SMM copy. If TableBase is NOT null, it means SMM copy has been ready, skip copy mem.
//
if (mS3BootScriptTableSmmPtr->TableBase == NULL) {
- CopyMem (mS3BootScriptTableSmmPtr, mS3BootScriptTablePtr, sizeof(*mS3BootScriptTablePtr));
+ CopyMem (mS3BootScriptTableSmmPtr, mS3BootScriptTablePtr, sizeof (*mS3BootScriptTablePtr));
//
// Set InSmm, we allow boot script update when InSmm, but not allow boot script outside SMM.
@@ -303,6 +303,7 @@ S3BootScriptSmmEventCallBack (
//
mS3BootScriptTableSmmPtr->InSmm = TRUE;
}
+
//
// We should not use ACPI Reserved copy, because it is not safe.
//
@@ -325,7 +326,7 @@ SaveBootTimeDataToLockBox (
VOID
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// ACPI Reserved copy is not safe, restore from BootScriptData LockBox first,
@@ -344,7 +345,7 @@ SaveBootTimeDataToLockBox (
//
Status = SaveLockBox (
&mBootScriptDataBootTimeGuid,
- (VOID *) mS3BootScriptTablePtr->TableBase,
+ (VOID *)mS3BootScriptTablePtr->TableBase,
mS3BootScriptTablePtr->BootTimeScriptLength
);
ASSERT_EFI_ERROR (Status);
@@ -360,17 +361,17 @@ SaveSmmPriviateDataToLockBoxAtRuntime (
VOID
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
//
// Save boot script SMM private data with BackFromS3 = TRUE.
//
mS3BootScriptTablePtr->BackFromS3 = TRUE;
- Status = SaveLockBox (
- &mBootScriptSmmPrivateDataGuid,
- (VOID *) mS3BootScriptTablePtr,
- sizeof (SCRIPT_TABLE_PRIVATE_DATA)
- );
+ Status = SaveLockBox (
+ &mBootScriptSmmPrivateDataGuid,
+ (VOID *)mS3BootScriptTablePtr,
+ sizeof (SCRIPT_TABLE_PRIVATE_DATA)
+ );
ASSERT_EFI_ERROR (Status);
Status = SetLockBoxAttributes (&mBootScriptSmmPrivateDataGuid, LOCK_BOX_ATTRIBUTE_RESTORE_IN_PLACE);
@@ -395,13 +396,13 @@ SaveSmmPriviateDataToLockBoxAtRuntime (
EFI_STATUS
EFIAPI
S3BootScriptSmmAtRuntimeCallBack (
- IN CONST EFI_GUID *Protocol,
- IN VOID *Interface,
- IN EFI_HANDLE Handle
+ IN CONST EFI_GUID *Protocol,
+ IN VOID *Interface,
+ IN EFI_HANDLE Handle
)
{
if (!mS3BootScriptTablePtr->AtRuntime) {
- mS3BootScriptTablePtr->BootTimeScriptLength = (UINT32) (mS3BootScriptTablePtr->TableLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE));
+ mS3BootScriptTablePtr->BootTimeScriptLength = (UINT32)(mS3BootScriptTablePtr->TableLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE));
SaveBootTimeDataToLockBox ();
mS3BootScriptTablePtr->AtRuntime = TRUE;
@@ -425,17 +426,17 @@ S3BootScriptSmmAtRuntimeCallBack (
RETURN_STATUS
EFIAPI
S3BootScriptLibInitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
- SCRIPT_TABLE_PRIVATE_DATA *S3TablePtr;
- SCRIPT_TABLE_PRIVATE_DATA *S3TableSmmPtr;
- VOID *Registration;
- EFI_SMM_BASE2_PROTOCOL *SmmBase2;
- BOOLEAN InSmm;
- EFI_PHYSICAL_ADDRESS Buffer;
+ EFI_STATUS Status;
+ SCRIPT_TABLE_PRIVATE_DATA *S3TablePtr;
+ SCRIPT_TABLE_PRIVATE_DATA *S3TableSmmPtr;
+ VOID *Registration;
+ EFI_SMM_BASE2_PROTOCOL *SmmBase2;
+ BOOLEAN InSmm;
+ EFI_PHYSICAL_ADDRESS Buffer;
if (!PcdGetBool (PcdAcpiS3Enable)) {
mS3BootScriptAcpiS3Enable = FALSE;
@@ -443,7 +444,7 @@ S3BootScriptLibInitialize (
return RETURN_SUCCESS;
}
- S3TablePtr = (SCRIPT_TABLE_PRIVATE_DATA*)(UINTN)PcdGet64(PcdS3BootScriptTablePrivateDataPtr);
+ S3TablePtr = (SCRIPT_TABLE_PRIVATE_DATA *)(UINTN)PcdGet64 (PcdS3BootScriptTablePrivateDataPtr);
//
// The Boot script private data is not be initialized. create it
//
@@ -452,16 +453,16 @@ S3BootScriptLibInitialize (
Status = gBS->AllocatePages (
AllocateMaxAddress,
EfiReservedMemoryType,
- EFI_SIZE_TO_PAGES(sizeof(SCRIPT_TABLE_PRIVATE_DATA)),
+ EFI_SIZE_TO_PAGES (sizeof (SCRIPT_TABLE_PRIVATE_DATA)),
&Buffer
);
ASSERT_EFI_ERROR (Status);
mS3BootScriptTableAllocated = TRUE;
- S3TablePtr = (VOID *) (UINTN) Buffer;
+ S3TablePtr = (VOID *)(UINTN)Buffer;
- Status = PcdSet64S (PcdS3BootScriptTablePrivateDataPtr, (UINT64) (UINTN)S3TablePtr);
+ Status = PcdSet64S (PcdS3BootScriptTablePrivateDataPtr, (UINT64)(UINTN)S3TablePtr);
ASSERT_EFI_ERROR (Status);
- ZeroMem (S3TablePtr, sizeof(SCRIPT_TABLE_PRIVATE_DATA));
+ ZeroMem (S3TablePtr, sizeof (SCRIPT_TABLE_PRIVATE_DATA));
//
// Create event to notify the library system enter the SmmLocked phase.
//
@@ -474,22 +475,26 @@ S3BootScriptLibInitialize (
);
ASSERT (mEventDxeSmmReadyToLock != NULL);
}
+
mS3BootScriptTablePtr = S3TablePtr;
//
// Get InSmm, we need to register SmmReadyToLock if this library is linked to SMM driver.
//
- Status = gBS->LocateProtocol (&gEfiSmmBase2ProtocolGuid, NULL, (VOID**) &SmmBase2);
+ Status = gBS->LocateProtocol (&gEfiSmmBase2ProtocolGuid, NULL, (VOID **)&SmmBase2);
if (EFI_ERROR (Status)) {
return RETURN_SUCCESS;
}
+
Status = SmmBase2->InSmm (SmmBase2, &InSmm);
if (EFI_ERROR (Status)) {
return RETURN_SUCCESS;
}
+
if (!InSmm) {
return RETURN_SUCCESS;
}
+
//
// Good, we are in SMM
//
@@ -498,22 +503,22 @@ S3BootScriptLibInitialize (
return RETURN_SUCCESS;
}
- S3TableSmmPtr = (SCRIPT_TABLE_PRIVATE_DATA*)(UINTN)PcdGet64(PcdS3BootScriptTablePrivateSmmDataPtr);
+ S3TableSmmPtr = (SCRIPT_TABLE_PRIVATE_DATA *)(UINTN)PcdGet64 (PcdS3BootScriptTablePrivateSmmDataPtr);
//
// The Boot script private data in SMM is not be initialized. create it
//
if (S3TableSmmPtr == 0) {
Status = mBootScriptSmst->SmmAllocatePool (
EfiRuntimeServicesData,
- sizeof(SCRIPT_TABLE_PRIVATE_DATA),
- (VOID **) &S3TableSmmPtr
+ sizeof (SCRIPT_TABLE_PRIVATE_DATA),
+ (VOID **)&S3TableSmmPtr
);
ASSERT_EFI_ERROR (Status);
mS3BootScriptTableSmmAllocated = TRUE;
- Status = PcdSet64S (PcdS3BootScriptTablePrivateSmmDataPtr, (UINT64) (UINTN)S3TableSmmPtr);
+ Status = PcdSet64S (PcdS3BootScriptTablePrivateSmmDataPtr, (UINT64)(UINTN)S3TableSmmPtr);
ASSERT_EFI_ERROR (Status);
- ZeroMem (S3TableSmmPtr, sizeof(SCRIPT_TABLE_PRIVATE_DATA));
+ ZeroMem (S3TableSmmPtr, sizeof (SCRIPT_TABLE_PRIVATE_DATA));
//
// Register SmmExitBootServices and SmmLegacyBoot notification.
@@ -532,6 +537,7 @@ S3BootScriptLibInitialize (
);
ASSERT_EFI_ERROR (Status);
}
+
mS3BootScriptTableSmmPtr = S3TableSmmPtr;
//
@@ -563,11 +569,11 @@ S3BootScriptLibInitialize (
RETURN_STATUS
EFIAPI
S3BootScriptLibDeinitialize (
- IN EFI_HANDLE ImageHandle,
- IN EFI_SYSTEM_TABLE *SystemTable
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
if (!mS3BootScriptAcpiS3Enable) {
return RETURN_SUCCESS;
@@ -595,6 +601,7 @@ S3BootScriptLibDeinitialize (
);
ASSERT_EFI_ERROR (Status);
}
+
if (mRegistrationSmmLegacyBoot != NULL) {
//
// Unregister SmmLegacyBoot notification.
@@ -606,6 +613,7 @@ S3BootScriptLibDeinitialize (
);
ASSERT_EFI_ERROR (Status);
}
+
if (mRegistrationSmmReadyToLock != NULL) {
//
// Unregister SmmReadyToLock notification.
@@ -623,11 +631,12 @@ S3BootScriptLibDeinitialize (
// Free the resources allocated and set PCDs to 0.
//
if (mS3BootScriptTableAllocated) {
- Status = gBS->FreePages ((EFI_PHYSICAL_ADDRESS) (UINTN) mS3BootScriptTablePtr, EFI_SIZE_TO_PAGES(sizeof(SCRIPT_TABLE_PRIVATE_DATA)));
+ Status = gBS->FreePages ((EFI_PHYSICAL_ADDRESS)(UINTN)mS3BootScriptTablePtr, EFI_SIZE_TO_PAGES (sizeof (SCRIPT_TABLE_PRIVATE_DATA)));
ASSERT_EFI_ERROR (Status);
Status = PcdSet64S (PcdS3BootScriptTablePrivateDataPtr, 0);
ASSERT_EFI_ERROR (Status);
}
+
if ((mBootScriptSmst != NULL) && mS3BootScriptTableSmmAllocated) {
Status = mBootScriptSmst->SmmFreePool (mS3BootScriptTableSmmPtr);
ASSERT_EFI_ERROR (Status);
@@ -648,95 +657,98 @@ S3BootScriptLibDeinitialize (
@retval the address from which the a new s3 boot script entry will write into
**/
-UINT8*
+UINT8 *
S3BootScriptGetBootTimeEntryAddAddress (
UINT8 EntryLength
)
{
- EFI_PHYSICAL_ADDRESS S3TableBase;
- EFI_PHYSICAL_ADDRESS NewS3TableBase;
- UINT8 *NewEntryPtr;
- UINT32 TableLength;
- UINT16 PageNumber;
- EFI_STATUS Status;
- EFI_BOOT_SCRIPT_TABLE_HEADER *ScriptTableInfo;
-
- S3TableBase = (EFI_PHYSICAL_ADDRESS)(UINTN)(mS3BootScriptTablePtr->TableBase);
- if (S3TableBase == 0) {
- //
- // The table is not exist. This is the first to add entry.
- // Allocate ACPI script table space under 4G memory.
- //
- S3TableBase = 0xffffffff;
- Status = gBS->AllocatePages (
- AllocateMaxAddress,
- EfiReservedMemoryType,
- 2 + PcdGet16(PcdS3BootScriptRuntimeTableReservePageNumber),
- (EFI_PHYSICAL_ADDRESS*)&S3TableBase
- );
+ EFI_PHYSICAL_ADDRESS S3TableBase;
+ EFI_PHYSICAL_ADDRESS NewS3TableBase;
+ UINT8 *NewEntryPtr;
+ UINT32 TableLength;
+ UINT16 PageNumber;
+ EFI_STATUS Status;
+ EFI_BOOT_SCRIPT_TABLE_HEADER *ScriptTableInfo;
+
+ S3TableBase = (EFI_PHYSICAL_ADDRESS)(UINTN)(mS3BootScriptTablePtr->TableBase);
+ if (S3TableBase == 0) {
+ //
+ // The table is not exist. This is the first to add entry.
+ // Allocate ACPI script table space under 4G memory.
+ //
+ S3TableBase = 0xffffffff;
+ Status = gBS->AllocatePages (
+ AllocateMaxAddress,
+ EfiReservedMemoryType,
+ 2 + PcdGet16 (PcdS3BootScriptRuntimeTableReservePageNumber),
+ (EFI_PHYSICAL_ADDRESS *)&S3TableBase
+ );
+
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return 0;
+ }
- if (EFI_ERROR(Status)) {
- ASSERT_EFI_ERROR (Status);
- return 0;
- }
- //
- // Fill Table Header
- //
- ScriptTableInfo = (EFI_BOOT_SCRIPT_TABLE_HEADER*)(UINTN)S3TableBase;
- ScriptTableInfo->OpCode = S3_BOOT_SCRIPT_LIB_TABLE_OPCODE;
- ScriptTableInfo->Length = (UINT8) sizeof (EFI_BOOT_SCRIPT_TABLE_HEADER);
- ScriptTableInfo->Version = BOOT_SCRIPT_TABLE_VERSION;
- ScriptTableInfo->TableLength = 0; // will be calculate at CloseTable
- mS3BootScriptTablePtr->TableLength = sizeof (EFI_BOOT_SCRIPT_TABLE_HEADER);
- mS3BootScriptTablePtr->TableBase = (UINT8*)(UINTN)S3TableBase;
- mS3BootScriptTablePtr->TableMemoryPageNumber = (UINT16)(2 + PcdGet16(PcdS3BootScriptRuntimeTableReservePageNumber));
- }
-
- // Here we do not count the reserved memory for runtime script table.
- PageNumber = (UINT16) (mS3BootScriptTablePtr->TableMemoryPageNumber - PcdGet16(PcdS3BootScriptRuntimeTableReservePageNumber));
- TableLength = mS3BootScriptTablePtr->TableLength;
- if (EFI_PAGES_TO_SIZE ((UINTN) PageNumber) < (TableLength + EntryLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE))) {
- //
- // The buffer is too small to hold the table, Reallocate the buffer
- //
- NewS3TableBase = 0xffffffff;
- Status = gBS->AllocatePages (
- AllocateMaxAddress,
- EfiReservedMemoryType,
- 2 + PageNumber + PcdGet16(PcdS3BootScriptRuntimeTableReservePageNumber),
- (EFI_PHYSICAL_ADDRESS*)&NewS3TableBase
- );
+ //
+ // Fill Table Header
+ //
+ ScriptTableInfo = (EFI_BOOT_SCRIPT_TABLE_HEADER *)(UINTN)S3TableBase;
+ ScriptTableInfo->OpCode = S3_BOOT_SCRIPT_LIB_TABLE_OPCODE;
+ ScriptTableInfo->Length = (UINT8)sizeof (EFI_BOOT_SCRIPT_TABLE_HEADER);
+ ScriptTableInfo->Version = BOOT_SCRIPT_TABLE_VERSION;
+ ScriptTableInfo->TableLength = 0; // will be calculate at CloseTable
+ mS3BootScriptTablePtr->TableLength = sizeof (EFI_BOOT_SCRIPT_TABLE_HEADER);
+ mS3BootScriptTablePtr->TableBase = (UINT8 *)(UINTN)S3TableBase;
+ mS3BootScriptTablePtr->TableMemoryPageNumber = (UINT16)(2 + PcdGet16 (PcdS3BootScriptRuntimeTableReservePageNumber));
+ }
+
+ // Here we do not count the reserved memory for runtime script table.
+ PageNumber = (UINT16)(mS3BootScriptTablePtr->TableMemoryPageNumber - PcdGet16 (PcdS3BootScriptRuntimeTableReservePageNumber));
+ TableLength = mS3BootScriptTablePtr->TableLength;
+ if (EFI_PAGES_TO_SIZE ((UINTN)PageNumber) < (TableLength + EntryLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE))) {
+ //
+ // The buffer is too small to hold the table, Reallocate the buffer
+ //
+ NewS3TableBase = 0xffffffff;
+ Status = gBS->AllocatePages (
+ AllocateMaxAddress,
+ EfiReservedMemoryType,
+ 2 + PageNumber + PcdGet16 (PcdS3BootScriptRuntimeTableReservePageNumber),
+ (EFI_PHYSICAL_ADDRESS *)&NewS3TableBase
+ );
+
+ if (EFI_ERROR (Status)) {
+ ASSERT_EFI_ERROR (Status);
+ return 0;
+ }
+
+ CopyMem ((VOID *)(UINTN)NewS3TableBase, (VOID *)(UINTN)S3TableBase, TableLength);
+ gBS->FreePages (S3TableBase, mS3BootScriptTablePtr->TableMemoryPageNumber);
+
+ mS3BootScriptTablePtr->TableBase = (UINT8 *)(UINTN)NewS3TableBase;
+ mS3BootScriptTablePtr->TableMemoryPageNumber = (UINT16)(2 + PageNumber + PcdGet16 (PcdS3BootScriptRuntimeTableReservePageNumber));
+ }
+
+ //
+ // calculate the the start address for the new entry.
+ //
+ NewEntryPtr = mS3BootScriptTablePtr->TableBase + TableLength;
+
+ //
+ // update the table lenghth
+ //
+ mS3BootScriptTablePtr->TableLength = TableLength + EntryLength;
- if (EFI_ERROR(Status)) {
- ASSERT_EFI_ERROR (Status);
- return 0;
- }
-
- CopyMem ((VOID*)(UINTN)NewS3TableBase, (VOID*)(UINTN)S3TableBase, TableLength);
- gBS->FreePages (S3TableBase, mS3BootScriptTablePtr->TableMemoryPageNumber);
-
- mS3BootScriptTablePtr->TableBase = (UINT8*)(UINTN)NewS3TableBase;
- mS3BootScriptTablePtr->TableMemoryPageNumber = (UINT16) (2 + PageNumber + PcdGet16(PcdS3BootScriptRuntimeTableReservePageNumber));
- }
- //
- // calculate the the start address for the new entry.
- //
- NewEntryPtr = mS3BootScriptTablePtr->TableBase + TableLength;
-
- //
- // update the table lenghth
- //
- mS3BootScriptTablePtr->TableLength = TableLength + EntryLength;
-
- //
- // In the boot time, we will not append the termination entry to the boot script
- // table until the callers think there is no boot time data that should be added and
- // it is caller's responsibility to explicit call the CloseTable.
- //
- //
-
- return NewEntryPtr;
+ //
+ // In the boot time, we will not append the termination entry to the boot script
+ // table until the callers think there is no boot time data that should be added and
+ // it is caller's responsibility to explicit call the CloseTable.
+ //
+ //
+
+ return NewEntryPtr;
}
+
/**
To get the start address from which a new runtime(after SmmReadyToLock) s3 boot script entry will write into.
In this case, it should be ensured that there is enough buffer to hold the entry.
@@ -745,26 +757,27 @@ S3BootScriptGetBootTimeEntryAddAddress (
@retval the address from which the a new s3 runtime(after SmmReadyToLock) script entry will write into
**/
-UINT8*
+UINT8 *
S3BootScriptGetRuntimeEntryAddAddress (
UINT8 EntryLength
)
{
- UINT8 *NewEntryPtr;
-
- NewEntryPtr = NULL;
- //
- // Check if the memory range reserved for S3 Boot Script table is large enough to hold the node.
- //
- if ((mS3BootScriptTablePtr->TableLength + EntryLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE)) <= EFI_PAGES_TO_SIZE ((UINTN) (mS3BootScriptTablePtr->TableMemoryPageNumber))) {
- NewEntryPtr = mS3BootScriptTablePtr->TableBase + mS3BootScriptTablePtr->TableLength;
- mS3BootScriptTablePtr->TableLength = mS3BootScriptTablePtr->TableLength + EntryLength;
- //
- // Append a terminate node on every insert
- //
- S3BootScriptInternalCloseTable ();
- }
- return (UINT8*)NewEntryPtr;
+ UINT8 *NewEntryPtr;
+
+ NewEntryPtr = NULL;
+ //
+ // Check if the memory range reserved for S3 Boot Script table is large enough to hold the node.
+ //
+ if ((mS3BootScriptTablePtr->TableLength + EntryLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE)) <= EFI_PAGES_TO_SIZE ((UINTN)(mS3BootScriptTablePtr->TableMemoryPageNumber))) {
+ NewEntryPtr = mS3BootScriptTablePtr->TableBase + mS3BootScriptTablePtr->TableLength;
+ mS3BootScriptTablePtr->TableLength = mS3BootScriptTablePtr->TableLength + EntryLength;
+ //
+ // Append a terminate node on every insert
+ //
+ S3BootScriptInternalCloseTable ();
+ }
+
+ return (UINT8 *)NewEntryPtr;
}
/**
@@ -776,18 +789,18 @@ RestoreBootTimeDataFromLockBox (
VOID
)
{
- EFI_STATUS Status;
- UINTN LockBoxLength;
+ EFI_STATUS Status;
+ UINTN LockBoxLength;
//
// Restore boot time boot script data from LockBox.
//
LockBoxLength = mS3BootScriptTablePtr->BootTimeScriptLength;
- Status = RestoreLockBox (
- &mBootScriptDataBootTimeGuid,
- (VOID *) mS3BootScriptTablePtr->TableBase,
- &LockBoxLength
- );
+ Status = RestoreLockBox (
+ &mBootScriptDataBootTimeGuid,
+ (VOID *)mS3BootScriptTablePtr->TableBase,
+ &LockBoxLength
+ );
ASSERT_EFI_ERROR (Status);
//
@@ -796,7 +809,7 @@ RestoreBootTimeDataFromLockBox (
Status = UpdateLockBox (
&mBootScriptDataGuid,
0,
- (VOID *) mS3BootScriptTablePtr->TableBase,
+ (VOID *)mS3BootScriptTablePtr->TableBase,
LockBoxLength
);
ASSERT_EFI_ERROR (Status);
@@ -804,7 +817,7 @@ RestoreBootTimeDataFromLockBox (
//
// Update TableLength.
//
- mS3BootScriptTablePtr->TableLength = (UINT32) (mS3BootScriptTablePtr->BootTimeScriptLength - sizeof (EFI_BOOT_SCRIPT_TERMINATE));
+ mS3BootScriptTablePtr->TableLength = (UINT32)(mS3BootScriptTablePtr->BootTimeScriptLength - sizeof (EFI_BOOT_SCRIPT_TERMINATE));
}
/**
@@ -814,12 +827,12 @@ RestoreBootTimeDataFromLockBox (
@retval the address from which the a new s3 boot script entry will write into
**/
-UINT8*
+UINT8 *
S3BootScriptGetEntryAddAddress (
UINT8 EntryLength
)
{
- UINT8* NewEntryPtr;
+ UINT8 *NewEntryPtr;
if (!mS3BootScriptAcpiS3Enable) {
return NULL;
@@ -847,12 +860,12 @@ S3BootScriptGetEntryAddAddress (
mS3BootScriptTablePtr->BackFromS3 = FALSE;
}
- NewEntryPtr = S3BootScriptGetRuntimeEntryAddAddress (EntryLength);
+ NewEntryPtr = S3BootScriptGetRuntimeEntryAddAddress (EntryLength);
} else {
- NewEntryPtr = S3BootScriptGetBootTimeEntryAddAddress (EntryLength);
+ NewEntryPtr = S3BootScriptGetBootTimeEntryAddAddress (EntryLength);
}
- return NewEntryPtr;
+ return NewEntryPtr;
}
/**
@@ -863,7 +876,7 @@ S3BootScriptGetEntryAddAddress (
**/
VOID
SyncBootScript (
- IN UINT8 *Script
+ IN UINT8 *Script
)
{
EFI_STATUS Status;
@@ -875,12 +888,12 @@ SyncBootScript (
// If it is not after SmmReadyToLock in SMM,
// just return.
//
- return ;
+ return;
}
- ScriptOffset = (UINT32) (Script - mS3BootScriptTablePtr->TableBase);
+ ScriptOffset = (UINT32)(Script - mS3BootScriptTablePtr->TableBase);
- TotalScriptLength = (UINT32) (mS3BootScriptTablePtr->TableLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE));
+ TotalScriptLength = (UINT32)(mS3BootScriptTablePtr->TableLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE));
//
// Update BootScriptData
@@ -932,26 +945,27 @@ SyncBootScript (
@note this function could only called in boot time phase
**/
-UINT8*
+UINT8 *
EFIAPI
S3BootScriptCloseTable (
VOID
)
{
- UINT8 *S3TableBase;
- UINT32 TableLength;
- UINT8 *Buffer;
- EFI_STATUS Status;
- EFI_BOOT_SCRIPT_TABLE_HEADER *ScriptTableInfo;
+ UINT8 *S3TableBase;
+ UINT32 TableLength;
+ UINT8 *Buffer;
+ EFI_STATUS Status;
+ EFI_BOOT_SCRIPT_TABLE_HEADER *ScriptTableInfo;
S3TableBase = mS3BootScriptTablePtr->TableBase;
if (S3TableBase == 0) {
return 0;
}
+
//
// Append the termination record the S3 boot script table
//
- S3BootScriptInternalCloseTable();
+ S3BootScriptInternalCloseTable ();
TableLength = mS3BootScriptTablePtr->TableLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE);
//
// Allocate the buffer and copy the boot script to the buffer.
@@ -959,11 +973,12 @@ S3BootScriptCloseTable (
Status = gBS->AllocatePool (
EfiBootServicesData,
(UINTN)TableLength,
- (VOID **) &Buffer
+ (VOID **)&Buffer
);
if (EFI_ERROR (Status)) {
- return 0;
+ return 0;
}
+
CopyMem (Buffer, S3TableBase, TableLength);
//
@@ -971,14 +986,15 @@ S3BootScriptCloseTable (
// will write the record to the first entry of the table.
//
// Fill the table header.
- ScriptTableInfo = (EFI_BOOT_SCRIPT_TABLE_HEADER*)S3TableBase;
+ ScriptTableInfo = (EFI_BOOT_SCRIPT_TABLE_HEADER *)S3TableBase;
ScriptTableInfo->OpCode = S3_BOOT_SCRIPT_LIB_TABLE_OPCODE;
- ScriptTableInfo->Length = (UINT8) sizeof (EFI_BOOT_SCRIPT_TABLE_HEADER);
+ ScriptTableInfo->Length = (UINT8)sizeof (EFI_BOOT_SCRIPT_TABLE_HEADER);
ScriptTableInfo->TableLength = 0; // will be calculate at close the table
mS3BootScriptTablePtr->TableLength = sizeof (EFI_BOOT_SCRIPT_TABLE_HEADER);
return Buffer;
}
+
/**
Save I/O write to boot script
@@ -993,33 +1009,36 @@ S3BootScriptCloseTable (
RETURN_STATUS
EFIAPI
S3BootScriptSaveIoWrite (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- IN VOID *Buffer
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN VOID *Buffer
)
{
UINT8 Length;
- UINT8 *Script;
+ UINT8 *Script;
UINT8 WidthInByte;
EFI_BOOT_SCRIPT_IO_WRITE ScriptIoWrite;
- WidthInByte = (UINT8) (0x01 << (Width & 0x03));
+ WidthInByte = (UINT8)(0x01 << (Width & 0x03));
//
// Truncation check
//
if ((Count > MAX_UINT8) ||
- (WidthInByte * Count > MAX_UINT8 - sizeof (EFI_BOOT_SCRIPT_IO_WRITE))) {
+ (WidthInByte * Count > MAX_UINT8 - sizeof (EFI_BOOT_SCRIPT_IO_WRITE)))
+ {
return RETURN_OUT_OF_RESOURCES;
}
+
Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_IO_WRITE) + (WidthInByte * Count));
Script = S3BootScriptGetEntryAddAddress (Length);
if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// save script data
//
@@ -1027,9 +1046,9 @@ S3BootScriptSaveIoWrite (
ScriptIoWrite.Length = Length;
ScriptIoWrite.Width = Width;
ScriptIoWrite.Address = Address;
- ScriptIoWrite.Count = (UINT32) Count;
- CopyMem ((VOID*)Script, (VOID*)&ScriptIoWrite, sizeof(EFI_BOOT_SCRIPT_IO_WRITE));
- CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_IO_WRITE)), Buffer, WidthInByte * Count);
+ ScriptIoWrite.Count = (UINT32)Count;
+ CopyMem ((VOID *)Script, (VOID *)&ScriptIoWrite, sizeof (EFI_BOOT_SCRIPT_IO_WRITE));
+ CopyMem ((VOID *)(Script + sizeof (EFI_BOOT_SCRIPT_IO_WRITE)), Buffer, WidthInByte * Count);
SyncBootScript (Script);
@@ -1050,24 +1069,25 @@ S3BootScriptSaveIoWrite (
RETURN_STATUS
EFIAPI
S3BootScriptSaveIoReadWrite (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT64 Address,
- IN VOID *Data,
- IN VOID *DataMask
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT64 Address,
+ IN VOID *Data,
+ IN VOID *DataMask
)
{
- UINT8 Length;
- UINT8 *Script;
- UINT8 WidthInByte;
+ UINT8 Length;
+ UINT8 *Script;
+ UINT8 WidthInByte;
EFI_BOOT_SCRIPT_IO_READ_WRITE ScriptIoReadWrite;
- WidthInByte = (UINT8) (0x01 << (Width & 0x03));
- Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_IO_READ_WRITE) + (WidthInByte * 2));
+ WidthInByte = (UINT8)(0x01 << (Width & 0x03));
+ Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_IO_READ_WRITE) + (WidthInByte * 2));
Script = S3BootScriptGetEntryAddAddress (Length);
if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// Build script data
//
@@ -1076,14 +1096,15 @@ S3BootScriptSaveIoReadWrite (
ScriptIoReadWrite.Width = Width;
ScriptIoReadWrite.Address = Address;
- CopyMem ((VOID*)Script, (VOID*)&ScriptIoReadWrite, sizeof(EFI_BOOT_SCRIPT_IO_READ_WRITE));
- CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_IO_READ_WRITE)), Data, WidthInByte);
- CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_IO_READ_WRITE) + WidthInByte), DataMask, WidthInByte);
+ CopyMem ((VOID *)Script, (VOID *)&ScriptIoReadWrite, sizeof (EFI_BOOT_SCRIPT_IO_READ_WRITE));
+ CopyMem ((VOID *)(Script + sizeof (EFI_BOOT_SCRIPT_IO_READ_WRITE)), Data, WidthInByte);
+ CopyMem ((VOID *)(Script + sizeof (EFI_BOOT_SCRIPT_IO_READ_WRITE) + WidthInByte), DataMask, WidthInByte);
SyncBootScript (Script);
return RETURN_SUCCESS;
}
+
/**
Adds a record for a memory write operation into a specified boot script table.
@@ -1098,48 +1119,52 @@ S3BootScriptSaveIoReadWrite (
RETURN_STATUS
EFIAPI
S3BootScriptSaveMemWrite (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- IN VOID *Buffer
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN VOID *Buffer
)
{
- UINT8 Length;
- UINT8 *Script;
- UINT8 WidthInByte;
+ UINT8 Length;
+ UINT8 *Script;
+ UINT8 WidthInByte;
EFI_BOOT_SCRIPT_MEM_WRITE ScriptMemWrite;
- WidthInByte = (UINT8) (0x01 << (Width & 0x03));
+ WidthInByte = (UINT8)(0x01 << (Width & 0x03));
//
// Truncation check
//
if ((Count > MAX_UINT8) ||
- (WidthInByte * Count > MAX_UINT8 - sizeof (EFI_BOOT_SCRIPT_MEM_WRITE))) {
+ (WidthInByte * Count > MAX_UINT8 - sizeof (EFI_BOOT_SCRIPT_MEM_WRITE)))
+ {
return RETURN_OUT_OF_RESOURCES;
}
+
Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_MEM_WRITE) + (WidthInByte * Count));
Script = S3BootScriptGetEntryAddAddress (Length);
if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// Build script data
//
- ScriptMemWrite.OpCode = EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE;
- ScriptMemWrite.Length = Length;
- ScriptMemWrite.Width = Width;
- ScriptMemWrite.Address = Address;
- ScriptMemWrite.Count = (UINT32) Count;
+ ScriptMemWrite.OpCode = EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE;
+ ScriptMemWrite.Length = Length;
+ ScriptMemWrite.Width = Width;
+ ScriptMemWrite.Address = Address;
+ ScriptMemWrite.Count = (UINT32)Count;
- CopyMem ((VOID*)Script, (VOID*)&ScriptMemWrite, sizeof(EFI_BOOT_SCRIPT_MEM_WRITE));
- CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_MEM_WRITE)), Buffer, WidthInByte * Count);
+ CopyMem ((VOID *)Script, (VOID *)&ScriptMemWrite, sizeof (EFI_BOOT_SCRIPT_MEM_WRITE));
+ CopyMem ((VOID *)(Script + sizeof (EFI_BOOT_SCRIPT_MEM_WRITE)), Buffer, WidthInByte * Count);
SyncBootScript (Script);
return RETURN_SUCCESS;
}
+
/**
Adds a record for a memory modify operation into a specified boot script table.
@@ -1154,40 +1179,42 @@ S3BootScriptSaveMemWrite (
RETURN_STATUS
EFIAPI
S3BootScriptSaveMemReadWrite (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT64 Address,
- IN VOID *Data,
- IN VOID *DataMask
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT64 Address,
+ IN VOID *Data,
+ IN VOID *DataMask
)
{
- UINT8 Length;
- UINT8 *Script;
- UINT8 WidthInByte;
+ UINT8 Length;
+ UINT8 *Script;
+ UINT8 WidthInByte;
EFI_BOOT_SCRIPT_MEM_READ_WRITE ScriptMemReadWrite;
- WidthInByte = (UINT8) (0x01 << (Width & 0x03));
- Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_MEM_READ_WRITE) + (WidthInByte * 2));
+ WidthInByte = (UINT8)(0x01 << (Width & 0x03));
+ Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_MEM_READ_WRITE) + (WidthInByte * 2));
Script = S3BootScriptGetEntryAddAddress (Length);
if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// Build script data
//
- ScriptMemReadWrite.OpCode = EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE;
- ScriptMemReadWrite.Length = Length;
- ScriptMemReadWrite.Width = Width;
- ScriptMemReadWrite.Address = Address;
+ ScriptMemReadWrite.OpCode = EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE;
+ ScriptMemReadWrite.Length = Length;
+ ScriptMemReadWrite.Width = Width;
+ ScriptMemReadWrite.Address = Address;
- CopyMem ((VOID*)Script, (VOID*)&ScriptMemReadWrite , sizeof (EFI_BOOT_SCRIPT_MEM_READ_WRITE));
- CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_MEM_READ_WRITE)), Data, WidthInByte);
- CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_MEM_READ_WRITE) + WidthInByte), DataMask, WidthInByte);
+ CopyMem ((VOID *)Script, (VOID *)&ScriptMemReadWrite, sizeof (EFI_BOOT_SCRIPT_MEM_READ_WRITE));
+ CopyMem ((VOID *)(Script + sizeof (EFI_BOOT_SCRIPT_MEM_READ_WRITE)), Data, WidthInByte);
+ CopyMem ((VOID *)(Script + sizeof (EFI_BOOT_SCRIPT_MEM_READ_WRITE) + WidthInByte), DataMask, WidthInByte);
SyncBootScript (Script);
return RETURN_SUCCESS;
}
+
/**
Adds a record for a PCI configuration space write operation into a specified boot script table.
@@ -1204,54 +1231,59 @@ S3BootScriptSaveMemReadWrite (
RETURN_STATUS
EFIAPI
S3BootScriptSavePciCfgWrite (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT64 Address,
- IN UINTN Count,
- IN VOID *Buffer
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN VOID *Buffer
)
{
- UINT8 Length;
- UINT8 *Script;
- UINT8 WidthInByte;
+ UINT8 Length;
+ UINT8 *Script;
+ UINT8 WidthInByte;
EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE ScriptPciWrite;
- if (Width == S3BootScriptWidthUint64 ||
- Width == S3BootScriptWidthFifoUint64 ||
- Width == S3BootScriptWidthFillUint64) {
+ if ((Width == S3BootScriptWidthUint64) ||
+ (Width == S3BootScriptWidthFifoUint64) ||
+ (Width == S3BootScriptWidthFillUint64))
+ {
return EFI_INVALID_PARAMETER;
}
- WidthInByte = (UINT8) (0x01 << (Width & 0x03));
+ WidthInByte = (UINT8)(0x01 << (Width & 0x03));
//
// Truncation check
//
if ((Count > MAX_UINT8) ||
- (WidthInByte * Count > MAX_UINT8 - sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE))) {
+ (WidthInByte * Count > MAX_UINT8 - sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE)))
+ {
return RETURN_OUT_OF_RESOURCES;
}
+
Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE) + (WidthInByte * Count));
Script = S3BootScriptGetEntryAddAddress (Length);
if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// Build script data
//
- ScriptPciWrite.OpCode = EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE;
- ScriptPciWrite.Length = Length;
- ScriptPciWrite.Width = Width;
- ScriptPciWrite.Address = Address;
- ScriptPciWrite.Count = (UINT32) Count;
+ ScriptPciWrite.OpCode = EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE;
+ ScriptPciWrite.Length = Length;
+ ScriptPciWrite.Width = Width;
+ ScriptPciWrite.Address = Address;
+ ScriptPciWrite.Count = (UINT32)Count;
- CopyMem ((VOID*)Script, (VOID*)&ScriptPciWrite, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE));
- CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE)), Buffer, WidthInByte * Count);
+ CopyMem ((VOID *)Script, (VOID *)&ScriptPciWrite, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE));
+ CopyMem ((VOID *)(Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE)), Buffer, WidthInByte * Count);
SyncBootScript (Script);
return RETURN_SUCCESS;
}
+
/**
Adds a record for a PCI configuration space modify operation into a specified boot script table.
@@ -1268,42 +1300,44 @@ S3BootScriptSavePciCfgWrite (
RETURN_STATUS
EFIAPI
S3BootScriptSavePciCfgReadWrite (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT64 Address,
- IN VOID *Data,
- IN VOID *DataMask
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT64 Address,
+ IN VOID *Data,
+ IN VOID *DataMask
)
{
- UINT8 Length;
- UINT8 *Script;
- UINT8 WidthInByte;
+ UINT8 Length;
+ UINT8 *Script;
+ UINT8 WidthInByte;
EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE ScriptPciReadWrite;
- if (Width == S3BootScriptWidthUint64 ||
- Width == S3BootScriptWidthFifoUint64 ||
- Width == S3BootScriptWidthFillUint64) {
+ if ((Width == S3BootScriptWidthUint64) ||
+ (Width == S3BootScriptWidthFifoUint64) ||
+ (Width == S3BootScriptWidthFillUint64))
+ {
return EFI_INVALID_PARAMETER;
}
- WidthInByte = (UINT8) (0x01 << (Width & 0x03));
- Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE) + (WidthInByte * 2));
+ WidthInByte = (UINT8)(0x01 << (Width & 0x03));
+ Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE) + (WidthInByte * 2));
Script = S3BootScriptGetEntryAddAddress (Length);
if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// Build script data
//
- ScriptPciReadWrite.OpCode = EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE;
- ScriptPciReadWrite.Length = Length;
- ScriptPciReadWrite.Width = Width;
- ScriptPciReadWrite.Address = Address;
+ ScriptPciReadWrite.OpCode = EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE;
+ ScriptPciReadWrite.Length = Length;
+ ScriptPciReadWrite.Width = Width;
+ ScriptPciReadWrite.Address = Address;
- CopyMem ((VOID*)Script, (VOID*)&ScriptPciReadWrite, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE));
- CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE)), Data, WidthInByte);
+ CopyMem ((VOID *)Script, (VOID *)&ScriptPciReadWrite, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE));
+ CopyMem ((VOID *)(Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE)), Data, WidthInByte);
CopyMem (
- (VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE) + WidthInByte),
+ (VOID *)(Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE) + WidthInByte),
DataMask,
WidthInByte
);
@@ -1312,6 +1346,7 @@ S3BootScriptSavePciCfgReadWrite (
return RETURN_SUCCESS;
}
+
/**
Adds a record for a PCI configuration 2 space write operation into a specified boot script table.
@@ -1329,56 +1364,61 @@ S3BootScriptSavePciCfgReadWrite (
RETURN_STATUS
EFIAPI
S3BootScriptSavePciCfg2Write (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT16 Segment,
- IN UINT64 Address,
- IN UINTN Count,
- IN VOID *Buffer
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT16 Segment,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN VOID *Buffer
)
{
- UINT8 Length;
- UINT8 *Script;
- UINT8 WidthInByte;
+ UINT8 Length;
+ UINT8 *Script;
+ UINT8 WidthInByte;
EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE ScriptPciWrite2;
- if (Width == S3BootScriptWidthUint64 ||
- Width == S3BootScriptWidthFifoUint64 ||
- Width == S3BootScriptWidthFillUint64) {
+ if ((Width == S3BootScriptWidthUint64) ||
+ (Width == S3BootScriptWidthFifoUint64) ||
+ (Width == S3BootScriptWidthFillUint64))
+ {
return EFI_INVALID_PARAMETER;
}
- WidthInByte = (UINT8) (0x01 << (Width & 0x03));
+ WidthInByte = (UINT8)(0x01 << (Width & 0x03));
//
// Truncation check
//
if ((Count > MAX_UINT8) ||
- (WidthInByte * Count > MAX_UINT8 - sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE))) {
+ (WidthInByte * Count > MAX_UINT8 - sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE)))
+ {
return RETURN_OUT_OF_RESOURCES;
}
+
Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE) + (WidthInByte * Count));
Script = S3BootScriptGetEntryAddAddress (Length);
if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// Build script data
//
- ScriptPciWrite2.OpCode = EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE;
- ScriptPciWrite2.Length = Length;
- ScriptPciWrite2.Width = Width;
- ScriptPciWrite2.Address = Address;
- ScriptPciWrite2.Segment = Segment;
- ScriptPciWrite2.Count = (UINT32)Count;
+ ScriptPciWrite2.OpCode = EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE;
+ ScriptPciWrite2.Length = Length;
+ ScriptPciWrite2.Width = Width;
+ ScriptPciWrite2.Address = Address;
+ ScriptPciWrite2.Segment = Segment;
+ ScriptPciWrite2.Count = (UINT32)Count;
- CopyMem ((VOID*)Script, (VOID*)&ScriptPciWrite2, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE));
- CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE)), Buffer, WidthInByte * Count);
+ CopyMem ((VOID *)Script, (VOID *)&ScriptPciWrite2, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE));
+ CopyMem ((VOID *)(Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE)), Buffer, WidthInByte * Count);
SyncBootScript (Script);
return RETURN_SUCCESS;
}
+
/**
Adds a record for a PCI configuration 2 space modify operation into a specified boot script table.
@@ -1396,44 +1436,46 @@ S3BootScriptSavePciCfg2Write (
RETURN_STATUS
EFIAPI
S3BootScriptSavePciCfg2ReadWrite (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT16 Segment,
- IN UINT64 Address,
- IN VOID *Data,
- IN VOID *DataMask
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT16 Segment,
+ IN UINT64 Address,
+ IN VOID *Data,
+ IN VOID *DataMask
)
{
- UINT8 Length;
- UINT8 *Script;
- UINT8 WidthInByte;
+ UINT8 Length;
+ UINT8 *Script;
+ UINT8 WidthInByte;
EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE ScriptPciReadWrite2;
- if (Width == S3BootScriptWidthUint64 ||
- Width == S3BootScriptWidthFifoUint64 ||
- Width == S3BootScriptWidthFillUint64) {
+ if ((Width == S3BootScriptWidthUint64) ||
+ (Width == S3BootScriptWidthFifoUint64) ||
+ (Width == S3BootScriptWidthFillUint64))
+ {
return EFI_INVALID_PARAMETER;
}
- WidthInByte = (UINT8) (0x01 << (Width & 0x03));
- Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE) + (WidthInByte * 2));
+ WidthInByte = (UINT8)(0x01 << (Width & 0x03));
+ Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE) + (WidthInByte * 2));
Script = S3BootScriptGetEntryAddAddress (Length);
if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// Build script data
//
- ScriptPciReadWrite2.OpCode = EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE;
- ScriptPciReadWrite2.Length = Length;
- ScriptPciReadWrite2.Width = Width;
- ScriptPciReadWrite2.Segment = Segment;
- ScriptPciReadWrite2.Address = Address;
+ ScriptPciReadWrite2.OpCode = EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE;
+ ScriptPciReadWrite2.Length = Length;
+ ScriptPciReadWrite2.Width = Width;
+ ScriptPciReadWrite2.Segment = Segment;
+ ScriptPciReadWrite2.Address = Address;
- CopyMem ((VOID*)Script, (VOID*)&ScriptPciReadWrite2, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE));
- CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE)), Data, WidthInByte);
+ CopyMem ((VOID *)Script, (VOID *)&ScriptPciReadWrite2, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE));
+ CopyMem ((VOID *)(Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE)), Data, WidthInByte);
CopyMem (
- (VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE) + WidthInByte),
+ (VOID *)(Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE) + WidthInByte),
DataMask,
WidthInByte
);
@@ -1477,19 +1519,19 @@ S3BootScriptSavePciCfg2ReadWrite (
**/
EFI_STATUS
CheckParameters (
- IN UINTN SmBusAddress,
- IN EFI_SMBUS_OPERATION Operation,
- IN OUT UINTN *Length,
- IN VOID *Buffer
+ IN UINTN SmBusAddress,
+ IN EFI_SMBUS_OPERATION Operation,
+ IN OUT UINTN *Length,
+ IN VOID *Buffer
)
{
- EFI_STATUS Status;
- UINTN RequiredLen;
- EFI_SMBUS_DEVICE_COMMAND Command;
- BOOLEAN PecCheck;
+ EFI_STATUS Status;
+ UINTN RequiredLen;
+ EFI_SMBUS_DEVICE_COMMAND Command;
+ BOOLEAN PecCheck;
- Command = SMBUS_LIB_COMMAND (SmBusAddress);
- PecCheck = SMBUS_LIB_PEC (SmBusAddress);
+ Command = SMBUS_LIB_COMMAND (SmBusAddress);
+ PecCheck = SMBUS_LIB_PEC (SmBusAddress);
//
// Set default value to be 2:
// for SmbusReadWord, SmbusWriteWord and SmbusProcessCall.
@@ -1499,32 +1541,35 @@ CheckParameters (
switch (Operation) {
case EfiSmbusQuickRead:
case EfiSmbusQuickWrite:
- if (PecCheck || Command != 0) {
+ if (PecCheck || (Command != 0)) {
return EFI_UNSUPPORTED;
}
+
break;
case EfiSmbusReceiveByte:
case EfiSmbusSendByte:
if (Command != 0) {
return EFI_UNSUPPORTED;
}
- //
- // Cascade to check length parameter.
- //
+
+ //
+ // Cascade to check length parameter.
+ //
case EfiSmbusReadByte:
case EfiSmbusWriteByte:
RequiredLen = 1;
- //
- // Cascade to check length parameter.
- //
+ //
+ // Cascade to check length parameter.
+ //
case EfiSmbusReadWord:
case EfiSmbusWriteWord:
case EfiSmbusProcessCall:
- if (Buffer == NULL || Length == NULL) {
+ if ((Buffer == NULL) || (Length == NULL)) {
return EFI_INVALID_PARAMETER;
} else if (*Length < RequiredLen) {
Status = EFI_BUFFER_TOO_SMALL;
}
+
*Length = RequiredLen;
break;
case EfiSmbusReadBlock:
@@ -1533,13 +1578,16 @@ CheckParameters (
if ((Buffer == NULL) ||
(Length == NULL) ||
(*Length < MIN_SMBUS_BLOCK_LEN) ||
- (*Length > MAX_SMBUS_BLOCK_LEN)) {
+ (*Length > MAX_SMBUS_BLOCK_LEN))
+ {
return EFI_INVALID_PARAMETER;
}
+
break;
default:
return EFI_INVALID_PARAMETER;
}
+
return Status;
}
@@ -1558,16 +1606,16 @@ CheckParameters (
RETURN_STATUS
EFIAPI
S3BootScriptSaveSmbusExecute (
- IN UINTN SmBusAddress,
- IN EFI_SMBUS_OPERATION Operation,
- IN UINTN *Length,
- IN VOID *Buffer
+ IN UINTN SmBusAddress,
+ IN EFI_SMBUS_OPERATION Operation,
+ IN UINTN *Length,
+ IN VOID *Buffer
)
{
- EFI_STATUS Status;
- UINTN BufferLength;
- UINT8 DataSize;
- UINT8 *Script;
+ EFI_STATUS Status;
+ UINTN BufferLength;
+ UINT8 DataSize;
+ UINT8 *Script;
EFI_BOOT_SCRIPT_SMBUS_EXECUTE ScriptSmbusExecute;
if (Length == NULL) {
@@ -1587,24 +1635,26 @@ S3BootScriptSaveSmbusExecute (
if (BufferLength > MAX_UINT8 - sizeof (EFI_BOOT_SCRIPT_SMBUS_EXECUTE)) {
return RETURN_OUT_OF_RESOURCES;
}
+
DataSize = (UINT8)(sizeof (EFI_BOOT_SCRIPT_SMBUS_EXECUTE) + BufferLength);
Script = S3BootScriptGetEntryAddAddress (DataSize);
if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// Build script data
//
ScriptSmbusExecute.OpCode = EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE;
ScriptSmbusExecute.Length = DataSize;
- ScriptSmbusExecute.SmBusAddress = (UINT64) SmBusAddress;
+ ScriptSmbusExecute.SmBusAddress = (UINT64)SmBusAddress;
ScriptSmbusExecute.Operation = Operation;
- ScriptSmbusExecute.DataSize = (UINT32) BufferLength;
+ ScriptSmbusExecute.DataSize = (UINT32)BufferLength;
- CopyMem ((VOID*)Script, (VOID*)&ScriptSmbusExecute, sizeof (EFI_BOOT_SCRIPT_SMBUS_EXECUTE));
+ CopyMem ((VOID *)Script, (VOID *)&ScriptSmbusExecute, sizeof (EFI_BOOT_SCRIPT_SMBUS_EXECUTE));
CopyMem (
- (VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_SMBUS_EXECUTE)),
+ (VOID *)(Script + sizeof (EFI_BOOT_SCRIPT_SMBUS_EXECUTE)),
Buffer,
BufferLength
);
@@ -1613,6 +1663,7 @@ S3BootScriptSaveSmbusExecute (
return RETURN_SUCCESS;
}
+
/**
Adds a record for an execution stall on the processor into a specified boot script table.
@@ -1624,11 +1675,11 @@ S3BootScriptSaveSmbusExecute (
RETURN_STATUS
EFIAPI
S3BootScriptSaveStall (
- IN UINTN Duration
+ IN UINTN Duration
)
{
- UINT8 Length;
- UINT8 *Script;
+ UINT8 Length;
+ UINT8 *Script;
EFI_BOOT_SCRIPT_STALL ScriptStall;
Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_STALL));
@@ -1637,19 +1688,21 @@ S3BootScriptSaveStall (
if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// Build script data
//
- ScriptStall.OpCode = EFI_BOOT_SCRIPT_STALL_OPCODE;
- ScriptStall.Length = Length;
- ScriptStall.Duration = Duration;
+ ScriptStall.OpCode = EFI_BOOT_SCRIPT_STALL_OPCODE;
+ ScriptStall.Length = Length;
+ ScriptStall.Duration = Duration;
- CopyMem ((VOID*)Script, (VOID*)&ScriptStall, sizeof (EFI_BOOT_SCRIPT_STALL));
+ CopyMem ((VOID *)Script, (VOID *)&ScriptStall, sizeof (EFI_BOOT_SCRIPT_STALL));
SyncBootScript (Script);
return RETURN_SUCCESS;
}
+
/**
Adds a record for dispatching specified arbitrary code into a specified boot script table.
@@ -1662,34 +1715,36 @@ S3BootScriptSaveStall (
RETURN_STATUS
EFIAPI
S3BootScriptSaveDispatch2 (
- IN VOID *EntryPoint,
- IN VOID *Context
+ IN VOID *EntryPoint,
+ IN VOID *Context
)
{
- UINT8 Length;
- UINT8 *Script;
+ UINT8 Length;
+ UINT8 *Script;
EFI_BOOT_SCRIPT_DISPATCH_2 ScriptDispatch2;
+
Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_DISPATCH_2));
Script = S3BootScriptGetEntryAddAddress (Length);
if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// Build script data
//
ScriptDispatch2.OpCode = EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE;
ScriptDispatch2.Length = Length;
ScriptDispatch2.EntryPoint = (EFI_PHYSICAL_ADDRESS)(UINTN)EntryPoint;
- ScriptDispatch2.Context = (EFI_PHYSICAL_ADDRESS)(UINTN)Context;
+ ScriptDispatch2.Context = (EFI_PHYSICAL_ADDRESS)(UINTN)Context;
- CopyMem ((VOID*)Script, (VOID*)&ScriptDispatch2, sizeof (EFI_BOOT_SCRIPT_DISPATCH_2));
+ CopyMem ((VOID *)Script, (VOID *)&ScriptDispatch2, sizeof (EFI_BOOT_SCRIPT_DISPATCH_2));
SyncBootScript (Script);
return RETURN_SUCCESS;
-
}
+
/**
Adds a record for memory reads of the memory location and continues when the exit criteria is
satisfied or after a defined duration.
@@ -1713,20 +1768,20 @@ S3BootScriptSaveDispatch2 (
RETURN_STATUS
EFIAPI
S3BootScriptSaveMemPoll (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT64 Address,
- IN VOID *BitMask,
- IN VOID *BitValue,
- IN UINTN Duration,
- IN UINT64 LoopTimes
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT64 Address,
+ IN VOID *BitMask,
+ IN VOID *BitValue,
+ IN UINTN Duration,
+ IN UINT64 LoopTimes
)
{
- UINT8 Length;
- UINT8 *Script;
- UINT8 WidthInByte;
- EFI_BOOT_SCRIPT_MEM_POLL ScriptMemPoll;
+ UINT8 Length;
+ UINT8 *Script;
+ UINT8 WidthInByte;
+ EFI_BOOT_SCRIPT_MEM_POLL ScriptMemPoll;
- WidthInByte = (UINT8) (0x01 << (Width & 0x03));
+ WidthInByte = (UINT8)(0x01 << (Width & 0x03));
Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_MEM_POLL) + (WidthInByte * 2));
@@ -1734,24 +1789,26 @@ S3BootScriptSaveMemPoll (
if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// Build script data
//
- ScriptMemPoll.OpCode = EFI_BOOT_SCRIPT_MEM_POLL_OPCODE;
- ScriptMemPoll.Length = Length;
- ScriptMemPoll.Width = Width;
- ScriptMemPoll.Address = Address;
- ScriptMemPoll.Duration = Duration;
+ ScriptMemPoll.OpCode = EFI_BOOT_SCRIPT_MEM_POLL_OPCODE;
+ ScriptMemPoll.Length = Length;
+ ScriptMemPoll.Width = Width;
+ ScriptMemPoll.Address = Address;
+ ScriptMemPoll.Duration = Duration;
ScriptMemPoll.LoopTimes = LoopTimes;
- CopyMem ((UINT8 *) (Script + sizeof (EFI_BOOT_SCRIPT_MEM_POLL)), BitValue, WidthInByte);
- CopyMem ((UINT8 *) (Script + sizeof (EFI_BOOT_SCRIPT_MEM_POLL) + WidthInByte), BitMask, WidthInByte);
- CopyMem ((VOID*)Script, (VOID*)&ScriptMemPoll, sizeof (EFI_BOOT_SCRIPT_MEM_POLL));
+ CopyMem ((UINT8 *)(Script + sizeof (EFI_BOOT_SCRIPT_MEM_POLL)), BitValue, WidthInByte);
+ CopyMem ((UINT8 *)(Script + sizeof (EFI_BOOT_SCRIPT_MEM_POLL) + WidthInByte), BitMask, WidthInByte);
+ CopyMem ((VOID *)Script, (VOID *)&ScriptMemPoll, sizeof (EFI_BOOT_SCRIPT_MEM_POLL));
SyncBootScript (Script);
return RETURN_SUCCESS;
}
+
/**
Store arbitrary information in the boot script table. This opcode is a no-op on dispatch and is only
used for debugging script issues.
@@ -1766,12 +1823,12 @@ S3BootScriptSaveMemPoll (
RETURN_STATUS
EFIAPI
S3BootScriptSaveInformation (
- IN UINT32 InformationLength,
- IN VOID *Information
+ IN UINT32 InformationLength,
+ IN VOID *Information
)
{
- UINT8 Length;
- UINT8 *Script;
+ UINT8 Length;
+ UINT8 *Script;
EFI_BOOT_SCRIPT_INFORMATION ScriptInformation;
//
@@ -1780,29 +1837,30 @@ S3BootScriptSaveInformation (
if (InformationLength > MAX_UINT8 - sizeof (EFI_BOOT_SCRIPT_INFORMATION)) {
return RETURN_OUT_OF_RESOURCES;
}
+
Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_INFORMATION) + InformationLength);
Script = S3BootScriptGetEntryAddAddress (Length);
if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// Build script data
//
- ScriptInformation.OpCode = EFI_BOOT_SCRIPT_INFORMATION_OPCODE;
- ScriptInformation.Length = Length;
-
+ ScriptInformation.OpCode = EFI_BOOT_SCRIPT_INFORMATION_OPCODE;
+ ScriptInformation.Length = Length;
ScriptInformation.InformationLength = InformationLength;
- CopyMem ((VOID*)Script, (VOID*)&ScriptInformation, sizeof (EFI_BOOT_SCRIPT_INFORMATION));
- CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_INFORMATION)), (VOID *) Information, (UINTN) InformationLength);
+ CopyMem ((VOID *)Script, (VOID *)&ScriptInformation, sizeof (EFI_BOOT_SCRIPT_INFORMATION));
+ CopyMem ((VOID *)(Script + sizeof (EFI_BOOT_SCRIPT_INFORMATION)), (VOID *)Information, (UINTN)InformationLength);
SyncBootScript (Script);
return RETURN_SUCCESS;
-
}
+
/**
Store a string in the boot script table. This opcode is a no-op on dispatch and is only
used for debugging script issues.
@@ -1816,14 +1874,15 @@ S3BootScriptSaveInformation (
RETURN_STATUS
EFIAPI
S3BootScriptSaveInformationAsciiString (
- IN CONST CHAR8 *String
+ IN CONST CHAR8 *String
)
{
return S3BootScriptSaveInformation (
- (UINT32) AsciiStrLen (String) + 1,
- (VOID*) String
+ (UINT32)AsciiStrLen (String) + 1,
+ (VOID *)String
);
}
+
/**
Adds a record for dispatching specified arbitrary code into a specified boot script table.
@@ -1835,11 +1894,11 @@ S3BootScriptSaveInformationAsciiString (
RETURN_STATUS
EFIAPI
S3BootScriptSaveDispatch (
- IN VOID *EntryPoint
+ IN VOID *EntryPoint
)
{
- UINT8 Length;
- UINT8 *Script;
+ UINT8 Length;
+ UINT8 *Script;
EFI_BOOT_SCRIPT_DISPATCH ScriptDispatch;
Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_DISPATCH));
@@ -1848,6 +1907,7 @@ S3BootScriptSaveDispatch (
if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// Build script data
//
@@ -1855,13 +1915,13 @@ S3BootScriptSaveDispatch (
ScriptDispatch.Length = Length;
ScriptDispatch.EntryPoint = (EFI_PHYSICAL_ADDRESS)(UINTN)EntryPoint;
- CopyMem ((VOID*)Script, (VOID*)&ScriptDispatch, sizeof (EFI_BOOT_SCRIPT_DISPATCH));
+ CopyMem ((VOID *)Script, (VOID *)&ScriptDispatch, sizeof (EFI_BOOT_SCRIPT_DISPATCH));
SyncBootScript (Script);
return RETURN_SUCCESS;
-
}
+
/**
Adds a record for I/O reads the I/O location and continues when the exit criteria is satisfied or after a
defined duration.
@@ -1881,38 +1941,38 @@ S3BootScriptSaveDispatch (
RETURN_STATUS
EFIAPI
S3BootScriptSaveIoPoll (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT64 Address,
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT64 Address,
IN VOID *Data,
IN VOID *DataMask,
- IN UINT64 Delay
+ IN UINT64 Delay
)
{
- UINT8 WidthInByte;
- UINT8 *Script;
- UINT8 Length;
+ UINT8 WidthInByte;
+ UINT8 *Script;
+ UINT8 Length;
EFI_BOOT_SCRIPT_IO_POLL ScriptIoPoll;
-
- WidthInByte = (UINT8) (0x01 << (Width & 0x03));
- Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_IO_POLL) + (WidthInByte * 2));
+ WidthInByte = (UINT8)(0x01 << (Width & 0x03));
+ Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_IO_POLL) + (WidthInByte * 2));
Script = S3BootScriptGetEntryAddAddress (Length);
if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// Build script data
//
- ScriptIoPoll.OpCode = EFI_BOOT_SCRIPT_IO_POLL_OPCODE;
- ScriptIoPoll.Length = (UINT8) (sizeof (EFI_BOOT_SCRIPT_IO_POLL) + (WidthInByte * 2));
- ScriptIoPoll.Width = Width;
- ScriptIoPoll.Address = Address;
- ScriptIoPoll.Delay = Delay;
+ ScriptIoPoll.OpCode = EFI_BOOT_SCRIPT_IO_POLL_OPCODE;
+ ScriptIoPoll.Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_IO_POLL) + (WidthInByte * 2));
+ ScriptIoPoll.Width = Width;
+ ScriptIoPoll.Address = Address;
+ ScriptIoPoll.Delay = Delay;
- CopyMem ((VOID*)Script, (VOID*)&ScriptIoPoll, sizeof (EFI_BOOT_SCRIPT_IO_POLL));
- CopyMem ((UINT8 *) (Script + sizeof (EFI_BOOT_SCRIPT_IO_POLL)), Data, WidthInByte);
- CopyMem ((UINT8 *) (Script + sizeof (EFI_BOOT_SCRIPT_IO_POLL) + WidthInByte), DataMask, WidthInByte);
+ CopyMem ((VOID *)Script, (VOID *)&ScriptIoPoll, sizeof (EFI_BOOT_SCRIPT_IO_POLL));
+ CopyMem ((UINT8 *)(Script + sizeof (EFI_BOOT_SCRIPT_IO_POLL)), Data, WidthInByte);
+ CopyMem ((UINT8 *)(Script + sizeof (EFI_BOOT_SCRIPT_IO_POLL) + WidthInByte), DataMask, WidthInByte);
SyncBootScript (Script);
@@ -1939,48 +1999,51 @@ S3BootScriptSaveIoPoll (
RETURN_STATUS
EFIAPI
S3BootScriptSavePciPoll (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT64 Address,
- IN VOID *Data,
- IN VOID *DataMask,
- IN UINT64 Delay
-)
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT64 Address,
+ IN VOID *Data,
+ IN VOID *DataMask,
+ IN UINT64 Delay
+ )
{
- UINT8 *Script;
- UINT8 WidthInByte;
- UINT8 Length;
+ UINT8 *Script;
+ UINT8 WidthInByte;
+ UINT8 Length;
EFI_BOOT_SCRIPT_PCI_CONFIG_POLL ScriptPciPoll;
- if (Width == S3BootScriptWidthUint64 ||
- Width == S3BootScriptWidthFifoUint64 ||
- Width == S3BootScriptWidthFillUint64) {
+ if ((Width == S3BootScriptWidthUint64) ||
+ (Width == S3BootScriptWidthFifoUint64) ||
+ (Width == S3BootScriptWidthFillUint64))
+ {
return EFI_INVALID_PARAMETER;
}
- WidthInByte = (UINT8) (0x01 << (Width & 0x03));
- Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_POLL) + (WidthInByte * 2));
+ WidthInByte = (UINT8)(0x01 << (Width & 0x03));
+ Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_POLL) + (WidthInByte * 2));
Script = S3BootScriptGetEntryAddAddress (Length);
if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// Build script data
//
- ScriptPciPoll.OpCode = EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE;
- ScriptPciPoll.Length = (UINT8) (sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_POLL) + (WidthInByte * 2));
- ScriptPciPoll.Width = Width;
- ScriptPciPoll.Address = Address;
- ScriptPciPoll.Delay = Delay;
+ ScriptPciPoll.OpCode = EFI_BOOT_SCRIPT_PCI_CONFIG_POLL_OPCODE;
+ ScriptPciPoll.Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_POLL) + (WidthInByte * 2));
+ ScriptPciPoll.Width = Width;
+ ScriptPciPoll.Address = Address;
+ ScriptPciPoll.Delay = Delay;
- CopyMem ((VOID*)Script, (VOID*)&ScriptPciPoll, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_POLL));
- CopyMem ((UINT8 *) (Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_POLL)), Data, WidthInByte);
- CopyMem ((UINT8 *) (Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_POLL) + WidthInByte), DataMask, WidthInByte);
+ CopyMem ((VOID *)Script, (VOID *)&ScriptPciPoll, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_POLL));
+ CopyMem ((UINT8 *)(Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_POLL)), Data, WidthInByte);
+ CopyMem ((UINT8 *)(Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_POLL) + WidthInByte), DataMask, WidthInByte);
SyncBootScript (Script);
return RETURN_SUCCESS;
}
+
/**
Adds a record for PCI configuration space reads and continues when the exit criteria is satisfied or
after a defined duration.
@@ -2002,50 +2065,53 @@ S3BootScriptSavePciPoll (
RETURN_STATUS
EFIAPI
S3BootScriptSavePci2Poll (
- IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
- IN UINT16 Segment,
- IN UINT64 Address,
- IN VOID *Data,
- IN VOID *DataMask,
- IN UINT64 Delay
-)
+ IN S3_BOOT_SCRIPT_LIB_WIDTH Width,
+ IN UINT16 Segment,
+ IN UINT64 Address,
+ IN VOID *Data,
+ IN VOID *DataMask,
+ IN UINT64 Delay
+ )
{
- UINT8 WidthInByte;
- UINT8 *Script;
- UINT8 Length;
+ UINT8 WidthInByte;
+ UINT8 *Script;
+ UINT8 Length;
EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL ScriptPci2Poll;
- if (Width == S3BootScriptWidthUint64 ||
- Width == S3BootScriptWidthFifoUint64 ||
- Width == S3BootScriptWidthFillUint64) {
+ if ((Width == S3BootScriptWidthUint64) ||
+ (Width == S3BootScriptWidthFifoUint64) ||
+ (Width == S3BootScriptWidthFillUint64))
+ {
return EFI_INVALID_PARAMETER;
}
- WidthInByte = (UINT8) (0x01 << (Width & 0x03));
- Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL) + (WidthInByte * 2));
+ WidthInByte = (UINT8)(0x01 << (Width & 0x03));
+ Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL) + (WidthInByte * 2));
Script = S3BootScriptGetEntryAddAddress (Length);
if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// Build script data
//
- ScriptPci2Poll.OpCode = EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE;
- ScriptPci2Poll.Length = (UINT8) (sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL) + (WidthInByte * 2));
- ScriptPci2Poll.Width = Width;
- ScriptPci2Poll.Segment = Segment;
- ScriptPci2Poll.Address = Address;
- ScriptPci2Poll.Delay = Delay;
+ ScriptPci2Poll.OpCode = EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE;
+ ScriptPci2Poll.Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL) + (WidthInByte * 2));
+ ScriptPci2Poll.Width = Width;
+ ScriptPci2Poll.Segment = Segment;
+ ScriptPci2Poll.Address = Address;
+ ScriptPci2Poll.Delay = Delay;
- CopyMem ((VOID*)Script, (VOID*)&ScriptPci2Poll, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL));
- CopyMem ((UINT8 *) (Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL)), Data, WidthInByte);
- CopyMem ((UINT8 *) (Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL) + WidthInByte), DataMask, WidthInByte);
+ CopyMem ((VOID *)Script, (VOID *)&ScriptPci2Poll, sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL));
+ CopyMem ((UINT8 *)(Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL)), Data, WidthInByte);
+ CopyMem ((UINT8 *)(Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL) + WidthInByte), DataMask, WidthInByte);
SyncBootScript (Script);
return RETURN_SUCCESS;
}
+
/**
Do the calculation of start address from which a new s3 boot script entry will write into.
@@ -2058,59 +2124,61 @@ S3BootScriptSavePci2Poll (
**/
VOID
S3BootScriptCalculateInsertAddress (
- IN UINT8 EntryLength,
+ IN UINT8 EntryLength,
IN VOID *Position OPTIONAL,
- IN BOOLEAN BeforeOrAfter OPTIONAL,
- OUT UINT8 **Script
+ IN BOOLEAN BeforeOrAfter OPTIONAL,
+ OUT UINT8 **Script
)
{
- UINTN TableLength;
- UINT8 *S3TableBase;
- UINTN PositionOffset;
- EFI_BOOT_SCRIPT_COMMON_HEADER ScriptHeader;
- //
- // The entry inserting to table is already added to the end of the table
- //
- TableLength = mS3BootScriptTablePtr->TableLength - EntryLength;
- S3TableBase = mS3BootScriptTablePtr->TableBase ;
- //
- // calculate the Position offset
- //
- if (Position != NULL) {
- PositionOffset = (UINTN)Position - (UINTN)S3TableBase;
-
- //
- // If the BeforeOrAfter is FALSE, that means to insert the node right after the node.
- //
- if (!BeforeOrAfter) {
- CopyMem ((VOID*)&ScriptHeader, Position, sizeof(EFI_BOOT_SCRIPT_COMMON_HEADER));
- PositionOffset += (ScriptHeader.Length);
- }
- //
- // Insert the node before the adjusted Position
- //
- CopyMem (S3TableBase+PositionOffset+EntryLength, S3TableBase+PositionOffset, TableLength - PositionOffset);
- //
- // calculate the the start address for the new entry.
- //
- *Script = S3TableBase + PositionOffset;
-
- } else {
- if (!BeforeOrAfter) {
- //
- // Insert the node to the end of the table
- //
- *Script = S3TableBase + TableLength;
- } else {
- //
- // Insert the node to the beginning of the table
- //
- PositionOffset = (UINTN) sizeof(EFI_BOOT_SCRIPT_TABLE_HEADER);
- CopyMem (S3TableBase+PositionOffset+EntryLength, S3TableBase+PositionOffset, TableLength - PositionOffset);
- *Script = S3TableBase + PositionOffset;
- }
- }
+ UINTN TableLength;
+ UINT8 *S3TableBase;
+ UINTN PositionOffset;
+ EFI_BOOT_SCRIPT_COMMON_HEADER ScriptHeader;
+
+ //
+ // The entry inserting to table is already added to the end of the table
+ //
+ TableLength = mS3BootScriptTablePtr->TableLength - EntryLength;
+ S3TableBase = mS3BootScriptTablePtr->TableBase;
+ //
+ // calculate the Position offset
+ //
+ if (Position != NULL) {
+ PositionOffset = (UINTN)Position - (UINTN)S3TableBase;
+
+ //
+ // If the BeforeOrAfter is FALSE, that means to insert the node right after the node.
+ //
+ if (!BeforeOrAfter) {
+ CopyMem ((VOID *)&ScriptHeader, Position, sizeof (EFI_BOOT_SCRIPT_COMMON_HEADER));
+ PositionOffset += (ScriptHeader.Length);
+ }
+
+ //
+ // Insert the node before the adjusted Position
+ //
+ CopyMem (S3TableBase+PositionOffset+EntryLength, S3TableBase+PositionOffset, TableLength - PositionOffset);
+ //
+ // calculate the the start address for the new entry.
+ //
+ *Script = S3TableBase + PositionOffset;
+ } else {
+ if (!BeforeOrAfter) {
+ //
+ // Insert the node to the end of the table
+ //
+ *Script = S3TableBase + TableLength;
+ } else {
+ //
+ // Insert the node to the beginning of the table
+ //
+ PositionOffset = (UINTN)sizeof (EFI_BOOT_SCRIPT_TABLE_HEADER);
+ CopyMem (S3TableBase+PositionOffset+EntryLength, S3TableBase+PositionOffset, TableLength - PositionOffset);
+ *Script = S3TableBase + PositionOffset;
+ }
+ }
}
+
/**
Move the last boot script entry to the position
@@ -2129,21 +2197,21 @@ S3BootScriptCalculateInsertAddress (
RETURN_STATUS
EFIAPI
S3BootScriptMoveLastOpcode (
- IN BOOLEAN BeforeOrAfter,
- IN OUT VOID **Position OPTIONAL
-)
+ IN BOOLEAN BeforeOrAfter,
+ IN OUT VOID **Position OPTIONAL
+ )
{
- UINT8* Script;
- VOID *TempPosition;
- UINTN StartAddress;
- UINT32 TableLength;
+ UINT8 *Script;
+ VOID *TempPosition;
+ UINTN StartAddress;
+ UINT32 TableLength;
EFI_BOOT_SCRIPT_COMMON_HEADER ScriptHeader;
- BOOLEAN ValidatePosition;
- UINT8* LastOpcode;
- UINT8 TempBootScriptEntry[BOOT_SCRIPT_NODE_MAX_LENGTH];
+ BOOLEAN ValidatePosition;
+ UINT8 *LastOpcode;
+ UINT8 TempBootScriptEntry[BOOT_SCRIPT_NODE_MAX_LENGTH];
ValidatePosition = FALSE;
- TempPosition = (Position == NULL) ? NULL:(*Position);
+ TempPosition = (Position == NULL) ? NULL : (*Position);
//
// Check that the script is initialized and synced without adding an entry to the script.
@@ -2152,38 +2220,42 @@ S3BootScriptMoveLastOpcode (
if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
Script = mS3BootScriptTablePtr->TableBase;
- StartAddress = (UINTN) Script;
- TableLength = mS3BootScriptTablePtr->TableLength;
- Script = Script + sizeof(EFI_BOOT_SCRIPT_TABLE_HEADER);
- LastOpcode = Script;
+ StartAddress = (UINTN)Script;
+ TableLength = mS3BootScriptTablePtr->TableLength;
+ Script = Script + sizeof (EFI_BOOT_SCRIPT_TABLE_HEADER);
+ LastOpcode = Script;
//
// Find the last boot Script Entry which is not the terminate node
//
- while ((UINTN) Script < (UINTN) (StartAddress + TableLength)) {
- CopyMem ((VOID*)&ScriptHeader, Script, sizeof(EFI_BOOT_SCRIPT_COMMON_HEADER));
- if (TempPosition != NULL && TempPosition == Script) {
+ while ((UINTN)Script < (UINTN)(StartAddress + TableLength)) {
+ CopyMem ((VOID *)&ScriptHeader, Script, sizeof (EFI_BOOT_SCRIPT_COMMON_HEADER));
+ if ((TempPosition != NULL) && (TempPosition == Script)) {
//
// If the position is specified, the position must be pointed to a boot script entry start address.
//
ValidatePosition = TRUE;
}
+
if (ScriptHeader.OpCode != S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE) {
LastOpcode = Script;
}
- Script = Script + ScriptHeader.Length;
+
+ Script = Script + ScriptHeader.Length;
}
+
//
// If the position is specified, but not the start of a boot script entry, it is a invalid input
//
- if (TempPosition != NULL && !ValidatePosition) {
+ if ((TempPosition != NULL) && !ValidatePosition) {
return RETURN_INVALID_PARAMETER;
}
- CopyMem ((VOID*)&ScriptHeader, LastOpcode, sizeof(EFI_BOOT_SCRIPT_COMMON_HEADER));
+ CopyMem ((VOID *)&ScriptHeader, LastOpcode, sizeof (EFI_BOOT_SCRIPT_COMMON_HEADER));
- CopyMem((VOID*)TempBootScriptEntry, LastOpcode, ScriptHeader.Length);
+ CopyMem ((VOID *)TempBootScriptEntry, LastOpcode, ScriptHeader.Length);
//
// Find the right position to write the node in
//
@@ -2192,11 +2264,11 @@ S3BootScriptMoveLastOpcode (
TempPosition,
BeforeOrAfter,
&Script
- );
+ );
//
// Copy the node to Boot script table
//
- CopyMem((VOID*)Script, (VOID*)TempBootScriptEntry, ScriptHeader.Length);
+ CopyMem ((VOID *)Script, (VOID *)TempBootScriptEntry, ScriptHeader.Length);
SyncBootScript (Script);
@@ -2206,8 +2278,10 @@ S3BootScriptMoveLastOpcode (
if (Position != NULL) {
*Position = Script;
}
+
return RETURN_SUCCESS;
}
+
/**
Create a Label node in the boot script table.
@@ -2229,14 +2303,14 @@ S3BootScriptMoveLastOpcode (
RETURN_STATUS
EFIAPI
S3BootScriptLabelInternal (
- IN BOOLEAN BeforeOrAfter,
- IN OUT VOID **Position OPTIONAL,
- IN UINT32 InformationLength,
- IN CONST CHAR8 *Information
+ IN BOOLEAN BeforeOrAfter,
+ IN OUT VOID **Position OPTIONAL,
+ IN UINT32 InformationLength,
+ IN CONST CHAR8 *Information
)
{
- UINT8 Length;
- UINT8 *Script;
+ UINT8 Length;
+ UINT8 *Script;
EFI_BOOT_SCRIPT_INFORMATION ScriptInformation;
//
@@ -2245,29 +2319,30 @@ S3BootScriptLabelInternal (
if (InformationLength > MAX_UINT8 - sizeof (EFI_BOOT_SCRIPT_INFORMATION)) {
return RETURN_OUT_OF_RESOURCES;
}
+
Length = (UINT8)(sizeof (EFI_BOOT_SCRIPT_INFORMATION) + InformationLength);
Script = S3BootScriptGetEntryAddAddress (Length);
if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
//
// Build script data
//
- ScriptInformation.OpCode = S3_BOOT_SCRIPT_LIB_LABEL_OPCODE;
- ScriptInformation.Length = Length;
-
+ ScriptInformation.OpCode = S3_BOOT_SCRIPT_LIB_LABEL_OPCODE;
+ ScriptInformation.Length = Length;
ScriptInformation.InformationLength = InformationLength;
- CopyMem ((VOID*)Script, (VOID*)&ScriptInformation, sizeof (EFI_BOOT_SCRIPT_INFORMATION));
- CopyMem ((VOID*)(Script + sizeof (EFI_BOOT_SCRIPT_INFORMATION)), (VOID *) Information, (UINTN) InformationLength);
+ CopyMem ((VOID *)Script, (VOID *)&ScriptInformation, sizeof (EFI_BOOT_SCRIPT_INFORMATION));
+ CopyMem ((VOID *)(Script + sizeof (EFI_BOOT_SCRIPT_INFORMATION)), (VOID *)Information, (UINTN)InformationLength);
SyncBootScript (Script);
return S3BootScriptMoveLastOpcode (BeforeOrAfter, Position);
-
}
+
/**
Find a label within the boot script table and, if not present, optionally create it.
@@ -2293,24 +2368,26 @@ S3BootScriptLabelInternal (
RETURN_STATUS
EFIAPI
S3BootScriptLabel (
- IN BOOLEAN BeforeOrAfter,
- IN BOOLEAN CreateIfNotFound,
- IN OUT VOID **Position OPTIONAL,
- IN CONST CHAR8 *Label
+ IN BOOLEAN BeforeOrAfter,
+ IN BOOLEAN CreateIfNotFound,
+ IN OUT VOID **Position OPTIONAL,
+ IN CONST CHAR8 *Label
)
{
- UINT8* Script;
- UINTN StartAddress;
- UINT32 TableLength;
+ UINT8 *Script;
+ UINTN StartAddress;
+ UINT32 TableLength;
EFI_BOOT_SCRIPT_COMMON_HEADER ScriptHeader;
EFI_BOOT_SCRIPT_TABLE_HEADER TableHeader;
UINT32 LabelLength;
+
//
// Check NULL Label
//
if (Label == NULL) {
return EFI_INVALID_PARAMETER;
}
+
//
// Check empty Label
//
@@ -2332,27 +2409,29 @@ S3BootScriptLabel (
// Check the header and search for existing label.
//
Script = mS3BootScriptTablePtr->TableBase;
- CopyMem ((VOID*)&TableHeader, Script, sizeof(EFI_BOOT_SCRIPT_TABLE_HEADER));
+ CopyMem ((VOID *)&TableHeader, Script, sizeof (EFI_BOOT_SCRIPT_TABLE_HEADER));
if (TableHeader.OpCode != S3_BOOT_SCRIPT_LIB_TABLE_OPCODE) {
return EFI_INVALID_PARAMETER;
}
- StartAddress = (UINTN) Script;
- TableLength = mS3BootScriptTablePtr->TableLength;
- Script = Script + TableHeader.Length;
- while ((UINTN) Script < (UINTN) (StartAddress + TableLength)) {
- CopyMem ((VOID*)&ScriptHeader, Script, sizeof(EFI_BOOT_SCRIPT_COMMON_HEADER));
+ StartAddress = (UINTN)Script;
+ TableLength = mS3BootScriptTablePtr->TableLength;
+ Script = Script + TableHeader.Length;
+ while ((UINTN)Script < (UINTN)(StartAddress + TableLength)) {
+ CopyMem ((VOID *)&ScriptHeader, Script, sizeof (EFI_BOOT_SCRIPT_COMMON_HEADER));
if (ScriptHeader.OpCode == S3_BOOT_SCRIPT_LIB_LABEL_OPCODE) {
- if (AsciiStrCmp ((CHAR8 *)(UINTN)(Script+sizeof(EFI_BOOT_SCRIPT_INFORMATION)), Label) == 0) {
+ if (AsciiStrCmp ((CHAR8 *)(UINTN)(Script+sizeof (EFI_BOOT_SCRIPT_INFORMATION)), Label) == 0) {
(*Position) = Script;
return EFI_SUCCESS;
}
}
- Script = Script + ScriptHeader.Length;
+
+ Script = Script + ScriptHeader.Length;
}
+
if (CreateIfNotFound) {
- LabelLength = (UINT32)AsciiStrSize(Label);
- return S3BootScriptLabelInternal (BeforeOrAfter,Position, LabelLength, Label);
+ LabelLength = (UINT32)AsciiStrSize (Label);
+ return S3BootScriptLabelInternal (BeforeOrAfter, Position, LabelLength, Label);
} else {
return EFI_NOT_FOUND;
}
@@ -2375,13 +2454,13 @@ S3BootScriptLabel (
RETURN_STATUS
EFIAPI
S3BootScriptCompare (
- IN UINT8 *Position1,
- IN UINT8 *Position2,
- OUT UINTN *RelativePosition
+ IN UINT8 *Position1,
+ IN UINT8 *Position2,
+ OUT UINTN *RelativePosition
)
{
- UINT8* Script;
- UINT32 TableLength;
+ UINT8 *Script;
+ UINT32 TableLength;
if (RelativePosition == NULL) {
return EFI_INVALID_PARAMETER;
@@ -2394,19 +2473,22 @@ S3BootScriptCompare (
if (Script == NULL) {
return RETURN_OUT_OF_RESOURCES;
}
+
Script = mS3BootScriptTablePtr->TableBase;
//
// mS3BootScriptTablePtr->TableLength does not include the termination node, so add it up
//
TableLength = mS3BootScriptTablePtr->TableLength + sizeof (EFI_BOOT_SCRIPT_TERMINATE);
- if (Position1 < Script || Position1 > Script+TableLength) {
+ if ((Position1 < Script) || (Position1 > Script+TableLength)) {
return EFI_INVALID_PARAMETER;
}
- if (Position2 < Script || Position2 > Script+TableLength) {
+
+ if ((Position2 < Script) || (Position2 > Script+TableLength)) {
return EFI_INVALID_PARAMETER;
}
- *RelativePosition = (Position1 < Position2)?-1:((Position1 == Position2)?0:1);
+
+ *RelativePosition = (Position1 < Position2) ? -1 : ((Position1 == Position2) ? 0 : 1);
return EFI_SUCCESS;
}
diff --git a/MdeModulePkg/Library/PiDxeS3BootScriptLib/InternalBootScriptLib.h b/MdeModulePkg/Library/PiDxeS3BootScriptLib/InternalBootScriptLib.h
index 9485994087..b443aec08e 100644
--- a/MdeModulePkg/Library/PiDxeS3BootScriptLib/InternalBootScriptLib.h
+++ b/MdeModulePkg/Library/PiDxeS3BootScriptLib/InternalBootScriptLib.h
@@ -7,6 +7,7 @@
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
+
#ifndef __INTERNAL_BOOT_SCRIPT_LIB__
#define __INTERNAL_BOOT_SCRIPT_LIB__
@@ -35,12 +36,12 @@
#include "BootScriptInternalFormat.h"
-#define MAX_IO_ADDRESS 0xFFFF
+#define MAX_IO_ADDRESS 0xFFFF
//
// Macro to convert a UEFI PCI address + segment to a PCI Segment Library PCI address
//
-#define PCI_ADDRESS_ENCODE(S, A) PCI_SEGMENT_LIB_ADDRESS( \
+#define PCI_ADDRESS_ENCODE(S, A) PCI_SEGMENT_LIB_ADDRESS(\
S, \
((((UINTN)(A)) & 0xff000000) >> 24), \
((((UINTN)(A)) & 0x00ff0000) >> 16), \
@@ -49,57 +50,54 @@
)
typedef union {
- UINT8 volatile *Buf;
- UINT8 volatile *Uint8;
- UINT16 volatile *Uint16;
- UINT32 volatile *Uint32;
- UINT64 volatile *Uint64;
- UINTN volatile Uint;
+ UINT8 volatile *Buf;
+ UINT8 volatile *Uint8;
+ UINT16 volatile *Uint16;
+ UINT32 volatile *Uint32;
+ UINT64 volatile *Uint64;
+ UINTN volatile Uint;
} PTR;
-
// Minimum and maximum length for SMBus bus block protocols defined in SMBus spec 2.0.
//
-#define MIN_SMBUS_BLOCK_LEN 1
-#define MAX_SMBUS_BLOCK_LEN 32
+#define MIN_SMBUS_BLOCK_LEN 1
+#define MAX_SMBUS_BLOCK_LEN 32
//
// The boot script private data.
//
typedef struct {
- UINT8 *TableBase;
- UINT32 TableLength; // Record the actual memory length
- UINT16 TableMemoryPageNumber; // Record the page number Allocated for the table
- BOOLEAN InSmm; // Record if this library is in SMM.
- BOOLEAN AtRuntime; // Record if current state is after SmmExitBootServices or SmmLegacyBoot.
- UINT32 BootTimeScriptLength; // Maintain boot time script length in LockBox after SmmReadyToLock in SMM.
- BOOLEAN SmmLocked; // Record if current state is after SmmReadyToLock
- BOOLEAN BackFromS3; // Indicate that the system is back from S3.
+ UINT8 *TableBase;
+ UINT32 TableLength; // Record the actual memory length
+ UINT16 TableMemoryPageNumber; // Record the page number Allocated for the table
+ BOOLEAN InSmm; // Record if this library is in SMM.
+ BOOLEAN AtRuntime; // Record if current state is after SmmExitBootServices or SmmLegacyBoot.
+ UINT32 BootTimeScriptLength; // Maintain boot time script length in LockBox after SmmReadyToLock in SMM.
+ BOOLEAN SmmLocked; // Record if current state is after SmmReadyToLock
+ BOOLEAN BackFromS3; // Indicate that the system is back from S3.
} SCRIPT_TABLE_PRIVATE_DATA;
typedef
EFI_STATUS
-(EFIAPI *DISPATCH_ENTRYPOINT_FUNC) (
+(EFIAPI *DISPATCH_ENTRYPOINT_FUNC)(
IN EFI_HANDLE ImageHandle,
IN VOID *Context
);
-extern SCRIPT_TABLE_PRIVATE_DATA *mS3BootScriptTablePtr;
+extern SCRIPT_TABLE_PRIVATE_DATA *mS3BootScriptTablePtr;
//
// Define Opcode for Label which is implementation specific and no standard spec define.
//
-#define S3_BOOT_SCRIPT_LIB_LABEL_OPCODE 0xFE
+#define S3_BOOT_SCRIPT_LIB_LABEL_OPCODE 0xFE
///
/// The opcode indicate the start of the boot script table.
///
-#define S3_BOOT_SCRIPT_LIB_TABLE_OPCODE 0xAA
+#define S3_BOOT_SCRIPT_LIB_TABLE_OPCODE 0xAA
///
/// The opcode indicate the end of the boot script table.
///
-#define S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE 0xFF
-
+#define S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE 0xFF
#endif //__INTERNAL_BOOT_SCRIPT_LIB__
-