How to get ACPI notifications

Hi all,

I am writing an ACPI device driver.

I have search/study for a long time to implement the WDM of getting the
ACPI event which is trigged by the BIOS ASL code notify (, 80) and
notify (, 81)?

Or, which approach I should try in order to get these ACPI
notifications? Do you get any sample code, opinion or comment?

================================================================================================================================================================
This message may contain information which is private, privileged or confidential of Compal Electronics, Inc. If you are not the intended recipient of this message, please notify the sender and destroy/delete the message. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information, by persons or entities other than the intended recipient is prohibited.

There’s an ACPI to WMI mapper driver that receives notifications from your BIOS ASL code, and raises them as ACPI events.

See: http://www.microsoft.com/whdc/system/pnppwr/wmi/wmi-acpi.mspx

The way we’ve done this in the past is to receive those events in user-mode (via a service, for example) and then send them to a kernel-mode driver (via an IOCTL, for example, if that’s what’s required).

Peter
OSR

Hi,

I have read the article - “Windows Instrumentation: WMI and ACPI” on the
WHDC. Please forgive the little driver, ACPI and WMI knowledge that I
got. I still have no idea how can I start to write a WDM driver that can
receive notifications from the BIOS ASL code.

Sorry to bother you in you busy life. May I ask you again, which DDK
sample or where can I get the more detail information for me to
implement such kind of function driver?

Thank you in advanced.

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@osr.com
Sent: Wednesday, February 08, 2006 10:16 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] How to get ACPI notifications

There’s an ACPI to WMI mapper driver that receives notifications from
your BIOS ASL code, and raises them as ACPI events.

See: http://www.microsoft.com/whdc/system/pnppwr/wmi/wmi-acpi.mspx

The way we’ve done this in the past is to receive those events in
user-mode (via a service, for example) and then send them to a
kernel-mode driver (via an IOCTL, for example, if that’s what’s
required).

Peter
OSR


Questions? First check the Kernel Driver FAQ at
http://www.osronline.com/article.cfm?id=256

You are currently subscribed to ntdev as: xxxxx@compal.com
To unsubscribe send a blank email to xxxxx@lists.osr.com

================================================================================================================================================================
This message may contain information which is private, privileged or confidential of Compal Electronics, Inc. If you are not the intended recipient of this message, please notify the sender and destroy/delete the message. Any review, retransmission, dissemination or other use of, or taking of any action in reliance upon this information, by persons or entities other than the intended recipient is prohibited.

I’m sorry, but there is not one sample that demonstrates exactly what you want to do.

There are, I assume, samples in the SDK that demonstate how to receive ACPI events in user mode. And there are samples in the DDK that should how to write a wDM driver that process IOCTLs. But there’s no single sample that does both.

P

Here’s some (excerpts from )WDF-based code that I’ve written to get ACPI
Notify events in a driver. WDM code would be similar, though I strongly
recommend that you use WDF.

  1. Pick up the ACPI interface function table from either the lower filter
    or PDO that’s owned by the ACPI driver. (This can only ever work from
    within a driver that’s part of the relevant device stack.

status = WdfFdoQueryForInterface(
Device,
&GUID_ACPI_INTERFACE_STANDARD,
(PINTERFACE) &context->AcpiInterfaces,
sizeof(ACPI_INTERFACE_STANDARD),
1,
NULL);

  1. Register a notification function.

//
// Register for notification callbacks.
//

callbackStatus =
context->AcpiInterfaces.RegisterForDeviceNotifications(
context->AcpiInterfaces.Context,
AcpiNotifyCallback,
Device
);

  1. Provide a callback function, or set of functions.

VOID
AcpiNotifyCallback(
PVOID Context,
ULONG NotifyCode
)
/*++

Routine Description:

This routine is called by the ACPI driver whenever
our device is the target of an ASL “Notify” statement.
This would typically happen as a result of a keyboard
hotkey event.

This routine may be called at any IRQL <=
DISPATCH_LEVEL. Because of this, we just queue a work
item to do the actual work.

Arguments:

Context - Handle to a framework driver object created in DriverEntry

NotifyCode - A byte code associated with an ASL “Notify” statement

Return Value:

None. If a failure occurs, just return. This means that
we’ll miss an event. But that’s not fatal in this case.

–*/
{
PACPI_NOTIFICATION_CONTEXT notificationContext;
WDF_WORKITEM_CONFIG workitemConfig;
WDF_OBJECT_ATTRIBUTES attributes;
WDFWORKITEM workItem;
WDFDEVICE device;
NTSTATUS status;

device = (WDFDEVICE)Context;

WDF_OBJECT_ATTRIBUTES_INIT(&attributes);
WDF_OBJECT_ATTRIBUTES_SET_CONTEXT_TYPE(&attributes,
ACPI_NOTIFICATION_CONTEXT);

WDF_WORKITEM_CONFIG_INIT(&workitemConfig, AcpiNotificationWorker);
workitemConfig.AutomaticSerialization = FALSE;

//
// Allocate the work item to do the actual work
// This is because that to complete the Iotarget
// synchronous evaluation of the bios, we need to
// be at PASSIVE_LEVEL
//
status = WdfWorkItemCreate(&workitemConfig,
&attributes,
&workItem
);
if (!NT_SUCCESS(status)) {
TraceEvents (TRACE_LEVEL_CRITICAL, DBG_INIT, “AcpiNotifyCallback:
WdfWorkItemCreate failed with status 0x%x\n”, status);
return;
}
notificationContext = GetAcpiWorkItemContext(workItem);
notificationContext->Device = device;
notificationContext->NotifyCode = NotifyCode;

WdfWorkItemEnqueue(workItem);

return;
}

VOID
AcpiNotificationWorker(
IN WDFWORKITEM WorkItem
)
/*++

Routine Description:

This routine is called on a worker thread whenever
our device is the target of an ASL “Notify” statement.

Arguments:

WorkItem - The work item associated with this.

Return Value:

None.

–*/
{
PACPI_NOTIFICATION_CONTEXT notificationContext;

PAGED_CODE();

notificationContext = GetAcpiWorkItemContext(WorkItem);

//
// Take action based on the notification code.
//
switch (notificationContext->NotifyCode) {
case 0x80:
// put whatever you like here
break;

case 0x81:

//
// again, whatever you like
//

break;

default:
ASSERT(!“Unknown Notify code sent.”);
}

WdfObjectDelete(WorkItem);
return;
}


Jake Oshins
Windows Kernel Group

The Virtual Machine Team at Microsoft is hiring. Contact
xxxxx@microsoft.com for more information.

This posting is provided “AS IS” with no warranties, and confers no rights.

wrote in message news:xxxxx@ntdev…
> I’m sorry, but there is not one sample that demonstrates exactly what you
> want to do.
>
> There are, I assume, samples in the SDK that demonstate how to receive
> ACPI events in user mode. And there are samples in the DDK that should
> how to write a wDM driver that process IOCTLs. But there’s no single
> sample that does both.
>
> P
>