]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseS3BootScriptLibNull/BootScriptLib.c
MdePkg: Add S3 library interfaces and base implementations
[mirror_edk2.git] / MdePkg / Library / BaseS3BootScriptLibNull / BootScriptLib.c
CommitLineData
fe69ac84 1/** @file\r
2 Null function implementation for EFI S3 boot script. \r
3\r
4 Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.<BR>\r
5\r
6 This program and the accompanying materials\r
7 are licensed and made available under the terms and conditions\r
8 of the BSD License which accompanies this distribution. The\r
9 full text of the license may be found at\r
10 http://opensource.org/licenses/bsd-license.php\r
11\r
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
14\r
15**/\r
16\r
17\r
18#include <Base.h>\r
19#include <Library/S3BootScriptLib.h>\r
20\r
21/**\r
22 Save I/O write to boot script \r
23\r
24 @param Width the width of the I/O operations.Enumerated in S3_BOOT_SCRIPT_LIB_WIDTH.\r
25 @param Address The base address of the I/O operations.\r
26 @param Count The number of I/O operations to perform.\r
27 @param Buffer The source buffer from which to write data.\r
28\r
29 @retval RETURN_OUT_OF_RESOURCES Not enough memory for the table do operation.\r
30 @retval RETURN_SUCCESS Opcode is added.\r
31**/\r
32RETURN_STATUS\r
33EFIAPI\r
34S3BootScriptSaveIoWrite (\r
35 IN S3_BOOT_SCRIPT_LIB_WIDTH Width,\r
36 IN UINT64 Address,\r
37 IN UINTN Count,\r
38 IN VOID *Buffer\r
39 )\r
40{\r
41 return RETURN_SUCCESS;\r
42}\r
43\r
44/**\r
45 Adds a record for an I/O modify operation into a S3 boot script table\r
46\r
47 @param Width The width of the I/O operations.Enumerated in S3_BOOT_SCRIPT_LIB_WIDTH.\r
48 @param Address The base address of the I/O operations.\r
49 @param Data A pointer to the data to be OR-ed.\r
50 @param DataMask A pointer to the data mask to be AND-ed with the data read from the register\r
51\r
52 @retval RETURN_OUT_OF_RESOURCES Not enough memory for the table do operation.\r
53 @retval RETURN_SUCCESS Opcode is added.\r
54**/\r
55RETURN_STATUS\r
56EFIAPI\r
57S3BootScriptSaveIoReadWrite (\r
58 IN S3_BOOT_SCRIPT_LIB_WIDTH Width,\r
59 IN UINT64 Address,\r
60 IN VOID *Data,\r
61 IN VOID *DataMask\r
62 )\r
63{\r
64 return RETURN_SUCCESS;\r
65}\r
66\r
67/**\r
68 Adds a record for a memory write operation into a specified boot script table.\r
69\r
70 @param Width The width of the I/O operations.Enumerated in S3_BOOT_SCRIPT_LIB_WIDTH.\r
71 @param Address The base address of the memory operations\r
72 @param Count The number of memory operations to perform.\r
73 @param Buffer The source buffer from which to write the data.\r
74\r
75 @retval RETURN_OUT_OF_RESOURCES Not enough memory for the table do operation.\r
76 @retval RETURN_SUCCESS Opcode is added.\r
77**/\r
78RETURN_STATUS\r
79EFIAPI\r
80S3BootScriptSaveMemWrite (\r
81 IN S3_BOOT_SCRIPT_LIB_WIDTH Width,\r
82 IN UINT64 Address,\r
83 IN UINTN Count,\r
84 IN VOID *Buffer\r
85 )\r
86{\r
87 return RETURN_SUCCESS;\r
88}\r
89/**\r
90 Adds a record for a memory modify operation into a specified boot script table.\r
91\r
92 @param Width The width of the I/O operations.Enumerated in S3_BOOT_SCRIPT_LIB_WIDTH.\r
93 @param Address The base address of the memory operations. Address needs alignment if required\r
94 @param Data A pointer to the data to be OR-ed.\r
95 @param DataMask A pointer to the data mask to be AND-ed with the data read from the register.\r
96\r
97 @retval RETURN_OUT_OF_RESOURCES Not enough memory for the table do operation.\r
98 @retval RETURN_SUCCESS Opcode is added.\r
99**/\r
100RETURN_STATUS\r
101EFIAPI\r
102S3BootScriptSaveMemReadWrite (\r
103 IN S3_BOOT_SCRIPT_LIB_WIDTH Width,\r
104 IN UINT64 Address,\r
105 IN VOID *Data,\r
106 IN VOID *DataMask\r
107 )\r
108{\r
109 return RETURN_SUCCESS;\r
110}\r
111/**\r
112 Adds a record for a PCI configuration space write operation into a specified boot script table.\r
113\r
114 @param Width The width of the I/O operations.Enumerated in S3_BOOT_SCRIPT_LIB_WIDTH.\r
115 @param Address The address within the PCI configuration space.\r
116 @param Count The number of PCI operations to perform.\r
117 @param Buffer The source buffer from which to write the data.\r
118\r
119 @retval RETURN_OUT_OF_RESOURCES Not enough memory for the table do operation.\r
120 @retval RETURN_SUCCESS Opcode is added.\r
121**/\r
122RETURN_STATUS\r
123EFIAPI\r
124S3BootScriptSavePciCfgWrite (\r
125 IN S3_BOOT_SCRIPT_LIB_WIDTH Width,\r
126 IN UINT64 Address,\r
127 IN UINTN Count,\r
128 IN VOID *Buffer\r
129 )\r
130{\r
131 return RETURN_SUCCESS;\r
132}\r
133\r
134/**\r
135 Adds a record for a PCI configuration space modify operation into a specified boot script table.\r
136\r
137 @param Width The width of the I/O operations.Enumerated in S3_BOOT_SCRIPT_LIB_WIDTH.\r
138 @param Address The address within the PCI configuration space.\r
139 @param Data A pointer to the data to be OR-ed.The size depends on Width.\r
140 @param DataMask A pointer to the data mask to be AND-ed.\r
141\r
142 @retval RETURN_OUT_OF_RESOURCES Not enough memory for the table do operation.\r
143 @retval RETURN__SUCCESS Opcode is added.\r
144**/\r
145RETURN_STATUS\r
146EFIAPI\r
147S3BootScriptSavePciCfgReadWrite (\r
148 IN S3_BOOT_SCRIPT_LIB_WIDTH Width,\r
149 IN UINT64 Address,\r
150 IN VOID *Data,\r
151 IN VOID *DataMask\r
152 )\r
153{\r
154 return RETURN_SUCCESS;\r
155}\r
156/**\r
157 Adds a record for a PCI configuration space modify operation into a specified boot script table.\r
158\r
159 @param Width The width of the I/O operations.Enumerated in S3_BOOT_SCRIPT_LIB_WIDTH.\r
160 @param Segment The PCI segment number for Address.\r
161 @param Address The address within the PCI configuration space.\r
162 @param Count The number of PCI operations to perform.\r
163 @param Buffer The source buffer from which to write the data.\r
164\r
165 @retval RETURN_OUT_OF_RESOURCES Not enough memory for the table do operation.\r
166 @retval RETURN_SUCCESS Opcode is added.\r
167**/\r
168RETURN_STATUS\r
169EFIAPI\r
170S3BootScriptSavePciCfg2Write (\r
171 IN S3_BOOT_SCRIPT_LIB_WIDTH Width,\r
172 IN UINT16 Segment,\r
173 IN UINT64 Address,\r
174 IN UINTN Count,\r
175 IN VOID *Buffer\r
176 )\r
177{\r
178 return RETURN_SUCCESS;\r
179}\r
180/**\r
181 Adds a record for a PCI configuration space modify operation into a specified boot script table.\r
182\r
183 @param Width The width of the I/O operations.Enumerated in S3_BOOT_SCRIPT_LIB_WIDTH.\r
184 @param Segment The PCI segment number for Address.\r
185 @param Address The address within the PCI configuration space.\r
186 @param Data A pointer to the data to be OR-ed. The size depends on Width.\r
187 @param DataMask A pointer to the data mask to be AND-ed.\r
188\r
189 @retval RETURN_OUT_OF_RESOURCES Not enough memory for the table do operation.\r
190 @retval RETURN_SUCCESS Opcode is added.\r
191**/\r
192RETURN_STATUS\r
193EFIAPI\r
194S3BootScriptSavePciCfg2ReadWrite (\r
195 IN S3_BOOT_SCRIPT_LIB_WIDTH Width,\r
196 IN UINT16 Segment,\r
197 IN UINT64 Address,\r
198 IN VOID *Data,\r
199 IN VOID *DataMask\r
200 )\r
201{ \r
202 return RETURN_SUCCESS;\r
203}\r
204/**\r
205 Adds a record for an SMBus command execution into a specified boot script table.\r
206\r
207 @param SmBusAddress Address that encodes the SMBUS Slave Address, SMBUS Command, SMBUS Data Length, and PEC.\r
208 @param Operation Indicates which particular SMBus protocol it will use to execute the SMBus\r
209 transactions.\r
210 @param Length A pointer to signify the number of bytes that this operation will do.\r
211 @param Buffer Contains the value of data to execute to the SMBUS slave device.\r
212 \r
213 @retval RETURN_OUT_OF_RESOURCES Not enough memory for the table do operation.\r
214 @retval RETURN_SUCCESS Opcode is added.\r
215**/\r
216RETURN_STATUS\r
217EFIAPI\r
218S3BootScriptSaveSmbusExecute (\r
219 IN UINTN SmBusAddress, \r
220 IN EFI_SMBUS_OPERATION Operation,\r
221 IN UINTN *Length,\r
222 IN VOID *Buffer\r
223 )\r
224{\r
225 return RETURN_SUCCESS;\r
226}\r
227/**\r
228 Adds a record for an execution stall on the processor into a specified boot script table.\r
229\r
230 @param Duration Duration in microseconds of the stall\r
231 \r
232 @retval RETURN_OUT_OF_RESOURCES Not enough memory for the table do operation.\r
233 @retval RETURN_SUCCESS Opcode is added.\r
234**/\r
235RETURN_STATUS\r
236EFIAPI\r
237S3BootScriptSaveStall (\r
238 IN UINTN Duration\r
239 )\r
240{\r
241 return RETURN_SUCCESS;\r
242}\r
243/**\r
244 Adds a record for dispatching specified arbitrary code into a specified boot script table.\r
245\r
246 @param EntryPoint Entry point of the code to be dispatched.\r
247 \r
248 @retval RETURN_OUT_OF_RESOURCES Not enough memory for the table do operation.\r
249 @retval RETURN_SUCCESS Opcode is added.\r
250**/\r
251RETURN_STATUS\r
252EFIAPI\r
253S3BootScriptSaveDispatch (\r
254 IN VOID *EntryPoint\r
255 )\r
256{\r
257 return RETURN_SUCCESS;\r
258}\r
259/**\r
260 Adds a record for an execution stall on the processor into a specified boot script table.\r
261\r
262 @param EntryPoint Entry point of the code to be dispatched.\r
263 @param Context Argument to be passed into the EntryPoint of the code to be dispatched.\r
264 \r
265 @retval RETURN_OUT_OF_RESOURCES Not enough memory for the table do operation.\r
266 @retval RETURN_SUCCESS Opcode is added.\r
267**/\r
268RETURN_STATUS\r
269EFIAPI\r
270S3BootScriptSaveDispatch2 (\r
271 IN VOID *EntryPoint,\r
272 IN VOID *Context\r
273 )\r
274{\r
275 return RETURN_SUCCESS;\r
276}\r
277\r
278/**\r
279 Adds a record for memory reads of the memory location and continues when the exit criteria is\r
280 satisfied or after a defined duration.\r
281 \r
282 @param Width The width of the memory operations.\r
283 @param Address The base address of the memory operations.\r
284 @param BitMask A pointer to the bit mask to be AND-ed with the data read from the register.\r
285 @param BitValue A pointer to the data value after to be Masked.\r
286 @param Duration Duration in microseconds of the stall.\r
287 @param LoopTimes The times of the register polling.\r
288\r
289 @retval RETURN_OUT_OF_RESOURCES Not enough memory for the table do operation.\r
290 @retval RETURN_SUCCESS Opcode is added.\r
291\r
292**/\r
293RETURN_STATUS\r
294EFIAPI\r
295S3BootScriptSaveMemPoll (\r
296 IN S3_BOOT_SCRIPT_LIB_WIDTH Width,\r
297 IN UINT64 Address,\r
298 IN VOID *BitMask,\r
299 IN VOID *BitValue,\r
300 IN UINTN Duration,\r
301 IN UINTN LoopTimes\r
302 )\r
303{\r
304 return RETURN_SUCCESS;\r
305}\r
306\r
307/**\r
308 Store arbitrary information in the boot script table. This opcode is a no-op on dispatch and is only\r
309 used for debugging script issues.\r
310 \r
311 @param InformationLength Length of the data in bytes\r
312 @param Information Information to be logged in the boot scrpit\r
313 \r
314 @retval RETURN_UNSUPPORTED If entering runtime, this method will not support.\r
315 @retval RETURN_OUT_OF_RESOURCES Not enough memory for the table do operation.\r
316 @retval RETURN_SUCCESS Opcode is added.\r
317\r
318**/\r
319RETURN_STATUS\r
320EFIAPI\r
321S3BootScriptSaveInformation (\r
322 IN UINT32 InformationLength, \r
323 IN VOID *Information\r
324 )\r
325{\r
326 return RETURN_SUCCESS;\r
327}\r
328/**\r
329 Adds a record for I/O reads the I/O location and continues when the exit criteria is satisfied or after a\r
330 defined duration.\r
331 \r
332 @param Width The width of the I/O operations. \r
333 @param Address The base address of the I/O operations.\r
334 @param Data The comparison value used for the polling exit criteria.\r
335 @param DataMask Mask used for the polling criteria. The bits in the bytes below Width which are zero\r
336 in Data are ignored when polling the memory address.\r
337 @param Delay The number of 100ns units to poll. Note that timer available may be of poorer\r
338 granularity so the delay may be longer.\r
339\r
340 @retval RETURN_OUT_OF_RESOURCES Not enough memory for the table do operation.\r
341 @retval RETURN_SUCCESS Opcode is added.\r
342\r
343**/\r
344RETURN_STATUS\r
345EFIAPI\r
346S3BootScriptSaveIoPoll (\r
347 IN S3_BOOT_SCRIPT_LIB_WIDTH Width,\r
348 IN UINT64 Address,\r
349 IN VOID *Data,\r
350 IN VOID *DataMask, \r
351 IN UINT64 Delay \r
352 )\r
353{\r
354 return RETURN_SUCCESS;\r
355}\r
356\r
357/**\r
358 Adds a record for PCI configuration space reads and continues when the exit criteria is satisfied or\r
359 after a defined duration.\r
360\r
361 @param Width The width of the I/O operations. \r
362 @param Address The address within the PCI configuration space.\r
363 @param Data The comparison value used for the polling exit criteria.\r
364 @param DataMask Mask used for the polling criteria. The bits in the bytes below Width which are zero\r
365 in Data are ignored when polling the memory address\r
366 @param Delay The number of 100ns units to poll. Note that timer available may be of poorer\r
367 granularity so the delay may be longer.\r
368\r
369 @retval RETURN_OUT_OF_RESOURCES Not enough memory for the table do operation.\r
370 @retval RETURN_SUCCESS Opcode is added.\r
371\r
372**/\r
373RETURN_STATUS\r
374EFIAPI\r
375S3BootScriptSavePciPoll (\r
376 IN S3_BOOT_SCRIPT_LIB_WIDTH Width,\r
377 IN UINT64 Address,\r
378 IN VOID *Data,\r
379 IN VOID *DataMask,\r
380 IN UINT64 Delay\r
381 )\r
382{\r
383 return RETURN_SUCCESS;\r
384}\r
385/**\r
386 Adds a record for PCI configuration space reads and continues when the exit criteria is satisfied or\r
387 after a defined duration.\r
388\r
389 @param Width The width of the I/O operations. \r
390 @param Segment The PCI segment number for Address.\r
391 @param Address The address within the PCI configuration space.\r
392 @param Data The comparison value used for the polling exit criteria.\r
393 @param DataMask Mask used for the polling criteria. The bits in the bytes below Width which are zero\r
394 in Data are ignored when polling the memory address\r
395 @param Delay The number of 100ns units to poll. Note that timer available may be of poorer\r
396 granularity so the delay may be longer.\r
397\r
398 @retval RETURN_OUT_OF_RESOURCES Not enough memory for the table do operation.\r
399 @retval RETURN_SUCCESS Opcode is added.\r
400 @note A known Limitations in the implementation: When interpreting the opcode EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE\r
401 EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE and EFI_BOOT_SCRIPT_PCI_CONFIG2_POLL_OPCODE, the 'Segment' parameter is assumed as \r
402 Zero, or else, assert.\r
403\r
404**/\r
405RETURN_STATUS\r
406EFIAPI\r
407S3BootScriptSavePci2Poll (\r
408 IN S3_BOOT_SCRIPT_LIB_WIDTH Width,\r
409 IN UINT16 Segment,\r
410 IN UINT64 Address,\r
411 IN VOID *Data,\r
412 IN VOID *DataMask,\r
413 IN UINT64 Delay\r
414 )\r
415{\r
416 return RETURN_SUCCESS;\r
417}\r
418/**\r
419 Save ASCII string information specified by Buffer to\r
420 boot script with opcode EFI_BOOT_SCRIPT_INFORMATION_OPCODE\r
421\r
422 @param String the ascii string to store into the S3 boot script table\r
423\r
424 @retval RETURN_NOT_FOUND BootScriptSave Protocol not exist.\r
425 @retval RETURN_SUCCESS BootScriptSave Protocol exist, always returns RETURN_SUCCESS\r
426\r
427**/\r
428RETURN_STATUS\r
429EFIAPI\r
430S3BootScriptSaveInformationAsciiString (\r
431 IN CONST CHAR8 *String\r
432 )\r
433{\r
434 return RETURN_SUCCESS;\r
435}\r
436/**\r
437 This is an function to close the S3 boot script table. The function could only be called in \r
438 BOOT time phase. To comply with the Framework spec definition on \r
439 EFI_BOOT_SCRIPT_SAVE_PROTOCOL.CloseTable(), this function will fulfill following things:\r
440 1. Closes the specified boot script table\r
441 2. It allocates a new memory pool to duplicate all the boot scripts in the specified table. \r
442 Once this function is called, the table maintained by the library will be destroyed \r
443 after it is copied into the allocated pool.\r
444 3. Any attempts to add a script record after calling this function will cause a new table \r
445 to be created by the library.\r
446 4. The base address of the allocated pool will be returned in Address. Note that after \r
447 using the boot script table, the CALLER is responsible for freeing the pool that is allocated\r
448 by this function. \r
449\r
450 In Spec PI1.1, this EFI_BOOT_SCRIPT_SAVE_PROTOCOL.CloseTable() is retired. By then it is not\r
451 necessary to provide this API in BootScriptLib. To provides this API for now is only to meet\r
452 the requirement from Framework Spec.\r
453 \r
454 If anyone does call CloseTable() on a real platform, then the caller is responsible for figuring out \r
455 how to get the script to run on an S3 resume because the boot script maintained by the lib will be \r
456 destroyed.\r
457 \r
458 @return the base address of the new copy of the boot script tble. \r
459\r
460**/\r
461UINT8*\r
462EFIAPI\r
463S3BootScriptCloseTable (\r
464 VOID\r
465 )\r
466{\r
467 return 0;\r
468}\r
469/**\r
470 Executes the S3 boot script table.\r
471\r
472 @param RETURN_SUCCESS The boot script table was executed successfully.\r
473 @param RETURN_UNSUPPORTED Invalid script table or opcode. \r
474**/\r
475RETURN_STATUS\r
476EFIAPI\r
477S3BootScriptExecute (\r
478 VOID\r
479 )\r
480{\r
481 return RETURN_SUCCESS;\r
482}\r
483/**\r
484 Move the last boot script entry to the position \r
485\r
486 @param BeforeOrAfter Specifies whether the opcode is stored before (TRUE) or after (FALSE) the position\r
487 in the boot script table specified by Position. If Position is NULL or points to\r
488 NULL then the new opcode is inserted at the beginning of the table (if TRUE) or end\r
489 of the table (if FALSE).\r
490 @param Position On entry, specifies the position in the boot script table where the opcode will be\r
491 inserted, either before or after, depending on BeforeOrAfter. On exit, specifies\r
492 the position of the inserted opcode in the boot script table.\r
493\r
494 @retval RETURN_OUT_OF_RESOURCES The table is not available.\r
495 @retval RETURN_INVALID_PARAMETER The Position is not a valid position in the boot script table.\r
496 @retval RETURN_SUCCESS Opcode is inserted.\r
497**/\r
498RETURN_STATUS\r
499EFIAPI\r
500S3BootScriptMoveLastOpcode (\r
501 IN BOOLEAN BeforeOrAfter,\r
502 IN OUT VOID **Position OPTIONAL\r
503)\r
504{\r
505 return RETURN_SUCCESS;\r
506}\r
507/**\r
508 Find a label within the boot script table and, if not present, optionally create it.\r
509\r
510 @param BeforeOrAfter Specifies whether the opcode is stored before (TRUE)\r
511 or after (FALSE) the position in the boot script table \r
512 specified by Position.\r
513 @param CreateIfNotFound Specifies whether the label will be created if the label \r
514 does not exists (TRUE) or not (FALSE).\r
515 @param Position On entry, specifies the position in the boot script table\r
516 where the opcode will be inserted, either before or after,\r
517 depending on BeforeOrAfter. On exit, specifies the position\r
518 of the inserted opcode in the boot script table.\r
519 @param Label Points to the label which will be inserted in the boot script table.\r
520\r
521 @retval EFI_SUCCESS The operation succeeded. A record was added into the\r
522 specified script table.\r
523 @retval EFI_INVALID_PARAMETER The parameter is illegal or the given boot script is not supported.\r
524 If the opcode is unknow or not supported because of the PCD \r
525 Feature Flags.\r
526 @retval EFI_OUT_OF_RESOURCES There is insufficient memory to store the boot script.\r
527\r
528**/\r
529RETURN_STATUS\r
530EFIAPI \r
531S3BootScriptLabel (\r
532 IN BOOLEAN BeforeOrAfter,\r
533 IN BOOLEAN CreateIfNotFound,\r
534 IN OUT VOID **Position OPTIONAL,\r
535 IN CONST CHAR8 *Label\r
536 )\r
537{\r
538 return RETURN_SUCCESS;\r
539}\r
540/**\r
541 Compare two positions in the boot script table and return their relative position.\r
542 @param Position1 The positions in the boot script table to compare\r
543 @param Position2 The positions in the boot script table to compare\r
544 @param RelativePosition On return, points to the result of the comparison\r
545\r
546 @retval EFI_SUCCESS The operation succeeded. A record was added into the\r
547 specified script table.\r
548 @retval EFI_INVALID_PARAMETER The parameter is illegal or the given boot script is not supported.\r
549 If the opcode is unknow or not supported because of the PCD \r
550 Feature Flags.\r
551 @retval EFI_OUT_OF_RESOURCES There is insufficient memory to store the boot script.\r
552\r
553**/\r
554RETURN_STATUS\r
555EFIAPI \r
556S3BootScriptCompare (\r
557 IN UINT8 *Position1,\r
558 IN UINT8 *Position2,\r
559 OUT UINTN *RelativePosition\r
560 )\r
561{\r
562 return RETURN_SUCCESS;\r
563}\r