Date: Fri, 24 Oct 2008 10:28:15 GMT From: Ed Schouten <ed@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 151846 for review Message-ID: <200810241028.m9OASFYw016498@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=151846 Change 151846 by ed@ed_dull on 2008/10/24 10:28:11 Add clist routine prototypes. Affected files ... .. //depot/projects/mpsafetty/sys/conf/files#20 edit .. //depot/projects/mpsafetty/sys/dev/kbdmux/kbdmux.c#5 edit .. //depot/projects/mpsafetty/sys/kern/subr_clist.c#8 add .. //depot/projects/mpsafetty/sys/sys/clist.h#7 edit Differences ... ==== //depot/projects/mpsafetty/sys/conf/files#20 (text+ko) ==== @@ -1662,6 +1662,7 @@ kern/subr_autoconf.c standard kern/subr_blist.c standard kern/subr_bus.c standard +kern/subr_clist.c standard kern/subr_clock.c standard kern/subr_devstat.c standard kern/subr_disk.c standard ==== //depot/projects/mpsafetty/sys/dev/kbdmux/kbdmux.c#5 (text+ko) ==== @@ -36,6 +36,7 @@ #include <sys/param.h> #include <sys/bus.h> +#include <sys/clist.h> #include <sys/conf.h> #include <sys/consio.h> #include <sys/fcntl.h> @@ -204,7 +205,7 @@ callout_deactivate(&state->ks_timo); /* queue interrupt task if needed */ - if (state->ks_inq.c_cc > 0 && !(state->ks_flags & TASK) && + if (clist_usage(&state->ks_inq) > 0 && !(state->ks_flags & TASK) && KBDMUX_QUEUE_INTR(state) == 0) state->ks_flags |= TASK; @@ -223,6 +224,7 @@ switch (event) { case KBDIO_KEYINPUT: { int c; + char cq; KBDMUX_LOCK(state); @@ -245,12 +247,13 @@ if (!KBD_IS_BUSY(kbd)) continue; /* not open - discard the input */ - putc(c, &state->ks_inq); + cq = c; + clist_write(&state->ks_inq, &cq, 1); } /* queue interrupt task if needed */ - if (state->ks_inq.c_cc > 0 && !(state->ks_flags & TASK) && - KBDMUX_QUEUE_INTR(state) == 0) + if (clist_usage(&state->ks_inq) > 0 && + !(state->ks_flags & TASK) && KBDMUX_QUEUE_INTR(state) == 0) state->ks_flags |= TASK; KBDMUX_UNLOCK(state); @@ -383,8 +386,7 @@ } KBDMUX_LOCK_INIT(state); - clist_alloc_cblocks(&state->ks_inq, - KBDMUX_Q_SIZE, KBDMUX_Q_SIZE / 2); + clist_alloc(&state->ks_inq, KBDMUX_Q_SIZE); TASK_INIT(&state->ks_task, 0, kbdmux_kbd_intr, (void *) kbd); KBDMUX_CALLOUT_INIT(state); SLIST_INIT(&state->ks_kbds); @@ -448,7 +450,7 @@ bad: if (needfree) { if (state != NULL) { - clist_free_cblocks(&state->ks_inq); + clist_free(&state->ks_inq); free(state, M_KBDMUX); } if (keymap != NULL) @@ -495,8 +497,7 @@ } /* flush input queue */ - ndflush(&state->ks_inq, state->ks_inq.c_cc); - clist_free_cblocks(&state->ks_inq); + clist_free(&state->ks_inq); KBDMUX_UNLOCK(state); @@ -573,14 +574,15 @@ kbdmux_read(keyboard_t *kbd, int wait) { kbdmux_state_t *state = (kbdmux_state_t *) kbd->kb_data; - int c; + char c; KBDMUX_LOCK(state); - c = getc(&state->ks_inq); + if (clist_read(&state->ks_inq, &c, 1) != 1) { + KBDMUX_UNLOCK(state); + return (-1); + } KBDMUX_UNLOCK(state); - - if (c != -1) - kbd->kb_count ++; + kbd->kb_count++; return (KBD_IS_ACTIVE(kbd)? c : -1); } @@ -598,7 +600,7 @@ return (FALSE); KBDMUX_LOCK(state); - ready = (state->ks_inq.c_cc > 0)? TRUE : FALSE; + ready = clist_usage(&state->ks_inq) > 0 ? TRUE : FALSE; KBDMUX_UNLOCK(state); return (ready); @@ -612,7 +614,8 @@ { kbdmux_state_t *state = (kbdmux_state_t *) kbd->kb_data; u_int action; - int scancode, keycode; + int scancode = -1, keycode; + char cq; KBDMUX_LOCK(state); @@ -634,8 +637,7 @@ } /* see if there is something in the keyboard queue */ - scancode = getc(&state->ks_inq); - if (scancode == -1) { + if (clist_read(&state->ks_inq, &cq, 1) == 1) { if (state->ks_flags & POLLING) { kbdmux_kbd_t *k; @@ -649,11 +651,12 @@ if (!KBD_IS_BUSY(k->kbd)) continue; - putc(scancode, &state->ks_inq); + cq = scancode; + clist_write(&state->ks_inq, &cq, 1); } } - if (state->ks_inq.c_cc > 0) + if (clist_usage(&state->ks_inq) > 0) goto next_code; } @@ -894,7 +897,7 @@ if (!(state->ks_flags & COMPOSE) && (state->ks_composed_char != 0)) ready = TRUE; else - ready = (state->ks_inq.c_cc > 0)? TRUE : FALSE; + ready = clist_usage(&state->ks_inq) > 0 ? TRUE : FALSE; KBDMUX_UNLOCK(state); @@ -1219,7 +1222,7 @@ state->ks_composed_char = 0; /* state->ks_prefix = 0; XXX */ - ndflush(&state->ks_inq, state->ks_inq.c_cc); + clist_flush(&state->ks_inq); } static void ==== //depot/projects/mpsafetty/sys/sys/clist.h#7 (text+ko) ==== @@ -40,7 +40,7 @@ size_t cl_len; }; -void clist_alloc(struct clist *cl, unsigned int len); +void clist_alloc(struct clist *cl, size_t len); void clist_free(struct clist *cl); size_t clist_read(struct clist *cl, void *buf, size_t len); size_t clist_write(struct clist *cl, const void *buf, size_t len);
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200810241028.m9OASFYw016498>