diff options
Diffstat (limited to 'device')
-rw-r--r-- | device/kmsg.c | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/device/kmsg.c b/device/kmsg.c index c80775d..dbf6b8a 100644 --- a/device/kmsg.c +++ b/device/kmsg.c @@ -44,7 +44,10 @@ static queue_head_t kmsg_read_queue; /* Used for exclusive access to the device */ static boolean_t kmsg_in_use; /* Used for exclusive access to the routines */ -decl_simple_lock_data (static, kmsg_lock); +static struct lock kmsg_lock_data; +#define kmsg_lock_init() lock_init (&kmsg_lock_data, FALSE) +#define kmsg_lock() lock_write (&kmsg_lock_data) +#define kmsg_unlock() lock_write_done (&kmsg_lock_data) /* If already initialized or not */ static boolean_t kmsg_init_done = FALSE; @@ -56,23 +59,23 @@ kmsginit (void) kmsg_read_offset = 0; queue_init (&kmsg_read_queue); kmsg_in_use = FALSE; - simple_lock_init (&kmsg_lock); + kmsg_lock_init (); } /* Kernel Message Open Handler */ io_return_t kmsgopen (dev_t dev, int flag, const io_req_t ior) { - simple_lock (&kmsg_lock); + kmsg_lock (); if (kmsg_in_use) { - simple_unlock (&kmsg_lock); + kmsg_unlock (); return D_ALREADY_OPEN; } kmsg_in_use = TRUE; - simple_unlock (&kmsg_lock); + kmsg_unlock (); return D_SUCCESS; } @@ -80,10 +83,10 @@ kmsgopen (dev_t dev, int flag, const io_req_t ior) void kmsgclose (dev_t dev, int flag) { - simple_lock (&kmsg_lock); + kmsg_lock (); kmsg_in_use = FALSE; - - simple_unlock (&kmsg_lock); + + kmsg_unlock (); } static boolean_t kmsg_read_done (io_req_t ior); @@ -99,19 +102,19 @@ kmsgread (dev_t dev, io_req_t ior) if (err != KERN_SUCCESS) return err; - simple_lock (&kmsg_lock); + kmsg_lock (); if (kmsg_read_offset == kmsg_write_offset) { /* The queue is empty. */ if (ior->io_mode & D_NOWAIT) { - simple_unlock (&kmsg_lock); + kmsg_unlock (); return D_WOULD_BLOCK; } ior->io_done = kmsg_read_done; enqueue_tail (&kmsg_read_queue, (queue_entry_t) ior); - simple_unlock (&kmsg_lock); + kmsg_unlock (); return D_IO_QUEUED; } @@ -141,8 +144,8 @@ kmsgread (dev_t dev, io_req_t ior) kmsg_read_offset -= KMSGBUFSIZE; ior->io_residual = ior->io_count - amt; - - simple_unlock (&kmsg_lock); + + kmsg_unlock (); return D_SUCCESS; } @@ -151,13 +154,13 @@ kmsg_read_done (io_req_t ior) { int amt, len; - simple_lock (&kmsg_lock); + kmsg_lock (); if (kmsg_read_offset == kmsg_write_offset) { /* The queue is empty. */ ior->io_done = kmsg_read_done; enqueue_tail (&kmsg_read_queue, (queue_entry_t) ior); - simple_unlock (&kmsg_lock); + kmsg_unlock (); return FALSE; } @@ -188,7 +191,7 @@ kmsg_read_done (io_req_t ior) ior->io_residual = ior->io_count - amt; - simple_unlock (&kmsg_lock); + kmsg_unlock (); ds_read_done (ior); return TRUE; @@ -226,8 +229,8 @@ kmsg_putchar (int c) kmsginit (); kmsg_init_done = TRUE; } - - simple_lock (&kmsg_lock); + + kmsg_lock (); offset = kmsg_write_offset + 1; if (offset == KMSGBUFSIZE) offset = 0; @@ -235,7 +238,7 @@ kmsg_putchar (int c) if (offset == kmsg_read_offset) { /* Discard C. */ - simple_unlock (&kmsg_lock); + kmsg_unlock (); return; } @@ -246,5 +249,5 @@ kmsg_putchar (int c) while ((ior = (io_req_t) dequeue_head (&kmsg_read_queue)) != NULL) iodone (ior); - simple_unlock (&kmsg_lock); + kmsg_unlock (); } |