3 Copyright (c) 2006 - 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 Support for EFI script.
22 #include "EfiScriptLib.h"
24 EFI_BOOT_SCRIPT_SAVE_PROTOCOL
*mBootScriptSave
;
28 BootScriptSaveInitialize (
29 IN EFI_HANDLE ImageHandle
,
30 IN EFI_SYSTEM_TABLE
*SystemTable
36 Intialize Boot Script Lib if it has not yet been initialized.
40 (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)
44 EFI_STATUS always returns EFI_SUCCESS
47 // GC_TODO: ImageHandle - add argument and description to function comment
48 // GC_TODO: SystemTable - add argument and description to function comment
51 EFI_BOOT_SERVICES
*BS
;
53 BS
= SystemTable
->BootServices
;
55 Status
= BS
->LocateProtocol (&gEfiBootScriptSaveGuid
, NULL
, (VOID
**)&mBootScriptSave
);
56 if (EFI_ERROR (Status
) && Status
!= EFI_ALREADY_STARTED
) {
57 mBootScriptSave
= NULL
;
65 BootScriptSaveIoWrite (
67 IN EFI_BOOT_SCRIPT_WIDTH Width
,
76 Save I/O write to boot script
80 TableName - Desired boot script table
82 (Standard EFI IO write script parameter)
86 EFI_NOT_FOUND - BootScriptSave Protocol not exist.
88 EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
91 // GC_TODO: Width - add argument and description to function comment
92 // GC_TODO: Address - add argument and description to function comment
93 // GC_TODO: Count - add argument and description to function comment
94 // GC_TODO: Buffer - add argument and description to function comment
96 if (mBootScriptSave
== NULL
) {
100 mBootScriptSave
->Write (
103 EFI_BOOT_SCRIPT_IO_WRITE_OPCODE
,
115 BootScriptSaveIoReadWrite (
117 IN EFI_BOOT_SCRIPT_WIDTH Width
,
126 Save I/O write to boot script
130 TableName - Desired boot script table
132 (Standard EFI IO read write script parameter)
136 EFI_NOT_FOUND - BootScriptSave Protocol not exist.
138 EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
141 // GC_TODO: Width - add argument and description to function comment
142 // GC_TODO: Address - add argument and description to function comment
143 // GC_TODO: Data - add argument and description to function comment
144 // GC_TODO: DataMask - add argument and description to function comment
146 if (mBootScriptSave
== NULL
) {
147 return EFI_NOT_FOUND
;
150 mBootScriptSave
->Write (
153 EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE
,
165 BootScriptSaveMemWrite (
167 IN EFI_BOOT_SCRIPT_WIDTH Width
,
176 Save I/O write to boot script
180 TableName - Desired boot script table
182 (Standard EFI MEM write script parameter)
186 EFI_NOT_FOUND - BootScriptSave Protocol not exist.
188 EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
191 // GC_TODO: Width - add argument and description to function comment
192 // GC_TODO: Address - add argument and description to function comment
193 // GC_TODO: Count - add argument and description to function comment
194 // GC_TODO: Buffer - add argument and description to function comment
196 if (mBootScriptSave
== NULL
) {
197 return EFI_NOT_FOUND
;
200 mBootScriptSave
->Write (
203 EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE
,
215 BootScriptSaveMemReadWrite (
217 IN EFI_BOOT_SCRIPT_WIDTH Width
,
226 Save I/O write to boot script
230 TableName - Desired boot script table
232 (Standard EFI MEM read write script parameter)
236 EFI_NOT_FOUND - BootScriptSave Protocol not exist.
238 EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
241 // GC_TODO: Width - add argument and description to function comment
242 // GC_TODO: Address - add argument and description to function comment
243 // GC_TODO: Data - add argument and description to function comment
244 // GC_TODO: DataMask - add argument and description to function comment
246 if (mBootScriptSave
== NULL
) {
247 return EFI_NOT_FOUND
;
250 mBootScriptSave
->Write (
253 EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE
,
265 BootScriptSavePciCfgWrite (
267 IN EFI_BOOT_SCRIPT_WIDTH Width
,
276 Save I/O write to boot script
280 TableName - Desired boot script table
282 (Standard EFI PCI write script parameter)
286 EFI_NOT_FOUND - BootScriptSave Protocol not exist.
288 EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
291 // GC_TODO: Width - add argument and description to function comment
292 // GC_TODO: Address - add argument and description to function comment
293 // GC_TODO: Count - add argument and description to function comment
294 // GC_TODO: Buffer - add argument and description to function comment
296 if (mBootScriptSave
== NULL
) {
297 return EFI_NOT_FOUND
;
300 mBootScriptSave
->Write (
303 EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE
,
315 BootScriptSavePciCfgReadWrite (
317 IN EFI_BOOT_SCRIPT_WIDTH Width
,
326 Save I/O write to boot script
330 TableName - Desired boot script table
332 (Standard EFI PCI read write script parameter)
336 EFI_NOT_FOUND - BootScriptSave Protocol not exist.
338 EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
341 // GC_TODO: Width - add argument and description to function comment
342 // GC_TODO: Address - add argument and description to function comment
343 // GC_TODO: Data - add argument and description to function comment
344 // GC_TODO: DataMask - add argument and description to function comment
346 if (mBootScriptSave
== NULL
) {
347 return EFI_NOT_FOUND
;
350 mBootScriptSave
->Write (
353 EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE
,
365 BootScriptSaveSmbusExecute (
367 IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress
,
368 IN EFI_SMBUS_DEVICE_COMMAND Command
,
369 IN EFI_SMBUS_OPERATION Operation
,
378 Save I/O write to boot script
382 TableName - Desired boot script table
384 (Standard EFI Smbus execute script parameter)
388 EFI_NOT_FOUND - BootScriptSave Protocol not exist.
390 EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
393 // GC_TODO: SlaveAddress - add argument and description to function comment
394 // GC_TODO: Command - add argument and description to function comment
395 // GC_TODO: Operation - add argument and description to function comment
396 // GC_TODO: PecCheck - add argument and description to function comment
397 // GC_TODO: Length - add argument and description to function comment
398 // GC_TODO: Buffer - add argument and description to function comment
400 if (mBootScriptSave
== NULL
) {
401 return EFI_NOT_FOUND
;
404 mBootScriptSave
->Write (
407 EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE
,
421 BootScriptSaveStall (
429 Save I/O write to boot script
433 TableName - Desired boot script table
435 (Standard EFI stall script parameter)
439 EFI_NOT_FOUND - BootScriptSave Protocol not exist.
441 EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
444 // GC_TODO: Duration - add argument and description to function comment
446 if (mBootScriptSave
== NULL
) {
447 return EFI_NOT_FOUND
;
450 mBootScriptSave
->Write (
453 EFI_BOOT_SCRIPT_STALL_OPCODE
,
462 BootScriptSaveDispatch (
464 IN EFI_PHYSICAL_ADDRESS EntryPoint
470 GC_TODO: Add function description
474 TableName - GC_TODO: add argument description
475 EntryPoint - GC_TODO: add argument description
479 EFI_NOT_FOUND - GC_TODO: Add description for return value
480 EFI_SUCCESS - GC_TODO: Add description for return value
484 if (mBootScriptSave
== NULL
) {
485 return EFI_NOT_FOUND
;
488 mBootScriptSave
->Write (
491 EFI_BOOT_SCRIPT_DISPATCH_OPCODE
,
503 IN EFI_BOOT_SCRIPT_WIDTH Width
,
514 Save I/O write to boot script
517 TableName - Desired boot script table
519 Width - The width of the memory operations.
521 Address - The base address of the memory operations.
523 BitMask - A pointer to the bit mask to be AND-ed with the data read from the register.
525 BitValue - A pointer to the data value after to be Masked.
527 Duration - Duration in microseconds of the stall.
529 LoopTimes - The times of the register polling.
533 EFI_NOT_FOUND - BootScriptSave Protocol not exist.
535 EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
539 mBootScriptSave
->Write (
542 EFI_BOOT_SCRIPT_MEM_POLL_OPCODE
,
556 BootScriptSaveInformation (
559 IN EFI_PHYSICAL_ADDRESS Buffer
565 Save a Information Opcode record in table specified with TableName
569 TableName - Desired boot script table
570 Length - Length of information in bytes
571 Buffer - Content of information that will be saved in script table
575 EFI_NOT_FOUND - BootScriptSave Protocol not exist.
577 EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
581 if (mBootScriptSave
== NULL
) {
582 return EFI_NOT_FOUND
;
585 mBootScriptSave
->Write (
588 EFI_BOOT_SCRIPT_INFORMATION_OPCODE
,
599 BootScriptSaveInformationUnicodeString (
607 Save a Information Opcode record in table specified with TableName, the information
612 TableName - Desired boot script table
613 String - The string that will be saved in script table
617 EFI_NOT_FOUND - BootScriptSave Protocol not exist.
619 EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
623 return BootScriptSaveInformation (
625 (UINT32
) EfiStrLen (String
) * 2 + 2,
626 (EFI_PHYSICAL_ADDRESS
) (UINTN
) String
632 BootScriptSaveInformationAsciiString (
640 Save a Information Opcode record in table specified with TableName, the information
645 TableName - Desired boot script table
646 String - The string that will be saved in script table
650 EFI_NOT_FOUND - BootScriptSave Protocol not exist.
652 EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
656 return BootScriptSaveInformation (
658 (UINT32
) EfiAsciiStrLen (String
) + 1,
659 (EFI_PHYSICAL_ADDRESS
) (UINTN
) String