Merge freeldr from amd64 branch:
[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 BOOLEAN
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 DPRINTM(DPRINT_HWDETECT, "Found APM BIOS\n");
41 DPRINTM(DPRINT_HWDETECT, "AH: %x\n", RegsOut.b.ah);
42 DPRINTM(DPRINT_HWDETECT, "AL: %x\n", RegsOut.b.al);
43 DPRINTM(DPRINT_HWDETECT, "BH: %x\n", RegsOut.b.bh);
44 DPRINTM(DPRINT_HWDETECT, "BL: %x\n", RegsOut.b.bl);
45 DPRINTM(DPRINT_HWDETECT, "CX: %x\n", RegsOut.w.cx);
46
47 return TRUE;
48 }
49
50 DPRINTM(DPRINT_HWDETECT, "No APM BIOS found\n");
51
52 return FALSE;
53 }
54
55
56 VOID
57 DetectApmBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
58 {
59 PCONFIGURATION_COMPONENT_DATA BiosKey;
60 CM_PARTIAL_RESOURCE_LIST PartialResourceList;
61
62 if (FindApmBios())
63 {
64 /* Create new bus key */
65 FldrCreateComponentKey(SystemKey,
66 L"MultifunctionAdapter",
67 *BusNumber,
68 AdapterClass,
69 MultiFunctionAdapter,
70 &BiosKey);
71
72 /* Set 'Component Information' */
73 FldrSetComponentInformation(BiosKey,
74 0x0,
75 0x0,
76 0xFFFFFFFF);
77
78 /* Set 'Configuration Data' value */
79 memset(&PartialResourceList, 0, sizeof(CM_PARTIAL_RESOURCE_LIST));
80 PartialResourceList.Version = 0;
81 PartialResourceList.Revision = 0;
82 PartialResourceList.Count = 0;
83 FldrSetConfigurationData(BiosKey,
84 &PartialResourceList,
85 sizeof(CM_PARTIAL_RESOURCE_LIST) -
86 sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR));
87
88 /* Increment bus number */
89 (*BusNumber)++;
90
91 /* Set 'Identifier' value */
92 FldrSetIdentifier(BiosKey, "APM");
93 }
94
95 /* FIXME: Add configuration data */
96 }
97
98 /* EOF */