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