]> git.proxmox.com Git - mirror_edk2.git/blob - UefiCpuPkg/CpuMpPei/CpuMpPei.h
UefiCpuPkg/CpuMpPei: Sync BPS's mtrr setting to APs
[mirror_edk2.git] / UefiCpuPkg / CpuMpPei / CpuMpPei.h
1 /** @file
2 Definitions to install Multiple Processor PPI.
3
4 Copyright (c) 2015, 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
15 #ifndef _CPU_MP_PEI_H_
16 #define _CPU_MP_PEI_H_
17
18 #include <PiPei.h>
19
20 #include <Ppi/SecPlatformInformation.h>
21
22 #include <Library/BaseLib.h>
23 #include <Library/BaseMemoryLib.h>
24 #include <Library/DebugLib.h>
25 #include <Library/HobLib.h>
26 #include <Library/LocalApicLib.h>
27 #include <Library/MtrrLib.h>
28 #include <Library/PcdLib.h>
29 #include <Library/PeimEntryPoint.h>
30 #include <Library/PeiServicesLib.h>
31 #include <Library/SynchronizationLib.h>
32 #include <Library/TimerLib.h>
33 #include <Library/UefiCpuLib.h>
34 //
35 // AP state
36 //
37 typedef enum {
38 CpuStateIdle,
39 CpuStateBusy,
40 CpuStateDisabled
41 } CPU_STATE;
42
43 //
44 // AP reset code information
45 //
46 typedef struct {
47 UINT8 *RendezvousFunnelAddress;
48 UINTN PModeEntryOffset;
49 UINTN LModeEntryOffset;
50 UINTN RendezvousFunnelSize;
51 } MP_ASSEMBLY_ADDRESS_MAP;
52
53 typedef struct _PEI_CPU_MP_DATA PEI_CPU_MP_DATA;
54
55 #pragma pack()
56
57 typedef union {
58 struct {
59 UINT32 LimitLow : 16;
60 UINT32 BaseLow : 16;
61 UINT32 BaseMid : 8;
62 UINT32 Type : 4;
63 UINT32 System : 1;
64 UINT32 Dpl : 2;
65 UINT32 Present : 1;
66 UINT32 LimitHigh : 4;
67 UINT32 Software : 1;
68 UINT32 Reserved : 1;
69 UINT32 DefaultSize : 1;
70 UINT32 Granularity : 1;
71 UINT32 BaseHigh : 8;
72 } Bits;
73 UINT64 Uint64;
74 } IA32_GDT;
75
76 //
77 // MP CPU exchange information for AP reset code
78 //
79 typedef struct {
80 UINTN Lock;
81 UINTN StackStart;
82 UINTN StackSize;
83 UINTN CFunction;
84 IA32_DESCRIPTOR GdtrProfile;
85 IA32_DESCRIPTOR IdtrProfile;
86 UINTN BufferStart;
87 UINTN PmodeOffset;
88 UINTN NumApsExecuting;
89 UINTN LmodeOffset;
90 UINTN Cr3;
91 PEI_CPU_MP_DATA *PeiCpuMpData;
92 } MP_CPU_EXCHANGE_INFO;
93
94 #pragma pack()
95
96 typedef struct {
97 UINT32 ApicId;
98 EFI_HEALTH_FLAGS Health;
99 CPU_STATE State;
100 BOOLEAN CpuHealthy;
101 } PEI_CPU_DATA;
102
103 //
104 // PEI CPU MP Data save in memory
105 //
106 struct _PEI_CPU_MP_DATA {
107 UINT32 CpuCount;
108 UINT32 BspNumber;
109 UINTN Buffer;
110 UINTN CpuApStackSize;
111 MP_ASSEMBLY_ADDRESS_MAP AddressMap;
112 UINTN WakeupBuffer;
113 UINTN BackupBuffer;
114 UINTN BackupBufferSize;
115 UINTN ApFunction;
116 UINTN ApFunctionArgument;
117 volatile UINT32 FinishedCount;
118 BOOLEAN InitFlag;
119 MTRR_SETTINGS MtrrTable;
120 PEI_CPU_DATA *CpuData;
121 volatile MP_CPU_EXCHANGE_INFO *MpCpuExchangeInfo;
122 };
123
124 /**
125 Assembly code to get starting address and size of the rendezvous entry for APs.
126 Information for fixing a jump instruction in the code is also returned.
127
128 @param AddressMap Output buffer for address map information.
129 **/
130 VOID
131 EFIAPI
132 AsmGetAddressMap (
133 OUT MP_ASSEMBLY_ADDRESS_MAP *AddressMap
134 );
135
136 /**
137 Assembly code to load GDT table and update segment accordingly.
138
139 @param Gdtr Pointer to GDT descriptor
140 **/
141 VOID
142 EFIAPI
143 AsmInitializeGdt (
144 IN IA32_DESCRIPTOR *Gdtr
145 );
146
147
148 #endif