]>
Commit | Line | Data |
---|---|---|
804405e7 | 1 | /*++\r |
2 | \r | |
3 | Copyright (c) 2006 - 2008, Intel Corporation \r | |
4 | All rights reserved. This program and the accompanying materials \r | |
5 | are licensed and made available under the terms and conditions of the BSD License \r | |
6 | which accompanies this distribution. The full text of the license may be found at \r | |
7 | http://opensource.org/licenses/bsd-license.php \r | |
8 | \r | |
9 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
10 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
11 | \r | |
12 | Module Name:\r | |
13 | UnixAutoscan.c\r | |
14 | \r | |
15 | Abstract:\r | |
16 | This PEIM to abstract memory auto-scan in an Unix environment.\r | |
17 | \r | |
18 | Revision History\r | |
19 | \r | |
20 | --*/\r | |
21 | \r | |
22 | #include "PiPei.h"\r | |
23 | #include <Ppi/UnixAutoScan.h>\r | |
804405e7 | 24 | #include <Ppi/MemoryDiscovered.h>\r |
25 | \r | |
26 | #include <Library/DebugLib.h>\r | |
27 | #include <Library/PeimEntryPoint.h>\r | |
28 | #include <Library/BaseLib.h>\r | |
29 | #include <Library/BaseMemoryLib.h>\r | |
30 | #include <Library/HobLib.h>\r | |
31 | #include <Library/PeiServicesLib.h>\r | |
32 | #include <Library/PeiServicesTablePointerLib.h>\r | |
33 | \r | |
34 | EFI_STATUS\r | |
35 | EFIAPI\r | |
36 | PeimInitializeUnixAutoScan (\r | |
cef5294b | 37 | IN EFI_PEI_FILE_HANDLE FileHandle,\r |
38 | IN CONST EFI_PEI_SERVICES **PeiServices\r | |
804405e7 | 39 | )\r |
40 | /*++\r | |
41 | \r | |
42 | Routine Description:\r | |
43 | Perform a call-back into the SEC simulator to get a memory value\r | |
44 | \r | |
45 | Arguments:\r | |
46 | FfsHeader - General purpose data available to every PEIM\r | |
47 | PeiServices - General purpose services available to every PEIM.\r | |
48 | \r | |
49 | Returns:\r | |
50 | None\r | |
51 | \r | |
52 | --*/\r | |
53 | {\r | |
54 | EFI_STATUS Status;\r | |
55 | EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;\r | |
56 | PEI_UNIX_AUTOSCAN_PPI *PeiUnixService;\r | |
57 | UINT64 MemorySize;\r | |
58 | EFI_PHYSICAL_ADDRESS MemoryBase;\r | |
804405e7 | 59 | UINTN Index;\r |
60 | EFI_RESOURCE_ATTRIBUTE_TYPE Attributes;\r | |
61 | \r | |
62 | \r | |
63 | DEBUG ((EFI_D_ERROR, "Unix Autoscan PEIM Loaded\n"));\r | |
64 | \r | |
65 | //\r | |
66 | // Get the PEI UNIX Autoscan PPI\r | |
67 | //\r | |
de13f245 | 68 | Status = PeiServicesLocatePpi (\r |
69 | &gPeiUnixAutoScanPpiGuid, // GUID\r | |
70 | 0, // INSTANCE\r | |
71 | &PpiDescriptor, // EFI_PEI_PPI_DESCRIPTOR\r | |
72 | (VOID **)&PeiUnixService // PPI\r | |
73 | );\r | |
804405e7 | 74 | ASSERT_EFI_ERROR (Status);\r |
75 | \r | |
804405e7 | 76 | Index = 0;\r |
77 | do {\r | |
78 | Status = PeiUnixService->UnixAutoScan (Index, &MemoryBase, &MemorySize);\r | |
79 | if (!EFI_ERROR (Status)) {\r | |
80 | Attributes =\r | |
81 | (\r | |
82 | EFI_RESOURCE_ATTRIBUTE_PRESENT |\r | |
83 | EFI_RESOURCE_ATTRIBUTE_INITIALIZED |\r | |
84 | EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE |\r | |
85 | EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE |\r | |
86 | EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE |\r | |
87 | EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE\r | |
88 | );\r | |
89 | \r | |
90 | if (Index == 0) {\r | |
91 | //\r | |
d73be1d1 | 92 | // Register the memory with the PEI Core\r |
804405e7 | 93 | //\r |
de13f245 | 94 | Status = PeiServicesInstallPeiMemory (MemoryBase, MemorySize);\r |
804405e7 | 95 | ASSERT_EFI_ERROR (Status);\r |
96 | \r | |
97 | Attributes |= EFI_RESOURCE_ATTRIBUTE_TESTED;\r | |
98 | }\r | |
99 | \r | |
100 | BuildResourceDescriptorHob (\r | |
101 | EFI_RESOURCE_SYSTEM_MEMORY,\r | |
102 | Attributes,\r | |
103 | MemoryBase,\r | |
104 | MemorySize\r | |
105 | );\r | |
106 | }\r | |
107 | Index++;\r | |
108 | } while (!EFI_ERROR (Status));\r | |
109 | \r | |
110 | //\r | |
111 | // Build the CPU hob with 36-bit addressing and 16-bits of IO space.\r | |
112 | //\r | |
113 | BuildCpuHob (36, 16);\r | |
114 | \r | |
115 | return Status;\r | |
116 | }\r |