2 This driver will report some MMIO/IO resources to dxe core, extract smbios and acpi
3 tables from coreboot and install.
5 Copyright (c) 2014, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php.
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "CbSupportDxe.h"
19 Reserve MMIO/IO resource in GCD
21 @param IsMMIO Flag of whether it is mmio resource or io resource.
22 @param GcdType Type of the space.
23 @param BaseAddress Base address of the space.
24 @param Length Length of the space.
25 @param Alignment Align with 2^Alignment
26 @param ImageHandle Handle for the image of this driver.
28 @retval EFI_SUCCESS Reserve successful
31 CbReserveResourceInGcd (
34 IN EFI_PHYSICAL_ADDRESS BaseAddress
,
37 IN EFI_HANDLE ImageHandle
43 Status
= gDS
->AddMemorySpace (
49 if (EFI_ERROR (Status
)) {
52 "Failed to add memory space :0x%x 0x%x\n",
57 ASSERT_EFI_ERROR (Status
);
58 Status
= gDS
->AllocateMemorySpace (
59 EfiGcdAllocateAddress
,
67 ASSERT_EFI_ERROR (Status
);
69 Status
= gDS
->AddIoSpace (
74 ASSERT_EFI_ERROR (Status
);
75 Status
= gDS
->AllocateIoSpace (
76 EfiGcdAllocateAddress
,
84 ASSERT_EFI_ERROR (Status
);
90 Notification function of EVT_GROUP_READY_TO_BOOT event group.
92 This is a notification function registered on EVT_GROUP_READY_TO_BOOT event group.
93 When the Boot Manager is about to load and execute a boot option, it reclaims variable
94 storage if free size is below the threshold.
96 @param Event Event whose notification function is being invoked.
97 @param Context Pointer to the notification function's context.
109 IoOr16 (mPmCtrlReg
, BIT0
);
111 DEBUG ((EFI_D_ERROR
, "Enable SCI bit at 0x%x before boot\n", mPmCtrlReg
));
115 Main entry for the Coreboot Support DXE module.
117 @param[in] ImageHandle The firmware allocated handle for the EFI image.
118 @param[in] SystemTable A pointer to the EFI System Table.
120 @retval EFI_SUCCESS The entry point is executed successfully.
121 @retval other Some error occurs when executing this entry point.
126 IN EFI_HANDLE ImageHandle
,
127 IN EFI_SYSTEM_TABLE
*SystemTable
131 EFI_EVENT ReadyToBootEvent
;
132 EFI_HOB_GUID_TYPE
*GuidHob
;
133 SYSTEM_TABLE_INFO
*pSystemTableInfo
;
134 ACPI_BOARD_INFO
*pAcpiBoardInfo
;
136 Status
= EFI_SUCCESS
;
138 // Report MMIO/IO Resources
140 Status
= CbReserveResourceInGcd (TRUE
, EfiGcdMemoryTypeMemoryMappedIo
, 0xFEE00000, SIZE_1MB
, 0, SystemTable
); // LAPIC
141 ASSERT_EFI_ERROR (Status
);
143 Status
= CbReserveResourceInGcd (TRUE
, EfiGcdMemoryTypeMemoryMappedIo
, 0xFEC00000, SIZE_4KB
, 0, SystemTable
); // IOAPIC
144 ASSERT_EFI_ERROR (Status
);
146 Status
= CbReserveResourceInGcd (TRUE
, EfiGcdMemoryTypeMemoryMappedIo
, 0xFED00000, SIZE_1KB
, 0, SystemTable
); // HPET
147 ASSERT_EFI_ERROR (Status
);
150 // Find the system table information guid hob
152 GuidHob
= GetFirstGuidHob (&gUefiSystemTableInfoGuid
);
153 ASSERT (GuidHob
!= NULL
);
154 pSystemTableInfo
= (SYSTEM_TABLE_INFO
*)GET_GUID_HOB_DATA (GuidHob
);
157 // Install Acpi Table
159 if (pSystemTableInfo
->AcpiTableBase
!= 0 && pSystemTableInfo
->AcpiTableSize
!= 0) {
160 DEBUG ((EFI_D_ERROR
, "Install Acpi Table at 0x%x, length 0x%x\n", (UINTN
)pSystemTableInfo
->AcpiTableBase
, pSystemTableInfo
->AcpiTableSize
));
161 Status
= gBS
->InstallConfigurationTable (&gEfiAcpiTableGuid
, (VOID
*)(UINTN
)pSystemTableInfo
->AcpiTableBase
);
162 ASSERT_EFI_ERROR (Status
);
166 // Install Smbios Table
168 if (pSystemTableInfo
->SmbiosTableBase
!= 0 && pSystemTableInfo
->SmbiosTableSize
!= 0) {
169 DEBUG ((EFI_D_ERROR
, "Install Smbios Table at 0x%x, length 0x%x\n", (UINTN
)pSystemTableInfo
->SmbiosTableBase
, pSystemTableInfo
->SmbiosTableSize
));
170 Status
= gBS
->InstallConfigurationTable (&gEfiSmbiosTableGuid
, (VOID
*)(UINTN
)pSystemTableInfo
->SmbiosTableBase
);
171 ASSERT_EFI_ERROR (Status
);
175 // Find the acpi board information guid hob
177 GuidHob
= GetFirstGuidHob (&gUefiAcpiBoardInfoGuid
);
178 ASSERT (GuidHob
!= NULL
);
179 pAcpiBoardInfo
= (ACPI_BOARD_INFO
*)GET_GUID_HOB_DATA (GuidHob
);
181 mPmCtrlReg
= (UINTN
)pAcpiBoardInfo
->PmCtrlRegBase
;
182 DEBUG ((EFI_D_ERROR
, "PmCtrlReg at 0x%x\n", mPmCtrlReg
));
185 // Register callback on the ready to boot event
186 // in order to enable SCI
188 ReadyToBootEvent
= NULL
;
189 Status
= EfiCreateEventReadyToBootEx (
195 ASSERT_EFI_ERROR (Status
);