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