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