]>
Commit | Line | Data |
---|---|---|
fce4ecd9 | 1 | /** @file\r |
f3a90fbf | 2 | This driver will report some MMIO/IO resources to dxe core, extract smbios and acpi\r |
fce4ecd9 | 3 | tables from coreboot and install.\r |
f3a90fbf | 4 | \r |
fce4ecd9 MM |
5 | Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>\r |
6 | This program and the accompanying materials\r | |
7 | are licensed and made available under the terms and conditions of the BSD License\r | |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php.\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
14 | **/\r | |
15 | #include "CbSupportDxe.h"\r | |
16 | \r | |
fce4ecd9 MM |
17 | /**\r |
18 | Reserve MMIO/IO resource in GCD\r | |
19 | \r | |
20 | @param IsMMIO Flag of whether it is mmio resource or io resource.\r | |
21 | @param GcdType Type of the space.\r | |
22 | @param BaseAddress Base address of the space.\r | |
23 | @param Length Length of the space.\r | |
24 | @param Alignment Align with 2^Alignment\r | |
25 | @param ImageHandle Handle for the image of this driver.\r | |
26 | \r | |
27 | @retval EFI_SUCCESS Reserve successful\r | |
28 | **/\r | |
29 | EFI_STATUS\r | |
30 | CbReserveResourceInGcd (\r | |
31 | IN BOOLEAN IsMMIO,\r | |
32 | IN UINTN GcdType,\r | |
33 | IN EFI_PHYSICAL_ADDRESS BaseAddress,\r | |
34 | IN UINT64 Length,\r | |
35 | IN UINTN Alignment,\r | |
36 | IN EFI_HANDLE ImageHandle\r | |
37 | )\r | |
38 | {\r | |
f3a90fbf | 39 | EFI_STATUS Status;\r |
fce4ecd9 MM |
40 | \r |
41 | if (IsMMIO) {\r | |
42 | Status = gDS->AddMemorySpace (\r | |
43 | GcdType,\r | |
44 | BaseAddress,\r | |
45 | Length,\r | |
46 | EFI_MEMORY_UC\r | |
47 | );\r | |
48 | if (EFI_ERROR (Status)) {\r | |
49 | DEBUG ((\r | |
50 | EFI_D_ERROR,\r | |
42e548a8 | 51 | "Failed to add memory space :0x%lx 0x%lx\n",\r |
fce4ecd9 MM |
52 | BaseAddress,\r |
53 | Length\r | |
54 | ));\r | |
55 | }\r | |
56 | ASSERT_EFI_ERROR (Status);\r | |
57 | Status = gDS->AllocateMemorySpace (\r | |
58 | EfiGcdAllocateAddress,\r | |
59 | GcdType,\r | |
60 | Alignment,\r | |
61 | Length,\r | |
62 | &BaseAddress,\r | |
63 | ImageHandle,\r | |
64 | NULL\r | |
65 | );\r | |
66 | ASSERT_EFI_ERROR (Status);\r | |
67 | } else {\r | |
68 | Status = gDS->AddIoSpace (\r | |
69 | GcdType,\r | |
70 | BaseAddress,\r | |
71 | Length\r | |
72 | );\r | |
73 | ASSERT_EFI_ERROR (Status);\r | |
74 | Status = gDS->AllocateIoSpace (\r | |
75 | EfiGcdAllocateAddress,\r | |
76 | GcdType,\r | |
77 | Alignment,\r | |
78 | Length,\r | |
79 | &BaseAddress,\r | |
80 | ImageHandle,\r | |
81 | NULL\r | |
82 | );\r | |
83 | ASSERT_EFI_ERROR (Status);\r | |
84 | }\r | |
85 | return Status;\r | |
86 | }\r | |
87 | \r | |
fce4ecd9 MM |
88 | \r |
89 | /**\r | |
90 | Main entry for the Coreboot Support DXE module.\r | |
f3a90fbf | 91 | \r |
fce4ecd9 MM |
92 | @param[in] ImageHandle The firmware allocated handle for the EFI image.\r |
93 | @param[in] SystemTable A pointer to the EFI System Table.\r | |
f3a90fbf | 94 | \r |
fce4ecd9 MM |
95 | @retval EFI_SUCCESS The entry point is executed successfully.\r |
96 | @retval other Some error occurs when executing this entry point.\r | |
97 | \r | |
98 | **/\r | |
99 | EFI_STATUS\r | |
6d577625 | 100 | EFIAPI\r |
fce4ecd9 MM |
101 | CbDxeEntryPoint (\r |
102 | IN EFI_HANDLE ImageHandle,\r | |
103 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
104 | )\r | |
f3a90fbf MM |
105 | {\r |
106 | EFI_STATUS Status;\r | |
f3a90fbf MM |
107 | EFI_HOB_GUID_TYPE *GuidHob;\r |
108 | SYSTEM_TABLE_INFO *pSystemTableInfo;\r | |
3aa86568 | 109 | FRAME_BUFFER_INFO *FbInfo;\r |
f3a90fbf MM |
110 | \r |
111 | Status = EFI_SUCCESS;\r | |
112 | //\r | |
113 | // Report MMIO/IO Resources\r | |
114 | //\r | |
f3a90fbf MM |
115 | Status = CbReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 0xFEC00000, SIZE_4KB, 0, SystemTable); // IOAPIC\r |
116 | ASSERT_EFI_ERROR (Status);\r | |
117 | \r | |
118 | Status = CbReserveResourceInGcd (TRUE, EfiGcdMemoryTypeMemoryMappedIo, 0xFED00000, SIZE_1KB, 0, SystemTable); // HPET\r | |
119 | ASSERT_EFI_ERROR (Status);\r | |
120 | \r | |
121 | //\r | |
122 | // Find the system table information guid hob\r | |
123 | //\r | |
124 | GuidHob = GetFirstGuidHob (&gUefiSystemTableInfoGuid);\r | |
125 | ASSERT (GuidHob != NULL);\r | |
fce4ecd9 | 126 | pSystemTableInfo = (SYSTEM_TABLE_INFO *)GET_GUID_HOB_DATA (GuidHob);\r |
f3a90fbf MM |
127 | \r |
128 | //\r | |
129 | // Install Acpi Table\r | |
130 | //\r | |
131 | if (pSystemTableInfo->AcpiTableBase != 0 && pSystemTableInfo->AcpiTableSize != 0) {\r | |
132 | DEBUG ((EFI_D_ERROR, "Install Acpi Table at 0x%lx, length 0x%x\n", pSystemTableInfo->AcpiTableBase, pSystemTableInfo->AcpiTableSize));\r | |
133 | Status = gBS->InstallConfigurationTable (&gEfiAcpiTableGuid, (VOID *)(UINTN)pSystemTableInfo->AcpiTableBase);\r | |
134 | ASSERT_EFI_ERROR (Status);\r | |
135 | }\r | |
136 | \r | |
137 | //\r | |
138 | // Install Smbios Table\r | |
139 | //\r | |
140 | if (pSystemTableInfo->SmbiosTableBase != 0 && pSystemTableInfo->SmbiosTableSize != 0) {\r | |
141 | DEBUG ((EFI_D_ERROR, "Install Smbios Table at 0x%lx, length 0x%x\n", pSystemTableInfo->SmbiosTableBase, pSystemTableInfo->SmbiosTableSize));\r | |
142 | Status = gBS->InstallConfigurationTable (&gEfiSmbiosTableGuid, (VOID *)(UINTN)pSystemTableInfo->SmbiosTableBase);\r | |
143 | ASSERT_EFI_ERROR (Status);\r | |
144 | }\r | |
145 | \r | |
3aa86568 MM |
146 | //\r |
147 | // Find the frame buffer information and update PCDs\r | |
148 | //\r | |
149 | GuidHob = GetFirstGuidHob (&gUefiFrameBufferInfoGuid);\r | |
60c809f3 LL |
150 | if (GuidHob != NULL) {\r |
151 | FbInfo = (FRAME_BUFFER_INFO *)GET_GUID_HOB_DATA (GuidHob);\r | |
152 | Status = PcdSet32S (PcdVideoHorizontalResolution, FbInfo->HorizontalResolution);\r | |
153 | ASSERT_EFI_ERROR (Status);\r | |
154 | Status = PcdSet32S (PcdVideoVerticalResolution, FbInfo->VerticalResolution);\r | |
155 | ASSERT_EFI_ERROR (Status);\r | |
156 | Status = PcdSet32S (PcdSetupVideoHorizontalResolution, FbInfo->HorizontalResolution);\r | |
157 | ASSERT_EFI_ERROR (Status);\r | |
158 | Status = PcdSet32S (PcdSetupVideoVerticalResolution, FbInfo->VerticalResolution);\r | |
159 | ASSERT_EFI_ERROR (Status);\r | |
160 | }\r | |
3aa86568 | 161 | \r |
fce4ecd9 MM |
162 | return EFI_SUCCESS;\r |
163 | }\r | |
164 | \r |