[CMBATT]: ACPI-compliant. WMI-managed Control Method Battery Driver. Step 1: Define...
authorSir Richard <sir_richard@svn.reactos.org>
Sat, 13 Mar 2010 21:06:22 +0000 (21:06 +0000)
committerSir Richard <sir_richard@svn.reactos.org>
Sat, 13 Mar 2010 21:06:22 +0000 (21:06 +0000)
The rest of the code is in my WC but needs ACPI Eval IOCTL support in ReactOS before it'll work.

svn path=/trunk/; revision=46188

reactos/drivers/bus/acpi/acpi.rbuild
reactos/drivers/bus/acpi/cmbatt/cmbatt.c [new file with mode: 0644]
reactos/drivers/bus/acpi/cmbatt/cmbatt.h [new file with mode: 0644]
reactos/drivers/bus/acpi/cmbatt/cmbatt.rbuild [new file with mode: 0644]
reactos/drivers/bus/acpi/cmbatt/cmbatt.rc [new file with mode: 0644]
reactos/drivers/bus/acpi/cmbatt/cmbpnp.c [new file with mode: 0644]
reactos/drivers/bus/acpi/cmbatt/cmbwmi.c [new file with mode: 0644]
reactos/drivers/bus/acpi/cmbatt/cmexec.c [new file with mode: 0644]

index f2b6a13..cbc124a 100644 (file)
@@ -4,6 +4,9 @@
 <directory name="acpica">
        <xi:include href="acpica/acpica.rbuild" />
 </directory>
+<directory name="cmbatt">
+       <xi:include href="cmbatt/cmbatt.rbuild" />
+</directory>
 </group>
 
 <module name="acpi" type="kernelmodedriver" installbase="system32/drivers" installname="acpi.sys" allowwarnings="true">
diff --git a/reactos/drivers/bus/acpi/cmbatt/cmbatt.c b/reactos/drivers/bus/acpi/cmbatt/cmbatt.c
new file mode 100644 (file)
index 0000000..1957597
--- /dev/null
@@ -0,0 +1,149 @@
+/*
+ * PROJECT:         ReactOS ACPI-Compliant Control Method Battery
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            boot/drivers/bus/acpi/cmbatt/cmbatt.c
+ * PURPOSE:         Main Initialization Code and IRP Handling
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include "cmbatt.h"
+
+/* GLOBALS ********************************************************************/
+
+ULONG CmBattDebug;
+
+/* FUNCTIONS ******************************************************************/
+
+VOID
+NTAPI
+CmBattPowerCallBack(PCMBATT_DEVICE_EXTENSION DeviceExtension,
+                    PVOID Argument1,
+                    PVOID Argument2)
+{
+    UNIMPLEMENTED;
+}
+
+VOID
+NTAPI
+CmBattWakeDpc(PKDPC Dpc,
+              PCMBATT_DEVICE_EXTENSION FdoExtension,
+              PVOID SystemArgument1,
+              PVOID SystemArgument2)
+{
+    UNIMPLEMENTED;   
+}
+
+VOID
+NTAPI
+CmBattNotifyHandler(PCMBATT_DEVICE_EXTENSION DeviceExtension,
+                    ULONG NotifyValue)
+{
+    UNIMPLEMENTED;
+}
+
+VOID
+NTAPI
+CmBattUnload(PDEVICE_OBJECT DeviceObject)
+{
+    UNIMPLEMENTED;
+}
+
+NTSTATUS
+NTAPI
+CmBattVerifyStaticInfo(ULONG StaData,
+                       ULONG BatteryTag)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;   
+}
+
+NTSTATUS
+NTAPI
+CmBattOpenClose(PDEVICE_OBJECT DeviceObject,
+                PIRP Irp)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;   
+}
+
+NTSTATUS
+NTAPI
+CmBattIoctl(PDEVICE_OBJECT DeviceObject,
+            PIRP Irp)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+NTAPI
+CmBattQueryTag(PCMBATT_DEVICE_EXTENSION DeviceExtension,
+               PULONG BatteryTag)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;   
+}
+
+NTSTATUS
+NTAPI
+CmBattDisableStatusNotify(PCMBATT_DEVICE_EXTENSION DeviceExtension)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+NTAPI
+CmBattSetStatusNotify(PCMBATT_DEVICE_EXTENSION DeviceExtension,
+                      ULONG BatteryTag,
+                      PBATTERY_NOTIFY BatteryNotify)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+NTAPI
+CmBattGetBatteryStatus(PCMBATT_DEVICE_EXTENSION DeviceExtension,
+                       ULONG BatteryTag)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+NTAPI
+CmBattQueryInformation(PCMBATT_DEVICE_EXTENSION DeviceExtension,
+                       ULONG BatteryTag,
+                       BATTERY_QUERY_INFORMATION_LEVEL Level,
+                       OPTIONAL LONG AtRate,
+                       PVOID Buffer,
+                       ULONG BufferLength,
+                       PULONG ReturnedLength)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED; 
+}
+
+NTSTATUS
+NTAPI
+CmBattQueryStatus(PCMBATT_DEVICE_EXTENSION DeviceExtension,
+                  ULONG BatteryTag,
+                  PBATTERY_STATUS BatteryStatus)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+NTAPI
+DriverEntry(PDRIVER_OBJECT DriverObject,
+            PUNICODE_STRING RegistryPath)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;
+}
+
+/* EOF */
diff --git a/reactos/drivers/bus/acpi/cmbatt/cmbatt.h b/reactos/drivers/bus/acpi/cmbatt/cmbatt.h
new file mode 100644 (file)
index 0000000..0443c4c
--- /dev/null
@@ -0,0 +1,105 @@
+/*
+ * PROJECT:         ReactOS ACPI-Compliant Control Method Battery
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            boot/drivers/bus/acpi/cmbatt/cmbatt.h
+ * PURPOSE:         Main Header File
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+
+#include <ntddk.h>
+#include <initguid.h>
+#include <batclass.h>
+#include <acpiioct.h>
+#include <wmilib.h>
+#include <debug.h>
+
+#define CMBATT_GENERIC_STATUS   0x01
+#define CMBATT_GENERIC_INFO     0x02
+#define CMBATT_GENERIC_WARNING  0x04
+#define CMBATT_ACPI_WARNING     0x08
+#define CMBATT_POWER_INFO       0x10
+#define CMBATT_PNP_INFO         0x20
+#define CMBATT_ACPI_ENTRY_EXIT  0x40
+#define CMBATT_PNP_ENTRY_EXIT   0x200
+#define CMBATT_ACPI_ASSERT      0x400
+
+typedef enum _CMBATT_EXTENSION_TYPE
+{
+    CmBattAcAdapter,
+    CmBattBattery
+} CMBATT_EXTENSION_TYPE;
+
+typedef struct _ACPI_BST_DATA
+{
+    ULONG State;
+    ULONG PresentRate;
+    ULONG RemainingCapacity;
+    ULONG PresentVoltage;
+} ACPI_BST_DATA, *PACPI_BST_DATA;
+
+typedef struct _ACPI_BIF_DATA
+{
+    ULONG PowerUnit;
+    ULONG DesignCapacity;
+    ULONG LastFullCapacity;
+    ULONG BatteryTechnology;
+    ULONG DesignVoltage;
+    ULONG DesignCapacityWarning;
+    ULONG DesignCapacityLow;
+    ULONG BatteryCapacityGranularity1;
+    ULONG BatteryCapacityGranularity2;
+    CHAR ModelNumber[256];
+    CHAR SerialNubmer[256];
+    CHAR BatteryType[256];
+    CHAR OemInfo[256];
+} ACPI_BIF_DATA, *PACPI_BIF_DATA;
+
+typedef struct _CMBATT_DEVICE_EXTENSION
+{
+    CMBATT_EXTENSION_TYPE FdoType;
+    PDEVICE_OBJECT DeviceObject;
+    PDEVICE_OBJECT FdoDeviceObject;
+    PDEVICE_OBJECT PdoDeviceObject;
+    PDEVICE_OBJECT AttachedDevice;
+    FAST_MUTEX FastMutex;
+    ULONG HandleCount;
+    PIRP PowerIrp;
+    POWER_STATE PowerState;
+    WMILIB_CONTEXT WmiLibInfo;
+    ULONG WaitWakeEnable;
+    ULONG WmiCount;
+    KEVENT WmiEvent;
+    ULONG DeviceId;
+    PUNICODE_STRING DeviceName;
+    ACPI_INTERFACE_STANDARD2 AcpiInterface;
+    BOOLEAN DelayAr;
+    BOOLEAN DelayedArFlag;
+    PVOID ClassData;
+    BOOLEAN Started;
+    BOOLEAN NotifySent;
+    ULONG ArLock;
+    ULONG TagData;
+    ULONG Tag;
+    ULONG ModelNumberLength;
+    PCHAR ModelNumber;
+    ULONG SerialNumberLength;
+    PCHAR SerialNumber;
+    ULONG OemInfoLength;
+    PCHAR OemInfo;
+    ACPI_BST_DATA BstData;
+    ACPI_BIF_DATA BifData;
+    ULONG Id;
+    ULONG State;
+    ULONG RemainingCapacity;
+    ULONG PresentVoltage;
+    ULONG Rate;
+    BATTERY_INFORMATION StaticBatteryInformation;
+    ULONG BatteryCapacityGranularity1;
+    ULONG BatteryCapacityGranularity2;
+    BOOLEAN TripPointSet;
+    ULONG TripPointValue;
+    ULONG TripPointOld;
+    ULONGLONG InterruptTime;
+} CMBATT_DEVICE_EXTENSION, *PCMBATT_DEVICE_EXTENSION;
+/* EOF */
diff --git a/reactos/drivers/bus/acpi/cmbatt/cmbatt.rbuild b/reactos/drivers/bus/acpi/cmbatt/cmbatt.rbuild
new file mode 100644 (file)
index 0000000..c8a09e3
--- /dev/null
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
+<module name="cmbattx" type="kernelmodedriver" installbase="system32/drivers" installname="cmbattx.sys">
+       <library>ntoskrnl</library>
+       <library>hal</library>
+       <library>battc</library>
+       <include base="cmbatt">.</include>
+       <file>cmbatt.c</file>
+       <file>cmexec.c</file>
+       <file>cmbpnp.c</file>
+       <file>cmbwmi.c</file>
+       <file>cmbatt.rc</file>
+</module>
diff --git a/reactos/drivers/bus/acpi/cmbatt/cmbatt.rc b/reactos/drivers/bus/acpi/cmbatt/cmbatt.rc
new file mode 100644 (file)
index 0000000..d1542f9
--- /dev/null
@@ -0,0 +1,5 @@
+#define REACTOS_VERSION_DLL
+#define REACTOS_STR_FILE_DESCRIPTION   "Control Method Battery Miniclass Driver\0"
+#define REACTOS_STR_INTERNAL_NAME          "cmbatt\0"
+#define REACTOS_STR_ORIGINAL_FILENAME  "cmbatt.sys\0"
+#include <reactos/version.rc>
diff --git a/reactos/drivers/bus/acpi/cmbatt/cmbpnp.c b/reactos/drivers/bus/acpi/cmbatt/cmbpnp.c
new file mode 100644 (file)
index 0000000..fee3ec8
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * PROJECT:         ReactOS ACPI-Compliant Control Method Battery
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            boot/drivers/bus/acpi/cmbatt/cmbpnp.c
+ * PURPOSE:         Plug-and-Play IOCTL/IRP Handling
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include "cmbatt.h"
+
+/* FUNCTIONS ******************************************************************/
+
+NTSTATUS
+NTAPI
+CmBattIoCompletion(PDEVICE_OBJECT DeviceObject,
+                   PIRP Irp,
+                   PKEVENT Event)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+NTAPI
+CmBattGetAcpiInterfaces(PDEVICE_OBJECT DeviceObject,
+                        PACPI_INTERFACE_STANDARD2 *AcpiInterface)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;
+}
+
+VOID
+NTAPI
+CmBattDestroyFdo(PDEVICE_OBJECT DeviceObject)
+{
+    UNIMPLEMENTED;
+}
+
+NTSTATUS
+NTAPI
+CmBattRemoveDevice(PDEVICE_OBJECT DeviceObject,
+                   PIRP Irp)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+NTAPI
+CmBattPowerDispatch(PDEVICE_OBJECT DeviceObject,
+                    PIRP Irp)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+NTAPI
+CmBattCreateFdo(PDRIVER_OBJECT DriverObject,
+                PDEVICE_OBJECT DeviceObject,
+                ULONG DeviceExtensionSize,
+                PDEVICE_OBJECT *NewDeviceObject)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+NTAPI
+CmBattPnpDispatch(PDEVICE_OBJECT DeviceObject,
+                  PIRP Irp)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+NTAPI
+CmBattAddBattery(PDRIVER_OBJECT DriverObject,
+                 PDEVICE_OBJECT DeviceObject)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+NTAPI
+CmBattAddAcAdapter(PDRIVER_OBJECT DriverObject,
+                   PDEVICE_OBJECT DeviceObject)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS NTAPI CmBattAddDevice(PDRIVER_OBJECT DriverObject,
+                               PDEVICE_OBJECT DeviceObject)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;
+}
+
+/* EOF */
diff --git a/reactos/drivers/bus/acpi/cmbatt/cmbwmi.c b/reactos/drivers/bus/acpi/cmbatt/cmbwmi.c
new file mode 100644 (file)
index 0000000..848c920
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * PROJECT:         ReactOS ACPI-Compliant Control Method Battery
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            boot/drivers/bus/acpi/cmbatt/cmbwmi.c
+ * PURPOSE:         WMI Interface
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include "cmbatt.h"
+
+/* FUNCTIONS ******************************************************************/
+
+NTSTATUS
+NTAPI
+CmBattQueryWmiRegInfo(PDEVICE_OBJECT DeviceObject,
+                      PULONG RegFlags,
+                      PUNICODE_STRING InstanceName,
+                      PUNICODE_STRING *RegistryPath,
+                      PUNICODE_STRING MofResourceName,
+                      PDEVICE_OBJECT *Pdo)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;
+}
+         
+NTSTATUS
+NTAPI
+CmBattQueryWmiDataBlock(PDEVICE_OBJECT DeviceObject,
+                        PIRP Irp,
+                        ULONG GuidIndex,
+                        ULONG InstanceIndex,
+                        ULONG InstanceCount,
+                        PULONG InstanceLengthArray,
+                        ULONG BufferAvail,
+                        PUCHAR Buffer)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+NTAPI
+CmBattSetWmiDataBlock(PDEVICE_OBJECT DeviceObject,
+                      PIRP Irp, 
+                      ULONG GuidIndex,
+                      ULONG InstanceIndex,
+                      ULONG BufferSize,
+                      PUCHAR Buffer)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+NTAPI
+CmBattSetWmiDataItem(PDEVICE_OBJECT DeviceObject,
+                     PIRP Irp,
+                     ULONG GuidIndex,
+                     ULONG InstanceIndex,
+                     ULONG DataItemId,
+                     ULONG BufferSize,
+                     PUCHAR Buffer)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+NTAPI
+CmBattWmiDeRegistration(PCMBATT_DEVICE_EXTENSION DeviceExtension)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+NTAPI
+CmBattWmiRegistration(PCMBATT_DEVICE_EXTENSION DeviceExtension)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+NTAPI
+CmBattSystemControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;
+}
+    
+/* EOF */
diff --git a/reactos/drivers/bus/acpi/cmbatt/cmexec.c b/reactos/drivers/bus/acpi/cmbatt/cmexec.c
new file mode 100644 (file)
index 0000000..a41865c
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * PROJECT:         ReactOS ACPI-Compliant Control Method Battery
+ * LICENSE:         BSD - See COPYING.ARM in the top level directory
+ * FILE:            boot/drivers/bus/acpi/cmbatt/cmexec.c
+ * PURPOSE:         ACPI Method Execution/Evaluation Glue
+ * PROGRAMMERS:     ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include "cmbatt.h"
+
+/* FUNCTIONS ******************************************************************/
+
+NTSTATUS
+NTAPI
+GetDwordElement(PACPI_METHOD_ARGUMENT Argument,
+                PULONG Value)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+NTAPI
+GetStringElement(PACPI_METHOD_ARGUMENT Argument,
+                 PCHAR Value)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+NTAPI
+CmBattGetPsrData(PDEVICE_OBJECT DeviceObject,
+                 PULONG PsrData)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED; 
+}
+
+NTSTATUS
+NTAPI
+CmBattGetBifData(PCMBATT_DEVICE_EXTENSION DeviceExtension,
+                 PACPI_BIF_DATA BifData)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+NTAPI
+CmBattGetBstData(PCMBATT_DEVICE_EXTENSION DeviceExtension,
+                 PACPI_BST_DATA BstData)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;
+}   
+
+NTSTATUS
+NTAPI
+CmBattGetStaData(PDEVICE_OBJECT DeviceObject,
+                 PULONG StaData)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+NTAPI
+CmBattGetUniqueId(PDEVICE_OBJECT DeviceObject,
+                  PULONG UniqueId)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;  
+}
+
+NTSTATUS
+NTAPI
+CmBattSetTripPpoint(PCMBATT_DEVICE_EXTENSION DeviceExtension,
+                    ULONG AlarmValue)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;
+}
+
+NTSTATUS
+NTAPI
+CmBattSendDownStreamIrp(PDEVICE_OBJECT DeviceObject,
+                        ULONG IoControlCode,
+                        PVOID InputBuffer,
+                        ULONG InputBufferLength,
+                        PACPI_EVAL_OUTPUT_BUFFER OutputBuffer,
+                        ULONG OutputBufferLength)
+{
+    UNIMPLEMENTED;
+    return STATUS_NOT_IMPLEMENTED;
+}
+     
+/* EOF */