3 Copyright (c) 2004 - 2007, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
24 #if (PI_SPECIFICATION_VERSION >= 0x00010000)
26 #ifdef EFI_NT_EMULATOR
27 EFI_PEI_SERVICES
**gPeiServices
;
32 SetPeiServicesTablePointer (
33 IN EFI_PEI_SERVICES
**PeiServices
39 Save PeiService pointer so that it can be retrieved anywhere.
43 PeiServices - The direct pointer to PeiServiceTable.
44 PhyscialAddress - The physcial address of variable PeiServices.
52 #ifdef EFI_NT_EMULATOR
55 // For NT32, set EFI_PEI_SERVICES** to global variable.
57 gPeiServices
= PeiServices
;
61 // For X86 processor,the EFI_PEI_SERVICES** is stored in the
62 // 4 bytes immediately preceding the Interrupt Descriptor Table.
65 IdtBaseAddress
= (UINTN
)ReadIdtBase();
66 *(UINTN
*)(IdtBaseAddress
- 4) = (UINTN
)PeiServices
;
73 GetPeiServicesTablePointer (
80 Get PeiService pointer.
87 The direct pointer to PeiServiceTable.
91 EFI_PEI_SERVICES
**PeiServices
;
93 #ifdef EFI_NT_EMULATOR
96 // For NT32, set EFI_PEI_SERVICES** to global variable.
98 PeiServices
= gPeiServices
;
102 // For X86 processor,the EFI_PEI_SERVICES** is stored in the
103 // 4 bytes immediately preceding the Interrupt Descriptor Table.
105 UINTN IdtBaseAddress
;
106 IdtBaseAddress
= (UINTN
)ReadIdtBase();
107 PeiServices
= (EFI_PEI_SERVICES
**)(UINTN
)(*(UINTN
*)(IdtBaseAddress
- 4));
115 IN EFI_PEI_SERVICES
**PeiServices
121 Migrate IDT from temporary memory to real memory where preceded with 4 bytes for
122 storing PeiService pointer.
126 PeiServices - The direct pointer to PeiServiceTable.
134 #ifndef EFI_NT_EMULATOR
141 IdtEntrySize
= ReadIdtLimit();
142 OldIdtBase
= ReadIdtBase();
143 Size
= sizeof(PEI_IDT_TABLE
) + (IdtEntrySize
+ 1);
144 Status
= (*PeiServices
)->AllocatePool (PeiServices
, Size
, &NewIdtBase
);
145 ASSERT_PEI_ERROR (PeiServices
, Status
);
146 (*PeiServices
)->CopyMem ((VOID
*)((UINTN
)NewIdtBase
+ sizeof(PEI_IDT_TABLE
)), (VOID
*)OldIdtBase
, (IdtEntrySize
+ 1));
147 SetIdtBase(((UINTN
)NewIdtBase
+ sizeof(PEI_IDT_TABLE
)), IdtEntrySize
);
148 SetPeiServicesTablePointer(PeiServices
);