TianoCore EDK2 master
Loading...
Searching...
No Matches
AutoScanPei.c
1/*++ @file
2
3Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
4Portions copyright (c) 2011, Apple Inc. All rights reserved.
5SPDX-License-Identifier: BSD-2-Clause-Patent
6
7**/
8
9#include "PiPei.h"
10#include <Ppi/EmuThunk.h>
12
13#include <Library/DebugLib.h>
15#include <Library/BaseLib.h>
17#include <Library/HobLib.h>
20
22EFIAPI
23PeimInitializeAutoScanPei (
24 IN EFI_PEI_FILE_HANDLE FileHandle,
25 IN CONST EFI_PEI_SERVICES **PeiServices
26 )
27
28/*++
29
30Routine Description:
31 Perform a call-back into the SEC simulator to get a memory value
32
33Arguments:
34 FfsHeader - General purpose data available to every PEIM
35 PeiServices - General purpose services available to every PEIM.
36
37Returns:
38 None
39
40**/
41{
42 EFI_STATUS Status;
43 EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;
44 EMU_THUNK_PPI *Thunk;
45 UINT64 MemorySize;
46 EFI_PHYSICAL_ADDRESS MemoryBase;
47 UINTN Index;
49
50 DEBUG ((DEBUG_ERROR, "Emu Autoscan PEIM Loaded\n"));
51
52 //
53 // Get the PEI UNIX Autoscan PPI
54 //
55 Status = PeiServicesLocatePpi (
56 &gEmuThunkPpiGuid, // GUID
57 0, // INSTANCE
58 &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR
59 (VOID **)&Thunk // PPI
60 );
61 ASSERT_EFI_ERROR (Status);
62
63 Index = 0;
64 do {
65 Status = Thunk->MemoryAutoScan (Index, &MemoryBase, &MemorySize);
66 if (!EFI_ERROR (Status)) {
67 Attributes =
68 (
69 EFI_RESOURCE_ATTRIBUTE_PRESENT |
70 EFI_RESOURCE_ATTRIBUTE_INITIALIZED |
71 EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |
72 EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |
73 EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |
74 EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE
75 );
76
77 if (Index == 0) {
78 //
79 // Register the memory with the PEI Core
80 //
81 Status = PeiServicesInstallPeiMemory (MemoryBase, MemorySize);
82 ASSERT_EFI_ERROR (Status);
83
84 Attributes |= EFI_RESOURCE_ATTRIBUTE_TESTED;
85 }
86
88 EFI_RESOURCE_SYSTEM_MEMORY,
89 Attributes,
90 MemoryBase,
91 MemorySize
92 );
93 }
94
95 Index++;
96 } while (!EFI_ERROR (Status));
97
98 //
99 // Build the CPU hob with 57-bit addressing and 16-bits of IO space.
100 //
101 BuildCpuHob (57, 16);
102
103 return Status;
104}
UINT64 UINTN
VOID EFIAPI BuildCpuHob(IN UINT8 SizeOfMemorySpace, IN UINT8 SizeOfIoSpace)
Definition: HobLib.c:520
VOID EFIAPI BuildResourceDescriptorHob(IN EFI_RESOURCE_TYPE ResourceType, IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute, IN EFI_PHYSICAL_ADDRESS PhysicalStart, IN UINT64 NumberOfBytes)
Definition: HobLib.c:299
EFI_STATUS EFIAPI PeiServicesLocatePpi(IN CONST EFI_GUID *Guid, IN UINTN Instance, IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor, IN OUT VOID **Ppi)
EFI_STATUS EFIAPI PeiServicesInstallPeiMemory(IN EFI_PHYSICAL_ADDRESS MemoryBegin, IN UINT64 MemoryLength)
#define CONST
Definition: Base.h:259
#define IN
Definition: Base.h:279
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
#define DEBUG(Expression)
Definition: DebugLib.h:434
UINT32 EFI_RESOURCE_ATTRIBUTE_TYPE
Definition: PiHob.h:241
VOID * EFI_PEI_FILE_HANDLE
Definition: PiPeiCis.h:26
UINT64 EFI_PHYSICAL_ADDRESS
Definition: UefiBaseType.h:50
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29