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