ReactOS  0.4.15-dev-499-g1f31905
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>
11 DBG_DEFAULT_CHANNEL(HWDETECT);
12 
13 static 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 
45 VOID
47 {
49  PCM_PARTIAL_RESOURCE_LIST PartialResourceList;
50  ULONG Size;
51 
52  if (!FindApmBios())
53  return;
54 
55  Size = sizeof(CM_PARTIAL_RESOURCE_LIST) -
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,
75  MultiFunctionAdapter,
76  0x0,
77  0,
78  0xFFFFFFFF,
79  "APM",
80  PartialResourceList,
81  Size,
82  &BiosKey);
83 
84  /* Increment bus number */
85  (*BusNumber)++;
86 }
87 
88 /* EOF */
struct _CM_PARTIAL_RESOURCE_LIST CM_PARTIAL_RESOURCE_LIST
#define TRUE
Definition: types.h:120
GLint x0
Definition: linetemp.h:95
unsigned short cx
Definition: pcbios.h:107
unsigned char ah
Definition: pcbios.h:126
int __cdecl Int386(int ivec, REGS *in, REGS *out)
#define INT386_SUCCESS(regs)
Definition: pcbios.h:173
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
_In_opt_ PUNICODE_STRING _In_ PDRIVER_OBJECT _In_ PDEVICE_OBJECT _In_ INTERFACE_TYPE _In_ ULONG BusNumber
Definition: halfuncs.h:156
FORCEINLINE PVOID FrLdrHeapAlloc(SIZE_T MemorySize, ULONG Tag)
Definition: mm.h:163
#define TRACE(s)
Definition: solgame.cpp:4
unsigned char bl
Definition: pcbios.h:128
BYTEREGS b
Definition: pcbios.h:157
unsigned char al
Definition: pcbios.h:125
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:361
VOID NTAPI 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 PCHAR IdentifierString, IN PCM_PARTIAL_RESOURCE_LIST ResourceList, IN ULONG Size, OUT PCONFIGURATION_COMPONENT_DATA *ComponentKey)
Definition: archwsup.c:147
#define ERR(fmt,...)
Definition: debug.h:110
unsigned char bh
Definition: pcbios.h:129
unsigned short bx
Definition: pcbios.h:106
unsigned short ax
Definition: pcbios.h:105
DBG_DEFAULT_CHANNEL(HWDETECT)
unsigned int ULONG
Definition: retypes.h:1
Definition: pcbios.h:152
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
static BOOLEAN FindApmBios(VOID)
Definition: hwapm.c:14
#define TAG_HW_RESOURCE_LIST
Definition: hardware.h:26
WORDREGS w
Definition: pcbios.h:156
VOID DetectApmBios(PCONFIGURATION_COMPONENT_DATA SystemKey, ULONG *BusNumber)
Definition: hwapm.c:46