#define HAS_SIBLINGS(d) (((d)->parent) && ((d)->node.next != &(d)->parent->children))
#define NODE_TO_DEVICE(n) (list_entry(n, struct acpi_device, node))
-extern int event_is_open;
+int event_is_open;
extern void acpi_pic_sci_set_trigger(unsigned int irq, UINT16 trigger);
typedef int (*acpi_bus_walk_callback)(struct acpi_device*, int, void*);
KSPIN_LOCK acpi_bus_event_lock;
LIST_HEAD(acpi_bus_event_list);
//DECLARE_WAIT_QUEUE_HEAD(acpi_bus_event_queue);
+KEVENT AcpiEventQueue;
static int
{
struct acpi_bus_event *event = NULL;
//unsigned long flags = 0;
+ KIRQL OldIrql;
DPRINT1("acpi_bus_generate_event");
return_VALUE(AE_BAD_PARAMETER);
/* drop event on the floor if no one's listening */
- //if (!event_is_open)
- // return_VALUE(0);
+ if (!event_is_open)
+ return_VALUE(0);
event = ExAllocatePool(NonPagedPool,sizeof(struct acpi_bus_event));
if (!event)
event->data = data;
//spin_lock_irqsave(&acpi_bus_event_lock, flags);
+ KeAcquireSpinLock(&acpi_bus_event_lock, &OldIrql);
list_add_tail(&event->node, &acpi_bus_event_list);
+ KeReleaseSpinLock(&acpi_bus_event_lock, OldIrql);
//spin_unlock_irqrestore(&acpi_bus_event_lock, flags);
+ KeSetEvent(&AcpiEventQueue, IO_NO_INCREMENT, FALSE);
//wake_up_interruptible(&acpi_bus_event_queue);
return_VALUE(0);
acpi_bus_receive_event (
struct acpi_bus_event *event)
{
- //unsigned long flags = 0;
- //struct acpi_bus_event *entry = NULL;
+// unsigned long flags = 0;
+ struct acpi_bus_event *entry = NULL;
+ KIRQL OldIrql;
//DECLARE_WAITQUEUE(wait, current);
DPRINT1("acpi_bus_receive_event");
- //if (!event)
- // return AE_BAD_PARAMETER;
-
- //if (list_empty(&acpi_bus_event_list)) {
-
- // set_current_state(TASK_INTERRUPTIBLE);
- // add_wait_queue(&acpi_bus_event_queue, &wait);
-
- // if (list_empty(&acpi_bus_event_list))
- // schedule();
+ if (!event)
+ return AE_BAD_PARAMETER;
- // remove_wait_queue(&acpi_bus_event_queue, &wait);
- // set_current_state(TASK_RUNNING);
+ event_is_open++;
+ KeWaitForSingleObject(&AcpiEventQueue,
+ Executive,
+ KernelMode,
+ FALSE,
+ NULL);
+ event_is_open--;
+ KeClearEvent(&AcpiEventQueue);
- // if (signal_pending(current))
- // return_VALUE(-ERESTARTSYS);
- //}
+ if (list_empty(&acpi_bus_event_list))
+ return_VALUE(AE_NOT_FOUND);
- //spin_lock_irqsave(&acpi_bus_event_lock, flags);
- //entry = list_entry(acpi_bus_event_list.next, struct acpi_bus_event, node);
- //if (entry)
- // list_del(&entry->node);
- //spin_unlock_irqrestore(&acpi_bus_event_lock, flags);
+// spin_lock_irqsave(&acpi_bus_event_lock, flags);
+ KeAcquireSpinLock(&acpi_bus_event_lock, &OldIrql);
+ entry = list_entry(acpi_bus_event_list.next, struct acpi_bus_event, node);
+ if (entry)
+ list_del(&entry->node);
+ KeReleaseSpinLock(&acpi_bus_event_lock, OldIrql);
+// spin_unlock_irqrestore(&acpi_bus_event_lock, flags);
- //if (!entry)
- // return_VALUE(AE_NOT_FOUND);
+ if (!entry)
+ return_VALUE(AE_NOT_FOUND);
- //memcpy(event, entry, sizeof(struct acpi_bus_event));
+ memcpy(event, entry, sizeof(struct acpi_bus_event));
- //kfree(entry);
- UNIMPLEMENTED;
+ ExFreePool(entry);
return_VALUE(0);
}
static LIST_HEAD(acpi_bus_drivers);
//static DECLARE_MUTEX(acpi_bus_drivers_lock);
+static FAST_MUTEX acpi_bus_drivers_lock;
/**
if (result)
return_VALUE(result);
- //down(&acpi_bus_drivers_lock);
+ down(&acpi_bus_drivers_lock);
++driver->references;
- //up(&acpi_bus_drivers_lock);
+ up(&acpi_bus_drivers_lock);
return_VALUE(0);
}
device->driver = NULL;
acpi_driver_data(device) = NULL;
- //down(&acpi_bus_drivers_lock);
+ down(&acpi_bus_drivers_lock);
driver->references--;
- //up(&acpi_bus_drivers_lock);
+ up(&acpi_bus_drivers_lock);
return_VALUE(0);
}
if (!device || device->driver)
return_VALUE(AE_BAD_PARAMETER);
- //down(&acpi_bus_drivers_lock);
+ down(&acpi_bus_drivers_lock);
list_for_each(entry, &acpi_bus_drivers) {
break;
}
- //up(&acpi_bus_drivers_lock);
+ up(&acpi_bus_drivers_lock);
return_VALUE(result);
}
//if (acpi_disabled)
// return_VALUE(AE_NOT_FOUND);
- //down(&acpi_bus_drivers_lock);
+ down(&acpi_bus_drivers_lock);
list_add_tail(&driver->node, &acpi_bus_drivers);
- //up(&acpi_bus_drivers_lock);
+ up(&acpi_bus_drivers_lock);
acpi_bus_walk(acpi_root, acpi_bus_attach,
WALK_DOWN, driver);
if (driver->references)
return;
- //down(&acpi_bus_drivers_lock);
+ down(&acpi_bus_drivers_lock);
list_del(&driver->node);
- //up(&acpi_bus_drivers_lock);
+ up(&acpi_bus_drivers_lock);
return;
}
DPRINT("Subsystem revision %08x\n",ACPI_CA_VERSION);
+ KeInitializeSpinLock(&acpi_bus_event_lock);
+ KeInitializeEvent(&AcpiEventQueue, NotificationEvent, FALSE);
+ ExInitializeFastMutex(&acpi_bus_drivers_lock);
+
result = acpi_bus_init();
//if (!result) {