summaryrefslogtreecommitdiff
path: root/sys/arch/atari
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>1996-01-09 09:14:03 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>1996-01-09 09:14:03 +0000
commitc5e97a05603999728235836b1742439de02920fb (patch)
treed647bc64ff344f9f048183813f01fa2709425a88 /sys/arch/atari
parent236fa81f1c26d81e3c0dd6e575edbc754296bba0 (diff)
from leo:
Common library for all tostools. (Waldi Ravens and myself)
Diffstat (limited to 'sys/arch/atari')
-rw-r--r--sys/arch/atari/stand/tostools/libtos/Makefile12
-rw-r--r--sys/arch/atari/stand/tostools/libtos/bsdstart.s117
-rw-r--r--sys/arch/atari/stand/tostools/libtos/eprintf.c82
-rw-r--r--sys/arch/atari/stand/tostools/libtos/error.c105
-rw-r--r--sys/arch/atari/stand/tostools/libtos/keywait.c68
-rw-r--r--sys/arch/atari/stand/tostools/libtos/kparamb.h74
-rw-r--r--sys/arch/atari/stand/tostools/libtos/libtos.h70
-rw-r--r--sys/arch/atari/stand/tostools/libtos/xalloc.c57
-rw-r--r--sys/arch/atari/stand/tostools/libtos/xexit.c60
9 files changed, 645 insertions, 0 deletions
diff --git a/sys/arch/atari/stand/tostools/libtos/Makefile b/sys/arch/atari/stand/tostools/libtos/Makefile
new file mode 100644
index 00000000000..f89ac1cd0eb
--- /dev/null
+++ b/sys/arch/atari/stand/tostools/libtos/Makefile
@@ -0,0 +1,12 @@
+# $NetBSD: Makefile,v 1.1.1.1 1996/01/07 21:50:50 leo Exp $
+#
+LIB = libtos.a
+
+OBJS = bsdstart.o eprintf.o error.o xalloc.o xexit.o keywait.o
+HEADERS = kparamb.h libtos.h
+
+include ../Makefile.inc
+
+${LIB}: ${OBJS}
+ @${RM} ${LIB}
+ ${AR} ${LIB} ${OBJS}
diff --git a/sys/arch/atari/stand/tostools/libtos/bsdstart.s b/sys/arch/atari/stand/tostools/libtos/bsdstart.s
new file mode 100644
index 00000000000..39722062c83
--- /dev/null
+++ b/sys/arch/atari/stand/tostools/libtos/bsdstart.s
@@ -0,0 +1,117 @@
+/* $NetBSD: bsdstart.s,v 1.1.1.1 1996/01/07 21:50:49 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 function sets up the registers according to the kernel parameter block,
+ * disables the MMU and jumps to the kernel.
+ *
+ * bsd_startup(struct kparamb *)
+ */
+ .text
+ .even
+ .globl _bsd_startup
+
+_bsd_startup:
+ movw #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.
+
+ movl sp@(4), a3 | a3 points to parameter block
+#ifndef STANDALONE
+ lea _bsd_startup,sp | make sure we have a good stack ***
+#endif
+ movl a3@,a0 | loaded kernel
+ movl a3@(8),d0 | kernel entry point
+ addl a0,d0 | added makes our absolute entry point
+ movl d0,sp@- | push entry point ***
+ movl a3@(12),d1 | stmem-size
+ movl a3@(16),d0 | ttmem-size
+ movl a3@(20),d2 | bootflags
+ movl a3@(24),d3 | boothowto
+ movl a3@(4),d4 | length of loaded kernel
+ movl a3@(28),d5 | start of fastram
+ movl a3@(32),a1 | end of symbols
+ subl 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 pc@(zero),a3
+ pmove a3@,tc | Turn off MMU
+ pmove a3@(-4),crp | crp = nullrp
+ pmove a3@(-4),srp | srp = nullrp
+
+ | Turn off 68030 TT registers
+ btst #3, d2 | Is this an 68030?
+ jeqs nott
+ .word 0xf013,0x0800 | pmove a3@,tt0
+ .word 0xf013,0x0c00 | pmove a3@,tt1
+
+nott:
+ movq #0,d6 | would have known contents)
+ movl d6,d7
+ movl d6,a2
+ movl d6,a3
+ movl d6,a4
+ movl d6,a5
+ movl d6,a6
+ rts | enter kernel at address on stack ***
+
+
+| A do-nothing MMU root pointer (includes the following long as well)
+| Note that the above code makes assumptions about the order of the following
+| items.
+
+nullrp: .long 0x80000202
+zero: .long 0
+#ifndef STANDALONE
+svsp: .long 0
+#endif
diff --git a/sys/arch/atari/stand/tostools/libtos/eprintf.c b/sys/arch/atari/stand/tostools/libtos/eprintf.c
new file mode 100644
index 00000000000..60e07c57daf
--- /dev/null
+++ b/sys/arch/atari/stand/tostools/libtos/eprintf.c
@@ -0,0 +1,82 @@
+/* $NetBSD: eprintf.c,v 1.1.1.1 1996/01/07 21:50:49 leo Exp $ */
+
+/*
+ * Copyright (c) 1995 Waldi Ravens.
+ * 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 Waldi Ravens.
+ * 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 <fcntl.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include "libtos.h"
+
+static int output_redirected = 0;
+
+void
+redirect_output(fn)
+ char *fn;
+{
+ int fd;
+
+ fd = creat(fn, 0666);
+ if (fd < 0 || dup2(fd, STDOUT_FILENO) < 0)
+ fatal(errno, "%s", fn);
+ output_redirected = 1;
+}
+
+/*
+ * Print output to stderr. When output is redirected,
+ * also write it to stdout.
+ */
+int
+eprintf(frm)
+ char *frm;
+{
+ va_list args;
+ int rv;
+
+ va_start(args, frm);
+ rv = veprintf(frm, args);
+ va_end(args);
+ return(rv);
+}
+
+int
+veprintf(frm, args)
+ char *frm;
+ va_list args;
+{
+ int rv;
+
+ rv = vfprintf(stderr, frm, args);
+ if (output_redirected)
+ vfprintf(stdout, frm, args);
+ return(rv);
+}
diff --git a/sys/arch/atari/stand/tostools/libtos/error.c b/sys/arch/atari/stand/tostools/libtos/error.c
new file mode 100644
index 00000000000..fe5ff6f57d7
--- /dev/null
+++ b/sys/arch/atari/stand/tostools/libtos/error.c
@@ -0,0 +1,105 @@
+/* $NetBSD: error.c,v 1.1.1.1 1996/01/07 21:50:49 leo Exp $ */
+
+/*
+ * Copyright (c) 1995 Waldi Ravens.
+ * 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 Waldi Ravens.
+ * 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 <stdio.h>
+#include <osbind.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include "libtos.h"
+
+static void errmsg PROTO((int, char *, va_list));
+
+const char *program_name;
+
+void
+init_toslib(arg0)
+ char *arg0;
+{
+ char *p;
+
+ if (isatty(STDERR_FILENO) && (!*arg0 || !getenv("STDERR")))
+ Fforce(STDERR_FILENO, -1);
+
+ if (!(p = strrchr(arg0, '/')))
+ p = strrchr(arg0, '\\');
+ program_name = p ? ++p : arg0;
+}
+
+void
+error(err, frm)
+ int err;
+ char *frm;
+{
+ va_list args;
+
+ va_start(args, frm);
+ errmsg(err, frm, args);
+ va_end(args);
+}
+
+void
+fatal(err, frm)
+ int err;
+ char *frm;
+{
+ va_list args;
+
+ va_start(args, frm);
+ errmsg(err, frm, args);
+ va_end(args);
+
+ xexit(EXIT_FAILURE);
+}
+
+static void
+errmsg(err, frm, args)
+ int err;
+ char *frm;
+ va_list args;
+{
+ extern const char *program_name;
+
+ eprintf("%s: ", program_name);
+ veprintf(frm, args);
+
+ if (err != -1) {
+ char *es = strerror(err);
+ if (es)
+ eprintf(": %s", es);
+ else
+ eprintf(": unknown error %d", err);
+ }
+
+ eprintf("\n");
+}
diff --git a/sys/arch/atari/stand/tostools/libtos/keywait.c b/sys/arch/atari/stand/tostools/libtos/keywait.c
new file mode 100644
index 00000000000..b0e73db52ad
--- /dev/null
+++ b/sys/arch/atari/stand/tostools/libtos/keywait.c
@@ -0,0 +1,68 @@
+/* $NetBSD: keywait.c,v 1.1.1.1 1996/01/07 21:50:50 leo Exp $ */
+
+/*
+ * Copyright (c) 1995 Waldi Ravens.
+ * 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 Waldi Ravens.
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <termios.h>
+#include "libtos.h"
+
+int
+key_wait(text)
+ char *text;
+{
+ struct termios term_attr;
+ tcflag_t lfl_orig;
+ int any_key;
+ char c;
+
+ any_key = (text == NULL);
+ if (any_key)
+ text = "Press any key...";
+
+ fprintf(stderr, text);
+ fflush(stderr);
+
+ tcgetattr(STDERR_FILENO, &term_attr);
+ lfl_orig = term_attr.c_lflag;
+ if (any_key)
+ term_attr.c_lflag &= ~ECHO;
+ term_attr.c_lflag &= ~ICANON;
+ tcsetattr(STDERR_FILENO, TCSAFLUSH, &term_attr);
+ read(STDERR_FILENO, &c, 1);
+ term_attr.c_lflag = lfl_orig;
+ tcsetattr(STDERR_FILENO, TCSAFLUSH, &term_attr);
+
+ fprintf(stderr, (any_key ? "\r" : "\r\n"));
+ fflush(stderr);
+ return(c);
+}
diff --git a/sys/arch/atari/stand/tostools/libtos/kparamb.h b/sys/arch/atari/stand/tostools/libtos/kparamb.h
new file mode 100644
index 00000000000..2c32467430a
--- /dev/null
+++ b/sys/arch/atari/stand/tostools/libtos/kparamb.h
@@ -0,0 +1,74 @@
+/* $NetBSD: kparamb.h,v 1.1.1.1 1996/01/07 21:50:49 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.
+ */
+
+/*
+ * Structure passed to bsd_startup().
+ */
+struct kparamb {
+ 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 bootflags; /* 20: Various boot flags */
+ long boothowto; /* 24: How to boot */
+ long ttmem_start; /* 28: Start of tt-ram */
+ long esym_loc; /* 32: End of symbol table */
+};
+
+#ifndef STANDALONE
+/*
+ * Values for 'bootflags'.
+ * Note: 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
+ * Note: These should match with the values NetBSD uses!
+ */
+#define RB_AUTOBOOT 0x00
+#define RB_ASKNAME 0x01
+#define RB_SINGLE 0x02
+#define RB_KDB 0x40
+
+#endif /* STANDALONE */
diff --git a/sys/arch/atari/stand/tostools/libtos/libtos.h b/sys/arch/atari/stand/tostools/libtos/libtos.h
new file mode 100644
index 00000000000..7873d816b8d
--- /dev/null
+++ b/sys/arch/atari/stand/tostools/libtos/libtos.h
@@ -0,0 +1,70 @@
+/* $NetBSD: libtos.h,v 1.1.1.1 1996/01/07 21:50:49 leo Exp $ */
+
+/*
+ * Copyright (c) 1995 Waldi Ravens.
+ * 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 Waldi Ravens.
+ * 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.
+ */
+
+#ifndef LIBTOS_H
+#define LIBTOS_H
+
+#ifdef __STDC__
+#define PROTO(x) x
+#define EXTERN
+#else
+#define PROTO(x) ()
+#define EXTERN extern
+#endif
+
+#ifdef __GNUC__
+#if (__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 5))
+#define NORETURN __attribute__((noreturn))
+#else
+#define NORETURN
+#endif
+#endif
+
+#include <sys/types.h>
+#include <stdarg.h>
+#include "kparamb.h"
+
+EXTERN void bsd_startup PROTO((struct kparamb *)) NORETURN;
+EXTERN void init_toslib PROTO((char *));
+EXTERN void redirect_output PROTO((char *));
+EXTERN int eprintf PROTO((char *, ...));
+EXTERN int veprintf PROTO((char *, va_list));
+EXTERN void set_wait_for_key PROTO((void));
+EXTERN void press_any_key PROTO((void));
+EXTERN int key_wait PROTO((char *));
+EXTERN void xexit PROTO((int)) NORETURN;
+EXTERN void error PROTO((int, char *, ...));
+EXTERN void fatal PROTO((int, char *, ...)) NORETURN;
+EXTERN void * xmalloc PROTO((size_t));
+EXTERN void * xrealloc PROTO((void *, size_t));
+
+#endif /* LIBTOS_H */
diff --git a/sys/arch/atari/stand/tostools/libtos/xalloc.c b/sys/arch/atari/stand/tostools/libtos/xalloc.c
new file mode 100644
index 00000000000..84b2f55cd4d
--- /dev/null
+++ b/sys/arch/atari/stand/tostools/libtos/xalloc.c
@@ -0,0 +1,57 @@
+/* $NetBSD: xalloc.c,v 1.1.1.1 1996/01/07 21:50:49 leo Exp $ */
+
+/*
+ * Copyright (c) 1995 Waldi Ravens.
+ * 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 Waldi Ravens.
+ * 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 <stdlib.h>
+#include "libtos.h"
+
+void *
+xmalloc(size)
+ size_t size;
+{
+ void * p = malloc(size);
+
+ if (p || !size)
+ return(p);
+ fatal(-1, "Virtual memory exhausted");
+}
+
+void *
+xrealloc(ptr, size)
+ void *ptr;
+ size_t size;
+{
+ void * p = realloc(ptr, size);
+
+ if (p || !size)
+ return(p);
+ fatal(-1, "Virtual memory exhausted");
+}
diff --git a/sys/arch/atari/stand/tostools/libtos/xexit.c b/sys/arch/atari/stand/tostools/libtos/xexit.c
new file mode 100644
index 00000000000..deb46724952
--- /dev/null
+++ b/sys/arch/atari/stand/tostools/libtos/xexit.c
@@ -0,0 +1,60 @@
+/* $NetBSD: xexit.c,v 1.1.1.1 1996/01/07 21:50:50 leo Exp $ */
+
+/*
+ * Copyright (c) 1995 Waldi Ravens.
+ * 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 Waldi Ravens.
+ * 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 <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include "libtos.h"
+
+static int wait_for_key = 0;
+
+void
+set_wait_for_key()
+{
+ if (isatty(STDERR_FILENO))
+ wait_for_key = 1;
+}
+
+void
+press_any_key()
+{
+ if (wait_for_key)
+ (void)key_wait(NULL);
+}
+
+void
+xexit(status)
+ int status;
+{
+ press_any_key();
+ exit(status);
+}