Made DPC module binary compatible with BeOS one.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23901 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
05b79eadff
commit
6198a9798e
@ -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 <OS.h>
|
||||
#include <module.h>
|
||||
|
||||
#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);
|
||||
|
||||
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_
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user