2 ** Copyright 2002/03, Thomas Kurschel. All rights reserved.
3 ** Distributed under the terms of the MIT License.
7 Part of Open SCSI bus manager
11 The only one defined herein is a spinlock that automatically
12 disabled IRQs on enter and restores them on leave. Probably,
13 this should be made public as it's quite basic.
16 #ifndef __SCSI_LOCK_H__
17 #define __SCSI_LOCK_H__
19 #include <KernelExport.h>
22 // enhanced spinlock that automatically disables irqs when lock is hold
23 typedef struct spinlock_irq
{
24 spinlock lock
; // normal spinlock
25 cpu_status prev_irq_state
; // irq state before spinlock was entered
30 spinlock_irq_init(spinlock_irq
*lock
)
32 B_INITIALIZE_SPINLOCK(&lock
->lock
);
36 acquire_spinlock_irq(spinlock_irq
*lock
)
38 cpu_status prev_irq_state
= disable_interrupts();
40 acquire_spinlock(&lock
->lock
);
41 lock
->prev_irq_state
= prev_irq_state
;
45 release_spinlock_irq(spinlock_irq
*lock
)
47 cpu_status prev_irq_state
= lock
->prev_irq_state
;
49 release_spinlock(&lock
->lock
);
50 restore_interrupts(prev_irq_state
);