5034b96b879c7dadc34b874ece96b6cb72d4adca
[reactos.git] / reactos / boot / freeldr / freeldr / arch / i386 / hwapm.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 static BOOL
27 FindApmBios(VOID)
28 {
29 REGS RegsIn;
30 REGS RegsOut;
31
32 RegsIn.b.ah = 0x53;
33 RegsIn.b.al = 0x00;
34 RegsIn.w.bx = 0x0000;
35
36 Int386(0x15, &RegsIn, &RegsOut);
37
38 if (INT386_SUCCESS(RegsOut))
39 {
40 DbgPrint((DPRINT_HWDETECT, "Found APM BIOS\n"));
41 DbgPrint((DPRINT_HWDETECT, "AH: %x\n", RegsOut.b.ah));
42 DbgPrint((DPRINT_HWDETECT, "AL: %x\n", RegsOut.b.al));
43 DbgPrint((DPRINT_HWDETECT, "BH: %x\n", RegsOut.b.bh));
44 DbgPrint((DPRINT_HWDETECT, "BL: %x\n", RegsOut.b.bl));
45 DbgPrint((DPRINT_HWDETECT, "CX: %x\n", RegsOut.w.cx));
46
47 return TRUE;
48 }
49
50 printf("No APM BIOS found\n");
51
52 return FALSE;
53 }
54
55
56 VOID
57 DetectApmBios(FRLDRHKEY SystemKey, ULONG *BusNumber)
58 {
59 WCHAR Buffer[80];
60 FRLDRHKEY BiosKey;
61 LONG Error;
62
63 if (FindApmBios())
64 {
65 /* Create new bus key */
66 swprintf(Buffer,
67 L"MultifunctionAdapter\\%u", *BusNumber);
68 Error = RegCreateKey(SystemKey,
69 Buffer,
70 &BiosKey);
71 if (Error != ERROR_SUCCESS)
72 {
73 DbgPrint((DPRINT_HWDETECT, "RegCreateKey() failed (Error %u)\n", (int)Error));
74 return;
75 }
76
77 #if 0
78 /* Set 'Component Information' */
79 SetComponentInformation(BiosKey,
80 0x0,
81 0x0,
82 0xFFFFFFFF);
83 #endif
84
85 /* Increment bus number */
86 (*BusNumber)++;
87
88 /* Set 'Identifier' value */
89 Error = RegSetValue(BiosKey,
90 L"Identifier",
91 REG_SZ,
92 (PCHAR)L"APM",
93 4 * sizeof(WCHAR));
94 if (Error != ERROR_SUCCESS)
95 {
96 DbgPrint((DPRINT_HWDETECT, "RegSetValue() failed (Error %u)\n", (int)Error));
97 return;
98 }
99
100 }
101
102 /* FIXME: Add congiguration data */
103 }
104
105 /* EOF */