1 /** @file
2 
3 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
4 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
8 
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.
11 
12 Module Name:
13   HobGeneration.h
14 
15 Abstract:
16 
17 Revision History:
18 
19 **/
20 
21 #ifndef _DXELDR_HOB_GENERATION_H_
22 #define _DXELDR_HOB_GENERATION_H_
23 
24 #include "DxeIpl.h"
25 
26 #define EFI_MEMORY_BELOW_1MB_START     0x86000
27 #define EFI_MEMORY_BELOW_1MB_END       0x9F800
28 #define EFI_MEMORY_STACK_PAGE_NUM      0x20
29 #define CONSUMED_MEMORY                0x100000 * 80
30 
31 #define NV_STORAGE_START               0x15000
32 #define NV_STORAGE_STATE               0x19000
33 
34 #pragma pack(1)
35 
36 typedef struct {
37   EFI_HOB_GUID_TYPE             Hob;
38   EFI_MEMORY_TYPE_INFORMATION   Info[10];
39 } MEMORY_TYPE_INFORMATION_HOB;
40 
41 typedef struct {
42   EFI_HOB_GUID_TYPE             Hob;
43   EFI_PHYSICAL_ADDRESS          Table;
44 } TABLE_HOB;
45 
46 typedef struct {
47   EFI_HOB_GUID_TYPE             Hob;
48   EFI_PHYSICAL_ADDRESS          Interface;
49 } PROTOCOL_HOB;
50 
51 typedef struct {
52   EFI_HOB_GUID_TYPE                         Hob;
53   // Note: we get only one PCI Segment now.
54   EFI_PCI_EXPRESS_BASE_ADDRESS_INFORMATION  PciExpressBaseAddressInfo;
55 } PCI_EXPRESS_BASE_HOB;
56 
57 typedef struct {
58   EFI_HOB_GUID_TYPE             Hob;
59   EFI_ACPI_DESCRIPTION          AcpiDescription;
60 } ACPI_DESCRIPTION_HOB;
61 
62 typedef struct {
63   EFI_HOB_GUID_TYPE             Hob;
64   EFI_FLASH_MAP_FS_ENTRY_DATA   FvbInfo;
65 } FVB_HOB;
66 
67 typedef struct {
68   EFI_HOB_HANDOFF_INFO_TABLE        Phit;
69   EFI_HOB_FIRMWARE_VOLUME           Bfv;
70   EFI_HOB_RESOURCE_DESCRIPTOR       BfvResource;
71   EFI_HOB_CPU                       Cpu;
72   EFI_HOB_MEMORY_ALLOCATION_STACK   Stack;
73   EFI_HOB_MEMORY_ALLOCATION         MemoryAllocation;
74   EFI_HOB_RESOURCE_DESCRIPTOR       MemoryFreeUnder1MB;
75   EFI_HOB_RESOURCE_DESCRIPTOR       MemoryAbove1MB;
76   EFI_HOB_RESOURCE_DESCRIPTOR       MemoryAbove4GB;
77   EFI_HOB_MEMORY_ALLOCATION_MODULE  DxeCore;
78   EFI_HOB_RESOURCE_DESCRIPTOR       MemoryDxeCore;
79   MEMORY_TYPE_INFORMATION_HOB       MemoryTypeInfo;
80   TABLE_HOB                         Acpi;
81   TABLE_HOB                         Acpi20;
82   TABLE_HOB                         Smbios;
83   TABLE_HOB                         Mps;
84   /**
85   PROTOCOL_HOB                      FlushInstructionCache;
86   PROTOCOL_HOB                      TransferControl;
87   PROTOCOL_HOB                      PeCoffLoader;
88   PROTOCOL_HOB                      EfiDecompress;
89   PROTOCOL_HOB                      TianoDecompress;
90   **/
91   PROTOCOL_HOB                      SerialStatusCode;
92   MEMORY_DESC_HOB                   MemoryDescriptor;
93   PCI_EXPRESS_BASE_HOB              PciExpress;
94   ACPI_DESCRIPTION_HOB              AcpiInfo;
95 
96   EFI_HOB_RESOURCE_DESCRIPTOR       NvStorageFvResource;
97 
98   FVB_HOB                           NvStorageFvb;
99   FVB_HOB                           NvStorage;
100 
101   EFI_HOB_RESOURCE_DESCRIPTOR       NvFtwFvResource;
102   FVB_HOB                           NvFtwFvb;
103   FVB_HOB                           NvFtwWorking;
104   FVB_HOB                           NvFtwSpare;
105 
106   EFI_HOB_GENERIC_HEADER            EndOfHobList;
107 } HOB_TEMPLATE;
108 
109 #pragma pack()
110 
111 extern HOB_TEMPLATE  *gHob;
112 
113 VOID *
114 PrepareHobStack (
115   IN VOID *StackTop
116   );
117 
118 VOID
119 PrepareHobBfv (
120   VOID  *Bfv,
121   UINTN BfvLength
122   );
123 
124 VOID *
125 PrepareHobMemory (
126   IN UINTN                    NumberOfMemoryMapEntries,
127   IN EFI_MEMORY_DESCRIPTOR    *EfiMemoryDescriptor
128   );
129 
130 VOID
131 PrepareHobDxeCore (
132   VOID                  *DxeCoreEntryPoint,
133   EFI_PHYSICAL_ADDRESS  DxeCoreImageBase,
134   UINT64                DxeCoreLength
135   );
136 
137 VOID *
138 PreparePageTable (
139   VOID  *PageNumberTop,
140   UINT8 SizeOfMemorySpace
141   );
142 
143 VOID *
144 PrepareHobMemoryDescriptor (
145   VOID                          *MemoryDescriptorTop,
146   UINTN                         MemDescCount,
147   EFI_MEMORY_DESCRIPTOR         *MemDesc
148   );
149 
150 VOID
151 PrepareHobPhit (
152   VOID *MemoryTop,
153   VOID *FreeMemoryTop
154   );
155 
156 VOID *
157 PrepareHobNvStorage (
158   VOID *NvStorageTop
159   );
160 
161 VOID
162 PrepareHobCpu (
163   VOID
164   );
165 
166 VOID
167 CompleteHobGeneration (
168   VOID
169   );
170 
171 #endif
172