]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Library/PiDxeS3BootScriptLib/InternalBootScriptLib.h
MdeModulePkg: Add PiDxeS3BootScriptLib
[mirror_edk2.git] / MdeModulePkg / Library / PiDxeS3BootScriptLib / InternalBootScriptLib.h
1 /** @file
2 Support for S3 boot script lib. This file defined some internal macro and internal
3 data structure
4
5 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
6
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions
9 of the BSD License which accompanies this distribution. The
10 full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php
12
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15
16 **/
17 #ifndef __INTERNAL_BOOT_SCRIPT_LIB__
18 #define __INTERNAL_BOOT_SCRIPT_LIB__
19
20 #include <PiDxe.h>
21
22 #include <Guid/EventGroup.h>
23 #include <Protocol/SmmBase2.h>
24 #include <Protocol/DxeSmmReadyToLock.h>
25 #include <Protocol/SmmReadyToLock.h>
26
27 #include <Library/S3BootScriptLib.h>
28
29 #include <Library/UefiBootServicesTableLib.h>
30 #include <Library/BaseLib.h>
31 #include <Library/PcdLib.h>
32 #include <Library/SmbusLib.h>
33 #include <Library/IoLib.h>
34 #include <Library/PciLib.h>
35 #include <Library/DebugLib.h>
36 #include <Library/BaseMemoryLib.h>
37 #include <Library/TimerLib.h>
38 #include <Library/UefiLib.h>
39 #include <Library/LockBoxLib.h>
40
41 #include "BootScriptInternalFormat.h"
42
43 #define MAX_IO_ADDRESS 0xFFFF
44
45 #define PCI_ADDRESS_ENCODE(A) (UINTN)PCI_LIB_ADDRESS( \
46 (((A)& 0xff000000) >> 24), (((A) &0x00ff0000) >> 16), (((A) & 0xff00) >> 8), ((RShiftU64 ((A), 32) & 0xfff) | ((A)& 0xff)) \
47 )
48
49
50
51 typedef union {
52 UINT8 volatile *Buf;
53 UINT8 volatile *Uint8;
54 UINT16 volatile *Uint16;
55 UINT32 volatile *Uint32;
56 UINT64 volatile *Uint64;
57 UINTN volatile Uint;
58 } PTR;
59
60
61 // Minimum and maximum length for SMBus bus block protocols defined in SMBus spec 2.0.
62 //
63 #define MIN_SMBUS_BLOCK_LEN 1
64 #define MAX_SMBUS_BLOCK_LEN 32
65
66 //
67 // The boot script private data.
68 //
69 typedef struct {
70 UINT8 *TableBase;
71 UINT32 TableLength; // Record the actual memory length
72 UINT16 TableMemoryPageNumber; // Record the page number Allocated for the table
73 BOOLEAN AtRuntime; // Record if current state is after SmmReadyToLock
74 BOOLEAN InSmm; // Record if this library is in SMM.
75 } SCRIPT_TABLE_PRIVATE_DATA;
76
77 typedef
78 EFI_STATUS
79 (EFIAPI *DISPATCH_ENTRYPOINT_FUNC) (
80 IN EFI_HANDLE ImageHandle,
81 IN VOID *Context
82 );
83
84 extern SCRIPT_TABLE_PRIVATE_DATA *mS3BootScriptTablePtr;
85
86 //
87 // Define Opcode for Label which is implementation specific and no standard spec define.
88 //
89 #define S3_BOOT_SCRIPT_LIB_LABEL_OPCODE 0xFE
90
91 ///
92 /// The opcode indicate the start of the boot script table.
93 ///
94 #define S3_BOOT_SCRIPT_LIB_TABLE_OPCODE 0xAA
95 ///
96 /// The opcode indicate the end of the boot script table.
97 ///
98 #define S3_BOOT_SCRIPT_LIB_TERMINATE_OPCODE 0xFF
99
100
101 #endif //__INTERNAL_BOOT_SCRIPT_LIB__
102