153889Smckusick /* 253889Smckusick * Copyright (c) 1992 The Regents of the University of California. 353889Smckusick * All rights reserved. 453889Smckusick * 553889Smckusick * This code is derived from software contributed to Berkeley by 653889Smckusick * Sony Corp. and Kazumasa Utashiro of Software Research Associates, Inc. 753889Smckusick * 853889Smckusick * %sccs.include.redist.c% 953889Smckusick * 1053889Smckusick * from: $Hdr: kb_ctrl.c,v 4.300 91/06/09 06:14:49 root Rel41 $ SONY 1153889Smckusick * 12*57177Sutashiro * @(#)kb_ctrl.c 7.2 (Berkeley) 12/17/92 1353889Smckusick */ 1453889Smckusick 1553889Smckusick /* 1653889Smckusick * Keyboard driver 1753889Smckusick */ 1853889Smckusick 19*57177Sutashiro #include <machine/fix_machine_type.h> 2053889Smckusick 2153889Smckusick #ifdef IPC_MRX 22*57177Sutashiro #include <sys/ioctl.h> 23*57177Sutashiro #include <news3400/iop/keyboard.h> 24*57177Sutashiro #include <news3400/iop/kbreg.h> 2553889Smckusick #else 26*57177Sutashiro #include <sys/ioctl.h> 27*57177Sutashiro #include <sys/param.h> 28*57177Sutashiro #include <sys/systm.h> 29*57177Sutashiro #include <sys/types.h> 30*57177Sutashiro #include <news3400/iop/keyboard.h> 31*57177Sutashiro #include <news3400/iop/kbreg.h> 3253889Smckusick #endif 3353889Smckusick 3453889Smckusick extern int tmode; 3553889Smckusick extern int kbd_status; 3653889Smckusick 3753889Smckusick int iscaps = 0; 3853889Smckusick int change_country = K_JAPANESE_J; 3953889Smckusick int country; 4053889Smckusick 4153889Smckusick extern Key_table default_table[]; 4253889Smckusick 4353889Smckusick #ifdef CPU_SINGLE 4453889Smckusick extern Key_table key_table[]; 4553889Smckusick Key_table *key_table_addr = key_table; 4653889Smckusick #endif 4753889Smckusick 4853889Smckusick #ifdef CPU_DOUBLE 4953889Smckusick Key_table *key_table_addr = default_table; 5053889Smckusick #endif 5153889Smckusick 5253889Smckusick #ifdef CPU_SINGLE 5353889Smckusick #include "ms.h" 54*57177Sutashiro #include <sys/clist.h> 55*57177Sutashiro #include <sys/ttydev.h> 56*57177Sutashiro #include <sys/tty.h> 57*57177Sutashiro #include <news3400/sio/scc.h> 58*57177Sutashiro #include <sys/time.h> 59*57177Sutashiro #include <news3400/iop/mouse.h> 6053889Smckusick 6153889Smckusick extern int cnrint(); 6253889Smckusick 6353889Smckusick kbd_open(chan) 6453889Smckusick int chan; 6553889Smckusick { 6653889Smckusick register int i; 6753889Smckusick 6853889Smckusick #ifdef news700 6953889Smckusick scc_open(chan); 7053889Smckusick #endif 7153889Smckusick #if defined(news1700) || defined(news1200) || defined(news3400) 7253889Smckusick kbm_open(chan); 7353889Smckusick #endif 7453889Smckusick return (0); 7553889Smckusick } 7653889Smckusick 7753889Smckusick kbd_read(chan, buf, n) 7853889Smckusick int chan; 7953889Smckusick char *buf; 8053889Smckusick int n; 8153889Smckusick { 8253889Smckusick #ifdef news700 8353889Smckusick register int i; 8453889Smckusick 8553889Smckusick for (i = n; i > 0; i--) 8653889Smckusick *buf++ = scc_getc(chan); 8753889Smckusick return (n); 8853889Smckusick #endif 8953889Smckusick #if defined(news1700) || defined(news1200) 9053889Smckusick 9153889Smckusick return (kbd_read_raw(chan, buf, n)); 9253889Smckusick #endif 9353889Smckusick } 9453889Smckusick 9553889Smckusick kbd_write(chan, buf, n) 9653889Smckusick int chan; 9753889Smckusick char *buf; 9853889Smckusick int n; 9953889Smckusick { 10053889Smckusick #ifdef news700 10153889Smckusick register int i; 10253889Smckusick 10353889Smckusick for (i = 0; i < n; i++) { 10453889Smckusick scc_putc(SCC_KEYBOARD, *buf++); 10553889Smckusick #ifndef NO_PRE_EMPT 10653889Smckusick if (i % 4 == 0) PRE_EMPT; 10753889Smckusick #endif 10853889Smckusick } 10953889Smckusick return (n); 11053889Smckusick #endif /* news700 */ 11153889Smckusick #if defined(news1700) || defined(news1200) || defined(news3400) 11253889Smckusick 11353889Smckusick return (kbm_write(SCC_KEYBOARD, buf, n)); 11453889Smckusick #endif 11553889Smckusick } 11653889Smckusick 11753889Smckusick kbd_back(buf, len) 11853889Smckusick register char *buf; 11953889Smckusick register int len; 12053889Smckusick { 12153889Smckusick int s; 12253889Smckusick 12353889Smckusick while (--len >= 0) { 12453889Smckusick s = spltty(); 12553889Smckusick cnrint(*buf++); 12653889Smckusick (void) splx(s); 12753889Smckusick } 12853889Smckusick return (0); 12953889Smckusick } 13053889Smckusick 13153889Smckusick #define KBPRI (PZERO+1) 13253889Smckusick 13353889Smckusick struct clist scode_buf; 13453889Smckusick struct clist keyboard_buf; 13553889Smckusick char kb_rwait; 13653889Smckusick 13753889Smckusick kbd_flush() 13853889Smckusick { 13953889Smckusick 14053889Smckusick ndflush(&scode_buf, scode_buf.c_cc); 14153889Smckusick return (0); 14253889Smckusick } 14353889Smckusick 14453889Smckusick static 14553889Smckusick kbd_put_raw(scode) 14653889Smckusick int scode; 14753889Smckusick { 14853889Smckusick extern char kb_busy; 14953889Smckusick 15053889Smckusick if (kb_busy) { 15153889Smckusick if (scode_buf.c_cc < CBSIZE) 15253889Smckusick putc(scode, &scode_buf); 15353889Smckusick if (kb_rwait) { 15453889Smckusick kb_rwait = 0; 15553889Smckusick wakeup((caddr_t)&kb_rwait); 15653889Smckusick } 15753889Smckusick } 15853889Smckusick return (scode); 15953889Smckusick 16053889Smckusick } 16153889Smckusick 16253889Smckusick kbd_read_raw(chan, buf, count) 16353889Smckusick int chan; 16453889Smckusick char *buf; 16553889Smckusick register int count; 16653889Smckusick { 16753889Smckusick register int i; 16853889Smckusick register int n; 16953889Smckusick register int s; 17053889Smckusick 17153889Smckusick if (count <= 0) 17253889Smckusick return (count); 17353889Smckusick s = splscc(); 17453889Smckusick while ((n = min(scode_buf.c_cc, count)) == 0) { 17553889Smckusick kb_rwait = 1; 17653889Smckusick sleep((caddr_t)&kb_rwait, KBPRI); 17753889Smckusick kb_rwait = 0; 17853889Smckusick } 17953889Smckusick (void) splx(s); 18053889Smckusick for (i = n; i > 0 ; i--) 18153889Smckusick *buf++ = getc(&scode_buf); 18253889Smckusick return (n); 18353889Smckusick } 18453889Smckusick 18553889Smckusick kbd_nread() 18653889Smckusick { 18753889Smckusick 18853889Smckusick return (scode_buf.c_cc); 18953889Smckusick } 19053889Smckusick 19153889Smckusick kbd_bell(n) 19253889Smckusick register int n; 19353889Smckusick { 19453889Smckusick 19553889Smckusick #if defined(news1700) || defined(news1200) || defined(news3400) 19653889Smckusick (void) kbm_write(SCC_KEYBOARD, NULL, n); 19753889Smckusick #endif 19853889Smckusick #ifdef news700 19953889Smckusick kbd_bell_scc(n); 20053889Smckusick #endif 20153889Smckusick return (0); 20253889Smckusick } 20353889Smckusick 20453889Smckusick kbd_putcode(code) 20553889Smckusick int code; 20653889Smckusick { 20753889Smckusick int c; 20853889Smckusick 20953889Smckusick kbd_put_raw(code); 21053889Smckusick kbd_encode(code); 21153889Smckusick while ((c = getc(&keyboard_buf)) != -1) 21253889Smckusick cnrint(c); 21353889Smckusick } 21453889Smckusick 21553889Smckusick put_code(buf, cnt) 21653889Smckusick register char *buf; 21753889Smckusick register int cnt; 21853889Smckusick { 21953889Smckusick 22053889Smckusick while (--cnt >= 0) 22153889Smckusick putc(*buf++, &keyboard_buf); 22253889Smckusick } 22353889Smckusick 22453889Smckusick kb_softint() 22553889Smckusick { 22653889Smckusick int code; 22753889Smckusick extern int tty00_is_console; 22853889Smckusick 22953889Smckusick while ((code = xgetc(SCC_KEYBOARD)) >= 0) { 23053889Smckusick #if defined(news1200) || defined(news3200) /* BEGIN reiko */ 23153889Smckusick if ((code & 0x7f) == KEY_EISUU) { 23253889Smckusick int up = code & OFF; 23353889Smckusick static int kana = 0; 23453889Smckusick 23553889Smckusick if (kana) { 23653889Smckusick if (up) { 23753889Smckusick kana = 0; 23853889Smckusick } 23953889Smckusick } else { 24053889Smckusick if (up) { 24153889Smckusick code = KEY_KANA | OFF; 24253889Smckusick kana = 1; 24353889Smckusick } else { 24453889Smckusick code = KEY_KANA; 24553889Smckusick } 24653889Smckusick } 24753889Smckusick } 24853889Smckusick #endif 24953889Smckusick 25053889Smckusick #ifdef NOTDEF /* KU:XXX */ 25153889Smckusick if (!tty00_is_console) 25253889Smckusick #endif 25353889Smckusick rst_dimmer_cnt(); 25453889Smckusick #if NMS > 0 25553889Smckusick if (!mskeytrigger(0, code & OFF, code & 0x7f)) 25653889Smckusick #endif 25753889Smckusick kbd_putcode(code); 25853889Smckusick } 25953889Smckusick } 26053889Smckusick #endif /* CPU_SINGLE */ 26153889Smckusick 26253889Smckusick #ifdef IPC_MRX 26353889Smckusick #include "mrx.h" 26453889Smckusick #include "queue.h" 26553889Smckusick #include "process.h" 26653889Smckusick #include "buffer.h" 26753889Smckusick #include "port.h" 26853889Smckusick #include "message.h" 26953889Smckusick #include "machdep.h" 27053889Smckusick #include "malloc.h" 27153889Smckusick #include "config.h" 27253889Smckusick #include "kbms.h" 27353889Smckusick 27453889Smckusick #ifdef news1800 27553889Smckusick #include "scc.h" 27653889Smckusick #endif 27753889Smckusick 27853889Smckusick static struct buffer *kbd_buf; 27953889Smckusick static int port_kbd_intr; 28053889Smckusick static int port_kbd_back; 28153889Smckusick static int port_kbd_ctrl; 28253889Smckusick 28353889Smckusick keyboard(chan) 28453889Smckusick int chan; 28553889Smckusick { 28653889Smckusick int kbd_ctrl(), kbd_output(); 28753889Smckusick int kbd_read(), kbd_ioctl(), kbd_io(); 28853889Smckusick 28953889Smckusick #ifdef news3800 29053889Smckusick extern int (*Xkb_intr)(); 29153889Smckusick int kb_intr(); 29253889Smckusick 29353889Smckusick Xkb_intr = kb_intr; 29453889Smckusick #endif 29553889Smckusick 29653889Smckusick #ifdef news1800 29753889Smckusick int scc_input(), scc_output(); 29853889Smckusick 29953889Smckusick if (scc_open(SCC_KEYBOARD) < 0) 30053889Smckusick return; 30153889Smckusick proc_create("scc_kbread", scc_input, 601, 512, SCC_KEYBOARD); 30253889Smckusick proc_create("scc_kbwrite", scc_output, 601, 512, SCC_KEYBOARD); 30353889Smckusick while (scc_std_ports[SCC_KEYBOARD][0] == 0) 30453889Smckusick proc_sleep_self(100); 30553889Smckusick #endif 30653889Smckusick kb_ioctl = kbd_ioctl; 30753889Smckusick kb_read = kbd_read; 30853889Smckusick kbd_init(); 30953889Smckusick proc_create("kbd_ctrl", kbd_ctrl, 300, DEFAULT_STACK_SIZE, 0); 31053889Smckusick proc_create("kbd_output", kbd_output, 300, DEFAULT_STACK_SIZE, 0); 31153889Smckusick proc_create("kbd_io", kbd_io, 300, DEFAULT_STACK_SIZE, 0); 31253889Smckusick } 31353889Smckusick 31453889Smckusick int (*reset_dimmer)(); 31553889Smckusick 31653889Smckusick kbd_ctrl() 31753889Smckusick { 31853889Smckusick register int m, n; 31953889Smckusick register int select; 32053889Smckusick int *len, from, count; 32153889Smckusick char *addr; 32253889Smckusick int ports[3]; 32353889Smckusick static char buf[16]; 32453889Smckusick 32553889Smckusick ports[0] = port_kbd_intr = port_create("kb_intr"); 32653889Smckusick ports[1] = port_kbd_back = port_create("kb_echoback"); 32753889Smckusick ports[2] = port_kbd_ctrl = STDPORT; 32853889Smckusick 32953889Smckusick #ifdef news3800 33053889Smckusick *(char *)KEYBD_RESET = 0; 33153889Smckusick *(char *)KEYBD_INTE = 1; 33253889Smckusick #endif 33353889Smckusick #ifdef news1800 33453889Smckusick count = 1; 33553889Smckusick msg_send(scc_std_ports[SCC_KEYBOARD][0], ports[0], 33653889Smckusick &count, sizeof (count), 0); 33753889Smckusick #endif 33853889Smckusick 33953889Smckusick kbd_buf = buffer_alloc(32); 34053889Smckusick (void) spl0(); 34153889Smckusick for (;;) { 34253889Smckusick if (buffer_status(kbd_buf) > 0) 34353889Smckusick m = 3; 34453889Smckusick else 34553889Smckusick m = 2; 34653889Smckusick if ((select = msg_select(m, ports)) == 0) { 34753889Smckusick msg_recv(ports[0], NULL, &addr, &count, 0); 34853889Smckusick if (reset_dimmer) 34953889Smckusick (*reset_dimmer)(); 35053889Smckusick while (--count >= 0) { 35153889Smckusick if (send_mouse == 0 || (*send_mouse)(*addr) == 0) 35253889Smckusick kbd_encode(*addr); 35353889Smckusick addr++; 35453889Smckusick } 35553889Smckusick #ifdef news1800 35653889Smckusick count = 1; 35753889Smckusick msg_send(scc_std_ports[SCC_KEYBOARD][0], ports[select], 35853889Smckusick &count, sizeof (count), 0); 35953889Smckusick #endif 36053889Smckusick } else if (select == 1) { /* ESC [ 6 n */ 36153889Smckusick msg_recv(ports[select], NULL, &addr, &count, 0); 36253889Smckusick put(kbd_buf, addr, count); 36353889Smckusick } else { 36453889Smckusick msg_recv(ports[select], &from, &len, NULL, 0); 36553889Smckusick n = buffer_status(kbd_buf); 36653889Smckusick n = min(n, *len); 36753889Smckusick n = get(kbd_buf, buf, min(n, sizeof (buf))); 36853889Smckusick msg_send(from, ports[select], buf, n, 0); 36953889Smckusick } 37053889Smckusick } 37153889Smckusick } 37253889Smckusick 37353889Smckusick kbd_output() 37453889Smckusick { 37553889Smckusick char *addr; 37653889Smckusick int from, len; 37753889Smckusick #ifdef news1800 37853889Smckusick register int subport; 37953889Smckusick 38053889Smckusick subport = port_create("port_kbd_write"); 38153889Smckusick #endif 38253889Smckusick 38353889Smckusick (void) spl0(); 38453889Smckusick for (;;) { 38553889Smckusick msg_recv(STDPORT, &from, &addr, &len, 0); 38653889Smckusick #ifdef news3800 38753889Smckusick len = kbd_write(0, addr, len); 38853889Smckusick #endif 38953889Smckusick #ifdef news1800 39053889Smckusick len = kbd_write(subport, addr, len); 39153889Smckusick #endif 39253889Smckusick msg_send(from, STDPORT, &len, sizeof(len), 0); 39353889Smckusick } 39453889Smckusick } 39553889Smckusick 39653889Smckusick kbd_io() 39753889Smckusick { 39853889Smckusick struct kb_ctrl_req *req; 39953889Smckusick int from, reply; 40053889Smckusick #ifdef news1800 40153889Smckusick register int sub_port; 40253889Smckusick 40353889Smckusick sub_port = port_create("port_kbd_sub"); 40453889Smckusick #endif 40553889Smckusick 40653889Smckusick (void) spl0(); 40753889Smckusick for (;;) { 40853889Smckusick msg_recv(STDPORT, &from, &req, NULL, 0); 40953889Smckusick if (req->kb_func == KIOCCHTBL || req->kb_func == KIOCOYATBL) 41053889Smckusick kbd_ioctl(0, req->kb_func, req->kb_arg); 41153889Smckusick else 41253889Smckusick #ifdef news1800 41353889Smckusick kbd_ioctl(sub_port, req->kb_func, &req->kb_arg); 41453889Smckusick #else 41553889Smckusick kbd_ioctl(0, req->kb_func, &req->kb_arg); 41653889Smckusick #endif 41753889Smckusick reply = req->kb_arg; 41853889Smckusick msg_send(from, STDPORT, &reply, sizeof(reply), 0); 41953889Smckusick } 42053889Smckusick } 42153889Smckusick 42253889Smckusick kbd_read(chan, buf, n) 42353889Smckusick int chan; 42453889Smckusick char *buf; 42553889Smckusick int n; 42653889Smckusick { 42753889Smckusick static int port; 42853889Smckusick char *addr; 42953889Smckusick int len; 43053889Smckusick 43153889Smckusick if (port == 0) 43253889Smckusick port = port_create("port_kbd_read"); 43353889Smckusick if (n <= 0) 43453889Smckusick return (0); 43553889Smckusick msg_send(port_kbd_ctrl, port, &n, sizeof (n), 0); 43653889Smckusick msg_recv(port, NULL, &addr, &len, 0); 43753889Smckusick bcopy(addr, buf, len); 43853889Smckusick msg_free(port); 43953889Smckusick return (len); 44053889Smckusick } 44153889Smckusick 44253889Smckusick kbd_write(chan, buf, n) 44353889Smckusick int chan; 44453889Smckusick char *buf; 44553889Smckusick int n; 44653889Smckusick { 44753889Smckusick #ifdef news1800 44853889Smckusick return (scc_write(chan, SCC_KEYBOARD, buf, n)); 44953889Smckusick #endif 45053889Smckusick 45153889Smckusick #ifdef news3800 45253889Smckusick *(char *)BEEP_FREQ = ~(n & 1); 45353889Smckusick *(char *)KEYBD_BEEP = 1; 45453889Smckusick return (n); 45553889Smckusick #endif 45653889Smckusick } 45753889Smckusick 45853889Smckusick kbd_back(buf, len) 45953889Smckusick char *buf; 46053889Smckusick int len; 46153889Smckusick { 46253889Smckusick 46353889Smckusick msg_send(port_kbd_back, 0, buf, len, 0); 46453889Smckusick return (0); 46553889Smckusick } 46653889Smckusick 46753889Smckusick kbd_nread() 46853889Smckusick { 46953889Smckusick 47053889Smckusick return (buffer_status(kbd_buf)); 47153889Smckusick } 47253889Smckusick 47353889Smckusick kbd_flush() 47453889Smckusick { 47553889Smckusick 47653889Smckusick buffer_flush(kbd_buf); 47753889Smckusick return (0); 47853889Smckusick } 47953889Smckusick 48053889Smckusick #ifdef news3800 48153889Smckusick kb_intr() 48253889Smckusick { 48353889Smckusick char c; 48453889Smckusick 48553889Smckusick if (port_kbd_intr > 0) 48653889Smckusick while (*(char *)KBMS_STAT & (1 << b_KBREADY)) { 48753889Smckusick c = *(char *)KEYBD_DATA; 48853889Smckusick msg_send(port_kbd_intr, 0, &c, sizeof (char), 0); 48953889Smckusick } 49053889Smckusick } 49153889Smckusick #endif /* news3800 */ 49253889Smckusick 49353889Smckusick kbd_bell(n, port) 49453889Smckusick int n, port; 49553889Smckusick { 49653889Smckusick 49753889Smckusick #ifdef news3800 49853889Smckusick (void) kbd_write(0, NULL, n); 49953889Smckusick #else 50053889Smckusick kbd_bell_scc(n, port); 50153889Smckusick #endif 50253889Smckusick return (0); 50353889Smckusick } 50453889Smckusick 50553889Smckusick put_code(buf, cnt) 50653889Smckusick char *buf; 50753889Smckusick int cnt; 50853889Smckusick { 50953889Smckusick 51053889Smckusick put(kbd_buf, buf, cnt); 51153889Smckusick } 51253889Smckusick #endif /* IPC_MRX */ 51353889Smckusick 51453889Smckusick kbd_ioctl(chan, cmd, argp) 51553889Smckusick int chan; 51653889Smckusick int cmd; 51753889Smckusick int *argp; 51853889Smckusick { 51953889Smckusick switch (cmd) { 52053889Smckusick 52153889Smckusick case KIOCFLUSH: 52253889Smckusick return (kbd_flush()); 52353889Smckusick 52453889Smckusick case KIOCSETS: 52553889Smckusick case KIOCGETS: 52653889Smckusick return (kbd_string(cmd, (Pfk_string *)argp)); 52753889Smckusick 52853889Smckusick case KIOCBELL: 52953889Smckusick #ifdef news1800 53053889Smckusick return (kbd_bell(*argp, chan)); 53153889Smckusick #else 53253889Smckusick return (kbd_bell(*argp)); 53353889Smckusick #endif 53453889Smckusick 53553889Smckusick case KIOCBACK: 53653889Smckusick if (argp == NULL) 53753889Smckusick return (-1); 53853889Smckusick if ((int)((Key_string *)argp)->key_string == NULL) 53953889Smckusick return (-1); 54053889Smckusick if ((int)((Key_string *)argp)->key_length <= 0) 54153889Smckusick return (-1); 54253889Smckusick return (kbd_back(((Key_string *)argp)->key_string, 54353889Smckusick ((Key_string *)argp)->key_length)); 54453889Smckusick 54553889Smckusick case KIOCREPT: 54653889Smckusick return (kbd_repeat(1)); 54753889Smckusick 54853889Smckusick case KIOCNRPT: 54953889Smckusick return (kbd_repeat(0)); 55053889Smckusick 55153889Smckusick case KIOCNREAD: 55253889Smckusick *argp = kbd_nread(); 55353889Smckusick return (0); 55453889Smckusick 55553889Smckusick case KIOCSETLOCK: 55653889Smckusick iscaps = *argp; 55753889Smckusick return (0); 55853889Smckusick 55953889Smckusick case KIOCGETCNUM: 56053889Smckusick *argp = country; 56153889Smckusick return (0); 56253889Smckusick 56353889Smckusick case KIOCSETCNUM: 56453889Smckusick country = *argp; 56553889Smckusick change_country = country; 56653889Smckusick return (0); 56753889Smckusick 56853889Smckusick case KIOCDEFTBL: 56953889Smckusick key_table_addr = default_table; 57053889Smckusick country = K_JAPANESE_J; 57153889Smckusick return (0); 57253889Smckusick 57353889Smckusick case KIOCCHTBL: 57453889Smckusick key_table_addr = (Key_table *)argp; 57553889Smckusick country = change_country; 57653889Smckusick return (0); 57753889Smckusick 57853889Smckusick case KIOCGETSTAT: 57953889Smckusick *argp = kbd_status; 58053889Smckusick return (0); 58153889Smckusick 58253889Smckusick case KIOCSETSTAT: 58353889Smckusick kbd_status = *argp; 58453889Smckusick return (0); 58553889Smckusick 58653889Smckusick default: 58753889Smckusick return (-1); 58853889Smckusick } 58953889Smckusick } 59053889Smckusick 59153889Smckusick #ifdef news1800 59253889Smckusick kbd_bell_scc(n, port) 59353889Smckusick register int n, port; 59453889Smckusick #else 59553889Smckusick kbd_bell_scc(n) 59653889Smckusick register int n; 59753889Smckusick #endif 59853889Smckusick { 59953889Smckusick register int i; 60053889Smckusick static char bell_data[] = { 60153889Smckusick 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 60253889Smckusick 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 60353889Smckusick 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 60453889Smckusick 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0 60553889Smckusick }; 60653889Smckusick 60753889Smckusick while (n > 0) { 60853889Smckusick i = min(n, sizeof (bell_data)); 60953889Smckusick #ifdef news1800 61053889Smckusick (void) kbd_write(port, bell_data, i); 61153889Smckusick #else 61253889Smckusick (void) kbd_write(0, bell_data, i); 61353889Smckusick #endif 61453889Smckusick n -= i; 61553889Smckusick } 61653889Smckusick } 61753889Smckusick 61853889Smckusick #ifdef KBDEBUG 61953889Smckusick scc_error_puts(chan, buf) 62053889Smckusick int chan; 62153889Smckusick char *buf; 62253889Smckusick { 62353889Smckusick while (*buf) { 62453889Smckusick scc_error_write(chan, *buf++, 1); 62553889Smckusick } 62653889Smckusick } 62753889Smckusick 62853889Smckusick scc_error_write_hex(chan, n, zs) 62953889Smckusick int chan; 63053889Smckusick unsigned int n; 63153889Smckusick int zs; 63253889Smckusick { 63353889Smckusick int i; 63453889Smckusick int tmp, al; 63553889Smckusick static char hex[] = "0123456789abcdef"; 63653889Smckusick 63753889Smckusick al = 0; 63853889Smckusick 63953889Smckusick for (i = 28; i >= 0; i -= 4) { 64053889Smckusick tmp = (n >> i) & 0x0f; 64153889Smckusick if (tmp || al || !zs || !i) { 64253889Smckusick al++; 64353889Smckusick scc_error_write(chan, hex[tmp], 1); 64453889Smckusick } 64553889Smckusick } 64653889Smckusick } 64753889Smckusick #endif /* KBDEBUG */ 648