ReactOS 0.4.15-dev-7674-gc0b4db1
uefihw.c
Go to the documentation of this file.
1/*
2 * PROJECT: FreeLoader UEFI Support
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: Hardware detection routines
5 * COPYRIGHT: Copyright 2022 Justin Miller <justinmiller100@gmail.com>
6 */
7
8/* INCLUDES ******************************************************************/
9
10#include <uefildr.h>
11
12#include <debug.h>
14
15/* GLOBALS *******************************************************************/
16
22
24
25/* FUNCTIONS *****************************************************************/
26
27static
30{
31 UINTN i;
32 RSDP_DESCRIPTOR* rsdp = NULL;
34
36 {
38 &acpi2_guid, sizeof(acpi2_guid)))
39 {
41 break;
42 }
43 }
44
45 return rsdp;
46}
47
48VOID
50{
52 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
53 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
55 PACPI_BIOS_DATA AcpiBiosData;
57
58 Rsdp = FindAcpiBios();
59
60 if (Rsdp)
61 {
62 /* Set up the flag in the loader block */
64
65 /* Calculate the table size */
67 sizeof(ACPI_BIOS_DATA) - sizeof(BIOS_MEMORY_MAP);
68
69 /* Set 'Configuration Data' value */
70 PartialResourceList = FrLdrHeapAlloc(sizeof(CM_PARTIAL_RESOURCE_LIST) +
72 if (PartialResourceList == NULL)
73 {
74 ERR("Failed to allocate resource descriptor\n");
75 return;
76 }
77
78 RtlZeroMemory(PartialResourceList, sizeof(CM_PARTIAL_RESOURCE_LIST) + TableSize);
79 PartialResourceList->Version = 0;
80 PartialResourceList->Revision = 0;
81 PartialResourceList->Count = 1;
82
83 PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
84 PartialDescriptor->Type = CmResourceTypeDeviceSpecific;
86 PartialDescriptor->u.DeviceSpecificData.DataSize = TableSize;
87
88 /* Fill the table */
89 AcpiBiosData = (PACPI_BIOS_DATA)&PartialResourceList->PartialDescriptors[1];
90
91 if (Rsdp->revision > 0)
92 {
93 TRACE("ACPI >1.0, using XSDT address\n");
94 AcpiBiosData->RSDTAddress.QuadPart = Rsdp->xsdt_physical_address;
95 }
96 else
97 {
98 TRACE("ACPI 1.0, using RSDT address\n");
99 AcpiBiosData->RSDTAddress.LowPart = Rsdp->rsdt_physical_address;
100 }
101
102 AcpiBiosData->Count = FreeldrDescCount;
103 memcpy(AcpiBiosData->MemoryMap, EfiMemoryMap,
105
106 TRACE("RSDT %p, data size %x\n", Rsdp->rsdt_physical_address, TableSize);
107
108 /* Create new bus key */
109 FldrCreateComponentKey(SystemKey,
112 0x0,
113 0x0,
114 0xFFFFFFFF,
115 "ACPI BIOS",
116 PartialResourceList,
118 &BiosKey);
119
120 /* Increment bus number */
121 (*BusNumber)++;
122 }
123}
124
128{
130 ULONG BusNumber = 0;
131
132 TRACE("DetectHardware()\n");
133
134 /* Create the 'System' key */
135#if defined(_M_IX86) || defined(_M_AMD64)
136 FldrCreateSystemKey(&SystemKey, "AT/AT COMPATIBLE");
137#elif defined(_M_IA64)
138 FldrCreateSystemKey(&SystemKey, "Intel Itanium processor family");
139#elif defined(_M_ARM) || defined(_M_ARM64)
140 FldrCreateSystemKey(&SystemKey, "ARM processor family");
141#else
142 #error Please define a system key for your architecture
143#endif
144
145 /* Detect ACPI */
146 DetectAcpiBios(SystemKey, &BusNumber);
147
148 TRACE("DetectHardware() Done\n");
149 return SystemKey;
150}
#define EFI_ACPI_20_TABLE_GUID
Definition: Acpi.h:40
#define WARNING
Definition: BusLogic958.h:56
unsigned char BOOLEAN
UINT32 UINTN
unsigned int UINT32
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
VOID FldrCreateSystemKey(_Out_ PCONFIGURATION_COMPONENT_DATA *SystemNode, _In_ PCSTR IdentifierString)
Definition: archwsup.c:135
VOID FldrCreateComponentKey(_In_ PCONFIGURATION_COMPONENT_DATA SystemNode, _In_ CONFIGURATION_CLASS Class, _In_ CONFIGURATION_TYPE Type, _In_ IDENTIFIER_FLAG Flags, _In_ ULONG Key, _In_ ULONG Affinity, _In_ PCSTR IdentifierString, _In_ PCM_PARTIAL_RESOURCE_LIST ResourceList, _In_ ULONG Size, _Out_ PCONFIGURATION_COMPONENT_DATA *ComponentKey)
Definition: archwsup.c:198
#define ERR(fmt,...)
Definition: debug.h:110
#define DBG_DEFAULT_CHANNEL(ch)
Definition: debug.h:103
FORCEINLINE PVOID FrLdrHeapAlloc(SIZE_T MemorySize, ULONG Tag)
Definition: mm.h:174
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define CmResourceTypeDeviceSpecific
Definition: hwresource.cpp:127
if(dx< 0)
Definition: linetemp.h:194
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define _In_opt_
Definition: ms_sal.h:309
struct _ACPI_BIOS_DATA * PACPI_BIOS_DATA
@ AdapterClass
Definition: arc.h:93
@ MultiFunctionAdapter
Definition: arc.h:116
#define TRACE(s)
Definition: solgame.cpp:4
EFI_CONFIGURATION_TABLE * ConfigurationTable
Definition: UefiSpec.h:1968
UINTN NumberOfTableEntries
Definition: UefiSpec.h:1963
ULONG rsdt_physical_address
Definition: winldr.h:26
UCHAR revision
Definition: winldr.h:25
ULONGLONG xsdt_physical_address
Definition: winldr.h:28
PHYSICAL_ADDRESS RSDTAddress
Definition: pcbios.h:77
BIOS_MEMORY_MAP MemoryMap[1]
Definition: pcbios.h:79
ULONGLONG Count
Definition: pcbios.h:78
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@394 u
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@394::@403 DeviceSpecificData
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: hwresource.cpp:119
const char * PCSTR
Definition: typedefs.h:52
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
#define TAG_HW_RESOURCE_LIST
Definition: uefidisk.c:15
VOID DetectAcpiBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: uefihw.c:49
UINT32 FreeldrDescCount
Definition: uefimem.c:36
EFI_MEMORY_DESCRIPTOR * EfiMemoryMap
Definition: uefimem.c:35
BOOLEAN AcpiPresent
Definition: uefihw.c:23
PCONFIGURATION_COMPONENT_DATA UefiHwDetect(_In_opt_ PCSTR Options)
Definition: uefihw.c:126
EFI_SYSTEM_TABLE * GlobalSystemTable
Definition: uefildr.c:16
static PRSDP_DESCRIPTOR FindAcpiBios(VOID)
Definition: uefihw.c:29
EFI_HANDLE GlobalImageHandle
Definition: uefildr.c:15
UCHAR PcBiosDiskCount
Definition: hwdisk.c:43
LONGLONG QuadPart
Definition: typedefs.h:114
ULONG LowPart
Definition: typedefs.h:106
_In_ PWDFDEVICE_INIT _In_ PWDF_REMOVE_LOCK_OPTIONS Options
Definition: wdfdevice.h:3534
@ CmResourceShareUndetermined
Definition: cmtypes.h:240
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:160
_Must_inspect_result_ typedef _Out_ PULONG TableSize
Definition: iotypes.h:4327
unsigned char UCHAR
Definition: xmlstorage.h:181