[FREELDR] Formatting only.
[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 DBG_DEFAULT_CHANNEL(HWDETECT);
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 TRACE("Found APM BIOS\n");
41 TRACE("AH: %x\n", RegsOut.b.ah);
42 TRACE("AL: %x\n", RegsOut.b.al);
43 TRACE("BH: %x\n", RegsOut.b.bh);
44 TRACE("BL: %x\n", RegsOut.b.bl);
45 TRACE("CX: %x\n", RegsOut.w.cx);
46
47 return TRUE;
48 }
49
50 TRACE("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 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
61 ULONG Size;
62
63 Size = sizeof(CM_PARTIAL_RESOURCE_LIST) -
64 sizeof(CM_PARTIAL_RESOURCE_DESCRIPTOR);
65
66 if (FindApmBios())
67 {
68 /* Create 'Configuration Data' value */
69 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
70 memset(PartialResourceList, 0, Size);
71 PartialResourceList->Version = 0;
72 PartialResourceList->Revision = 0;
73 PartialResourceList->Count = 0;
74
75 /* Create new bus key */
76 FldrCreateComponentKey(SystemKey,
77 AdapterClass,
78 MultiFunctionAdapter,
79 0x0,
80 0x0,
81 0xFFFFFFFF,
82 "APM",
83 PartialResourceList,
84 Size,
85 &BiosKey);
86
87 /* Increment bus number */
88 (*BusNumber)++;
89 }
90
91 /* FIXME: Add configuration data */
92 }
93
94 /* EOF */