1 /** @file
2   Header file for S3 Boot Script Saver thunk driver.
3 
4   Copyright (c) 2010 - 2014, Intel Corporation. All rights reserved.<BR>
5   This program and the accompanying materials
6   are licensed and made available under the terms and conditions of the BSD License
7   which accompanies this distribution.  The full text of the license may be found at
8   http://opensource.org/licenses/bsd-license.php
9 
10   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 
13 **/
14 #ifndef __BOOT_SCRIPT_SAVE_ON_S3_SAVE_STATE_H__
15 #define __BOOT_SCRIPT_SAVE_ON_S3_SAVE_STATE_H__
16 #include <FrameworkDxe.h>
17 
18 #include <Protocol/BootScriptSave.h>
19 #include <Protocol/S3SaveState.h>
20 
21 #include <Library/BaseLib.h>
22 #include <Library/DebugLib.h>
23 #include <Library/UefiBootServicesTableLib.h>
24 #include <Library/UefiRuntimeServicesTableLib.h>
25 #include <Library/SmbusLib.h>
26 #include <Library/PeCoffLib.h>
27 #include <Library/PcdLib.h>
28 #include <Library/MemoryAllocationLib.h>
29 #include <Library/DxeServicesLib.h>
30 #include <Library/CacheMaintenanceLib.h>
31 #include <Library/BaseMemoryLib.h>
32 #include <Library/DevicePathLib.h>
33 #include <Library/UefiLib.h>
34 
35 #include <Guid/BootScriptThunkData.h>
36 #include <Guid/MemoryProfile.h>
37 
38 #include <IndustryStandard/SmBus.h>
39 
40 typedef
41 EFI_STATUS
42 (EFIAPI *DISPATCH_ENTRYPOINT_FUNC) (
43   IN EFI_HANDLE ImageHandle,
44   IN VOID       *Context
45   );
46 
47 /**
48   Adds a record into a specified Framework boot script table.
49 
50   This function is used to store a boot script record into a given boot
51   script table. If the table specified by TableName is nonexistent in the
52   system, a new table will automatically be created and then the script record
53   will be added into the new table. A boot script table can add new script records
54   until EFI_BOOT_SCRIPT_SAVE_PROTOCOL.CloseTable() is called. Currently, the only
55   meaningful table name is EFI_ACPI_S3_RESUME_SCRIPT_TABLE. This function is
56   responsible for allocating necessary memory for the script.
57 
58   This function has a variable parameter list. The exact parameter list depends on
59   the OpCode that is passed into the function. If an unsupported OpCode or illegal
60   parameter list is passed in, this function returns EFI_INVALID_PARAMETER.
61   If there are not enough resources available for storing more scripts, this function returns
62   EFI_OUT_OF_RESOURCES.
63 
64   @param  This                  A pointer to the EFI_BOOT_SCRIPT_SAVE_PROTOCOL instance.
65   @param  TableName             Name of the script table. Currently, the only meaningful value is
66                                 EFI_ACPI_S3_RESUME_SCRIPT_TABLE.
67   @param  OpCode                The operation code (opcode) number.
68   @param  ...                   Argument list that is specific to each opcode.
69 
70   @retval EFI_SUCCESS           The operation succeeded. A record was added into the
71                                 specified script table.
72   @retval EFI_INVALID_PARAMETER The parameter is illegal or the given boot script is not supported.
73                                 If the opcode is unknow or not supported because of the PCD
74                                 Feature Flags.
75   @retval EFI_OUT_OF_RESOURCES  There is insufficient memory to store the boot script.
76 
77 **/
78 EFI_STATUS
79 EFIAPI
80 BootScriptWrite (
81   IN EFI_BOOT_SCRIPT_SAVE_PROTOCOL    *This,
82   IN UINT16                           TableName,
83   IN UINT16                           OpCode,
84   ...
85   );
86 
87 /**
88   Closes the specified script table.
89 
90   This function closes the specified boot script table and returns the base address
91   of the table. It allocates a new pool to duplicate all the boot scripts in the specified
92   table. Once this function is called, the specified table will be destroyed after it is
93   copied into the allocated pool. As a result, any attempts to add a script record into a
94   closed table will cause a new table to be created. The base address of the allocated pool
95   will be returned in Address. After using the boot script table, the caller is responsible
96   for freeing the pool that is allocated by this function. If the boot script table,
97   such as EFI_ACPI_S3_RESUME_SCRIPT_TABLE, is required to be stored in a nonperturbed
98   memory region, the caller should copy the table into the nonperturbed memory region by itself.
99 
100   @param  This                  A pointer to the EFI_BOOT_SCRIPT_SAVE_PROTOCOL instance.
101   @param  TableName             Name of the script table. Currently, the only meaningful value is
102                                  EFI_ACPI_S3_RESUME_SCRIPT_TABLE.
103   @param  Address               A pointer to the physical address where the table begins.
104 
105   @retval EFI_SUCCESS           The table was successfully returned.
106   @retval EFI_NOT_FOUND         The specified table was not created previously.
107   @retval EFI_OUT_OF_RESOURCE   Memory is insufficient to hold the reorganized boot script table.
108   @retval EFI_UNSUPPORTED       the table type is not EFI_ACPI_S3_RESUME_SCRIPT_TABLE
109 
110 **/
111 EFI_STATUS
112 EFIAPI
113 BootScriptCloseTable (
114   IN EFI_BOOT_SCRIPT_SAVE_PROTOCOL    *This,
115   IN UINT16                           TableName,
116   OUT EFI_PHYSICAL_ADDRESS            *Address
117   );
118 
119 #endif
120