/* * Put a character into a queue. */ static void tty_putc(int c, struct tty_queue *tq) { int s = splhigh(); if (ttyq_full(tq)) { splx(s); return; } tq->tq_buf[tq->tq_tail] = (char)(c & 0xFF); tq->tq_tail = ttyq_next(tq->tq_tail); tq->tq_count++; splx(s); }
/* * Get a character from a queue. */ int tty_getc(struct tty_queue *tq) { int s = splhigh(); if (ttyq_empty(tq)) { splx(s); return -1; } int c = tq->tq_buf[tq->tq_head]; tq->tq_head = ttyq_next(tq->tq_head); tq->tq_count--; splx(s); return c & 0xFF; }
/* * Put a character into a queue. */ void ttyq_putc(int c, struct tty_queue *tq) { irq_lock(); if (ttyq_full(tq)) { irq_unlock(); return; } tq->tq_buf[tq->tq_tail] = c; tq->tq_tail = ttyq_next(tq->tq_tail); tq->tq_count++; irq_unlock(); }
/* * Get a character from a queue. */ int ttyq_getc(struct tty_queue *tq) { int c; irq_lock(); if (ttyq_empty(tq)) { irq_unlock(); return -1; } c = tq->tq_buf[tq->tq_head]; tq->tq_head = ttyq_next(tq->tq_head); tq->tq_count--; irq_unlock(); return c; }