summaryrefslogtreecommitdiff
path: root/sys/arch/zaurus/stand
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/zaurus/stand')
-rw-r--r--sys/arch/zaurus/stand/zboot/Makefile6
-rw-r--r--sys/arch/zaurus/stand/zboot/compat_linux.h31
-rw-r--r--sys/arch/zaurus/stand/zboot/conf.c18
-rw-r--r--sys/arch/zaurus/stand/zboot/devopen.c102
-rw-r--r--sys/arch/zaurus/stand/zboot/disk.h92
-rw-r--r--sys/arch/zaurus/stand/zboot/diskprobe.c304
-rw-r--r--sys/arch/zaurus/stand/zboot/exit.c11
-rw-r--r--sys/arch/zaurus/stand/zboot/libsa.h13
-rw-r--r--sys/arch/zaurus/stand/zboot/loadfile.c23
-rw-r--r--sys/arch/zaurus/stand/zboot/machdep.c13
-rw-r--r--sys/arch/zaurus/stand/zboot/termios.c37
-rw-r--r--sys/arch/zaurus/stand/zboot/unixcons.c231
-rw-r--r--sys/arch/zaurus/stand/zboot/unixdev.c192
-rw-r--r--sys/arch/zaurus/stand/zboot/unixdev.h57
-rw-r--r--sys/arch/zaurus/stand/zboot/unixsys.S9
15 files changed, 893 insertions, 246 deletions
diff --git a/sys/arch/zaurus/stand/zboot/Makefile b/sys/arch/zaurus/stand/zboot/Makefile
index f7f5c4015c9..91dbdc15c0c 100644
--- a/sys/arch/zaurus/stand/zboot/Makefile
+++ b/sys/arch/zaurus/stand/zboot/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.5 2005/05/12 05:10:30 uwe Exp $
+# $OpenBSD: Makefile,v 1.6 2005/05/24 20:38:20 uwe Exp $
MAN= boot.8
MANSUBDIR=zaurus
@@ -33,8 +33,8 @@ SRCS+= strcmp.c strlcpy.c strlen.c strncmp.c strncpy.c write.c \
ashrdi3.c divsi3.S
# local overrides and additions
-SRCS+= alloc.c cmd.c devopen.c exec.c exit.c loadfile.c machdep.c \
- termios.c unixdev.c unixsys.S
+SRCS+= alloc.c cmd.c devopen.c diskprobe.c exec.c exit.c loadfile.c \
+ machdep.c termios.c unixcons.c unixdev.c unixsys.S
.PATH: ${S}/stand/boot
.PATH: ${S}/lib/libsa
diff --git a/sys/arch/zaurus/stand/zboot/compat_linux.h b/sys/arch/zaurus/stand/zboot/compat_linux.h
index 461ace4179a..2662f064eac 100644
--- a/sys/arch/zaurus/stand/zboot/compat_linux.h
+++ b/sys/arch/zaurus/stand/zboot/compat_linux.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: compat_linux.h,v 1.6 2005/05/12 05:10:30 uwe Exp $ */
+/* $OpenBSD: compat_linux.h,v 1.7 2005/05/24 20:38:20 uwe Exp $ */
/*
* Copyright (c) 2005 Uwe Stuehler <uwe@bsdx.de>
@@ -32,11 +32,13 @@ struct proc;
#undef O_RDONLY
#undef O_WRONLY
+#undef O_RDWR
#undef SEEK_SET
#undef SEEK_CUR
#define O_RDONLY LINUX_O_RDONLY
#define O_WRONLY LINUX_O_WRONLY
+#define O_RDWR LINUX_O_RDWR
#define SEEK_SET 0
#define SEEK_CUR 1
@@ -72,25 +74,30 @@ struct proc;
#define TCSADRAIN LINUX_TCSADRAIN
#define TCSAFLUSH LINUX_TCSAFLUSH
+typedef unsigned int speed_t;
+
void cfmakeraw(struct termios *);
+int cfsetspeed(struct termios *, speed_t);
int tcgetattr(int, struct termios *);
int tcsetattr(int, int, struct termios *);
#endif /* !_LOCORE */
+#include <compat/linux/linux_syscall.h>
+
/* linux/asm/unistd.h */
#define __NR_SYSCALL_BASE 0x900000
-#define __NR_exit (__NR_SYSCALL_BASE+ 1)
-#define __NR_read (__NR_SYSCALL_BASE+ 3)
-#define __NR_write (__NR_SYSCALL_BASE+ 4)
-#define __NR_open (__NR_SYSCALL_BASE+ 5)
-#define __NR_close (__NR_SYSCALL_BASE+ 6)
-#define __NR_time (__NR_SYSCALL_BASE+ 13)
-#define __NR_lseek32 (__NR_SYSCALL_BASE+ 19)
-#define __NR_ioctl (__NR_SYSCALL_BASE+ 54)
-#define __NR__new_select (__NR_SYSCALL_BASE+142)
-#define __NR_select __NR__new_select /* XXX */
+#define __NR_exit (__NR_SYSCALL_BASE+LINUX_SYS_exit)
+#define __NR_read (__NR_SYSCALL_BASE+LINUX_SYS_read)
+#define __NR_write (__NR_SYSCALL_BASE+LINUX_SYS_write)
+#define __NR_open (__NR_SYSCALL_BASE+LINUX_SYS_open)
+#define __NR_close (__NR_SYSCALL_BASE+LINUX_SYS_close)
+#define __NR_time (__NR_SYSCALL_BASE+LINUX_SYS_time)
+#define __NR_lseek32 (__NR_SYSCALL_BASE+LINUX_SYS_lseek)
+#define __NR_ioctl (__NR_SYSCALL_BASE+LINUX_SYS_ioctl)
+#define __NR_select (__NR_SYSCALL_BASE+LINUX_SYS_select)
+#define __NR_stat (__NR_SYSCALL_BASE+LINUX_SYS_stat)
#define __NR_syscall (__NR_SYSCALL_BASE+113)
#undef SYS_select
-#define SYS_select __NR__new_select
+#define SYS_select __NR_select
diff --git a/sys/arch/zaurus/stand/zboot/conf.c b/sys/arch/zaurus/stand/zboot/conf.c
index fed7131106f..0793eef266f 100644
--- a/sys/arch/zaurus/stand/zboot/conf.c
+++ b/sys/arch/zaurus/stand/zboot/conf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: conf.c,v 1.3 2005/05/09 14:09:20 uwe Exp $ */
+/* $OpenBSD: conf.c,v 1.4 2005/05/24 20:38:20 uwe Exp $ */
/*
* Copyright (c) 1996 Michael Shalayeff
@@ -38,31 +38,22 @@
#include <lib/libsa/tftp.h>
#include <lib/libsa/netif.h>
#endif
-#include <lib/libsa/unixdev.h>
+#include "unixdev.h"
#include <dev/cons.h>
-#if 0
-#include "debug.h"
-#endif
-const char version[] = "2.07";
-#if 0
+const char version[] = "2.08";
int debug = 1;
-#endif
void (*zaurus_probe1[])(void) = {
cninit
};
-#if 0
void (*zaurus_probe2[])(void) = {
diskprobe
};
-#endif
struct zaurus_boot_probes probe_list[] = {
{ "probing", zaurus_probe1, NENTS(zaurus_probe1) },
-#if 0
{ "disk", zaurus_probe2, NENTS(zaurus_probe2) }
-#endif
};
int nibprobes = NENTS(probe_list);
@@ -103,7 +94,8 @@ int n_netif_drivers = NENTS(netif_drivers);
#endif
struct consdev constab[] = {
- { unix_probe, unix_init, unix_getc, unix_putc },
+ { cn_probe, cn_init, cn_getc, cn_putc },
+ { com_probe, com_init, com_getc, com_putc },
{ NULL }
};
struct consdev *cn_tab = constab;
diff --git a/sys/arch/zaurus/stand/zboot/devopen.c b/sys/arch/zaurus/stand/zboot/devopen.c
index e5a81a880b1..3ef47b79bb1 100644
--- a/sys/arch/zaurus/stand/zboot/devopen.c
+++ b/sys/arch/zaurus/stand/zboot/devopen.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: devopen.c,v 1.4 2005/05/12 05:10:30 uwe Exp $ */
+/* $OpenBSD: devopen.c,v 1.5 2005/05/24 20:38:20 uwe Exp $ */
/*
* Copyright (c) 1996-1999 Michael Shalayeff
@@ -26,15 +26,12 @@
* THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "libsa.h"
#include <sys/param.h>
#include <sys/disklabel.h>
#include <dev/cons.h>
-
+#include "libsa.h"
#include <stand/boot/cmd.h>
-extern int debug;
-
/* XXX use slot for 'rd' for 'hd' pseudo-device */
const char bdevs[][4] = {
"wd", "", "fd", "wt", "sd", "st", "cd", "mcd",
@@ -45,12 +42,10 @@ const int nbdevs = NENTS(bdevs);
const char cdevs[][4] = {
"cn", "", "", "", "", "", "", "",
- "com", "", "", "", "pc"
+ "", "", "", "", "com"
};
const int ncdevs = NENTS(cdevs);
-int getbootdev(dev_t, char *);
-
/* pass dev_t to the open routines */
int
devopen(struct open_file *f, const char *fname, char **file)
@@ -91,95 +86,16 @@ devopen(struct open_file *f, const char *fname, char **file)
return rc;
}
-int
-getbootdev(dev_t bootdev, char *p)
+void
+devboot(dev_t bootdev, char *p)
{
- char buf[DEV_BSIZE];
- struct dos_partition *dp;
- struct disklabel label;
- static int timeout = 10;
- char *s;
- int fd;
- int n;
- char *msg = "";
+ dev_t unit = 0; /* XXX */
- s = p;
- *p++ = '/';
- *p++ = 'd';
- *p++ = 'e';
- *p++ = 'v';
- *p++ = '/';
*p++ = 'h';
*p++ = 'd';
- *p++ = 'a' + (bootdev & 0xf); /* a - h */
- *p = '\0';
-
- /*
- * Give disk devices some time to become ready when the first open
- * fails. Even when open succeeds the disk is sometimes not ready.
- */
- if ((fd = uopen(s, O_RDONLY)) == -1 && errno == ENXIO) {
- int t;
-
- while (fd == -1 && timeout > 0) {
- timeout--;
- t = getsecs() + 1;
- while (getsecs() < t)
- ;
- fd = uopen(s, O_RDONLY);
- }
- if (fd != -1) {
- t = getsecs() + 2;
- while (getsecs() < t)
- ;
- }
- }
- if (fd == -1)
- return 0;
-
- /* Read the disk's MBR. */
- if (unixstrategy((void *)fd, F_READ, DOSBBSECTOR, DEV_BSIZE, buf,
- &n) != 0 || n != DEV_BSIZE) {
- uclose(fd);
- return 0;
- }
-
- /* Find OpenBSD primary partition in the disk's MBR. */
- dp = (struct dos_partition *)&buf[DOSPARTOFF];
- for (n = 0; n < NDOSPART; n++)
- if (dp[n].dp_typ == DOSPTYP_OPENBSD)
- break;
- if (n == NDOSPART) {
- uclose(fd);
- return 0;
- }
- *p++ = '1' + n;
+ *p++ = '0' + unit;
+ *p++ = 'a';
*p = '\0';
- uclose(fd);
-
- /* Test if the OpenBSD partition has a valid disklabel. */
- if ((fd = uopen(s, O_RDONLY)) != -1) {
- if (unixstrategy((void *)fd, F_READ, LABELSECTOR,
- DEV_BSIZE, buf, &n) == 0 && n == DEV_BSIZE)
- msg = getdisklabel(buf, &label);
- uclose(fd);
- }
- return msg == NULL;
-}
-
-void
-devboot(dev_t bootdev, char *p)
-{
-
- if (bootdev != 0 && getbootdev(bootdev, p))
- return;
-
- for (bootdev = 0; bootdev < 8; bootdev++)
- if (getbootdev(bootdev, p))
- return;
-
- /* fall-back to the previous default device */
- strlcpy(p, "/dev/hda4", sizeof cmd.bootdev);
}
int pch_pos = 0;
@@ -224,9 +140,7 @@ getchar(void)
if ((c < ' ' && c != '\n') || c == '\177')
return c;
-#ifndef _TEST
putchar(c);
-#endif
return c;
}
diff --git a/sys/arch/zaurus/stand/zboot/disk.h b/sys/arch/zaurus/stand/zboot/disk.h
new file mode 100644
index 00000000000..9308972b483
--- /dev/null
+++ b/sys/arch/zaurus/stand/zboot/disk.h
@@ -0,0 +1,92 @@
+/* $OpenBSD: disk.h,v 1.1 2005/05/24 20:38:20 uwe Exp $ */
+
+/*
+ * Copyright (c) 1997 Tobias Weingartner
+ * 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.
+ *
+ * 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 REGENTS OR CONTRIBUTORS 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 _DISKPROBE_H
+#define _DISKPROBE_H
+
+#include <sys/queue.h>
+
+/* XXX snatched from <i386/biosdev.h> */
+#if 1
+/* Info about disk from the bios, plus the mapping from
+ * BIOS numbers to BSD major (driver?) number.
+ *
+ * Also, do not bother with BIOSN*() macros, just parcel
+ * the info out, and use it like this. This makes for less
+ * of a dependance on BIOSN*() macros having to be the same
+ * across /boot, /bsd, and userland.
+ */
+#define BOOTARG_DISKINFO 1
+typedef struct _bios_diskinfo {
+ /* BIOS section */
+ int bios_number; /* BIOS number of drive (or -1) */
+ u_int bios_cylinders; /* BIOS cylinders */
+ u_int bios_heads; /* BIOS heads */
+ u_int bios_sectors; /* BIOS sectors */
+ int bios_edd; /* EDD support */
+
+ /* BSD section */
+ dev_t bsd_dev; /* BSD device */
+
+ /* Checksum section */
+ u_int32_t checksum; /* Checksum for drive */
+
+ /* Misc. flags */
+ u_int32_t flags;
+#define BDI_INVALID 0x00000001 /* I/O error during checksumming */
+#define BDI_GOODLABEL 0x00000002 /* Had SCSI or ST506/ESDI disklabel */
+#define BDI_BADLABEL 0x00000004 /* Had another disklabel */
+#define BDI_EL_TORITO 0x00000008 /* 2,048-byte sectors */
+#define BDI_PICKED 0x80000000 /* kernel-only: cksum matched */
+
+} bios_diskinfo_t;
+
+#define BOOTARG_CKSUMLEN 3 /* u_int32_t */
+#endif /* 1 */
+
+/* All the info on a disk we've found */
+struct diskinfo {
+ bios_diskinfo_t bios_info;
+ struct disklabel disklabel;
+
+ dev_t bsddev, bootdev;
+
+ TAILQ_ENTRY(diskinfo) list;
+};
+TAILQ_HEAD(disklist_lh, diskinfo);
+
+/* diskprobe.c */
+struct diskinfo *dkdevice(dev_t, dev_t);
+void bios_devpath(int, int, char *);
+char *bios_getdiskinfo(int, bios_diskinfo_t *);
+int bios_getdospart(bios_diskinfo_t *);
+char *bios_getdisklabel(bios_diskinfo_t *, struct disklabel *);
+void dump_diskinfo(void);
+
+#endif /* _DISKPROBE_H */
diff --git a/sys/arch/zaurus/stand/zboot/diskprobe.c b/sys/arch/zaurus/stand/zboot/diskprobe.c
new file mode 100644
index 00000000000..8a24754e0b5
--- /dev/null
+++ b/sys/arch/zaurus/stand/zboot/diskprobe.c
@@ -0,0 +1,304 @@
+/* $OpenBSD: diskprobe.c,v 1.1 2005/05/24 20:38:20 uwe Exp $ */
+
+/*
+ * Copyright (c) 1997 Tobias Weingartner
+ * 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.
+ *
+ * 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 REGENTS OR CONTRIBUTORS 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.
+ *
+ */
+
+/* We want the disk type names from disklabel.h */
+#undef DKTYPENAMES
+
+#include <sys/param.h>
+#include <sys/queue.h>
+#include <sys/reboot.h>
+#include <sys/disklabel.h>
+#include <stand/boot/bootarg.h>
+#if 0
+#include <machine/biosvar.h>
+#endif
+#include <lib/libz/zlib.h>
+#include "disk.h"
+#if 0
+#include "biosdev.h"
+#endif
+#include "libsa.h"
+
+#define MAX_CKSUMLEN MAXBSIZE / DEV_BSIZE /* Max # of blks to cksum */
+
+/* Disk spin-up wait timeout. */
+static u_int timeout = 10;
+
+/* Local Prototypes */
+static void hardprobe(void);
+
+/* List of disk devices we found/probed */
+struct disklist_lh disklist;
+
+/*
+ * Probe for all hard disks.
+ */
+static void
+hardprobe(void)
+{
+ struct diskinfo *dip;
+ int i;
+ u_int bsdunit, type;
+ u_int scsi = 0, ide = 0;
+ u_int disk = 0;
+
+ /* Hard disks */
+ for (i = (0x80 + 8); i >= 0x80; i--) {
+ dip = alloc(sizeof(struct diskinfo));
+ bzero(dip, sizeof(*dip));
+
+ if (bios_getdiskinfo(i, &dip->bios_info) != NULL) {
+ free(dip, 0);
+ continue;
+ }
+
+ printf("hd%u", disk++);
+
+ /* Try to find the label, to figure out device type. */
+ if (bios_getdisklabel(&dip->bios_info, &dip->disklabel)
+ == NULL) {
+ printf("*");
+ bsdunit = ide++;
+ type = 0; /* XXX let it be IDE */
+ } else {
+ /* Best guess */
+ switch (dip->disklabel.d_type) {
+ case DTYPE_SCSI:
+ type = 4;
+ bsdunit = scsi++;
+ dip->bios_info.flags |= BDI_GOODLABEL;
+ break;
+
+ case DTYPE_ESDI:
+ case DTYPE_ST506:
+ type = 0;
+ bsdunit = ide++;
+ dip->bios_info.flags |= BDI_GOODLABEL;
+ break;
+
+ default:
+ dip->bios_info.flags |= BDI_BADLABEL;
+ type = 0; /* XXX Suggest IDE */
+ bsdunit = ide++;
+ }
+ }
+
+ dip->bios_info.checksum = 0; /* just in case */
+ /* Fill out best we can. */
+ dip->bios_info.bsd_dev =
+ MAKEBOOTDEV(type, 0, 0, bsdunit, RAW_PART);
+
+ /* Add to queue of disks. */
+ TAILQ_INSERT_TAIL(&disklist, dip, list);
+
+ printf(" ");
+ }
+}
+
+/* Probe for all BIOS supported disks */
+u_int32_t bios_cksumlen;
+void
+diskprobe(void)
+{
+ struct diskinfo *dip;
+ int i;
+
+ /* These get passed to kernel */
+ bios_diskinfo_t *bios_diskinfo;
+
+ /* Init stuff */
+ TAILQ_INIT(&disklist);
+
+ /* Do probes */
+ hardprobe();
+
+#if 0
+ /* Checksumming of hard disks */
+ for (i = 0; disksum(i++) && i < MAX_CKSUMLEN; )
+ ;
+ bios_cksumlen = i;
+
+ /* Get space for passing bios_diskinfo stuff to kernel */
+ for (i = 0, dip = TAILQ_FIRST(&disklist); dip;
+ dip = TAILQ_NEXT(dip, list))
+ i++;
+ bios_diskinfo = alloc(++i * sizeof(bios_diskinfo_t));
+
+ /* Copy out the bios_diskinfo stuff */
+ for (i = 0, dip = TAILQ_FIRST(&disklist); dip;
+ dip = TAILQ_NEXT(dip, list))
+ bios_diskinfo[i++] = dip->bios_info;
+
+ bios_diskinfo[i++].bios_number = -1;
+ /* Register for kernel use */
+ addbootarg(BOOTARG_CKSUMLEN, sizeof(u_int32_t), &bios_cksumlen);
+ addbootarg(BOOTARG_DISKINFO, i * sizeof(bios_diskinfo_t),
+ bios_diskinfo);
+#endif
+}
+
+/*
+ * Find info on the disk given by major + unit number.
+ */
+struct diskinfo *
+dkdevice(dev_t maj, dev_t unit)
+{
+ struct diskinfo *dip;
+
+ for (dip = TAILQ_FIRST(&disklist); dip;
+ dip = TAILQ_NEXT(dip, list)) {
+ /* XXX skip non-matching entries according to maj. */
+
+ if (unit-- == 0)
+ return dip;
+ }
+
+ return NULL;
+}
+
+/*
+ * Find the Linux device path that corresponds to the given "BIOS" disk,
+ * where 0x80 corresponds to /dev/hda, 0x81 to /dev/hdb, and so on.
+ */
+void
+bios_devpath(int dev, int part, char *p)
+{
+ *p++ = '/';
+ *p++ = 'd';
+ *p++ = 'e';
+ *p++ = 'v';
+ *p++ = '/';
+ if ((dev & 0x80) != 0)
+ *p++ = 'h';
+ else
+ *p++ = 'f';
+ *p++ = 'd';
+ *p++ = 'a' + (dev & 0x7f);
+ if (part != -1)
+ *p++ = '1' + part;
+ *p = '\0';
+}
+
+/*
+ * Fill out a bios_diskinfo_t for this device.
+ */
+char *
+bios_getdiskinfo(int dev, bios_diskinfo_t *bdi)
+{
+ static char path[PATH_MAX];
+ struct linux_stat sb;
+ char *p;
+
+ bzero(bdi, sizeof *bdi);
+ bdi->bios_number = -1;
+
+ bios_devpath(dev, -1, path);
+
+ if (ustat(path, &sb) != 0)
+ return "no device node";
+
+ bdi->bios_number = dev;
+
+ if (bios_getdospart(bdi) < 0)
+ return "no BSD partition";
+
+ return 0;
+}
+
+int
+bios_getdospart(bios_diskinfo_t *bdi)
+{
+ char path[PATH_MAX];
+ char buf[DEV_BSIZE];
+ struct dos_partition *dp;
+ int fd;
+ u_int part;
+ size_t rsize;
+
+ bios_devpath(bdi->bios_number, -1, path);
+
+ if ((fd = uopen(path, O_RDONLY)) == -1) {
+ errno = ENOENT;
+ return -1;
+ }
+
+ /* Read the disk's MBR. */
+ if (unixstrategy((void *)fd, F_READ, DOSBBSECTOR,
+ DEV_BSIZE, buf, &rsize) != 0 || rsize != DEV_BSIZE) {
+ uclose(fd);
+ errno = EIO;
+ return -1;
+ }
+
+ /* Find OpenBSD primary partition in the disk's MBR. */
+ dp = (struct dos_partition *)&buf[DOSPARTOFF];
+ for (part = 0; part < NDOSPART; part++)
+ if (dp[part].dp_typ == DOSPTYP_OPENBSD)
+ break;
+ if (part == NDOSPART) {
+ uclose(fd);
+ errno = ERDLAB;
+ return -1;
+ }
+ uclose(fd);
+
+ return part;
+}
+
+char *
+bios_getdisklabel(bios_diskinfo_t *bdi, struct disklabel *label)
+{
+ char path[PATH_MAX];
+ char buf[DEV_BSIZE];
+ int part;
+ int fd;
+ size_t rsize;
+
+ part = bios_getdospart(bdi);
+ if (part < 0)
+ return "no BSD partition";
+
+ bios_devpath(bdi->bios_number, part, path);
+
+ /* Test if the OpenBSD partition has a valid disklabel. */
+ if ((fd = uopen(path, O_RDONLY)) != -1) {
+ char *msg = "failed to read disklabel";
+
+ if (unixstrategy((void *)fd, F_READ, LABELSECTOR,
+ DEV_BSIZE, buf, &rsize) == 0 && rsize == DEV_BSIZE)
+ msg = getdisklabel(buf, label);
+ uclose(fd);
+ /* Don't wait for other disks if this label is ok. */
+ if (msg == NULL)
+ timeout = 0;
+ return (msg);
+ }
+
+ return "failed to open partition";
+}
diff --git a/sys/arch/zaurus/stand/zboot/exit.c b/sys/arch/zaurus/stand/zboot/exit.c
index 4c6a29e9056..d500e3f56aa 100644
--- a/sys/arch/zaurus/stand/zboot/exit.c
+++ b/sys/arch/zaurus/stand/zboot/exit.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exit.c,v 1.3 2005/05/12 05:10:30 uwe Exp $ */
+/* $OpenBSD: exit.c,v 1.4 2005/05/24 20:38:20 uwe Exp $ */
/* $NetBSD: exit.c,v 1.11 1996/12/01 20:22:19 pk Exp $ */
/*-
@@ -33,6 +33,10 @@
#include "libsa.h"
+/* unixcons.c */
+extern struct termios tioc;
+extern int tioc_valid;
+
__dead void
panic(const char *fmt, ...)
{
@@ -61,8 +65,7 @@ panic(const char *fmt, ...)
void
exit(void)
{
- extern struct termios otc;
-
- (void)tcsetattr(0, TCSADRAIN, &otc);
+ if (tioc_valid)
+ (void)tcsetattr(0, TCSADRAIN, &tioc);
uexit(0);
}
diff --git a/sys/arch/zaurus/stand/zboot/libsa.h b/sys/arch/zaurus/stand/zboot/libsa.h
index 295b084fb18..b0c4064eeeb 100644
--- a/sys/arch/zaurus/stand/zboot/libsa.h
+++ b/sys/arch/zaurus/stand/zboot/libsa.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: libsa.h,v 1.2 2005/01/10 21:10:57 uwe Exp $ */
+/* $OpenBSD: libsa.h,v 1.3 2005/05/24 20:38:20 uwe Exp $ */
/*
* Copyright (c) 2005 Uwe Stuehler <uwe@bsdx.de>
@@ -18,6 +18,8 @@
#include <lib/libsa/stand.h>
+#include "compat_linux.h"
+
#define EXEC_ELF
#define DEFAULT_KERNEL_ADDRESS 0xa0200000
@@ -28,8 +30,15 @@ struct zaurus_boot_probes {
int count;
};
+void diskprobe(void);
+
+extern const char bdevs[][4];
+extern const int nbdevs;
+
extern struct zaurus_boot_probes probe_list[];
extern int nibprobes;
+#if 0
extern void (*devboot_p)(dev_t, char *);
+#endif
-#include "compat_linux.h"
+extern int debug;
diff --git a/sys/arch/zaurus/stand/zboot/loadfile.c b/sys/arch/zaurus/stand/zboot/loadfile.c
index a87e035b66d..119094ee355 100644
--- a/sys/arch/zaurus/stand/zboot/loadfile.c
+++ b/sys/arch/zaurus/stand/zboot/loadfile.c
@@ -1,5 +1,5 @@
/* $NetBSD: loadfile.c,v 1.10 2000/12/03 02:53:04 tsutsui Exp $ */
-/* $OpenBSD: loadfile.c,v 1.2 2005/01/24 22:20:33 uwe Exp $ */
+/* $OpenBSD: loadfile.c,v 1.3 2005/05/24 20:38:20 uwe Exp $ */
/*-
* Copyright (c) 1997 The NetBSD Foundation, Inc.
@@ -108,6 +108,7 @@ static int elf_exec(int, Elf_Ehdr *, u_long *, int);
static int aout_exec(int, struct exec *, u_long *, int);
#endif
#ifdef BOOT_ZBOOT
+#include <dev/cons.h> /* XXX */
static int zboot_exec(int, u_long *, int);
#endif
@@ -664,16 +665,28 @@ zboot_exec(int fd, u_long *marks, int flags)
}
buf[0] = ' ';
+ buf[1] = '-';
+ if (uwrite(tofd, buf, 2) != 2) {
+ printf("zboot_exec: argument write error\n");
+ goto err;
+ }
+
i = (cmd.argc > 1 && cmd.argv[1][0] != '-') ? 2 : 1;
for (; i < cmd.argc; i++) {
-
- if (i > 0 && uwrite(tofd, buf, 1) != 1) {
+ p = cmd.argv[i];
+ if (*p == '-')
+ p++;
+ sz = strlen(p);
+ if (uwrite(tofd, p, sz) != sz) {
printf("zboot_exec: argument write error\n");
goto err;
}
+ }
- sz = strlen(cmd.argv[i]);
- if (uwrite(tofd, cmd.argv[i], sz) != sz) {
+ /* Select UART unit for serial console. */
+ if (cn_tab && major(cn_tab->cn_dev) == 12) {
+ buf[0] = '0' + minor(cn_tab->cn_dev);
+ if (uwrite(tofd, buf, 1) != 1) {
printf("zboot_exec: argument write error\n");
goto err;
}
diff --git a/sys/arch/zaurus/stand/zboot/machdep.c b/sys/arch/zaurus/stand/zboot/machdep.c
index 1411b3f61bf..e0a38d66eee 100644
--- a/sys/arch/zaurus/stand/zboot/machdep.c
+++ b/sys/arch/zaurus/stand/zboot/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.3 2005/05/12 05:10:30 uwe Exp $ */
+/* $OpenBSD: machdep.c,v 1.4 2005/05/24 20:38:20 uwe Exp $ */
/*
* Copyright (c) 2004 Tom Cosgrove
@@ -29,24 +29,13 @@
#include "libsa.h"
-struct termios otc;
-
char _alloc_heap[4 * 1024 * 1024];
-int debug;
-
void
machdep(void)
{
int i, j;
struct zaurus_boot_probes *pr;
- struct termios t;
-
- if (tcgetattr(0, &t) == 0) {
- otc = t;
- cfmakeraw(&t);
- (void)tcsetattr(0, TCSAFLUSH, &t);
- }
/*
* The list of probe routines is now in conf.c.
diff --git a/sys/arch/zaurus/stand/zboot/termios.c b/sys/arch/zaurus/stand/zboot/termios.c
index b7c883f6484..87f86085673 100644
--- a/sys/arch/zaurus/stand/zboot/termios.c
+++ b/sys/arch/zaurus/stand/zboot/termios.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: termios.c,v 1.1 2005/05/12 05:10:30 uwe Exp $ */
+/* $OpenBSD: termios.c,v 1.2 2005/05/24 20:38:20 uwe Exp $ */
/*-
* Copyright (c) 1989, 1993
@@ -31,6 +31,39 @@
#include "libsa.h"
+/* Linux-specific line speed handling from linux_termios.c */
+
+static speed_t linux_speeds[] = {
+ 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
+ 9600, 19200, 38400, 57600, 115200, 230400
+};
+
+static const int linux_spmasks[] = {
+ LINUX_B0, LINUX_B50, LINUX_B75, LINUX_B110, LINUX_B134, LINUX_B150,
+ LINUX_B200, LINUX_B300, LINUX_B600, LINUX_B1200, LINUX_B1800,
+ LINUX_B2400, LINUX_B4800, LINUX_B9600, LINUX_B19200, LINUX_B38400,
+ LINUX_B57600, LINUX_B115200, LINUX_B230400
+};
+
+int
+cfsetspeed(struct termios *t, speed_t speed)
+{
+ int mask;
+ int i;
+
+ mask = LINUX_B9600; /* XXX default value should this be 0? */
+ for (i = 0; i < sizeof (linux_speeds) / sizeof (speed_t); i++) {
+ if (speed == linux_speeds[i]) {
+ mask = linux_spmasks[i];
+ break;
+ }
+ }
+ t->c_cflag &= ~LINUX_CBAUD;
+ t->c_cflag |= mask;
+
+ return (0);
+}
+
void
cfmakeraw(struct termios *t)
{
@@ -63,7 +96,7 @@ tcsetattr(int fd, int action, struct termios *t)
break;
default:
errno = EINVAL;
- return -1;
+ return (-1);
}
return (uioctl(fd, action, t));
}
diff --git a/sys/arch/zaurus/stand/zboot/unixcons.c b/sys/arch/zaurus/stand/zboot/unixcons.c
new file mode 100644
index 00000000000..6c34b5c8fe9
--- /dev/null
+++ b/sys/arch/zaurus/stand/zboot/unixcons.c
@@ -0,0 +1,231 @@
+/* $OpenBSD: unixcons.c,v 1.1 2005/05/24 20:38:20 uwe Exp $ */
+
+/*
+ * Copyright (c) 1997-1999 Michael Shalayeff
+ * 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.
+ *
+ * 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 OR HIS RELATIVES 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 MIND, 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 <dev/cons.h>
+#include "libsa.h"
+#include "unixdev.h"
+
+struct termios tioc;
+int tioc_valid = 0;
+
+#define NCOM 3
+const char *compath[NCOM] = {
+ "/dev/ttyS0", /* com0 */
+ "/dev/ttyS2", /* com1 */
+ "/dev/ttyS1" /* com2 */
+};
+
+int com_fd = -1; /* open serial port */
+int com_speed = 9600; /* default speed is 9600 baud */
+
+/* Local prototypes */
+void common_putc(dev_t, int);
+int common_getc(dev_t);
+
+
+void
+common_putc(dev_t dev, int c)
+{
+ /* Always send to stdout. */
+ (void)uwrite(1, &c, 1);
+
+ /* Copy to serial if open. */
+ if (com_fd != -1)
+ (void)uwrite(com_fd, &c, 1);
+}
+
+int
+common_getc(dev_t dev)
+{
+ struct timeval tv;
+ fd_set fdset;
+ int fd, nfds, n;
+ char c;
+
+ while (1) {
+ tv.tv_sec = 0;
+ tv.tv_usec = 10000;
+ FD_ZERO(&fdset);
+
+ /* Always read from stdin. */
+ fd = 0;
+ nfds = 1;
+ FD_SET(fd, &fdset);
+
+ /* Read from serial if open. */
+ if (com_fd != -1) {
+ nfds = com_fd+1;
+ FD_SET(com_fd, &fdset);
+ }
+
+ n = uselect(nfds, &fdset, NULL, NULL, &tv);
+ if ((dev & 0x80) != 0)
+ return (n > 0);
+
+ if (n > 0)
+ break;
+ }
+
+ for (fd = 0; fd < nfds; fd++)
+ if (FD_ISSET(fd, &fdset))
+ break;
+
+ return (uread(fd, &c, 1) < 1 ? -1 : c);
+}
+
+
+void
+cn_probe(struct consdev *cn)
+{
+ cn->cn_pri = CN_INTERNAL;
+ cn->cn_dev = makedev(0,0);
+ printf("cn%d ", minor(cn->cn_dev));
+}
+
+void
+cn_init(struct consdev *cn)
+{
+ struct termios t;
+
+ if (!tioc_valid && tcgetattr(0, &t) == 0) {
+ tioc = t;
+ tioc_valid = 1;
+ cfmakeraw(&t);
+ (void)tcsetattr(0, TCSAFLUSH, &t);
+ }
+}
+
+void
+cn_putc(dev_t dev, int c)
+{
+ common_putc(dev, c);
+}
+
+int
+cn_getc(dev_t dev)
+{
+ return (common_getc(dev));
+}
+
+
+void
+com_probe(struct consdev *cn)
+{
+ int i;
+ struct linux_stat sb;
+
+ for (i = 0; i < NCOM; i++) {
+ if (ustat(compath[i], &sb) != 0)
+ continue;
+ printf("com%d ", i);
+ }
+
+ cn->cn_pri = CN_NORMAL;
+ /* XXX from arm/conf.c */
+ cn->cn_dev = makedev(12, 0);
+}
+
+void
+com_init(struct consdev *cn)
+{
+ struct termios t;
+ int unit = minor(cn->cn_dev);
+
+ if (unit >= NCOM)
+ return;
+
+ if (com_fd != -1)
+ uclose(com_fd);
+
+ com_fd = uopen(compath[unit], O_RDWR);
+ if (com_fd == -1)
+ return;
+
+ if (tcgetattr(com_fd, &t) == 0) {
+ cfmakeraw(&t);
+ cfsetspeed(&t, (speed_t)com_speed);
+ (void)tcsetattr(com_fd, TCSAFLUSH, &t);
+ }
+}
+
+void
+com_putc(dev_t dev, int c)
+{
+ common_putc(dev, c);
+}
+
+int
+com_getc(dev_t dev)
+{
+ return (common_getc(dev));
+}
+
+
+int
+cnspeed(dev_t dev, int sp)
+{
+ if (major(dev) == 12) /* comN */
+ return (comspeed(dev, sp));
+
+ /* cn0 or anything else */
+ return (9600);
+}
+
+/* call with sp == 0 to query the current speed */
+int
+comspeed(dev_t dev, int sp)
+{
+ struct termios t;
+
+ if (sp <= 0)
+ return (com_speed);
+
+ /* check if the new speed is a valid baud rate */
+ if (cfsetspeed(&t, (speed_t)sp) != 0)
+ sp = com_speed;
+
+ if (cn_tab && cn_tab->cn_dev == dev && com_speed != sp) {
+ printf("com%d: changing speed to %d baud in 5 seconds, "
+ "change your terminal to match!\n\a",
+ minor(dev), sp);
+ sleep(5);
+ if (com_fd != -1 && tcgetattr(com_fd, &t) == 0) {
+ (void)cfsetspeed(&t, (speed_t)sp);
+ (void)tcsetattr(com_fd, TCSAFLUSH, &t);
+ }
+ printf("\n");
+ }
+
+ if (com_speed != sp) {
+ printf("com%d: %d baud\n", minor(dev), sp);
+ com_speed = sp;
+ }
+
+ return (com_speed);
+}
diff --git a/sys/arch/zaurus/stand/zboot/unixdev.c b/sys/arch/zaurus/stand/zboot/unixdev.c
index e4d713a8e6f..d0d52a5e063 100644
--- a/sys/arch/zaurus/stand/zboot/unixdev.c
+++ b/sys/arch/zaurus/stand/zboot/unixdev.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: unixdev.c,v 1.4 2005/04/13 04:33:47 uwe Exp $ */
+/* $OpenBSD: unixdev.c,v 1.5 2005/05/24 20:38:20 uwe Exp $ */
/*
* Copyright (c) 1996-1998 Michael Shalayeff
@@ -28,19 +28,18 @@
*/
#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/time.h>
+#include <sys/reboot.h>
+#include <sys/disklabel.h>
#include <sys/syscall.h>
+#include <sys/time.h>
#define open uopen
#include <sys/fcntl.h>
#include <dev/cons.h>
#undef open
+#include "disk.h"
#include "libsa.h"
#include <lib/libsa/unixdev.h>
-/* unixsys.S */
-int uselect(int, fd_set *, fd_set *, fd_set *, struct timeval *);
-
int
unixstrategy(void *devdata, int rw, daddr_t blk, size_t size, void *buf,
size_t *rsize)
@@ -48,7 +47,7 @@ unixstrategy(void *devdata, int rw, daddr_t blk, size_t size, void *buf,
int rc = 0;
off_t off;
-#ifdef UNIX_DEBUG
+#ifdef UNIX_DEBUG
printf("unixstrategy: %s %d bytes @ %d\n",
(rw==F_READ?"reading":"writing"), size, blk);
#endif
@@ -70,40 +69,101 @@ unixstrategy(void *devdata, int rw, daddr_t blk, size_t size, void *buf,
int
unixopen(struct open_file *f, ...)
{
- char **file, *p = NULL;
- va_list ap;
- int fd;
- int c;
+ va_list ap;
+ char path[PATH_MAX];
+ char *cp, **file;
+ dev_t maj, unit, part, bsd_dev;
+ struct diskinfo *dip;
va_start(ap, f);
- file = va_arg(ap, char **);
+ cp = *(file = va_arg(ap, char **));
va_end(ap);
-#ifdef UNIX_DEBUG
- printf("unixopen: %s\n", *file);
+#ifdef UNIX_DEBUG
+ if (debug)
+ printf("unixopen: %s\n", cp);
#endif
- /* p = strchr(p, ':') */
- for (p = *file; *p != '\0' && *p != ':'; p++)
+ f->f_devdata = NULL;
+ /* Search for device specification. */
+ if (strlen(cp) < 4)
+ return ENOENT;
+ cp += 2;
+ if (cp[2] != ':') {
+ if (cp[3] != ':')
+ return ENOENT;
+ else
+ cp++;
+ }
+
+ for (maj = 0;
+ maj < nbdevs && strncmp(*file, bdevs[maj], cp - *file) != 0;
+ maj++)
;
+ if (maj >= nbdevs) {
+ printf("Unknown device: ");
+ for (cp = *file; *cp != ':'; cp++)
+ putchar(*cp);
+ putchar('\n');
+ return EADAPT;
+ }
- c = *p;
- *p = '\0';
-#if 0
- f->f_devdata = (void *)(fd = uopen(*file, O_RDWR, 0));
-#else
- f->f_devdata = (void *)(fd = uopen(*file, O_RDONLY, 0));
-#endif
- *p = c;
+ /* Get unit. */
+ if ('0' <= *cp && *cp <= '9')
+ unit = *cp++ - '0';
+ else {
+ printf("Bad unit number\n");
+ return EUNIT;
+ }
+
+ /* Get partition. */
+ if ('a' <= *cp && *cp <= 'p')
+ part = *cp++ - 'a';
+ else {
+ printf("Bad partition id\n");
+ return EPART;
+ }
- if (*p == '\0')
- *file = p;
- else if (*(p+1) == '\0')
- *file = (char *)"/";
+ cp++; /* skip ':' */
+ if (*cp != 0)
+ *file = cp;
else
- *file = p+1;
+ f->f_flags |= F_RAW;
+
+ /* Find device. */
+ dip = dkdevice(maj, unit);
+ if (dip == (struct diskinfo *)NULL)
+ return ENOENT;
+
+ /* Fix up bootdev. */
+ bsd_dev = dip->bios_info.bsd_dev;
+ dip->bsddev = MAKEBOOTDEV(B_TYPE(bsd_dev), B_ADAPTOR(bsd_dev),
+ B_CONTROLLER(bsd_dev), unit, part);
+ dip->bootdev = MAKEBOOTDEV(B_TYPE(bsd_dev), B_ADAPTOR(bsd_dev),
+ B_CONTROLLER(bsd_dev), B_UNIT(bsd_dev), part);
+
+ /* Try for disklabel again (might be removable media). */
+ if (dip->bios_info.flags & BDI_BADLABEL) {
+ const char *st = bios_getdisklabel(&dip->bios_info,
+ &dip->disklabel);
+#ifdef UNIX_DEBUG
+ if (debug && st)
+ printf("%s\n", st);
+#endif
+ if (!st) {
+ dip->bios_info.flags &= ~BDI_BADLABEL;
+ dip->bios_info.flags |= BDI_GOODLABEL;
+ } else
+ return ERDLAB;
+ }
+
+ part = bios_getdospart(&dip->bios_info);
+ bios_devpath(dip->bios_info.bios_number, part, path);
+ f->f_devdata = (void *)uopen(path, O_RDONLY);
+ if ((int)f->f_devdata == -1)
+ return errno;
- return fd < 0 ? -1 : 0;
+ return 0;
}
int
@@ -144,78 +204,20 @@ ulseek(int fd, off_t off, int wh)
return r;
}
-
-void
-unix_probe(struct consdev *cn)
-{
- cn->cn_pri = CN_INTERNAL;
- cn->cn_dev = makedev(0,0);
- printf("ux%d ", minor(cn->cn_dev));
-}
-
-void
-unix_init(struct consdev *cn)
-{
-}
-
-void
-unix_putc(dev_t dev, int c)
-{
- uwrite(1, &c, 1);
-}
-
-int
-unix_getc(dev_t dev)
-{
- if (dev & 0x80) {
- struct timeval tv;
- fd_set fdset;
- int rc;
-
- tv.tv_sec = 0;
- tv.tv_usec = 0;
- FD_ZERO(&fdset);
- FD_SET(0, &fdset);
-
-#if 0
- rc = syscall(SYS_select, 1, &fdset, NULL, NULL, &tv);
-#else
- rc = uselect(1, &fdset, NULL, NULL, &tv);
-#endif
- if (rc <= 0)
- return 0;
- else
- return 1;
- } else {
- char c;
-
- return uread(0, &c, 1)<1? -1: c;
- }
-}
-
time_t
getsecs(void)
{
return (time_t)syscall(__NR_time, NULL);
}
-void
-time_print(void)
+unsigned int
+sleep(unsigned int seconds)
{
-}
-
-void
-atexit(void)
-{
-}
+ unsigned int start;
-int
-cnspeed(dev_t dev, int sp)
-{
- return 9600;
-}
+ start = getsecs();
+ while (getsecs() - start < seconds)
+ ;
-void
-__main(void)
-{
+ return (0);
}
diff --git a/sys/arch/zaurus/stand/zboot/unixdev.h b/sys/arch/zaurus/stand/zboot/unixdev.h
new file mode 100644
index 00000000000..50734544d5d
--- /dev/null
+++ b/sys/arch/zaurus/stand/zboot/unixdev.h
@@ -0,0 +1,57 @@
+/* $OpenBSD: unixdev.h,v 1.1 2005/05/24 20:38:20 uwe Exp $ */
+
+/*
+ * Copyright (c) 1996 Michael Shalayeff
+ * 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.
+ *
+ * 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 REGENTS OR CONTRIBUTORS 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.
+ *
+ */
+
+/* unixdev.c */
+int unixstrategy(void *, int, daddr_t, size_t, void *, size_t *);
+int unixopen(struct open_file *, ...);
+int unixclose(struct open_file *);
+int unixioctl(struct open_file *, u_long, void *);
+
+/* unixcons.c */
+void cn_probe(struct consdev *);
+void cn_init(struct consdev *);
+void cn_putc(dev_t, int);
+int cn_getc(dev_t);
+void com_probe(struct consdev *);
+void com_init(struct consdev *);
+void com_putc(dev_t, int);
+int com_getc(dev_t);
+int comspeed(dev_t, int);
+
+/* unixsys.S */
+int uopen(const char *, int, ...);
+int uread(int, void *, size_t);
+int uwrite(int, void *, size_t);
+int uioctl(int, u_long, char *);
+int uclose(int);
+off_t ulseek(int, off_t, int);
+void uexit(int) __attribute__((noreturn));
+int uselect(int, fd_set *, fd_set *, fd_set *, struct timeval *);
+int syscall(int, ...);
+int __syscall(quad_t, ...);
diff --git a/sys/arch/zaurus/stand/zboot/unixsys.S b/sys/arch/zaurus/stand/zboot/unixsys.S
index a956adc2240..eb8a6284f9c 100644
--- a/sys/arch/zaurus/stand/zboot/unixsys.S
+++ b/sys/arch/zaurus/stand/zboot/unixsys.S
@@ -1,4 +1,4 @@
-/* $OpenBSD: unixsys.S,v 1.5 2005/04/13 04:33:47 uwe Exp $ */
+/* $OpenBSD: unixsys.S,v 1.6 2005/05/24 20:38:20 uwe Exp $ */
/*
* Copyright (c) 2005 Uwe Stuehler <uwe@bsdx.de>
@@ -27,13 +27,14 @@
swi __NR_##x; \
b 1f
-RSYSCALL(open)
+RSYSCALL(exit)
RSYSCALL(read)
RSYSCALL(write)
+RSYSCALL(open)
+RSYSCALL(close)
RSYSCALL(lseek32)
RSYSCALL(ioctl)
-RSYSCALL(close)
-RSYSCALL(exit)
+RSYSCALL(stat)
1:
cmn r0, #4096