1 /* 2 * Copyright (c) 1988 University of Utah. 3 * Copyright (c) 1990, 1993 4 * The Regents of the University of California. All rights reserved. 5 * 6 * This code is derived from software contributed to Berkeley by 7 * the Systems Programming Group of the University of Utah Computer 8 * Science Department. 9 * 10 * %sccs.include.redist.c% 11 * 12 * from: Utah $Hdr: hil.c 1.1 89/08/22$ 13 * 14 * @(#)hil.c 8.1 (Berkeley) 06/10/93 15 */ 16 17 /* 18 * Keyboard routines for the standalone ITE. 19 */ 20 #include <hp300/stand/samachdep.h> 21 22 #ifdef ITECONSOLE 23 24 #include <sys/param.h> 25 #include <hp/dev/hilreg.h> 26 #include <hp/dev/kbdmap.h> 27 #include <hp/dev/itevar.h> 28 29 #ifndef SMALL 30 31 /* 32 * HIL cooked keyboard keymaps. 33 * Supports only unshifted, shifted and control keys. 34 */ 35 char us_keymap[] = { 36 NULL, '`', '\\', ESC, NULL, DEL, NULL, NULL, 37 '\n', '\t', NULL, NULL, NULL, NULL, NULL, NULL, 38 NULL, '\n', NULL, NULL, NULL, NULL, NULL, NULL, 39 NULL, '\t', NULL, NULL, NULL, NULL, NULL, NULL, 40 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 41 NULL, NULL, NULL, NULL, NULL, NULL, '\b', NULL, 42 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 43 ESC, '\r', NULL, '\n', '0', '.', ',', '+', 44 '1', '2', '3', '-', '4', '5', '6', '*', 45 '7', '8', '9', '/', 'E', '(', ')', '^', 46 '1', '2', '3', '4', '5', '6', '7', '8', 47 '9', '0', '-', '=', '[', ']', ';', '\'', 48 ',', '.', '/', '\040', 'o', 'p', 'k', 'l', 49 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 50 'a', 's', 'd', 'f', 'g', 'h', 'j', 'm', 51 'z', 'x', 'c', 'v', 'b', 'n', NULL, NULL 52 }; 53 54 char us_shiftmap[] = { 55 NULL, '~', '|', DEL, NULL, DEL, NULL, NULL, 56 '\n', '\t', NULL, NULL, NULL, NULL, NULL, NULL, 57 NULL, '\n', NULL, NULL, NULL, NULL, NULL, NULL, 58 NULL, '\t', NULL, NULL, NULL, NULL, NULL, NULL, 59 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 60 NULL, NULL, NULL, NULL, NULL, NULL, DEL, NULL, 61 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 62 ESC, '\r', NULL, '\n', '0', '.', ',', '+', 63 '1', '2', '3', '-', '4', '5', '6', '*', 64 '7', '8', '9', '/', '`', '|', '\\', '~', 65 '!', '@', '#', '$', '%', '^', '&', '*', 66 '(', ')', '_', '+', '{', '}', ':', '\"', 67 '<', '>', '?', '\040', 'O', 'P', 'K', 'L', 68 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 69 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'M', 70 'Z', 'X', 'C', 'V', 'B', 'N', NULL, NULL 71 }; 72 73 char us_ctrlmap[] = { 74 NULL, '`', '\034', ESC, NULL, DEL, NULL, NULL, 75 '\n', '\t', NULL, NULL, NULL, NULL, NULL, NULL, 76 NULL, '\n', NULL, NULL, NULL, NULL, NULL, NULL, 77 NULL, '\t', NULL, NULL, NULL, NULL, NULL, NULL, 78 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 79 NULL, NULL, NULL, NULL, NULL, NULL, '\b', NULL, 80 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 81 ESC, '\r', NULL, '\n', '0', '.', ',', '+', 82 '1', '2', '3', '-', '4', '5', '6', '*', 83 '7', '8', '9', '/', 'E', '(', ')', '\036', 84 '1', '2', '3', '4', '5', '6', '7', '8', 85 '9', '0', '-', '=', '\033', '\035', ';', '\'', 86 ',', '.', '/', '\040', '\017', '\020', '\013', '\014', 87 '\021', '\027', '\005', '\022', '\024', '\031', '\025', '\011', 88 '\001', '\023', '\004', '\006', '\007', '\010', '\012', '\015', 89 '\032', '\030', '\003', '\026', '\002', '\016', NULL, NULL 90 }; 91 92 #ifdef UK_KEYBOARD 93 char uk_keymap[] = { 94 NULL, '`', '<', ESC, NULL, DEL, NULL, NULL, 95 '\n', '\t', NULL, NULL, NULL, NULL, NULL, NULL, 96 NULL, '\n', NULL, NULL, NULL, NULL, NULL, NULL, 97 NULL, '\t', NULL, NULL, NULL, NULL, NULL, NULL, 98 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 99 NULL, NULL, NULL, NULL, NULL, NULL, '\b', NULL, 100 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 101 ESC, '\r', NULL, '\n', '0', '.', ',', '+', 102 '1', '2', '3', '-', '4', '5', '6', '*', 103 '7', '8', '9', '/', 'E', '(', ')', '^', 104 '1', '2', '3', '4', '5', '6', '7', '8', 105 '9', '0', '+', '\'', '[', ']', '*', '\\', 106 ',', '.', '-', '\040', 'o', 'p', 'k', 'l', 107 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 108 'a', 's', 'd', 'f', 'g', 'h', 'j', 'm', 109 'z', 'x', 'c', 'v', 'b', 'n', NULL, NULL 110 }; 111 112 char uk_shiftmap[] = { 113 NULL, '~', '>', DEL, NULL, DEL, NULL, NULL, 114 '\n', '\t', NULL, NULL, NULL, NULL, NULL, NULL, 115 NULL, '\n', NULL, NULL, NULL, NULL, NULL, NULL, 116 NULL, '\t', NULL, NULL, NULL, NULL, NULL, NULL, 117 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 118 NULL, NULL, NULL, NULL, NULL, NULL, DEL, NULL, 119 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 120 ESC, '\r', NULL, '\n', '0', '.', ',', '+', 121 '1', '2', '3', '-', '4', '5', '6', '*', 122 '7', '8', '9', '/', '`', '|', '\\', '~', 123 '!', '\"', '#', '$', '%', '&', '^', '(', 124 ')', '=', '?', '/', '{', '}', '@', '|', 125 ';', ':', '_', '\040', 'O', 'P', 'K', 'L', 126 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 127 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'M', 128 'Z', 'X', 'C', 'V', 'B', 'N', NULL, NULL 129 }; 130 131 char uk_ctrlmap[] = { 132 NULL, '`', '<', ESC, NULL, DEL, NULL, NULL, 133 '\n', '\t', NULL, NULL, NULL, NULL, NULL, NULL, 134 NULL, '\n', NULL, NULL, NULL, NULL, NULL, NULL, 135 NULL, '\t', NULL, NULL, NULL, NULL, NULL, NULL, 136 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 137 NULL, NULL, NULL, NULL, NULL, NULL, '\b', NULL, 138 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, 139 ESC, '\r', NULL, '\n', '0', '.', ',', '+', 140 '1', '2', '3', '-', '4', '5', '6', '*', 141 '7', '8', '9', '/', 'E', '(', ')', '\036', 142 '1', '2', '3', '4', '5', '6', '7', '8', 143 '9', '0', '+', '\'', '\033', '\035', '*', '\034', 144 ',', '.', '/', '\040', '\017', '\020', '\013', '\014', 145 '\021', '\027', '\005', '\022', '\024', '\031', '\025', '\011', 146 '\001', '\023', '\004', '\006', '\007', '\010', '\012', '\015', 147 '\032', '\030', '\003', '\026', '\002', '\016', NULL, NULL 148 }; 149 #endif 150 151 /* 152 * The keyboard map table. 153 * Lookup is by hardware returned language code. 154 */ 155 struct kbdmap kbd_map[] = { 156 KBD_US, NULL, 157 us_keymap, us_shiftmap, us_ctrlmap, NULL, NULL, 158 159 #ifdef UK_KEYBOARD 160 KBD_UK, NULL, 161 uk_keymap, uk_shiftmap, uk_ctrlmap, NULL, NULL, 162 #endif 163 164 0, NULL, 165 NULL, NULL, NULL, NULL, NULL, 166 }; 167 168 char *kbd_keymap = us_keymap; 169 char *kbd_shiftmap = us_shiftmap; 170 char *kbd_ctrlmap = us_ctrlmap; 171 172 kbdgetc() 173 { 174 register int status, c; 175 register struct hil_dev *hiladdr = HILADDR; 176 177 status = hiladdr->hil_stat; 178 if ((status & HIL_DATA_RDY) == 0) 179 return(0); 180 c = hiladdr->hil_data; 181 switch ((status>>KBD_SSHIFT) & KBD_SMASK) { 182 case KBD_SHIFT: 183 c = kbd_shiftmap[c & KBD_CHARMASK]; 184 break; 185 case KBD_CTRL: 186 c = kbd_ctrlmap[c & KBD_CHARMASK]; 187 break; 188 case KBD_KEY: 189 c = kbd_keymap[c & KBD_CHARMASK]; 190 break; 191 default: 192 c = 0; 193 break; 194 } 195 return(c); 196 } 197 #endif 198 199 kbdnmi() 200 { 201 register struct hil_dev *hiladdr = HILADDR; 202 203 HILWAIT(hiladdr); 204 hiladdr->hil_cmd = HIL_CNMT; 205 HILWAIT(hiladdr); 206 hiladdr->hil_cmd = HIL_CNMT; 207 HILWAIT(hiladdr); 208 printf("\nboot interrupted\n"); 209 } 210 211 kbdinit() 212 { 213 register struct hil_dev *hiladdr = HILADDR; 214 register struct kbdmap *km; 215 u_char lang; 216 217 HILWAIT(hiladdr); 218 hiladdr->hil_cmd = HIL_SETARR; 219 HILWAIT(hiladdr); 220 hiladdr->hil_data = ar_format(KBD_ARR); 221 HILWAIT(hiladdr); 222 hiladdr->hil_cmd = HIL_READKBDLANG; 223 HILDATAWAIT(hiladdr); 224 lang = hiladdr->hil_data; 225 for (km = kbd_map; km->kbd_code; km++) 226 if (km->kbd_code == lang) { 227 kbd_keymap = km->kbd_keymap; 228 kbd_shiftmap = km->kbd_shiftmap; 229 kbd_ctrlmap = km->kbd_ctrlmap; 230 } 231 HILWAIT(hiladdr); 232 hiladdr->hil_cmd = HIL_INTON; 233 } 234 #endif 235