diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1995-10-18 08:53:40 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1995-10-18 08:53:40 +0000 |
commit | d6583bb2a13f329cf0332ef2570eb8bb8fc0e39c (patch) | |
tree | ece253b876159b39c620e62b6c9b1174642e070e /sys/arch/atari/stand |
initial import of NetBSD tree
Diffstat (limited to 'sys/arch/atari/stand')
-rw-r--r-- | sys/arch/atari/stand/binpatch/Makefile | 9 | ||||
-rw-r--r-- | sys/arch/atari/stand/binpatch/binpatch.8 | 96 | ||||
-rw-r--r-- | sys/arch/atari/stand/binpatch/binpatch.c | 241 | ||||
-rw-r--r-- | sys/arch/atari/stand/chg_pid/chg_pid.c | 240 | ||||
-rw-r--r-- | sys/arch/atari/stand/loadbsd/loadbsd.c | 438 | ||||
-rw-r--r-- | sys/arch/atari/stand/loadbsd/loader.h | 89 | ||||
-rw-r--r-- | sys/arch/atari/stand/loadkmap/ge-kbdmap.c | 208 | ||||
-rw-r--r-- | sys/arch/atari/stand/loadkmap/loadkmap.c | 74 | ||||
-rw-r--r-- | sys/arch/atari/stand/loadkmap/uk-kbdmap.c | 141 | ||||
-rw-r--r-- | sys/arch/atari/stand/loadkmap/us-kbdmap.c | 157 | ||||
-rw-r--r-- | sys/arch/atari/stand/rawwrite/rawwrite.c | 115 |
11 files changed, 1808 insertions, 0 deletions
diff --git a/sys/arch/atari/stand/binpatch/Makefile b/sys/arch/atari/stand/binpatch/Makefile new file mode 100644 index 00000000000..f8416da4a33 --- /dev/null +++ b/sys/arch/atari/stand/binpatch/Makefile @@ -0,0 +1,9 @@ +# $NetBSD: Makefile,v 1.2 1995/08/29 20:26:39 leo Exp $ + +PROG=binpatch +MAN=binpatch.8 + +BINDIR=/sbin +LDFLAGS+=-static + +.include <bsd.prog.mk> diff --git a/sys/arch/atari/stand/binpatch/binpatch.8 b/sys/arch/atari/stand/binpatch/binpatch.8 new file mode 100644 index 00000000000..4d0017b3eb4 --- /dev/null +++ b/sys/arch/atari/stand/binpatch/binpatch.8 @@ -0,0 +1,96 @@ +.\" $NetBSD: binpatch.8,v 1.1.1.1 1995/03/26 07:12:05 leo 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 atari +.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/atari/stand/binpatch/binpatch.c b/sys/arch/atari/stand/binpatch/binpatch.c new file mode 100644 index 00000000000..79f25f72c0a --- /dev/null +++ b/sys/arch/atari/stand/binpatch/binpatch.c @@ -0,0 +1,241 @@ +/* $NetBSD: binpatch.c,v 1.1.1.1 1995/03/26 07:12:04 leo 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. + */ + +#include <sys/types.h> +#include <a.out.h> +#include <stdio.h> + +extern char *optarg; +extern int optind; + +volatile void error (); + +int test = 1; +int testbss; +char foo = 23; + + +int +main(argc, argv) + int argc; + char *argv[]; +{ + struct exec e; + int c; + u_long addr = 0, offset = 0; + u_long replace = 0, do_replace = 0; + char *symbol = 0; + char size = 4; /* default to long */ + char *fname; + int fd; + int type, off; + u_long lval; + u_short sval; + u_char cval; + + + while ((c = getopt (argc, argv, "a:bwlr:s:o:")) != EOF) + switch (c) + { + 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; + break; + + case 'w': + size = 2; + break; + + case 'l': + size = 4; + 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; + } + + 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]; + nl[0].n_un.n_name = symbol; + nl[1].n_un.n_name = 0; + if (nlist (fname, nl) != 0) + 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; + } + + + 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; + } + } + + close (fd); +} + + + +volatile void error (str) + char *str; +{ + fprintf (stderr, "%s\n", str); + exit (1); +} diff --git a/sys/arch/atari/stand/chg_pid/chg_pid.c b/sys/arch/atari/stand/chg_pid/chg_pid.c new file mode 100644 index 00000000000..926519b8075 --- /dev/null +++ b/sys/arch/atari/stand/chg_pid/chg_pid.c @@ -0,0 +1,240 @@ +/* $NetBSD: chg_pid.c,v 1.1.1.1 1995/03/26 07:12:04 leo Exp $ */ + +/* + * Copyright (c) 1995 L. Weppelman + * 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 Leo Weppelman. + * 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. + */ + +/* + * + * This program changes the partition id field (p_id) in the GEM + * partition info. NetBSD uses these id-fields to determine the kind + * of partition. Sensible id's to set are: + * NBU : NetBSD User partition + * NBR : NetBSD Root partition + * NBS : NetBSD Swap partition + * + * When NetBSD auto boots, the first 'NBR' partition found when scanning the + * SCSI-disks becomes the active root partition. The same goes for 'NBS'. + * Drives are scanned in 'SCSI-id' order. + */ +#include <stdio.h> +#include <osbind.h> + +/* + * Format of GEM root sector + */ +typedef struct gem_part { + u_char p_flg; /* bit 0 is in-use flag */ + u_char p_id[3]; /* id: GEM, BGM, XGM, UNX, MIX */ + u_long p_st; /* block where partition starts */ + u_long p_size; /* partition size */ +} GEM_PART; + +#define NGEM_PARTS 4 /* Max. partition infos in root sector */ + +typedef struct gem_root { + u_char fill[0x1c2]; /* Filler, can be boot code */ + u_long hd_siz; /* size of entire volume */ + GEM_PART parts[NGEM_PARTS]; /* see above */ + u_long bsl_st; /* start of bad-sector list */ + u_long bsl_cnt; /* nr. blocks in bad-sector list*/ + u_short csum; /* checksum correction */ +} GEM_ROOT; + +main(argc, argv) +int argc; +char *argv[]; +{ + int driveno = 0; + int partno = 0; + char *newname; + int c; + + if(argc != 4) + usage(); + driveno = atoi(argv[1]); + partno = atoi(argv[2]); + newname = argv[3]; + + printf("Note: drives start numbering at 0!\n"); + printf("About to change id of partition %d on drive %d to %s\n", + partno, driveno, newname); + printf("Are you sure (y/n)? "); + c = getchar(); + switch(c) { + case 'y': + case 'Y': + if(chg_tosparts(partno, driveno, newname)) + printf("Done\n"); + else printf("Partion number not found\n"); + break; + default : + printf("Aborted\n"); + } +} + +usage() +{ + printf("Usage: chg_pid <driveno> <partno> <newid>\n"); + exit(1); +} + +int chg_tosparts(chg_part, drive, newname) +int chg_part, drive; +char *newname; +{ + GEM_ROOT *g_root; + GEM_PART g_local[NGEM_PARTS]; + char buf[512]; + int pno = 1; + int i; + + /* + * Read root sector + */ + if(read_block(buf, 0, drive) == 0) { + fprintf(stderr, "Cannot read block 0\n"); + exit(1); + } + + /* + * Make local copy of partition info, we may need to re-use + * the buffer in case of 'XGM' partitions. + */ + g_root = (GEM_ROOT*)buf; + bcopy(g_root->parts, g_local, NGEM_PARTS*sizeof(GEM_PART)); + + + for(i = 0; i < NGEM_PARTS; i++) { + if(!(g_local[i].p_flg & 1)) + continue; + if(!strncmp(g_local[i].p_id, "XGM", 3)) { + int j; + daddr_t new_root = g_local[i].p_st; + + /* + * Loop through extended partition list + */ + for(;;) { + if(read_block(buf, new_root, drive) == 0) { + fprintf(stderr, "Cannot read block %d\n", new_root); + exit(1); + } + for(j = 0; j < NGEM_PARTS; j++) { + if(!(g_root->parts[j].p_flg & 1)) + continue; + if(!strncmp(g_root->parts[j].p_id, "XGM", 3)) { + new_root = g_local[i].p_st + g_root->parts[j].p_st; + break; + } + else { + if(pno == chg_part) { + change_it(pno,g_root->parts[j].p_id, newname); + if(write_block(buf, new_root, drive) == 0) { + fprintf(stderr, "Cannot write block %d\n", + new_root); + exit(1); + } + return(1); + } + pno++; + } + } + if(j == NGEM_PARTS) + break; + } + } + else { + if(pno == chg_part) { + /* + * Re-read block 0 + */ + if(read_block(buf, 0, drive) == 0) { + fprintf(stderr, "Cannot read block 0\n"); + exit(1); + } + change_it(pno, g_root->parts[i].p_id, newname); + set_csum(buf); + if(write_block(buf, 0, drive) == 0) { + fprintf(stderr, "Cannot write block 0\n"); + exit(1); + } + return(1); + } + pno++; + } + } + return(0); +} + +change_it(pno, p_id, newname) +int pno; +char *p_id, *newname; +{ + char s1[4], s2[4]; + + strncpy(s1, p_id, 3); + strncpy(s2, newname, 3); + s1[3] = s2[3] = '\0'; + printf("Changing partition %d: %s -> %s ...", pno, s1, s2); + p_id[0] = s2[0]; p_id[1] = s2[1]; p_id[2] = s2[2]; +} + +read_block(buf, blkno, drive) +void *buf; +int blkno; +int drive; +{ + if(Dmaread(blkno, 1, buf, drive + 8) != 0) + return(0); + return(1); +} + +write_block(buf, blkno, drive) +void *buf; +int blkno; +int drive; +{ + if(Dmawrite(blkno, 1, buf, drive + 8) != 0) + return(0); + return(1); +} + +set_csum(buf) +char *buf; +{ + unsigned short *p = (unsigned short *)buf; + unsigned short csum = 0; + int i; + + p[255] = 0; + for(i = 0; i < 256; i++) + csum += *p++; + *--p = (0x1234 - csum) & 0xffff; +} diff --git a/sys/arch/atari/stand/loadbsd/loadbsd.c b/sys/arch/atari/stand/loadbsd/loadbsd.c new file mode 100644 index 00000000000..afeed68a952 --- /dev/null +++ b/sys/arch/atari/stand/loadbsd/loadbsd.c @@ -0,0 +1,438 @@ +/* $NetBSD: loadbsd.c,v 1.9 1995/09/23 20:31:21 leo Exp $ */ + +/* + * Copyright (c) 1995 L. Weppelman + * 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 Leo Weppelman. + * 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. + */ + +/* + * NetBSD loader for the Atari-TT. + */ + +#include <stdio.h> +#include <a_out.h> +#include <fcntl.h> +#include <osbind.h> +#include <stdarg.h> +#include "loader.h" + +char *Progname; /* How are we called */ +int t_flag = 0; /* Just test, do not execute */ +int d_flag = 0; /* Output debugging output? */ +int s_flag = 0; /* St-ram only */ + +char version[] = "$Revision: 1.1 $"; + +/* + * Default name of kernel to boot, large enough to patch + */ +char kname[80] = "n:/netbsd"; + +static struct { + u_char *kp; /* 00: Kernel load address */ + long ksize; /* 04: Size of loaded kernel */ + u_long entry; /* 08: Kernel entry point */ + long stmem_size; /* 12: Size of st-ram */ + long ttmem_size; /* 16: Size of tt-ram */ + long cputype; /* 20: Type of cpu */ + long boothowto; /* 24: How to boot */ + long ttmem_start; /* 28: Start of tt-ram */ + long esym_loc; /* 32: End of symbol table */ +} kparam; + +void get_sys_info(void); +void error(char *fmt, ...); +void help(void); +void usage(void); +void start_kernel(void); +void do_exit(int); + +int main(argc, argv) +int argc; +char **argv; +{ + /* + * Option parsing + */ + extern int optind; + extern char *optarg; + int ch; + int fd; + long textsz, stringsz; + struct exec ehdr; + + Progname = argv[0]; + + kparam.boothowto = RB_SINGLE; + + while ((ch = getopt(argc, argv, "abdhstvDS:T:")) != EOF) { + switch(ch) { + case 'a': + kparam.boothowto &= ~(RB_SINGLE); + kparam.boothowto |= RB_AUTOBOOT; + break; + case 'b': + kparam.boothowto |= RB_ASKNAME; + break; + case 'd': + kparam.boothowto |= RB_KDB; + break; + case 'D': + d_flag = 1; + break; + case 's': + s_flag = 1; + break; + case 'S': + kparam.stmem_size = atoi(optarg); + break; + case 't': + t_flag = 1; + break; + case 'T': + kparam.ttmem_size = atoi(optarg); + break; + case 'v': + fprintf(stdout,"%s\r\n", version); + break; + case 'h': + help(); + default: + usage(); + } + } + argc -= optind; + argv += optind; + if(argc == 1) + strcpy(kname, argv[0]); + + /* + * Get system info to pass to NetBSD + */ + get_sys_info(); + + /* + * Find the kernel to boot and read it's exec-header + */ + if((fd = open(kname, O_RDONLY)) < 0) + error("Cannot open kernel '%s'", kname); + if(read(fd, &ehdr, sizeof(ehdr)) != sizeof(ehdr)) + error("Cannot read exec-header of '%s'", kname); + if((ehdr.a_magic & 0xffff) != NMAGIC) /* XXX */ + error("Not an NMAGIC file '%s'", kname); + + /* + * Extract various sizes from the kernel executable + */ + textsz = (ehdr.a_text + __LDPGSZ - 1) & ~(__LDPGSZ - 1); + kparam.esym_loc = 0; + kparam.ksize = textsz + ehdr.a_data + ehdr.a_bss; + kparam.entry = ehdr.a_entry; + + if(ehdr.a_syms) { + if(lseek(fd,ehdr.a_text+ehdr.a_data+ehdr.a_syms+sizeof(ehdr), 0) <= 0) + error("Cannot seek to string table in '%s'", kname); + if(read(fd, &stringsz, sizeof(long)) != sizeof(long)) + error("Cannot read string-table size"); + if(lseek(fd, sizeof(ehdr), 0) <= 0) + error("Cannot seek back to text start"); + kparam.ksize += ehdr.a_syms + sizeof(long) + stringsz; + } + + if((kparam.kp = (u_char *)malloc(kparam.ksize)) == NULL) + error("Cannot malloc kernel image space"); + + /* + * Read text & data, clear bss + */ + if((read(fd, kparam.kp, ehdr.a_text) != ehdr.a_text) + || (read(fd, kparam.kp + textsz, ehdr.a_data) != ehdr.a_data)) + error("Unable to read kernel image\n"); + memset(kparam.kp + textsz + ehdr.a_data, 0, ehdr.a_bss); + + /* + * Read symbol and string table + */ + if(ehdr.a_syms) { + long *p; + + p = (long *)(kparam.kp + textsz + ehdr.a_data + ehdr.a_bss); + *p++ = ehdr.a_syms; + if(read(fd, (char *)p, ehdr.a_syms) != ehdr.a_syms) + error("Cannot read symbol table\n"); + p = (long *)((char *)p + ehdr.a_syms); + if(read(fd, (char *)p, stringsz) != stringsz) + error("Cannot read string table\n"); + kparam.esym_loc = (long)((char *)p-(char *)kparam.kp +stringsz); + } + + if(d_flag) { + fprintf(stdout, "\r\nKernel info:\r\n"); + fprintf(stdout, "Kernel loadaddr\t: 0x%08x\r\n", kparam.kp); + fprintf(stdout, "Kernel size\t: %10d bytes\r\n", kparam.ksize); + fprintf(stdout, "Kernel entry\t: 0x%08x\r\n", kparam.entry); + fprintf(stdout, "Kernel esym\t: 0x%08x\r\n", kparam.esym_loc); + } + + if(!t_flag) + start_kernel(); + /* NOT REACHED */ + + fprintf(stdout, "Kernel '%s' was loaded OK\r\n", kname); + do_exit(0); +} + +/* + * Extract memory and cpu/fpu info from system. + */ +void get_sys_info() +{ + long stck; + long *jar; + OSH *oshdr; + + kparam.cputype = 0; + + stck = Super(0); + + /* + * Some GEMDOS versions use a different year-base in the RTC. + */ + oshdr = *ADDR_OSHEAD; + oshdr = oshdr->os_beg; + if((oshdr->os_version >= 0x0300) && (oshdr->os_version < 0x0306)) + kparam.cputype |= ATARI_CLKBROKEN; + + if(kparam.stmem_size <= 0) + kparam.stmem_size = *ADDR_PHYSTOP; + + if(kparam.ttmem_size) + kparam.ttmem_start = TTRAM_BASE; + else { + if(!s_flag && (*ADDR_CHKRAMTOP == RAM_TOP_MAGIC)) { + kparam.ttmem_size = *ADDR_RAMTOP; + if(kparam.ttmem_size > TTRAM_BASE) { + kparam.ttmem_size -= TTRAM_BASE; + kparam.ttmem_start = TTRAM_BASE; + } + else kparam.ttmem_size = 0; + } + } + + /* + * Scan cookiejar for cpu types + */ + jar = *ADDR_P_COOKIE; + if(jar != NULL) { + do { + if(jar[0] == 0x5f435055) { /* _CPU */ + switch(jar[1]) { + case 0: + kparam.cputype |= ATARI_68000; + break; + case 10: + kparam.cputype |= ATARI_68010; + break; + case 20: + kparam.cputype |= ATARI_68020; + break; + case 30: + kparam.cputype |= ATARI_68030; + break; + case 40: + kparam.cputype |= ATARI_68040; + break; + default: + error("Unknown CPU-type"); + } + } + if(jar[0] == 0x42504658) { /* BPFX */ + unsigned long *p; + + p = (unsigned long*)jar[1]; + + kparam.ttmem_start = p[1]; + kparam.ttmem_size = p[2]; + } + jar = &jar[2]; + } while(jar[-2]); + } + if(!(kparam.cputype & ATARI_ANYCPU)) + error("Cannot determine CPU-type"); + + Super(stck); + + if(d_flag) { + fprintf(stdout, "Machine info:\r\n"); + fprintf(stdout, "ST-RAM size\t: %10d bytes\r\n", kparam.stmem_size); + fprintf(stdout, "TT-RAM size\t: %10d bytes\r\n", kparam.ttmem_size); + fprintf(stdout, "TT-RAM start\t: 0x%08x\r\n", kparam.ttmem_start); + fprintf(stdout, "Cpu-type\t: 0x%08x\r\n", kparam.cputype); + } +} + +void error(char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + + fprintf(stdout, "%s: ", Progname); + vfprintf(stdout, fmt, ap); + fprintf(stdout, "\r\n"); + do_exit(1); + /*NOTREACHED*/ +} + +void help() +{ + fprintf(stdout, "\r +NetBSD loader for the Atari-TT\r +\r +Usage: %s [-abdhstvD] [-S <stram-size>] [kernel]\r +\r +Description of options:\r +\r +\t-a Boot up to multi-user mode.\r +\t-b Ask for root device to use.\r +\t-d Enter kernel debugger.\r +\t-h What your getting right now.\r +\t-s Use only ST-compatible RAM\r +\t-S Set amount of ST-compatible RAM\r +\t-T Set amount of TT-compatible RAM\r +\t-t Test the loader. It will do everything except executing the\r +\t loaded kernel.\r +\t-D printout debugging information while loading\r +\t-v Print loader version.\r +", Progname); + do_exit(0); +} + +void usage() +{ + fprintf(stdout, "Usage: %s [-abdhtv] [kernel]\r\n", Progname); + do_exit(1); +} + +void do_exit(code) +int code; +{ + fprintf(stdout, "\r\nHit <return> to continue..."); + (void)getchar(); + fprintf(stdout, "\r\n"); + exit(code); +} + +void start_kernel() +{ + long stck; + + stck = Super(0); + startit(); + /* NOT REACHED */ + + Super(stck); +} + +asm(" + .text + .globl _startit + +_startit: + move.w #0x2700,sr + + | the BSD kernel wants values into the following registers: + | d0: ttmem-size + | d1: stmem-size + | d2: cputype + | d3: boothowto + | d4: length of loaded kernel + | d5: start of fastram + | a0: start of loaded kernel + | a1: end of symbols (esym) + | All other registers zeroed for possible future requirements. + + lea _kparam, a3 | a3 points to parameter block + lea _startit,sp | make sure we have a good stack *** + move.l (a3),a0 | loaded kernel + move.l 8(a3),-(sp) | push entry point *** + move.l a0,d0 | offset of loaded kernel + add.l d0,(sp) | add offset + move.l 12(a3),d1 | stmem-size + move.l 16(a3),d0 | ttmem-size + move.l 20(a3),d2 | cputype + move.l 24(a3),d3 | boothowto + move.l 4(a3),d4 | length of loaded kernel + move.l 28(a3),d5 | start of fastram + move.l 32(a3),a1 | end of symbols + sub.l a5,a5 | target, load to 0 + btst #4, d2 | Is this an 68040? + 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 zero,a3 + pmove (a3),tcr | Turn off MMU + lea nullrp,a3 + pmove (a3),crp | Turn off MMU some more + pmove (a3),srp | Really, really, turn off MMU + + | Turn off 68030 TT registers + btst #3, d2 | Is this an 68030? + beq.b nott + lea zero,a3 + pmove (a3),tt0 + pmove (a3),tt1 + +nott: + moveq.l #0,d6 | would have known contents) + moveq.l #0,d7 + movea.l d6,a2 + movea.l d6,a3 + movea.l d6,a4 + movea.l d6,a5 + movea.l d6,a6 + rts | enter kernel at address on stack *** + + +| A do-nothing MMU root pointer (includes the following long as well) + +nullrp: .long 0x80000202 +zero: .long 0 +svsp: .long 0 + +"); diff --git a/sys/arch/atari/stand/loadbsd/loader.h b/sys/arch/atari/stand/loadbsd/loader.h new file mode 100644 index 00000000000..4c86a7aa614 --- /dev/null +++ b/sys/arch/atari/stand/loadbsd/loader.h @@ -0,0 +1,89 @@ +/* $NetBSD: loader.h,v 1.5 1995/08/29 20:35:16 leo Exp $ */ + +/* + * Copyright (c) 1995 L. Weppelman + * 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 Leo Weppelman. + * 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. + */ + +/* + * NetBSD loader for the Atari-TT. + * + * Assume compiling under TOS or MINT. The page-size will always + * be incorrect then (if it is defined anyway). + */ +#ifdef __LDPGSZ +#undef __LDPGSZ +#endif + +#define __LDPGSZ (8*1024) /* Page size for NetBSD */ + +#define TTRAM_BASE 0x1000000 /* Fastram always starts here */ + +/* + * System var's used in low-memory + */ +#define ADDR_RAMTOP ((long*)0x5a4) /* End of TT-ram (unofficial) */ +#define ADDR_CHKRAMTOP ((long*)0x5a8) /* above is valid (unofficial)*/ +#define ADDR_PHYSTOP ((long*)0x42e) /* End of ST-ram */ +#define ADDR_P_COOKIE ((long**)0x5a0) /* Pointer to cookie jar */ +#define ADDR_OSHEAD ((OSH**)0x4f2) /* Pointer Os-header */ + +#define RAM_TOP_MAGIC (0x1357bd13) /* Magic nr. for ADDR_CHKRAMTOP */ + +/* + * These should match with the values NetBSD uses! + */ +#define ATARI_68000 1 /* 68000 CPU */ +#define ATARI_68010 (1<<1) /* 68010 CPU */ +#define ATARI_68020 (1<<2) /* 68020 CPU */ +#define ATARI_68030 (1<<3) /* 68030 CPU */ +#define ATARI_68040 (1<<4) /* 68040 CPU */ +#define ATARI_TT (1L<<11) /* This is a TT030 */ +#define ATARI_FALCON (1L<<12) /* This is a Falcon */ + +#define ATARI_CLKBROKEN (1<<16) /* GEMDOS has faulty year base */ + +#define ATARI_ANYCPU (0x1f) + +/* + * Definitions for boothowto + */ +#define RB_AUTOBOOT 0x00 +#define RB_ASKNAME 0x01 +#define RB_SINGLE 0x02 +#define RB_KDB 0x40 + +/* + * Sufficient but incomplete definition os Os-header + */ +typedef struct osh { + unsigned short os_entry; + unsigned short os_version; + void *reseth; + struct osh *os_beg; +} OSH; diff --git a/sys/arch/atari/stand/loadkmap/ge-kbdmap.c b/sys/arch/atari/stand/loadkmap/ge-kbdmap.c new file mode 100644 index 00000000000..cff128e2d5a --- /dev/null +++ b/sys/arch/atari/stand/loadkmap/ge-kbdmap.c @@ -0,0 +1,208 @@ +/* $NetBSD: ge-kbdmap.c,v 1.2 1995/09/23 20:27:15 leo Exp $ */ + +/* + * Contributed by Thomas Gerner + */ + +#include "../../dev/kbdmap.h" + +/* mode shortcuts: */ +#define S KBD_MODE_STRING +#define C KBD_MODE_CAPS +#define K KBD_MODE_KPAD + +struct kbdmap kbdmap; +struct kbdmap ascii_kbdmap = { + /* normal map */ + { +/* 0x00 */ 0, 0, 0, ESC, 0, '1', 0, '2', +/* 0x04 */ 0, '3', 0, '4', 0, '5', 0, '6', +/* 0x08 */ 0, '7', 0, '8', 0, '9', 0, '0', +/* 0x0c */ C, 0xDF, 0, '\'', 0, '\b', 0, '\t', +/* 0x10 */ C, 'q', C, 'w', C, 'e', C, 'r', +/* 0x14 */ C, 't', C, 'z', C, 'u', C, 'i', +/* 0x18 */ C, 'o', C, 'p', C, 0xFC, 0, '+', +/* 0x1c */ 0, '\r', 0, 0, C, 'a', C, 's', +/* 0x20 */ C, 'd', C, 'f', C, 'g', C, 'h', +/* 0x24 */ C, 'j', C, 'k', C, 'l', C, 0xF6, +/* 0x28 */ C, 0xE4, 0, '#', 0, 0, 0, '~', +/* 0x2c */ C, 'y', C, 'x', C, 'c', C, 'v', +/* 0x30 */ C, 'b', C, 'n', C, 'm', 0, ',', +/* 0x34 */ 0, '.', 0, '-', 0, 0, 0, 0, +/* 0x38 */ 0, 0, 0, ' ', 0, 0, S, 0x10, +/* 0x3c */ S, 0x15, S, 0x1A, S, 0x1F, S, 0x24, +/* 0x40 */ S, 0x29, S, 0x2E, S, 0x33, S, 0x38, +/* 0x44 */ S, 0x3D, 0, 0, 0, 0, 0, 0, +/* 0x48 */ S, 0x00, 0, 0, 0, '-', S, 0x0C, +/* 0x4c */ 0, 0, S, 0x08, 0, '+', 0, 0, +/* 0x50 */ S, 0x04, 0, 0, 0, 0, 0, DEL, +/* 0x54 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x58 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x5c */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x60 */ +/* 0x60 */ 0, '<', 0, 0, 0, 0, 0, '(', +/* 0x64 */ 0, ')', 0, '/', 0, '*', K, '7', +/* 0x68 */ K, '8', K, '9', K, '4', K, '5', +/* 0x6c */ K, '6', K, '1', K, '2', K, '3', +/* 0x70 */ K, '0', K, '.', K, '\r', 0, 0, +/* 0x74 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x78 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x7c */ 0, 0, 0, 0, 0, 0, 0, 0 +}, + /* shifted map */ + { +/* 0x00 */ 0, 0, 0, ESC, 0, '!', 0, '"', +/* 0x04 */ 0, 0xA7, 0, '$', 0, '%', 0, '&', +/* 0x08 */ 0, '/', 0, '(', 0, ')', 0, '=', +/* 0x0c */ 0, '?', 0, '`', 0, '\b', 0, '\t', +/* 0x10 */ C, 'Q', C, 'W', C, 'E', C, 'R', +/* 0x14 */ C, 'T', C, 'Z', C, 'U', C, 'I', +/* 0x18 */ C, 'O', C, 'P', C, 0xDC, 0, '*', +/* 0x1c */ 0, '\r', 0, 0, C, 'A', C, 'S', +/* 0x20 */ C, 'D', C, 'F', C, 'G', C, 'H', +/* 0x24 */ C, 'J', C, 'K', C, 'L', C, 0xD6, +/* 0x28 */ C, 0xC4, 0, '^', 0, 0, 0, '|', +/* 0x2c */ C, 'Y', C, 'X', C, 'C', C, 'V', +/* 0x30 */ C, 'B', C, 'N', C, 'M', 0, ';', +/* 0x34 */ 0, ':', 0, '_', 0, 0, 0, 0, +/* 0x38 */ 0, 0, 0, ' ', 0, 0, S, 0x5d, +/* 0x3c */ S, 0x63, S, 0x69, S, 0x6F, S, 0x75, +/* 0x40 */ S, 0x7b, S, 0x81, S, 0x87, S, 0x8d, +/* 0x44 */ S, 0x93, 0, 0, 0, 0, 0, 0, +/* 0x48 */ S, 0x47, 0, 0, 0, '-', S, 0x57, +/* 0x4c */ 0, 0, S, 0x51, 0, '+', 0, 0, +/* 0x50 */ S, 0x4c, 0, 0, 0, 0, 0, DEL, +/* 0x54 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x58 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x5c */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x60 */ +/* 0x60 */ 0, '>', 0, 0, 0, 0, 0, '(', +/* 0x64 */ 0, ')', 0, '/', 0, '*', K, '7', +/* 0x68 */ K, '8', K, '9', K, '4', K, '5', +/* 0x6c */ K, '6', K, '1', K, '2', K, '3', +/* 0x70 */ K, '0', K, '.', K, '\r', 0, 0, +/* 0x74 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x78 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x7c */ 0, 0, 0, 0, 0, 0, 0, 0 + }, + + /* alt map */ + { +/* 0x00 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x04 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x08 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x0c */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x10 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x14 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x18 */ 0, 0, 0, 0, 0, '@', 0, 0, +/* 0x1c */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x20 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x24 */ 0, 0, 0, 0, 0, 0, 0, '[', +/* 0x28 */ 0, ']', 0, 0, 0, 0, 0, 0, +/* 0x2c */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x30 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x34 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x38 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x3c */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x40 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x44 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x48 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x4c */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x50 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x54 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x58 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x5c */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x60 */ +/* 0x60 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x64 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x68 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x6c */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x70 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x74 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x78 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x7c */ 0, 0, 0, 0, 0, 0, 0, 0 + }, + + /* shift alt map */ + { +/* 0x00 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x04 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x08 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x0c */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x10 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x14 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x18 */ 0, 0, 0, 0, 0, '\\', 0, 0, +/* 0x1c */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x20 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x24 */ 0, 0, 0, 0, 0, 0, 0, '{', +/* 0x28 */ 0, '}', 0, 0, 0, 0, 0, 0, +/* 0x2c */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x30 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x34 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x38 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x3c */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x40 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x44 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x48 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x4c */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x50 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x54 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x58 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x5c */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x60 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x64 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x68 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x6c */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x70 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x74 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x78 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x7c */ 0, 0, 0, 0, 0, 0, 0, 0 + }, + + { + /* 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 */ + }, +}; + +main() +{ + write (1, &ascii_kbdmap, sizeof (kbdmap)); +} diff --git a/sys/arch/atari/stand/loadkmap/loadkmap.c b/sys/arch/atari/stand/loadkmap/loadkmap.c new file mode 100644 index 00000000000..0884f691ca2 --- /dev/null +++ b/sys/arch/atari/stand/loadkmap/loadkmap.c @@ -0,0 +1,74 @@ +/* $NetBSD: loadkmap.c,v 1.2 1995/07/24 05:47:48 leo 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 *, int)); +void dump_kmap(); + +int +main(argc, argv) + int argc; + char *argv[]; +{ + int set_sysmap = 0; + char *mapfile; + + if (argc > 2) { + if ((argc == 3) && !strcmp(argv[1], "-f")) { + mapfile = argv[2]; + set_sysmap = 1; + } + else { + fprintf(stderr, "%s [-f] keymap\n", argv[0]); + exit(1); + } + } + else mapfile = argv[1]; + + if (argc == 1) + dump_kmap(); + else load_kmap(mapfile, set_sysmap); + + exit (0); +} + + +void +load_kmap(file, set_sysmap) +const char *file; +int set_sysmap; +{ + int fd; + char buf[sizeof (struct kbdmap)]; + int ioc; + + ioc = set_sysmap ? ITEIOCSSKMAP : ITEIOCSKMAP; + + if ((fd = open (file, 0)) >= 0) { + if (read (fd, buf, sizeof (buf)) == sizeof (buf)) { + if (ioctl (0, ioc, 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/atari/stand/loadkmap/uk-kbdmap.c b/sys/arch/atari/stand/loadkmap/uk-kbdmap.c new file mode 100644 index 00000000000..25b7d6f0e7a --- /dev/null +++ b/sys/arch/atari/stand/loadkmap/uk-kbdmap.c @@ -0,0 +1,141 @@ +/* $NetBSD: uk-kbdmap.c,v 1.1.1.1 1995/07/03 20:49:40 leo Exp $ */ + +#include "../../dev/kbdmap.h" + +/* mode shortcuts: */ +#define S KBD_MODE_STRING +#define C KBD_MODE_CAPS +#define K KBD_MODE_KPAD + +struct kbdmap kbdmap; +struct kbdmap ascii_kbdmap = { + /* normal map */ + { +/* 0x00 */ 0, 0, 0, ESC, 0, '1', 0, '2', +/* 0x04 */ 0, '3', 0, '4', 0, '5', 0, '6', +/* 0x08 */ 0, '7', 0, '8', 0, '9', 0, '0', +/* 0x0c */ 0, '-', 0, '=', 0, '\b', 0, '\t', +/* 0x10 */ C, 'q', C, 'w', C, 'e', C, 'r', +/* 0x14 */ C, 't', C, 'y', C, 'u', C, 'i', +/* 0x18 */ C, 'o', C, 'p', 0, '[', 0, ']', +/* 0x1c */ 0, '\r', 0, 0, C, 'a', C, 's', +/* 0x20 */ C, 'd', C, 'f', C, 'g', C, 'h', +/* 0x24 */ C, 'j', C, 'k', C, 'l', 0, ';', +/* 0x28 */ 0, '\'', 0, '`', 0, 0, 0, '#', +/* 0x2c */ C, 'z', C, 'x', C, 'c', C, 'v', +/* 0x30 */ C, 'b', C, 'n', C, 'm', 0, ',', +/* 0x34 */ 0, '.', 0, '/', 0, 0, 0, 0, +/* 0x38 */ 0, 0, 0, ' ', 0, 0, S, 0x10, +/* 0x3c */ S, 0x15, S, 0x1A, S, 0x1F, S, 0x24, +/* 0x40 */ S, 0x29, S, 0x2E, S, 0x33, S, 0x38, +/* 0x44 */ S, 0x3D, 0, 0, 0, 0, 0, 0, +/* 0x48 */ S, 0x00, 0, 0, 0, '-', S, 0x0C, +/* 0x4c */ 0, 0, S, 0x08, 0, '+', 0, 0, +/* 0x50 */ S, 0x04, 0, 0, 0, 0, 0, DEL, +/* 0x54 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x58 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x5c */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x60 */ +/* 0x60 */ 0, '\\', 0, 0, 0, 0, 0, '(', +/* 0x64 */ 0, ')', 0, '/', 0, '*', K, '7', +/* 0x68 */ K, '8', K, '9', K, '4', K, '5', +/* 0x6c */ K, '6', K, '1', K, '2', K, '3', +/* 0x70 */ K, '0', K, '.', K, '\r', 0, 0, +/* 0x74 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x78 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x7c */ 0, 0, 0, 0, 0, 0, 0, 0 +}, + /* shifted map */ + { +/* 0x00 */ 0, 0, 0, ESC, 0, '!', 0, '"', +/* 0x04 */ 0, '#', 0, '$', 0, '%', 0, '^', +/* 0x08 */ 0, '&', 0, '*', 0, '(', 0, ')', +/* 0x0c */ 0, '_', 0, '+', 0, '\b', 0, '\t', +/* 0x10 */ C, 'Q', C, 'W', C, 'E', C, 'R', +/* 0x14 */ C, 'T', C, 'Y', C, 'U', C, 'I', +/* 0x18 */ C, 'O', C, 'P', 0, '{', 0, '}', +/* 0x1c */ 0, '\r', 0, 0, C, 'A', C, 'S', +/* 0x20 */ C, 'D', C, 'F', C, 'G', C, 'H', +/* 0x24 */ C, 'J', C, 'K', C, 'L', 0, ':', +/* 0x28 */ 0, '@', 0, '_', 0, 0, 0, '~', +/* 0x2c */ C, 'Z', C, 'X', C, 'C', C, 'V', +/* 0x30 */ C, 'B', C, 'N', C, 'M', 0, '<', +/* 0x34 */ 0, '>', 0, '?', 0, 0, 0, 0, +/* 0x38 */ 0, 0, 0, ' ', 0, 0, S, 0x5d, +/* 0x3c */ S, 0x63, S, 0x69, S, 0x6F, S, 0x75, +/* 0x40 */ S, 0x7b, S, 0x81, S, 0x87, S, 0x8d, +/* 0x44 */ S, 0x93, 0, 0, 0, 0, 0, 0, +/* 0x48 */ S, 0x47, 0, 0, 0, '-', S, 0x57, +/* 0x4c */ 0, 0, S, 0x51, 0, '+', 0, 0, +/* 0x50 */ S, 0x4c, 0, 0, 0, 0, 0, DEL, +/* 0x54 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x58 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x5c */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x60 */ +/* 0x60 */ 0, '|', 0, 0, 0, 0, 0, '(', +/* 0x64 */ 0, ')', 0, '/', 0, '*', K, '7', +/* 0x68 */ K, '8', K, '9', K, '4', K, '5', +/* 0x6c */ K, '6', K, '1', K, '2', K, '3', +/* 0x70 */ K, '0', K, '.', K, '\r', 0, 0, +/* 0x74 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x78 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x7c */ 0, 0, 0, 0, 0, 0, 0, 0 + }, + + /* alt map FIXME: No altmap yet.. */ + { + 0, 0 + }, + + /* shift alt map FIXME: No shift altmap yet... */ + { + 0, 0 + }, + + { + /* 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 */ + }, +}; + +main() +{ + write (1, &ascii_kbdmap, sizeof (kbdmap)); +} diff --git a/sys/arch/atari/stand/loadkmap/us-kbdmap.c b/sys/arch/atari/stand/loadkmap/us-kbdmap.c new file mode 100644 index 00000000000..70ca7d53f3c --- /dev/null +++ b/sys/arch/atari/stand/loadkmap/us-kbdmap.c @@ -0,0 +1,157 @@ +/* $NetBSD: us-kbdmap.c,v 1.2 1995/07/24 05:44:43 leo Exp $ */ + +#include "../../dev/kbdmap.h" + +/* mode shortcuts: */ +#define S KBD_MODE_STRING +#define C KBD_MODE_CAPS +#define K KBD_MODE_KPAD + + +/* +| 20.June.95 +| Abdulkareem asx@ccnet.com +| +| Changes made for the US keyboard +| The pipe symbol '|', the double-quote '"', the at sign, '@', the +| tidle '~', the backslash '\' were incompatible to the built-in +| keymap and therefore not available on the US keyabords. +| +| I've added the loadkmap us-map line in my /etc/rc.local file; don't +| know where else to put it. +| +*/ + + +struct kbdmap kbdmap; +struct kbdmap ascii_kbdmap = { + /* normal map */ + { +/* 0x00 */ 0, 0, 0, ESC, 0, '1', 0, '2', +/* 0x04 */ 0, '3', 0, '4', 0, '5', 0, '6', +/* 0x08 */ 0, '7', 0, '8', 0, '9', 0, '0', +/* 0x0c */ 0, '-', 0, '=', 0, '\b', 0, '\t', +/* 0x10 */ C, 'q', C, 'w', C, 'e', C, 'r', +/* 0x14 */ C, 't', C, 'y', C, 'u', C, 'i', +/* 0x18 */ C, 'o', C, 'p', 0, '[', 0, ']', +/* 0x1c */ 0, '\r', 0, DEL, C, 'a', C, 's', +/* 0x20 */ C, 'd', C, 'f', C, 'g', C, 'h', +/* 0x24 */ C, 'j', C, 'k', C, 'l', 0, ';', +/* 0x28 */ 0, '\'', 0, '`', 0, 0, 0, '\\', +/* 0x2c */ C, 'z', C, 'x', C, 'c', C, 'v', +/* 0x30 */ C, 'b', C, 'n', C, 'm', 0, ',', +/* 0x34 */ 0, '.', 0, '/', 0, 0, 0, 0, +/* 0x38 */ 0, 0, 0, ' ', 0, 0, S, 0x10, +/* 0x3c */ S, 0x15, S, 0x1A, S, 0x1F, S, 0x24, +/* 0x40 */ S, 0x29, S, 0x2E, S, 0x33, S, 0x38, +/* 0x44 */ S, 0x3D, 0, 0, 0, 0, 0, 0, +/* 0x48 */ S, 0x00, 0, 0, 0, '-', S, 0x0C, +/* 0x4c */ 0, 0, S, 0x08, 0, '+', 0, 0, +/* 0x50 */ S, 0x04, 0, 0, 0, 0, 0, DEL, +/* 0x54 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x58 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x5c */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x60 */ +/* 0x60 */ 0, 0, 0, 0, 0, 0, 0, '(', +/* 0x64 */ 0, ')', 0, '/', 0, '*', K, '7', +/* 0x68 */ K, '8', K, '9', K, '4', K, '5', +/* 0x6c */ K, '6', K, '1', K, '2', K, '3', +/* 0x70 */ K, '0', K, '.', K, '\r', 0, 0, +/* 0x74 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x78 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x7c */ 0, 0, 0, 0, 0, 0, 0, 0 +}, + /* shifted map */ + { +/* 0x00 */ 0, 0, 0, ESC, 0, '!', 0, '@', +/* 0x04 */ 0, '#', 0, '$', 0, '%', 0, '^', +/* 0x08 */ 0, '&', 0, '*', 0, '(', 0, ')', +/* 0x0c */ 0, '_', 0, '+', 0, '\b', 0, '\t', +/* 0x10 */ C, 'Q', C, 'W', C, 'E', C, 'R', +/* 0x14 */ C, 'T', C, 'Y', C, 'U', C, 'I', +/* 0x18 */ C, 'O', C, 'P', 0, '{', 0, '}', +/* 0x1c */ 0, '\r', 0, 0, C, 'A', C, 'S', +/* 0x20 */ C, 'D', C, 'F', C, 'G', C, 'H', +/* 0x24 */ C, 'J', C, 'K', C, 'L', 0, ':', +/* 0x28 */ 0, '"', 0, '~', 0, 0, 0, '|', +/* 0x2c */ C, 'Z', C, 'X', C, 'C', C, 'V', +/* 0x30 */ C, 'B', C, 'N', C, 'M', 0, '<', +/* 0x34 */ 0, '>', 0, '?', 0, 0, 0, 0, +/* 0x38 */ 0, 0, 0, ' ', 0, 0, S, 0x5d, +/* 0x3c */ S, 0x63, S, 0x69, S, 0x6F, S, 0x75, +/* 0x40 */ S, 0x7b, S, 0x81, S, 0x87, S, 0x8d, +/* 0x44 */ S, 0x93, 0, 0, 0, 0, 0, 0, +/* 0x48 */ S, 0x47, 0, 0, 0, '-', S, 0x57, +/* 0x4c */ 0, 0, S, 0x51, 0, '+', 0, 0, +/* 0x50 */ S, 0x4c, 0, 0, 0, 0, 0, DEL, +/* 0x54 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x58 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x5c */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x60 */ +/* 0x60 */ 0, 0, 0, 0, 0, 0, 0, '(', +/* 0x64 */ 0, ')', 0, '/', 0, '*', K, '7', +/* 0x68 */ K, '8', K, '9', K, '4', K, '5', +/* 0x6c */ K, '6', K, '1', K, '2', K, '3', +/* 0x70 */ K, '0', K, '.', K, '\r', 0, 0, +/* 0x74 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x78 */ 0, 0, 0, 0, 0, 0, 0, 0, +/* 0x7c */ 0, 0, 0, 0, 0, 0, 0, 0 + }, + + /* alt map FIXME: No altmap yet.. */ + { + 0, 0 + }, + + /* shift alt map FIXME: No shift altmap yet... */ + { + 0, 0 + }, + + { + /* 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 */ + }, +}; + +main() +{ + write (1, &ascii_kbdmap, sizeof (kbdmap)); +} diff --git a/sys/arch/atari/stand/rawwrite/rawwrite.c b/sys/arch/atari/stand/rawwrite/rawwrite.c new file mode 100644 index 00000000000..24699fc1769 --- /dev/null +++ b/sys/arch/atari/stand/rawwrite/rawwrite.c @@ -0,0 +1,115 @@ +/* $NetBSD: rawwrite.c,v 1.1.1.1 1995/04/06 21:04:54 leo Exp $ */ + +/* + * Copyright (c) 1995 Leo Weppelman. + * 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 Leo Weppelman. + * 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 <osbind.h> +#include <stdio.h> +#include <fcntl.h> +#include <string.h> + +#define SECT_SIZE 512 /* Sector size */ +#define NSECT_DD 18 /* Sectors per track 720Kb */ +#define NSECT_HD 36 /* Sectors per track 1.44Mb */ +#define NTRK 80 /* Number of tracks */ + +static void usage(); +static void brwrite(); + +char buf[NSECT_HD * SECT_SIZE]; +int vflag = 0; +char *progname; + +main(argc, argv) +int argc; +char *argv[]; +{ + extern int optind; + extern char *optarg; + int ch; + char *infile; + int fd; + int i; + int nsect; + + progname = argv[0]; + while ((ch = getopt(argc, argv, "v")) != EOF) { + switch(ch) { + case 'v': + vflag = 1; + break; + default : + usage(); + break; + } + } + if(optind >= argc) + usage(); + + infile = argv[optind]; + nsect = NSECT_DD; + + if((fd = open(infile, O_RDONLY)) < 0) { + fprintf(stderr, "%s: Cannot open '%s'\n", progname, infile); + exit(1); + } + + for(i = 0; i < NTRK; i++) { + if(read(fd, buf, nsect * SECT_SIZE) != (nsect * SECT_SIZE)) { + fprintf(stderr, "\nRead error on '%s'\n", progname, infile); + exit(1); + } + if(vflag) { + if(i && !(i % 40)) + printf("\n"); + fprintf(stderr, "."); + } + brwrite(buf, nsect * i, nsect); + } + close(fd); + if(vflag) + printf("\n"); +} + +static void brwrite(buf, blk, cnt) +char *buf; +int blk, cnt; +{ + if(Rwabs(3, buf, cnt, blk, 0) != 0) { + fprintf(stderr, "\n%s: Write error on floppy\n", progname); + exit(1); + } +} + +static void usage() +{ + fprintf(stderr, "usage: rawwrite [-v] <infile>\n"); + exit(1); +} |