/** @file\r
Interpret and execute the S3 data in S3 boot script. \r
\r
- Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.<BR>\r
\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions\r
**/\r
#include "InternalBootScriptLib.h"\r
\r
-/**\r
- Checks the parameter of SmbusExecute().\r
-\r
- This function checks the input parameters of SmbusExecute(). If the input parameters are valid\r
- for certain SMBus bus protocol, it will return EFI_SUCCESS; otherwise, it will return certain\r
- error code based on the input SMBus bus protocol.\r
-\r
- @param SmBusAddress Address that encodes the SMBUS Slave Address, SMBUS Command, SMBUS Data Length, \r
- and PEC.\r
- @param Operation Signifies which particular SMBus hardware protocol instance that\r
- it will use to execute the SMBus transactions. This SMBus\r
- hardware protocol is defined by the SMBus Specification and is\r
- not related to EFI.\r
- @param Length Signifies the number of bytes that this operation will do. The\r
- maximum number of bytes can be revision specific and operation\r
- specific. This field will contain the actual number of bytes that\r
- are executed for this operation. Not all operations require this\r
- argument.\r
- @param Buffer Contains the value of data to execute to the SMBus slave device.\r
- Not all operations require this argument. The length of this\r
- buffer is identified by Length.\r
-\r
- @retval EFI_SUCCESS All the parameters are valid for the corresponding SMBus bus\r
- protocol. \r
- @retval EFI_INVALID_PARAMETER Operation is not defined in EFI_SMBUS_OPERATION.\r
- @retval EFI_INVALID_PARAMETER Length/Buffer is NULL for operations except for EfiSmbusQuickRead\r
- and EfiSmbusQuickWrite. Length is outside the range of valid\r
- values.\r
- @retval EFI_UNSUPPORTED The SMBus operation or PEC is not supported.\r
- @retval EFI_BUFFER_TOO_SMALL Buffer is not sufficient for this operation.\r
-\r
-**/\r
-EFI_STATUS\r
-CheckParameters (\r
- IN UINTN SmBusAddress,\r
- IN EFI_SMBUS_OPERATION Operation,\r
- IN OUT UINTN *Length,\r
- IN OUT VOID *Buffer\r
- )\r
-{\r
- EFI_STATUS Status;\r
- UINTN RequiredLen;\r
- EFI_SMBUS_DEVICE_COMMAND Command;\r
- BOOLEAN PecCheck;\r
- \r
- Command = SMBUS_LIB_COMMAND (SmBusAddress);\r
- PecCheck = SMBUS_LIB_PEC (SmBusAddress);\r
- //\r
- // Set default value to be 2:\r
- // for SmbusReadWord, SmbusWriteWord and SmbusProcessCall. \r
- //\r
- RequiredLen = 2;\r
- Status = EFI_SUCCESS;\r
- switch (Operation) {\r
- case EfiSmbusQuickRead:\r
- case EfiSmbusQuickWrite:\r
- if (PecCheck || Command != 0) {\r
- return EFI_UNSUPPORTED;\r
- }\r
- break;\r
- case EfiSmbusReceiveByte:\r
- case EfiSmbusSendByte:\r
- if (Command != 0) {\r
- return EFI_UNSUPPORTED;\r
- }\r
- //\r
- // Cascade to check length parameter.\r
- //\r
- case EfiSmbusReadByte:\r
- case EfiSmbusWriteByte:\r
- RequiredLen = 1;\r
- //\r
- // Cascade to check length parameter.\r
- //\r
- case EfiSmbusReadWord:\r
- case EfiSmbusWriteWord:\r
- case EfiSmbusProcessCall:\r
- if (Buffer == NULL || Length == NULL) {\r
- return EFI_INVALID_PARAMETER;\r
- } else if (*Length < RequiredLen) {\r
- Status = EFI_BUFFER_TOO_SMALL;\r
- }\r
- *Length = RequiredLen;\r
- break;\r
- case EfiSmbusReadBlock:\r
- case EfiSmbusWriteBlock:\r
- if ((Buffer == NULL) || \r
- (Length == NULL) || \r
- (*Length < MIN_SMBUS_BLOCK_LEN) ||\r
- (*Length > MAX_SMBUS_BLOCK_LEN)) {\r
- return EFI_INVALID_PARAMETER;\r
- } \r
- break;\r
- case EfiSmbusBWBRProcessCall:\r
- return EFI_UNSUPPORTED;\r
- default:\r
- return EFI_INVALID_PARAMETER;\r
- }\r
- return Status;\r
-}\r
-\r
/**\r
Executes an SMBus operation to an SMBus controller. Returns when either the command has been\r
executed or an error is encountered in doing the operation.\r
)\r
{\r
EFI_STATUS Status;\r
- UINTN WorkBufferLen;\r
UINT8 WorkBuffer[MAX_SMBUS_BLOCK_LEN];\r
\r
- Status = CheckParameters (SmbusAddress, Operation, Length, Buffer);\r
- if (EFI_ERROR (Status)) {\r
- return Status;\r
- }\r
-\r
switch (Operation) {\r
case EfiSmbusQuickRead:\r
DEBUG ((EFI_D_INFO, "EfiSmbusQuickRead - 0x%08x\n", SmbusAddress));\r
break;\r
case EfiSmbusReceiveByte:\r
DEBUG ((EFI_D_INFO, "EfiSmbusReceiveByte - 0x%08x\n", SmbusAddress));\r
- *(UINT8 *) Buffer = SmBusReceiveByte (SmbusAddress, &Status);\r
+ SmBusReceiveByte (SmbusAddress, &Status);\r
break;\r
case EfiSmbusSendByte:\r
- DEBUG ((EFI_D_INFO, "EfiSmbusReceiveByte - 0x%08x (0x%02x)\n", SmbusAddress, (UINTN)*(UINT8 *) Buffer));\r
+ DEBUG ((EFI_D_INFO, "EfiSmbusSendByte - 0x%08x (0x%02x)\n", SmbusAddress, (UINTN)*(UINT8 *) Buffer));\r
SmBusSendByte (SmbusAddress, *(UINT8 *) Buffer, &Status);\r
break;\r
case EfiSmbusReadByte:\r
DEBUG ((EFI_D_INFO, "EfiSmbusReadByte - 0x%08x\n", SmbusAddress));\r
- *(UINT8 *) Buffer = SmBusReadDataByte (SmbusAddress, &Status);\r
+ SmBusReadDataByte (SmbusAddress, &Status);\r
break;\r
case EfiSmbusWriteByte:\r
DEBUG ((EFI_D_INFO, "EfiSmbusWriteByte - 0x%08x (0x%02x)\n", SmbusAddress, (UINTN)*(UINT8 *) Buffer));\r
break;\r
case EfiSmbusReadWord:\r
DEBUG ((EFI_D_INFO, "EfiSmbusReadWord - 0x%08x\n", SmbusAddress));\r
- *(UINT16 *) Buffer = SmBusReadDataWord (SmbusAddress, &Status);\r
+ SmBusReadDataWord (SmbusAddress, &Status);\r
break;\r
case EfiSmbusWriteWord:\r
- DEBUG ((EFI_D_INFO, "EfiSmbusWriteByte - 0x%08x (0x%04x)\n", SmbusAddress, (UINTN)*(UINT16 *) Buffer));\r
+ DEBUG ((EFI_D_INFO, "EfiSmbusWriteWord - 0x%08x (0x%04x)\n", SmbusAddress, (UINTN)*(UINT16 *) Buffer));\r
SmBusWriteDataWord (SmbusAddress, *(UINT16 *) Buffer, &Status);\r
break;\r
case EfiSmbusProcessCall:\r
DEBUG ((EFI_D_INFO, "EfiSmbusProcessCall - 0x%08x (0x%04x)\n", SmbusAddress, (UINTN)*(UINT16 *) Buffer));\r
- *(UINT16 *) Buffer = SmBusProcessCall (SmbusAddress, *(UINT16 *) Buffer, &Status);\r
+ SmBusProcessCall (SmbusAddress, *(UINT16 *) Buffer, &Status);\r
break;\r
case EfiSmbusReadBlock:\r
DEBUG ((EFI_D_INFO, "EfiSmbusReadBlock - 0x%08x\n", SmbusAddress));\r
- WorkBufferLen = SmBusReadBlock (SmbusAddress, WorkBuffer, &Status);\r
- if (!EFI_ERROR (Status)) {\r
- //\r
- // Read block transaction is complete successfully, and then\r
- // check whether the output buffer is large enough. \r
- //\r
- if (*Length >= WorkBufferLen) {\r
- CopyMem (Buffer, WorkBuffer, WorkBufferLen);\r
- } else {\r
- Status = EFI_BUFFER_TOO_SMALL;\r
- }\r
- *Length = WorkBufferLen;\r
- }\r
+ SmBusReadBlock (SmbusAddress, WorkBuffer, &Status);\r
break;\r
case EfiSmbusWriteBlock:\r
- DEBUG ((EFI_D_INFO, "EfiSmbusWriteBlock - 0x%08x (0x%04x)\n", SmbusAddress, (UINTN)*(UINT16 *) Buffer));\r
- SmBusWriteBlock ((SmbusAddress + SMBUS_LIB_ADDRESS (0, 0, (*Length), FALSE)) , Buffer, &Status);\r
+ DEBUG ((EFI_D_INFO, "EfiSmbusWriteBlock - 0x%08x\n", SmbusAddress));\r
+ SmBusWriteBlock ((SmbusAddress + SMBUS_LIB_ADDRESS (0, 0, (*Length), FALSE)), Buffer, &Status);\r
break;\r
case EfiSmbusBWBRProcessCall:\r
- //\r
- // BUGBUG: Should this case be handled?\r
- //\r
+ DEBUG ((EFI_D_INFO, "EfiSmbusBWBRProcessCall - 0x%08x\n", SmbusAddress));\r
+ SmBusBlockProcessCall ((SmbusAddress + SMBUS_LIB_ADDRESS (0, 0, (*Length), FALSE)), Buffer, WorkBuffer, &Status);\r
break;\r
+ default:\r
+ return EFI_INVALID_PARAMETER;\r
}\r
\r
return Status; \r
}\r
\r
/**\r
- Translates boot script to MDE library interface.\r
+ Perform IO read operation\r
\r
@param[in] Width Width of the operation.\r
@param[in] Address Address of the operation.\r
switch (Width) {\r
\r
case S3BootScriptWidthUint8:\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint8 - 0x%08x\n", (UINTN) Address));\r
+ *Out.Uint8 = IoRead8 ((UINTN) Address);\r
+ break;\r
case S3BootScriptWidthFifoUint8:\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x\n", (UINTN) Address));\r
+ *Out.Uint8 = IoRead8 ((UINTN) Address);\r
+ break;\r
case S3BootScriptWidthFillUint8:\r
- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint8Read - 0x%08x\n", Address));\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%08x\n", (UINTN) Address));\r
*Out.Uint8 = IoRead8 ((UINTN) Address);\r
break;\r
\r
case S3BootScriptWidthUint16:\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint16 - 0x%08x\n", (UINTN) Address));\r
+ *Out.Uint16 = IoRead16 ((UINTN) Address);\r
+ break;\r
case S3BootScriptWidthFifoUint16:\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint16 - 0x%08x\n", (UINTN) Address));\r
+ *Out.Uint16 = IoRead16 ((UINTN) Address);\r
+ break;\r
case S3BootScriptWidthFillUint16:\r
- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint16Read - 0x%08x\n", Address));\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint16 - 0x%08x\n", (UINTN) Address));\r
*Out.Uint16 = IoRead16 ((UINTN) Address);\r
break;\r
\r
case S3BootScriptWidthUint32:\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint32 - 0x%08x\n", (UINTN) Address));\r
+ *Out.Uint32 = IoRead32 ((UINTN) Address);\r
+ break;\r
case S3BootScriptWidthFifoUint32:\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint32 - 0x%08x\n", (UINTN) Address));\r
+ *Out.Uint32 = IoRead32 ((UINTN) Address);\r
+ break;\r
case S3BootScriptWidthFillUint32:\r
- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint32Read - 0x%08x\n", Address));\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint32 - 0x%08x\n", (UINTN) Address));\r
*Out.Uint32 = IoRead32 ((UINTN) Address);\r
break;\r
\r
+ case S3BootScriptWidthUint64:\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint64 - 0x%08x\n", (UINTN) Address));\r
+ *Out.Uint64 = IoRead64 ((UINTN) Address);\r
+ break;\r
+ case S3BootScriptWidthFifoUint64:\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint64 - 0x%08x\n", (UINTN) Address));\r
+ *Out.Uint64 = IoRead64 ((UINTN) Address);\r
+ break;\r
+ case S3BootScriptWidthFillUint64:\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint64 - 0x%08x\n", (UINTN) Address));\r
+ *Out.Uint64 = IoRead64 ((UINTN) Address);\r
+ break;\r
+\r
default:\r
return EFI_INVALID_PARAMETER;\r
}\r
}\r
\r
/**\r
- Perform a write operation\r
+ Perform IO write operation\r
\r
@param[in] Width Width of the operation.\r
@param[in] Address Address of the operation.\r
IoWrite8 ((UINTN) OriginalAddress, *In.Uint8);\r
break; \r
case S3BootScriptWidthFillUint8:\r
- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%08x (0x%02x)\n", (UINTN)Address, (UINTN)*In.Uint8));\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%08x (0x%02x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint8));\r
IoWrite8 ((UINTN) Address, *OriginalIn.Uint8);\r
break;\r
case S3BootScriptWidthUint16:\r
IoWrite16 ((UINTN) OriginalAddress, *In.Uint16);\r
break; \r
case S3BootScriptWidthFillUint16:\r
- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint16 - 0x%08x (0x%04x)\n", (UINTN)Address, (UINTN)*In.Uint16));\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint16 - 0x%08x (0x%04x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint16));\r
IoWrite16 ((UINTN) Address, *OriginalIn.Uint16);\r
break;\r
case S3BootScriptWidthUint32:\r
IoWrite32 ((UINTN) OriginalAddress, *In.Uint32);\r
break;\r
case S3BootScriptWidthFillUint32:\r
- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint32 - 0x%08x (0x%08x)\n", (UINTN)Address, (UINTN)*In.Uint32));\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint32 - 0x%08x (0x%08x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint32));\r
IoWrite32 ((UINTN) Address, *OriginalIn.Uint32);\r
break;\r
case S3BootScriptWidthUint64:\r
IoWrite64 ((UINTN) Address, *In.Uint64);\r
break; \r
case S3BootScriptWidthFifoUint64:\r
- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint64 - 0x%08x (0x%016lx)\n", (UINTN)Address, *In.Uint64));\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint64 - 0x%08x (0x%016lx)\n", (UINTN)OriginalAddress, *In.Uint64));\r
IoWrite64 ((UINTN) OriginalAddress, *In.Uint64);\r
break; \r
case S3BootScriptWidthFillUint64:\r
- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint64 - 0x%08x (0x%016lx)\n", (UINTN)Address, *In.Uint64));\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint64 - 0x%08x (0x%016lx)\n", (UINTN)Address, *OriginalIn.Uint64));\r
IoWrite64 ((UINTN) Address, *OriginalIn.Uint64);\r
break;\r
default:\r
return EFI_SUCCESS;\r
}\r
/**\r
- Interprete the IO write entry in S3 boot script and perform the write operation\r
+ Interprete the boot script node with EFI_BOOT_SCRIPT_IO_WRITE OP code.\r
\r
@param Script Pointer to the node which is to be interpreted.\r
\r
Address = IoWrite.Address;\r
Count = IoWrite.Count;\r
Buffer = Script + sizeof (EFI_BOOT_SCRIPT_IO_WRITE);\r
- \r
+\r
+ DEBUG ((EFI_D_INFO, "BootScriptExecuteIoWrite - 0x%08x, 0x%08x, 0x%08x\n", (UINTN)Address, Count, (UINTN)Width));\r
return ScriptIoWrite(Width, Address, Count, Buffer);\r
}\r
/**\r
for (; Count > 0; Count--, Address += AddressStride, Out.Buf += BufferStride) {\r
switch (Width) {\r
case S3BootScriptWidthUint8:\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint8 - 0x%08x\n", (UINTN)Address));\r
+ *Out.Uint8 = MmioRead8 ((UINTN) Address);\r
+ break;\r
case S3BootScriptWidthFifoUint8:\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x\n", (UINTN)Address));\r
+ *Out.Uint8 = MmioRead8 ((UINTN) Address);\r
+ break;\r
case S3BootScriptWidthFillUint8:\r
- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint8 - 0x%08x\n", (UINTN)Address));\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%08x\n", (UINTN)Address));\r
*Out.Uint8 = MmioRead8 ((UINTN) Address);\r
break;\r
\r
case S3BootScriptWidthUint16:\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint16 - 0x%08x\n", (UINTN)Address));\r
+ *Out.Uint16 = MmioRead16 ((UINTN) Address);\r
+ break;\r
case S3BootScriptWidthFifoUint16:\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint16 - 0x%08x\n", (UINTN)Address));\r
+ *Out.Uint16 = MmioRead16 ((UINTN) Address);\r
+ break;\r
case S3BootScriptWidthFillUint16:\r
- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint16 - 0x%08x\n", (UINTN)Address));\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint16 - 0x%08x\n", (UINTN)Address));\r
*Out.Uint16 = MmioRead16 ((UINTN) Address);\r
break;\r
\r
case S3BootScriptWidthUint32:\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint32 - 0x%08x\n", (UINTN)Address));\r
+ *Out.Uint32 = MmioRead32 ((UINTN) Address);\r
+ break;\r
case S3BootScriptWidthFifoUint32:\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint32 - 0x%08x\n", (UINTN)Address));\r
+ *Out.Uint32 = MmioRead32 ((UINTN) Address);\r
+ break;\r
case S3BootScriptWidthFillUint32:\r
- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint32 - 0x%08x\n", (UINTN)Address));\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint32 - 0x%08x\n", (UINTN)Address));\r
*Out.Uint32 = MmioRead32 ((UINTN) Address);\r
break;\r
\r
case S3BootScriptWidthUint64:\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint64 - 0x%08x\n", (UINTN)Address));\r
+ *Out.Uint64 = MmioRead64 ((UINTN) Address);\r
+ break;\r
case S3BootScriptWidthFifoUint64:\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint64 - 0x%08x\n", (UINTN)Address));\r
+ *Out.Uint64 = MmioRead64 ((UINTN) Address);\r
+ break;\r
case S3BootScriptWidthFillUint64:\r
- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint64 - 0x%08x\n", (UINTN)Address));\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint64 - 0x%08x\n", (UINTN)Address));\r
*Out.Uint64 = MmioRead64 ((UINTN) Address);\r
break;\r
\r
return EFI_SUCCESS;\r
}\r
/**\r
- Translates boot script to MDE library interface.\r
+ Perform memory write operation\r
\r
@param Width Width of the operation.\r
@param Address Address of the operation.\r
MmioWrite8 ((UINTN) OriginalAddress, *In.Uint8);\r
break; \r
case S3BootScriptWidthFillUint8:\r
- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%08x (0x%02x)\n", (UINTN)Address, (UINTN)*In.Uint8));\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%08x (0x%02x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint8));\r
MmioWrite8 ((UINTN) Address, *OriginalIn.Uint8);\r
break;\r
case S3BootScriptWidthUint16:\r
MmioWrite16 ((UINTN) OriginalAddress, *In.Uint16);\r
break; \r
case S3BootScriptWidthFillUint16:\r
- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint16 - 0x%08x (0x%04x)\n", (UINTN)Address, (UINTN)*In.Uint16));\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint16 - 0x%08x (0x%04x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint16));\r
MmioWrite16 ((UINTN) Address, *OriginalIn.Uint16);\r
break;\r
case S3BootScriptWidthUint32:\r
MmioWrite32 ((UINTN) OriginalAddress, *In.Uint32);\r
break; \r
case S3BootScriptWidthFillUint32:\r
- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint32 - 0x%08x (0x%08x)\n", (UINTN)Address, (UINTN)*In.Uint32));\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint32 - 0x%08x (0x%08x)\n", (UINTN)Address, (UINTN)*OriginalIn.Uint32));\r
MmioWrite32 ((UINTN) Address, *OriginalIn.Uint32);\r
break;\r
case S3BootScriptWidthUint64:\r
MmioWrite64 ((UINTN) OriginalAddress, *In.Uint64);\r
break; \r
case S3BootScriptWidthFillUint64:\r
- DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint64 - 0x%08x (0x%016lx)\n", (UINTN)Address, *In.Uint64));\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint64 - 0x%08x (0x%016lx)\n", (UINTN)Address, *OriginalIn.Uint64));\r
MmioWrite64 ((UINTN) Address, *OriginalIn.Uint64);\r
break;\r
default:\r
Count = MemWrite.Count;\r
Buffer = Script + sizeof(EFI_BOOT_SCRIPT_MEM_WRITE);\r
\r
- DEBUG ((EFI_D_INFO, "BootScriptExecuteMemoryWrite - 0x%08x, 0x%08x, 0x%08x\n", (UINTN)Address, (UINTN)Count, (UINTN)Width));\r
+ DEBUG ((EFI_D_INFO, "BootScriptExecuteMemoryWrite - 0x%08x, 0x%08x, 0x%08x\n", (UINTN)Address, Count, (UINTN)Width));\r
return ScriptMemoryWrite (Width,Address, Count, Buffer);\r
\r
} \r
/**\r
- Translates boot script to MDE library interface for PCI configuration read operation\r
+ Performance PCI configuration read operation\r
\r
@param Width Width of the operation.\r
@param Address Address of the operation.\r
- @param Buffer Pointer to the buffer reaf from PCI config space\r
+ @param Count Count of the number of accesses to perform.\r
+ @param Buffer Pointer to the buffer read from PCI config space\r
\r
@retval EFI_SUCCESS The read succeed.\r
@retval EFI_INVALID_PARAMETER if Width is not defined \r
- \r
+ @note A known Limitations in the implementation which is 64bits operations are not supported.\r
+\r
**/\r
EFI_STATUS\r
ScriptPciCfgRead (\r
IN S3_BOOT_SCRIPT_LIB_WIDTH Width,\r
IN UINT64 Address,\r
+ IN UINTN Count,\r
OUT VOID *Buffer\r
)\r
{\r
+ EFI_STATUS Status;\r
+ UINTN AddressStride;\r
+ UINTN BufferStride;\r
+ PTR Out;\r
+ UINTN PciAddress;\r
+\r
+ Out.Buf = (UINT8 *) Buffer;\r
+\r
+ PciAddress = PCI_ADDRESS_ENCODE (Address);\r
+\r
+ Status = BuildLoopData (Width, PciAddress, &AddressStride, &BufferStride);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+ //\r
+ // Loop for each iteration and move the data\r
+ //\r
+ for (; Count > 0; Count--, PciAddress += AddressStride, Out.Buf += BufferStride) {\r
switch (Width) {\r
case S3BootScriptWidthUint8:\r
- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint8 - 0x%016lx\n", Address));\r
- * (UINT8 *) Buffer = PciRead8 (PCI_ADDRESS_ENCODE(Address));\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint8 - 0x%08x\n", PciAddress));\r
+ *Out.Uint8 = PciRead8 (PciAddress);\r
+ break;\r
+ case S3BootScriptWidthFifoUint8:\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x\n", PciAddress));\r
+ *Out.Uint8 = PciRead8 (PciAddress);\r
+ break;\r
+ case S3BootScriptWidthFillUint8:\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%08x\n", PciAddress));\r
+ *Out.Uint8 = PciRead8 (PciAddress);\r
break;\r
\r
case S3BootScriptWidthUint16:\r
- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint16 - 0x%016lx\n", Address));\r
- * (UINT16 *) Buffer = PciRead16 (PCI_ADDRESS_ENCODE(Address));\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint16 - 0x%08x\n", PciAddress));\r
+ *Out.Uint16 = PciRead16 (PciAddress);\r
+ break;\r
+ case S3BootScriptWidthFifoUint16:\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint16 - 0x%08x\n", PciAddress));\r
+ *Out.Uint16 = PciRead16 (PciAddress);\r
+ break;\r
+ case S3BootScriptWidthFillUint16:\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint16 - 0x%08x\n", PciAddress));\r
+ *Out.Uint16 = PciRead16 (PciAddress);\r
break;\r
\r
case S3BootScriptWidthUint32:\r
- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint32 - 0x%016lx\n", Address));\r
- * (UINT32 *) Buffer = PciRead32 (PCI_ADDRESS_ENCODE(Address));\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint32 - 0x%08x\n", PciAddress));\r
+ *Out.Uint32 = PciRead32 (PciAddress);\r
+ break;\r
+ case S3BootScriptWidthFifoUint32:\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint32 - 0x%08x\n", PciAddress));\r
+ *Out.Uint32 = PciRead32 (PciAddress);\r
+ break;\r
+ case S3BootScriptWidthFillUint32:\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint32 - 0x%08x\n", PciAddress));\r
+ *Out.Uint32 = PciRead32 (PciAddress);\r
break;\r
\r
default:\r
return EFI_INVALID_PARAMETER;\r
+ }\r
}\r
- return EFI_SUCCESS;\r
+ return EFI_SUCCESS;\r
}\r
\r
/**\r
- Translates boot script to MDE library interface for PCI configuration write operation\r
+ Performance PCI configuration write operation\r
\r
@param Width Width of the operation.\r
@param Address Address of the operation.\r
- @param Buffer Pointer to the buffer reaf from PCI config space\r
+ @param Count Count of the number of accesses to perform.\r
+ @param Buffer Pointer to the buffer write to PCI config space\r
\r
@retval EFI_SUCCESS The write succeed.\r
@retval EFI_INVALID_PARAMETER if Width is not defined \r
- \r
+ @note A known Limitations in the implementation which is 64bits operations are not supported.\r
+\r
**/\r
EFI_STATUS\r
ScriptPciCfgWrite (\r
IN S3_BOOT_SCRIPT_LIB_WIDTH Width,\r
IN UINT64 Address,\r
- OUT VOID *Buffer\r
+ IN UINTN Count,\r
+ IN VOID *Buffer\r
)\r
{\r
- switch (Width) {\r
- case S3BootScriptWidthUint8:\r
- case S3BootScriptWidthFifoUint8:\r
- case S3BootScriptWidthFillUint8: \r
- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint8 - 0x%016lx (0x%02x)\n", Address, (UINTN)*(UINT8 *) Buffer));\r
- PciWrite8 (PCI_ADDRESS_ENCODE(Address), *(UINT8 *) Buffer);\r
- break;\r
- case S3BootScriptWidthUint16:\r
- case S3BootScriptWidthFifoUint16:\r
- case S3BootScriptWidthFillUint16: \r
- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint16 - 0x%016lx (0x%04x)\n", Address, (UINTN)*(UINT16 *) Buffer));\r
- PciWrite16 (PCI_ADDRESS_ENCODE(Address), *(UINT16 *) Buffer);\r
- break;\r
- case S3BootScriptWidthUint32:\r
- case S3BootScriptWidthFifoUint32:\r
- case S3BootScriptWidthFillUint32: \r
- DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint32 - 0x%016lx (0x%08x)\n", Address, (UINTN)*(UINT32 *) Buffer));\r
- PciWrite32 (PCI_ADDRESS_ENCODE(Address), *(UINT32 *) Buffer);\r
- break;\r
- default:\r
- return EFI_INVALID_PARAMETER;\r
+ EFI_STATUS Status;\r
+ UINTN AddressStride;\r
+ UINTN BufferStride;\r
+ UINTN OriginalPciAddress;\r
+ PTR In;\r
+ PTR OriginalIn;\r
+ UINTN PciAddress;\r
+\r
+ In.Buf = (UINT8 *) Buffer;\r
+\r
+ PciAddress = PCI_ADDRESS_ENCODE (Address);\r
+\r
+ Status = BuildLoopData (Width, PciAddress, &AddressStride, &BufferStride);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
}\r
- return EFI_SUCCESS;\r
+ //\r
+ // Loop for each iteration and move the data\r
+ //\r
+ OriginalPciAddress = PciAddress;\r
+ OriginalIn.Buf = In.Buf;\r
+ for (; Count > 0; Count--, PciAddress += AddressStride, In.Buf += BufferStride) {\r
+ switch (Width) {\r
+ case S3BootScriptWidthUint8:\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint8 - 0x%08x (0x%02x)\n", PciAddress, (UINTN)*In.Uint8));\r
+ PciWrite8 (PciAddress, *In.Uint8);\r
+ break; \r
+ case S3BootScriptWidthFifoUint8:\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint8 - 0x%08x (0x%02x)\n", OriginalPciAddress, (UINTN)*In.Uint8));\r
+ PciWrite8 (OriginalPciAddress, *In.Uint8);\r
+ break; \r
+ case S3BootScriptWidthFillUint8:\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint8 - 0x%08x (0x%02x)\n", PciAddress, (UINTN)*OriginalIn.Uint8));\r
+ PciWrite8 (PciAddress, *OriginalIn.Uint8);\r
+ break;\r
+ case S3BootScriptWidthUint16:\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint16 - 0x%08x (0x%04x)\n", PciAddress, (UINTN)*In.Uint16));\r
+ PciWrite16 (PciAddress, *In.Uint16);\r
+ break; \r
+ case S3BootScriptWidthFifoUint16:\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint16 - 0x%08x (0x%04x)\n", OriginalPciAddress, (UINTN)*In.Uint16));\r
+ PciWrite16 (OriginalPciAddress, *In.Uint16);\r
+ break; \r
+ case S3BootScriptWidthFillUint16:\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint16 - 0x%08x (0x%04x)\n", PciAddress, (UINTN)*OriginalIn.Uint16));\r
+ PciWrite16 (PciAddress, *OriginalIn.Uint16);\r
+ break;\r
+ case S3BootScriptWidthUint32:\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthUint32 - 0x%08x (0x%08x)\n", PciAddress, (UINTN)*In.Uint32));\r
+ PciWrite32 (PciAddress, *In.Uint32);\r
+ break; \r
+ case S3BootScriptWidthFifoUint32:\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFifoUint32 - 0x%08x (0x%08x)\n", OriginalPciAddress, (UINTN)*In.Uint32));\r
+ PciWrite32 (OriginalPciAddress, *In.Uint32);\r
+ break; \r
+ case S3BootScriptWidthFillUint32:\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptWidthFillUint32 - 0x%08x (0x%08x)\n", (UINTN)PciAddress, (UINTN)*OriginalIn.Uint32));\r
+ PciWrite32 (PciAddress, *OriginalIn.Uint32);\r
+ break;\r
+ default:\r
+ return EFI_INVALID_PARAMETER;\r
+ }\r
+ }\r
+ return EFI_SUCCESS;\r
}\r
/**\r
- Perform pci configure 2 read operation.\r
+ Performance PCI configuration 2 read operation\r
\r
@param Width Width of the operation.\r
@param Segment Pci segment number\r
@param Address Address of the operation.\r
- @param Buffer Pointer to the buffer to write to I/O space. \r
+ @param Count Count of the number of accesses to perform.\r
+ @param Buffer Pointer to the buffer to read from PCI config space.\r
\r
@retval EFI_SUCCESS The data was written to the EFI System.\r
@retval EFI_INVALID_PARAMETER Width is invalid for this EFI System.\r
IN S3_BOOT_SCRIPT_LIB_WIDTH Width,\r
IN UINT16 Segment, \r
IN UINT64 Address,\r
+ IN UINTN Count,\r
OUT VOID *Buffer\r
)\r
{\r
ASSERT (Segment==0);\r
\r
- return ScriptPciCfgRead (Width, Address, Buffer);\r
+ return ScriptPciCfgRead (Width, Address, Count, Buffer);\r
}\r
/**\r
- Perform pci configure write operation.\r
+ Performance PCI configuration 2 write operation\r
\r
@param Width Width of the operation.\r
@param Segment Pci segment number\r
@param Address Address of the operation.\r
- @param Buffer Pointer to the buffer to write to I/O space. \r
+ @param Count Count of the number of accesses to perform.\r
+ @param Buffer Pointer to the buffer to write to PCI config space.\r
\r
@retval EFI_SUCCESS The data was written to the EFI System.\r
@retval EFI_INVALID_PARAMETER Width is invalid for this EFI System.\r
IN S3_BOOT_SCRIPT_LIB_WIDTH Width,\r
IN UINT16 Segment, \r
IN UINT64 Address,\r
- OUT VOID *Buffer\r
+ IN UINTN Count,\r
+ IN VOID *Buffer\r
)\r
{\r
ASSERT (Segment==0);\r
- return ScriptPciCfgWrite (Width, Address, Buffer);\r
+ return ScriptPciCfgWrite (Width, Address, Count, Buffer);\r
}\r
/**\r
- Perform Pci configuration Write operation.\r
+ Interprete the boot script node with EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE OP code.\r
\r
@param Script The pointer of typed node in boot script table \r
\r
IN UINT8 *Script\r
)\r
{\r
- EFI_STATUS Status;\r
- UINT8 *Buffer;\r
- UINTN DataWidth;\r
- UINTN Index;\r
- UINT64 PciAddress;\r
- UINT8 Reg;\r
- EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE PciConfigWrite;\r
-\r
- CopyMem ((VOID*)&PciConfigWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE));\r
- Status = EFI_SUCCESS;\r
-\r
- PciAddress = PciConfigWrite.Address;\r
- DataWidth = (UINT32)(0x01 << (PciConfigWrite.Width));\r
- Buffer = Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE);\r
-\r
- DEBUG ((EFI_D_INFO, "BootScriptExecutePciCfgWrite - 0x%08x, 0x%08x, 0x%08x\n", (UINTN)PciAddress, (UINTN)PciConfigWrite.Count, (UINTN)DataWidth));\r
-\r
- for (Index = 0; Index < PciConfigWrite.Count; Index++) {\r
- Status = ScriptPciCfgWrite (\r
- (S3_BOOT_SCRIPT_LIB_WIDTH) PciConfigWrite.Width,\r
- PciAddress,\r
- Buffer\r
- );\r
+ VOID *Buffer;\r
+ S3_BOOT_SCRIPT_LIB_WIDTH Width;\r
+ UINT64 Address;\r
+ UINTN Count;\r
+ EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE PciCfgWrite;\r
\r
- if ( S3BootScriptWidthFillUint8 != PciConfigWrite.Width ||\r
- S3BootScriptWidthFillUint16 != PciConfigWrite.Width || \r
- S3BootScriptWidthFillUint32 != PciConfigWrite.Width ||\r
- S3BootScriptWidthFillUint64 != PciConfigWrite.Width){\r
- Reg = (UINT8) ((UINT8) PciAddress + DataWidth);\r
- PciAddress = (PciAddress & 0xFFFFFFFFFFFFFF00ULL) + Reg;\r
- }\r
+ CopyMem ((VOID*)&PciCfgWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE));\r
\r
- if (S3BootScriptWidthFifoUint8 != PciConfigWrite.Width ||\r
- S3BootScriptWidthFifoUint16 != PciConfigWrite.Width || \r
- S3BootScriptWidthFifoUint32 != PciConfigWrite.Width ||\r
- S3BootScriptWidthFifoUint64 != PciConfigWrite.Width) {\r
- Buffer += DataWidth;\r
- }\r
- }\r
+ Width = (S3_BOOT_SCRIPT_LIB_WIDTH)PciCfgWrite.Width;\r
+ Address = PciCfgWrite.Address;\r
+ Count = PciCfgWrite.Count;\r
+ Buffer = Script + sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE);\r
\r
- return Status;\r
+ DEBUG ((EFI_D_INFO, "BootScriptExecutePciCfgWrite - 0x%08x, 0x%08x, 0x%08x\n", PCI_ADDRESS_ENCODE (Address), Count, (UINTN)Width));\r
+ return ScriptPciCfgWrite (Width, Address, Count, Buffer);\r
}\r
/**\r
- Excute the script to perform IO modification operation.\r
+ Interprete the boot script node with EFI_BOOT_SCRIPT_IO_READ_WRITE OP code.\r
\r
@param Script The pointer of typed node in boot script table \r
@param AndMask Mask value for 'and' operation\r
\r
CopyMem((VOID*)&IoReadWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_IO_READ_WRITE));\r
\r
- DEBUG ((EFI_D_INFO, "BootScriptExecuteIoReadWrite - 0x%08x, 0x%016lx, 0x%016lx\n", (UINTN)IoReadWrite.Address, (UINT64)AndMask, (UINT64)OrMask));\r
+ DEBUG ((EFI_D_INFO, "BootScriptExecuteIoReadWrite - 0x%08x, 0x%016lx, 0x%016lx\n", (UINTN)IoReadWrite.Address, AndMask, OrMask));\r
\r
Status = ScriptIoRead (\r
(S3_BOOT_SCRIPT_LIB_WIDTH) IoReadWrite.Width,\r
return Status;\r
}\r
/**\r
- Excute the script to perform memory modification operation.\r
+ Interprete the boot script node with EFI_BOOT_SCRIPT_MEM_READ_WRITE OP code.\r
\r
@param Script The pointer of typed node in boot script table \r
@param AndMask Mask value for 'and' operation\r
\r
CopyMem((VOID*)&MemReadWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_MEM_READ_WRITE));\r
\r
- DEBUG ((EFI_D_INFO, "BootScriptExecuteMemoryReadWrite - 0x%08x, 0x%016lx, 0x%016lx\n", (UINTN)MemReadWrite.Address, (UINT64)AndMask, (UINT64)OrMask));\r
+ DEBUG ((EFI_D_INFO, "BootScriptExecuteMemoryReadWrite - 0x%08x, 0x%016lx, 0x%016lx\n", (UINTN)MemReadWrite.Address, AndMask, OrMask));\r
\r
Status = ScriptMemoryRead (\r
(S3_BOOT_SCRIPT_LIB_WIDTH) MemReadWrite.Width,\r
return Status;\r
}\r
/**\r
- Excute the script to perform PCI IO modification operation.\r
+ Interprete the boot script node with EFI_BOOT_SCRIPT_PCI_CFG_READ_WRITE OP code.\r
\r
@param Script The pointer of typed node in boot script table \r
@param AndMask Mask value for 'and' operation\r
EFI_STATUS Status;\r
UINT64 Data;\r
EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE PciCfgReadWrite;\r
- \r
+\r
+ Data = 0;\r
+\r
CopyMem((VOID*)&PciCfgReadWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE));\r
\r
- DEBUG ((EFI_D_INFO, "BootScriptExecutePciCfgReadWrite - 0x%08x, 0x%016lx, 0x%016lx\n", (UINTN)PciCfgReadWrite.Address, (UINT64)AndMask, (UINT64)OrMask));\r
+ DEBUG ((EFI_D_INFO, "BootScriptExecutePciCfgReadWrite - 0x%08x, 0x%016lx, 0x%016lx\n", PCI_ADDRESS_ENCODE (PciCfgReadWrite.Address), AndMask, OrMask));\r
\r
Status = ScriptPciCfgRead (\r
(S3_BOOT_SCRIPT_LIB_WIDTH) PciCfgReadWrite.Width,\r
PciCfgReadWrite.Address,\r
+ 1,\r
&Data\r
);\r
if (EFI_ERROR (Status)) {\r
Status = ScriptPciCfgWrite (\r
(S3_BOOT_SCRIPT_LIB_WIDTH) PciCfgReadWrite.Width,\r
PciCfgReadWrite.Address,\r
+ 1,\r
&Data\r
);\r
\r
return Status;\r
}\r
/**\r
- To Execute SMBUS command. \r
+ Interprete the boot script node with EFI_BOOT_SCRIPT_SMBUS_EXECUTE OP code.\r
\r
@param Script The pointer of typed node in boot script table \r
\r
);\r
}\r
/**\r
- Execute stall operation in boot script table.\r
+ Interprete the boot script node with EFI_BOOT_SCRIPT_STALL OP code.\r
\r
@param Script The pointer of typed node in boot script table \r
\r
return EFI_SUCCESS;\r
}\r
/**\r
- To execute assigned function.\r
+ Interprete the boot script node with EFI_BOOT_SCRIPT_DISPATCH OP code.\r
\r
- @param Script The pointer of typed node in boot script table \r
- @retval EFI_SUCCESS The operation was executed successfully\r
+ @param Script The pointer of typed node in boot script table \r
+ @retval EFI_SUCCESS The operation was executed successfully\r
**/\r
EFI_STATUS\r
BootScriptExecuteDispatch (\r
return Status;\r
}\r
/**\r
- Execute dispach2 opertion code which is to invoke a spcified function with one parameter. \r
+ Interprete the boot script node with EFI_BOOT_SCRIPT_DISPATCH_2 OP code.\r
\r
@param Script The pointer of typed node in boot script table \r
@retval EFI_SUCCESS The operation was executed successfully\r
return Status;\r
}\r
/**\r
- Excute the script to poll memory.\r
+ Interprete the boot script node with EFI_BOOT_SCRIPT_MEM_POLL OP code.\r
\r
@param Script The pointer of typed node in boot script table \r
@param AndMask Mask value for 'and' operation\r
\r
CopyMem ((VOID*)&MemPoll, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_MEM_POLL));\r
\r
- DEBUG ((EFI_D_INFO, "BootScriptExecuteMemPoll - 0x%08x\n", (UINTN)MemPoll.Address));\r
+ DEBUG ((EFI_D_INFO, "BootScriptExecuteMemPoll - 0x%08x, 0x%016lx, 0x%016lx\n", (UINTN)MemPoll.Address, AndMask, OrMask));\r
\r
Data = 0;\r
Status = ScriptMemoryRead (\r
}\r
\r
for (LoopTimes = 0; LoopTimes < MemPoll.LoopTimes; LoopTimes++) {\r
- NanoSecondDelay ((UINTN)MemPoll.Duration);\r
+ MicroSecondDelay ((UINTN)MemPoll.Duration);\r
\r
Data = 0;\r
Status = ScriptMemoryRead (\r
}\r
}\r
/**\r
- Execute the boot script to interpret the Store arbitrary information. \r
+ Execute the boot script to interpret the Store arbitrary information.\r
This opcode is a no-op on dispatch and is only used for debugging script issues.\r
\r
@param Script The pointer of node in boot script table \r
)\r
\r
{\r
- UINT8 Index;\r
- for (Index = 0; Index < 10; Index++);\r
+ UINT32 Index;\r
+ EFI_BOOT_SCRIPT_INFORMATION Information;\r
+ UINT8 *InformationData;\r
+\r
+ CopyMem ((VOID*)&Information, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_INFORMATION));\r
+\r
+ InformationData = Script + sizeof (EFI_BOOT_SCRIPT_INFORMATION);\r
+ DEBUG ((EFI_D_INFO, "BootScriptExecuteInformation - 0x%08x\n", (UINTN) InformationData));\r
+\r
+ DEBUG ((EFI_D_INFO, "BootScriptInformation: "));\r
+ for (Index = 0; Index < Information.InformationLength; Index++) {\r
+ DEBUG ((EFI_D_INFO, "%02x ", InformationData[Index]));\r
+ }\r
+ DEBUG ((EFI_D_INFO, "\n"));\r
+}\r
+\r
+/**\r
+ Execute the boot script to interpret the Label information. \r
+\r
+ @param Script The pointer of node in boot script table \r
+ \r
+**/\r
+VOID\r
+BootScriptExecuteLabel (\r
+ IN UINT8 *Script\r
+ )\r
+\r
+{\r
+ UINT32 Index;\r
+ EFI_BOOT_SCRIPT_INFORMATION Information;\r
+ UINT8 *InformationData;\r
+\r
+ CopyMem ((VOID*)&Information, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_INFORMATION));\r
+\r
+ InformationData = Script + sizeof (EFI_BOOT_SCRIPT_INFORMATION);\r
+ DEBUG ((EFI_D_INFO, "BootScriptExecuteLabel - 0x%08x\n", (UINTN) InformationData));\r
+\r
+ DEBUG ((EFI_D_INFO, "BootScriptLabel: "));\r
+ for (Index = 0; Index < Information.InformationLength; Index++) {\r
+ DEBUG ((EFI_D_INFO, "%02x ", InformationData[Index]));\r
+ }\r
+ DEBUG ((EFI_D_INFO, "\n"));\r
}\r
+\r
/**\r
calculate the mask value for 'and' and 'or' operation\r
@param ScriptHeader The pointer of header of node in boot script table \r
\r
switch (ScriptHeader->Width) {\r
case S3BootScriptWidthUint8:\r
- *AndMask = (UINT64) *(DataPtr + 1);\r
+ *AndMask = (UINT64) (*(UINT8*) (DataPtr + 1));\r
*OrMask = (UINT64) (*DataPtr);\r
break;\r
\r
return;\r
}\r
/**\r
- Excute the script to poll Io port for some time\r
+ Interprete the boot script node with EFI_BOOT_SCRIPT_IO_POLL OP code.\r
\r
@param Script The pointer of typed node in boot script table \r
@param AndMask Mask value for 'and' operation\r
\r
CopyMem ((VOID*)&IoPoll, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_IO_POLL));\r
\r
- DEBUG ((EFI_D_INFO, "BootScriptExecuteIoPoll - 0x%08x\n", (UINTN)IoPoll.Address));\r
+ DEBUG ((EFI_D_INFO, "BootScriptExecuteIoPoll - 0x%08x, 0x%016lx, 0x%016lx\n", (UINTN)IoPoll.Address, AndMask, OrMask));\r
\r
Data = 0;\r
Status = ScriptIoRead (\r
}\r
}\r
/**\r
- Perform Pci configuration Write operation.\r
+ Interprete the boot script node with EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE OP code.\r
\r
@param Script The pointer of S3 boot script\r
\r
IN UINT8 *Script\r
)\r
{\r
- UINT8 Reg;\r
- UINT8 *Buffer;\r
- UINTN DataWidth;\r
- UINTN Index;\r
- UINT16 Segment;\r
- UINT64 PciAddress;\r
- EFI_STATUS Status;\r
- EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE PciCfg2Write;\r
+ VOID *Buffer;\r
+ S3_BOOT_SCRIPT_LIB_WIDTH Width;\r
+ UINT16 Segment;\r
+ UINT64 Address;\r
+ UINTN Count;\r
+ EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE PciCfg2Write;\r
\r
CopyMem ((VOID*)&PciCfg2Write, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE));\r
- Status = EFI_SUCCESS;\r
- Segment = PciCfg2Write.Segment;\r
- PciAddress = PciCfg2Write.Address;\r
- DataWidth = (UINT32)(0x01 << (PciCfg2Write.Width));\r
- Buffer = Script + sizeof (EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE);\r
-\r
- DEBUG ((EFI_D_INFO, "BootScriptExecutePciCfg2Write - 0x%08x\n", (UINTN)PciAddress));\r
-\r
- for (Index = 0; Index < PciCfg2Write.Count; Index++) {\r
- Status = ScriptPciCfg2Write (\r
- (S3_BOOT_SCRIPT_LIB_WIDTH) PciCfg2Write.Width,\r
- Segment,\r
- PciAddress,\r
- Buffer\r
- );\r
- if (S3BootScriptWidthFillUint8 != PciCfg2Write.Width ||\r
- S3BootScriptWidthFillUint16 != PciCfg2Write.Width || \r
- S3BootScriptWidthFillUint32 != PciCfg2Write.Width ||\r
- S3BootScriptWidthFillUint64 != PciCfg2Write.Width){\r
- Reg = (UINT8) ((UINT8) PciAddress + DataWidth);\r
- PciAddress = (PciAddress & 0xFFFFFFFFFFFFFF00ULL) + Reg;\r
- }\r
\r
- if (S3BootScriptWidthFifoUint8 != PciCfg2Write.Width ||\r
- S3BootScriptWidthFifoUint16 != PciCfg2Write.Width || \r
- S3BootScriptWidthFifoUint32 != PciCfg2Write.Width ||\r
- S3BootScriptWidthFifoUint64 != PciCfg2Write.Width) {\r
- Buffer += DataWidth;\r
- }\r
- }\r
- return Status;\r
+ Width = (S3_BOOT_SCRIPT_LIB_WIDTH)PciCfg2Write.Width;\r
+ Segment = PciCfg2Write.Segment;\r
+ Address = PciCfg2Write.Address;\r
+ Count = PciCfg2Write.Count;\r
+ Buffer = Script + sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE);\r
+\r
+ DEBUG ((EFI_D_INFO, "BootScriptExecutePciCfg2Write - 0x%04x, 0x%08x, 0x%08x, 0x%08x\n", Segment, PCI_ADDRESS_ENCODE (Address), Count, (UINTN)Width));\r
+ return ScriptPciCfg2Write (Width, Segment, Address, Count, Buffer);\r
}\r
\r
\r
/**\r
- Perform pci configuration read & Write operation.\r
+ Interprete the boot script node with EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE OP code.\r
\r
@param Script The pointer of S3 boot script\r
@param AndMask Mask value for 'and' operation\r
UINT64 Data;\r
EFI_STATUS Status;\r
EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE PciCfg2ReadWrite;\r
+\r
+ Data = 0;\r
+\r
CopyMem ((VOID*)&PciCfg2ReadWrite, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE));\r
\r
- DEBUG ((EFI_D_INFO, "BootScriptExecutePciCfg2ReadWrite - 0x%08x\n", (UINTN)PciCfg2ReadWrite.Address));\r
+ DEBUG ((EFI_D_INFO, "BootScriptExecutePciCfg2ReadWrite - 0x%04x, 0x%08x, 0x%016lx, 0x%016lx\n", PciCfg2ReadWrite.Segment, PCI_ADDRESS_ENCODE (PciCfg2ReadWrite.Address), AndMask, OrMask));\r
\r
Status = ScriptPciCfg2Read (\r
(S3_BOOT_SCRIPT_LIB_WIDTH) PciCfg2ReadWrite.Width,\r
PciCfg2ReadWrite.Segment,\r
PciCfg2ReadWrite.Address,\r
+ 1,\r
&Data\r
);\r
if (EFI_ERROR (Status)) {\r
(S3_BOOT_SCRIPT_LIB_WIDTH) PciCfg2ReadWrite.Width,\r
PciCfg2ReadWrite.Segment,\r
PciCfg2ReadWrite.Address,\r
+ 1,\r
&Data\r
);\r
return Status;\r
}\r
/**\r
- To perform poll pci configure operation.\r
+ Interprete the boot script node with EFI_BOOT_SCRIPT_PCI_CONFIG_POLL OP code.\r
\r
@param Script The pointer of S3 boot script\r
@param AndMask Mask value for 'and' operation\r
EFI_BOOT_SCRIPT_PCI_CONFIG_POLL PciCfgPoll;\r
CopyMem ((VOID*)&PciCfgPoll, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG_POLL));\r
\r
- DEBUG ((EFI_D_INFO, "BootScriptPciCfgPoll - 0x%08x\n", (UINTN)PciCfgPoll.Address));\r
+ DEBUG ((EFI_D_INFO, "BootScriptPciCfgPoll - 0x%08x, 0x%016lx, 0x%016lx\n", PCI_ADDRESS_ENCODE (PciCfgPoll.Address), AndMask, OrMask));\r
\r
Data = 0;\r
Status = ScriptPciCfgRead (\r
(S3_BOOT_SCRIPT_LIB_WIDTH) PciCfgPoll.Width,\r
PciCfgPoll.Address,\r
+ 1,\r
&Data\r
);\r
if ((!EFI_ERROR (Status)) &&(Data & AndMask) == OrMask) {\r
Status = ScriptPciCfgRead (\r
(S3_BOOT_SCRIPT_LIB_WIDTH) PciCfgPoll.Width,\r
PciCfgPoll.Address,\r
+ 1,\r
&Data\r
);\r
if ((!EFI_ERROR (Status)) &&\r
}\r
\r
/**\r
- To perform poll pci configure operation.\r
+ Interprete the boot script node with EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL OP code.\r
\r
@param Script The pointer of S3 Boot Script\r
@param AndMask Mask value for 'and' operation\r
Data = 0;\r
CopyMem ((VOID*)&PciCfg2Poll, (VOID*)Script, sizeof(EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL));\r
\r
- DEBUG ((EFI_D_INFO, "BootScriptPciCfg2Poll - 0x%08x\n", (UINTN)PciCfg2Poll.Address));\r
+ DEBUG ((EFI_D_INFO, "BootScriptPciCfg2Poll - 0x%04x, 0x%08x, 0x%016lx, 0x%016lx\n", PciCfg2Poll.Segment, PCI_ADDRESS_ENCODE (PciCfg2Poll.Address), AndMask, OrMask));\r
\r
Status = ScriptPciCfg2Read (\r
(S3_BOOT_SCRIPT_LIB_WIDTH) PciCfg2Poll.Width,\r
PciCfg2Poll.Segment,\r
PciCfg2Poll.Address,\r
+ 1,\r
&Data\r
);\r
if ((!EFI_ERROR (Status)) && (Data & AndMask) == OrMask) {\r
(S3_BOOT_SCRIPT_LIB_WIDTH) PciCfg2Poll.Width,\r
PciCfg2Poll.Segment, \r
PciCfg2Poll.Address,\r
+ 1,\r
&Data\r
);\r
if ((!EFI_ERROR (Status)) && (Data & AndMask) == OrMask) {\r
AndMask = 0;\r
OrMask = 0;\r
\r
+ DEBUG ((EFI_D_INFO, "TableHeader.Version - 0x%04x\n", (UINTN)TableHeader.Version));\r
DEBUG ((EFI_D_INFO, "TableHeader.TableLength - 0x%08x\n", (UINTN)TableLength));\r
\r
while ((UINTN) Script < (UINTN) (StartAddress + TableLength)) {\r
\r
case S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE:\r
DEBUG ((EFI_D_INFO, "S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE\n"));\r
+ DEBUG ((EFI_D_INFO, "S3BootScriptDone - %r\n", EFI_SUCCESS));\r
return EFI_SUCCESS;\r
\r
case EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE:\r
// For label\r
//\r
DEBUG ((EFI_D_INFO, "S3_BOOT_SCRIPT_LIB_LABEL_OPCODE\n"));\r
+ BootScriptExecuteLabel (Script);\r
break;\r
default:\r
DEBUG ((EFI_D_INFO, "S3BootScriptDone - %r\n", EFI_UNSUPPORTED));\r