3 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
4 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
;
27 EfiScriptLibAsciiStrLen (
33 Return the number of Ascii characters in String. This is not the same as
34 the length of the string in bytes.
37 String - String to process
40 Number of Ascii characters in String
46 for (Length
=0; *String
; String
++, Length
++);
57 Return the number of Unicode characters in String. This is not the same as
58 the length of the string in bytes.
61 String - String to process
64 Number of Unicode characters in String
70 for (Length
=0; *String
; String
++, Length
++);
76 BootScriptSaveInitialize (
77 IN EFI_HANDLE ImageHandle
,
78 IN EFI_SYSTEM_TABLE
*SystemTable
84 Intialize Boot Script Lib if it has not yet been initialized.
88 (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)
92 EFI_STATUS always returns EFI_SUCCESS
95 // GC_TODO: ImageHandle - add argument and description to function comment
96 // GC_TODO: SystemTable - add argument and description to function comment
99 EFI_BOOT_SERVICES
*BS
;
101 BS
= SystemTable
->BootServices
;
103 Status
= BS
->LocateProtocol (&gEfiBootScriptSaveGuid
, NULL
, (VOID
**)&mBootScriptSave
);
104 if (EFI_ERROR (Status
) && Status
!= EFI_ALREADY_STARTED
) {
105 mBootScriptSave
= NULL
;
113 BootScriptSaveIoWrite (
115 IN EFI_BOOT_SCRIPT_WIDTH Width
,
124 Save I/O write to boot script
128 TableName - Desired boot script table
130 (Standard EFI IO write script parameter)
134 EFI_NOT_FOUND - BootScriptSave Protocol not exist.
136 EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
139 // GC_TODO: Width - add argument and description to function comment
140 // GC_TODO: Address - add argument and description to function comment
141 // GC_TODO: Count - add argument and description to function comment
142 // GC_TODO: Buffer - add argument and description to function comment
144 if (mBootScriptSave
== NULL
) {
145 return EFI_NOT_FOUND
;
148 mBootScriptSave
->Write (
151 EFI_BOOT_SCRIPT_IO_WRITE_OPCODE
,
163 BootScriptSaveIoReadWrite (
165 IN EFI_BOOT_SCRIPT_WIDTH Width
,
174 Save I/O write to boot script
178 TableName - Desired boot script table
180 (Standard EFI IO read write script parameter)
184 EFI_NOT_FOUND - BootScriptSave Protocol not exist.
186 EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
189 // GC_TODO: Width - add argument and description to function comment
190 // GC_TODO: Address - add argument and description to function comment
191 // GC_TODO: Data - add argument and description to function comment
192 // GC_TODO: DataMask - add argument and description to function comment
194 if (mBootScriptSave
== NULL
) {
195 return EFI_NOT_FOUND
;
198 mBootScriptSave
->Write (
201 EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE
,
213 BootScriptSaveMemWrite (
215 IN EFI_BOOT_SCRIPT_WIDTH Width
,
224 Save I/O write to boot script
228 TableName - Desired boot script table
230 (Standard EFI MEM write script parameter)
234 EFI_NOT_FOUND - BootScriptSave Protocol not exist.
236 EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
239 // GC_TODO: Width - add argument and description to function comment
240 // GC_TODO: Address - add argument and description to function comment
241 // GC_TODO: Count - add argument and description to function comment
242 // GC_TODO: Buffer - add argument and description to function comment
244 if (mBootScriptSave
== NULL
) {
245 return EFI_NOT_FOUND
;
248 mBootScriptSave
->Write (
251 EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE
,
263 BootScriptSaveMemReadWrite (
265 IN EFI_BOOT_SCRIPT_WIDTH Width
,
274 Save I/O write to boot script
278 TableName - Desired boot script table
280 (Standard EFI MEM read write script parameter)
284 EFI_NOT_FOUND - BootScriptSave Protocol not exist.
286 EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
289 // GC_TODO: Width - add argument and description to function comment
290 // GC_TODO: Address - add argument and description to function comment
291 // GC_TODO: Data - add argument and description to function comment
292 // GC_TODO: DataMask - add argument and description to function comment
294 if (mBootScriptSave
== NULL
) {
295 return EFI_NOT_FOUND
;
298 mBootScriptSave
->Write (
301 EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE
,
313 BootScriptSavePciCfgWrite (
315 IN EFI_BOOT_SCRIPT_WIDTH Width
,
324 Save I/O write to boot script
328 TableName - Desired boot script table
330 (Standard EFI PCI write script parameter)
334 EFI_NOT_FOUND - BootScriptSave Protocol not exist.
336 EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
339 // GC_TODO: Width - add argument and description to function comment
340 // GC_TODO: Address - add argument and description to function comment
341 // GC_TODO: Count - add argument and description to function comment
342 // GC_TODO: Buffer - add argument and description to function comment
344 if (mBootScriptSave
== NULL
) {
345 return EFI_NOT_FOUND
;
348 mBootScriptSave
->Write (
351 EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE
,
363 BootScriptSavePciCfgReadWrite (
365 IN EFI_BOOT_SCRIPT_WIDTH Width
,
374 Save I/O write to boot script
378 TableName - Desired boot script table
380 (Standard EFI PCI read write script parameter)
384 EFI_NOT_FOUND - BootScriptSave Protocol not exist.
386 EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
389 // GC_TODO: Width - add argument and description to function comment
390 // GC_TODO: Address - add argument and description to function comment
391 // GC_TODO: Data - add argument and description to function comment
392 // GC_TODO: DataMask - add argument and description to function comment
394 if (mBootScriptSave
== NULL
) {
395 return EFI_NOT_FOUND
;
398 mBootScriptSave
->Write (
401 EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE
,
413 BootScriptSaveSmbusExecute (
415 IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress
,
416 IN EFI_SMBUS_DEVICE_COMMAND Command
,
417 IN EFI_SMBUS_OPERATION Operation
,
426 Save I/O write to boot script
430 TableName - Desired boot script table
432 (Standard EFI Smbus execute script parameter)
436 EFI_NOT_FOUND - BootScriptSave Protocol not exist.
438 EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
441 // GC_TODO: SlaveAddress - add argument and description to function comment
442 // GC_TODO: Command - add argument and description to function comment
443 // GC_TODO: Operation - add argument and description to function comment
444 // GC_TODO: PecCheck - add argument and description to function comment
445 // GC_TODO: Length - add argument and description to function comment
446 // GC_TODO: Buffer - add argument and description to function comment
448 if (mBootScriptSave
== NULL
) {
449 return EFI_NOT_FOUND
;
452 mBootScriptSave
->Write (
455 EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE
,
469 BootScriptSaveStall (
477 Save I/O write to boot script
481 TableName - Desired boot script table
483 (Standard EFI stall script parameter)
487 EFI_NOT_FOUND - BootScriptSave Protocol not exist.
489 EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
492 // GC_TODO: Duration - add argument and description to function comment
494 if (mBootScriptSave
== NULL
) {
495 return EFI_NOT_FOUND
;
498 mBootScriptSave
->Write (
501 EFI_BOOT_SCRIPT_STALL_OPCODE
,
510 BootScriptSaveDispatch (
512 IN EFI_PHYSICAL_ADDRESS EntryPoint
518 GC_TODO: Add function description
522 TableName - GC_TODO: add argument description
523 EntryPoint - GC_TODO: add argument description
527 EFI_NOT_FOUND - GC_TODO: Add description for return value
528 EFI_SUCCESS - GC_TODO: Add description for return value
532 if (mBootScriptSave
== NULL
) {
533 return EFI_NOT_FOUND
;
536 mBootScriptSave
->Write (
539 EFI_BOOT_SCRIPT_DISPATCH_OPCODE
,
551 IN EFI_BOOT_SCRIPT_WIDTH Width
,
562 Save I/O write to boot script
565 TableName - Desired boot script table
567 Width - The width of the memory operations.
569 Address - The base address of the memory operations.
571 BitMask - A pointer to the bit mask to be AND-ed with the data read from the register.
573 BitValue - A pointer to the data value after to be Masked.
575 Duration - Duration in microseconds of the stall.
577 LoopTimes - The times of the register polling.
581 EFI_NOT_FOUND - BootScriptSave Protocol not exist.
583 EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
587 mBootScriptSave
->Write (
590 EFI_BOOT_SCRIPT_MEM_POLL_OPCODE
,
604 BootScriptSaveInformation (
607 IN EFI_PHYSICAL_ADDRESS Buffer
613 Save a Information Opcode record in table specified with TableName
617 TableName - Desired boot script table
618 Length - Length of information in bytes
619 Buffer - Content of information that will be saved in script table
623 EFI_NOT_FOUND - BootScriptSave Protocol not exist.
625 EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
629 if (mBootScriptSave
== NULL
) {
630 return EFI_NOT_FOUND
;
633 mBootScriptSave
->Write (
636 EFI_BOOT_SCRIPT_INFORMATION_OPCODE
,
647 BootScriptSaveInformationUnicodeString (
655 Save a Information Opcode record in table specified with TableName, the information
660 TableName - Desired boot script table
661 String - The string that will be saved in script table
665 EFI_NOT_FOUND - BootScriptSave Protocol not exist.
667 EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
671 return BootScriptSaveInformation (
673 (UINT32
) EfiScriptLibStrLen (String
) * 2 + 2,
674 (EFI_PHYSICAL_ADDRESS
) (UINTN
) String
680 BootScriptSaveInformationAsciiString (
688 Save a Information Opcode record in table specified with TableName, the information
693 TableName - Desired boot script table
694 String - The string that will be saved in script table
698 EFI_NOT_FOUND - BootScriptSave Protocol not exist.
700 EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
704 return BootScriptSaveInformation (
706 (UINT32
) EfiScriptLibAsciiStrLen (String
) + 1,
707 (EFI_PHYSICAL_ADDRESS
) (UINTN
) String