Print this page
NEX-16819 loader UEFI support
Includes work by Toomas Soome <tsoome@me.com>
Upstream commits:
    loader: pxe receive cleanup
    9475 libefi: Do not return only if ReceiveFilter
    installboot: should support efi system partition
    8931 boot1.efi: scan all display modes rather than
    loader: spinconsole updates
    loader: gfx experiment to try GOP Blt() function.
    sha1 build test
    loader: add sha1 hash calculation
    common/sha1: update for loader build
    loader: biosdisk rework
    uts: 32-bit kernel FB needs mapping in low memory
    uts: add diag-device
    uts: boot console mirror with diag-device
    uts: enable very early console on ttya
    kmdb: add diag-device as input/output device
    uts: test VGA memory exclusion from mapping
    uts: clear boot mapping and protect boot pages test
    uts: add dboot map debug printf
    uts: need to release FB pages in release_bootstrap()
    uts: add screenmap ioctl
    uts: update sys/queue.h
    loader: add illumos uts/common to include path
    loader: tem/gfx font cleanup
    loader: vbe checks
    uts: gfx_private set KD_TEXT when KD_RESETTEXT is
    uts: gfx 8-bit update
    loader: gfx 8-bit fix
    loader: always set media size from partition.
    uts: MB2 support for 32-bit kernel
    loader: x86 should have tem 80x25
    uts: x86 should have tem 80x25
    uts: font update
    loader: font update
    uts: tem attributes
    loader: tem.c comment added
    uts: use font module
    loader: add font module
    loader: build rules for new font setup
    uts: gfx_private update for new font structure
    uts: early boot update for new font structure
    uts: font update
    uts: font build rules update for new fonts
    uts: tem update to new font structure
    loader: module.c needs to include tem_impl.h
    uts: gfx_private 8x16 font rework
    uts: make font_lookup public
    loader: font rework
    uts: font rework
    9259 libefi: efi_alloc_and_read should check for PMBR
    uts: tem utf-8 support
    loader: implement tem utf-8 support
    loader: tem should be able to display UTF-8
    7784 uts: console input should support utf-8
    7796 uts: ldterm default to utf-8
    uts: do not reset serial console
    uts: set up colors even if tem is not console
    uts: add type for early boot properties
    uts: gfx_private experiment with drm and vga
    uts: gfx_private should use setmode drm callback.
    uts: identify FB types and set up gfx_private based
    loader: replace gop and vesa with framebuffer
    uts: boot needs simple tem to support mdb
    uts: boot_keyboard should emit esc sequences for
    uts: gfx_private FB showuld be written by line
    kmdb: set terminal window size
    uts: gfx_private needs to keep track of early boot FB
    pnglite: move pnglite to usr/src/common
    loader: gfx_fb
    ficl-sys: add gfx primitives
    loader: add illumos.png logo
    ficl: add fb-putimage
    loader: add png support
    loader: add alpha blending for gfx_fb
    loader: use term-drawrect for menu frame
    ficl: add simple gfx words
    uts: provide fb_info via fbgattr dev_specific array.
    uts: gfx_private add alpha blending
    uts: update sys/ascii.h
    uts: tem OSC support (incomplete)
    uts: implement env module support and use data from
    uts: tem get colors from early boot data
    loader: use crc32 from libstand (libz)
    loader: optimize for size
    loader: pass tem info to the environment
    loader: import tem for loader console
    loader: UEFI loader needs to set ISADIR based on
    loader: need UEFI32 support
    8918 loader.efi: add vesa edid support
    uts: tem_safe_pix_clear_prom_output() should only
    uts: tem_safe_pix_clear_entire_screen() should use
    uts: tem_safe_check_first_time() should query cursor
    uts: tem implement cls callback & visual_io v4
    uts: gfx_vgatext use block cursor for vgatext
    uts: gfx_private implement cls callback & visual_io
    uts: gfx_private bitmap framebuffer implementation
    uts: early start frame buffer console support
    uts: font functions should check the input char
    uts: font rendering should support 16/24/32bit depths
    uts: use smallest font as fallback default.
    uts: update terminal dimensions based on selected
    7834 uts: vgatext should use gfx_private
    uts: add spacing property to 8859-1.bdf
    terminfo: add underline for sun-color
    terminfo: sun-color has 16 colors
    uts: add font load callback type
    loader: do not repeat int13 calls with error 0x20 and
    8905 loader: add skein/edonr support
    8904 common/crypto: make skein and edonr loader
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>
Revert "NEX-16819 loader UEFI support"
This reverts commit ec06b9fc617b99234e538bf2e7e4d02a24993e0c.
Reverting due to failures in the zfs-tests and the sharefs-tests
NEX-16819 loader UEFI support
Includes work by Toomas Soome <tsoome@me.com>
Upstream commits:
    loader: pxe receive cleanup
    9475 libefi: Do not return only if ReceiveFilter
    installboot: should support efi system partition
    8931 boot1.efi: scan all display modes rather than
    loader: spinconsole updates
    loader: gfx experiment to try GOP Blt() function.
    sha1 build test
    loader: add sha1 hash calculation
    common/sha1: update for loader build
    loader: biosdisk rework
    uts: 32-bit kernel FB needs mapping in low memory
    uts: add diag-device
    uts: boot console mirror with diag-device
    uts: enable very early console on ttya
    kmdb: add diag-device as input/output device
    uts: test VGA memory exclusion from mapping
    uts: clear boot mapping and protect boot pages test
    uts: add dboot map debug printf
    uts: need to release FB pages in release_bootstrap()
    uts: add screenmap ioctl
    uts: update sys/queue.h
    loader: add illumos uts/common to include path
    loader: tem/gfx font cleanup
    loader: vbe checks
    uts: gfx_private set KD_TEXT when KD_RESETTEXT is
    uts: gfx 8-bit update
    loader: gfx 8-bit fix
    loader: always set media size from partition.
    uts: MB2 support for 32-bit kernel
    loader: x86 should have tem 80x25
    uts: x86 should have tem 80x25
    uts: font update
    loader: font update
    uts: tem attributes
    loader: tem.c comment added
    uts: use font module
    loader: add font module
    loader: build rules for new font setup
    uts: gfx_private update for new font structure
    uts: early boot update for new font structure
    uts: font update
    uts: font build rules update for new fonts
    uts: tem update to new font structure
    loader: module.c needs to include tem_impl.h
    uts: gfx_private 8x16 font rework
    uts: make font_lookup public
    loader: font rework
    uts: font rework
    libefi: efi_alloc_and_read should check for PMBR
    uts: tem utf-8 support
    loader: implement tem utf-8 support
    loader: tem should be able to display UTF-8
    7784 uts: console input should support utf-8
    7796 uts: ldterm default to utf-8
    uts: do not reset serial console
    uts: set up colors even if tem is not console
    uts: add type for early boot properties
    uts: gfx_private experiment with drm and vga
    uts: gfx_private should use setmode drm callback.
    uts: identify FB types and set up gfx_private based
    loader: replace gop and vesa with framebuffer
    uts: boot needs simple tem to support mdb
    uts: boot_keyboard should emit esc sequences for
    uts: gfx_private FB showuld be written by line
    kmdb: set terminal window size
    uts: gfx_private needs to keep track of early boot FB
    pnglite: move pnglite to usr/src/common
    loader: gfx_fb
    ficl-sys: add gfx primitives
    loader: add illumos.png logo
    ficl: add fb-putimage
    loader: add png support
    loader: add alpha blending for gfx_fb
    loader: use term-drawrect for menu frame
    ficl: add simple gfx words
    uts: provide fb_info via fbgattr dev_specific array.
    uts: gfx_private add alpha blending
    uts: update sys/ascii.h
    uts: tem OSC support (incomplete)
    uts: implement env module support and use data from
    uts: tem get colors from early boot data
    loader: use crc32 from libstand (libz)
    loader: optimize for size
    loader: pass tem info to the environment
    loader: import tem for loader console
    loader: UEFI loader needs to set ISADIR based on
    loader: need UEFI32 support
    8918 loader.efi: add vesa edid support
    uts: tem_safe_pix_clear_prom_output() should only
    uts: tem_safe_pix_clear_entire_screen() should use
    uts: tem_safe_check_first_time() should query cursor
    uts: tem implement cls callback & visual_io v4
    uts: gfx_vgatext use block cursor for vgatext
    uts: gfx_private implement cls callback & visual_io
    uts: gfx_private bitmap framebuffer implementation
    uts: early start frame buffer console support
    uts: font functions should check the input char
    uts: font rendering should support 16/24/32bit depths
    uts: use smallest font as fallback default.
    uts: update terminal dimensions based on selected
    7834 uts: vgatext should use gfx_private
    uts: add spacing property to 8859-1.bdf
    terminfo: add underline for sun-color
    terminfo: sun-color has 16 colors
    uts: add font load callback type
    loader: do not repeat int13 calls with error 0x20 and
    8905 loader: add skein/edonr support
    8904 common/crypto: make skein and edonr loader
Reviewed by: Yuri Pankov <yuri.pankov@nexenta.com>
Reviewed by: Sanjay Nadkarni <sanjay.nadkarni@nexenta.com>
Reviewed by: Evan Layton <evan.layton@nexenta.com>


1261 
1262 /*
1263  * kbtrans_keypressed:
1264  *      Modify Firm event to be sent up the stream
1265  */
1266 static void
1267 kbtrans_keypressed(struct kbtrans *upper, uchar_t key_station,
1268                     Firm_event *fe, ushort_t base)
1269 {
1270 
1271         register short  id_addr;
1272         struct kbtrans_lower    *lower = &upper->kbtrans_lower;
1273 
1274         /* Set pair values */
1275         if (fe->id < (ushort_t)VKEY_FIRST) {
1276                 /*
1277                  * If CTRLed, find the ID that would have been used had it
1278                  * not been CTRLed.
1279                  */
1280                 if (lower->kbtrans_shiftmask & (CTRLMASK | CTLSMASK)) {
1281                         unsigned short *ke;
1282                         unsigned int mask;
1283 
1284                         mask = lower->kbtrans_shiftmask &
1285                             ~(CTRLMASK | CTLSMASK | UPMASK);
1286 
1287                         ke = kbtrans_find_entry(lower, mask, key_station);
1288                         if (ke == NULL)
1289                                 return;
1290 
1291                         base = *ke;
1292                 }
1293                 if (base != fe->id) {
1294                         fe->pair_type = FE_PAIR_SET;
1295                         fe->pair = (uchar_t)base;
1296 
1297                         goto send;
1298                 }
1299         }
1300         fe->pair_type = FE_PAIR_NONE;
1301         fe->pair = 0;


1422          * If we can't send it up, then we just drop it.
1423          */
1424         if (!canputnext(upper->kbtrans_streams_readq)) {
1425 
1426                 return;
1427         }
1428 
1429         /*
1430          * Allocate a messsage block to send up.
1431          */
1432         if ((bp = allocb(sizeof (uint_t), BPRI_HI)) == NULL) {
1433 
1434                 cmn_err(CE_WARN, "kbtrans_putcode: Can't allocate block\
1435                         for keycode.");
1436 
1437                 return;
1438         }
1439 
1440         /*
1441          * We will strip out any high order information here.

1442          */
1443         /* NOTE the implicit cast here */
1444         *bp->b_wptr++ = (uchar_t)code;














1445 
1446         /*
1447          * Send the message up.
1448          */
1449         (void) putnext(upper->kbtrans_streams_readq, bp);
1450 }
1451 
1452 
1453 /*
1454  * kbtrans_putbuf:
1455  *      Pass generated keycode sequence to upstream, if possible.
1456  */
1457 static void
1458 kbtrans_putbuf(char *buf, queue_t *q)
1459 {
1460         register mblk_t *bp;
1461 
1462         if (!canputnext(q)) {
1463                 cmn_err(CE_WARN, "kbtrans_putbuf: Can't put block for keycode");
1464         } else {


1771                 }
1772 
1773                 return;
1774 
1775         case PADKEYS:
1776                 /*
1777                  * These are the keys on the keypad.  Look up the
1778                  * answer in the kb_numlock_table and send it upstream.
1779                  */
1780                 kbtrans_putcode(upper,
1781                     lower->kbtrans_numlock_table[entry&0x1F]);
1782 
1783                 return;
1784 
1785         case 0: /* normal character */
1786         default:
1787                 break;
1788         }
1789 
1790         /*
1791          * Send the byte upstream.
1792          */
1793         kbtrans_putcode(upper, entry);
1794 
1795 }
1796 
1797 #define KB_SCANCODE_ALT         0xe2
1798 #define KB_SCANCODE_ALTGRAPH    0xe6
1799 
1800 /*
1801  * kbtrans_ascii_keyreleased:
1802  *      This is the function if we are in TR_ASCII mode and a key
1803  *      is released.  ASCII doesn't have the concept of released keys,
1804  *      or make/break codes.  So there is nothing for us to do except
1805  *      checking 'Alt/AltGraph' release key in order to reset the state
1806  *      of vt switch key sequence.
1807  */
1808 /* ARGSUSED */
1809 static void
1810 kbtrans_ascii_keyreleased(struct kbtrans *upper, kbtrans_key_t key)
1811 {


2072 #define OLD_SHIFTKEYS   0x80
2073 #define OLD_BUCKYBITS   0x90
2074 #define OLD_FUNNY       0xA0
2075 #define OLD_FA_UMLAUT   0xA9
2076 #define OLD_FA_CFLEX    0xAA
2077 #define OLD_FA_TILDE    0xAB
2078 #define OLD_FA_CEDILLA  0xAC
2079 #define OLD_FA_ACUTE    0xAD
2080 #define OLD_FA_GRAVE    0xAE
2081 #define OLD_ISOCHAR     0xAF
2082 #define OLD_STRING      0xB0
2083 #define OLD_LEFTFUNC    0xC0
2084 #define OLD_RIGHTFUNC   0xD0
2085 #define OLD_TOPFUNC     0xE0
2086 #define OLD_BOTTOMFUNC  0xF0
2087 
2088 /*
2089  * Map old special codes to new ones.
2090  * Indexed by ((old special code) >> 4) & 0x07; add (old special code) & 0x0F.
2091  */
2092 static ushort_t  special_old_to_new[] = {
2093         SHIFTKEYS,
2094         BUCKYBITS,
2095         FUNNY,
2096         STRING,
2097         LEFTFUNC,
2098         RIGHTFUNC,
2099         TOPFUNC,
2100         BOTTOMFUNC,
2101 };
2102 
2103 
2104 /*
2105  * kbtrans_setkey:
2106  *       Set individual keystation translation from old-style entry.
2107  */
2108 static int
2109 kbtrans_setkey(struct kbtrans_lower *lower, struct kiockey *key, cred_t *cr)
2110 {
2111         int     strtabindex, i;
2112         unsigned short  *ke;
2113         register int tablemask;
2114         register ushort_t entry;
2115         register struct keyboard *kp;
2116 
2117         kp = lower->kbtrans_keyboard;
2118 
2119         if (key->kio_station >= kp->k_keymap_size)
2120 
2121                 return (EINVAL);
2122 
2123         if (lower->kbtrans_keyboard == NULL)
2124 
2125                 return (EINVAL);
2126 
2127         tablemask = key->kio_tablemask;
2128 
2129         switch (tablemask) {
2130         case KIOCABORT1:
2131         case KIOCABORT1A:
2132         case KIOCABORT2:
2133                 i = secpolicy_console(cr);
2134                 if (i != 0)
2135                         return (i);
2136 
2137                 switch (tablemask) {
2138                 case KIOCABORT1:
2139                         kp->k_abort1 = key->kio_station;
2140                         break;


2191  */
2192 static uchar_t   special_new_to_old[] = {
2193         0,                      /* normal */
2194         OLD_SHIFTKEYS,          /* SHIFTKEYS */
2195         OLD_BUCKYBITS,          /* BUCKYBITS */
2196         OLD_FUNNY,              /* FUNNY */
2197         OLD_FA_UMLAUT,          /* FA_CLASS */
2198         OLD_STRING,             /* STRING */
2199         OLD_LEFTFUNC,           /* FUNCKEYS */
2200 };
2201 
2202 
2203 /*
2204  * kbtrans_getkey:
2205  *      Get individual keystation translation as old-style entry.
2206  */
2207 static int
2208 kbtrans_getkey(struct kbtrans_lower *lower, struct kiockey *key)
2209 {
2210         int     strtabindex;
2211         unsigned short  *ke;
2212         register ushort_t entry;
2213         struct keyboard *kp;
2214 
2215         kp = lower->kbtrans_keyboard;
2216 
2217         if (key->kio_station >= kp->k_keymap_size)
2218                 return (EINVAL);
2219 
2220         if (lower->kbtrans_keyboard == NULL)
2221                 return (EINVAL);
2222 
2223         switch (key->kio_tablemask) {
2224         case KIOCABORT1:
2225                 key->kio_station = kp->k_abort1;
2226                 return (0);
2227         case KIOCABORT1A:
2228                 key->kio_station = kp->k_abort1a;
2229                 return (0);
2230         case KIOCABORT2:
2231                 key->kio_station = kp->k_abort2;
2232                 return (0);


2250                         key->kio_entry = (ushort_t)entry;
2251         }
2252 
2253         if (entry >= STRING && entry <= (uchar_t)(STRING + 15)) {
2254                 strtabindex = entry - STRING;
2255                 bcopy(lower->kbtrans_keystringtab[strtabindex],
2256                     key->kio_string, KTAB_STRLEN);
2257         }
2258         return (0);
2259 }
2260 
2261 
2262 /*
2263  * kbtrans_skey:
2264  *      Set individual keystation translation from new-style entry.
2265  */
2266 static int
2267 kbtrans_skey(struct kbtrans_lower *lower, struct kiockeymap *key, cred_t *cr)
2268 {
2269         int     strtabindex, i;
2270         unsigned short *ke;
2271         struct keyboard *kp;
2272 
2273         kp = lower->kbtrans_keyboard;
2274 
2275         if (key->kio_station >= kp->k_keymap_size) {
2276                 return (EINVAL);
2277 
2278         }
2279 
2280         if (lower->kbtrans_keyboard == NULL) {
2281                 return (EINVAL);
2282         }
2283 
2284         switch (key->kio_tablemask) {
2285         case KIOCABORT1:
2286         case KIOCABORT1A:
2287         case KIOCABORT2:
2288                 i = secpolicy_console(cr);
2289                 if (i != 0)
2290                         return (i);
2291                 switch (key->kio_tablemask) {
2292                 case KIOCABORT1:
2293                         kp->k_abort1 = key->kio_station;
2294                         break;
2295                 case KIOCABORT1A:
2296                         kp->k_abort1a = key->kio_station;
2297                         break;
2298                 case KIOCABORT2:
2299                         kp->k_abort2 = key->kio_station;
2300                         break;
2301                 }
2302                 return (0);
2303         }
2304 
2305         ke = kbtrans_find_entry(lower, (uint_t)key->kio_tablemask,
2306             key->kio_station);
2307         if (ke == NULL)
2308                 return (EINVAL);
2309 
2310         if (key->kio_entry >= STRING &&
2311             key->kio_entry <= (ushort_t)(STRING + 15)) {
2312                 strtabindex = key->kio_entry-STRING;
2313                 bcopy(key->kio_string,
2314                     lower->kbtrans_keystringtab[strtabindex], KTAB_STRLEN);
2315                 lower->kbtrans_keystringtab[strtabindex][KTAB_STRLEN-1] = '\0';
2316         }
2317 
2318         *ke = key->kio_entry;
2319 
2320         return (0);
2321 }
2322 
2323 
2324 /*
2325  * kbtrans_gkey:
2326  *      Get individual keystation translation as new-style entry.
2327  */
2328 static int
2329 kbtrans_gkey(struct kbtrans_lower *lower, struct        kiockeymap *key)
2330 {
2331         int     strtabindex;
2332         unsigned short *ke;
2333         struct keyboard *kp;
2334 
2335         kp = lower->kbtrans_keyboard;
2336 
2337         if (key->kio_station >= kp->k_keymap_size)
2338                 return (EINVAL);
2339 
2340         if (lower->kbtrans_keyboard == NULL)
2341                 return (EINVAL);
2342 
2343         switch (key->kio_tablemask) {
2344         case KIOCABORT1:
2345                 key->kio_station = kp->k_abort1;
2346                 return (0);
2347         case KIOCABORT1A:
2348                 key->kio_station = kp->k_abort1a;
2349                 return (0);
2350         case KIOCABORT2:
2351                 key->kio_station = kp->k_abort2;
2352                 return (0);
2353         }
2354 
2355         ke = kbtrans_find_entry(lower, (uint_t)key->kio_tablemask,
2356             key->kio_station);
2357         if (ke == NULL)
2358                 return (EINVAL);
2359 
2360         key->kio_entry = *ke;
2361 
2362         if (key->kio_entry >= STRING &&
2363             key->kio_entry <= (ushort_t)(STRING + 15)) {
2364                 strtabindex = key->kio_entry-STRING;
2365                 bcopy(lower->kbtrans_keystringtab[strtabindex],
2366                     key->kio_string, KTAB_STRLEN);
2367         }
2368         return (0);
2369 }


1261 
1262 /*
1263  * kbtrans_keypressed:
1264  *      Modify Firm event to be sent up the stream
1265  */
1266 static void
1267 kbtrans_keypressed(struct kbtrans *upper, uchar_t key_station,
1268     Firm_event *fe, ushort_t base)
1269 {
1270 
1271         register short  id_addr;
1272         struct kbtrans_lower    *lower = &upper->kbtrans_lower;
1273 
1274         /* Set pair values */
1275         if (fe->id < (ushort_t)VKEY_FIRST) {
1276                 /*
1277                  * If CTRLed, find the ID that would have been used had it
1278                  * not been CTRLed.
1279                  */
1280                 if (lower->kbtrans_shiftmask & (CTRLMASK | CTLSMASK)) {
1281                         keymap_entry_t *ke;
1282                         unsigned int mask;
1283 
1284                         mask = lower->kbtrans_shiftmask &
1285                             ~(CTRLMASK | CTLSMASK | UPMASK);
1286 
1287                         ke = kbtrans_find_entry(lower, mask, key_station);
1288                         if (ke == NULL)
1289                                 return;
1290 
1291                         base = *ke;
1292                 }
1293                 if (base != fe->id) {
1294                         fe->pair_type = FE_PAIR_SET;
1295                         fe->pair = (uchar_t)base;
1296 
1297                         goto send;
1298                 }
1299         }
1300         fe->pair_type = FE_PAIR_NONE;
1301         fe->pair = 0;


1422          * If we can't send it up, then we just drop it.
1423          */
1424         if (!canputnext(upper->kbtrans_streams_readq)) {
1425 
1426                 return;
1427         }
1428 
1429         /*
1430          * Allocate a messsage block to send up.
1431          */
1432         if ((bp = allocb(sizeof (uint_t), BPRI_HI)) == NULL) {
1433 
1434                 cmn_err(CE_WARN, "kbtrans_putcode: Can't allocate block\
1435                         for keycode.");
1436 
1437                 return;
1438         }
1439 
1440         /*
1441          * We will strip out any high order information here.
1442          * Convert to UTF-8.
1443          */
1444         code = KEYCHAR(code);
1445         if (code < 0x80) {
1446                 *bp->b_wptr++ = (char)code;
1447         } else if (code < 0x800) {
1448                 *bp->b_wptr++ = 0xc0 | (code >> 6);
1449                 *bp->b_wptr++ = 0x80 | (code & 0x3f);
1450         } else if (code < 0x10000) {
1451                 *bp->b_wptr++ = 0xe0 | (code >> 12);
1452                 *bp->b_wptr++ = 0x80 | ((code >> 6) & 0x3f);
1453                 *bp->b_wptr++ = 0x80 | (code & 0x3f);
1454         } else {
1455                 *bp->b_wptr++ = 0xf0 | (code >> 18);
1456                 *bp->b_wptr++ = 0x80 | ((code >> 12) & 0x3f);
1457                 *bp->b_wptr++ = 0x80 | ((code >> 6) & 0x3f);
1458                 *bp->b_wptr++ = 0x80 | (code & 0x3f);
1459         }
1460 
1461         /*
1462          * Send the message up.
1463          */
1464         (void) putnext(upper->kbtrans_streams_readq, bp);
1465 }
1466 
1467 
1468 /*
1469  * kbtrans_putbuf:
1470  *      Pass generated keycode sequence to upstream, if possible.
1471  */
1472 static void
1473 kbtrans_putbuf(char *buf, queue_t *q)
1474 {
1475         register mblk_t *bp;
1476 
1477         if (!canputnext(q)) {
1478                 cmn_err(CE_WARN, "kbtrans_putbuf: Can't put block for keycode");
1479         } else {


1786                 }
1787 
1788                 return;
1789 
1790         case PADKEYS:
1791                 /*
1792                  * These are the keys on the keypad.  Look up the
1793                  * answer in the kb_numlock_table and send it upstream.
1794                  */
1795                 kbtrans_putcode(upper,
1796                     lower->kbtrans_numlock_table[entry&0x1F]);
1797 
1798                 return;
1799 
1800         case 0: /* normal character */
1801         default:
1802                 break;
1803         }
1804 
1805         /*
1806          * Send the char upstream.
1807          */
1808         kbtrans_putcode(upper, entry);
1809 
1810 }
1811 
1812 #define KB_SCANCODE_ALT         0xe2
1813 #define KB_SCANCODE_ALTGRAPH    0xe6
1814 
1815 /*
1816  * kbtrans_ascii_keyreleased:
1817  *      This is the function if we are in TR_ASCII mode and a key
1818  *      is released.  ASCII doesn't have the concept of released keys,
1819  *      or make/break codes.  So there is nothing for us to do except
1820  *      checking 'Alt/AltGraph' release key in order to reset the state
1821  *      of vt switch key sequence.
1822  */
1823 /* ARGSUSED */
1824 static void
1825 kbtrans_ascii_keyreleased(struct kbtrans *upper, kbtrans_key_t key)
1826 {


2087 #define OLD_SHIFTKEYS   0x80
2088 #define OLD_BUCKYBITS   0x90
2089 #define OLD_FUNNY       0xA0
2090 #define OLD_FA_UMLAUT   0xA9
2091 #define OLD_FA_CFLEX    0xAA
2092 #define OLD_FA_TILDE    0xAB
2093 #define OLD_FA_CEDILLA  0xAC
2094 #define OLD_FA_ACUTE    0xAD
2095 #define OLD_FA_GRAVE    0xAE
2096 #define OLD_ISOCHAR     0xAF
2097 #define OLD_STRING      0xB0
2098 #define OLD_LEFTFUNC    0xC0
2099 #define OLD_RIGHTFUNC   0xD0
2100 #define OLD_TOPFUNC     0xE0
2101 #define OLD_BOTTOMFUNC  0xF0
2102 
2103 /*
2104  * Map old special codes to new ones.
2105  * Indexed by ((old special code) >> 4) & 0x07; add (old special code) & 0x0F.
2106  */
2107 static keymap_entry_t  special_old_to_new[] = {
2108         SHIFTKEYS,
2109         BUCKYBITS,
2110         FUNNY,
2111         STRING,
2112         LEFTFUNC,
2113         RIGHTFUNC,
2114         TOPFUNC,
2115         BOTTOMFUNC,
2116 };
2117 
2118 
2119 /*
2120  * kbtrans_setkey:
2121  *       Set individual keystation translation from old-style entry.
2122  */
2123 static int
2124 kbtrans_setkey(struct kbtrans_lower *lower, struct kiockey *key, cred_t *cr)
2125 {
2126         int     strtabindex, i;
2127         keymap_entry_t  *ke;
2128         register int tablemask;
2129         register keymap_entry_t entry;
2130         register struct keyboard *kp;
2131 
2132         kp = lower->kbtrans_keyboard;
2133 
2134         if (key->kio_station >= kp->k_keymap_size)

2135                 return (EINVAL);
2136 
2137         if (lower->kbtrans_keyboard == NULL)
2138 
2139                 return (EINVAL);
2140 
2141         tablemask = key->kio_tablemask;
2142 
2143         switch (tablemask) {
2144         case KIOCABORT1:
2145         case KIOCABORT1A:
2146         case KIOCABORT2:
2147                 i = secpolicy_console(cr);
2148                 if (i != 0)
2149                         return (i);
2150 
2151                 switch (tablemask) {
2152                 case KIOCABORT1:
2153                         kp->k_abort1 = key->kio_station;
2154                         break;


2205  */
2206 static uchar_t   special_new_to_old[] = {
2207         0,                      /* normal */
2208         OLD_SHIFTKEYS,          /* SHIFTKEYS */
2209         OLD_BUCKYBITS,          /* BUCKYBITS */
2210         OLD_FUNNY,              /* FUNNY */
2211         OLD_FA_UMLAUT,          /* FA_CLASS */
2212         OLD_STRING,             /* STRING */
2213         OLD_LEFTFUNC,           /* FUNCKEYS */
2214 };
2215 
2216 
2217 /*
2218  * kbtrans_getkey:
2219  *      Get individual keystation translation as old-style entry.
2220  */
2221 static int
2222 kbtrans_getkey(struct kbtrans_lower *lower, struct kiockey *key)
2223 {
2224         int     strtabindex;
2225         keymap_entry_t  *ke;
2226         register keymap_entry_t entry;
2227         struct keyboard *kp;
2228 
2229         kp = lower->kbtrans_keyboard;
2230 
2231         if (key->kio_station >= kp->k_keymap_size)
2232                 return (EINVAL);
2233 
2234         if (lower->kbtrans_keyboard == NULL)
2235                 return (EINVAL);
2236 
2237         switch (key->kio_tablemask) {
2238         case KIOCABORT1:
2239                 key->kio_station = kp->k_abort1;
2240                 return (0);
2241         case KIOCABORT1A:
2242                 key->kio_station = kp->k_abort1a;
2243                 return (0);
2244         case KIOCABORT2:
2245                 key->kio_station = kp->k_abort2;
2246                 return (0);


2264                         key->kio_entry = (ushort_t)entry;
2265         }
2266 
2267         if (entry >= STRING && entry <= (uchar_t)(STRING + 15)) {
2268                 strtabindex = entry - STRING;
2269                 bcopy(lower->kbtrans_keystringtab[strtabindex],
2270                     key->kio_string, KTAB_STRLEN);
2271         }
2272         return (0);
2273 }
2274 
2275 
2276 /*
2277  * kbtrans_skey:
2278  *      Set individual keystation translation from new-style entry.
2279  */
2280 static int
2281 kbtrans_skey(struct kbtrans_lower *lower, struct kiockeymap *key, cred_t *cr)
2282 {
2283         int     strtabindex, i;
2284         keymap_entry_t *ke;
2285         struct keyboard *kp;
2286 
2287         kp = lower->kbtrans_keyboard;
2288 
2289         if (key->kio_station >= kp->k_keymap_size) {
2290                 return (EINVAL);
2291 
2292         }
2293 
2294         if (lower->kbtrans_keyboard == NULL) {
2295                 return (EINVAL);
2296         }
2297 
2298         switch (key->kio_tablemask) {
2299         case KIOCABORT1:
2300         case KIOCABORT1A:
2301         case KIOCABORT2:
2302                 i = secpolicy_console(cr);
2303                 if (i != 0)
2304                         return (i);
2305                 switch (key->kio_tablemask) {
2306                 case KIOCABORT1:
2307                         kp->k_abort1 = key->kio_station;
2308                         break;
2309                 case KIOCABORT1A:
2310                         kp->k_abort1a = key->kio_station;
2311                         break;
2312                 case KIOCABORT2:
2313                         kp->k_abort2 = key->kio_station;
2314                         break;
2315                 }
2316                 return (0);
2317         }
2318 
2319         ke = kbtrans_find_entry(lower, (uint_t)key->kio_tablemask,
2320             key->kio_station);
2321         if (ke == NULL)
2322                 return (EINVAL);
2323 
2324         if (key->kio_entry >= STRING &&
2325             key->kio_entry <= (STRING + 15)) {
2326                 strtabindex = key->kio_entry-STRING;
2327                 bcopy(key->kio_string,
2328                     lower->kbtrans_keystringtab[strtabindex], KTAB_STRLEN);
2329                 lower->kbtrans_keystringtab[strtabindex][KTAB_STRLEN-1] = '\0';
2330         }
2331 
2332         *ke = key->kio_entry;
2333 
2334         return (0);
2335 }
2336 
2337 
2338 /*
2339  * kbtrans_gkey:
2340  *      Get individual keystation translation as new-style entry.
2341  */
2342 static int
2343 kbtrans_gkey(struct kbtrans_lower *lower, struct kiockeymap *key)
2344 {
2345         int     strtabindex;
2346         keymap_entry_t *ke;
2347         struct keyboard *kp;
2348 
2349         kp = lower->kbtrans_keyboard;
2350 
2351         if (key->kio_station >= kp->k_keymap_size)
2352                 return (EINVAL);
2353 
2354         if (lower->kbtrans_keyboard == NULL)
2355                 return (EINVAL);
2356 
2357         switch (key->kio_tablemask) {
2358         case KIOCABORT1:
2359                 key->kio_station = kp->k_abort1;
2360                 return (0);
2361         case KIOCABORT1A:
2362                 key->kio_station = kp->k_abort1a;
2363                 return (0);
2364         case KIOCABORT2:
2365                 key->kio_station = kp->k_abort2;
2366                 return (0);
2367         }
2368 
2369         ke = kbtrans_find_entry(lower, (uint_t)key->kio_tablemask,
2370             key->kio_station);
2371         if (ke == NULL)
2372                 return (EINVAL);
2373 
2374         key->kio_entry = *ke;
2375 
2376         if (key->kio_entry >= STRING &&
2377             key->kio_entry <= (STRING + 15)) {
2378                 strtabindex = key->kio_entry-STRING;
2379                 bcopy(lower->kbtrans_keystringtab[strtabindex],
2380                     key->kio_string, KTAB_STRLEN);
2381         }
2382         return (0);
2383 }