EFI_STATUS SmmBootScriptWrite ( IN OUT EFI_SMM_SCRIPT_TABLE *ScriptTable, IN UINTN Type, IN UINT16 OpCode, ... ) { EFI_STATUS Status; VA_LIST Marker; if (ScriptTable == NULL) { return EFI_INVALID_PARAMETER; } // // Build script according to opcode // switch ( OpCode ) { case EFI_BOOT_SCRIPT_IO_WRITE_OPCODE: VA_START(Marker, OpCode); Status = BootScriptIoWrite (ScriptTable, Marker); VA_END(Marker); break; case EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE: VA_START(Marker, OpCode); Status = BootScriptPciCfgWrite(ScriptTable, Marker); VA_END(Marker); break; default: Status = EFI_SUCCESS; break; } return Status; }
/** Adds a record into a specified Framework boot script table. This function is used to store a boot script record into a given boot script table. If the table specified by TableName is nonexistent in the system, a new table will automatically be created and then the script record will be added into the new table. A boot script table can add new script records until EFI_BOOT_SCRIPT_SAVE_PROTOCOL.CloseTable() is called. Currently, the only meaningful table name is EFI_ACPI_S3_RESUME_SCRIPT_TABLE. This function is responsible for allocating necessary memory for the script. This function has a variable parameter list. The exact parameter list depends on the OpCode that is passed into the function. If an unsupported OpCode or illegal parameter list is passed in, this function returns EFI_INVALID_PARAMETER. If there are not enough resources available for storing more scripts, this function returns EFI_OUT_OF_RESOURCES. @param This A pointer to the EFI_BOOT_SCRIPT_SAVE_PROTOCOL instance. @param TableName Name of the script table. Currently, the only meaningful value is EFI_ACPI_S3_RESUME_SCRIPT_TABLE. @param OpCode The operation code (opcode) number. @param ... Argument list that is specific to each opcode. @retval EFI_SUCCESS The operation succeeded. A record was added into the specified script table. @retval EFI_INVALID_PARAMETER The parameter is illegal or the given boot script is not supported. If the opcode is unknow or not supported because of the PCD Feature Flags. @retval EFI_OUT_OF_RESOURCES There is insufficient memory to store the boot script. **/ EFI_STATUS EFIAPI BootScriptWrite ( IN EFI_BOOT_SCRIPT_SAVE_PROTOCOL *This, IN UINT16 TableName, IN UINT16 OpCode, ... ) { EFI_STATUS Status; VA_LIST Marker; if (TableName != FRAMEWORK_EFI_ACPI_S3_RESUME_SCRIPT_TABLE) { // // Only S3 boot script is supported for now // return EFI_OUT_OF_RESOURCES; } // // Build script according to opcode // switch (OpCode) { case EFI_BOOT_SCRIPT_IO_WRITE_OPCODE: VA_START (Marker, OpCode); Status = BootScriptIoWrite (Marker); VA_END (Marker); break; case EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE: VA_START (Marker, OpCode); Status = BootScriptIoReadWrite (Marker); VA_END (Marker); break; case EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE: VA_START (Marker, OpCode); Status = BootScriptMemWrite (Marker); VA_END (Marker); break; case EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE: VA_START (Marker, OpCode); Status = BootScriptMemReadWrite (Marker); VA_END (Marker); break; case EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE: VA_START (Marker, OpCode); Status = BootScriptPciCfgWrite (Marker); VA_END (Marker); break; case EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE: VA_START (Marker, OpCode); Status = BootScriptPciCfgReadWrite (Marker); VA_END (Marker); break; case EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE: VA_START (Marker, OpCode); Status = BootScriptSmbusExecute (Marker); VA_END (Marker); break; case EFI_BOOT_SCRIPT_STALL_OPCODE: VA_START (Marker, OpCode); Status = BootScriptStall (Marker); VA_END (Marker); break; case EFI_BOOT_SCRIPT_DISPATCH_OPCODE: VA_START (Marker, OpCode); Status = BootScriptDispatch (Marker); VA_END (Marker); break; case FRAMEWORK_EFI_BOOT_SCRIPT_DISPATCH_2_OPCODE: VA_START (Marker, OpCode); Status = BootScriptDispatch2 (Marker); VA_END (Marker); break; case EFI_BOOT_SCRIPT_INFORMATION_OPCODE: VA_START (Marker, OpCode); Status = BootScriptInformation (Marker); VA_END (Marker); break; case FRAMEWORK_EFI_BOOT_SCRIPT_MEM_POLL_OPCODE: VA_START (Marker, OpCode); Status = BootScriptMemPoll (Marker); VA_END (Marker); break; case EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE: VA_START (Marker, OpCode); Status = BootScriptPciCfg2Write (Marker); VA_END (Marker); break; case EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE: VA_START (Marker, OpCode); Status = BootScriptPciCfg2ReadWrite (Marker); VA_END (Marker); break; default: Status = EFI_INVALID_PARAMETER; break; } return Status; }