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