ReactOS 0.4.16-dev-979-g79f281e
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
28{
29 return AcpiPresent;
30}
31
32static
35{
36 UINTN i;
37 RSDP_DESCRIPTOR* rsdp = NULL;
39
41 {
43 &acpi2_guid, sizeof(acpi2_guid)))
44 {
46 break;
47 }
48 }
49
50 return rsdp;
51}
52
53VOID
55{
57 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
58 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
60 PACPI_BIOS_DATA AcpiBiosData;
62
63 Rsdp = FindAcpiBios();
64
65 if (Rsdp)
66 {
67 /* Set up the flag in the loader block */
69
70 /* Calculate the table size */
72 sizeof(ACPI_BIOS_DATA) - sizeof(BIOS_MEMORY_MAP);
73
74 /* Set 'Configuration Data' value */
75 PartialResourceList = FrLdrHeapAlloc(sizeof(CM_PARTIAL_RESOURCE_LIST) +
77 if (PartialResourceList == NULL)
78 {
79 ERR("Failed to allocate resource descriptor\n");
80 return;
81 }
82
83 RtlZeroMemory(PartialResourceList, sizeof(CM_PARTIAL_RESOURCE_LIST) + TableSize);
84 PartialResourceList->Version = 0;
85 PartialResourceList->Revision = 0;
86 PartialResourceList->Count = 1;
87
88 PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
89 PartialDescriptor->Type = CmResourceTypeDeviceSpecific;
91 PartialDescriptor->u.DeviceSpecificData.DataSize = TableSize;
92
93 /* Fill the table */
94 AcpiBiosData = (PACPI_BIOS_DATA)&PartialResourceList->PartialDescriptors[1];
95
96 if (Rsdp->revision > 0)
97 {
98 TRACE("ACPI >1.0, using XSDT address\n");
99 AcpiBiosData->RSDTAddress.QuadPart = Rsdp->xsdt_physical_address;
100 }
101 else
102 {
103 TRACE("ACPI 1.0, using RSDT address\n");
104 AcpiBiosData->RSDTAddress.LowPart = Rsdp->rsdt_physical_address;
105 }
106
107 AcpiBiosData->Count = FreeldrDescCount;
108 memcpy(AcpiBiosData->MemoryMap, EfiMemoryMap,
110
111 TRACE("RSDT %p, data size %x\n", Rsdp->rsdt_physical_address, TableSize);
112
113 /* Create new bus key */
114 FldrCreateComponentKey(SystemKey,
117 0x0,
118 0x0,
119 0xFFFFFFFF,
120 "ACPI BIOS",
121 PartialResourceList,
123 &BiosKey);
124
125 /* Increment bus number */
126 (*BusNumber)++;
127 }
128}
129
133{
135 ULONG BusNumber = 0;
136
137 TRACE("DetectHardware()\n");
138
139 /* Create the 'System' key */
140#if defined(_M_IX86) || defined(_M_AMD64)
141 FldrCreateSystemKey(&SystemKey, "AT/AT COMPATIBLE");
142#elif defined(_M_IA64)
143 FldrCreateSystemKey(&SystemKey, "Intel Itanium processor family");
144#elif defined(_M_ARM) || defined(_M_ARM64)
145 FldrCreateSystemKey(&SystemKey, "ARM processor family");
146#else
147 #error Please define a system key for your architecture
148#endif
149
150 /* Detect ACPI */
151 DetectAcpiBios(SystemKey, &BusNumber);
152
153 TRACE("DetectHardware() Done\n");
154 return SystemKey;
155}
#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: precomp.h:57
#define DBG_DEFAULT_CHANNEL(ch)
Definition: debug.h:106
PVOID FrLdrHeapAlloc(SIZE_T MemorySize, ULONG Tag)
Definition: heap.c:533
#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: no_sal2.h:212
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
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@416::@425 DeviceSpecificData
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@416 u
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:54
UINT32 FreeldrDescCount
Definition: uefimem.c:36
EFI_MEMORY_DESCRIPTOR * EfiMemoryMap
Definition: uefimem.c:35
BOOLEAN IsAcpiPresent(VOID)
Definition: uefihw.c:27
BOOLEAN AcpiPresent
Definition: uefihw.c:23
PCONFIGURATION_COMPONENT_DATA UefiHwDetect(_In_opt_ PCSTR Options)
Definition: uefihw.c:131
EFI_SYSTEM_TABLE * GlobalSystemTable
Definition: uefildr.c:16
static PRSDP_DESCRIPTOR FindAcpiBios(VOID)
Definition: uefihw.c:34
EFI_HANDLE GlobalImageHandle
Definition: uefildr.c:15
UCHAR PcBiosDiskCount
Definition: hwdisk.c:46
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