]>
Commit | Line | Data |
---|---|---|
64d14edf | 1 | /** @file\r |
3a03e95e | 2 | Support for S3 boot script lib. This file defined some internal macro and internal\r |
64d14edf | 3 | data structure\r |
3a03e95e | 4 | \r |
3d20524a | 5 | Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r |
64d14edf | 6 | \r |
9d510e61 | 7 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
64d14edf | 8 | \r |
9 | **/\r | |
1436aea4 | 10 | \r |
64d14edf | 11 | #ifndef __INTERNAL_BOOT_SCRIPT_LIB__\r |
12 | #define __INTERNAL_BOOT_SCRIPT_LIB__\r | |
13 | \r | |
14 | #include <PiDxe.h>\r | |
15 | \r | |
16 | #include <Guid/EventGroup.h>\r | |
17 | #include <Protocol/SmmBase2.h>\r | |
18 | #include <Protocol/DxeSmmReadyToLock.h>\r | |
19 | #include <Protocol/SmmReadyToLock.h>\r | |
960f2d53 SZ |
20 | #include <Protocol/SmmExitBootServices.h>\r |
21 | #include <Protocol/SmmLegacyBoot.h>\r | |
64d14edf | 22 | \r |
23 | #include <Library/S3BootScriptLib.h>\r | |
24 | \r | |
25 | #include <Library/UefiBootServicesTableLib.h>\r | |
26 | #include <Library/BaseLib.h>\r | |
27 | #include <Library/PcdLib.h>\r | |
28 | #include <Library/SmbusLib.h>\r | |
29 | #include <Library/IoLib.h>\r | |
3d20524a | 30 | #include <Library/PciSegmentLib.h>\r |
64d14edf | 31 | #include <Library/DebugLib.h>\r |
32 | #include <Library/BaseMemoryLib.h>\r | |
33 | #include <Library/TimerLib.h>\r | |
34 | #include <Library/UefiLib.h>\r | |
35 | #include <Library/LockBoxLib.h>\r | |
36 | \r | |
37 | #include "BootScriptInternalFormat.h"\r | |
38 | \r | |
1436aea4 | 39 | #define MAX_IO_ADDRESS 0xFFFF\r |
64d14edf | 40 | \r |
e0e7f80c | 41 | //\r |
3d20524a | 42 | // Macro to convert a UEFI PCI address + segment to a PCI Segment Library PCI address\r |
e0e7f80c | 43 | //\r |
1436aea4 | 44 | #define PCI_ADDRESS_ENCODE(S, A) PCI_SEGMENT_LIB_ADDRESS(\\r |
3d20524a SZ |
45 | S, \\r |
46 | ((((UINTN)(A)) & 0xff000000) >> 24), \\r | |
47 | ((((UINTN)(A)) & 0x00ff0000) >> 16), \\r | |
48 | ((((UINTN)(A)) & 0xff00) >> 8), \\r | |
49 | ((RShiftU64 ((A), 32) & 0xfff) | ((A) & 0xff)) \\r | |
50 | )\r | |
64d14edf | 51 | \r |
52 | typedef union {\r | |
1436aea4 MK |
53 | UINT8 volatile *Buf;\r |
54 | UINT8 volatile *Uint8;\r | |
55 | UINT16 volatile *Uint16;\r | |
56 | UINT32 volatile *Uint32;\r | |
57 | UINT64 volatile *Uint64;\r | |
58 | UINTN volatile Uint;\r | |
64d14edf | 59 | } PTR;\r |
60 | \r | |
64d14edf | 61 | // Minimum and maximum length for SMBus bus block protocols defined in SMBus spec 2.0.\r |
62 | //\r | |
1436aea4 MK |
63 | #define MIN_SMBUS_BLOCK_LEN 1\r |
64 | #define MAX_SMBUS_BLOCK_LEN 32\r | |
64d14edf | 65 | \r |
66 | //\r | |
67 | // The boot script private data.\r | |
68 | //\r | |
69 | typedef struct {\r | |
1436aea4 MK |
70 | UINT8 *TableBase;\r |
71 | UINT32 TableLength; // Record the actual memory length\r | |
72 | UINT16 TableMemoryPageNumber; // Record the page number Allocated for the table\r | |
73 | BOOLEAN InSmm; // Record if this library is in SMM.\r | |
74 | BOOLEAN AtRuntime; // Record if current state is after SmmExitBootServices or SmmLegacyBoot.\r | |
75 | UINT32 BootTimeScriptLength; // Maintain boot time script length in LockBox after SmmReadyToLock in SMM.\r | |
76 | BOOLEAN SmmLocked; // Record if current state is after SmmReadyToLock\r | |
77 | BOOLEAN BackFromS3; // Indicate that the system is back from S3.\r | |
64d14edf | 78 | } SCRIPT_TABLE_PRIVATE_DATA;\r |
79 | \r | |
80 | typedef\r | |
81 | EFI_STATUS\r | |
1436aea4 | 82 | (EFIAPI *DISPATCH_ENTRYPOINT_FUNC)(\r |
64d14edf | 83 | IN EFI_HANDLE ImageHandle,\r |
84 | IN VOID *Context\r | |
85 | );\r | |
86 | \r | |
1436aea4 | 87 | extern SCRIPT_TABLE_PRIVATE_DATA *mS3BootScriptTablePtr;\r |
64d14edf | 88 | \r |
89 | //\r | |
90 | // Define Opcode for Label which is implementation specific and no standard spec define.\r | |
91 | //\r | |
1436aea4 | 92 | #define S3_BOOT_SCRIPT_LIB_LABEL_OPCODE 0xFE\r |
64d14edf | 93 | \r |
94 | ///\r | |
95 | /// The opcode indicate the start of the boot script table.\r | |
96 | ///\r | |
1436aea4 | 97 | #define S3_BOOT_SCRIPT_LIB_TABLE_OPCODE 0xAA\r |
64d14edf | 98 | ///\r |
99 | /// The opcode indicate the end of the boot script table.\r | |
100 | ///\r | |
1436aea4 | 101 | #define S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE 0xFF\r |
64d14edf | 102 | \r |
103 | #endif //__INTERNAL_BOOT_SCRIPT_LIB__\r |