]> git.proxmox.com Git - mirror_edk2.git/blob - UefiCpuPkg/Library/MpInitLib/MpLib.h
UefiCpuPkg/MpInitLib: Get ApLoopMode and MointorFilter size
[mirror_edk2.git] / UefiCpuPkg / Library / MpInitLib / MpLib.h
1 /** @file
2 Common header file for MP Initialize Library.
3
4 Copyright (c) 2016, 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 _MP_LIB_H_
16 #define _MP_LIB_H_
17
18 #include <PiPei.h>
19
20 #include <Register/Cpuid.h>
21 #include <Register/Msr.h>
22 #include <Register/LocalApic.h>
23 #include <Register/Microcode.h>
24
25 #include <Library/MpInitLib.h>
26 #include <Library/BaseLib.h>
27 #include <Library/BaseMemoryLib.h>
28 #include <Library/MemoryAllocationLib.h>
29 #include <Library/DebugLib.h>
30 #include <Library/LocalApicLib.h>
31 #include <Library/CpuLib.h>
32 #include <Library/UefiCpuLib.h>
33 #include <Library/TimerLib.h>
34 #include <Library/SynchronizationLib.h>
35 #include <Library/MtrrLib.h>
36 #include <Library/HobLib.h>
37
38 //
39 // AP loop state when APs are in idle state
40 // It's value is the same with PcdCpuApLoopMode
41 //
42 typedef enum {
43 ApInHltLoop = 1,
44 ApInMwaitLoop = 2,
45 ApInRunLoop = 3
46 } AP_LOOP_MODE;
47
48 //
49 // AP reset code information including code address and size,
50 // this structure will be shared be C code and assembly code.
51 // It is natural aligned by design.
52 //
53 typedef struct {
54 UINT8 *RendezvousFunnelAddress;
55 UINTN ModeEntryOffset;
56 UINTN RendezvousFunnelSize;
57 UINT8 *RelocateApLoopFuncAddress;
58 UINTN RelocateApLoopFuncSize;
59 } MP_ASSEMBLY_ADDRESS_MAP;
60
61 #pragma pack(1)
62
63 //
64 // MP CPU exchange information for AP reset code
65 // This structure is required to be packed because fixed field offsets
66 // into this structure are used in assembly code in this module
67 //
68 typedef struct {
69 UINTN Lock;
70 UINTN StackStart;
71 UINTN StackSize;
72 UINTN CFunction;
73 IA32_DESCRIPTOR GdtrProfile;
74 IA32_DESCRIPTOR IdtrProfile;
75 UINTN BufferStart;
76 UINTN ModeOffset;
77 UINTN NumApsExecuting;
78 UINTN CodeSegment;
79 UINTN DataSegment;
80 UINTN EnableExecuteDisable;
81 UINTN Cr3;
82 } MP_CPU_EXCHANGE_INFO;
83
84 #pragma pack()
85 /**
86 Assembly code to place AP into safe loop mode.
87
88 Place AP into targeted C-State if MONITOR is supported, otherwise
89 place AP into hlt state.
90 Place AP in protected mode if the current is long mode. Due to AP maybe
91 wakeup by some hardware event. It could avoid accessing page table that
92 may not available during booting to OS.
93
94 @param[in] MwaitSupport TRUE indicates MONITOR is supported.
95 FALSE indicates MONITOR is not supported.
96 @param[in] ApTargetCState Target C-State value.
97 @param[in] PmCodeSegment Protected mode code segment value.
98 **/
99 typedef
100 VOID
101 (EFIAPI * ASM_RELOCATE_AP_LOOP) (
102 IN BOOLEAN MwaitSupport,
103 IN UINTN ApTargetCState,
104 IN UINTN PmCodeSegment
105 );
106
107 /**
108 Assembly code to get starting address and size of the rendezvous entry for APs.
109 Information for fixing a jump instruction in the code is also returned.
110
111 @param[out] AddressMap Output buffer for address map information.
112 **/
113 VOID
114 EFIAPI
115 AsmGetAddressMap (
116 OUT MP_ASSEMBLY_ADDRESS_MAP *AddressMap
117 );
118
119 #endif
120