ReactOS  0.4.14-dev-50-g13bb5e2
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>
24 DBG_DEFAULT_CHANNEL(HWDETECT);
25 
27 
28 static PRSDP_DESCRIPTOR
30 {
31  PUCHAR Ptr;
32 
33  /* Find the 'Root System Descriptor Table Pointer' */
34  Ptr = (PUCHAR)0xE0000;
35  while ((ULONG_PTR)Ptr < 0x100000)
36  {
37  if (!memcmp(Ptr, "RSD PTR ", 8))
38  {
39  TRACE("ACPI supported\n");
40 
41  return (PRSDP_DESCRIPTOR)Ptr;
42  }
43 
44  Ptr = (PUCHAR)((ULONG_PTR)Ptr + 0x10);
45  }
46 
47  TRACE("ACPI not supported\n");
48 
49  return NULL;
50 }
51 
52 
53 VOID
55 {
57  PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
58  PCM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptor;
59  PRSDP_DESCRIPTOR Rsdp;
60  PACPI_BIOS_DATA AcpiBiosData;
62 
63  Rsdp = FindAcpiBios();
64 
65  if (Rsdp)
66  {
67  /* Set up the flag in the loader block */
68  AcpiPresent = TRUE;
69 
70  /* Calculate the table size */
72  sizeof(ACPI_BIOS_DATA) - sizeof(BIOS_MEMORY_MAP);
73 
74  /* Set 'Configuration Data' value */
75  PartialResourceList =
78 
79  if (PartialResourceList == NULL)
80  {
81  ERR("Failed to allocate resource descriptor\n");
82  return;
83  }
84 
85  memset(PartialResourceList, 0, sizeof(CM_PARTIAL_RESOURCE_LIST) + TableSize);
86  PartialResourceList->Version = 0;
87  PartialResourceList->Revision = 0;
88  PartialResourceList->Count = 1;
89 
90  PartialDescriptor = &PartialResourceList->PartialDescriptors[0];
91  PartialDescriptor->Type = CmResourceTypeDeviceSpecific;
92  PartialDescriptor->ShareDisposition = CmResourceShareUndetermined;
93  PartialDescriptor->u.DeviceSpecificData.DataSize = TableSize;
94 
95  /* Fill the table */
96  AcpiBiosData = (PACPI_BIOS_DATA)&PartialResourceList->PartialDescriptors[1];
97 
98  if (Rsdp->revision > 0)
99  {
100  TRACE("ACPI >1.0, using XSDT address\n");
101  AcpiBiosData->RSDTAddress.QuadPart = Rsdp->xsdt_physical_address;
102  }
103  else
104  {
105  TRACE("ACPI 1.0, using RSDT address\n");
106  AcpiBiosData->RSDTAddress.LowPart = Rsdp->rsdt_physical_address;
107  }
108 
109  AcpiBiosData->Count = PcBiosMapCount;
110  memcpy(AcpiBiosData->MemoryMap, PcBiosMemoryMap,
111  PcBiosMapCount * sizeof(BIOS_MEMORY_MAP));
112 
113  TRACE("RSDT %p, data size %x\n", Rsdp->rsdt_physical_address,
114  TableSize);
115 
116  /* Create new bus key */
117  FldrCreateComponentKey(SystemKey,
118  AdapterClass,
119  MultiFunctionAdapter,
120  0x0,
121  0x0,
122  0xFFFFFFFF,
123  "ACPI BIOS",
124  PartialResourceList,
126  &BiosKey);
127 
128  /* Increment bus number */
129  (*BusNumber)++;
130  }
131 }
132 
133 /* EOF */
UCHAR revision
Definition: winldr.h:25
PHYSICAL_ADDRESS RSDTAddress
Definition: pcbios.h:71
ULONGLONG xsdt_physical_address
Definition: winldr.h:28
#define CmResourceTypeDeviceSpecific
Definition: hwresource.cpp:127
BOOLEAN AcpiPresent
Definition: hwacpi.c:26
#define TRUE
Definition: types.h:120
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
GLint x0
Definition: linetemp.h:95
struct _ACPI_BIOS_DATA * PACPI_BIOS_DATA
unsigned char * PUCHAR
Definition: retypes.h:3
_Must_inspect_result_ _In_ PFSRTL_PER_STREAM_CONTEXT Ptr
Definition: fsrtlfuncs.h:898
uint32_t ULONG_PTR
Definition: typedefs.h:63
ULONGLONG Count
Definition: pcbios.h:72
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
union _CM_PARTIAL_RESOURCE_DESCRIPTOR::@371 u
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:156
FORCEINLINE PVOID FrLdrHeapAlloc(SIZE_T MemorySize, ULONG Tag)
Definition: mm.h:163
#define TRACE(s)
Definition: solgame.cpp:4
BIOS_MEMORY_MAP PcBiosMemoryMap[MAX_BIOS_DESCRIPTORS]
Definition: pcmem.c:37
if(!(yy_init))
Definition: macro.lex.yy.c:714
static PRSDP_DESCRIPTOR FindAcpiBios(VOID)
Definition: hwacpi.c:29
DBG_DEFAULT_CHANNEL(HWDETECT)
VOID DetectAcpiBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: hwacpi.c:54
BIOS_MEMORY_MAP MemoryMap[1]
Definition: pcbios.h:73
struct _CM_PARTIAL_RESOURCE_DESCRIPTOR::@371::@380 DeviceSpecificData
CM_PARTIAL_RESOURCE_DESCRIPTOR PartialDescriptors[1]
Definition: hwresource.cpp:119
ULONG LowPart
Definition: typedefs.h:104
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
VOID NTAPI 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 PCHAR IdentifierString, IN PCM_PARTIAL_RESOURCE_LIST ResourceList, IN ULONG Size, OUT PCONFIGURATION_COMPONENT_DATA *ComponentKey)
Definition: archwsup.c:147
#define ERR(fmt,...)
Definition: debug.h:109
ULONG rsdt_physical_address
Definition: winldr.h:26
_Must_inspect_result_ typedef _Out_ PULONG TableSize
Definition: iotypes.h:3971
unsigned int ULONG
Definition: retypes.h:1
#define memset(x, y, z)
Definition: compat.h:39
#define TAG_HW_RESOURCE_LIST
Definition: hardware.h:26
LONGLONG QuadPart
Definition: typedefs.h:112
ULONG PcBiosMapCount
Definition: pcmem.c:38