• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*++
2 
3 Copyright (c) 2004 - 2007, 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
8 
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.
11 
12 Module Name:
13 
14     EfiScriptLib.h
15 
16 Abstract:
17 
18 
19 --*/
20 
21 #ifndef _EFI_SCRIPT_LIB_H_
22 #define _EFI_SCRIPT_LIB_H_
23 
24 #include "Tiano.h"
25 #include "EfiCommonLib.h"
26 #include "EfiBootScript.h"
27 #include EFI_PROTOCOL_DEFINITION (BootScriptSave)
28 
29 
30 EFI_STATUS
31 EFIAPI
32 BootScriptSaveInitialize (
33   IN EFI_HANDLE           ImageHandle,
34   IN EFI_SYSTEM_TABLE     *SystemTable
35   )
36 /*++
37 
38 Routine Description:
39 
40   Intialize Boot Script Lib if it has not yet been initialized.
41 
42 Arguments:
43 
44   ImageHandle     - The firmware allocated handle for the EFI image.
45 
46   SystemTable     - A pointer to the EFI System Table.
47 
48 Returns:
49 
50   EFI_STATUS always returns EFI_SUCCESS
51 
52 --*/
53 ;
54 
55 EFI_STATUS
56 EFIAPI
57 BootScriptSaveIoWrite (
58   IN  UINT16                            TableName,
59   IN  EFI_BOOT_SCRIPT_WIDTH             Width,
60   IN  UINT64                            Address,
61   IN  UINTN                             Count,
62   IN  VOID                              *Buffer
63   )
64 /*++
65 
66 Routine Description:
67 
68   Save I/O write to boot script with opcode EFI_BOOT_SCRIPT_IO_WRITE_OPCODE
69 
70 Arguments:
71 
72   TableName - Desired boot script table
73 
74   Width   - The width of the I/O operations.
75 
76   Address - The base address of the I/O operations.
77 
78   Count   - The number of I/O operations to perform.
79 
80   Buffer  - The source buffer from which to write data.
81 
82 Returns:
83 
84   EFI_NOT_FOUND - BootScriptSave Protocol not exist.
85 
86   EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
87 
88 --*/
89 ;
90 
91 EFI_STATUS
92 EFIAPI
93 BootScriptSaveIoReadWrite (
94   IN  UINT16                            TableName,
95   IN  EFI_BOOT_SCRIPT_WIDTH             Width,
96   IN  UINT64                            Address,
97   IN  VOID                              *Data,
98   IN  VOID                              *DataMask
99   )
100 /*++
101 
102 Routine Description:
103 
104   Save I/O modify to boot script with opcode EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE
105 
106 Arguments:
107 
108   TableName - Desired boot script table
109 
110   Width   - The width of the I/O operations.
111 
112   Address - The base address of the I/O operations.
113 
114   Data    - A pointer to the data to be OR-ed.
115 
116   DataMask  - A pointer to the data mask to be AND-ed with the data read from the register.
117 
118 Returns:
119 
120   EFI_NOT_FOUND - BootScriptSave Protocol not exist.
121 
122   EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
123 
124 --*/
125 ;
126 
127 EFI_STATUS
128 EFIAPI
129 BootScriptSaveMemWrite (
130   IN  UINT16                            TableName,
131   IN  EFI_BOOT_SCRIPT_WIDTH             Width,
132   IN  UINT64                            Address,
133   IN  UINTN                             Count,
134   IN  VOID                              *Buffer
135   )
136 /*++
137 
138 Routine Description:
139 
140   Save memory write to boot script with opcode EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE
141 
142 Arguments:
143 
144   TableName - Desired boot script table
145 
146   Width   - The width of the memory operations.
147 
148   Address - The base address of the memory operations.
149 
150   Count   - The number of memory operations to perform.
151 
152   Buffer  - The source buffer from which to write the data.
153 
154 Returns:
155 
156   EFI_NOT_FOUND - BootScriptSave Protocol not exist.
157 
158   EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
159 
160 --*/
161 ;
162 
163 EFI_STATUS
164 EFIAPI
165 BootScriptSaveMemReadWrite (
166   IN  UINT16                            TableName,
167   IN  EFI_BOOT_SCRIPT_WIDTH             Width,
168   IN  UINT64                            Address,
169   IN  VOID                              *Data,
170   IN  VOID                              *DataMask
171   )
172 /*++
173 
174 Routine Description:
175 
176   Save memory modify to boot script with opcode EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE
177 
178 Arguments:
179 
180   TableName - Desired boot script table
181 
182   Width   - The width of the memory operations.
183 
184   Address - The base address of the memory operations.
185 
186   Data    - A pointer to the data to be OR-ed.
187 
188   DataMask  - A pointer to the data mask to be AND-ed with the data read from the register.
189 
190 Returns:
191 
192   EFI_NOT_FOUND - BootScriptSave Protocol not exist.
193 
194   EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
195 
196 --*/
197 ;
198 
199 EFI_STATUS
200 EFIAPI
201 BootScriptSavePciCfgWrite (
202   IN  UINT16                            TableName,
203   IN  EFI_BOOT_SCRIPT_WIDTH             Width,
204   IN  UINT64                            Address,
205   IN  UINTN                             Count,
206   IN  VOID                              *Buffer
207   )
208 /*++
209 
210 Routine Description:
211 
212   Save PCI configuration space write operation to boot script with opcode
213   EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE
214 
215 Arguments:
216 
217   TableName - Desired boot script table
218 
219   Width   - The width of the PCI operations
220 
221   Address - The address within the PCI configuration space.
222 
223   Count   - The number of PCI operations to perform.
224 
225   Buffer  - The source buffer from which to write the data.
226 
227 Returns:
228 
229   EFI_NOT_FOUND - BootScriptSave Protocol not exist.
230 
231   EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
232 
233 --*/
234 ;
235 
236 EFI_STATUS
237 EFIAPI
238 BootScriptSavePciCfgReadWrite (
239   IN  UINT16                            TableName,
240   IN  EFI_BOOT_SCRIPT_WIDTH             Width,
241   IN  UINT64                            Address,
242   IN  VOID                              *Data,
243   IN  VOID                              *DataMask
244   )
245 /*++
246 
247 Routine Description:
248 
249   Save PCI configuration space modify operation to boot script with opcode
250   EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE
251 
252 Arguments:
253 
254   TableName - Desired boot script table
255 
256   Width   - The width of the PCI operations
257 
258   Address - The address within the PCI configuration space.
259 
260   Data    - A pointer to the data to be OR-ed.
261 
262   DataMask  - A pointer to the data mask to be AND-ed with the data read from the register.
263 
264 Returns:
265 
266   EFI_NOT_FOUND - BootScriptSave Protocol not exist.
267 
268   EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
269 
270 --*/
271 ;
272 ;
273 
274 EFI_STATUS
275 EFIAPI
276 BootScriptSaveSmbusExecute (
277   IN  UINT16                            TableName,
278   IN  EFI_SMBUS_DEVICE_ADDRESS          SlaveAddress,
279   IN  EFI_SMBUS_DEVICE_COMMAND          Command,
280   IN  EFI_SMBUS_OPERATION               Operation,
281   IN  BOOLEAN                           PecCheck,
282   IN  UINTN                             *Length,
283   IN  VOID                              *Buffer
284   )
285 /*++
286 
287 Routine Description:
288 
289   Save SMBus command execution to boot script with opcode
290   EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE
291 
292 Arguments:
293 
294   TableName     - Desired boot script table
295   SlaveAddress  - The SMBus address for the slave device that the operation is targeting.
296   Command       - The command that is transmitted by the SMBus host controller to the
297                   SMBus slave device.
298   Operation     - Indicates which particular SMBus protocol it will use to execute the
299                   SMBus transactions.
300   PecCheck      - Defines if Packet Error Code (PEC) checking is required for this operation.
301   Length        - A pointer to signify the number of bytes that this operation will do.
302   Buffer        - Contains the value of data to execute to the SMBUS slave device.
303 
304 Returns:
305 
306   EFI_NOT_FOUND - BootScriptSave Protocol not exist.
307 
308   EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
309 
310 --*/
311 ;
312 
313 EFI_STATUS
314 EFIAPI
315 BootScriptSaveStall (
316   IN  UINT16                            TableName,
317   IN  UINTN                             Duration
318   )
319 /*++
320 
321 Routine Description:
322 
323   Save execution stall on the processor to boot script with opcode
324   EFI_BOOT_SCRIPT_STALL_OPCODE
325 
326 Arguments:
327 
328   TableName     - Desired boot script table
329 
330   Duration      - Duration in microseconds of the stall.
331 
332 Returns:
333 
334   EFI_NOT_FOUND - BootScriptSave Protocol not exist.
335 
336   EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
337 
338 --*/
339 ;
340 
341 EFI_STATUS
342 EFIAPI
343 BootScriptSaveDispatch (
344   IN  UINT16                            TableName,
345   IN  EFI_PHYSICAL_ADDRESS              EntryPoint
346   )
347 /*++
348 
349 Routine Description:
350 
351   Save dispatching specified arbitrary code to boot script with opcode
352   EFI_BOOT_SCRIPT_DISPATCH_OPCODE
353 
354 Arguments:
355 
356   TableName     - Desired boot script table
357 
358   EntryPoint    - Entry point of the code to be dispatched.
359 
360 Returns:
361 
362   EFI_NOT_FOUND - BootScriptSave Protocol not exist.
363 
364   EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
365 
366 --*/
367 ;
368 
369 EFI_STATUS
370 EFIAPI
371 BootScriptMemPoll (
372   IN  UINT16                            TableName,
373   IN  EFI_BOOT_SCRIPT_WIDTH             Width,
374   IN  UINT64                            Address,
375   IN  VOID                              *BitMask,
376   IN  VOID                              *BitValue,
377   IN  UINTN                             Duration,
378   IN  UINTN                             LoopTimes
379   )
380 /*++
381 
382 Routine Description:
383   Polling one memory mapping register
384 
385 Arguments:
386   TableName - Desired boot script table
387 
388   Width     - The width of the memory operations.
389 
390   Address   - The base address of the memory operations.
391 
392   BitMask   - A pointer to the bit mask to be AND-ed with the data read from the register.
393 
394   BitValue  - A pointer to the data value after to be Masked.
395 
396   Duration  - Duration in microseconds of the stall.
397 
398   LoopTimes - The times of the register polling.
399 
400 Returns:
401 
402   EFI_SUCCESS           - The operation was executed successfully
403 
404 --*/
405 ;
406 
407 EFI_STATUS
408 EFIAPI
409 BootScriptSaveInformation (
410   IN  UINT16                                 TableName,
411   IN  UINT32                                 Length,
412   IN  EFI_PHYSICAL_ADDRESS                   Buffer
413   )
414 /*++
415 
416 Routine Description:
417 
418   Save a Information Opcode record in table specified with TableName
419 
420 Arguments:
421 
422   TableName   - Desired boot script table
423   Length         - Length of information in bytes
424   Buffer          - Content of information that will be saved in script table
425 
426 Returns:
427 
428   EFI_NOT_FOUND - BootScriptSave Protocol not exist.
429 
430   EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
431 
432 --*/
433 ;
434 
435 EFI_STATUS
436 EFIAPI
437 BootScriptSaveInformationUnicodeString (
438   IN        UINT16              TableName,
439   IN        CHAR16              *String
440   )
441 /*++
442 
443 Routine Description:
444 
445   Save a Information Opcode record in table specified with TableName, the information
446   is a unicode string.
447 
448 Arguments:
449 
450   TableName   - Desired boot script table
451   String          - The string that will be saved in script table
452 
453 Returns:
454 
455   EFI_NOT_FOUND - BootScriptSave Protocol not exist.
456 
457   EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
458 
459 --*/
460 ;
461 
462 EFI_STATUS
463 EFIAPI
464 BootScriptSaveInformationAsciiString (
465   IN        UINT16              TableName,
466   IN        CHAR8               *String
467   )
468 /*++
469 
470 Routine Description:
471 
472   Save a Information Opcode record in table specified with TableName, the information
473   is a ascii string.
474 
475 Arguments:
476 
477   TableName   - Desired boot script table
478   String          - The string that will be saved in script table
479 
480 Returns:
481 
482   EFI_NOT_FOUND - BootScriptSave Protocol not exist.
483 
484   EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
485 
486 --*/
487 ;
488 
489 #ifdef EFI_S3_RESUME
490 
491 #define INITIALIZE_SCRIPT(ImageHandle, SystemTable) \
492           BootScriptSaveInitialize(ImageHandle, SystemTable)
493 
494 #define SCRIPT_IO_WRITE(TableName, Width, Address, Count, Buffer) \
495           BootScriptSaveIoWrite(TableName, Width, Address, Count, Buffer)
496 
497 #define SCRIPT_IO_READ_WRITE(TableName, Width, Address, Data, DataMask) \
498           BootScriptSaveIoReadWrite(TableName, Width, Address, Data, DataMask)
499 
500 #define SCRIPT_MEM_WRITE(TableName, Width, Address, Count, Buffer) \
501           BootScriptSaveMemWrite(TableName, Width, Address, Count, Buffer)
502 
503 #define SCRIPT_MEM_WRITE_THIS(TableName, Width, Address, Count) \
504           BootScriptSaveMemWrite(TableName, Width, Address, Count, (VOID*)(UINTN)Address)
505 
506 #define SCRIPT_MEM_READ_WRITE(TableName, Width, Address, Data, DataMask) \
507           BootScriptSaveMemReadWrite(TableName, Width, Address, Data, DataMask)
508 
509 #define SCRIPT_PCI_CFG_WRITE(TableName, Width, Address, Count, Buffer) \
510           BootScriptSavePciCfgWrite(TableName, Width, Address, Count, Buffer)
511 
512 #define SCRIPT_PCI_CFG_READ_WRITE(TableName, Width, Address, Data, DataMask) \
513           BootScriptSavePciCfgReadWrite(TableName, Width, Address, Data, DataMask)
514 
515 #define SCRIPT_SMBUS_EXECUTE(TableName, SlaveAddress, Command, Operation, PecCheck, Length, Buffer) \
516           BootScriptSaveSmbusExecute(TableName, SlaveAddress, Command, Operation, PecCheck, Length, Buffer)
517 
518 #define SCRIPT_STALL(TableName, Duration) \
519           BootScriptSaveStall(TableName, Duration)
520 
521 #define SCRIPT_DISPATCH(TableName, EntryPoint) \
522           BootScriptSaveDispatch(TableName, EntryPoint)
523 
524 #define SCRIPT_MEM_POLL(TableName, Width, Address, BitMask, BitValue, Duration, LoopTimes) \
525           BootScriptMemPoll(TableName, Width, Address, BitMask, BitValue, Duration, LoopTimes)
526 
527 #define SCRIPT_INFORMATION(TableName, Length, Buffer) \
528           BootScriptSaveInformation(TableName, Length, Buffer)
529 
530 #define SCRIPT_INFORMATION_UNICODE_STRING(TableName, String) \
531           BootScriptSaveInformationUnicodeString(TableName, String)
532 
533 #define SCRIPT_INFORMATION_ASCII_STRING(TableName, String) \
534           BootScriptSaveInformationAsciiString(TableName, String)
535 
536 //
537 // For backward compatibility
538 //
539 #define SCRIPT_INOFRMATION(TableName, Length, Buffer) \
540           BootScriptSaveInformation(TableName, Length, Buffer)
541 
542 #define SCRIPT_INOFRMATION_UNICODE_STRING(TableName, String) \
543           BootScriptSaveInformationUnicodeString(TableName, String)
544 
545 #define SCRIPT_INOFRMATION_ASCII_STRING(TableName, String) \
546           BootScriptSaveInformationAsciiString(TableName, String)
547 
548 #else
549 
550 #define INITIALIZE_SCRIPT(ImageHandle, SystemTable)
551 
552 #define SCRIPT_IO_WRITE(TableName, Width, Address, Count, Buffer)
553 
554 #define SCRIPT_IO_READ_WRITE(TableName, Width, Address, Data, DataMask)
555 
556 #define SCRIPT_MEM_WRITE(TableName, Width, Address, Count, Buffer)
557 
558 #define SCRIPT_MEM_WRITE_THIS(TableName, Width, Address, Count)
559 
560 #define SCRIPT_MEM_READ_WRITE(TableName, Width, Address, Data, DataMask)
561 
562 #define SCRIPT_PCI_CFG_WRITE(TableName, Width, Address, Count, Buffer)
563 
564 #define SCRIPT_PCI_CFG_READ_WRITE(TableName, Width, Address, Data, DataMask)
565 
566 #define SCRIPT_SMBUS_EXECUTE(TableName, SlaveAddress, Command, Operation, PecCheck, Length, Buffer)
567 
568 #define SCRIPT_STALL(TableName, Duration)
569 
570 #define SCRIPT_DISPATCH(TableName, EntryPoint)
571 
572 #define SCRIPT_MEM_POLL(TableName, Width, Address, BitMask, BitValue, Duration, LoopTimes)
573 
574 #define SCRIPT_INFORMATION(TableName, Length, Buffer)
575 
576 #define SCRIPT_INFORMATION_UNICODE_STRING(TableName, String)
577 
578 #define SCRIPT_INFORMATION_ASCII_STRING(TableName, String)
579 
580 //
581 // For backward compatibility
582 //
583 #define SCRIPT_INOFRMATION(TableName, Length, Buffer)
584 
585 #define SCRIPT_INOFRMATION_UNICODE_STRING(TableName, String)
586 
587 #define SCRIPT_INOFRMATION_ASCII_STRING(TableName, String)
588 
589 #endif
590 
591 #endif
592