- Sync up Mm interface with WinLdr branch (introduce the concept of a memory type...
[reactos.git] / reactos / boot / freeldr / freeldr / arch / i386 / hwacpi.c
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
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20
21 #include <freeldr.h>
22 #include <debug.h>
23
24 BOOLEAN AcpiPresent = FALSE;
25
26 static BOOLEAN
27 FindAcpiBios(VOID)
28 {
29 PUCHAR Ptr;
30
31 /* Find the 'Root System Descriptor Table Pointer' */
32 Ptr = (PUCHAR)0xE0000;
33 while ((ULONG)Ptr < 0x100000)
34 {
35 if (!memcmp(Ptr, "RSD PTR ", 8))
36 {
37 DbgPrint((DPRINT_HWDETECT, "ACPI supported\n"));
38
39 return TRUE;
40 }
41
42 Ptr = (PUCHAR)((ULONG)Ptr + 0x10);
43 }
44
45 DbgPrint((DPRINT_HWDETECT, "ACPI not supported\n"));
46
47 return FALSE;
48 }
49
50
51 VOID
52 DetectAcpiBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
53 {
54 PCONFIGURATION_COMPONENT_DATA BiosKey;
55 CM_PARTIAL_RESOURCE_LIST PartialResourceList;
56
57 if (FindAcpiBios())
58 {
59 AcpiPresent = TRUE;
60
61 /* Create new bus key */
62 FldrCreateComponentKey(SystemKey,
63 L"MultifunctionAdapter",
64 *BusNumber,
65 AdapterClass,
66 MultiFunctionAdapter,
67 &BiosKey);
68
69 /* Set 'Component Information' */
70 FldrSetComponentInformation(BiosKey,
71 0x0,
72 0x0,
73 0xFFFFFFFF);
74
75 /* Set 'Configuration Data' value */
76 memset(&PartialResourceList, 0, sizeof(CM_PARTIAL_RESOURCE_LIST));
77 PartialResourceList.Version = 0;
78 PartialResourceList.Revision = 0;
79 PartialResourceList.Count = 0;
80 FldrSetConfigurationData(BiosKey,
81 &PartialResourceList,
82 sizeof(CM_PARTIAL_RESOURCE_LIST) -
83 sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
84
85 /* Increment bus number */
86 (*BusNumber)++;
87
88 /* Set 'Identifier' value */
89 FldrSetIdentifier(BiosKey, L"ACPI BIOS");
90 }
91
92 /* FIXME: Add congiguration data */
93 }
94
95 /* EOF */