3 Copyright (c) 2006, 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
;
27 BootScriptSaveInitialize (
28 IN EFI_HANDLE ImageHandle
,
29 IN EFI_SYSTEM_TABLE
*SystemTable
35 Intialize Boot Script Lib if it has not yet been initialized.
39 (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)
43 EFI_STATUS always returns EFI_SUCCESS
46 // GC_TODO: ImageHandle - add argument and description to function comment
47 // GC_TODO: SystemTable - add argument and description to function comment
50 EFI_BOOT_SERVICES
*BS
;
52 BS
= SystemTable
->BootServices
;
54 Status
= BS
->LocateProtocol (&gEfiBootScriptSaveGuid
, NULL
, &mBootScriptSave
);
55 if (EFI_ERROR (Status
) && Status
!= EFI_ALREADY_STARTED
) {
56 mBootScriptSave
= NULL
;
63 BootScriptSaveIoWrite (
65 IN EFI_BOOT_SCRIPT_WIDTH Width
,
74 Save I/O write to boot script
78 TableName - Desired boot script table
80 (Standard EFI IO write script parameter)
84 EFI_NOT_FOUND - BootScriptSave Protocol not exist.
86 EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
89 // GC_TODO: Width - add argument and description to function comment
90 // GC_TODO: Address - add argument and description to function comment
91 // GC_TODO: Count - add argument and description to function comment
92 // GC_TODO: Buffer - add argument and description to function comment
94 if (mBootScriptSave
== NULL
) {
98 mBootScriptSave
->Write (
101 EFI_BOOT_SCRIPT_IO_WRITE_OPCODE
,
112 BootScriptSaveIoReadWrite (
114 IN EFI_BOOT_SCRIPT_WIDTH Width
,
123 Save I/O write to boot script
127 TableName - Desired boot script table
129 (Standard EFI IO read write script parameter)
133 EFI_NOT_FOUND - BootScriptSave Protocol not exist.
135 EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
138 // GC_TODO: Width - add argument and description to function comment
139 // GC_TODO: Address - add argument and description to function comment
140 // GC_TODO: Data - add argument and description to function comment
141 // GC_TODO: DataMask - add argument and description to function comment
143 if (mBootScriptSave
== NULL
) {
144 return EFI_NOT_FOUND
;
147 mBootScriptSave
->Write (
150 EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE
,
161 BootScriptSaveMemWrite (
163 IN EFI_BOOT_SCRIPT_WIDTH Width
,
172 Save I/O write to boot script
176 TableName - Desired boot script table
178 (Standard EFI MEM write script parameter)
182 EFI_NOT_FOUND - BootScriptSave Protocol not exist.
184 EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
187 // GC_TODO: Width - add argument and description to function comment
188 // GC_TODO: Address - add argument and description to function comment
189 // GC_TODO: Count - add argument and description to function comment
190 // GC_TODO: Buffer - add argument and description to function comment
192 if (mBootScriptSave
== NULL
) {
193 return EFI_NOT_FOUND
;
196 mBootScriptSave
->Write (
199 EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE
,
210 BootScriptSaveMemReadWrite (
212 IN EFI_BOOT_SCRIPT_WIDTH Width
,
221 Save I/O write to boot script
225 TableName - Desired boot script table
227 (Standard EFI MEM read write script parameter)
231 EFI_NOT_FOUND - BootScriptSave Protocol not exist.
233 EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
236 // GC_TODO: Width - add argument and description to function comment
237 // GC_TODO: Address - add argument and description to function comment
238 // GC_TODO: Data - add argument and description to function comment
239 // GC_TODO: DataMask - add argument and description to function comment
241 if (mBootScriptSave
== NULL
) {
242 return EFI_NOT_FOUND
;
245 mBootScriptSave
->Write (
248 EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE
,
259 BootScriptSavePciCfgWrite (
261 IN EFI_BOOT_SCRIPT_WIDTH Width
,
270 Save I/O write to boot script
274 TableName - Desired boot script table
276 (Standard EFI PCI write script parameter)
280 EFI_NOT_FOUND - BootScriptSave Protocol not exist.
282 EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
285 // GC_TODO: Width - add argument and description to function comment
286 // GC_TODO: Address - add argument and description to function comment
287 // GC_TODO: Count - add argument and description to function comment
288 // GC_TODO: Buffer - add argument and description to function comment
290 if (mBootScriptSave
== NULL
) {
291 return EFI_NOT_FOUND
;
294 mBootScriptSave
->Write (
297 EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE
,
308 BootScriptSavePciCfgReadWrite (
310 IN EFI_BOOT_SCRIPT_WIDTH Width
,
319 Save I/O write to boot script
323 TableName - Desired boot script table
325 (Standard EFI PCI read write script parameter)
329 EFI_NOT_FOUND - BootScriptSave Protocol not exist.
331 EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
334 // GC_TODO: Width - add argument and description to function comment
335 // GC_TODO: Address - add argument and description to function comment
336 // GC_TODO: Data - add argument and description to function comment
337 // GC_TODO: DataMask - add argument and description to function comment
339 if (mBootScriptSave
== NULL
) {
340 return EFI_NOT_FOUND
;
343 mBootScriptSave
->Write (
346 EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE
,
357 BootScriptSaveSmbusExecute (
359 IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress
,
360 IN EFI_SMBUS_DEVICE_COMMAND Command
,
361 IN EFI_SMBUS_OPERATION Operation
,
370 Save I/O write to boot script
374 TableName - Desired boot script table
376 (Standard EFI Smbus execute script parameter)
380 EFI_NOT_FOUND - BootScriptSave Protocol not exist.
382 EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
385 // GC_TODO: SlaveAddress - add argument and description to function comment
386 // GC_TODO: Command - add argument and description to function comment
387 // GC_TODO: Operation - add argument and description to function comment
388 // GC_TODO: PecCheck - add argument and description to function comment
389 // GC_TODO: Length - add argument and description to function comment
390 // GC_TODO: Buffer - add argument and description to function comment
392 if (mBootScriptSave
== NULL
) {
393 return EFI_NOT_FOUND
;
396 mBootScriptSave
->Write (
399 EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE
,
412 BootScriptSaveStall (
420 Save I/O write to boot script
424 TableName - Desired boot script table
426 (Standard EFI stall script parameter)
430 EFI_NOT_FOUND - BootScriptSave Protocol not exist.
432 EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
435 // GC_TODO: Duration - add argument and description to function comment
437 if (mBootScriptSave
== NULL
) {
438 return EFI_NOT_FOUND
;
441 mBootScriptSave
->Write (
444 EFI_BOOT_SCRIPT_STALL_OPCODE
,
452 BootScriptSaveDispatch (
454 IN EFI_PHYSICAL_ADDRESS EntryPoint
460 GC_TODO: Add function description
464 TableName - GC_TODO: add argument description
465 EntryPoint - GC_TODO: add argument description
469 EFI_NOT_FOUND - GC_TODO: Add description for return value
470 EFI_SUCCESS - GC_TODO: Add description for return value
474 if (mBootScriptSave
== NULL
) {
475 return EFI_NOT_FOUND
;
478 mBootScriptSave
->Write (
481 EFI_BOOT_SCRIPT_DISPATCH_OPCODE
,
491 BootScriptSaveInformation (
494 IN EFI_PHYSICAL_ADDRESS Buffer
500 Save a Information Opcode record in table specified with TableName
504 TableName - Desired boot script table
505 Length - Length of information in bytes
506 Buffer - Content of information that will be saved in script table
510 EFI_NOT_FOUND - BootScriptSave Protocol not exist.
512 EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
516 if (mBootScriptSave
== NULL
) {
517 return EFI_NOT_FOUND
;
520 mBootScriptSave
->Write (
523 EFI_BOOT_SCRIPT_INFORMATION_OPCODE
,
534 BootScriptSaveInformationUnicodeString (
542 Save a Information Opcode record in table specified with TableName, the information
547 TableName - Desired boot script table
548 String - The string that will be saved in script table
552 EFI_NOT_FOUND - BootScriptSave Protocol not exist.
554 EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
558 return BootScriptSaveInformation (
560 (UINT32
) EfiStrLen (String
) * 2 + 2,
561 (EFI_PHYSICAL_ADDRESS
)String
567 BootScriptSaveInformationAsciiString (
575 Save a Information Opcode record in table specified with TableName, the information
580 TableName - Desired boot script table
581 String - The string that will be saved in script table
585 EFI_NOT_FOUND - BootScriptSave Protocol not exist.
587 EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
591 return BootScriptSaveInformation (
593 (UINT32
) EfiAsciiStrLen (String
) + 1,
594 (EFI_PHYSICAL_ADDRESS
)String