ReactOS 0.4.16-dev-2293-g4d8327b
hwacpi.c
Go to the documentation of this file.
1/*
2 * FreeLoader
3 *
4 * Copyright (C) 2004 Eric Kohl
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21#include <freeldr.h>
22
23#include <debug.h>
25
27
29{
30 return AcpiPresent;
31}
32
35{
36 PUCHAR Ptr;
37
38 /* Find the 'Root System Descriptor Table Pointer' */
39 Ptr = (PUCHAR)0xE0000;
40 while ((ULONG_PTR)Ptr < 0x100000)
41 {
42 if (!memcmp(Ptr, "RSD PTR ", 8))
43 {
44 TRACE("ACPI supported\n");
45
46 return (PRSDP_DESCRIPTOR)Ptr;
47 }
48
49 Ptr = (PUCHAR)((ULONG_PTR)Ptr + 0x10);
50 }
51
52 TRACE("ACPI not supported\n");
53
54 return NULL;
55}
56
57
58VOID
60{
62 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
63 PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
65 PACPI_BIOS_DATA AcpiBiosData;
67
68 Rsdp = FindAcpiBios();
69
70 if (Rsdp)
71 {
72 /* Set up the flag in the loader block */
74
75 /* Calculate the table size */
77 sizeof(ACPI_BIOS_DATA) - sizeof(BIOS_MEMORY_MAP);
78
79 /* Set 'Configuration Data' value */
80 Size = FIELD_OFFSET(CM_PARTIAL_RESOURCE_LIST, PartialDescriptors[1]) + TableSize;
81 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
82 if (PartialResourceList == NULL)
83 {
84 ERR("Failed to allocate resource descriptor\n");
85 return;
86 }
87
88 RtlZeroMemory(PartialResourceList, Size);
89 PartialResourceList->Version = 0;
90 PartialResourceList->Revision = 0;
91 PartialResourceList->Count = 1;
92
93 PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
94 PartialDescriptor->Type = CmResourceTypeDeviceSpecific;
96 PartialDescriptor->u.DeviceSpecificData.DataSize = TableSize;
97
98 /* Fill the table */
99 AcpiBiosData = (PACPI_BIOS_DATA)(PartialDescriptor + 1);
100
101 if (Rsdp->revision > 0)
102 {
103 TRACE("ACPI >1.0, using XSDT address\n");
104 AcpiBiosData->RSDTAddress.QuadPart = Rsdp->xsdt_physical_address;
105 }
106 else
107 {
108 TRACE("ACPI 1.0, using RSDT address\n");
109 AcpiBiosData->RSDTAddress.LowPart = Rsdp->rsdt_physical_address;
110 }
111
112 AcpiBiosData->Count = PcBiosMapCount;
115
116 TRACE("RSDT %p, data size %x\n", Rsdp->rsdt_physical_address,
117 TableSize);
118
119 /* Create new bus key */
120 FldrCreateComponentKey(SystemKey,
123 0,
124 0,
125 0xFFFFFFFF,
126 "ACPI BIOS",
127 PartialResourceList,
128 Size,
129 &BiosKey);
130
131 /* Increment bus number */
132 (*BusNumber)++;
133 }
134}
135
136/* EOF */
unsigned char BOOLEAN
Definition: actypes.h:127
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
VOID DetectAcpiBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: hwacpi.c:59
BOOLEAN IsAcpiPresent(VOID)
Definition: hwacpi.c:28
BOOLEAN AcpiPresent
Definition: hwacpi.c:26
static PRSDP_DESCRIPTOR FindAcpiBios(VOID)
Definition: hwacpi.c:34
#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
_ACRTIMP int __cdecl memcmp(const void *, const void *, size_t)
Definition: string.c:2802
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
struct _ACPI_BIOS_DATA * PACPI_BIOS_DATA
ULONG PcBiosMapCount
Definition: pcmem.c:38
BIOS_MEMORY_MAP PcBiosMemoryMap[MAX_BIOS_DESCRIPTORS]
Definition: pcmem.c:37
#define CmResourceTypeDeviceSpecific
Definition: restypes.h:108
@ AdapterClass
Definition: arc.h:102
@ MultiFunctionAdapter
Definition: arc.h:125
#define TRACE(s)
Definition: solgame.cpp:4
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::@382::@391 DeviceSpecificData
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@382 u
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: restypes.h:100
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG_PTR
Definition: typedefs.h:65
unsigned char * PUCHAR
Definition: typedefs.h:53
uint32_t ULONG
Definition: typedefs.h:59
#define TAG_HW_RESOURCE_LIST
Definition: uefidisk.c:15
LONGLONG QuadPart
Definition: typedefs.h:114
ULONG LowPart
Definition: typedefs.h:106
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4539
@ 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:4330