2 ** Copyright 2002/03, Thomas Kurschel. All rights reserved.
3 ** Distributed under the terms of the Haiku License.
7 Part of Open SCSI bus manager
9 DPC handling (deferred procedure calls).
11 DPC are executed by the service thread of the bus
15 #include "scsi_internal.h"
22 scsi_alloc_dpc(scsi_dpc_info
**dpc
)
26 *dpc
= (scsi_dpc_info
*)malloc(sizeof(scsi_dpc_info
));
30 memset(*dpc
, 0, sizeof(scsi_dpc_info
));
36 scsi_free_dpc(scsi_dpc_info
*dpc
)
46 scsi_schedule_dpc(scsi_bus_info
*bus
, scsi_dpc_info
*dpc
, /*int flags,*/
47 void (*func
)(void *arg
), void *arg
)
49 SHOW_FLOW(3, "bus=%p, dpc=%p", bus
, dpc
);
50 acquire_spinlock_irq(&bus
->dpc_lock
);
55 if (!dpc
->registered
) {
56 dpc
->registered
= true;
57 dpc
->next
= bus
->dpc_list
;
60 SHOW_FLOW0(3, "already registered - ignored");
62 release_spinlock_irq(&bus
->dpc_lock
);
64 // this is called in IRQ context, so scheduler is not allowed
65 release_sem_etc(bus
->start_service
, 1, B_DO_NOT_RESCHEDULE
);
70 /** execute pending DPCs */
73 scsi_check_exec_dpc(scsi_bus_info
*bus
)
75 SHOW_FLOW(3, "bus=%p, dpc_list=%p", bus
, bus
->dpc_list
);
76 acquire_spinlock_irq(&bus
->dpc_lock
);
80 void (*dpc_func
)(void *);
84 bus
->dpc_list
= dpc
->next
;
88 dpc
->registered
= false;
90 release_spinlock_irq(&bus
->dpc_lock
);
96 release_spinlock_irq(&bus
->dpc_lock
);