2 CPU PEI Module installs CPU Multiple Processor PPI.
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
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.
18 // Global Descriptor Table (GDT)
20 GLOBAL_REMOVE_IF_UNREFERENCED IA32_GDT mGdtEntries
[] = {
21 /* selector { Global Segment Descriptor } */
22 /* 0x00 */ {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, //null descriptor
23 /* 0x08 */ {{0xffff, 0, 0, 0x2, 1, 0, 1, 0xf, 0, 0, 1, 1, 0}}, //linear data segment descriptor
24 /* 0x10 */ {{0xffff, 0, 0, 0xf, 1, 0, 1, 0xf, 0, 0, 1, 1, 0}}, //linear code segment descriptor
25 /* 0x18 */ {{0xffff, 0, 0, 0x3, 1, 0, 1, 0xf, 0, 0, 1, 1, 0}}, //system data segment descriptor
26 /* 0x20 */ {{0xffff, 0, 0, 0xa, 1, 0, 1, 0xf, 0, 0, 1, 1, 0}}, //system code segment descriptor
27 /* 0x28 */ {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, //spare segment descriptor
28 /* 0x30 */ {{0xffff, 0, 0, 0x2, 1, 0, 1, 0xf, 0, 0, 1, 1, 0}}, //system data segment descriptor
29 /* 0x38 */ {{0xffff, 0, 0, 0xa, 1, 0, 1, 0xf, 0, 1, 0, 1, 0}}, //system code segment descriptor
30 /* 0x40 */ {{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}}, //spare segment descriptor
36 GLOBAL_REMOVE_IF_UNREFERENCED IA32_DESCRIPTOR mGdt
= {
37 sizeof (mGdtEntries
) - 1,
42 Get available system memory below 1MB by specified size.
44 @param WakeupBufferSize Wakeup buffer size required
46 @retval other Return wakeup buffer address below 1MB.
47 @retval -1 Cannot find free memory below 1MB.
51 IN UINTN WakeupBufferSize
54 EFI_PEI_HOB_POINTERS Hob
;
55 UINTN WakeupBufferStart
;
56 UINTN WakeupBufferEnd
;
59 // Get the HOB list for processing
61 Hob
.Raw
= GetHobList ();
64 // Collect memory ranges
66 while (!END_OF_HOB_LIST (Hob
)) {
67 if (Hob
.Header
->HobType
== EFI_HOB_TYPE_RESOURCE_DESCRIPTOR
) {
68 if ((Hob
.ResourceDescriptor
->PhysicalStart
< BASE_1MB
) &&
69 (Hob
.ResourceDescriptor
->ResourceType
== EFI_RESOURCE_SYSTEM_MEMORY
) &&
70 ((Hob
.ResourceDescriptor
->ResourceAttribute
&
71 (EFI_RESOURCE_ATTRIBUTE_READ_PROTECTED
|
72 EFI_RESOURCE_ATTRIBUTE_WRITE_PROTECTED
|
73 EFI_RESOURCE_ATTRIBUTE_EXECUTION_PROTECTED
77 // Need memory under 1MB to be collected here
79 WakeupBufferEnd
= (UINTN
) (Hob
.ResourceDescriptor
->PhysicalStart
+ Hob
.ResourceDescriptor
->ResourceLength
);
80 if (WakeupBufferEnd
> BASE_1MB
) {
82 // Wakeup buffer should be under 1MB
84 WakeupBufferEnd
= BASE_1MB
;
87 // Wakeup buffer should be aligned on 4KB
89 WakeupBufferStart
= (WakeupBufferEnd
- WakeupBufferSize
) & ~(SIZE_4KB
- 1);
90 if (WakeupBufferStart
< Hob
.ResourceDescriptor
->PhysicalStart
) {
94 // Create a memory allocation HOB.
96 BuildMemoryAllocationHob (
101 return WakeupBufferStart
;
107 Hob
.Raw
= GET_NEXT_HOB (Hob
);
114 The Entry point of the MP CPU PEIM.
116 This function will wakeup APs and collect CPU AP count and install the
119 @param FileHandle Handle of the file being invoked.
120 @param PeiServices Describes the list of possible PEI Services.
122 @retval EFI_SUCCESS MpServicePpi is installed successfully.
128 IN EFI_PEI_FILE_HANDLE FileHandle
,
129 IN CONST EFI_PEI_SERVICES
**PeiServices
135 // Load new GDT table on BSP
137 AsmInitializeGdt (&mGdt
);