--- Gnu-Mach/device/kmsg.c 2020/09/02 04:41:25 1.1 +++ Gnu-Mach/device/kmsg.c 2020/09/02 04:47:54 1.1.1.3 @@ -1,5 +1,7 @@ /* GNU Mach Kernel Message Device. - Copyright (C) 1998, 1999 Free Software Foundation, Inc. + + Copyright (C) 1998, 1999, 2007 Free Software Foundation, Inc. + Written by OKUJI Yoshinori. This is free software; you can redistribute it and/or modify @@ -16,14 +18,17 @@ You should have received a copy of the G along with the software; see the file COPYING. If not, write to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* Now kmsg provides stream interface, not random access methods. */ +/* kmsg provides a stream interface. */ #include +#include + #include +#include #include #include #include -#include +#include #define KMSGBUFSIZE (4096) /* XXX */ @@ -37,11 +42,11 @@ static int kmsg_read_offset; /* I/O request queue for blocking read */ static queue_head_t kmsg_read_queue; /* Used for exclusive access to the device */ -static int kmsg_in_use; +static boolean_t kmsg_in_use; /* Used for exclusive access to the routines */ -static simple_lock_data_t kmsg_lock; +decl_simple_lock_data (static, kmsg_lock); /* If already initialized or not */ -static int kmsg_init_done = 0; +static boolean_t kmsg_init_done = FALSE; /* Kernel Message Initializer */ static void @@ -50,13 +55,13 @@ kmsginit (void) kmsg_write_offset = 0; kmsg_read_offset = 0; queue_init (&kmsg_read_queue); - kmsg_in_use = 0; + kmsg_in_use = FALSE; simple_lock_init (&kmsg_lock); } /* Kernel Message Open Handler */ io_return_t -kmsgopen (dev_t dev, int flag, io_req_t ior) +kmsgopen (dev_t dev, int flag, const io_req_t ior) { simple_lock (&kmsg_lock); if (kmsg_in_use) @@ -65,21 +70,20 @@ kmsgopen (dev_t dev, int flag, io_req_t return D_ALREADY_OPEN; } - kmsg_in_use = 1; + kmsg_in_use = TRUE; simple_unlock (&kmsg_lock); return D_SUCCESS; } /* Kernel Message Close Handler */ -io_return_t +void kmsgclose (dev_t dev, int flag) { simple_lock (&kmsg_lock); - kmsg_in_use = 0; + kmsg_in_use = FALSE; simple_unlock (&kmsg_lock); - return D_SUCCESS; } static boolean_t kmsg_read_done (io_req_t ior); @@ -106,7 +110,7 @@ kmsgread (dev_t dev, io_req_t ior) } ior->io_done = kmsg_read_done; - enqueue_tail (&kmsg_read_queue, ior); + enqueue_tail (&kmsg_read_queue, (queue_entry_t) ior); simple_unlock (&kmsg_lock); return D_IO_QUEUED; } @@ -145,7 +149,6 @@ kmsgread (dev_t dev, io_req_t ior) static boolean_t kmsg_read_done (io_req_t ior) { - int err; int amt, len; simple_lock (&kmsg_lock); @@ -153,7 +156,7 @@ kmsg_read_done (io_req_t ior) { /* The queue is empty. */ ior->io_done = kmsg_read_done; - enqueue_tail (&kmsg_read_queue, ior); + enqueue_tail (&kmsg_read_queue, (queue_entry_t) ior); simple_unlock (&kmsg_lock); return FALSE; } @@ -221,7 +224,7 @@ kmsg_putchar (int c) if (!kmsg_init_done) { kmsginit (); - kmsg_init_done = 1; + kmsg_init_done = TRUE; } simple_lock (&kmsg_lock);