1 /** @file
2   The internal header file that declared a data structure that is shared
3   between the SMM IPL and the SMM Core.
4 
5   Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>
6   This program and the accompanying materials are licensed and made available
7   under the terms and conditions of the BSD License which accompanies this
8   distribution.  The full text of the license may be found at
9   http://opensource.org/licenses/bsd-license.php
10 
11   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 
14 **/
15 
16 #ifndef _PI_SMM_CORE_PRIVATE_DATA_H_
17 #define _PI_SMM_CORE_PRIVATE_DATA_H_
18 
19 ///
20 /// Define values for the communications buffer used when gEfiEventDxeDispatchGuid is
21 /// event signaled.  This event is signaled by the DXE Core each time the DXE Core
22 /// dispatcher has completed its work.  When this event is signaled, the SMM Core
23 /// if notified, so the SMM Core can dispatch SMM drivers.  If COMM_BUFFER_SMM_DISPATCH_ERROR
24 /// is returned in the communication buffer, then an error occurred dispatching SMM
25 /// Drivers.  If COMM_BUFFER_SMM_DISPATCH_SUCCESS is returned, then the SMM Core
26 /// dispatched all the drivers it could.  If COMM_BUFFER_SMM_DISPATCH_RESTART is
27 /// returned, then the SMM Core just dispatched the SMM Driver that registered
28 /// the SMM Entry Point enabling the use of SMM Mode.  In this case, the SMM Core
29 /// should be notified again to dispatch more SMM Drivers using SMM Mode.
30 ///
31 #define COMM_BUFFER_SMM_DISPATCH_ERROR    0x00
32 #define COMM_BUFFER_SMM_DISPATCH_SUCCESS  0x01
33 #define COMM_BUFFER_SMM_DISPATCH_RESTART  0x02
34 
35 ///
36 /// Signature for the private structure shared between the SMM IPL and the SMM Core
37 ///
38 #define SMM_CORE_PRIVATE_DATA_SIGNATURE  SIGNATURE_32 ('s', 'm', 'm', 'c')
39 
40 ///
41 /// Private structure that is used to share information between the SMM IPL and
42 /// the SMM Core.  This structure is allocated from memory of type EfiRuntimeServicesData.
43 /// Since runtime memory types are converted to available memory when a legacy boot
44 /// is performed, the SMM Core must not access any fields of this structure if a legacy
45 /// boot is performed.  As a result, the SMM IPL must create an event notification
46 /// for the Legacy Boot event and notify the SMM Core that a legacy boot is being
47 /// performed.  The SMM Core can then use this information to filter accesses to
48 /// thos structure.
49 ///
50 typedef struct {
51   UINTN                           Signature;
52 
53   ///
54   /// The ImageHandle passed into the entry point of the SMM IPL.  This ImageHandle
55   /// is used by the SMM Core to fill in the ParentImageHandle field of the Loaded
56   /// Image Protocol for each SMM Driver that is dispatched by the SMM Core.
57   ///
58   EFI_HANDLE                      SmmIplImageHandle;
59 
60   ///
61   /// The number of SMRAM ranges passed from the SMM IPL to the SMM Core.  The SMM
62   /// Core uses these ranges of SMRAM to initialize the SMM Core memory manager.
63   ///
64   UINTN                           SmramRangeCount;
65 
66   ///
67   /// A table of SMRAM ranges passed from the SMM IPL to the SMM Core.  The SMM
68   /// Core uses these ranges of SMRAM to initialize the SMM Core memory manager.
69   ///
70   EFI_SMRAM_DESCRIPTOR            *SmramRanges;
71 
72   ///
73   /// The SMM Foundation Entry Point.  The SMM Core fills in this field when the
74   /// SMM Core is initialized.  The SMM IPL is responsbile for registering this entry
75   /// point with the SMM Configuration Protocol.  The SMM Configuration Protocol may
76   /// not be available at the time the SMM IPL and SMM Core are started, so the SMM IPL
77   /// sets up a protocol notification on the SMM Configuration Protocol and registers
78   /// the SMM Foundation Entry Point as soon as the SMM Configuration Protocol is
79   /// available.
80   ///
81   EFI_SMM_ENTRY_POINT             SmmEntryPoint;
82 
83   ///
84   /// Boolean flag set to TRUE while an SMI is being processed by the SMM Core.
85   ///
86   BOOLEAN                         SmmEntryPointRegistered;
87 
88   ///
89   /// Boolean flag set to TRUE while an SMI is being processed by the SMM Core.
90   ///
91   BOOLEAN                         InSmm;
92 
93   ///
94   /// This field is set by the SMM Core then the SMM Core is initialized.  This field is
95   /// used by the SMM Base 2 Protocol and SMM Communication Protocol implementations in
96   /// the SMM IPL.
97   ///
98   EFI_SMM_SYSTEM_TABLE2           *Smst;
99 
100   ///
101   /// This field is used by the SMM Communicatioon Protocol to pass a buffer into
102   /// a software SMI handler and for the software SMI handler to pass a buffer back to
103   /// the caller of the SMM Communication Protocol.
104   ///
105   VOID                            *CommunicationBuffer;
106 
107   ///
108   /// This field is used by the SMM Communicatioon Protocol to pass the size of a buffer,
109   /// in bytes, into a software SMI handler and for the software SMI handler to pass the
110   /// size, in bytes, of a buffer back to the caller of the SMM Communication Protocol.
111   ///
112   UINTN                           BufferSize;
113 
114   ///
115   /// This field is used by the SMM Communication Protocol to pass the return status from
116   /// a software SMI handler back to the caller of the SMM Communication Protocol.
117   ///
118   EFI_STATUS                      ReturnStatus;
119 
120   EFI_PHYSICAL_ADDRESS            PiSmmCoreImageBase;
121   UINT64                          PiSmmCoreImageSize;
122   EFI_PHYSICAL_ADDRESS            PiSmmCoreEntryPoint;
123 } SMM_CORE_PRIVATE_DATA;
124 
125 #endif
126