From 6198a9798e8b8eb0210a60ebedf2a839704e4dbe Mon Sep 17 00:00:00 2001 From: Philippe Houdoin Date: Wed, 6 Feb 2008 23:10:13 +0000 Subject: [PATCH] Made DPC module binary compatible with BeOS one. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23901 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- headers/os/drivers/dpc.h | 14 ++++++----- .../kernel/bus_managers/acpi/acpi_busman.c | 5 +++- .../kernel/bus_managers/firewire/fwohci.c | 2 +- src/add-ons/kernel/generic/dpc/dpc.c | 24 ++++++++++++------- 4 files changed, 29 insertions(+), 16 deletions(-) diff --git a/headers/os/drivers/dpc.h b/headers/os/drivers/dpc.h index 198f683717..549622b45f 100644 --- a/headers/os/drivers/dpc.h +++ b/headers/os/drivers/dpc.h @@ -1,26 +1,28 @@ /* DPC module API - * Copyright 2007, Haiku Inc. All Rights Reserved. + * Copyright 2007-2008, Haiku Inc. All Rights Reserved. * Distributed under the terms of the MIT License */ #ifndef _DPC_MODULE_H_ #define _DPC_MODULE_H_ +#include #include #ifdef __cplusplus extern "C" { #endif -#define B_DPC_MODULE_NAME "generic/dpc/haiku/v1" +#define B_DPC_MODULE_NAME "generic/dpc/v1" typedef void (*dpc_func) (void *arg); typedef struct { - module_info info; - void * (*new_dpc_queue)(const char *name, long priority, int queue_size); + module_info info; + + status_t (*new_dpc_queue)(void **queue, const char *name, int32 priority); status_t (*delete_dpc_queue)(void *queue); - status_t (*queue_dpc)(void *queue, dpc_func dpc_name, void *arg); + status_t (*queue_dpc)(void *queue, dpc_func func, void *arg); } dpc_module_info; @@ -28,4 +30,4 @@ typedef struct { } #endif -#endif +#endif // _DPC_MODULE_H_ diff --git a/src/add-ons/kernel/bus_managers/acpi/acpi_busman.c b/src/add-ons/kernel/bus_managers/acpi/acpi_busman.c index 09010e5807..f2be9f5276 100644 --- a/src/add-ons/kernel/bus_managers/acpi/acpi_busman.c +++ b/src/add-ons/kernel/bus_managers/acpi/acpi_busman.c @@ -110,7 +110,10 @@ acpi_std_ops(int32 op,...) } #endif - gDPChandle = gDPC->new_dpc_queue("acpi_task", B_NORMAL_PRIORITY, 10); + if (gDPC->new_dpc_queue(&gDPChandle, "acpi_task", B_NORMAL_PRIORITY) != B_OK) { + ERROR("AcpiInitializeSubsystem failed (new_dpc_queue() failed!)\n"); + goto err; + } #ifdef ACPI_DEBUG_OUTPUT AcpiDbgLevel = ACPI_DEBUG_ALL | ACPI_LV_VERBOSE; diff --git a/src/add-ons/kernel/bus_managers/firewire/fwohci.c b/src/add-ons/kernel/bus_managers/firewire/fwohci.c index 79aaff08c5..115a2d378b 100644 --- a/src/add-ons/kernel/bus_managers/firewire/fwohci.c +++ b/src/add-ons/kernel/bus_managers/firewire/fwohci.c @@ -764,7 +764,7 @@ fwohci_init(struct fwohci_softc *sc) TASK_INIT(&sc->fwohci_task_busreset, 2, fwohci_task_busreset, sc); TASK_INIT(&sc->fwohci_task_sid, 1, fwohci_task_sid, sc); TASK_INIT(&sc->fwohci_task_dma, 0, fwohci_task_dma, sc);*/ - sc->fc.taskqueue = gDpc->new_dpc_queue("fw_taskq", FW_TASKQ_PRI, FW_TASKQ_SIZE); + gDpc->new_dpc_queue(&sc->fc.taskqueue, "fw_taskq", FW_TASKQ_PRI); fw_init(&sc->fc); fwohci_reset(sc); diff --git a/src/add-ons/kernel/generic/dpc/dpc.c b/src/add-ons/kernel/generic/dpc/dpc.c index bd77da4507..19fcde2477 100644 --- a/src/add-ons/kernel/generic/dpc/dpc.c +++ b/src/add-ons/kernel/generic/dpc/dpc.c @@ -35,6 +35,7 @@ typedef struct { // size * slots follow } dpc_queue; +#define DPC_QUEUE_SIZE 64 static int32 dpc_thread(void *arg) @@ -74,18 +75,21 @@ dpc_thread(void *arg) // ---- Public API -static void * -new_dpc_queue(const char *name, long priority, int queue_size) +static status_t +new_dpc_queue(void **handle, const char *name, int32 priority) { char str[64]; dpc_queue *queue; - queue = malloc(sizeof(dpc_queue) + queue_size * sizeof(dpc_slot)); + if (!handle) + return B_BAD_VALUE; + + queue = malloc(sizeof(dpc_queue) + DPC_QUEUE_SIZE * sizeof(dpc_slot)); if (!queue) - return NULL; + return B_NO_MEMORY; queue->head = queue->tail = 0; - queue->size = queue_size; + queue->size = DPC_QUEUE_SIZE; queue->count = 0; queue->lock = 0; // Init the spinlock @@ -100,8 +104,9 @@ new_dpc_queue(const char *name, long priority, int queue_size) queue->wakeup_sem = create_sem(0, str); if (queue->wakeup_sem < B_OK) { + status_t status = queue->wakeup_sem; free(queue); - return NULL; + return status; } set_sem_owner(queue->wakeup_sem, B_SYSTEM_TEAM); @@ -109,13 +114,16 @@ new_dpc_queue(const char *name, long priority, int queue_size) // the queued/deferred procedure calls queue->thread = spawn_kernel_thread(dpc_thread, name, priority, queue); if (queue->thread < 0) { + status_t status = queue->thread; delete_sem(queue->wakeup_sem); free(queue); - return NULL; + return status; } resume_thread(queue->thread); - return queue; + *handle = queue; + + return B_OK; }