f7c7fd8513bea9fa351e52228100d4c3058f37e7
[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 <arch.h>
23 #include <rtl.h>
24 #include <debug.h>
25 #include <mm.h>
26 #include <portio.h>
27
28 #include "../../reactos/registry.h"
29 #include "hardware.h"
30
31 BOOLEAN AcpiPresent = FALSE;
32
33 static BOOL
34 FindAcpiBios(VOID)
35 {
36 PUCHAR Ptr;
37
38 /* Find the 'Root System Descriptor Table Pointer' */
39 Ptr = (PUCHAR)0xE0000;
40 while ((ULONG)Ptr < 0x100000)
41 {
42 if (!memcmp(Ptr, "RSD PTR ", 8))
43 {
44 DbgPrint((DPRINT_HWDETECT, "ACPI supported\n"));
45
46 return TRUE;
47 }
48
49 Ptr = (PUCHAR)((ULONG)Ptr + 0x10);
50 }
51
52 DbgPrint((DPRINT_HWDETECT, "ACPI not supported\n"));
53
54 return FALSE;
55 }
56
57
58 VOID
59 DetectAcpiBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
60 {
61 char Buffer[80];
62 FRLDRHKEY BiosKey;
63 LONG Error;
64
65 if (FindAcpiBios())
66 {
67 AcpiPresent = TRUE;
68 /* Create new bus key */
69 sprintf(Buffer,
70 "MultifunctionAdapter\\%u", *BusNumber);
71 Error = RegCreateKey(SystemKey,
72 Buffer,
73 &BiosKey);
74 if (Error != ERROR_SUCCESS)
75 {
76 DbgPrint((DPRINT_HWDETECT, "RegCreateKey() failed (Error %u)\n", (int)Error));
77 return;
78 }
79
80 #if 0
81 /* Set 'Component Information' */
82 SetComponentInformation(BiosKey,
83 0x0,
84 0x0,
85 0xFFFFFFFF);
86 #endif
87
88 /* Increment bus number */
89 (*BusNumber)++;
90
91 /* Set 'Identifier' value */
92 Error = RegSetValue(BiosKey,
93 "Identifier",
94 REG_SZ,
95 (PUCHAR)"ACPI BIOS",
96 10);
97 if (Error != ERROR_SUCCESS)
98 {
99 DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
100 return;
101 }
102
103 }
104 }
105
106 /* EOF */