1 | /** @file
|
---|
2 | Base Null library instance of the QemuFwCfgS3Lib class.
|
---|
3 |
|
---|
4 | This library instance returns constant FALSE from QemuFwCfgS3Enabled(), and
|
---|
5 | all other library functions trigger assertion failures. It is suitable for
|
---|
6 | QEMU targets and machine types that never enable S3.
|
---|
7 |
|
---|
8 | Copyright (C) 2017, Red Hat, Inc.
|
---|
9 |
|
---|
10 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
11 | **/
|
---|
12 |
|
---|
13 | #include <Library/DebugLib.h>
|
---|
14 | #include <Library/QemuFwCfgS3Lib.h>
|
---|
15 |
|
---|
16 | /**
|
---|
17 | Determine if S3 support is explicitly enabled.
|
---|
18 |
|
---|
19 | @retval TRUE If S3 support is explicitly enabled. Other functions in this
|
---|
20 | library may be called (subject to their individual
|
---|
21 | restrictions).
|
---|
22 |
|
---|
23 | FALSE Otherwise. This includes unavailability of the firmware
|
---|
24 | configuration interface. No other function in this library
|
---|
25 | must be called.
|
---|
26 | **/
|
---|
27 | BOOLEAN
|
---|
28 | EFIAPI
|
---|
29 | QemuFwCfgS3Enabled (
|
---|
30 | VOID
|
---|
31 | )
|
---|
32 | {
|
---|
33 | return FALSE;
|
---|
34 | }
|
---|
35 |
|
---|
36 |
|
---|
37 | /**
|
---|
38 | Install the client module's FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION callback for
|
---|
39 | when the production of ACPI S3 Boot Script opcodes becomes possible.
|
---|
40 |
|
---|
41 | Take ownership of the client-provided Context, and pass it to the callback
|
---|
42 | function, when the latter is invoked.
|
---|
43 |
|
---|
44 | Allocate scratch space for those ACPI S3 Boot Script opcodes to work upon
|
---|
45 | that the client will produce in the callback function.
|
---|
46 |
|
---|
47 | @param[in] Callback FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION to invoke
|
---|
48 | when the production of ACPI S3 Boot Script
|
---|
49 | opcodes becomes possible. Callback() may be
|
---|
50 | called immediately from
|
---|
51 | QemuFwCfgS3CallWhenBootScriptReady().
|
---|
52 |
|
---|
53 | @param[in,out] Context Client-provided data structure for the
|
---|
54 | Callback() callback function to consume.
|
---|
55 |
|
---|
56 | If Context points to dynamically allocated
|
---|
57 | memory, then Callback() must release it.
|
---|
58 |
|
---|
59 | If Context points to dynamically allocated
|
---|
60 | memory, and
|
---|
61 | QemuFwCfgS3CallWhenBootScriptReady() returns
|
---|
62 | successfully, then the caller of
|
---|
63 | QemuFwCfgS3CallWhenBootScriptReady() must
|
---|
64 | neither dereference nor even evaluate Context
|
---|
65 | any longer, as ownership of the referenced area
|
---|
66 | has been transferred to Callback().
|
---|
67 |
|
---|
68 | @param[in] ScratchBufferSize The size of the scratch buffer that will hold,
|
---|
69 | in reserved memory, all client data read,
|
---|
70 | written, and checked by the ACPI S3 Boot Script
|
---|
71 | opcodes produced by Callback().
|
---|
72 |
|
---|
73 | @retval RETURN_UNSUPPORTED The library instance does not support this
|
---|
74 | function.
|
---|
75 |
|
---|
76 | @retval RETURN_NOT_FOUND The fw_cfg DMA interface to QEMU is
|
---|
77 | unavailable.
|
---|
78 |
|
---|
79 | @retval RETURN_BAD_BUFFER_SIZE ScratchBufferSize is too large.
|
---|
80 |
|
---|
81 | @retval RETURN_OUT_OF_RESOURCES Memory allocation failed.
|
---|
82 |
|
---|
83 | @retval RETURN_SUCCESS Callback() has been installed, and the
|
---|
84 | ownership of Context has been transferred.
|
---|
85 | Reserved memory has been allocated for the
|
---|
86 | scratch buffer.
|
---|
87 |
|
---|
88 | A successful invocation of
|
---|
89 | QemuFwCfgS3CallWhenBootScriptReady() cannot
|
---|
90 | be rolled back.
|
---|
91 |
|
---|
92 | @return Error codes from underlying functions.
|
---|
93 | **/
|
---|
94 |
|
---|
95 | RETURN_STATUS
|
---|
96 | EFIAPI
|
---|
97 | QemuFwCfgS3CallWhenBootScriptReady (
|
---|
98 | IN FW_CFG_BOOT_SCRIPT_CALLBACK_FUNCTION *Callback,
|
---|
99 | IN OUT VOID *Context, OPTIONAL
|
---|
100 | IN UINTN ScratchBufferSize
|
---|
101 | )
|
---|
102 | {
|
---|
103 | ASSERT (FALSE);
|
---|
104 | return RETURN_UNSUPPORTED;
|
---|
105 | }
|
---|