--- Gnu-Mach/i386/i386at/kd.c 2020/09/02 04:44:36 1.1.1.3 +++ Gnu-Mach/i386/i386at/kd.c 2020/09/02 04:49:22 1.1.1.5 @@ -76,61 +76,39 @@ WITH THE USE OR PERFORMANCE OF THIS SOFT /* $ Header: $ */ -#include - #include -#include +#include +#include +#include #include #include #include -#include /* for struct uio (!) */ -#include +#include #include -#include "vm_param.h" +#include +#include +#include #include +#include #include #include +#include +#include #include -#include - -#include -#if NBLIT > 0 -#include -#else -#define blit_present() FALSE -#define blit_init() /* nothing */ -#endif - -#include -#if NEVC > 0 -int evc1init(); -#else -#define evc1init() FALSE -#endif +#include +#include #define DEBUG 1 /* export feep() */ -#define DEFAULT -1 /* see kd_atoi */ - -void kd_enqsc(); /* enqueues a scancode */ - -void timeout(); - #if 0 #define BROKEN_KEYBOARD_RESET #endif struct tty kd_tty; -extern int rebootflag; +extern boolean_t rebootflag; static void charput(), charmvup(), charmvdown(), charclear(), charsetcursor(); -static void kd_noopreset(); -boolean_t kdcheckmagic(); - -int kdcnprobe(struct consdev *cp); -int kdcninit(struct consdev *cp); -int kdcngetc(dev_t dev, int wait); -int kdcnputc(dev_t dev, int c); +static void kd_noopreset(void); /* * These routines define the interface to the device-specific layer. @@ -144,10 +122,6 @@ void (*kd_dsetcursor)() = charsetcursor; /* set cursor position on displayed page */ void (*kd_dreset)() = kd_noopreset; /* prepare for reboot */ -/* forward declarations */ -unsigned char kd_getdata(), state2leds(); - - /* * Globals used for both character-based controllers and bitmap-based * controllers. Default is EGA. @@ -230,7 +204,7 @@ u_char *esc_spt = (u_char *)0; - Delete returns `ESC [ 9' instead of 0x7f. - Alt + function keys return key sequences that are different from the key sequences returned by the function keys alone. - This is done with the idea of alowing a terminal server to + This is done with the idea of allowing a terminal server to implement multiple virtual consoles mapped on Alt+F1, Alt+F2, etc, as in Linux. @@ -239,68 +213,63 @@ u_char *esc_spt = (u_char *)0; unsigned char key_map[NUMKEYS][WIDTH_KMAP] = { {NC,NC,NC, NC,N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,K_PERIOD,NC, 0x1b,0x4e,K_GTHN}, +{K_SLASH,NC,NC, K_QUES,NC,NC, K_SLASH,NC,NC, 0x1b,K_SLASH,NC, 0x1b,0x4e,K_QUES}, +{K_SCAN,K_RSHSC,NC, K_SCAN,K_RSHSC,NC, K_SCAN,K_RSHSC,NC, K_SCAN,K_RSHSC,NC, K_SCAN,K_RSHSC,NC}, +{K_ASTER,NC,NC, K_ASTER,NC,NC, K_ASTER,NC,NC, 0x1b,K_ASTER,NC, 0x1b,0x4e,K_ASTER}, +{K_SCAN,K_ALTSC,NC, K_SCAN,K_ALTSC,NC, K_SCAN,K_ALTSC,NC, K_SCAN,K_ALTSC,NC, K_SCAN,K_ALTSC,NC}, {K_SPACE,NC,NC, K_SPACE,NC,NC, K_NUL,NC,NC, 0x1b,K_SPACE,NC, K_SPACE,NC,NC}, -{K_SCAN,K_CLCKSC,NC, K_SCAN,K_CLCKSC,NC, K_SCAN,K_CLCKSC,NC, - K_SCAN,K_CLCKSC,NC, K_SCAN,K_CLCKSC,NC}, +{K_SCAN,K_CLCKSC,NC, K_SCAN,K_CLCKSC,NC, K_SCAN,K_CLCKSC,NC, K_SCAN,K_CLCKSC,NC, K_SCAN,K_CLCKSC,NC}, {K_F1, K_F1S, K_F1, K_F1A, K_F1S}, {K_F2, K_F2S, K_F2, K_F2A, K_F2S}, {K_F3, K_F3S, K_F3, K_F3A, K_F3S}, @@ -311,25 +280,21 @@ unsigned char key_map[NUMKEYS][WIDTH_KMA {K_F8, K_F8S, K_F8, K_F8A, K_F8S}, {K_F9, K_F9S, K_F9, K_F9A, K_F9S}, {K_F10, K_F10S, K_F10, K_F10A, K_F10S}, -{K_SCAN,K_NLCKSC,NC, K_SCAN,K_NLCKSC,NC, K_SCAN,K_NLCKSC,NC, - K_SCAN,K_NLCKSC,NC, K_SCAN,K_NLCKSC,NC}, +{K_SCAN,K_NLCKSC,NC, K_SCAN,K_NLCKSC,NC, K_SCAN,K_NLCKSC,NC, K_SCAN,K_NLCKSC,NC, K_SCAN,K_NLCKSC,NC}, {K_SCRL, K_NUL,NC,NC, K_SCRL, K_SCRL, K_NUL,NC,NC}, -{K_HOME, K_SEVEN,NC,NC, K_HOME, K_HOME, 0x1b,0x4e,0x37}, -{K_UA, K_EIGHT,NC,NC, K_UA, K_UA, 0x1b,0x4e,0x38}, -{K_PUP, K_NINE,NC,NC, K_PUP, K_PUP, 0x1b,0x4e,0x39}, -{0x1b,0x5b,0x53, K_MINUS,NC,NC, 0x1b,0x5b,0x53, 0x1b,0x5b,0x53, - 0x1b,0x4e,0x2d}, -{K_LA, K_FOUR,NC,NC, K_LA, K_LA, 0x1b,0x4e,0x34}, -{0x1b,0x5b,0x47, K_FIVE,NC,NC, 0x1b,0x5b,0x47, 0x1b,0x5b,0x47, - 0x1b,0x4e,0x35}, -{K_RA, K_SIX,NC,NC, K_RA, K_RA, 0x1b,0x4e,0x36}, -{0x1b,0x5b,0x54, K_PLUS,NC,NC, 0x1b,0x5b,0x54, 0x1b,0x5b,0x54, - 0x1b,0x4e,0x2b}, -{K_END, K_ONE,NC,NC, K_END, K_END, 0x1b,0x4e,0x31}, -{K_DA, K_TWO,NC,NC, K_DA, K_DA, 0x1b,0x4e,0x32}, -{K_PDN, K_THREE,NC,NC, K_PDN, K_PDN, 0x1b,0x4e,0x33}, -{K_INS, K_ZERO,NC,NC, K_INS, K_INS, 0x1b,0x4e,0x30}, -{0x1b,0x5b,0x39, K_PERIOD,NC,NC, K_DEL,NC,NC, K_DEL,NC,NC, 0x1b,0x4e,0x2e}, +{K_HOME, K_SEVEN,NC,NC, K_HOME, K_HOME, 0x1b,0x4e,K_SEVEN}, +{K_UA, K_EIGHT,NC,NC, K_UA, K_UA, 0x1b,0x4e,K_EIGHT}, +{K_PUP, K_NINE,NC,NC, K_PUP, K_PUP, 0x1b,0x4e,K_NINE}, +{0x1b,0x5b,0x53, K_MINUS,NC,NC, 0x1b,0x5b,0x53, 0x1b,0x5b,0x53, 0x1b,0x4e,0x2d}, +{K_LA, K_FOUR,NC,NC, K_LA, K_LA, 0x1b,0x4e,K_FOUR}, +{0x1b,0x5b,0x47, K_FIVE,NC,NC, 0x1b,0x5b,0x47, 0x1b,0x5b,0x47, 0x1b,0x4e,0x35}, +{K_RA, K_SIX,NC,NC, K_RA, K_RA, 0x1b,0x4e,K_SIX}, +{0x1b,0x5b,0x54, K_PLUS,NC,NC, 0x1b,0x5b,0x54, 0x1b,0x5b,0x54, 0x1b,0x4e,0x2b}, +{K_END, K_ONE,NC,NC, K_END, K_END, 0x1b,0x4e,K_ONE}, +{K_DA, K_TWO,NC,NC, K_DA, K_DA, 0x1b,0x4e,K_TWO}, +{K_PDN, K_THREE,NC,NC, K_PDN, K_PDN, 0x1b,0x4e,K_THREE}, +{K_INS, K_ZERO,NC,NC, K_INS, K_INS, 0x1b,0x4e,K_ZERO}, +{0x1b,0x5b,0x39, K_PERIOD,NC,NC, K_DEL,NC,NC, K_DEL,NC,NC, 0x1b,0x4e,K_PERIOD}, {NC,NC,NC, NC,NC,NC, NC,NC,NC, NC,NC,NC, NC,NC,NC}, {NC,NC,NC, NC,NC,NC, NC,NC,NC, NC,NC,NC, NC,NC,NC}, {NC,NC,NC, NC,NC,NC, NC,NC,NC, NC,NC,NC, NC,NC,NC}, @@ -345,31 +310,6 @@ unsigned char key_map[NUMKEYS][WIDTH_KMA short kd_index_reg = EGA_IDX_REG; short kd_io_reg = EGA_IO_REG; -/* - * IO port sets for different controllers. - */ -io_reg_t vga_port_list[] = { - 0x3b4, 0x3b5, 0x3b8, 0x3b9, 0x3ba, /* MDA/EGA */ - 0x3d4, 0x3d5, 0x3d8, 0x3d9, 0x3da, /* CGA/EGA */ - 0x3c0, 0x3c1, 0x3c2, 0x3c3, 0x3c4, 0x3c5, 0x3c6, 0x3c7, - 0x3c8, 0x3c9, 0x3ca, 0x3cb, 0x3cc, 0x3cd, 0x3ce, 0x3cf, - IO_REG_NULL -}; - -mach_device_t kd_io_device = 0; - -kd_io_map_open(device) - mach_device_t device; -{ - kd_io_device = device; - io_port_create(device, vga_port_list); -} - -kd_io_map_close() -{ - io_port_destroy(kd_io_device); - kd_io_device = 0; -} /* * Globals used only for bitmap-based controllers. See kdsoft.h for @@ -408,17 +348,19 @@ int kd_pollc = 0; * Ring the bell for a short time. * Warning: uses outb(). You may prefer to use kd_debug_put. */ -feep() +void +feep(void) { int i; kd_bellon(); for (i = 0; i < 50000; ++i) ; - kd_belloff(); + kd_belloff(NULL); } -pause() +void +pause(void) { int i; @@ -431,9 +373,10 @@ pause() * LOC=0 means put it in the bottom right corner, LOC=1 means put it * one column to the left, etc. */ -kd_debug_put(loc, c) -int loc; -char c; +void +kd_debug_put( + int loc, + char c) { csrpos_t pos = ONE_PAGE - (loc+1) * ONE_SPACE; @@ -442,11 +385,11 @@ char c; #endif /* DEBUG */ -extern int mouse_in_use; -int old_kb_mode; +extern boolean_t mouse_in_use; +int old_kb_mode; -cnpollc(on) -boolean_t on; +void +cnpollc(boolean_t on) { if (mouse_in_use) { if (on) { @@ -486,15 +429,14 @@ boolean_t on; * output: device is opened and setup * */ -kdopen(dev, flag, ior) - dev_t dev; - int flag; - io_req_t ior; +int +kdopen( + dev_t dev, + int flag, + io_req_t ior) { struct tty *tp; - int kdstart(); spl_t o_pri; - int kdstop(); tp = &kd_tty; o_pri = spltty(); @@ -513,11 +455,6 @@ kdopen(dev, flag, ior) tp->t_ospeed = tp->t_ispeed = B9600; tp->t_flags = ODDP|EVENP|ECHO|CRMOD|XTABS; kdinit(); - - /* XXX kd_io_map_open allocates memory */ - simple_unlock(&tp->t_lock); - kd_io_map_open(ior->io_device); - simple_lock(&tp->t_lock); } tp->t_state |= TS_CARR_ON; simple_unlock(&tp->t_lock); @@ -538,8 +475,9 @@ kdopen(dev, flag, ior) * */ /*ARGSUSED*/ +void kdclose(dev, flag) -int dev; +dev_t dev; int flag; { struct tty *tp; @@ -553,10 +491,7 @@ int flag; splx(s); } - kd_io_map_close(); - return; - } @@ -572,9 +507,10 @@ int flag; * */ /*ARGSUSED*/ +int kdread(dev, uio) -int dev; -struct uio *uio; +dev_t dev; +io_req_t uio; { struct tty *tp; @@ -596,9 +532,10 @@ struct uio *uio; * */ /*ARGSUSED*/ +int kdwrite(dev, uio) -int dev; -struct uio *uio; +dev_t dev; +io_req_t uio; { return((*linesw[kd_tty.t_line].l_write)(&kd_tty, uio)); } @@ -611,29 +548,30 @@ struct uio *uio; int kdmmap(dev, off, prot) dev_t dev; - off_t off; - int prot; + vm_offset_t off; + vm_prot_t prot; { - if ((u_int) off >= (128*1024)) + if (off >= (128*1024)) return(-1); /* Get page frame number for the page to be mapped. */ return(i386_btop(kd_bitmap_start+off)); } -kdportdeath(dev, port) - dev_t dev; - mach_port_t port; +int +kdportdeath( + dev_t dev, + mach_port_t port) { - return (tty_portdeath(&kd_tty, port)); + return (tty_portdeath(&kd_tty, (ipc_port_t)port)); } /*ARGSUSED*/ -io_return_t kdgetstat(dev, flavor, data, count) - dev_t dev; - int flavor; - int * data; /* pointer to OUT array */ - unsigned int *count; /* OUT */ +io_return_t kdgetstat( + dev_t dev, + int flavor, + int * data, /* pointer to OUT array */ + natural_t *count) /* OUT */ { io_return_t result; @@ -659,11 +597,11 @@ io_return_t kdgetstat(dev, flavor, data, } /*ARGSUSED*/ -io_return_t kdsetstat(dev, flavor, data, count) - dev_t dev; - int flavor; - int * data; - unsigned int count; +io_return_t kdsetstat( + dev_t dev, + int flavor, + int * data, + natural_t count) { io_return_t result; @@ -695,31 +633,30 @@ io_return_t kdsetstat(dev, flavor, data, * Turn the bell on or off. Returns error code, if given bogus * on/off value. */ -kdsetbell(val, flags) -int val; /* on or off */ -int flags; /* flags set for console */ +int +kdsetbell( + int val, /* on or off */ + int flags) /* flags set for console */ { int err = 0; - if (val == KD_BELLON) kd_bellon(); else if (val == KD_BELLOFF) - kd_belloff(); + kd_belloff(NULL); else err = D_INVALID_OPERATION; return(err); } - /* * kdgetkbent: * * Get entry from key mapping table. Returns error code, if any. */ -kdgetkbent(kbent) -struct kbentry * kbent; +int +kdgetkbent(struct kbentry *kbent) { u_char *cp; spl_t o_pri = SPLKD(); /* probably superfluous */ @@ -739,9 +676,9 @@ struct kbentry * kbent; * Set entry in key mapping table. Return error code, if any. */ int -kdsetkbent(kbent, flags) -struct kbentry * kbent; -int flags; /* flags set for console */ +kdsetkbent( + struct kbentry *kbent, + int flags) /* flags set for console */ { u_char *cp; spl_t o_pri; @@ -770,23 +707,25 @@ int flags; /* flags set for console * * */ /*ARGSUSED*/ -kdintr(vec, regs) -int vec; -int regs; +void +kdintr(int vec) { struct tty *tp; unsigned char c; unsigned char scancode; - int o_pri; - int char_idx; + unsigned int char_idx; boolean_t up = FALSE; /* key-up event */ - extern int mouse_in_use; + if (kd_pollc) return; /* kdb polling kbd */ + if (!kd_initialized) + return; + tp = &kd_tty; #ifdef old - while ((inb(K_STATUS) & K_OBUF_FUL) == 0); /* this should never loop */ + while ((inb(K_STATUS) & K_OBUF_FUL) == 0) + ; /* this should never loop */ #else /* old */ { /* @@ -835,7 +774,7 @@ int regs; goto done; } else if (kd_kbd_mouse && kd_kbd_magic(scancode)) { goto done; - } else if (kdcheckmagic(scancode, ®s)) { + } else if (kdcheckmagic(scancode)) { goto done; } else if (kb_mode == KB_EVENT) { kd_enqsc(scancode); @@ -855,7 +794,7 @@ int regs; set_kd_state(do_modifier(kd_state, c, up)); } else if (!up) { /* regular key-down */ - int max; /* max index for char sequence */ + unsigned int max; /* max index for char sequence */ max = char_idx + NUMOUTPUT; char_idx++; @@ -909,7 +848,8 @@ int regs; * For pending commands, complete the command. For data bytes, * drop the ack on the floor. */ -kd_handle_ack() +void +kd_handle_ack(void) { switch (kd_ack) { case SET_LEDS: @@ -933,7 +873,8 @@ kd_handle_ack() * * Resend a missed keyboard command or data byte. */ -kd_resend() +void +kd_resend(void) { if (kd_ack == NOT_WAITING) printf("unexpected RESEND from keyboard\n"); @@ -953,10 +894,11 @@ kd_resend() * * output: the new state */ -do_modifier(state, c, up) -int state; -Scancode c; -boolean_t up; +int +do_modifier( + int state, + Scancode c, + boolean_t up) { switch (c) { case (K_ALTSC): @@ -1018,13 +960,10 @@ boolean_t up; * are still held down. */ boolean_t -kdcheckmagic(scancode, regs) -Scancode scancode; -int *regs; +kdcheckmagic(Scancode scancode) { static int magic_state = KS_NORMAL; /* like kd_state */ boolean_t up = FALSE; - extern int rebootflag; if (scancode == 0x46) /* scroll lock */ /* if (scancode == 0x52) ** insert key */ @@ -1075,8 +1014,9 @@ int *regs; * Return the value for the 2nd index into key_map that * corresponds to the given state. */ +unsigned int kdstate2idx(state, extended) -int state; /* bit vector, not a state index */ +unsigned int state; /* bit vector, not a state index */ boolean_t extended; { int state_idx = NORM_STATE; @@ -1114,8 +1054,8 @@ boolean_t extended; * Entered and left at spltty. Drops priority to spl0 to display character. * ASSUMES that it is never called from interrupt-driven code. */ -kdstart(tp) -struct tty *tp; +void +kdstart(struct tty *tp) { spl_t o_pri; int ch; @@ -1164,9 +1104,10 @@ struct tty *tp; } /*ARGSUSED*/ -kdstop(tp, flags) - register struct tty *tp; - int flags; +void +kdstop( + struct tty *tp, + int flags) { /* * do nothing - all characters are output by one call to @@ -1190,9 +1131,9 @@ kdstop(tp, flags) * output : Driver is initialized * */ -kdinit() +void +kdinit(void) { - void kd_xga_init(); unsigned char k_comm; /* keyboard command byte */ if (kd_initialized) @@ -1207,11 +1148,7 @@ kdinit() * board specific initialization: set up globals and kd_dxxx * pointers, and synch displayed cursor with logical cursor. */ - if (!evc1init()) - if (blit_present()) - blit_init(); - else - kd_xga_init(); + kd_xga_init(); /* get rid of any garbage in output buffer */ if (inb(K_STATUS) & K_OBUF_FUL) @@ -1229,21 +1166,24 @@ kdinit() /* Now that we're set up, we no longer need or want the immediate console. */ { - extern int immediate_console_enable; - immediate_console_enable = 0; + extern boolean_t immediate_console_enable; + immediate_console_enable = FALSE; } /* The immediate console printed stuff at the bottom of the screen rather than at the cursor position, so that's where we should start. */ kd_setpos(ONE_PAGE - ONE_LINE); printf("\n"); -#endif +#endif /* ENABLE_IMMEDIATE_CONSOLE */ cnsetleds(kd_state = KS_NORMAL); /* clear the LEDs AFTER we enable the keyboard controller. This keeps NUM-LOCK from being set on the NEC Versa. */ + + /* Allocate the input buffer. */ + ttychars(&kd_tty); } /* @@ -1256,14 +1196,16 @@ kdinit() * output : bell is turned off * */ -static unsigned int kd_bellstate = 0; -kd_belloff() +static boolean_t kd_bellstate = FALSE; + +void +kd_belloff(void * param) { unsigned char status; status = (inb(K_PORTB) & ~(K_SPKRDATA | K_ENABLETMR2)); outb(K_PORTB, status); - kd_bellstate = 0; + kd_bellstate = FALSE; return; } @@ -1277,7 +1219,8 @@ kd_belloff() * output : bell is turned on * */ -kd_bellon() +void +kd_bellon(void) { unsigned char status; @@ -1306,8 +1249,8 @@ kd_bellon() */ int sit_for_0 = 1; -kd_putc(ch) -u_char ch; +void +kd_putc(u_char ch) { if ((!ch) && sit_for_0) return; @@ -1334,7 +1277,7 @@ u_char ch; { kd_bellon(); timeout(kd_belloff, 0, hz/8 ); - kd_bellstate = 1; + kd_bellstate = TRUE; } break; default: @@ -1359,8 +1302,8 @@ u_char ch; * screen. * */ -kd_setpos(newpos) -csrpos_t newpos; +void +kd_setpos(csrpos_t newpos) { if (newpos > ONE_PAGE) { kd_scrollup(); @@ -1385,7 +1328,8 @@ csrpos_t newpos; * output : lines on screen appear to be shifted up one line * */ -kd_scrollup() +void +kd_scrollup(void) { csrpos_t to; csrpos_t from; @@ -1414,7 +1358,8 @@ kd_scrollup() * output : Lines on screen appear to be moved down one line * */ -kd_scrolldn() +void +kd_scrolldn(void) { csrpos_t to; csrpos_t from; @@ -1447,7 +1392,8 @@ kd_scrolldn() * defined by the ansi terminal specification * */ -kd_parseesc() +void +kd_parseesc(void) { u_char *escp; @@ -1518,24 +1464,24 @@ unsigned char color_table[] = { 0, 4, 2, * sequence acceptable to the ansi terminal specification * */ -kd_parserest(cp) -u_char *cp; +void +kd_parserest(u_char *cp) { int number[16], npar = 0, i; csrpos_t newpos; for(i=0;i<=15;i++) - number[i] = DEFAULT; + number[i] = MACH_ATOI_DEFAULT; do { - cp += kd_atoi(cp, &number[npar]); + cp += mach_atoi(cp, &number[npar]); } while (*cp == ';' && ++npar <= 15 && cp++); switch(*cp) { case 'm': for (i=0;i<=npar;i++) switch(number[i]) { - case DEFAULT: + case MACH_ATOI_DEFAULT: case 0: kd_attrflags = 0; kd_color = KA_NORMAL; @@ -1595,14 +1541,14 @@ u_char *cp; esc_spt = esc_seq; break; case '@': - if (number[0] == DEFAULT) + if (number[0] == MACH_ATOI_DEFAULT) kd_insch(1); else kd_insch(number[0]); esc_spt = esc_seq; break; case 'A': - if (number[0] == DEFAULT) + if (number[0] == MACH_ATOI_DEFAULT) kd_up(); else while (number[0]--) @@ -1610,7 +1556,7 @@ u_char *cp; esc_spt = esc_seq; break; case 'B': - if (number[0] == DEFAULT) + if (number[0] == MACH_ATOI_DEFAULT) kd_down(); else while (number[0]--) @@ -1618,7 +1564,7 @@ u_char *cp; esc_spt = esc_seq; break; case 'C': - if (number[0] == DEFAULT) + if (number[0] == MACH_ATOI_DEFAULT) kd_right(); else while (number[0]--) @@ -1626,7 +1572,7 @@ u_char *cp; esc_spt = esc_seq; break; case 'D': - if (number[0] == DEFAULT) + if (number[0] == MACH_ATOI_DEFAULT) kd_left(); else while (number[0]--) @@ -1635,7 +1581,7 @@ u_char *cp; break; case 'E': kd_cr(); - if (number[0] == DEFAULT) + if (number[0] == MACH_ATOI_DEFAULT) kd_down(); else while (number[0]--) @@ -1644,7 +1590,7 @@ u_char *cp; break; case 'F': kd_cr(); - if (number[0] == DEFAULT) + if (number[0] == MACH_ATOI_DEFAULT) kd_up(); else while (number[0]--) @@ -1652,7 +1598,7 @@ u_char *cp; esc_spt = esc_seq; break; case 'G': - if (number[0] == DEFAULT) + if (number[0] == MACH_ATOI_DEFAULT) number[0] = 0; else if (number[0] > 0) @@ -1662,18 +1608,18 @@ u_char *cp; break; case 'f': case 'H': - if (number[0] == DEFAULT && number[1] == DEFAULT) + if (number[0] == MACH_ATOI_DEFAULT && number[1] == MACH_ATOI_DEFAULT) { kd_home(); esc_spt = esc_seq; break; } - if (number[0] == DEFAULT) + if (number[0] == MACH_ATOI_DEFAULT) number[0] = 0; else if (number[0] > 0) --number[0]; /* numbered from 1 */ newpos = (number[0] * ONE_LINE); /* setup row */ - if (number[1] == DEFAULT) + if (number[1] == MACH_ATOI_DEFAULT) number[1] = 0; else if (number[1] > 0) number[1]--; @@ -1687,7 +1633,7 @@ u_char *cp; break; /* done or not ready */ case 'J': switch(number[0]) { - case DEFAULT: + case MACH_ATOI_DEFAULT: case 0: kd_cltobcur(); /* clears from current pos to bottom. @@ -1708,7 +1654,7 @@ u_char *cp; break; case 'K': switch(number[0]) { - case DEFAULT: + case MACH_ATOI_DEFAULT: case 0: kd_cltoecur(); /* clears from current pos to eoln. @@ -1729,28 +1675,28 @@ u_char *cp; esc_spt = esc_seq; break; case 'L': - if (number[0] == DEFAULT) + if (number[0] == MACH_ATOI_DEFAULT) kd_insln(1); else kd_insln(number[0]); esc_spt = esc_seq; break; case 'M': - if (number[0] == DEFAULT) + if (number[0] == MACH_ATOI_DEFAULT) kd_delln(1); else kd_delln(number[0]); esc_spt = esc_seq; break; case 'P': - if (number[0] == DEFAULT) + if (number[0] == MACH_ATOI_DEFAULT) kd_delch(1); else kd_delch(number[0]); esc_spt = esc_seq; break; case 'S': - if (number[0] == DEFAULT) + if (number[0] == MACH_ATOI_DEFAULT) kd_scrollup(); else while (number[0]--) @@ -1758,7 +1704,7 @@ u_char *cp; esc_spt = esc_seq; break; case 'T': - if (number[0] == DEFAULT) + if (number[0] == MACH_ATOI_DEFAULT) kd_scrolldn(); else while (number[0]--) @@ -1766,7 +1712,7 @@ u_char *cp; esc_spt = esc_seq; break; case 'X': - if (number[0] == DEFAULT) + if (number[0] == MACH_ATOI_DEFAULT) kd_erase(1); else kd_erase(number[0]); @@ -1782,38 +1728,8 @@ u_char *cp; return; } -/* - * kd_atoi: - * - * This function converts an ascii string into an integer, and - * returns DEFAULT if no integer was found. Note that this is why - * we don't use the regular atio(), because ZERO is ZERO and not - * the DEFAULT in all cases. - * - * input : string - * output : a number or possibly DEFAULT, and the count of characters - * consumed by the conversion - * - */ -int -kd_atoi(cp, nump) -u_char *cp; -int *nump; -{ - int number; - u_char *original; - - original = cp; - for (number = 0; ('0' <= *cp) && (*cp <= '9'); cp++) - number = (number * 10) + (*cp - '0'); - if (original == cp) - *nump = DEFAULT; - else - *nump = number; - return(cp - original); -} - -kd_tab() +void +kd_tab(void) { int i; @@ -1833,7 +1749,8 @@ kd_tab() * output : Screen is cleared * */ -kd_cls() +void +kd_cls(void) { (*kd_dclear)(0, ONE_PAGE/ONE_SPACE, kd_attr); return; @@ -1850,7 +1767,8 @@ kd_cls() * output : Cursor position is moved * */ -kd_home() +void +kd_home(void) { kd_setpos(0); return; @@ -1866,7 +1784,8 @@ kd_home() * output : Cursor moves up one line, or screen is scrolled * */ -kd_up() +void +kd_up(void) { if (kd_curpos < ONE_LINE) kd_scrolldn(); @@ -1885,7 +1804,8 @@ kd_up() * output : Cursor moves down one line or the screen is scrolled * */ -kd_down() +void +kd_down(void) { if (kd_curpos >= (ONE_PAGE - ONE_LINE)) kd_scrollup(); @@ -1904,7 +1824,8 @@ kd_down() * output : Cursor moves one position to the right * */ -kd_right() +void +kd_right(void) { if (kd_curpos < (ONE_PAGE - ONE_SPACE)) kd_setpos(kd_curpos + ONE_SPACE); @@ -1925,7 +1846,8 @@ kd_right() * output : Cursor moves one position to the left * */ -kd_left() +void +kd_left(void) { if (0 < kd_curpos) kd_setpos(kd_curpos - ONE_SPACE); @@ -1943,7 +1865,8 @@ kd_left() * output : Cursor moves to the beginning of the current line * */ -kd_cr() +void +kd_cr(void) { kd_setpos(BEG_OF_LINE(kd_curpos)); return; @@ -1957,10 +1880,11 @@ kd_cr() * of the screen. * * input : None - * output : Screen is cleared from current cursor postion to bottom + * output : Screen is cleared from current cursor position to bottom * */ -kd_cltobcur() +void +kd_cltobcur(void) { csrpos_t start; int count; @@ -1979,10 +1903,11 @@ kd_cltobcur() * of the screen. * * input : None - * output : Screen is cleared from current cursor postion to top + * output : Screen is cleared from current cursor position to top * */ -kd_cltopcur() +void +kd_cltopcur(void) { int count; @@ -2001,7 +1926,8 @@ kd_cltopcur() * output : Line is cleared from current cursor position to eoln * */ -kd_cltoecur() +void +kd_cltoecur(void) { csrpos_t i; csrpos_t hold; @@ -2023,7 +1949,8 @@ kd_cltoecur() * output : Line is cleared from beginning to current position * */ -kd_clfrbcur() +void +kd_clfrbcur(void) { csrpos_t i; @@ -2043,8 +1970,8 @@ kd_clfrbcur() * output : lines appear to be deleted * */ -kd_delln(number) -int number; +void +kd_delln(int number) { csrpos_t to; csrpos_t from; @@ -2081,8 +2008,8 @@ int number; * output : New lines appear to be inserted * */ -kd_insln(number) -int number; +void +kd_insln(int number) { csrpos_t to; csrpos_t from; @@ -2120,12 +2047,12 @@ int number; * output : characters appear to be deleted * */ -kd_delch(number) -int number; +void +kd_delch(int number) { - int count; /* num words moved/filled */ - int delbytes; /* bytes to delete */ - register csrpos_t to; + int count; /* num words moved/filled */ + int delbytes; /* bytes to delete */ + csrpos_t to; csrpos_t from; csrpos_t nextline; /* start of next line */ @@ -2161,8 +2088,8 @@ int number; * output : characters appear to be blanked or erased * */ -kd_erase(number) -int number; +void +kd_erase(int number) { csrpos_t i; csrpos_t stop; @@ -2186,7 +2113,8 @@ int number; * output : Current line is erased * */ -kd_eraseln() +void +kd_eraseln(void) { csrpos_t i; csrpos_t stop; @@ -2209,8 +2137,8 @@ kd_eraseln() * output : Blanks are inserted at cursor position * */ -kd_insch(number) -int number; +void +kd_insch(int number) { csrpos_t to; csrpos_t from; @@ -2250,16 +2178,16 @@ int number; * returns TRUE if character is lowercase * */ -kd_isupper(c) -u_char c; +boolean_t +kd_isupper(u_char c) { if (('A' <= c) && (c <= 'Z')) return(TRUE); return(FALSE); } -kd_islower(c) -u_char c; +boolean_t +kd_islower(u_char c) { if (('a' <= c) && (c <= 'z')) return(TRUE); @@ -2275,10 +2203,11 @@ u_char c; * keyboard command. * */ -kd_senddata(ch) -unsigned char ch; +void +kd_senddata(unsigned char ch) { - while (inb(K_STATUS) & K_IBUF_FUL); + while (inb(K_STATUS) & K_IBUF_FUL) + ; outb(K_RDWR, ch); last_sent = ch; return; @@ -2292,10 +2221,11 @@ unsigned char ch; * clear before sending the data. * */ -kd_sendcmd(ch) -unsigned char ch; +void +kd_sendcmd(unsigned char ch) { - while (inb(K_STATUS) & K_IBUF_FUL); + while (inb(K_STATUS) & K_IBUF_FUL) + ; outb(K_CMD, ch); return; } @@ -2309,38 +2239,47 @@ unsigned char ch; * read. */ unsigned char -kd_getdata() +kd_getdata(void) { - while ((inb(K_STATUS) & K_OBUF_FUL) == 0); + while ((inb(K_STATUS) & K_OBUF_FUL) == 0) + ; return(inb(K_RDWR)); } -kd_cmdreg_read() +unsigned char +kd_cmdreg_read(void) { int ch=KC_CMD_READ; - while (inb(K_STATUS) & K_IBUF_FUL); + while (inb(K_STATUS) & K_IBUF_FUL) + ; outb(K_CMD, ch); - while ((inb(K_STATUS) & K_OBUF_FUL) == 0); + while ((inb(K_STATUS) & K_OBUF_FUL) == 0) + ; return(inb(K_RDWR)); } -kd_cmdreg_write(val) +void +kd_cmdreg_write(int val) { int ch=KC_CMD_WRITE; - while (inb(K_STATUS) & K_IBUF_FUL); + while (inb(K_STATUS) & K_IBUF_FUL) + ; outb(K_CMD, ch); - while (inb(K_STATUS) & K_IBUF_FUL); + while (inb(K_STATUS) & K_IBUF_FUL) + ; outb(K_RDWR, val); } -kd_mouse_drain() +void +kd_mouse_drain(void) { int i; - while(inb(K_STATUS) & K_IBUF_FUL); + while(inb(K_STATUS) & K_IBUF_FUL) + ; while((i = inb(K_STATUS)) & K_OBUF_FUL) printf("kbd: S = %x D = %x\n", i, inb(K_RDWR)); } @@ -2350,9 +2289,8 @@ kd_mouse_drain() * * Set kd_state and update the keyboard status LEDs. */ - -set_kd_state(newstate) -int newstate; +void +set_kd_state(int newstate) { kd_state = newstate; kd_setleds1(state2leds(newstate)); @@ -2365,8 +2303,7 @@ int newstate; * a state vector. */ u_char -state2leds(state) -int state; +state2leds(int state) { u_char result = 0; @@ -2382,11 +2319,13 @@ int state; * * Set the keyboard LEDs according to the given byte. */ -kd_setleds1(val) -u_char val; +void +kd_setleds1(u_char val) { if (kd_ack != NOT_WAITING) { +#ifdef MACH_KBD printf("kd_setleds1: unexpected state (%d)\n", kd_ack); +#endif return; } @@ -2395,7 +2334,8 @@ u_char val; kd_senddata(K_CMD_LEDS); } -kd_setleds2() +void +kd_setleds2(void) { kd_senddata(kd_nextled); } @@ -2408,8 +2348,8 @@ kd_setleds2() * Currently disabled because cngetc ignores caps lock and num * lock anyway. */ -cnsetleds(val) -u_char val; +void +cnsetleds(u_char val) { kd_senddata(K_CMD_LEDS); (void)kd_getdata(); /* XXX - assume is ACK */ @@ -2417,7 +2357,8 @@ u_char val; (void)kd_getdata(); /* XXX - assume is ACK */ } -kdreboot() +void +kdreboot(void) { (*kd_dreset)(); @@ -2435,7 +2376,8 @@ kdreboot() static int which_button[] = {0, MOUSE_LEFT, MOUSE_MIDDLE, MOUSE_RIGHT}; static struct mouse_motion moved; -kd_kbd_magic(scancode) +int +kd_kbd_magic(int scancode) { int new_button = 0; @@ -2529,14 +2471,18 @@ int new_button = 0; * Initialization specific to character-based graphics adapters. */ void -kd_xga_init() +kd_xga_init(void) { csrpos_t xga_getpos(); unsigned char screen; + unsigned char start, stop; outb(CMOS_ADDR, CMOS_EB); screen = inb(CMOS_DATA) & CM_SCRMSK; switch(screen) { + default: + printf("kd: unknown screen type, defaulting to EGA\n"); + /* FALLTHROUGH */ case CM_EGA_VGA: /* * Here we'll want to query to bios on the card @@ -2562,6 +2508,8 @@ kd_xga_init() addr[i] = 0x00; } break; +#if 0 + /* XXX: some buggy BIOSes report these... */ case CM_CGA_40: vid_start = (u_char *)phystokv(CGA_START); kd_index_reg = CGA_IDX_REG; @@ -2583,8 +2531,25 @@ kd_xga_init() kd_lines = 25; kd_cols = 80; break; - default: - printf("kd: unknown screen type, defaulting to EGA\n"); +#endif + } + + outb(kd_index_reg, C_START); + start = inb(kd_io_reg); + /* Make sure cursor is enabled */ + start &= ~0x20; + outb(kd_io_reg, start); + outb(kd_index_reg, C_STOP); + stop = inb(kd_io_reg); + + if (!start && !stop) + { + /* Some firmware seem not to be initializing the cursor size + * any more... Try using standard values. */ + outb(kd_index_reg, C_START); + outb(kd_io_reg, 14); + outb(kd_index_reg, C_STOP); + outb(kd_io_reg, 15); } kd_setpos(xga_getpos()); @@ -2602,7 +2567,7 @@ kd_xga_init() * */ csrpos_t -xga_getpos() +xga_getpos(void) { unsigned char low; @@ -2705,38 +2670,24 @@ char chattr; * No-op reset routine for kd_dreset. */ static void -kd_noopreset() +kd_noopreset(void) { } - -/* - * Generic routines for bitmap devices (i.e., assume no hardware - * assist). Assumes a simple byte ordering (i.e., a byte at a lower - * address is to the left of the byte at the next higher address). - * For the 82786, this works anyway if the characters are 2 bytes - * wide. (more bubble gum and paper clips.) - * - * See the comments above about SLAMBPW. - */ - -void bmpch2bit(), bmppaintcsr(); -u_char *bit2fbptr(); - - /* * bmpput: Copy a character from the font to the frame buffer. */ void -bmpput(pos, ch, chattr) -csrpos_t pos; -char ch, chattr; +bmpput( + csrpos_t pos, + char ch, + char chattr) { short xbit, ybit; /* u/l corner of char pos */ - register u_char *to, *from; - register short i, j; + u_char *to, *from; + short i, j; u_char mask = (chattr == KA_REVERSE ? 0xff : 0); if ((u_char)ch >= chars_in_font) @@ -2758,13 +2709,14 @@ char ch, chattr; * another. */ void -bmpcp1char(from, to) -csrpos_t from, to; +bmpcp1char( + csrpos_t from, + csrpos_t to) { short from_xbit, from_ybit; short to_xbit, to_ybit; - register u_char *tp, *fp; - register short i, j; + u_char *tp, *fp; + short i, j; bmpch2bit(from, &from_xbit, &from_ybit); bmpch2bit(to, &to_xbit, &to_ybit); @@ -2784,9 +2736,10 @@ csrpos_t from, to; * bmpvmup: Copy a block of character positions upwards. */ void -bmpmvup(from, to, count) -csrpos_t from, to; -int count; +bmpmvup( + csrpos_t from, + csrpos_t to, + int count) { short from_xbit, from_ybit; short to_xbit, to_ybit; @@ -2819,9 +2772,10 @@ int count; * bmpmvdown: copy a block of characters down. */ void -bmpmvdown(from, to, count) -csrpos_t from, to; -int count; +bmpmvdown( + csrpos_t from, + csrpos_t to, + int count) { short from_xbit, from_ybit; short to_xbit, to_ybit; @@ -2857,12 +2811,12 @@ int count; * bmpclear: clear one or more character positions. */ void -bmpclear(to, count, chattr) -csrpos_t to; /* 1st char */ -int count; /* num chars */ -char chattr; /* reverse or normal */ +bmpclear( + csrpos_t to, /* 1st char */ + int count, /* num chars */ + char chattr) /* reverse or normal */ { - register short i; + short i; u_short clearval; u_short clearbyte = (chattr == KA_REVERSE ? char_white : char_black); @@ -2883,8 +2837,7 @@ char chattr; /* reverse or normal */ * bmpsetcursor: update the display and set the logical cursor. */ void -bmpsetcursor(pos) -csrpos_t pos; +bmpsetcursor(csrpos_t pos) { /* erase old cursor & paint new one */ bmppaintcsr(kd_curpos, char_black); @@ -2896,13 +2849,13 @@ csrpos_t pos; * bmppaintcsr: paint cursor bits. */ void -bmppaintcsr(pos, val) -csrpos_t pos; -u_char val; +bmppaintcsr( + csrpos_t pos, + u_char val) { short xbit, ybit; - register u_char *cp; - register short line, byte; + u_char *cp; + short line, byte; bmpch2bit(pos, &xbit, &ybit); ybit += char_height; /* position at bottom of line */ @@ -2919,11 +2872,12 @@ u_char val; * (0, 0) is the upper left corner. */ void -bmpch2bit(pos, xb, yb) -csrpos_t pos; -short *xb, *yb; /* x, y bit positions, u/l corner */ +bmpch2bit( + csrpos_t pos, + short *xb, + short *yb) /* x, y bit positions, u/l corner */ { - register short xch, ych; + short xch, ych; xch = (pos / ONE_SPACE) % kd_cols; ych = pos / (ONE_SPACE * kd_cols); @@ -2938,8 +2892,9 @@ short *xb, *yb; /* x, y bit positions, * byte. */ u_char * -bit2fbptr(xb, yb) -short xb, yb; +bit2fbptr( + short xb, + short yb) { return(vid_start + yb * fb_byte_width + xb/8); } @@ -2963,6 +2918,7 @@ kdcnprobe(struct consdev *cp) cp->cn_dev = makedev(maj, unit); cp->cn_pri = pri; + return 0; } int @@ -2988,15 +2944,15 @@ kdcngetc(dev_t dev, int wait) int kdcnputc(dev_t dev, int c) { - int i; - if (!kd_initialized) - return; + return -1; /* Note that tab is handled in kd_putc */ if (c == '\n') kd_putc('\r'); kd_putc(c); + + return 0; } /* @@ -3073,6 +3029,39 @@ kdcnmaygetc(void) #ifdef notdef cnsetleds(state2leds(kd_state)); #endif + } else if (! up + && c == K_ESC + && key_map[scancode][char_idx+1] == 0x5b) { + /* As a convenience for the nice + people using our debugger, remap + some keys to the readline-like + shortcuts supported by dde. + + XXX This is a workaround for the + limited kernel getchar interface. + It is only used by the debugger. */ + c = key_map[scancode][char_idx+2]; + switch (c) { +#define _MAP(A,B,C) (C) +#define MAP(T) _MAP(T) +#define CTRL(c) ((c) & 0x1f) + case MAP(K_HOME): c = CTRL('a'); break; + case MAP(K_UA): c = CTRL('p'); break; + case MAP(K_LA): c = CTRL('b'); break; + case MAP(K_RA): c = CTRL('f'); break; + case MAP(K_DA): c = CTRL('n'); break; + case MAP(K_END): c = CTRL('e'); break; + /* delete */ + case 0x39: c = CTRL('d'); break; +#undef CTRL +#undef MAP +#undef _MAP + default: + /* Retain the old behavior. */ + c = K_ESC; + } + + return(c); } else if (!up) { /* regular key-down */ if (c == K_CR)