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