]> git.proxmox.com Git - mirror_edk2.git/blob - EmbeddedPkg/Ebl/Hob.c
c541f6696801a1f2ad18044c8164cee913a67b0d
[mirror_edk2.git] / EmbeddedPkg / Ebl / Hob.c
1 /** @file
2 Hob command for EBL (Embedded Boot Loader)
3
4 Copyright (c) 2007, Intel Corporation<BR>
5 Portions copyright (c) 2008-2009, Apple Inc. All rights reserved.
6
7 All rights reserved. This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
15 Module Name: Hob.c
16
17 Search/Replace Dir with the name of your new command
18
19 Boot Mode:
20 ==========
21 BOOT_WITH_FULL_CONFIGURATION 0x00
22 BOOT_WITH_MINIMAL_CONFIGURATION 0x01
23 BOOT_ASSUMING_NO_CONFIGURATION_CHANGES 0x02
24 BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS 0x03
25 BOOT_WITH_DEFAULT_SETTINGS 0x04
26 BOOT_ON_S4_RESUME 0x05
27 BOOT_ON_S5_RESUME 0x06
28 BOOT_ON_S2_RESUME 0x10
29 BOOT_ON_S3_RESUME 0x11
30 BOOT_ON_FLASH_UPDATE 0x12
31 BOOT_IN_RECOVERY_MODE 0x20
32 BOOT_IN_RECOVERY_MODE_MASK 0x40
33 BOOT_SPECIAL_MASK 0x80
34
35 Mem Alloc HOB Type:
36 ===================
37 typedef enum {
38 EfiReservedMemoryType = 0x00
39 EfiLoaderCode = 0x01
40 EfiLoaderData = 0x02
41 EfiBootServicesCode = 0x03
42 EfiBootServicesData = 0x04
43 EfiRuntimeServicesCode = 0x05
44 EfiRuntimeServicesData = 0x06
45 EfiConventionalMemory = 0x07
46 EfiUnusableMemory = 0x08
47 EfiACPIReclaimMemory = 0x09
48 EfiACPIMemoryNVS = 0x0a
49 EfiMemoryMappedIO = 0x0b
50 EfiMemoryMappedIOPortSpace = 0x0c
51 EfiPalCode = 0x0d
52 EfiMaxMemoryType = 0x0e
53 } EFI_MEMORY_TYPE;
54
55 Resource Hob Tye:
56 =================
57 EFI_RESOURCE_SYSTEM_MEMORY 0
58 EFI_RESOURCE_MEMORY_MAPPED_IO 1
59 EFI_RESOURCE_IO 2
60 EFI_RESOURCE_FIRMWARE_DEVICE 3
61 EFI_RESOURCE_MEMORY_MAPPED_IO_PORT 4
62 EFI_RESOURCE_MEMORY_RESERVED 5
63 EFI_RESOURCE_IO_RESERVED 6
64 EFI_RESOURCE_MAX_MEMORY_TYPE 7
65
66 Resource Hob Attribute (last thing printed):
67 ============================================
68 EFI_RESOURCE_ATTRIBUTE_PRESENT 0x00000001
69 EFI_RESOURCE_ATTRIBUTE_INITIALIZED 0x00000002
70 EFI_RESOURCE_ATTRIBUTE_TESTED 0x00000004
71 EFI_RESOURCE_ATTRIBUTE_SINGLE_BIT_ECC 0x00000008
72 EFI_RESOURCE_ATTRIBUTE_MULTIPLE_BIT_ECC 0x00000010
73 EFI_RESOURCE_ATTRIBUTE_ECC_RESERVED_1 0x00000020
74 EFI_RESOURCE_ATTRIBUTE_ECC_RESERVED_2 0x00000040
75 EFI_RESOURCE_ATTRIBUTE_READ_PROTECTED 0x00000080
76 EFI_RESOURCE_ATTRIBUTE_WRITE_PROTECTED 0x00000100
77 EFI_RESOURCE_ATTRIBUTE_EXECUTION_PROTECTED 0x00000200
78 EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE 0x00000400
79 EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE 0x00000800
80 EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE 0x00001000
81 EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE 0x00002000
82 EFI_RESOURCE_ATTRIBUTE_16_BIT_IO 0x00004000
83 EFI_RESOURCE_ATTRIBUTE_32_BIT_IO 0x00008000
84 EFI_RESOURCE_ATTRIBUTE_64_BIT_IO 0x00010000
85 EFI_RESOURCE_ATTRIBUTE_UNCACHED_EXPORTED 0x00020000
86
87 **/
88
89 #include "Ebl.h"
90 // BugBug: Autogen does not allow this to be included currently
91 //#include <EdkModulePkg/Include/EdkDxe.h>
92
93 GLOBAL_REMOVE_IF_UNREFERENCED char *mHobResourceType[] = {
94 "Memory ",
95 "MMIO ",
96 "IO ",
97 "Firmware ",
98 "MMIO Port ",
99 "Reserved ",
100 "IO Reserved",
101 "Illegal "
102 };
103
104
105 /**
106 Dump out the HOBs in the system. HOBs are defined in the PI specificaiton
107 and they are used to hand off information from PEI to DXE.
108
109 Argv[0] - "hob"
110
111 @param Argc Number of command arguments in Argv
112 @param Argv Array of strings that represent the parsed command line.
113 Argv[0] is the comamnd name
114
115 @return EFI_SUCCESS
116
117 **/
118 EFI_STATUS
119 EblHobCmd (
120 IN UINTN Argc,
121 IN CHAR8 **Argv
122 )
123 {
124 UINTN CurrentRow;
125 EFI_PEI_HOB_POINTERS Hob;
126 EFI_MEMORY_TYPE_INFORMATION *EfiMemoryTypeInformation;
127 UINTN Index;
128
129 CurrentRow = 0;
130 for (Hob.Raw = GetHobList (); !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) {
131 if (Hob.Header->HobType == EFI_HOB_TYPE_HANDOFF) {
132 AsciiPrint ("PHIT HOB Ver %x Boot Mode %02x Top %lx Bottom %lx\n",
133 Hob.HandoffInformationTable->Version,
134 Hob.HandoffInformationTable->BootMode,
135 Hob.HandoffInformationTable->EfiMemoryTop,
136 Hob.HandoffInformationTable->EfiMemoryBottom
137 );
138
139 if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {
140 return EFI_SUCCESS;
141 }
142
143 AsciiPrint (" Free Top %lx Free Bottom %lx End Of HOB %lx\n",
144 Hob.HandoffInformationTable->EfiFreeMemoryTop,
145 Hob.HandoffInformationTable->EfiFreeMemoryBottom,
146 Hob.HandoffInformationTable->EfiEndOfHobList
147 );
148
149 } else if (Hob.Header->HobType == EFI_HOB_TYPE_MEMORY_ALLOCATION) {
150 // mod(%) on array index is just to prevent buffer overrun
151 AsciiPrint ("Mem Alloc HOB %a %g %08lx:%lx\n",
152 (Hob.MemoryAllocation->AllocDescriptor.MemoryType < EfiMaxMemoryType) ? gMemMapType[Hob.MemoryAllocation->AllocDescriptor.MemoryType] : "ILLEGAL TYPE",
153 &Hob.MemoryAllocation->AllocDescriptor.Name,
154 Hob.MemoryAllocation->AllocDescriptor.MemoryBaseAddress,
155 Hob.MemoryAllocation->AllocDescriptor.MemoryLength
156 );
157 if (CompareGuid (&gEfiHobMemoryAllocModuleGuid, &Hob.MemoryAllocation->AllocDescriptor.Name)) {
158 if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {
159 return EFI_SUCCESS;
160 }
161 AsciiPrint (" Module Name %g EntryPoint %lx\n", &Hob.MemoryAllocationModule->ModuleName, Hob.MemoryAllocationModule->EntryPoint);
162 }
163 } else if (Hob.Header->HobType == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {
164 AsciiPrint ("Resource HOB %a %g %08lx:%lx\n Attributes: %08x\n",
165 (Hob.ResourceDescriptor->ResourceType < EFI_RESOURCE_MAX_MEMORY_TYPE) ? mHobResourceType[Hob.ResourceDescriptor->ResourceType] : mHobResourceType[EFI_RESOURCE_MAX_MEMORY_TYPE],
166 &Hob.ResourceDescriptor->Owner,
167 Hob.ResourceDescriptor->PhysicalStart,
168 Hob.ResourceDescriptor->ResourceLength,
169 Hob.ResourceDescriptor->ResourceAttribute
170 );
171 if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {
172 return EFI_SUCCESS;
173 }
174 } else if (Hob.Header->HobType == EFI_HOB_TYPE_GUID_EXTENSION) {
175 AsciiPrint ("GUID HOB %g\n", &Hob.Guid->Name);
176 if (CompareGuid (&gEfiMemoryTypeInformationGuid, &Hob.Guid->Name)) {
177 EfiMemoryTypeInformation = GET_GUID_HOB_DATA (Hob.Guid);
178 for (Index = 0; Index < (GET_GUID_HOB_DATA_SIZE (Hob.Guid)/sizeof (EFI_MEMORY_TYPE_INFORMATION)); Index++, EfiMemoryTypeInformation++) {
179 if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {
180 return EFI_SUCCESS;
181 }
182 AsciiPrint (" %a 0x%08x\n",
183 (EfiMemoryTypeInformation->Type < EfiMaxMemoryType) ? gMemMapType[EfiMemoryTypeInformation->Type] : "END ",
184 EfiMemoryTypeInformation->NumberOfPages
185 );
186 }
187 }
188 } else if (Hob.Header->HobType == EFI_HOB_TYPE_FV) {
189 AsciiPrint ("FV HOB %08lx:%08lx\n", Hob.FirmwareVolume->BaseAddress, Hob.FirmwareVolume->Length);
190 } else if (Hob.Header->HobType == EFI_HOB_TYPE_CPU) {
191 AsciiPrint ("CPU HOB: Mem %x IO %x\n", Hob.Cpu->SizeOfMemorySpace, Hob.Cpu->SizeOfIoSpace);
192 } else if (Hob.Header->HobType == EFI_HOB_TYPE_MEMORY_POOL) {
193 AsciiPrint ("Mem Pool HOB:\n");
194 /* Not in PI
195 } else if (Hob.Header->HobType == EFI_HOB_TYPE_CV) {
196 AsciiPrint ("CV HOB: %08lx:%08lx\n", Hob.CapsuleVolume->BaseAddress, Hob.CapsuleVolume->Length);
197 */
198 }
199
200 if (EblAnyKeyToContinueQtoQuit (&CurrentRow, FALSE)) {
201 break;
202 }
203 }
204
205 return EFI_SUCCESS;
206 }
207
208
209 GLOBAL_REMOVE_IF_UNREFERENCED const EBL_COMMAND_TABLE mCmdHobTemplate[] =
210 {
211 {
212 "hob",
213 "; dump HOBs",
214 NULL,
215 EblHobCmd
216 }
217 };
218
219
220 /**
221 Initialize the commands in this in this file
222 **/
223 VOID
224 EblInitializeHobCmd (
225 VOID
226 )
227 {
228 if (FeaturePcdGet (PcdEmbeddedHobCmd)) {
229 EblAddCommands (mCmdHobTemplate, sizeof (mCmdHobTemplate)/sizeof (EBL_COMMAND_TABLE));
230 }
231 }
232