[FREELDR]
[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 along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 */
20
21 #include <freeldr.h>
22
23 #define NDEBUG
24 #include <debug.h>
25
26 DBG_DEFAULT_CHANNEL(HWDETECT);
27
28 static BOOLEAN
29 FindApmBios(VOID)
30 {
31 REGS RegsIn;
32 REGS RegsOut;
33
34 RegsIn.b.ah = 0x53;
35 RegsIn.b.al = 0x00;
36 RegsIn.w.bx = 0x0000;
37
38 Int386(0x15, &RegsIn, &RegsOut);
39
40 if (INT386_SUCCESS(RegsOut))
41 {
42 TRACE("Found APM BIOS\n");
43 TRACE("AH: %x\n", RegsOut.b.ah);
44 TRACE("AL: %x\n", RegsOut.b.al);
45 TRACE("BH: %x\n", RegsOut.b.bh);
46 TRACE("BL: %x\n", RegsOut.b.bl);
47 TRACE("CX: %x\n", RegsOut.w.cx);
48
49 return TRUE;
50 }
51
52 TRACE("No APM BIOS found\n");
53
54 return FALSE;
55 }
56
57
58 VOID
59 DetectApmBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
60 {
61 PCONFIGURATION_COMPONENT_DATA BiosKey;
62 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
63 ULONG Size;
64
65 Size = sizeof(CM_PARTIAL_RESOURCE_LIST) -
66 sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
67
68 if (FindApmBios())
69 {
70 /* Create 'Configuration Data' value */
71 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
72 memset(PartialResourceList, 0, Size);
73 PartialResourceList->Version = 0;
74 PartialResourceList->Revision = 0;
75 PartialResourceList->Count = 0;
76
77 /* Create new bus key */
78 FldrCreateComponentKey(SystemKey,
79 AdapterClass,
80 MultiFunctionAdapter,
81 0x0,
82 0x0,
83 0xFFFFFFFF,
84 "APM",
85 PartialResourceList,
86 Size,
87 &BiosKey);
88
89 /* Increment bus number */
90 (*BusNumber)++;
91 }
92
93 /* FIXME: Add configuration data */
94 }
95
96 /* EOF */