ReactOS 0.4.15-dev-8219-ge8b88cf
hwapm.c
Go to the documentation of this file.
1/*
2 * PROJECT: FreeLoader
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: APM BIOS detection routines
5 * COPYRIGHT: Copyright 2004 Eric Kohl (eric.kohl@reactos.org)
6 */
7
8#include <freeldr.h>
9
10#include <debug.h>
12
13static BOOLEAN
15{
16 REGS RegsIn, RegsOut;
17
18 /* APM BIOS - Installation check */
19#if defined(SARCH_PC98)
20 RegsIn.w.ax = 0x9A00;
21 RegsIn.w.bx = 0x0000;
22 Int386(0x1F, &RegsIn, &RegsOut);
23#else
24 RegsIn.w.ax = 0x5300;
25 RegsIn.w.bx = 0x0000;
26 Int386(0x15, &RegsIn, &RegsOut);
27#endif
28 if (INT386_SUCCESS(RegsOut) && RegsOut.w.bx == 'PM')
29 {
30 TRACE("Found APM BIOS\n");
31 TRACE("AH: %x\n", RegsOut.b.ah);
32 TRACE("AL: %x\n", RegsOut.b.al);
33 TRACE("BH: %x\n", RegsOut.b.bh);
34 TRACE("BL: %x\n", RegsOut.b.bl);
35 TRACE("CX: %x\n", RegsOut.w.cx);
36
37 return TRUE;
38 }
39
40 TRACE("No APM BIOS found\n");
41
42 return FALSE;
43}
44
45VOID
47{
49 PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
50 ULONG Size;
51
52 if (!FindApmBios())
53 return;
54
57
58 /* Set 'Configuration Data' value */
59 PartialResourceList = FrLdrHeapAlloc(Size, TAG_HW_RESOURCE_LIST);
60 if (PartialResourceList == NULL)
61 {
62 ERR("Failed to allocate resource descriptor\n");
63 return;
64 }
65 RtlZeroMemory(PartialResourceList, Size);
66 PartialResourceList->Version = 0;
67 PartialResourceList->Revision = 0;
68 PartialResourceList->Count = 0;
69
70 /* FIXME: Add configuration data */
71
72 /* Create new bus key */
73 FldrCreateComponentKey(SystemKey,
76 0,
77 0,
78 0xFFFFFFFF,
79 "APM",
80 PartialResourceList,
81 Size,
82 &BiosKey);
83
84 /* Increment bus number */
85 (*BusNumber)++;
86}
87
88/* EOF */
unsigned char BOOLEAN
VOID FldrCreateComponentKey(_In_ PCONFIGURATION_COMPONENT_DATA SystemNode, _In_ CONFIGURATION_CLASS Class, _In_ CONFIGURATION_TYPE Type, _In_ IDENTIFIER_FLAG Flags, _In_ ULONG Key, _In_ ULONG Affinity, _In_ PCSTR IdentifierString, _In_ PCM_PARTIAL_RESOURCE_LIST ResourceList, _In_ ULONG Size, _Out_ PCONFIGURATION_COMPONENT_DATA *ComponentKey)
Definition: archwsup.c:198
#define ERR(fmt,...)
Definition: debug.h:113
#define DBG_DEFAULT_CHANNEL(ch)
Definition: debug.h:106
FORCEINLINE PVOID FrLdrHeapAlloc(SIZE_T MemorySize, ULONG Tag)
Definition: mm.h:174
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static BOOLEAN FindApmBios(VOID)
Definition: hwapm.c:14
VOID DetectApmBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: hwapm.c:46
struct _CM_PARTIAL_RESOURCE_LIST CM_PARTIAL_RESOURCE_LIST
#define INT386_SUCCESS(regs)
Definition: pcbios.h:179
int __cdecl Int386(int ivec, REGS *in, REGS *out)
@ AdapterClass
Definition: arc.h:93
@ MultiFunctionAdapter
Definition: arc.h:116
#define TRACE(s)
Definition: solgame.cpp:4
unsigned char bl
Definition: pcbios.h:134
unsigned char al
Definition: pcbios.h:131
unsigned char ah
Definition: pcbios.h:132
unsigned char bh
Definition: pcbios.h:135
unsigned short cx
Definition: pcbios.h:113
unsigned short bx
Definition: pcbios.h:112
unsigned short ax
Definition: pcbios.h:111
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59
#define TAG_HW_RESOURCE_LIST
Definition: uefidisk.c:15
Definition: pcbios.h:159
BYTEREGS b
Definition: pcbios.h:163
WORDREGS w
Definition: pcbios.h:162
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:160