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