diff options
Diffstat (limited to 'sys/arch/amiga/stand')
-rw-r--r-- | sys/arch/amiga/stand/binpatch/Makefile | 9 | ||||
-rw-r--r-- | sys/arch/amiga/stand/binpatch/binpatch.8 | 96 | ||||
-rw-r--r-- | sys/arch/amiga/stand/binpatch/binpatch.c | 419 | ||||
-rw-r--r-- | sys/arch/amiga/stand/dumpfont/dumpfont.c | 98 | ||||
-rw-r--r-- | sys/arch/amiga/stand/dumpfont/fontdumper.c | 181 | ||||
-rw-r--r-- | sys/arch/amiga/stand/loadbsd/loadbsd.c | 701 | ||||
-rw-r--r-- | sys/arch/amiga/stand/loadkmap/din-kbdmap.c | 484 | ||||
-rw-r--r-- | sys/arch/amiga/stand/loadkmap/loadkmap.c | 67 | ||||
-rw-r--r-- | sys/arch/amiga/stand/loadkmap/us-kbdmap.c | 481 |
9 files changed, 2536 insertions, 0 deletions
diff --git a/sys/arch/amiga/stand/binpatch/Makefile b/sys/arch/amiga/stand/binpatch/Makefile new file mode 100644 index 00000000000..68515d25505 --- /dev/null +++ b/sys/arch/amiga/stand/binpatch/Makefile @@ -0,0 +1,9 @@ +# $NetBSD: Makefile,v 1.4 1994/12/22 10:47:08 cgd Exp $ + +PROG=binpatch +MAN=binpatch.8 + +BINDIR=/sbin +LDFLAGS+=-static + +.include <bsd.prog.mk> diff --git a/sys/arch/amiga/stand/binpatch/binpatch.8 b/sys/arch/amiga/stand/binpatch/binpatch.8 new file mode 100644 index 00000000000..935f010b7c6 --- /dev/null +++ b/sys/arch/amiga/stand/binpatch/binpatch.8 @@ -0,0 +1,96 @@ +.\" $NetBSD: binpatch.8,v 1.3 1994/10/26 02:06:54 cgd Exp $ +.\" +.\" Copyright (c) 1994 Christian E. Hopps +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" 3. All advertising materials mentioning features or use of this software +.\" must display the following acknowledgement: +.\" This product includes software developed by Christian E. Hopps. +.\" 3. The name of the author may not be used to endorse or promote products +.\" derived from this software without specific prior written permission +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.Dd February 2, 1994 +.Dt BINPATCH 8 amiga +.Os +.Sh NAME +.Nm binpatch +.Nd examine and or modify initialized data in a binary file. +.Sh SYNOPSIS +.Nm binpatch +.Op Fl b | Fl w | Fl l +.Op Fl o Ar offset +.Fl s Ar symname +.Op Fl r Ar value +.Ar binfile +.Nm binpatch +.Op Fl b | Fl w | Fl l +.Op Fl o Ar offset +.Fl a Ar addr +.Op Fl r Ar value +.Ar binfile +.Sh DESCRIPTION +.Nm binpatch +is used to modify or examine the data associated with a symbol in a binary +file +.Ar binfile . +The flags +.Fl b , +.Fl w +and +.Fl l +specify the size of the data to be modified or examined +(byte, word and long respectively.) The +.Ar binfile +is scanned in search of the symbol +.Ar symname +(specified with the +.Fl s +flag) +If the symbol is found the current data and address are printed. Next if the +.Fl r +flag has been given, the current data is replaced with that of +.Ar value . +.Pp +If the second form is used the address +.Ar addr +specified with the +.Fl a +flag is used as a direct address into the data section of the binary and +no symbol search is performed. +.Pp +The +.Fl o +flag specifies an offset in byte, word or long ( +.Fl b +, +.Fl w +, +or +.Fl l +) units from the given locator ( +.Fl s +or +.Fl a +) for +.Nm binpatch +to perform it's described actions. + diff --git a/sys/arch/amiga/stand/binpatch/binpatch.c b/sys/arch/amiga/stand/binpatch/binpatch.c new file mode 100644 index 00000000000..300bdfe3bef --- /dev/null +++ b/sys/arch/amiga/stand/binpatch/binpatch.c @@ -0,0 +1,419 @@ +/* $NetBSD: binpatch.c,v 1.6 1995/08/18 15:28:28 chopps Exp $ */ + +/* Author: Markus Wild mw@eunet.ch ??? */ +/* Modified: Rob Leland leland@mitre.org */ + +#include <sys/types.h> +#include <a.out.h> +#include <fcntl.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#ifdef __NetBSD__ +/* + * assume NMAGIC files are linked at 0 (for kernel) + */ +#undef N_TXTADDR +#define N_TXTADDR(ex) \ + ((N_GETMAGIC2(ex) == (ZMAGIC|0x10000) || N_GETMAGIC2(ex) == NMAGIC) ? \ + 0 : __LDPGSZ) +#endif + + +static char synusage[] = " +NAME +\t%s - Allows the patching of BSD binaries +SYNOPSIS +\t%s [-HELP] +\t%s [-b|-w|-l] -s symbol[[[index]][=value]] binary +\t%s [-b|-w|-l] [-o offset] -s symbol [-r value] binary +\t%s [-b|-w|-l] [-o offset] -a address [-r value] binary +"; +static char desusage[] = "DESCRIPTION +\tAllows the patching of BSD binaries, for example,a distributed +\tkernel. Recient additions allows the user to index into an array +\tand assign a value. Binpatch has internal variables to allow +\tyou to test it on itself under NetBSD. +OPTIONS +\t-a patch variable by specifying address in hex +\t-b symbol or address to be patched is 1 byte +\t-l symbol or address to be patched is 4 bytes (default) +\t-o offset to begin patching value relative to symbol or address +\t-r replace value, and print out previous value to stdout +\t-s patch variable by specifying symbol name. Use '[]' +\t to specify the 'index'. If '-b, -w or -l' not specified +\t then index value is used like an offset. Also can use '=' +\t to assign value +\t-w symbol or address to be patched is 2 bytes +EXAMPLES +\tThis should print 100 (this is a nice reality check...) +\t\tbinpatch -l -s _hz netbsd +\tNow it gets more advanced, replace the value: +\t\tbinpatch -l -s _sbic_debug -r 1 netbsd +\tNow patch a variable at a given 'index' not offset, +\tunder NetBSD you must use '', under AmigaDos CLI '' is optional.: +\t\tbinpatch -w -s '_vieww[4]' -r 0 a.out +\tsame as +\t\tbinpatch -w -o 8 -s _vieww -r 0 a.out +\tAnother example of using [] +\t\tbinpatch -s '_viewl[4]' -r 0 a.out +\tsame as +\t\tbinpatch -o 4 -s _viewl -r 0 a.out +\tOne last example using '=' and [] +\t\tbinpatch -w -s '_vieww[4]=2' a.out +\tSo if the kernel is not finding your drives, you could enable +\tall available debugging options, helping to shed light on that problem. +\t\tbinpatch -l -s _sbic_debug -r 1 netbsd scsi-level +\t\tbinpatch -l -s _sddebug -r 1 netbsd sd-level (disk-driver) +\t\tbinpatch -l -s _acdebug -r 1 netbsd autoconfig-level +SEE ALSO +\tbinpatch.c binpatch(1) +"; + +extern char *optarg; +extern int optind; + +volatile void error (char *); +static void Synopsis(char *program_name); +static void Usage(char *program_name); +static u_long FindAssign(char *symbol,u_long *rvalue); +static void FindOffset(char *symbol,u_long *index); + +/* The following variables are so binpatch can be tested on itself */ +int test = 1; +int testbss; +char foo = 23; +char viewb[10] = {0,0,1,0,1,1,0,1,1,1}; +short vieww[10] = {0,0,1,0,1,1,0,1,1,1}; +long viewl[10] = {0,0,1,0,1,1,0,1,1,1}; +/* End of test binpatch variables */ +int +main(int argc, char *argv[]) +{ + struct exec e; + int c; + u_long addr = 0, offset = 0; + u_long index = 0;/* Related to offset */ + u_long replace = 0, do_replace = 0; + char *symbol = 0; + char size = 4; /* default to long */ + char size_opt = 0; /* Flag to say size option was set, used with index */ + char *fname; + char *pgname = argv[0]; /* Program name */ + int fd; + int type, off; + u_long lval; + u_short sval; + u_char cval; + + + while ((c = getopt (argc, argv, "H:a:bwlr:s:o:")) != EOF) + switch (c) + { + case 'H': + Usage(argv[0]); + break; + case 'a': + if (addr || symbol) + error ("only one address/symbol allowed"); + if (! strncmp (optarg, "0x", 2)) + sscanf (optarg, "%x", &addr); + else + addr = atoi (optarg); + if (! addr) + error ("invalid address"); + break; + + case 'b': + size = 1; + size_opt = 1; + break; + + case 'w': + size = 2; + size_opt = 1; + break; + + case 'l': + size = 4; + size_opt = 1; + break; + + case 'r': + do_replace = 1; + if (! strncmp (optarg, "0x", 2)) + sscanf (optarg, "%x", &replace); + else + replace = atoi (optarg); + break; + + case 's': + if (addr || symbol) + error ("only one address/symbol allowed"); + symbol = optarg; + break; + + case 'o': + if (offset) + error ("only one offset allowed"); + if (! strncmp (optarg, "0x", 2)) + sscanf (optarg, "%x", &offset); + else + offset = atoi (optarg); + break; + }/* while switch() */ + + if (argc > 1) + { + if (addr || symbol) + { + argv += optind; + argc -= optind; + + if (argc < 1) + error ("No file to patch."); + + fname = argv[0]; + if ((fd = open (fname, 0)) < 0) + error ("Can't open file"); + + if (read (fd, &e, sizeof (e)) != sizeof (e) + || N_BADMAG (e)) + error ("Not a valid executable."); + + /* fake mid, so the N_ macros work on the amiga.. */ + e.a_midmag |= 127 << 16; + + if (symbol) + { + struct nlist nl[2]; + if (offset == 0) + { + u_long new_do_replace = 0; + new_do_replace = FindAssign(symbol,&replace); + if (new_do_replace && do_replace) + error("Cannot use both '=' and '-r' option!"); + FindOffset(symbol,&index); + if (size_opt) + offset = index*size; /* Treat like an index */ + else + offset = index; /* Treat index like an offset */ + if (new_do_replace) + do_replace = new_do_replace; + } + nl[0].n_un.n_name = symbol; + nl[1].n_un.n_name = 0; + if (nlist (fname, nl) != 0) + { + fprintf(stderr,"Symbol is %s ",symbol); + error ("Symbol not found."); + } + addr = nl[0].n_value; + type = nl[0].n_type & N_TYPE; + } + else + { + type = N_UNDF; + if (addr >= N_TXTADDR(e) && addr < N_DATADDR(e)) + type = N_TEXT; + else if (addr >= N_DATADDR(e) && addr < N_DATADDR(e) + e.a_data) + type = N_DATA; + } + addr += offset; + + /* if replace-mode, have to reopen the file for writing. + Can't do that from the beginning, or nlist() will not + work (at least not under AmigaDOS) */ + if (do_replace) + { + close (fd); + if ((fd = open (fname, 2)) == -1) + error ("Can't reopen file for writing."); + } + + if (type != N_TEXT && type != N_DATA) + error ("address/symbol is not in text or data section."); + + if (type == N_TEXT) + off = addr - N_TXTADDR(e) + N_TXTOFF(e); + else + off = addr - N_DATADDR(e) + N_DATOFF(e); + + if (lseek (fd, off, 0) == -1) + error ("lseek"); + + /* not beautiful, but works on big and little endian machines */ + switch (size) + { + case 1: + if (read (fd, &cval, 1) != 1) + error ("cread"); + lval = cval; + break; + + case 2: + if (read (fd, &sval, 2) != 2) + error ("sread"); + lval = sval; + break; + + case 4: + if (read (fd, &lval, 4) != 4) + error ("lread"); + break; + }/* switch size */ + + + if (symbol) + printf ("%s(0x%x): %d (0x%x)\n", symbol, addr, lval, lval); + else + printf ("0x%x: %d (0x%x)\n", addr, lval, lval); + + if (do_replace) + { + if (lseek (fd, off, 0) == -1) + error ("write-lseek"); + switch (size) + { + case 1: + cval = replace; + if (cval != replace) + error ("byte-value overflow."); + if (write (fd, &cval, 1) != 1) + error ("cwrite"); + break; + + case 2: + sval = replace; + if (sval != replace) + error ("word-value overflow."); + if (write (fd, &sval, 2) != 2) + error ("swrite"); + break; + + case 4: + if (write (fd, &replace, 4) != 4) + error ("lwrite"); + break; + }/* switch(size) */ + }/* if (do_replace) */ + + close (fd); + }/* if(addr || symbol ) */ + else + { + error("Must specify either address or symbol."); + } + }/* if argc < 1 */ + else + { + Synopsis(pgname); + } + return(0); +}/* main () */ + + + +volatile void error (char *str) +{ + fprintf (stderr, "%s\n", str); + exit (1); +} + +/* Give user very short help to avoid scrolling screen much */ +static void Synopsis(char *pgname) +{ + fprintf(stdout,synusage,pgname,pgname,pgname,pgname,pgname); +} + + +static void Usage(char *pgname) +{ + Synopsis(pgname); + fprintf(stdout,desusage); + exit(0); +} + + +/* FindOffset() - Determine if there is an offset, -or- index + embedded in the symbol. + If there is, return it, and truncate symbol to + exclude the [...]. + Example: If view is declared as short view[10], + and we want to index the 3rd. element. + which is offset = (3 -1)*sizeof(short) =4. + we would use view[4], which becomes view,4. + The was the code is implemented the [value] is + treated as a index if-and-only-if a '-b -w -l' option + was given. Otherwise it is treated like an offset. + See above documentation in for of help! +*/ +static void FindOffset(char *symbol,u_long *index) +{ + char *sb=strchr(symbol,'['); /* Start of '[', now line must + contain matching']' */ + char *eb=strchr(symbol,']'); /* End of ']' */ + short sz=strlen(symbol); /* symbol size */ + if (sb) + { + if (eb && (eb > sb)) + { + if ((eb - symbol) == (sz - 1)) + { + char *sindex; /* Start of index */ + u_long newindex = 0; + /* In the future we could get fancy and parse the + sindex string for mathmatical expressions like: + (3 - 1)*2 = 4 from above example, + ugh forget I mentioned ot :-) ! + */ + sindex = sb + 1; + *eb = '\0'; + newindex = (u_long)atoi(sindex); + if (*index == 0) + { + *index = newindex; + *sb = '\0'; /* Make _view[3] look like _view */ + } + else + fprintf(stderr,"Error index can only be specified once!\n"); + } + else + { + fprintf(stderr,"Error: Garbage trailing ']'\n"); + } + } + else + { + fprintf(stderr,"Error ']' in symbol before '[' !\n"); + } + }/* if sb != 0 */ +}/* FindOffset */ + +/* FindAssign : Scans symbol name for an '=number' strips it off + of the symbol and proceeds. +*/ +static u_long FindAssign(char *symbol,u_long *rvalue) +{ + char *ce = rindex(symbol,'='); /* Assign symbol some number */ + char *cn = ce + 1; /* This should point at some number, no spaces allowed */ + u_long dr = 0; /* flag for do_replace */ + if (ce) + { + int nscan; /* number of variaables scanned in */ + /* get the number to assign to symbol and strip off = */ + for (cn=ce + 1;((*cn==' ')&&(*cn!='\0'));cn++) + ; + if (! strncmp (cn, "0x", 2)) + nscan = sscanf (cn, "%x",rvalue); + else + nscan = sscanf(cn,"%d",rvalue); + if (nscan != 1) + error("Invalid value following '='"); + dr = 1; + *ce = '\0';/* Now were left with just symbol */ + }/* if (ce) */ + return(dr); +}/* FindAssign */ diff --git a/sys/arch/amiga/stand/dumpfont/dumpfont.c b/sys/arch/amiga/stand/dumpfont/dumpfont.c new file mode 100644 index 00000000000..0107c2e7dd5 --- /dev/null +++ b/sys/arch/amiga/stand/dumpfont/dumpfont.c @@ -0,0 +1,98 @@ +/* $NetBSD: dumpfont.c,v 1.5 1994/10/26 02:06:57 cgd Exp $ */ + +/* + * This is a *real* hack to dump the topaz80 kernel font. This one is + * ways nicer than the ugly Mach font, but we'll have to dump it from a + * running system to not run against Commodore copyrights. *NEVER* distribute + * the generated font with BSD, always regenerate! + */ + +#include <exec/types.h> +#include <exec/memory.h> +#include <dos/dos.h> +#include <graphics/gfx.h> +#include <graphics/rastport.h> +#include <graphics/text.h> + +#include <inline/exec.h> +#include <inline/graphics.h> + +#include <stdio.h> + + +main() +{ + unsigned char str[256], *pp; + int i; + struct TextAttr ta = { "topaz.font", 8, FS_NORMAL, FPF_ROMFONT }; + struct RastPort rp; + struct BitMap bm = { 256, /* bytes per row */ + 8, /* rows */ + 0, /* flags */ + 1, /* depth */ + 0, /* pad */ + 0 }; /* planes */ + struct TextFont *tf; + + InitRastPort (& rp); + rp.BitMap = &bm; + bm.Planes[0] = pp = AllocRaster (256 * 8, 8); + + if (!pp) + { + fprintf (stderr, "Can't allocate raster!\n"); + exit (1); + } + bzero (pp, 256 * 8); + + tf = OpenFont (& ta); + if (! tf) + { + fprintf (stderr, "can't open topaz font.\n"); + exit (1); + } + + SetFont (&rp, tf); + + /* initialize string to be printed */ + for (i = 32; i < 256; i++) str[i - 32] = i; + + Move (&rp, 0, 6); + + Text (&rp, str, 256 - 32); + { + int bin = open ("bitmap", 1); + if (bin >= 0) + { + write (bin, pp, 256*8); + close (bin); + } + } + + /* dump them.. */ + printf ("/* generated automatically by dumpfont.c. *DONT* distribute\n"); + printf (" this file, it contains information Copyright by Commodore!\n"); + printf ("\n"); + printf (" This is the (new) topaz80 system font: */\n\n"); + + printf ("unsigned char kernel_font_width = 8;\n"); + printf ("unsigned char kernel_font_height = 8;\n"); + printf ("unsigned char kernel_font_lo = 32;\n"); + printf ("unsigned char kernel_font_hi = 255;\n\n"); + + printf ("unsigned char kernel_cursor[] = {\n"); + printf (" 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };\n\n"); + printf ("unsigned char kernel_font[] = {\n"); + + for (i = 0; i < 256 - 32; i++) + { + printf ("/* %c */ ", i + 32); + printf ("0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x,\n", + pp[i+0*256], pp[i+1*256], pp[i+2*256], pp[i+3*256], + pp[i+4*256], pp[i+5*256], pp[i+6*256], pp[i+7*256]); + } + printf ("};\n"); + + CloseFont (tf); + FreeRaster (pp, 256 * 8, 8); +} diff --git a/sys/arch/amiga/stand/dumpfont/fontdumper.c b/sys/arch/amiga/stand/dumpfont/fontdumper.c new file mode 100644 index 00000000000..365dbb7916d --- /dev/null +++ b/sys/arch/amiga/stand/dumpfont/fontdumper.c @@ -0,0 +1,181 @@ +/* $NetBSD: fontdumper.c,v 1.3 1994/10/26 02:06:59 cgd Exp $ */ + +/* + * Routine to allow user to select from available fonts that fit restricitons of + * NetBSD display code and then dump that font in the format for inclusion in the + * kernel. Only character values 32-255 are dumped. + * + * Current kernel only allows fonts up to 8 pixels wide & non-proportional. + * If this changes, the font requestor flags and restriction tests will need updating. + * Also the NetBSDwidth value, cursor bits and dumping of font hex values needs updating. + * + * Author: Alan Bair + * Dated: 11/12/1993 + * + * Added printing of some other useful data for future (and current) expansion. + * -ch + * Dated: 11/17/1993 + */ + +/* Original code by Markus Wild */ +/* This is a *real* hack to dump the topaz80 kernel font. This one is + ways nicer than the ugly Mach font, but we'll have to dump it from a + running system to not run against Commodore copyrights. *NEVER* distribute + the generated font with BSD, always regenerate! */ + +#include <exec/types.h> +#include <exec/memory.h> +#include <dos/dos.h> +#include <graphics/gfx.h> +#include <graphics/rastport.h> +#include <graphics/text.h> +#include <libraries/asl.h> + +#include <inline/exec.h> +#include <inline/graphics.h> + +#include <stdio.h> + +#define NetBSDwidth 8 + +main(int argc, char *argv[]) +{ + unsigned char str[256]; + int i; + int j; + struct RastPort rp; + unsigned char *pp; + struct BitMap bm = { + 256, /* bytes per row */ + 8, /* rows */ + 0, /* flags */ + 1, /* depth */ + 0, /* pad */ + 0 /* planes */ + }; + struct TextAttr ta; + struct TextFont *tf; + struct FontRequester *fr; + struct TagItem frtags[] = { + ASL_Hail, (ULONG)"NetBSD font choices", + ASL_Width, 640, + ASL_Height, 400, + ASL_LeftEdge, 10, + ASL_TopEdge, 10, + ASL_OKText, (ULONG)"Dump", + ASL_CancelText, (ULONG)"Cancel", + ASL_FontName, (ULONG)"topaz.font", + ASL_FontHeight, 8L, + ASL_FontStyles, FS_NORMAL, + ASL_FuncFlags, FONF_STYLES | FONF_FIXEDWIDTH, + TAG_DONE + }; + + /* Let the user pick a font to dump */ + if (fr = (struct FontRequester *) + AllocAslRequest(ASL_FontRequest, frtags)) { + if (!AslRequest(fr, NULL)) { + FreeAslRequest(fr); + fprintf(stderr, "User requested exit\n"); + exit (0); + } + ta.ta_Name = (STRPTR)malloc(strlen(fr->fo_Attr.ta_Name)); + strcpy(ta.ta_Name, fr->fo_Attr.ta_Name); + ta.ta_YSize = fr->fo_Attr.ta_YSize; + ta.ta_Style = fr->fo_Attr.ta_Style; + ta.ta_Flags = fr->fo_Attr.ta_Flags; + FreeAslRequest(fr); + } else { + fprintf(stderr, "Can't allocate Font Requestor\n"); + exit (1); + } + + /* Open the selected font */ + tf = (struct TextFont *)OpenDiskFont (&ta); + if (! tf) { + fprintf (stderr, "Can't open font: %s\n", ta.ta_Name); + exit (1); + } +#ifdef DEBUG + fprintf(stderr, "Information on selected font:\n"); + fprintf(stderr, "Name=%s\n", ta.ta_Name); + fprintf(stderr, "Height=%d tf_Style=%x tf_Flags=%x Width=%d Baseline=%d\n", + tf->tf_YSize, tf->tf_Style, tf->tf_Flags, tf->tf_XSize, tf->tf_Baseline); +#endif + + /* Check for NetBSD restrictions */ + if (tf->tf_Flags & FPF_PROPORTIONAL) { + fprintf(stderr, "NetBSD does not support proportional fonts\n"); + exit (1); + } + if (tf->tf_XSize > NetBSDwidth) { + fprintf(stderr, "NetBSD does not support fonts wider than %d pixels\n", NetBSDwidth); + exit (1); + } + + /* Allocate area to render font in */ + InitBitMap(&bm, 1, 256 * NetBSDwidth, tf->tf_YSize); + InitRastPort (&rp); + rp.BitMap = &bm; + bm.Planes[0] = pp = AllocRaster (256 * NetBSDwidth, tf->tf_YSize); + if (!pp) { + fprintf (stderr, "Can't allocate raster!\n"); + exit (1); + } + + /* Initialize string to be rendered */ + for (i = 32; i < 256; i++) { + str[i - 32] = i; + } + + /* Render string with selected font */ + SetFont (&rp, tf); + SetSoftStyle(&rp, ta.ta_Style ^ tf->tf_Style, (FSF_BOLD | FSF_UNDERLINED | FSF_ITALIC)); + Move (&rp, 0, tf->tf_Baseline); + ClearEOL(&rp); + if (tf->tf_XSize != NetBSDwidth) { + /* right-justify char in cell */ + Move (&rp, NetBSDwidth - tf->tf_XSize, tf->tf_Baseline); + /* Narrow font, put each character in space of normal font */ + for (i = 0; i < (256 - 32); i++) { + Text (&rp, &str[i], 1); + Move (&rp, rp.cp_x + (NetBSDwidth - tf->tf_XSize), rp.cp_y); + } + } else { + Text (&rp, str, 256 - 32); + } + + /* Dump them.. */ + printf ("/* Generated automatically by fontdumper.c. *DONT* distribute\n"); + printf (" this file, it may contain information Copyright by Commodore!\n"); + printf ("\n"); + printf (" Font: %s/%d\n", ta.ta_Name, tf->tf_YSize); + printf (" */\n\n"); + + printf ("unsigned char kernel_font_width = %d;\n", tf->tf_XSize); + printf ("unsigned char kernel_font_height = %d;\n", tf->tf_YSize); + printf ("unsigned char kernel_font_baseline = %d;\n", tf->tf_Baseline); + printf ("short kernel_font_boldsmear = %d;\n", tf->tf_BoldSmear); + printf ("unsigned char kernel_font_lo = 32;\n"); + printf ("unsigned char kernel_font_hi = 255;\n\n"); + + printf ("unsigned char kernel_cursor[] = {\n"); + for (j = 0; j < (tf->tf_YSize -1); j++) { + printf ("0xff, "); + } + printf ("0xff };\n\n"); + + printf ("unsigned char kernel_font[] = {\n"); + for (i = 0; i < 256 - 32; i++) { + printf ("/* %c */", i + 32); + for (j = 0; j < tf->tf_YSize; j++) { + printf (" 0x%02x,", pp[i+j*256]); + } + printf ("\n"); + } + printf ("};\n"); + + CloseFont (tf); + FreeRaster (pp, 256 * NetBSDwidth, tf->tf_YSize); + return (0); +} diff --git a/sys/arch/amiga/stand/loadbsd/loadbsd.c b/sys/arch/amiga/stand/loadbsd/loadbsd.c new file mode 100644 index 00000000000..087bb4cacb1 --- /dev/null +++ b/sys/arch/amiga/stand/loadbsd/loadbsd.c @@ -0,0 +1,701 @@ +/* $NetBSD: loadbsd.c,v 1.16 1995/02/12 19:19:41 chopps Exp $ */ + +/* + * Copyright (c) 1994 Michael L. Hitch + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by Michael L. Hitch. + * 4. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR + * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. + * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT + * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF + * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/types.h> +#include <a.out.h> +#include <stdio.h> +#include <unistd.h> +#include <errno.h> +#include <stdarg.h> +#include <signal.h> +#ifdef __NetBSD__ +#include <err.h> +#endif +#include <exec/types.h> +#include <exec/execbase.h> +#include <exec/memory.h> +#include <exec/resident.h> +#include <graphics/gfxbase.h> +#include <libraries/configregs.h> +#include <libraries/configvars.h> +#include <libraries/expansion.h> +#include <libraries/expansionbase.h> + +#include <inline/exec.h> +#include <inline/expansion.h> +#include <inline/graphics.h> + +/* Get definitions for boothowto */ +#include "reboot.h" + +#undef __LDPGSZ +#define __LDPGSZ 8192 + +#ifndef __NetBSD__ +#ifndef __P +#ifdef __STDC__ +#define __P(x) x +#else +#define __P(x) +#endif +#endif +void err __P((int, const char *, ...)); +void errx __P((int, const char *, ...)); +void warn __P((const char *, ...)); +void warnx __P((const char *, ...)); +#endif + +/* + * Version history: + * 1.x Kernel parameter passing version check. + * 2.0 Added symbol table end address and symbol table support. + * 2.1 03/23/94 - Round up end of fastram segment. + * Check fastram segment size for minimum of 2M. + * Use largest segment of highest priority if -p option. + * Print out fastram size in KB if not a multiple of MB. + * 2.2 03/24/94 - Zero out all unused registers. + * Started version history comment. + * 2.3 04/26/94 - Added -D option to enter debugger on boot. + * 2.4 04/30/94 - Cpuid includes base machine type. + * Also check if CPU is capable of running NetBSD. + * 2.5 05/17/94 - Add check for "A3000 bonus". + * 2.6 06/05/94 - Added -c option to override machine type. + * 2.7 06/15/94 - Pass E clock frequency. + * 2.8 06/22/94 - Fix supervisor stack usage. + * 2.9 06/26/94 - Use PAL flag for E clock freq on pre 2.0 WB + * Added AGA enable parameter + * 2.10 12/22/94 - Use FindResident() & OpenResource() for machine + * type detection. + * Add -n flag & option for non-contiguous memory. + * 01/28/95 - Corrected -n on usage & help messages. + */ +static const char _version[] = "$VER: LoadBSD 2.10 (28.1.95)"; + +/* + * Kernel parameter passing version + * 1: first version of loadbsd + * 2: needs esym location passed in a4 + */ +#define KERNEL_PARAMETER_VERSION 2 + +#define MAXMEMSEG 16 +struct boot_memlist { + u_int m_nseg; /* num_mem; */ + struct boot_memseg { + u_int ms_start; + u_int ms_size; + u_short ms_attrib; + short ms_pri; + } m_seg[MAXMEMSEG]; +}; +struct boot_memlist memlist; +struct boot_memlist *kmemlist; + + +void get_mem_config __P((void **, u_long *, u_long *)); +void get_cpuid __P((void)); +void get_eclock __P((void)); +void get_AGA __P((void)); +void usage __P((void)); +void verbose_usage __P((void)); +void Version __P((void)); + +extern struct ExecBase *SysBase; +extern char *optarg; +extern int optind; + +int k_flag; +int p_flag; +int t_flag; +int reqmemsz; +int S_flag; +u_long cpuid; +long eclock_freq; +long amiga_flags; +char *program_name; +char *kname; +struct ExpansionBase *ExpansionBase; +struct GfxBase *GfxBase; + + +int +main(argc, argv) + int argc; + char **argv; +{ + struct exec e; + struct ConfigDev *cd, *kcd; + u_long fmemsz, cmemsz; + int fd, boothowto, ksize, textsz, stringsz, ncd, i, mem_ix, ch; + u_short *kvers; + int *nkcd; + u_char *kp; + void *fmem; + char *esym; + + program_name = argv[0]; + boothowto = RB_SINGLE; + + if (argc < 2) + usage(); + if ((GfxBase = (void *)OpenLibrary(GRAPHICSNAME, 0)) == NULL) + err(20, "can't open graphics library"); + if ((ExpansionBase=(void *)OpenLibrary(EXPANSIONNAME, 0)) == NULL) + err(20, "can't open expansion library"); + + while ((ch = getopt(argc, argv, "aAbc:Dhkm:n:ptSV")) != EOF) { + switch (ch) { + case 'k': + k_flag = 1; + break; + case 'a': + boothowto &= ~(RB_SINGLE); + boothowto |= RB_AUTOBOOT; + break; + case 'b': + boothowto |= RB_ASKNAME; + break; + case 'p': + p_flag = 1; + break; + case 't': + t_flag = 1; + break; + case 'm': + reqmemsz = atoi(optarg) * 1024; + break; + case 'V': + fprintf(stderr,"%s\n",_version + 6); + break; + case 'S': + S_flag = 1; + break; + case 'D': + boothowto |= RB_KDB; + break; + case 'c': + cpuid = atoi(optarg) << 16; + break; + case 'A': + amiga_flags |= 1; + break; + case 'n': + i = atoi(optarg); + if (i >= 0 && i <= 3) + amiga_flags |= i << 1; + else + err(20, "-n option must be 0, 1, 2, or 3"); + break; + case 'h': + verbose_usage(); + default: + usage(); + } + } + argc -= optind; + argv += optind; + + if (argc != 1) + usage(); + kname = argv[0]; + + if ((fd = open(kname, 0)) < 0) + err(20, "open"); + if (read(fd, &e, sizeof(e)) != sizeof(e)) + err(20, "reading exec"); + if (e.a_magic != NMAGIC) + err(20, "unknown binary"); + + for (cd = 0, ncd = 0; cd = FindConfigDev(cd, -1, -1); ncd++) + ; + get_mem_config(&fmem, &fmemsz, &cmemsz); + get_cpuid(); + get_eclock(); + get_AGA(); + + textsz = (e.a_text + __LDPGSZ - 1) & (-__LDPGSZ); + esym = NULL; + ksize = textsz + e.a_data + e.a_bss + ncd * sizeof(*cd) + + 4 + memlist.m_nseg * sizeof(struct boot_memseg) + 4; + + /* + * get symbol table size & string size + * (should check kernel version to see if it will handle it) + */ + if (S_flag && e.a_syms) { + if (lseek(fd, e.a_text + e.a_data + e.a_syms, SEEK_CUR) <= 0 + || read(fd, &stringsz, 4) != 4 + || lseek(fd, sizeof(e), SEEK_SET) < 0) + err(20, "lseek for symbols"); + ksize += e.a_syms + 4 + stringsz; + } + + kp = (u_char *)malloc(ksize); + if (t_flag) { + for (i = 0; i < memlist.m_nseg; ++i) { + printf("mem segment %d: start=%08lx size=%08lx" + " attribute=%04lx pri=%d\n", + i + 1, memlist.m_seg[i].ms_start, + memlist.m_seg[i].ms_size, + memlist.m_seg[i].ms_attrib, + memlist.m_seg[i].ms_pri); + } + } + if (kp == NULL) + err(20, "failed malloc %d\n", ksize); + + if (read(fd, kp, e.a_text) != e.a_text + || read(fd, kp + textsz, e.a_data) != e.a_data) + err(20, "unable to read kernel image\n"); + + if (k_flag) { + fmem += 4 * 1024 * 1024; + fmemsz -= 4 * 1024 * 1024; + } + + if (reqmemsz && reqmemsz <= fmemsz) + fmemsz = reqmemsz; + if (boothowto & RB_AUTOBOOT) + printf("Autobooting..."); + if (boothowto & RB_ASKNAME) + printf("Askboot..."); + + printf("Using %d%c FASTMEM at 0x%x, %dM CHIPMEM\n", + (fmemsz & 0xfffff) ? fmemsz >> 10 : fmemsz >> 20, + (fmemsz & 0xfffff) ? 'K' : 'M', fmem, cmemsz >> 20); + kvers = (u_short *)(kp + e.a_entry - 2); + if (*kvers > KERNEL_PARAMETER_VERSION && *kvers != 0x4e73) + err(20, "newer loadbsd required: %d\n", *kvers); + if ((cpuid & AFB_68020) == 0) + err(20, "cpu not supported"); + /* + * give them a chance to read the information... + */ + sleep(2); + + bzero(kp + textsz + e.a_data, e.a_bss); + /* + * If symbols wanted (and kernel can handle them), + * load symbol table & strings and set esym to end. + */ + nkcd = (int *)(kp + textsz + e.a_data + e.a_bss); + if (*kvers != 0x4e73 && *kvers > 1 && S_flag && e.a_syms) { + *nkcd++ = e.a_syms; + read(fd, (char *)nkcd, e.a_syms); + nkcd = (int *)((char *)nkcd + e.a_syms); + read(fd, (char *)nkcd, stringsz); + nkcd = (int*)((char *)nkcd + stringsz); + esym = (char *)(textsz + e.a_data + e.a_bss + + e.a_syms + 4 + stringsz); + } + *nkcd = ncd; + + kcd = (struct ConfigDev *)(nkcd + 1); + while(cd = FindConfigDev(cd, -1, -1)) + *kcd++ = *cd; + + kmemlist = (struct boot_memlist *)kcd; + kmemlist->m_nseg = memlist.m_nseg; + for (mem_ix = 0; mem_ix < memlist.m_nseg; mem_ix++) + kmemlist->m_seg[mem_ix] = memlist.m_seg[mem_ix]; + /* + * if test option set, done + */ + if (t_flag) + exit(0); + + /* + * XXX AGA startup - may need more + */ + LoadView(NULL); /* Don't do this if AGA active? */ + startit(kp, ksize, e.a_entry, fmem, fmemsz, cmemsz, boothowto, esym, + cpuid, eclock_freq, amiga_flags); + /*NOTREACHED*/ +} + +void +get_mem_config(fmem, fmemsz, cmemsz) + void **fmem; + u_long *fmemsz, *cmemsz; +{ + struct MemHeader *mh, *nmh; + u_int segsz, seg, eseg, nmem; + char mempri; + + nmem = 0; + mempri = -128; + *fmemsz = 0; + *cmemsz = 0; + + /* + * walk thru the exec memory list + */ + Forbid(); + for (mh = (void *) SysBase->MemList.lh_Head; + nmh = (void *) mh->mh_Node.ln_Succ; mh = nmh, nmem++) { + memlist.m_seg[nmem].ms_attrib = mh->mh_Attributes; + memlist.m_seg[nmem].ms_pri = mh->mh_Node.ln_Pri; + seg = (u_int)mh->mh_Lower; + eseg = (u_int)mh->mh_Upper; + segsz = eseg - seg; + memlist.m_seg[nmem].ms_size = segsz; + memlist.m_seg[nmem].ms_start = seg; + + if (mh->mh_Attributes & MEMF_CHIP) { + /* + * there should hardly be more than one entry for + * chip mem, but handle it the same nevertheless + * cmem always starts at 0, so include vector area + */ + memlist.m_seg[nmem].ms_start = seg = 0; + /* + * round to multiple of 512K + */ + segsz = (segsz + 512 * 1024 - 1) & -(512 * 1024); + memlist.m_seg[nmem].ms_size = segsz; + if (segsz > *cmemsz) + *cmemsz = segsz; + continue; + } + /* + * some heuristics.. + */ + seg &= -__LDPGSZ; + eseg = (eseg + __LDPGSZ - 1) & -__LDPGSZ; + + /* + * get the mem back stolen by incore kickstart on + * A3000 with V36 bootrom. + */ + if (eseg == 0x07f80000) + eseg = 0x08000000; + + /* + * or by zkick on a A2000. + */ + if (seg == 0x280000 && + strcmp(mh->mh_Node.ln_Name, "zkick memory") == 0) + seg = 0x200000; + + segsz = eseg - seg; + memlist.m_seg[nmem].ms_start = seg; + memlist.m_seg[nmem].ms_size = segsz; + /* + * If this segment is smaller than 2M, + * don't use it to load the kernel + */ + if (segsz < 2 * 1024 * 1024) + continue; + /* + * if p_flag is set, select memory by priority + * instead of size + */ + if ((!p_flag && segsz > *fmemsz) || (p_flag && + mempri <= mh->mh_Node.ln_Pri && segsz > *fmemsz)) { + *fmemsz = segsz; + *fmem = (void *)seg; + mempri = mh->mh_Node.ln_Pri; + } + } + memlist.m_nseg = nmem; + Permit(); +} + +/* + * Try to determine the machine ID by searching the resident module list + * for modules only present on specific machines. (Thanks, Bill!) + */ +void +get_cpuid() +{ + u_long *rl; + struct Resident *rm; + struct Node *rn; /* Resource node entry */ + + cpuid |= SysBase->AttnFlags; /* get FPU and CPU flags */ + if (cpuid & 0xffff0000) { + switch (cpuid >> 16) { + case 500: + case 600: + case 1000: + case 1200: + case 2000: + case 3000: + case 4000: + return; + default: + printf("machine Amiga %d is not recognized\n", + cpuid >> 16); + exit(1); + } + } + if (FindResident("A4000 Bonus") || FindResident("A1000 Bonus")) + cpuid |= 4000 << 16; + else if (FindResident("A3000 Bonus") || FindResident("A3000 bonus")) + cpuid |= 3000 << 16; + else if (OpenResource("card.resource")) { + /* Test for AGA? */ + cpuid |= 1200 << 16; + } + /* + * Nothing found, it's probably an A2000 or A500 + */ + if ((cpuid >> 16) == 0) + cpuid |= 2000 << 16; +} + +void +get_eclock() +{ + /* Fix for 1.3 startups? */ + if (SysBase->LibNode.lib_Version > 36) + eclock_freq = SysBase->ex_EClockFrequency; + else + eclock_freq = (GfxBase->DisplayFlags & PAL) ? + 709379 : 715909; +} + +void +get_AGA() +{ + /* + * Determine if an AGA mode is active + */ +} + + +asm(" + .set ABSEXECBASE,4 + + .text + .globl _startit + +_startit: + movel sp,a3 + movel 4:w,a6 + lea pc@(start_super-.+2),a5 + jmp a6@(-0x1e) | supervisor-call + +start_super: + movew #0x2700,sr + + | the BSD kernel wants values into the following registers: + | a0: fastmem-start + | d0: fastmem-size + | d1: chipmem-size + | d3: Amiga specific flags + | d4: E clock frequency + | d5: AttnFlags (cpuid) + | d7: boothowto + | a4: esym location + | All other registers zeroed for possible future requirements. + + lea pc@(_startit-.+2),sp | make sure we have a good stack *** + movel a3@(4),a1 | loaded kernel + movel a3@(8),d2 | length of loaded kernel +| movel a3@(12),sp | entry point in stack pointer + movel a3@(12),sp@- | push entry point *** + movel a3@(16),a0 | fastmem-start + movel a3@(20),d0 | fastmem-size + movel a3@(24),d1 | chipmem-size + movel a3@(28),d7 | boothowto + movel a3@(32),a4 | esym + movel a3@(36),d5 | cpuid + movel a3@(40),d4 | E clock frequency + movel a3@(44),d3 | Amiga flags + subl a5,a5 | target, load to 0 + + btst #3,(ABSEXECBASE)@(0x129) | AFB_68040,SysBase->AttnFlags + beq not040 + +| Turn off 68040 MMU + + .word 0x4e7b,0xd003 | movec a5,tc + .word 0x4e7b,0xd806 | movec a5,urp + .word 0x4e7b,0xd807 | movec a5,srp + .word 0x4e7b,0xd004 | movec a5,itt0 + .word 0x4e7b,0xd005 | movec a5,itt1 + .word 0x4e7b,0xd006 | movec a5,dtt0 + .word 0x4e7b,0xd007 | movec a5,dtt1 + bra nott + +not040: + lea pc@(zero-.+2),a3 + pmove a3@,tc | Turn off MMU + lea pc@(nullrp-.+2),a3 + pmove a3@,crp | Turn off MMU some more + pmove a3@,srp | Really, really, turn off MMU + +| Turn off 68030 TT registers + + btst #2,(ABSEXECBASE)@(0x129) | AFB_68030,SysBase->AttnFlags + beq nott | Skip TT registers if not 68030 + lea pc@(zero-.+2),a3 + .word 0xf013,0x0800 | pmove a3@,tt0 (gas only knows about 68851 ops..) + .word 0xf013,0x0c00 | pmove a3@,tt1 (gas only knows about 68851 ops..) + +nott: + + movew #(1<<9),0xdff096 | disable DMA + +L0: + moveb a1@+,a5@+ + subl #1,d2 + bcc L0 + + + moveq #0,d2 | zero out unused registers + moveq #0,d6 | (might make future compatibility + movel d6,a1 | would have known contents) + movel d6,a2 + movel d6,a3 + movel d6,a5 + movel d6,a6 +| jmp sp@ | jump to kernel entry point + rts | enter kernel at address on stack *** + + +| A do-nothing MMU root pointer (includes the following long as well) + +nullrp: .long 0x7fff0001 +zero: .long 0 + + +"); + +void +usage() +{ + fprintf(stderr, "usage: %s [-abhkptADSV] [-c machine] [-m mem] [-n mode] kernel\n", + program_name); + exit(1); +} + + +void +verbose_usage() +{ + fprintf(stderr, " +NAME +\t%s - loads NetBSD from amiga dos. +SYNOPSIS +\t%s [-abhkptDSV] [-c machine] [-m mem] [-n flags] kernel +OPTIONS +\t-a Boot up to multiuser mode. +\t-b Ask for which root device. +\t Its possible to have multiple roots and choose between them. +\t-c Set machine type. [e.g 3000] +\t-h This help message. +\t-k Reserve the first 4M of fast mem [Some one else +\t is going to have to answer what that it is used for]. +\t-m Tweak amount of available memory, for finding minimum amount +\t of memory required to run. Sets fastmem size to specified +\t size in Kbytes. +\t-n Enable multiple non-contiguous memory: value = 0 (disabled), +\t 1 (two segments), 2 (all avail segments), 3 (same as 2?). +\t-p Use highest priority fastmem segement instead of the largest +\t segment. The higher priority segment is usually faster +\t (i.e. 32 bit memory), but some people have smaller amounts +\t of 32 bit memory. +\t-t This is a *test* option. It prints out the memory +\t list information being passed to the kernel and also +\t exits without actually starting NetBSD. +\t-S Include kernel symbol table. +\t-D Enter debugger +\t-A Use AGA display mode, if available. +\t-V Version of loadbsd program. +HISTORY +\tThis version supports Kernel version 720 +\n", + program_name, program_name); + exit(1); +} + + +void +_Vdomessage(doexit, eval, doerrno, fmt, args) + int doexit, doerrno, eval; + const char *fmt; + va_list args; +{ + fprintf(stderr, "%s: ", program_name); + if (fmt) { + vfprintf(stderr, fmt, args); + fprintf(stderr, ": "); + } + if (doerrno && errno < sys_nerr) { + fprintf(stderr, "%s", strerror(errno)); + if (errno == EINTR || errno == 0) { + int sigs; + sigpending((sigset_t *)&sigs); + printf("%x\n", sigs); + } + } + fprintf(stderr, "\n"); + if (doexit) + exit(eval); +} + +void +err(int eval, const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + _Vdomessage(1, eval, 1, fmt, ap); + /*NOTREACHED*/ +} + +void +errx(int eval, const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + _Vdomessage(1, eval, 0, fmt, ap); + /*NOTREACHED*/ +} + +void +warn(const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + _Vdomessage(0, 0, 1, fmt, ap); + va_end(ap); +} + +void +warnx(const char *fmt, ...) +{ + va_list ap; + va_start(ap, fmt); + _Vdomessage(0, 0, 0, fmt, ap); + va_end(ap); +} diff --git a/sys/arch/amiga/stand/loadkmap/din-kbdmap.c b/sys/arch/amiga/stand/loadkmap/din-kbdmap.c new file mode 100644 index 00000000000..1164ab6497b --- /dev/null +++ b/sys/arch/amiga/stand/loadkmap/din-kbdmap.c @@ -0,0 +1,484 @@ +/* $NetBSD: din-kbdmap.c,v 1.4 1995/10/09 14:27:18 chopps Exp $ */ + +#include "../../dev/kbdmap.h" + +/* define a default keymap. This can be changed by keyboard ioctl's + (later at least..) */ + +/* mode shortcuts: */ +#define S KBD_MODE_STRING +#define DG (KBD_MODE_DEAD | KBD_MODE_GRAVE) +#define DA (KBD_MODE_DEAD | KBD_MODE_ACUTE) +#define DC (KBD_MODE_DEAD | KBD_MODE_CIRC) +#define DT (KBD_MODE_DEAD | KBD_MODE_TILDE) +#define DD (KBD_MODE_DEAD | KBD_MODE_DIER) +#define C KBD_MODE_CAPS +#define K KBD_MODE_KPAD + +struct kbdmap kbdmap = { + /* normal map */ + { + 0, '`', /* 0x00 */ + 0, '1', + 0, '2', + 0, '3', + 0, '4', + 0, '5', + 0, '6', + 0, '7', + 0, '8', /* 0x08 */ + 0, '9', + 0, '0', + 0, 'ß', + DA, '\'', + 0, '\\', + 0, 0, + K, '0', + C, 'q', /* 0x10 */ + C, 'w', + C, 'e', + C, 'r', + C, 't', + C, 'z', + C, 'u', + C, 'i', + C, 'o', /* 0x18 */ + C, 'p', + C, 'ü', + 0, '+', + 0, 0, + K, '1', + K, '2', + K, '3', + C, 'a', /* 0x20 */ + C, 's', + C, 'd', + C, 'f', + C, 'g', + C, 'h', + C, 'j', + C, 'k', + C, 'l', /* 0x28 */ + C, 'ö', + C, 'ä', + 0, '#', + 0, 0, + K, '4', + K, '5', + K, '6', + 0, '<', /* 0x30 */ + C, 'y', + C, 'x', + C, 'c', + C, 'v', + C, 'b', + C, 'n', + C, 'm', + 0, ',', /* 0x38 */ + 0, '.', + 0, '-', + 0, 0, + K, '.', + K, '7', + K, '8', + K, '9', + 0, ' ', /* 0x40 */ + 0, DEL, /* really BS, DEL & BS swapped */ + 0, '\t', + K, '\r', /* enter */ + 0, '\r', /* return */ + 0, ESC, + 0, '\b', /* really DEL, BS & DEL swapped */ + 0, 0, + 0, 0, /* 0x48 */ + 0, 0, + K, '-', + 0, 0, + S, 0x00, /* now it gets hairy.. CRSR UP */ + S, 0x04, /* CRSR DOWN */ + S, 0x08, /* CRSR RIGHT */ + S, 0x0C, /* CRSR LEFT */ + S, 0x10, /* 0x50 F1 */ + S, 0x15, /* F2 */ + S, 0x1A, /* F3 */ + S, 0x1F, /* F4 */ + S, 0x24, /* F5 */ + S, 0x29, /* F6 */ + S, 0x2E, /* F7 */ + S, 0x33, /* F8 */ + S, 0x38, /* 0x58 F9 */ + S, 0x3D, /* F10 */ + K, '[', + K, ']', + K, '/', + K, '*', + K, '+', + S, 0x42, /* HELP */ + }, + + /* shifted map */ + { + 0, '~', /* 0x00 */ + 0, '!', + 0, '"', + 0, '§', + 0, '$', + 0, '%', + 0, '&', + 0, '/', + 0, '(', /* 0x08 */ + 0, ')', + 0, '=', + 0, '?', + DG, '`', + 0, '|', + 0, 0, + K, '0', + C, 'Q', /* 0x10 */ + C, 'W', + C, 'E', + C, 'R', + C, 'T', + C, 'Z', + C, 'U', + C, 'I', + C, 'O', /* 0x18 */ + C, 'P', + C, 'Ü', + 0, '*', + 0, 0, + K, '1', + K, '2', + K, '3', + C, 'A', /* 0x20 */ + C, 'S', + C, 'D', + C, 'F', + C, 'G', + C, 'H', + C, 'J', + C, 'K', + C, 'L', /* 0x28 */ + C, 'Ö', + C, 'Ä', + 0, '^', + 0, 0, + K, '4', + K, '5', + K, '6', + 0, '>', /* 0x30 */ + C, 'Y', + C, 'X', + C, 'C', + C, 'V', + C, 'B', + C, 'N', + C, 'M', + 0, ';', /* 0x38 */ + 0, ':', + 0, '_', + 0, 0, + K, '.', + K, '7', + K, '8', + K, '9', + 0, ' ', /* 0x40 */ + 0, DEL, /* really BS, DEL & BS swapped */ + S, 0x99, /* shift TAB */ + K, '\r', /* enter */ + 0, '\r', /* return */ + 0, ESC, + 0, '\b', /* really DEL, BS & DEL swapped */ + 0, 0, + 0, 0, /* 0x48 */ + 0, 0, + K, '-', + 0, 0, + S, 0x47, /* shift CRSR UP */ + S, 0x4C, /* shift CRSR DOWN */ + S, 0x51, /* shift CRSR RIGHT */ + S, 0x57, /* shift CRSR LEFT */ + S, 0x5D, /* 0x50 shift F1 */ + S, 0x63, /* shift F2 */ + S, 0x69, /* shift F3 */ + S, 0x6F, /* shift F4 */ + S, 0x75, /* shift F5 */ + S, 0x7B, /* shift F6 */ + S, 0x81, /* shift F7 */ + S, 0x87, /* shift F8 */ + S, 0x8D, /* 0x58 shift F9 */ + S, 0x93, /* shift F10 */ + K, '{', + K, '}', + K, '/', + K, '*', + K, '+', + S, 0x42, /* HELP (no special shift code) */ + }, + + + /* alt map */ + { + 0, '`', /* 0x00 */ + 0, '¹', + 0, '@', + 0, '³', + 0, '°', + 0, '¼', + 0, '½', + 0, '¾', + 0, '·', /* 0x08 */ + 0, '«', + 0, '»', + 0, '-', + 0, '=', + 0, '\\', + 0, 0, + K, '0', + C, 'å', /* 0x10 */ + 0, '°', + 0, '©', + 0, '®', + C, 'þ', + 0, '¤', + 0, 'µ', + 0, '¡', + C, 'ø', /* 0x18 */ + 0, '¶', + 0, '[', + 0, ']', + 0, 0, + K, '1', + K, '2', + K, '3', + C, 'æ', /* 0x20 */ + 0, 'ß', + C, 'ð', + DA, '\'', + DG, '`', + DC, '^', + DT, '~', + DD, '¨', + 0, '£', /* 0x28 */ + 0, ';', + 0, '\'', + 0, 0, + 0, 0, + K, '4', + K, '5', + K, '6', + 0, '<', /* 0x30 */ + 0, '±', + 0, '×', + C, 'ç', + 0, 'ª', + 0, 'º', + 0, '', + 0, '¸', + 0, ',', /* 0x38 */ + 0, '.', + 0, '/', + 0, 0, + K, '.', + K, '7', + K, '8', + K, '9', + 0, ' ', /* 0x40 */ + 0, DEL, /* really BS, DEL & BS swapped */ + 0, '\t', + K, '\r', /* enter */ + 0, '\r', /* return */ + S, 0x9d, /* CSI */ + 0, '\b', /* really DEL, BS & DEL swapped */ + 0, 0, + 0, 0, /* 0x48 */ + 0, 0, + K, '-', + 0, 0, + S, 0x00, /* now it gets hairy.. CRSR UP */ + S, 0x04, /* CRSR DOWN */ + S, 0x08, /* CRSR RIGHT */ + S, 0x0C, /* CRSR LEFT */ + S, 0x10, /* 0x50 F1 */ + S, 0x15, /* F2 */ + S, 0x1A, /* F3 */ + S, 0x1F, /* F4 */ + S, 0x24, /* F5 */ + S, 0x29, /* F6 */ + S, 0x2E, /* F7 */ + S, 0x33, /* F8 */ + S, 0x38, /* 0x58 F9 */ + S, 0x3D, /* F10 */ + K, '[', + K, ']', + K, '/', + K, '*', + K, '+', + S, 0x42, /* HELP */ + }, + + /* shift alt map */ + { + 0, '~', /* 0x00 */ + 0, '!', + 0, '²', + 0, '#', + 0, '¢', + 0, '%', + 0, '^', + 0, '&', + 0, '*', /* 0x08 */ + 0, '(', + 0, ')', + 0, '_', + 0, '+', + 0, '|', + 0, 0, + K, '0', + C, 'Å', /* 0x10 */ + 0, '°', + 0, '©', + 0, '®', + C, 'Þ', + 0, '¥', + 0, 'µ', + 0, '¦', + C, 'Ø', /* 0x18 */ + 0, '¶', + 0, '{', + 0, '}', + 0, 0, + K, '1', + K, '2', + K, '3', + C, 'Æ', /* 0x20 */ + 0, '§', + C, 'Ð', + DA, '\'', + DG, '`', + DC, '^', + DT, '~', + DD, '¨', + 0, '£', /* 0x28 */ + 0, ':', + 0, '"', + 0, '^', + 0, 0, + K, '4', + K, '5', + K, '6', + 0, '>', /* 0x30 */ + 0, '¬', + 0, '÷', + C, 'Ç', + 0, 'ª', + 0, 'º', + 0, '¯', + 0, '¿', + 0, '<', /* 0x38 */ + 0, '>', + 0, '?', + 0, 0, + K, '.', + K, '7', + K, '8', + K, '9', + 0, ' ', /* 0x40 */ + 0, DEL, /* really BS, DEL & BS swapped */ + 0, '\t', + K, '\r', /* enter */ + 0, '\r', /* return */ + S, 0x9d, /* CSI */ + 0, '\b', /* really DEL, BS & DEL swapped */ + 0, 0, + 0, 0, /* 0x48 */ + 0, 0, + K, '-', + 0, 0, + S, 0x00, /* now it gets hairy.. CRSR UP */ + S, 0x04, /* CRSR DOWN */ + S, 0x08, /* CRSR RIGHT */ + S, 0x0C, /* CRSR LEFT */ + S, 0x10, /* 0x50 F1 */ + S, 0x15, /* F2 */ + S, 0x1A, /* F3 */ + S, 0x1F, /* F4 */ + S, 0x24, /* F5 */ + S, 0x29, /* F6 */ + S, 0x2E, /* F7 */ + S, 0x33, /* 0x58 F8 */ + S, 0x38, /* F9 */ + S, 0x3D, /* F10 */ + K, '{', + K, '}', + K, '/', + K, '*', + K, '+', + S, 0x42, /* HELP */ + }, + + { + /* string table. If there's a better way to get the offsets into the + above table, please tell me.. + + NOTE: save yourself and others a lot of grief by *not* using + CSI == 0x9b, using the two-character sequence gives + much less trouble, especially in GNU-Emacs.. */ + + 3, ESC, '[', 'A', /* 0x00: CRSR UP */ + 3, ESC, '[', 'B', /* 0x04: CRSR DOWN */ + 3, ESC, '[', 'C', /* 0x08: CRSR RIGHT */ + 3, ESC, '[', 'D', /* 0x0C: CRSR LEFT */ + 4, ESC, '[', '0', '~', /* 0x10: F1 */ + 4, ESC, '[', '1', '~', /* 0x15: F2 */ + 4, ESC, '[', '2', '~', /* 0x1A: F3 */ + 4, ESC, '[', '3', '~', /* 0x1F: F4 */ + 4, ESC, '[', '4', '~', /* 0x24: F5 */ + 4, ESC, '[', '5', '~', /* 0x29: F6 */ + 4, ESC, '[', '6', '~', /* 0x2E: F7 */ + 4, ESC, '[', '7', '~', /* 0x33: F8 */ + 4, ESC, '[', '8', '~', /* 0x38: F9 */ + 4, ESC, '[', '9', '~', /* 0x3D: F10 */ + 4, ESC, '[', '?', '~', /* 0x42: HELP */ + + 4, ESC, '[', 'T', '~', /* 0x47: shift CRSR UP */ + 4, ESC, '[', 'S', '~', /* 0x4C: shift CRSR DOWN */ + 5, ESC, '[', ' ', '@', '~', /* 0x51: shift CRSR RIGHT */ + 5, ESC, '[', ' ', 'A', '~', /* 0x57: shift CRSR LEFT */ + 5, ESC, '[', '1', '0', '~', /* 0x5D: shift F1 */ + 5, ESC, '[', '1', '1', '~', /* 0x63: shift F2 */ + 5, ESC, '[', '1', '2', '~', /* 0x69: shift F3 */ + 5, ESC, '[', '1', '3', '~', /* 0x6F: shift F4 */ + 5, ESC, '[', '1', '4', '~', /* 0x75: shift F5 */ + 5, ESC, '[', '1', '5', '~', /* 0x7B: shift F6 */ + 5, ESC, '[', '1', '6', '~', /* 0x81: shift F7 */ + 5, ESC, '[', '1', '7', '~', /* 0x87: shift F8 */ + 5, ESC, '[', '1', '8', '~', /* 0x8D: shift F9 */ + 5, ESC, '[', '1', '9', '~', /* 0x93: shift F10 */ + 3, ESC, '[', 'Z', /* 0x99: shift TAB */ + 2, ESC, '[', /* 0x9D: alt ESC == CSI */ + }, +}; + +unsigned char acctable[KBD_NUM_ACC][64] = { + { "@ÀBCDÈFGHÌJKLMNÒPQRSTÙVWXYZ[\\]^_" + "`àbcdèfghìjklmnòpqrstùvwxyz{|}~\177"}, /* KBD_ACC_GRAVE */ + + { "@ÁBCDÉFGHÍJKLMNÓPQRSTÚVWXYZ[\\]^_" + "`ábcdéfghíjklmnópqrstúvwxyz{|}~\177"}, /* KBD_ACC_ACUTE */ + + { "@ÂBCDÊFGHÎJKLMNÔPQRSTÛVWXYZ[\\]^_" + "`âbcdêfghîjklmnôpqrstûvwxyz{|}~\177"}, /* KBD_ACC_CIRC */ + + { "@ÃBCDEFGHIJKLMÑÕPQRSTUVWXYZ[\\]^_" + "`ãbcdefghijklmñÕpqrstuvwxyz{|}~\177"}, /* KBD_ACC_TILDE */ + + { "@ÄBCDËFGHÏJKLMNÖPQRSTÜVWXYZ[\\]^_" + "`äbcdëfghïjklmnöpqrstüvwxyz{|}~\177"}, /* KBD_ACC_DIER */ +}; + + +main() +{ + write (1, &kbdmap, sizeof (kbdmap)); +} diff --git a/sys/arch/amiga/stand/loadkmap/loadkmap.c b/sys/arch/amiga/stand/loadkmap/loadkmap.c new file mode 100644 index 00000000000..72a6c7b7e3f --- /dev/null +++ b/sys/arch/amiga/stand/loadkmap/loadkmap.c @@ -0,0 +1,67 @@ +/* $NetBSD: loadkmap.c,v 1.4 1994/10/26 02:07:09 cgd Exp $ */ + +#include <sys/types.h> +#include <sys/stat.h> +#include <sys/ioctl.h> +#include "../../dev/iteioctl.h" +#include "../../dev/kbdmap.h" +#include <stdio.h> + + +void load_kmap __P((const char *)); +void dump_kmap(); + +int +main(argc, argv) + int argc; + char *argv[]; +{ + if (argc > 2) + { + fprintf (stderr, "%s keymap\n", argv[0]); + exit (1); + } + + if (argc == 1) + dump_kmap (); + else + load_kmap (argv[1]); + + exit (0); +} + + +void +load_kmap (file) + const char *file; +{ + int fd; + char buf[sizeof (struct kbdmap)]; + + if ((fd = open (file, 0)) >= 0) + { + if (read (fd, buf, sizeof (buf)) == sizeof (buf)) + { + if (ioctl (0, ITEIOCSKMAP, buf) == 0) + return; + else + perror ("ITEIOCSKMAP"); + } + else + perror ("read kmap"); + + close (fd); + } + else + perror ("open kmap"); +} + +void +dump_kmap() +{ + char buf[sizeof (struct kbdmap)]; + if (ioctl (0, ITEIOCGKMAP, buf) == 0) + write (1, buf, sizeof (buf)); + else + perror ("ITEIOCGKMAP"); +} diff --git a/sys/arch/amiga/stand/loadkmap/us-kbdmap.c b/sys/arch/amiga/stand/loadkmap/us-kbdmap.c new file mode 100644 index 00000000000..81fe2eb2e46 --- /dev/null +++ b/sys/arch/amiga/stand/loadkmap/us-kbdmap.c @@ -0,0 +1,481 @@ +/* $NetBSD: us-kbdmap.c,v 1.3 1994/10/26 02:07:10 cgd Exp $ */ + +#include "../../dev/kbdmap.h" + +/* define a default keymap. This can be changed by keyboard ioctl's + (later at least..) */ + +/* mode shortcuts: */ +#define S KBD_MODE_STRING +#define DG (KBD_MODE_DEAD | KBD_MODE_GRAVE) +#define DA (KBD_MODE_DEAD | KBD_MODE_ACUTE) +#define DC (KBD_MODE_DEAD | KBD_MODE_CIRC) +#define DT (KBD_MODE_DEAD | KBD_MODE_TILDE) +#define DD (KBD_MODE_DEAD | KBD_MODE_DIER) +#define C KBD_MODE_CAPS +#define K KBD_MODE_KPAD + +struct kbdmap kbdmap = { + /* normal map */ + { + 0, '`', /* 0x00 */ + 0, '1', + 0, '2', + 0, '3', + 0, '4', + 0, '5', + 0, '6', + 0, '7', + 0, '8', /* 0x08 */ + 0, '9', + 0, '0', + 0, '-', + 0, '=', + 0, '\\', + 0, 0, + K, '0', + C, 'q', /* 0x10 */ + C, 'w', + C, 'e', + C, 'r', + C, 't', + C, 'y', + C, 'u', + C, 'i', + C, 'o', /* 0x18 */ + C, 'p', + 0, '[', + 0, ']', + 0, 0, + K, '1', + K, '2', + K, '3', + C, 'a', /* 0x20 */ + C, 's', + C, 'd', + C, 'f', + C, 'g', + C, 'h', + C, 'j', + C, 'k', + C, 'l', /* 0x28 */ + 0, ';', + 0, '\'', + 0, 0, + 0, 0, + K, '4', + K, '5', + K, '6', + 0, 0, /* 0x30 */ + C, 'z', + C, 'x', + C, 'c', + C, 'v', + C, 'b', + C, 'n', + C, 'm', + 0, ',', /* 0x38 */ + 0, '.', + 0, '/', + 0, 0, + K, '.', + K, '7', + K, '8', + K, '9', + 0, ' ', /* 0x40 */ + 0, DEL, /* really BS, DEL & BS swapped */ + 0, '\t', + K, '\r', /* enter */ + 0, '\r', /* return */ + 0, ESC, + 0, '\b', /* really DEL, BS & DEL swapped */ + 0, 0, + 0, 0, /* 0x48 */ + 0, 0, + K, '-', + 0, 0, + S, 0x00, /* now it gets hairy.. CRSR UP */ + S, 0x04, /* CRSR DOWN */ + S, 0x08, /* CRSR RIGHT */ + S, 0x0C, /* CRSR LEFT */ + S, 0x10, /* 0x50 F1 */ + S, 0x15, /* F2 */ + S, 0x1A, /* F3 */ + S, 0x1F, /* F4 */ + S, 0x24, /* F5 */ + S, 0x29, /* F6 */ + S, 0x2E, /* F7 */ + S, 0x33, /* 0x58 F8 */ + S, 0x38, /* F9 */ + S, 0x3D, /* F10 */ + K, '(', + K, ')', + K, '/', + K, '*', + S, 0x42, /* HELP */ + }, + + /* shifted map */ + { + 0, '~', /* 0x00 */ + 0, '!', + 0, '@', + 0, '#', + 0, '$', + 0, '%', + 0, '^', + 0, '&', + 0, '*', /* 0x08 */ + 0, '(', + 0, ')', + 0, '_', + 0, '+', + 0, '|', + 0, 0, + K, '0', + C, 'Q', /* 0x10 */ + C, 'W', + C, 'E', + C, 'R', + C, 'T', + C, 'Y', + C, 'U', + C, 'I', + C, 'O', /* 0x18 */ + C, 'P', + 0, '{', + 0, '}', + 0, 0, + K, '1', + K, '2', + K, '3', + C, 'A', /* 0x20 */ + C, 'S', + C, 'D', + C, 'F', + C, 'G', + C, 'H', + C, 'J', + C, 'K', + C, 'L', /* 0x28 */ + 0, ':', + 0, '\"', + 0, 0, + 0, 0, + K, '4', + K, '5', + K, '6', + 0, 0, /* 0x30 */ + C, 'Z', + C, 'X', + C, 'C', + C, 'V', + C, 'B', + C, 'N', + C, 'M', + 0, '<', /* 0x38 */ + 0, '>', + 0, '?', + 0, 0, + K, '.', + K, '7', + K, '8', + K, '9', + 0, ' ', /* 0x40 */ + 0, DEL, /* really BS, DEL & BS swapped */ + S, 0x99, /* shift TAB */ + K, '\r', /* enter */ + 0, '\r', /* return */ + 0, ESC, + 0, '\b', /* really DEL, BS & DEL swapped */ + 0, 0, + 0, 0, /* 0x48 */ + 0, 0, + K, '-', + 0, 0, + S, 0x47, /* shift CRSR UP */ + S, 0x4C, /* shift CRSR DOWN */ + S, 0x51, /* shift CRSR RIGHT */ + S, 0x57, /* shift CRSR LEFT */ + S, 0x5D, /* 0x50 shift F1 */ + S, 0x63, /* shift F2 */ + S, 0x69, /* shift F3 */ + S, 0x6F, /* shift F4 */ + S, 0x75, /* shift F5 */ + S, 0x7B, /* shift F6 */ + S, 0x81, /* shift F7 */ + S, 0x87, /* 0x58 shift F8 */ + S, 0x8D, /* shift F9 */ + S, 0x93, /* shift F10 */ + K, '(', + K, ')', + K, '/', + K, '*', + S, 0x42, /* HELP (no special shift code) */ + }, + + + /* alt map */ + { + 0, '`', /* 0x00 */ + 0, '¹', + 0, '²', + 0, '³', + 0, '¢', + 0, '¼', + 0, '½', + 0, '¾', + 0, '·', /* 0x08 */ + 0, '«', + 0, '»', + 0, '-', + 0, '=', + 0, '\\', + 0, 0, + K, '0', + C, 'å', /* 0x10 */ + 0, '°', + 0, '©', + 0, '®', + C, 'þ', + 0, '¤', + 0, 'µ', + 0, '¡', + C, 'ø', /* 0x18 */ + 0, '¶', + 0, '[', + 0, ']', + 0, 0, + K, '1', + K, '2', + K, '3', + C, 'æ', /* 0x20 */ + 0, 'ß', + C, 'ð', + DA, '´', + DG, '`', + DC, '^', + DT, '~', + DD, '¨', + 0, '£', /* 0x28 */ + 0, ';', + 0, '\'', + 0, 0, + 0, 0, + K, '4', + K, '5', + K, '6', + 0, 0, /* 0x30 */ + 0, '±', + 0, '×', + C, 'ç', + 0, 'ª', + 0, 'º', + 0, '', + 0, '¸', + 0, ',', /* 0x38 */ + 0, '.', + 0, '/', + 0, 0, + K, '.', + K, '7', + K, '8', + K, '9', + 0, ' ', /* 0x40 */ + 0, DEL, /* really BS, DEL & BS swapped */ + 0, '\t', + K, '\r', /* enter */ + 0, '\r', /* return */ + S, 0x9d, /* CSI */ + 0, '\b', /* really DEL, BS & DEL swapped */ + 0, 0, + 0, 0, /* 0x48 */ + 0, 0, + K, '-', + 0, 0, + S, 0x00, /* now it gets hairy.. CRSR UP */ + S, 0x04, /* CRSR DOWN */ + S, 0x08, /* CRSR RIGHT */ + S, 0x0C, /* CRSR LEFT */ + S, 0x10, /* 0x50 F1 */ + S, 0x15, /* F2 */ + S, 0x1A, /* F3 */ + S, 0x1F, /* F4 */ + S, 0x24, /* F5 */ + S, 0x29, /* F6 */ + S, 0x2E, /* F7 */ + S, 0x33, /* 0x58 F8 */ + S, 0x38, /* F9 */ + S, 0x3D, /* F10 */ + K, '(', + K, ')', + K, '/', + K, '*', + S, 0x42, /* HELP */ + }, + + /* shift alt map */ + { + 0, '~', /* 0x00 */ + 0, '!', + 0, '@', + 0, '#', + 0, '$', + 0, '%', + 0, '^', + 0, '&', + 0, '*', /* 0x08 */ + 0, '(', + 0, ')', + 0, '_', + 0, '+', + 0, '|', + 0, 0, + K, '0', + C, 'Å', /* 0x10 */ + 0, '°', + 0, '©', + 0, '®', + C, 'Þ', + 0, '¥', + 0, 'µ', + 0, '¦', + C, 'Ø', /* 0x18 */ + 0, '¶', + 0, '[', + 0, ']', + 0, 0, + K, '1', + K, '2', + K, '3', + C, 'Æ', /* 0x20 */ + 0, '§', + C, 'Ð', + DA, '´', + DG, '`', + DC, '^', + DT, '~', + DD, '¨', + 0, '£', /* 0x28 */ + 0, ';', + 0, '\'', + 0, 0, + 0, 0, + K, '4', + K, '5', + K, '6', + 0, 0, /* 0x30 */ + 0, '±', + 0, '×', + C, 'ç', + 0, 'ª', + 0, 'º', + 0, '', + 0, '¸', + 0, ',', /* 0x38 */ + 0, '.', + 0, '/', + 0, 0, + K, '.', + K, '7', + K, '8', + K, '9', + 0, ' ', /* 0x40 */ + 0, DEL, /* really BS, DEL & BS swapped */ + 0, '\t', + K, '\r', /* enter */ + 0, '\r', /* return */ + S, 0x9d, /* CSI */ + 0, '\b', /* really DEL, BS & DEL swapped */ + 0, 0, + 0, 0, /* 0x48 */ + 0, 0, + K, '-', + 0, 0, + S, 0x00, /* now it gets hairy.. CRSR UP */ + S, 0x04, /* CRSR DOWN */ + S, 0x08, /* CRSR RIGHT */ + S, 0x0C, /* CRSR LEFT */ + S, 0x10, /* 0x50 F1 */ + S, 0x15, /* F2 */ + S, 0x1A, /* F3 */ + S, 0x1F, /* F4 */ + S, 0x24, /* F5 */ + S, 0x29, /* F6 */ + S, 0x2E, /* F7 */ + S, 0x33, /* 0x58 F8 */ + S, 0x38, /* F9 */ + S, 0x3D, /* F10 */ + K, '(', + K, ')', + K, '/', + K, '*', + S, 0x42, /* HELP */ + }, + + { + /* string table. If there's a better way to get the offsets into the + above table, please tell me.. + + NOTE: save yourself and others a lot of grief by *not* using + CSI == 0x9b, using the two-character sequence gives + much less trouble, especially in GNU-Emacs.. */ + + 3, ESC, '[', 'A', /* 0x00: CRSR UP */ + 3, ESC, '[', 'B', /* 0x04: CRSR DOWN */ + 3, ESC, '[', 'C', /* 0x08: CRSR RIGHT */ + 3, ESC, '[', 'D', /* 0x0C: CRSR LEFT */ + 4, ESC, '[', '0', '~', /* 0x10: F1 */ + 4, ESC, '[', '1', '~', /* 0x15: F2 */ + 4, ESC, '[', '2', '~', /* 0x1A: F3 */ + 4, ESC, '[', '3', '~', /* 0x1F: F4 */ + 4, ESC, '[', '4', '~', /* 0x24: F5 */ + 4, ESC, '[', '5', '~', /* 0x29: F6 */ + 4, ESC, '[', '6', '~', /* 0x2E: F7 */ + 4, ESC, '[', '7', '~', /* 0x33: F8 */ + 4, ESC, '[', '8', '~', /* 0x38: F9 */ + 4, ESC, '[', '9', '~', /* 0x3D: F10 */ + 4, ESC, '[', '?', '~', /* 0x42: HELP */ + + 4, ESC, '[', 'T', '~', /* 0x47: shift CRSR UP */ + 4, ESC, '[', 'S', '~', /* 0x4C: shift CRSR DOWN */ + 5, ESC, '[', ' ', '@', '~', /* 0x51: shift CRSR RIGHT */ + 5, ESC, '[', ' ', 'A', '~', /* 0x57: shift CRSR LEFT */ + 5, ESC, '[', '1', '0', '~', /* 0x5D: shift F1 */ + 5, ESC, '[', '1', '1', '~', /* 0x63: shift F2 */ + 5, ESC, '[', '1', '2', '~', /* 0x69: shift F3 */ + 5, ESC, '[', '1', '3', '~', /* 0x6F: shift F4 */ + 5, ESC, '[', '1', '4', '~', /* 0x75: shift F5 */ + 5, ESC, '[', '1', '5', '~', /* 0x7B: shift F6 */ + 5, ESC, '[', '1', '6', '~', /* 0x81: shift F7 */ + 5, ESC, '[', '1', '7', '~', /* 0x87: shift F8 */ + 5, ESC, '[', '1', '8', '~', /* 0x8D: shift F9 */ + 5, ESC, '[', '1', '9', '~', /* 0x93: shift F10 */ + 3, ESC, '[', 'Z', /* 0x99: shift TAB */ + 2, ESC, '[', /* 0x9d: alt ESC == CSI */ + }, +}; + +unsigned char acctable[KBD_NUM_ACC][64] = { + { "@ÀBCDÈFGHÌJKLMNÒPQRSTÙVWXYZ[\\]^_" + "`àbcdèfghìjklmnòpqrstùvwxyz{|}~\177"}, /* KBD_ACC_GRAVE */ + + { "@ÁBCDÉFGHÍJKLMNÓPQRSTÚVWXYZ[\\]^_" + "`ábcdéfghíjklmnópqrstúvwxyz{|}~\177"}, /* KBD_ACC_ACUTE */ + + { "@ÂBCDÊFGHÎJKLMNÔPQRSTÛVWXYZ[\\]^_" + "`âbcdêfghîjklmnôpqrstûvwxyz{|}~\177"}, /* KBD_ACC_CIRC */ + + { "@ÃBCDEFGHIJKLMÑÕPQRSTUVWXYZ[\\]^_" + "`ãbcdefghijklmñÕpqrstuvwxyz{|}~\177"}, /* KBD_ACC_TILDE */ + + { "@ÄBCDËFGHÏJKLMNÖPQRSTÜVWXYZ[\\]^_" + "`äbcdëfghïjklmnöpqrstüvwxyz{|}~\177"}, /* KBD_ACC_DIER */ +}; + + + +main() +{ + write (1, &kbdmap, sizeof (kbdmap)); +} |