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