summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>2006-10-06 21:48:51 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>2006-10-06 21:48:51 +0000
commit83b32e82fc7a5cb82458e3db56483ae958f083d3 (patch)
tree25cb7e586908e5deebe19642a6468c09585163eb /sys
parentcd7ea476994e7b1417f1387ef000c66afa1da348 (diff)
w/ help of netbsd srcs and some mother unzel made it lift off
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/landisk/conf/GENERIC41
-rw-r--r--sys/arch/landisk/conf/Makefile.landisk4
-rw-r--r--sys/arch/landisk/landisk/conf.c542
-rw-r--r--sys/arch/landisk/landisk/machdep.c25
-rw-r--r--sys/arch/landisk/landisk/mainbus.c24
-rw-r--r--sys/arch/landisk/stand/Makefile5
-rw-r--r--sys/arch/landisk/stand/Makefile.inc12
-rw-r--r--sys/arch/landisk/stand/boot/Makefile42
-rw-r--r--sys/arch/landisk/stand/boot/conf.c52
-rw-r--r--sys/arch/landisk/stand/boot/delay.c131
-rw-r--r--sys/arch/landisk/stand/boot/devs.c160
-rw-r--r--sys/arch/landisk/stand/boot/getsecs.c202
-rw-r--r--sys/arch/landisk/stand/boot/libsa.h34
-rw-r--r--sys/arch/landisk/stand/boot/scifcons.c250
-rw-r--r--sys/arch/landisk/stand/boot/srt0.S153
-rw-r--r--sys/arch/landisk/stand/bootxx/Makefile45
-rw-r--r--sys/arch/landisk/stand/bootxx/boot1.c157
-rw-r--r--sys/arch/landisk/stand/bootxx/bootxx.868
-rw-r--r--sys/arch/landisk/stand/bootxx/bootxx.S137
-rw-r--r--sys/arch/landisk/stand/bootxx/pbr.S212
-rw-r--r--sys/arch/landisk/stand/mbr/Makefile25
-rw-r--r--sys/arch/landisk/stand/mbr/mbr.860
-rw-r--r--sys/arch/landisk/stand/mbr/mbr.S212
23 files changed, 2551 insertions, 42 deletions
diff --git a/sys/arch/landisk/conf/GENERIC b/sys/arch/landisk/conf/GENERIC
index 6986a30abc4..dd87ef1f6d8 100644
--- a/sys/arch/landisk/conf/GENERIC
+++ b/sys/arch/landisk/conf/GENERIC
@@ -1,4 +1,4 @@
-# $OpenBSD: GENERIC,v 1.1 2006/10/06 21:16:15 miod Exp $
+# $OpenBSD: GENERIC,v 1.2 2006/10/06 21:48:50 mickey Exp $
#
# For further information on compiling OpenBSD kernels, see the config(8)
# man page.
@@ -21,52 +21,55 @@ option PCLOCK=33333333 # 33.33MHz clock
option DONT_INIT_BSC
#option DONT_INIT_PCIBSC
+option PCIVERBOSE
+option USBVERBOSE
+
# Cache options.
option SH4_CACHE_DISABLE_EMODE # disable extended (2x larger) mode
-#config bsd swap generic
-config bsd root on wd0a
+config bsd swap generic
+#config bsd root on wd0a
mainbus0 at root
cpu0 at mainbus?
# PCI bus support
shpcic* at mainbus? # SH7751 PCIC
-pci0 at shpcic? bus ?
+pci0 at shpcic?
# SH bus
shb* at mainbus?
# ob-board I/O bus
-obio0 at mainbus?
+#obio0 at mainbus?
# Serial Devices
option SCIFCONSOLE
option SCIFCN_SPEED=9600
scif0 at shb?
-clock0 at shb?
+#clock0 at shb?
-wdc0 at obio? port 0x14000000 irq 10 # CF
-wd* at wdc? flags 0x0000
+#wdc0 at obio? port 0x14000000 irq 10 # CF
+#wd* at wdc? flags 0x0000
# Network Interfaces
# PCI network interfaces
-re* at pci? dev ? function ? # Realtek 8139C+/8169/8169S/8110S
-rl* at pci? dev ? function ? # Realtek 8129/8139
+#re* at pci? # Realtek 8139C+/8169/8169S/8110S
+#rl* at pci? # Realtek 8129/8139
# MII/PHY support
-rgephy* at mii? phy ?
-rlphy* at mii? phy ? # Realtek 8139/8201L PHYs
-urlphy* at mii? phy ? # Realtek RTL8150L internal PHYs
-ukphy* at mii? phy ? # generic unknown PHYs
+#rgephy* at mii? phy ?
+#rlphy* at mii? phy ? # Realtek 8139/8201L PHYs
+#urlphy* at mii? phy ? # Realtek RTL8150L internal PHYs
+#ukphy* at mii? phy ? # generic unknown PHYs
# USB Controller and Devices
# PCI USB controllers
-ehci* at pci? dev ? function ? # Enhanced Host Controller
-ohci* at pci? dev ? function ? # Open Host Controller
+ehci* at pci? # Enhanced Host Controller
+ohci* at pci? # Open Host Controller
# USB bus support
usb* at ehci?
@@ -82,10 +85,10 @@ uhidev* at uhub? port ? configuration ? interface ?
# USB Mass Storage
umass* at uhub? port ? configuration ? interface ?
scsibus* at umass?
-atapiscsi* at umass?
+#atapiscsi* at umass?
-sd* at scsibus? target ? lun ? # SCSI disk drives
-cd* at scsibus? target ? lun ? # SCSI CD-ROM drives
+sd* at scsibus? # SCSI disk drives
+cd* at scsibus? # SCSI CD-ROM drives
# USB Generic driver
ugen* at uhub? port ?
diff --git a/sys/arch/landisk/conf/Makefile.landisk b/sys/arch/landisk/conf/Makefile.landisk
index 490dbb3b6c4..38f4ae8bc75 100644
--- a/sys/arch/landisk/conf/Makefile.landisk
+++ b/sys/arch/landisk/conf/Makefile.landisk
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile.landisk,v 1.1 2006/10/06 21:16:15 miod Exp $
+# $OpenBSD: Makefile.landisk,v 1.2 2006/10/06 21:48:50 mickey Exp $
#
# Makefile for OpenBSD/landisk
#
@@ -52,7 +52,7 @@ CMACHFLAGS+= -fno-stack-protector
COPTS?= -O2
CFLAGS= ${DEBUG} ${CWARNFLAGS} ${CMACHFLAGS} ${COPTS} ${PIPE}
AFLAGS= -x assembler-with-cpp -traditional-cpp -D_LOCORE -Wa,-little
-LINKFLAGS= -N -Ttext 0x8c001000 -e start --warn-common
+LINKFLAGS= -N -Ttext 0x8c002000 -e start --warn-common
STRIPFLAGS= -g -X -x
HOSTCC?= ${CC}
diff --git a/sys/arch/landisk/landisk/conf.c b/sys/arch/landisk/landisk/conf.c
new file mode 100644
index 00000000000..6180cb38565
--- /dev/null
+++ b/sys/arch/landisk/landisk/conf.c
@@ -0,0 +1,542 @@
+/* $OpenBSD: conf.c,v 1.1 2006/10/06 21:48:50 mickey Exp $ */
+
+/*
+ * Copyright (c) 1994-1998 Mark Brinicombe.
+ * 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 Mark Brinicombe
+ * for the NetBSD Project.
+ * 4. The name of the company nor the name of the author may 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 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.
+ *
+ * RiscBSD kernel project
+ *
+ * conf.c
+ *
+ * Character and Block Device configuration
+ * Console configuration
+ *
+ * Defines the structures cdevsw and constab
+ *
+ * Created : 17/09/94
+ */
+
+#include <sys/param.h>
+#include <sys/systm.h>
+#include <sys/buf.h>
+#include <sys/ioctl.h>
+#include <sys/tty.h>
+#include <sys/conf.h>
+#include <sys/vnode.h>
+
+#include <machine/conf.h>
+
+#include "inet.h"
+
+/*
+ * From this point, these need to be MI foo.h files.
+ */
+
+/*
+ * Standard MI devices (e.g. ones in dev/ic)
+ */
+#include "com.h" /* NS164x0 serial ports */
+
+/*
+ * Standard pseudo-devices
+ */
+#include "bpfilter.h"
+#include "pf.h"
+#include "pty.h"
+#include "tun.h"
+#include "ksyms.h"
+
+/*
+ * APM interface
+ */
+#ifdef CONF_HAVE_APM
+#include "apm.h"
+#else
+#define NAPM 0
+#endif
+
+/*
+ * Disk/Filesystem pseudo-devices
+ */
+#include "ccd.h" /* concatenated disk driver */
+#include "rd.h" /* memory disk driver */
+#include "raid.h" /* RAIDframe */
+#include "vnd.h" /* vnode disk driver */
+
+/*
+ * WD/ATA devices
+ */
+#include "wd.h"
+bdev_decl(wd);
+bdev_decl(sw);
+
+#ifdef USER_PCICONF
+#include "pci.h"
+cdev_decl(pci);
+#endif
+
+/*
+ * SCSI/ATAPI devices
+ */
+#include "sd.h"
+#include "st.h"
+#include "cd.h"
+#include "ch.h"
+#include "uk.h"
+#include "ss.h"
+
+/*
+ * Audio devices
+ */
+#include "audio.h"
+#include "midi.h"
+#include "sequencer.h"
+
+/*
+ * USB devices
+ */
+#include "usb.h"
+#include "ucom.h"
+#include "ugen.h"
+#include "uhid.h"
+#include "ulpt.h"
+#include "urio.h"
+#include "uscanner.h"
+
+/*
+ * WSCONS devices
+ */
+#if 0
+#include "wsdisplay.h"
+/*
+#include "wsfont.h"
+*/
+#include "wskbd.h"
+#include "wsmouse.h"
+#include "wsmux.h"
+#else
+#define NWSDISPLAY 0
+#define NWSMOUSE 0
+#define NWSKBD 0
+#define NWSMUX 0
+#endif
+cdev_decl(wskbd);
+cdev_decl(wsmouse);
+
+#include "lpt.h"
+#ifdef CONF_HAVE_FCOM
+#include "fcom.h"
+#else
+#define NFCOM 0
+#endif
+
+#include "radio.h"
+cdev_decl(radio);
+
+/* Block devices */
+
+struct bdevsw bdevsw[] = {
+ bdev_lkm_dummy(), /* 0: */
+ bdev_swap_init(1, sw), /* 1: swap pseudo-device */
+ bdev_lkm_dummy(), /* 2: */
+ bdev_lkm_dummy(), /* 3: */
+ bdev_lkm_dummy(), /* 4: */
+ bdev_lkm_dummy(), /* 5: */
+ bdev_lkm_dummy(), /* 6: */
+ bdev_lkm_dummy(), /* 7: */
+ bdev_lkm_dummy(), /* 8: */
+ bdev_lkm_dummy(), /* 9: */
+ bdev_lkm_dummy(), /* 10: */
+ bdev_lkm_dummy(), /* 11: */
+ bdev_lkm_dummy(), /* 12: */
+ bdev_lkm_dummy(), /* 13: */
+ bdev_lkm_dummy(), /* 14: */
+ bdev_lkm_dummy(), /* 15: */
+ bdev_disk_init(NWD,wd), /* 16: Internal IDE disk */
+ bdev_lkm_dummy(), /* 17: */
+ bdev_disk_init(NRD,rd), /* 18: memory disk */
+ bdev_disk_init(NVND,vnd), /* 19: vnode disk driver */
+ bdev_lkm_dummy(), /* 20: */
+ bdev_disk_init(NCCD,ccd), /* 21: concatenated disk driver */
+ bdev_lkm_dummy(), /* 22: */
+ bdev_lkm_dummy(), /* 23: */
+ bdev_disk_init(NSD,sd), /* 24: SCSI disk */
+ bdev_tape_init(NST,st), /* 25: SCSI tape */
+ bdev_disk_init(NCD,cd), /* 26: SCSI cdrom */
+ bdev_lkm_dummy(), /* 27: */
+ bdev_lkm_dummy(), /* 28: */
+ bdev_lkm_dummy(), /* 29: */
+ bdev_lkm_dummy(), /* 30: */
+ bdev_lkm_dummy(), /* 31: */
+ bdev_lkm_dummy(), /* 32: */
+ bdev_lkm_dummy(), /* 33: */
+ bdev_lkm_dummy(), /* 34: */
+ bdev_lkm_dummy(), /* 35: */
+ bdev_lkm_dummy(), /* 36: */
+ bdev_lkm_dummy(), /* 37: */
+ bdev_lkm_dummy(), /* 38: */
+ bdev_lkm_dummy(), /* 39: */
+ bdev_lkm_dummy(), /* 40: */
+ bdev_lkm_dummy(), /* 41: */
+ bdev_lkm_dummy(), /* 42: */
+ bdev_lkm_dummy(), /* 43: */
+ bdev_lkm_dummy(), /* 44: */
+ bdev_lkm_dummy(), /* 45: */
+ bdev_lkm_dummy(), /* 46: */
+ bdev_lkm_dummy(), /* 47: */
+ bdev_lkm_dummy(), /* 48: */
+ bdev_lkm_dummy(), /* 49: */
+ bdev_lkm_dummy(), /* 50: */
+ bdev_lkm_dummy(), /* 51: */
+ bdev_lkm_dummy(), /* 52: */
+ bdev_lkm_dummy(), /* 53: */
+ bdev_lkm_dummy(), /* 54: */
+ bdev_lkm_dummy(), /* 55: */
+ bdev_lkm_dummy(), /* 56: */
+ bdev_lkm_dummy(), /* 57: */
+ bdev_lkm_dummy(), /* 58: */
+ bdev_lkm_dummy(), /* 59: */
+ bdev_lkm_dummy(), /* 60: */
+ bdev_lkm_dummy(), /* 61: */
+ bdev_lkm_dummy(), /* 62: */
+ bdev_lkm_dummy(), /* 63: */
+ bdev_lkm_dummy(), /* 64: */
+ bdev_lkm_dummy(), /* 65: */
+ bdev_lkm_dummy(), /* 66: */
+ bdev_lkm_dummy(), /* 67: */
+ bdev_lkm_dummy(), /* 68: */
+ bdev_lkm_dummy(), /* 69: */
+ bdev_lkm_dummy(), /* 70: */
+ bdev_disk_init(NRAID,raid), /* 71: RAIDframe disk driver */
+ bdev_lkm_dummy(), /* 72: */
+ bdev_lkm_dummy(), /* 73: */
+ bdev_lkm_dummy(), /* 74: */
+ bdev_lkm_dummy(), /* 75: */
+ bdev_lkm_dummy(), /* 76: */
+ bdev_lkm_dummy(), /* 77: */
+ bdev_lkm_dummy(), /* 78: */
+ bdev_lkm_dummy(), /* 79: */
+ bdev_lkm_dummy(), /* 80: */
+ bdev_lkm_dummy(), /* 81: */
+ bdev_lkm_dummy(), /* 82: */
+ bdev_lkm_dummy(), /* 83: */
+ bdev_lkm_dummy(), /* 84: */
+ bdev_lkm_dummy(), /* 85: */
+ bdev_lkm_dummy(), /* 86: */
+ bdev_lkm_dummy(), /* 87: */
+ bdev_lkm_dummy(), /* 88: */
+ bdev_lkm_dummy(), /* 89: */
+ bdev_lkm_dummy(), /* 90: */
+ bdev_lkm_dummy(), /* 91: */
+ bdev_lkm_dummy(), /* 93: */
+ bdev_lkm_dummy(), /* 94: */
+ bdev_lkm_dummy(), /* 95: */
+ bdev_lkm_dummy(), /* 96: */
+ bdev_lkm_dummy(), /* 97: */
+};
+
+/* Character devices */
+#define ptstty ptytty
+#define ptsioctl ptyioctl
+#define ptctty ptytty
+#define ptcioctl ptyioctl
+
+#ifdef XFS
+#include <xfs/nxfs.h>
+cdev_decl(xfs_dev);
+#endif
+#include "systrace.h"
+
+#include "hotplug.h"
+
+#ifdef CONF_HAVE_GPIO
+#include "gpio.h"
+#else
+#define NGPIO 0
+#endif
+
+struct cdevsw cdevsw[] = {
+ cdev_cn_init(1,cn), /* 0: virtual console */
+ cdev_ctty_init(1,ctty), /* 1: controlling terminal */
+ cdev_mm_init(1,mm), /* 2: /dev/{null,mem,kmem,...} */
+ cdev_swap_init(1,sw), /* 3: /dev/drum (swap pseudo-device) */
+ cdev_tty_init(NPTY,pts), /* 4: pseudo-tty slave */
+ cdev_ptc_init(NPTY,ptc), /* 5: pseudo-tty master */
+ cdev_log_init(1,log), /* 6: /dev/klog */
+ cdev_fd_init(1,filedesc), /* 7: file descriptor pseudo-device */
+ cdev_ksyms_init(NKSYMS,ksyms), /* 8: Kernel symbols device */
+ cdev_lpt_init(NLPT,lpt), /* 9: parallel printer */
+ cdev_lkm_dummy(), /* 10: */
+ cdev_lkm_dummy(), /* 11: */
+ cdev_tty_init(NCOM,com), /* 12: serial port */
+ cdev_gpio_init(NGPIO,gpio), /* 13: GPIO interface */
+ cdev_lkm_dummy(), /* 14: */
+ cdev_lkm_dummy(), /* 15: */
+ cdev_disk_init(NWD,wd), /* 16: ST506/ESDI/IDE disk */
+ cdev_lkm_dummy(), /* 17: */
+ cdev_disk_init(NRD,rd), /* 18: ram disk driver */
+ cdev_disk_init(NVND,vnd), /* 19: vnode disk driver */
+ cdev_lkm_dummy(), /* 20: */
+ cdev_disk_init(NCCD,ccd), /* 21: concatenated disk driver */
+ cdev_bpftun_init(NBPFILTER,bpf), /* 22: Berkeley packet filter */
+ cdev_lkm_dummy(), /* 23: */
+ cdev_disk_init(NSD,sd), /* 24: SCSI disk */
+ cdev_tape_init(NST,st), /* 25: SCSI tape */
+ cdev_disk_init(NCD,cd), /* 26: SCSI CD-ROM */
+ cdev_ch_init(NCH,ch), /* 27: SCSI autochanger */
+ cdev_uk_init(NUK,uk), /* 28: SCSI unknown */
+ cdev_scanner_init(NSS,ss), /* 29: SCSI scanner */
+ cdev_lkm_dummy(), /* 30: */
+ cdev_lkm_dummy(), /* 31: */
+ cdev_lkm_dummy(), /* 32: */
+ cdev_bpftun_init(NTUN,tun), /* 33: network tunnel */
+ cdev_apm_init(NAPM,apm), /* 34: APM interface */
+ cdev_lkm_init(NLKM,lkm), /* 35: loadable module driver */
+ cdev_audio_init(NAUDIO,audio), /* 36: generic audio I/O */
+ cdev_hotplug_init(NHOTPLUG,hotplug), /* 37: devices hot plugging*/
+ cdev_notdef(), /* 38: removed cpu device */
+ cdev_lkm_dummy(), /* 39: reserved */
+ cdev_random_init(1,random), /* 40: random generator */
+ cdev_lkm_dummy(), /* 41: reserved */
+ cdev_lkm_dummy(), /* 42: reserved */
+ cdev_lkm_dummy(), /* 43: reserved */
+ cdev_lkm_dummy(), /* 44: reserved */
+ cdev_lkm_dummy(), /* 45: reserved */
+ cdev_pf_init(NPF,pf), /* 46: packet filter */
+ cdev_crypto_init(NCRYPTO,crypto), /* 47: /dev/crypto */
+ cdev_lkm_dummy(), /* 48: reserved */
+ cdev_lkm_dummy(), /* 49: reserved */
+ cdev_systrace_init(NSYSTRACE,systrace), /* 50: system call tracing */
+#ifdef XFS
+ cdev_xfs_init(NXFS,xfs_dev), /* 51: xfs communication device */
+#else
+ cdev_notdef(), /* 51: reserved */
+#endif
+ cdev_notdef(), /* 52: reserved */
+ cdev_notdef(), /* 53: reserved */
+ cdev_tty_init(NFCOM,fcom), /* 54: FOOTBRIDGE console */
+ cdev_lkm_dummy(), /* 55: Reserved for bypass device */
+ cdev_notdef(), /* 56: reserved */
+ cdev_midi_init(NMIDI,midi), /* 57: MIDI I/O */
+ cdev_midi_init(NSEQUENCER,sequencer), /* 58: sequencer I/O */
+ cdev_notdef(), /* 59: reserved */
+ cdev_wsdisplay_init(NWSDISPLAY,wsdisplay), /* 60: frame buffers, etc.*/
+ cdev_mouse_init(NWSKBD,wskbd), /* 61: keyboards */
+ cdev_mouse_init(NWSMOUSE,wsmouse), /* 62: mice */
+ cdev_mouse_init(NWSMUX,wsmux), /* 63: ws multiplexor */
+ cdev_usb_init(NUSB,usb), /* 64: USB controller */
+ cdev_usbdev_init(NUHID,uhid), /* 65: USB generic HID */
+ cdev_lpt_init(NULPT,ulpt), /* 66: USB printer */
+ cdev_urio_init(NURIO,urio), /* 67: Diamond Rio 500 */
+ cdev_tty_init(NUCOM,ucom), /* 68: USB tty */
+ cdev_usbdev_init(NUSCANNER,uscanner), /* 69: USB scanner */
+ cdev_usbdev_init(NUGEN,ugen), /* 70: USB generic driver */
+ cdev_disk_init(NRAID,raid), /* 71: RAIDframe disk driver */
+ cdev_lkm_dummy(), /* 72: reserved */
+ cdev_lkm_dummy(), /* 73: reserved */
+ cdev_lkm_dummy(), /* 74: reserved */
+ cdev_lkm_dummy(), /* 75: reserved */
+ cdev_lkm_dummy(), /* 76: reserved */
+ cdev_notdef(), /* 77: removed device */
+ cdev_notdef(), /* 78: removed device */
+ cdev_notdef(), /* 79: removed device */
+ cdev_notdef(), /* 80: removed device */
+ cdev_notdef(), /* 81: removed device */
+ cdev_notdef(), /* 82: removed device */
+ cdev_notdef(), /* 83: removed device */
+ cdev_notdef(), /* 84: removed device */
+ cdev_notdef(), /* 85: removed device */
+ cdev_notdef(), /* 86: removed device */
+ cdev_notdef(), /* 87: removed device */
+#ifdef USER_PCICONF
+ cdev_pci_init(NPCI,pci), /* 88: PCI user */
+#else
+ cdev_notdef(),
+#endif
+ cdev_notdef(), /* 89: removed device */
+ cdev_notdef(), /* 90: removed device */
+ cdev_notdef(), /* 91: removed device */
+ cdev_notdef(), /* 92: removed device */
+ cdev_notdef(), /* 93: removed device */
+ cdev_notdef(), /* 94: removed device */
+ cdev_notdef(), /* 95: removed device */
+ cdev_notdef(), /* 96: removed device */
+ cdev_radio_init(NRADIO,radio), /* 97: generic radio I/O */
+ cdev_ptm_init(NPTY,ptm), /* 98: pseudo-tty ptm device */
+};
+
+int nblkdev = sizeof(bdevsw) / sizeof(bdevsw[0]);
+int nchrdev = sizeof(cdevsw) / sizeof(cdevsw[0]);
+
+int mem_no = 2; /* major device number of memory special file */
+
+/*
+ * Swapdev is a fake device implemented
+ * in sw.c used only internally to get to swstrategy.
+ * It cannot be provided to the users, because the
+ * swstrategy routine munches the b_dev and b_blkno entries
+ * before calling the appropriate driver. This would horribly
+ * confuse, e.g. the hashing routines. Instead, /dev/drum is
+ * provided as a character (raw) device.
+ */
+dev_t swapdev = makedev(1, 0);
+
+/*
+ * Returns true if dev is /dev/mem or /dev/kmem.
+ */
+int
+iskmemdev(dev)
+ dev_t dev;
+{
+ return (major(dev) == mem_no && minor(dev) < 2);
+}
+
+/*
+ * Returns true if dev is /dev/zero.
+ */
+int
+iszerodev(dev)
+ dev_t dev;
+{
+ return (major(dev) == mem_no && minor(dev) == 3);
+}
+
+
+int chrtoblktbl[] = {
+/* XXXX This needs to be dynamic for LKMs. */
+ /*VCHR*/ /*VBLK*/
+ /* 0 */ NODEV,
+ /* 1 */ 1,
+ /* 2 */ NODEV,
+ /* 3 */ NODEV,
+ /* 4 */ NODEV,
+ /* 5 */ NODEV,
+ /* 6 */ NODEV,
+ /* 7 */ NODEV,
+ /* 8 */ NODEV,
+ /* 9 */ NODEV,
+ /* 10 */ NODEV,
+ /* 11 */ NODEV,
+ /* 12 */ NODEV,
+ /* 13 */ NODEV,
+ /* 14 */ NODEV,
+ /* 15 */ NODEV,
+ /* 16 */ 16,
+ /* 17 */ 17,
+ /* 18 */ 18,
+ /* 19 */ 19,
+ /* 20 */ NODEV,
+ /* 21 */ 21,
+ /* 22 */ NODEV,
+ /* 23 */ NODEV,
+ /* 24 */ 24,
+ /* 25 */ 25,
+ /* 26 */ 26,
+ /* 27 */ NODEV,
+ /* 28 */ NODEV,
+ /* 29 */ NODEV,
+ /* 30 */ NODEV,
+ /* 31 */ NODEV,
+ /* 32 */ NODEV,
+ /* 33 */ NODEV,
+ /* 34 */ NODEV,
+ /* 35 */ NODEV,
+ /* 36 */ NODEV,
+ /* 37 */ NODEV,
+ /* 38 */ NODEV,
+ /* 39 */ NODEV,
+ /* 40 */ NODEV,
+ /* 41 */ NODEV,
+ /* 42 */ NODEV,
+ /* 43 */ NODEV,
+ /* 44 */ NODEV,
+ /* 45 */ NODEV,
+ /* 46 */ NODEV,
+ /* 47 */ NODEV,
+ /* 48 */ NODEV,
+ /* 49 */ NODEV,
+ /* 50 */ NODEV,
+ /* 51 */ NODEV,
+ /* 52 */ NODEV,
+ /* 53 */ NODEV,
+ /* 54 */ NODEV,
+ /* 55 */ NODEV,
+ /* 56 */ NODEV,
+ /* 57 */ NODEV,
+ /* 58 */ NODEV,
+ /* 59 */ NODEV,
+ /* 60 */ NODEV,
+ /* 61 */ NODEV,
+ /* 62 */ NODEV,
+ /* 63 */ NODEV,
+ /* 64 */ NODEV,
+ /* 65 */ NODEV,
+ /* 66 */ NODEV,
+ /* 67 */ NODEV,
+ /* 68 */ NODEV,
+ /* 69 */ NODEV,
+ /* 70 */ NODEV,
+ /* 71 */ 71,
+ /* 72 */ NODEV,
+ /* 73 */ NODEV,
+ /* 74 */ NODEV,
+ /* 75 */ NODEV,
+ /* 76 */ NODEV,
+ /* 77 */ NODEV,
+ /* 78 */ NODEV,
+ /* 79 */ NODEV,
+ /* 80 */ NODEV,
+ /* 81 */ NODEV,
+ /* 82 */ NODEV,
+ /* 83 */ NODEV,
+ /* 84 */ NODEV,
+ /* 85 */ NODEV,
+ /* 86 */ NODEV,
+ /* 87 */ NODEV,
+ /* 88 */ NODEV,
+ /* 89 */ NODEV,
+ /* 90 */ NODEV,
+ /* 91 */ NODEV,
+ /* 92 */ 92,
+ /* 93 */ NODEV,
+ /* 94 */ NODEV,
+ /* 95 */ NODEV,
+ /* 96 */ NODEV,
+ /* 97 */ NODEV,
+};
+int nchrtoblktbl = sizeof(chrtoblktbl) / sizeof(chrtoblktbl[0]);
+
+
+dev_t
+getnulldev()
+{
+ return makedev(mem_no, 2);
+}
diff --git a/sys/arch/landisk/landisk/machdep.c b/sys/arch/landisk/landisk/machdep.c
index b9f6679a1df..4105803f890 100644
--- a/sys/arch/landisk/landisk/machdep.c
+++ b/sys/arch/landisk/landisk/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.1 2006/10/06 21:16:15 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.2 2006/10/06 21:48:50 mickey Exp $ */
/* $NetBSD: machdep.c,v 1.1 2006/09/01 21:26:18 uwe Exp $ */
/*-
@@ -111,7 +111,7 @@ char machine[] = MACHINE; /* landisk */
struct bootinfo _bootinfo;
struct bootinfo *bootinfo;
-__dead void landisk_startup(int, void *);
+__dead void landisk_startup(int, char *, void *);
__dead void main(void);
void
@@ -126,22 +126,25 @@ cpu_startup(void)
}
vaddr_t kernend; /* used by /dev/mem too */
+char *esym;
-void
-landisk_startup(int howto, void *bi)
+__dead void
+landisk_startup(int howto, char *_esym, void *bi)
{
extern char edata[], end[];
/* Clear bss */
- memset(edata, 0, end - edata);
+ bzero(edata, end - edata);
-/* XXX symbols */
/* Start to determine heap area */
- kernend = (vaddr_t)round_page((vaddr_t)end);
+ esym = _esym;
+ kernend = (vaddr_t)round_page((vaddr_t)esym);
/* Copy bootinfo */
- bootinfo = &_bootinfo;
- memcpy(bootinfo, bi, sizeof(struct bootinfo));
+ if (bi) {
+ bootinfo = &_bootinfo;
+ memcpy(bootinfo, bi, sizeof(struct bootinfo));
+ }
boothowto = howto;
/* Initialize CPU ops. */
@@ -173,8 +176,8 @@ landisk_startup(int howto, void *bi)
/* Jump to main */
__asm volatile(
- "jmp @%0;"
- "mov %1, sp"
+ "jmp @%0\n\t"
+ " mov %1, sp"
:: "r" (main), "r" (proc0.p_md.md_pcb->pcb_sf.sf_r7_bank));
/* NOTREACHED */
for (;;) ;
diff --git a/sys/arch/landisk/landisk/mainbus.c b/sys/arch/landisk/landisk/mainbus.c
index 872d13e265d..1f13ad4e9a8 100644
--- a/sys/arch/landisk/landisk/mainbus.c
+++ b/sys/arch/landisk/landisk/mainbus.c
@@ -1,4 +1,3 @@
-/* $OpenBSD: mainbus.c,v 1.1 2006/10/06 21:16:15 miod Exp $ */
/* $NetBSD: mainbus.c,v 1.1 2006/09/01 21:26:18 uwe Exp $ */
/*-
@@ -46,19 +45,24 @@
#include <landisk/dev/obiovar.h>
-static int mainbus_match(struct device *, struct cfdata *, void *);
-static void mainbus_attach(struct device *, struct device *, void *);
+int mainbus_match(struct device *, void *, void *);
+void mainbus_attach(struct device *, struct device *, void *);
-CFATTACH_DECL(mainbus, sizeof(struct device),
- mainbus_match, mainbus_attach, NULL, NULL);
+struct cfattach mainbus_ca = {
+ sizeof(struct device), mainbus_match, mainbus_attach
+};
-static int mainbus_print(void *, const char *);
+struct cfdriver mainbus_cd = {
+ NULL, "mainbus", DV_DULL
+};
+
+int mainbus_print(void *, const char *);
/* There can be only one. */
int mainbus_found = 0;
-static int
-mainbus_match(struct device *parent, struct cfdata *cf, void *aux)
+int
+mainbus_match(struct device *parent, void *cf, void *aux)
{
if (mainbus_found)
@@ -67,7 +71,7 @@ mainbus_match(struct device *parent, struct cfdata *cf, void *aux)
return (1);
}
-static void
+void
mainbus_attach(struct device *parent, struct device *self, void *aux)
{
union {
@@ -108,7 +112,7 @@ mainbus_attach(struct device *parent, struct device *self, void *aux)
#endif
}
-static int
+int
mainbus_print(void *aux, const char *pnp)
{
diff --git a/sys/arch/landisk/stand/Makefile b/sys/arch/landisk/stand/Makefile
new file mode 100644
index 00000000000..c30bf9efc55
--- /dev/null
+++ b/sys/arch/landisk/stand/Makefile
@@ -0,0 +1,5 @@
+# $OpenBSD: Makefile,v 1.1 2006/10/06 21:48:50 mickey Exp $
+
+SUBDIR= mbr bootxx boot
+
+.include <bsd.subdir.mk>
diff --git a/sys/arch/landisk/stand/Makefile.inc b/sys/arch/landisk/stand/Makefile.inc
new file mode 100644
index 00000000000..f46fde8c38a
--- /dev/null
+++ b/sys/arch/landisk/stand/Makefile.inc
@@ -0,0 +1,12 @@
+# $OpenBSD: Makefile.inc,v 1.1 2006/10/06 21:48:50 mickey Exp $
+
+.if !make(libdep) && !make(sadep) && !make(salibdir) && !make(kernlibdir) && !make(obj) && !make(clean) && !make(cleandir)
+.BEGIN:
+ @([ X$(S) = X -o -h machine ] || ln -s $(S)/arch/landisk/include machine)
+ @([ X$(S) = X -o -h sh ] || ln -s $(S)/arch/sh/include sh)
+.endif
+
+CFLAGS+=-Os -fno-stack-protector -fno-builtin
+CLEANFILES+= machine sh
+BINDIR= /usr/mdec
+MANSUBDIR=landisk
diff --git a/sys/arch/landisk/stand/boot/Makefile b/sys/arch/landisk/stand/boot/Makefile
new file mode 100644
index 00000000000..eda9d8989c3
--- /dev/null
+++ b/sys/arch/landisk/stand/boot/Makefile
@@ -0,0 +1,42 @@
+# $OpenBSD: Makefile,v 1.1 2006/10/06 21:48:50 mickey Exp $
+
+PROG= boot
+SRCS= srt0.S conf.c devs.c getsecs.c scifcons.c delay.c
+LDFLAGS=-nostdlib -Ttext 0x8ff00000 -N -x -Bstatic -e start
+
+INSTALL_STRIP=
+
+S= ${.CURDIR}/../../../..
+CPPFLAGS+=-D_STANDALONE
+CPPFLAGS+=-DSH4
+CPPFLAGS+=-nostdinc -I${.OBJDIR} -I${.CURDIR} -I${.CURDIR}/.. -I${S}
+CPPFLAGS+=-DLOADADDRESS=0x8ff00000
+
+.PATH: ${S}/stand/boot
+SRCS+= boot.c cmd.c vars.c bootarg.c
+
+SAREL=
+SA_ZLIB=
+USE_LOADFILE=
+.PATH: ${S}/lib/libsa
+SRCS+= ctime.c strtol.c
+.include "${S}/lib/libsa/Makefile.inc"
+DPADD+= $(SALIB)
+LDADD+= $(SALIB)
+
+KERN_AS?= library
+.include "${S}/lib/libkern/Makefile.inc"
+DPADD+= $(KERNLIB)
+LDADD+= $(KERNLIB)
+
+Z_AS?= library
+.include "${S}/lib/libz/Makefile.inc"
+DPADD+= $(ZLIB)
+LDADD+= $(ZLIB)
+
+${PROG}: ${OBJS} ${DPADD}
+ ${LD} -o ${PROG}.sym ${LDFLAGS} \
+ -Map ${PROG}.map -cref ${OBJS} ${LDADD}
+ ${OBJCOPY} -O binary ${PROG}.sym ${PROG}
+
+.include <bsd.prog.mk>
diff --git a/sys/arch/landisk/stand/boot/conf.c b/sys/arch/landisk/stand/boot/conf.c
new file mode 100644
index 00000000000..4ac899aa9ff
--- /dev/null
+++ b/sys/arch/landisk/stand/boot/conf.c
@@ -0,0 +1,52 @@
+/* $OpenBSD: conf.c,v 1.1 2006/10/06 21:48:50 mickey Exp $ */
+
+/*
+ * Copyright (c) 2006 Michael Shalayeff
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/types.h>
+#include <libsa.h>
+#include <lib/libsa/ufs.h>
+#ifdef notdef
+#include <lib/libsa/cd9660.h>
+#include <lib/libsa/fat.h>
+#include <lib/libsa/nfs.h>
+#include <lib/libsa/tftp.h>
+#include <lib/libsa/netif.h>
+#endif
+#include <dev/cons.h>
+
+const char version[] = "0.99";
+int debug = 1;
+
+struct fs_ops file_system[] = {
+ { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek,
+ ufs_stat, ufs_readdir },
+#ifdef notdef
+ { fat_open, fat_close, fat_read, fat_write, fat_seek,
+ fat_stat, fat_readdir },
+ { nfs_open, nfs_close, nfs_read, nfs_write, nfs_seek,
+ nfs_stat, nfs_readdir },
+ { cd9660_open, cd9660_close, cd9660_read, cd9660_write, cd9660_seek,
+ cd9660_stat, cd9660_readdir },
+#endif
+};
+int nfsys = NENTS(file_system);
+
+struct devsw devsw[] = {
+ { "dk", blkdevstrategy, blkdevopen, blkdevclose, noioctl },
+};
+int ndevs = NENTS(devsw);
diff --git a/sys/arch/landisk/stand/boot/delay.c b/sys/arch/landisk/stand/boot/delay.c
new file mode 100644
index 00000000000..b0dc7f2cab1
--- /dev/null
+++ b/sys/arch/landisk/stand/boot/delay.c
@@ -0,0 +1,131 @@
+/* $OpenBSD: delay.c,v 1.1 2006/10/06 21:48:50 mickey Exp $ */
+/* $NetBSD: delay.c,v 1.1 2006/09/01 21:26:18 uwe Exp $ */
+
+/*-
+ * Copyright (c) 2005 NONAKA Kimihiro
+ * 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 REGENTS AND CONTRIBUTORS ``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.
+ */
+
+#include <sys/param.h>
+#include <libsa.h>
+
+#include <sh/tmureg.h>
+
+#ifndef TICK_CH
+#define TICK_CH 0
+#endif
+#if TICK_CH == 0
+#define TSTR SH4_TSTR
+#define TCOR SH4_TCOR0
+#define TCNT SH4_TCNT0
+#define TCR SH4_TCR0
+#define TSTR_CH TSTR_STR0
+#elif TICK_CH == 1
+#define TSTR SH4_TSTR
+#define TCOR SH4_TCOR1
+#define TCNT SH4_TCNT1
+#define TCR SH4_TCR1
+#define TSTR_CH TSTR_STR1
+#elif TICK_CH == 2
+#define TSTR SH4_TSTR
+#define TCOR SH4_TCOR2
+#define TCNT SH4_TCNT2
+#define TCR SH4_TCR2
+#define TSTR_CH TSTR_STR2
+#elif TICK_CH == 3
+#define TSTR SH4_TSTR2
+#define TCOR SH4_TCOR3
+#define TCNT SH4_TCNT3
+#define TCR SH4_TCR3
+#define TSTR_CH SH4_TSTR2_STR3
+#elif TICK_CH == 4
+#define TSTR SH4_TSTR2
+#define TCOR SH4_TCOR4
+#define TCNT SH4_TCNT4
+#define TCR SH4_TCR4
+#define TSTR_CH SH4_TSTR2_STR4
+#else
+#error TICK_CH != [01234]
+#endif
+
+#ifndef TICK_PRESC
+#define TICK_PRESC 1024
+#endif
+#if TICK_PRESC == 4
+#define TCR_TPSC TCR_TPSC_P4
+#elif TICK_PRESC == 16
+#define TCR_TPSC TCR_TPSC_P16
+#elif TICK_PRESC == 64
+#define TCR_TPSC TCR_TPSC_P64
+#elif TICK_PRESC == 256
+#define TCR_TPSC TCR_TPSC_P256
+#elif TICK_PRESC == 1024
+#define TCR_TPSC SH4_TCR_TPSC_P1024
+#else
+#error TICK_PRESC != 4, 16, 64, 256, 1024
+#endif
+
+#define TICKS_PER_SEC (PCLOCK / TICK_PRESC)
+#define MS_PER_TICK (1000000 / TICKS_PER_SEC)
+
+int
+tick_init(void)
+{
+
+ _reg_bclr_1(TSTR, TSTR_CH);
+ _reg_write_2(TCR, TCR_TPSC);
+ _reg_write_4(TCOR, 0xffffffff);
+ _reg_write_4(TCNT, 0xffffffff);
+ _reg_bset_1(TSTR, TSTR_CH);
+
+ return 0;
+}
+
+void
+tick_stop(void)
+{
+
+ _reg_bclr_1(TSTR, TSTR_CH);
+}
+
+uint32_t
+gettick(void)
+{
+
+ return ~(_reg_read_4(TCNT));
+}
+
+void
+delay(int ms)
+{
+ uint32_t base, now;
+
+ base = gettick();
+ for (;;) {
+ now = gettick();
+ if (((now - base) / MS_PER_TICK) > ms) {
+ break;
+ }
+ }
+}
diff --git a/sys/arch/landisk/stand/boot/devs.c b/sys/arch/landisk/stand/boot/devs.c
new file mode 100644
index 00000000000..919c41e1d15
--- /dev/null
+++ b/sys/arch/landisk/stand/boot/devs.c
@@ -0,0 +1,160 @@
+/* $OpenBSD: devs.c,v 1.1 2006/10/06 21:48:50 mickey Exp $ */
+
+/*
+ * Copyright (c) 2006 Michael Shalayeff
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <sys/param.h>
+#include <libsa.h>
+#include <lib/libsa/loadfile.h>
+
+int sector;
+
+void
+machdep(void)
+{
+ /* scif_init(9600); */
+}
+
+int
+devopen(struct open_file *f, const char *fname, char **file)
+{
+ if (fname[0] != 'c' || fname[1] != 'f' || fname[2] != ':')
+ return EINVAL;
+
+ *file = (char *)fname + 3;
+ f->f_flags |= F_NODEV;
+ f->f_dev = &devsw[0];
+ return (0);
+}
+
+void
+devboot(dev_t bootdev, char *p)
+{
+ sector = bootdev; /* passed from pbr */
+ p[0] = 'c';
+ p[1] = 'f';
+ p[2] = '\0';
+}
+
+char *
+ttyname(int fd)
+{
+ return "scif";
+}
+
+dev_t
+ttydev(char *name)
+{
+ return NODEV;
+}
+
+int
+cnspeed(dev_t dev, int sp)
+{
+ scif_init(sp);
+ return sp;
+}
+
+void
+run_loadfile(u_long *marks, int howto)
+{
+ u_long entry;
+
+ entry = marks[MARK_ENTRY];
+
+ printf("entry point at 0x%x\n", (int)entry);
+ (*(void (*)(int,int,int))entry)(howto, marks[MARK_END], 0);
+}
+
+int
+blkdevopen(struct open_file *f, ...)
+{
+ return 0;
+}
+
+int
+blkdevstrategy(void *v, int flag, daddr_t dblk, size_t size, void *buf, size_t *rsize)
+{
+
+ if (flag != F_READ)
+ return EROFS;
+
+ if (size & (DEV_BSIZE - 1))
+ return EINVAL;
+
+ if (rsize)
+ *rsize = size;
+
+ if (size != 0 && readsects(0x40, sector + dblk, buf,
+ size / DEV_BSIZE) != 0)
+ return EIO;
+
+ return 0;
+}
+
+int
+blkdevclose(struct open_file *f)
+{
+ return 0;
+}
+
+int pch_pos = 0;
+
+void
+putchar(int c)
+{
+ switch (c) {
+ case '\177': /* DEL erases */
+ scif_putc('\b');
+ scif_putc(' ');
+ case '\b':
+ scif_putc('\b');
+ if (pch_pos)
+ pch_pos--;
+ break;
+ case '\t':
+ do
+ scif_putc(' ');
+ while (++pch_pos % 8);
+ break;
+ case '\n':
+ scif_putc(c);
+ case '\r':
+ scif_putc('\r');
+ pch_pos=0;
+ break;
+ default:
+ scif_putc(c);
+ pch_pos++;
+ break;
+ }
+}
+
+int
+getchar(void)
+{
+ int c = scif_getc();
+
+ if (c == '\r')
+ c = '\n';
+
+ if ((c < ' ' && c != '\n') || c == '\177')
+ return c;
+
+ putchar(c);
+ return c;
+}
diff --git a/sys/arch/landisk/stand/boot/getsecs.c b/sys/arch/landisk/stand/boot/getsecs.c
new file mode 100644
index 00000000000..64c21d7ad31
--- /dev/null
+++ b/sys/arch/landisk/stand/boot/getsecs.c
@@ -0,0 +1,202 @@
+/* $NetBSD: getsecs.c,v 1.2 2006/09/11 13:48:57 nonaka Exp $ */
+
+#include <sys/param.h>
+
+#include <netinet/in.h>
+#include <netinet/in_systm.h>
+
+#include <lib/libsa/stand.h>
+#include <lib/libsa/net.h>
+#include <lib/libsa/netif.h>
+
+#include <sh/devreg.h>
+#include <sh/scireg.h>
+
+#include <dev/ic/rs5c313reg.h>
+
+/**
+ * RICOH RS5C313
+ *
+ * Web page: http://www.ricoh.co.jp/LSI/product_rtc/3wire/5c313/
+ *
+ * How to control RS5C313 on LANDISK
+ * see http://www.mizore.jp/wiki/index.php?LANDISK/rtc
+ */
+
+uint8_t rtc_read(uint32_t addr);
+void rtc_write(uint32_t addr, uint8_t data);
+
+static void
+rtc_init(void)
+{
+
+ SHREG_SCSPTR = SCSPTR_SPB1IO | SCSPTR_SPB1DT
+ | SCSPTR_SPB0IO | SCSPTR_SPB0DT;
+}
+
+/* control RTC chip enable */
+static void
+rtc_ce(int onoff)
+{
+
+ if (onoff) {
+ _reg_write_1(0xb0000003, (1 << 1));
+ } else {
+ _reg_write_1(0xb0000003, (0 << 1));
+ }
+}
+
+static inline void
+rtc_clk(int onoff)
+{
+
+ if (onoff) {
+ SHREG_SCSPTR |= SCSPTR_SPB0DT;
+ } else {
+ SHREG_SCSPTR &= ~SCSPTR_SPB0DT;
+ }
+}
+
+static void
+rtc_dir(int output)
+{
+
+ if (output) {
+ SHREG_SCSPTR |= SCSPTR_SPB1IO;
+ } else {
+ SHREG_SCSPTR &= ~SCSPTR_SPB1IO;
+ }
+}
+
+/* data-out */
+static void
+rtc_do(int onoff)
+{
+
+ if (onoff) {
+ SHREG_SCSPTR |= SCSPTR_SPB1DT;
+ } else {
+ SHREG_SCSPTR &= ~SCSPTR_SPB1DT;
+ }
+
+ rtc_clk(0);
+ rtc_clk(1);
+}
+
+/* data-in */
+static int
+rtc_di(void)
+{
+ int d;
+
+ d = (SHREG_SCSPTR & SCSPTR_SPB1DT) ? 1 : 0;
+
+ rtc_clk(0);
+ rtc_clk(1);
+
+ return d;
+}
+
+uint8_t
+rtc_read(uint32_t addr)
+{
+ uint8_t data;
+
+ rtc_init();
+ rtc_ce(1);
+
+ rtc_dir(1);
+ rtc_do(1); /* Don't care */
+ rtc_do(1); /* R/#W = 1(READ) */
+ rtc_do(1); /* AD = 1 */
+ rtc_do(0); /* DT = 0 */
+ rtc_do(addr & 0x8); /* A3 */
+ rtc_do(addr & 0x4); /* A2 */
+ rtc_do(addr & 0x2); /* A1 */
+ rtc_do(addr & 0x1); /* A0 */
+
+ rtc_dir(0);
+ (void)rtc_di();
+ (void)rtc_di();
+ (void)rtc_di();
+ (void)rtc_di();
+ data = rtc_di(); /* D3 */
+ data <<= 1;
+ data |= rtc_di(); /* D2 */
+ data <<= 1;
+ data |= rtc_di(); /* D1 */
+ data <<= 1;
+ data |= rtc_di(); /* D0 */
+
+ rtc_ce(0);
+
+ return data & 0xf;
+}
+
+void
+rtc_write(uint32_t addr, uint8_t data)
+{
+
+ rtc_init();
+ rtc_ce(1);
+
+ rtc_dir(1);
+ rtc_do(1); /* Don't care */
+ rtc_do(0); /* R/#W = 0(WRITE) */
+ rtc_do(1); /* AD = 1 */
+ rtc_do(0); /* DT = 0 */
+ rtc_do(addr & 0x8); /* A3 */
+ rtc_do(addr & 0x4); /* A2 */
+ rtc_do(addr & 0x2); /* A1 */
+ rtc_do(addr & 0x1); /* A0 */
+
+ rtc_do(1); /* Don't care */
+ rtc_do(0); /* R/#W = 0(WRITE) */
+ rtc_do(0); /* AD = 0 */
+ rtc_do(1); /* DT = 1 */
+ rtc_do(data & 0x8); /* D3 */
+ rtc_do(data & 0x4); /* D2 */
+ rtc_do(data & 0x2); /* D1 */
+ rtc_do(data & 0x1); /* D0 */
+
+ rtc_ce(0);
+}
+
+time_t
+getsecs(void)
+{
+ uint32_t sec, min, hour, day;
+#if 0
+ uint32_t mon, year;
+#endif
+ time_t secs;
+
+ sec = rtc_read(RS5C313_SEC1);
+ sec += rtc_read(RS5C313_SEC10) * 10;
+ min = rtc_read(RS5C313_MIN1);
+ min += rtc_read(RS5C313_MIN10) * 10;
+ hour = rtc_read(RS5C313_HOUR1);
+ hour += rtc_read(RS5C313_HOUR10) * 10;
+ day = rtc_read(RS5C313_DAY1);
+ day += rtc_read(RS5C313_DAY10) * 10;
+#if 0
+ mon = rtc_read(RS5C313_MON1);
+ mon += rtc_read(RS5C313_MON10) * 10;
+ year = rtc_read(RS5C313_YEAR1);
+ year += rtc_read(RS5C313_YEAR10) * 10;
+#endif
+
+ secs = sec;
+ secs += min * 60;
+ secs += hour * 60 * 60;
+ secs += day * 60 * 60 * 24;
+#if 0
+ /* XXX mon, year */
+#endif
+
+#if defined(DEBUG)
+ printf("getsecs: secs = %d\n", (uint32_t)secs);
+#endif
+
+ return secs;
+}
diff --git a/sys/arch/landisk/stand/boot/libsa.h b/sys/arch/landisk/stand/boot/libsa.h
new file mode 100644
index 00000000000..5b24d33fd0a
--- /dev/null
+++ b/sys/arch/landisk/stand/boot/libsa.h
@@ -0,0 +1,34 @@
+/* $OpenBSD: libsa.h,v 1.1 2006/10/06 21:48:50 mickey Exp $ */
+
+/*
+ * Copyright (c) 2006 Michael Shalayeff
+ * All rights reserved.
+ *
+ * Permission to use, copy, modify, and distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+ * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+ * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ */
+
+#include <lib/libsa/stand.h>
+
+#define EXEC_ELF
+
+#define DEFAULT_KERNEL_ADDRESS 0
+
+#define PCLOCK 33333333
+
+int readsects(int dev, uint32_t lba, void *buf, size_t size);
+int blkdevopen(struct open_file *, ...);
+int blkdevclose(struct open_file *);
+int blkdevstrategy(void *, int, daddr_t, size_t, void *, size_t *);
+void scif_init(unsigned int);
+int scif_getc(void);
+void scif_putc(int);
diff --git a/sys/arch/landisk/stand/boot/scifcons.c b/sys/arch/landisk/stand/boot/scifcons.c
new file mode 100644
index 00000000000..63551234f13
--- /dev/null
+++ b/sys/arch/landisk/stand/boot/scifcons.c
@@ -0,0 +1,250 @@
+/* $OpenBSD: scifcons.c,v 1.1 2006/10/06 21:48:50 mickey Exp $ */
+/* $NetBSD: scifcons.c,v 1.1 2006/09/01 21:26:18 uwe Exp $ */
+/* NetBSD: scif.c,v 1.38 2004/12/13 02:14:13 chs Exp */
+
+/*-
+ * Copyright (C) 1999 T.Horiuchi and SAITOH Masanobu. 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. 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.
+ */
+/*-
+ * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Charles M. Hannum.
+ *
+ * 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 the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION 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.
+ */
+/*
+ * Copyright (c) 1991 The Regents of the University of California.
+ * 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. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``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.
+ *
+ * @(#)com.c 7.5 (Berkeley) 5/16/91
+ */
+/*
+ * SH internal serial driver
+ *
+ * This code is derived from both z8530tty.c and com.c
+ */
+
+#include <libsa.h>
+
+#include <sh/scifreg.h>
+
+#define scif_smr_read() SHREG_SCSMR2
+#define scif_smr_write(v) (SHREG_SCSMR2 = (v))
+
+#define scif_brr_read() SHREG_SCBRR2
+#define scif_brr_write(v) (SHREG_SCBRR2 = (v))
+
+#define scif_scr_read() SHREG_SCSCR2
+#define scif_scr_write(v) (SHREG_SCSCR2 = (v))
+
+#define scif_ftdr_write(v) (SHREG_SCFTDR2 = (v))
+
+#define scif_ssr_read() SHREG_SCSSR2
+#define scif_ssr_write(v) (SHREG_SCSSR2 = (v))
+
+#define scif_frdr_read() SHREG_SCFRDR2
+
+#define scif_fcr_read() SHREG_SCFCR2
+#define scif_fcr_write(v) (SHREG_SCFCR2 = (v))
+
+#define scif_fdr_read() SHREG_SCFDR2
+
+#define scif_sptr_read() SHREG_SCSPTR2
+#define scif_sptr_write(v) (SHREG_SCSPTR2 = (v))
+
+#define scif_lsr_read() SHREG_SCLSR2
+#define scif_lsr_write(v) (SHREG_SCLSR2 = (v))
+
+#define divrnd(n, q) (((n)*2/(q)+1)/2) /* divide and round off */
+
+#define SERBUFSIZE 16
+static u_char serbuf[SERBUFSIZE];
+static int serbuf_read = 0;
+static int serbuf_write = 0;
+
+void
+scif_init(unsigned int bps)
+{
+
+ serbuf_read = 0;
+ serbuf_write = 0;
+
+ /* Initialize SCR */
+ scif_scr_write(0x00);
+
+ /* Clear FIFO */
+ scif_fcr_write(SCFCR2_TFRST | SCFCR2_RFRST);
+
+ /* Serial Mode Register */
+ scif_smr_write(0x00); /* 8bit,NonParity,Even,1Stop */
+
+ /* Bit Rate Register */
+ scif_brr_write(divrnd(PCLOCK, 32 * bps) - 1);
+
+ delay(100);
+
+ scif_sptr_write(SCSPTR2_RTSIO);
+
+ scif_fcr_write(FIFO_RCV_TRIGGER_1 | FIFO_XMT_TRIGGER_8);
+
+ /* Send permission, Receive permission ON */
+ scif_scr_write(SCSCR2_TE | SCSCR2_RE);
+
+ /* Serial Status Register */
+ scif_ssr_write(scif_ssr_read() & SCSSR2_TDFE); /* Clear Status */
+}
+
+int
+scif_getc(void)
+{
+ unsigned char c, err_c;
+ unsigned short err_c2;
+
+ if (serbuf_read != serbuf_write) {
+ c = serbuf[serbuf_read];
+ serbuf_read = (serbuf_read + 1) % SERBUFSIZE;
+ return (c);
+ }
+
+ for (;;) {
+ /* wait for ready */
+ while ((scif_fdr_read() & SCFDR2_RECVCNT) == 0)
+ continue;
+
+ c = scif_frdr_read();
+ err_c = scif_ssr_read();
+ scif_ssr_write(scif_ssr_read()
+ & ~(SCSSR2_ER | SCSSR2_BRK | SCSSR2_RDF | SCSSR2_DR));
+
+ err_c2 = scif_lsr_read();
+ scif_lsr_write(scif_lsr_read() & ~SCLSR2_ORER);
+
+ if ((err_c & (SCSSR2_ER | SCSSR2_BRK | SCSSR2_FER
+ | SCSSR2_PER)) == 0) {
+ if ((err_c2 & SCLSR2_ORER) == 0) {
+ return (c);
+ }
+ }
+ }
+}
+
+void
+scif_putc(int c)
+{
+
+ /* wait for ready */
+ while ((scif_fdr_read() & SCFDR2_TXCNT) == SCFDR2_TXF_FULL)
+ continue;
+
+ /* write send data to send register */
+ scif_ftdr_write(c);
+
+ /* clear ready flag */
+ scif_ssr_write(scif_ssr_read() & ~(SCSSR2_TDFE | SCSSR2_TEND));
+}
+
+int
+cnischar(void)
+{
+ unsigned char c, err_c;
+ unsigned short err_c2;
+
+ /* check if any preread input is already there */
+ if (serbuf_read != serbuf_write)
+ return (1);
+
+ if (scif_fdr_read() & SCFDR2_RECVCNT) {
+ c = scif_frdr_read();
+ err_c = scif_ssr_read();
+ scif_ssr_write(scif_ssr_read()
+ & ~(SCSSR2_ER | SCSSR2_BRK | SCSSR2_RDF | SCSSR2_DR));
+
+ err_c2 = scif_lsr_read();
+ scif_lsr_write(scif_lsr_read() & ~SCLSR2_ORER);
+
+ if ((err_c & (SCSSR2_ER | SCSSR2_BRK | SCSSR2_FER
+ | SCSSR2_PER)) == 0) {
+ if ((err_c2 & SCLSR2_ORER) == 0) {
+ /* stuff char into preread buffer */
+ serbuf[serbuf_write] = (u_char)c;
+ serbuf_write = (serbuf_write + 1) % SERBUFSIZE;
+ return (1);
+ }
+ }
+ }
+ return (0); /* nothing out there... */
+}
diff --git a/sys/arch/landisk/stand/boot/srt0.S b/sys/arch/landisk/stand/boot/srt0.S
new file mode 100644
index 00000000000..3e46a2a2e33
--- /dev/null
+++ b/sys/arch/landisk/stand/boot/srt0.S
@@ -0,0 +1,153 @@
+/* $OpenBSD: srt0.S,v 1.1 2006/10/06 21:48:50 mickey Exp $ */
+/* $NetBSD: boot.S,v 1.1 2006/09/01 21:26:18 uwe Exp $ */
+
+/*-
+ * Copyright (c) 2005 NONAKA Kimihiro
+ * 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 REGENTS AND CONTRIBUTORS ``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.
+ */
+
+#include <machine/asm.h>
+
+ENTRY(start)
+ bra boot_start1
+ nop
+ .balign 4
+ENTRY(boot_magic)
+ .long 0x20041110
+ENTRY(boot_params)
+ .long boot_start1 - boot_params
+
+ . = start + 0x80
+boot_start1:
+ mov r4, r0
+ add #-4, r0
+ mov.l @(0, r0), r0
+ mov.l .L.boot_magic1, r1
+ cmp/eq r0, r1
+ bf 2f
+ mov r4, r0
+ mov.l .L.boot_params_size, r3
+ mov.l @r0, r2
+ mov.l .L.boot_params, r1
+ cmp/hi r3, r2
+ bf 1f
+ mov r3, r2
+1: mov.b @r0+, r3
+ mov.b r3, @r1
+ dt r2
+ bf/s 1b
+ add #1, r1
+2:
+ mov.l .L._end, r0 /* zero bss */
+ mov.l .L.__bss_start, r1
+ sub r1, r0
+ shlr2 r0 /* _end and __bss_start are aligned */
+ mov #0, r2
+1: mov.l r2, @r1
+ dt r0
+ bf/s 1b
+ add #4, r1
+
+ mov.l .L.boot, r0
+ jsr @r0
+ mov r5, r4
+
+boot_fail:
+ mov r0, r1
+ mova .L.errtxt, r0
+ mov r0, r4
+ mov #32, r0
+ trapa #0x3f
+ mov r1, r4
+ mov #32, r0
+ trapa #0x3f
+ mova .L.crlf, r0
+ mov r0, r4
+ mov #32, r0
+ trapa #0x3f
+99: bra 99b
+ nop
+
+
+ENTRY(halt)
+ mova .L.pwrctl, r0
+ mov #1, r1
+ mov.b @r1, r0
+ rts
+ nop
+
+ENTRY(reboot)
+ENTRY(_rtt)
+ mov #1, r4 /* reboot */
+ mov #11, r0
+ trapa #0x3f
+ mov.l .L.start, r0
+ jmp @r0
+ nop
+
+/*
+ * int raise(int sig);
+ */
+ENTRY(raise)
+ rts
+ nop
+
+/*
+ *
+ */
+ENTRY(cnset)
+ rts
+ nop
+
+/*
+ * int readsects(int dev, uint32_t lba, void *buf, size_t size);
+ */
+ENTRY(readsects)
+ mov #2, r0
+ trapa #0x3f
+ rts
+ nop
+
+ .align 2
+.L.boot_magic1:
+ .long 0x20031125
+.L.boot_params:
+ .long boot_params
+.L.boot_params_size:
+ .long boot_start1 - boot_params
+.L._end:
+ .long _end
+.L.__bss_start:
+ .long __bss_start
+.L.boot:
+ .long _C_LABEL(boot)
+.L.start:
+ .long 0xc0000000
+.L.pwrctl:
+ .long 0xb0000003
+
+ .align 2
+.L.errtxt: .asciz ">>BOOT FAILED: "
+ .align 2
+.L.crlf: .asciz "\r\n"
diff --git a/sys/arch/landisk/stand/bootxx/Makefile b/sys/arch/landisk/stand/bootxx/Makefile
new file mode 100644
index 00000000000..70b49c44968
--- /dev/null
+++ b/sys/arch/landisk/stand/bootxx/Makefile
@@ -0,0 +1,45 @@
+# $OpenBSD: Makefile,v 1.1 2006/10/06 21:48:50 mickey Exp $
+
+PROG= bootxx
+SRCS= pbr.S bootxx.S boot1.c
+MAN= bootxx.8
+LDFLAGS=-nostdlib -Ttext 0x8c201000 -N -x -Bstatic -e start
+
+INSTALL_STRIP=
+
+BOOTXX_SECTORS?= 15
+BOOTXX_MAXSIZE?= (( ${BOOTXX_SECTORS} * 512 ))
+
+CPPFLAGS+=-D_STANDALONE -DNO_READDIR
+CPPFLAGS+=-nostdinc -I${.OBJDIR} -I${.CURDIR}/.. -I${.CURDIR}/../../../..
+CPPFLAGS+=-DLOADADDRESS=0x8ff00000 -DBOOTXX_SECTORS=${BOOTXX_SECTORS}
+
+S= ${.CURDIR}/../../../..
+SAREL=
+.include "${S}/lib/libsa/Makefile.inc"
+DPADD+= $(SALIB)
+LDADD+= $(SALIB)
+
+KERN_AS?= library
+.include "${S}/lib/libkern/Makefile.inc"
+DPADD+= $(KERNLIB)
+LDADD+= $(KERNLIB)
+
+${PROG}: ${OBJS} ${DPADD}
+ ${LD} -o ${PROG}.sym ${LDFLAGS} \
+ -Map ${PROG}.map -cref ${OBJS} ${LDADD}
+ ${OBJCOPY} -O binary ${PROG}.sym ${PROG}
+ @ sz=$$(ls -ln ${PROG} | tr -s ' ' | cut -d' ' -f5); \
+ if [ "$$sz" -gt "$$${BOOTXX_MAXSIZE}" ]; then \
+ echo "### ${PROG} size $$sz is larger than ${BOOTXX_MAXSIZE}" >&2 \
+ rm -f ${PROG}; \
+ ! :; \
+ else \
+ : pad to sector boundary; \
+ pad=$$(( 512 - ( $$sz & 511 ) )); \
+ [ $$pad = 512 ] || \
+ dd if=/dev/zero bs=1 count=$$pad >>${PROG} 2>/dev/null; \
+ echo "${PROG} size $$sz, $$((${BOOTXX_MAXSIZE} - $$sz)) free"; \
+ fi
+
+.include <bsd.prog.mk>
diff --git a/sys/arch/landisk/stand/bootxx/boot1.c b/sys/arch/landisk/stand/bootxx/boot1.c
new file mode 100644
index 00000000000..63d46325739
--- /dev/null
+++ b/sys/arch/landisk/stand/bootxx/boot1.c
@@ -0,0 +1,157 @@
+/* $OpenBSD: boot1.c,v 1.1 2006/10/06 21:48:50 mickey Exp $ */
+/* $NetBSD: boot1.c,v 1.1 2006/09/01 21:26:19 uwe Exp $ */
+
+/*-
+ * Copyright (c) 2003 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by David Laight.
+ *
+ * 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 the NetBSD
+ * Foundation, Inc. and its contributors.
+ * 4. Neither the name of The NetBSD Foundation nor the names of its
+ * contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``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 FOUNDATION 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.
+ */
+
+#include <sys/param.h>
+#include <lib/libsa/stand.h>
+#include <lib/libsa/ufs.h>
+
+#include <sys/disklabel.h>
+
+#define XSTR(x) #x
+#define STR(x) XSTR(x)
+
+static uint32_t bios_sector;
+
+const char *boot1(uint32_t *);
+void putstr(const char *str);
+int raise(int sig);
+int blkdevstrategy(void *, int, daddr_t, size_t, void *, size_t *);
+
+extern struct disklabel ptn_disklabel;
+
+struct fs_ops file_system[] = {
+ { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek,
+ ufs_stat, nullsys },
+};
+int nfsys = NENTS(file_system);
+
+struct devsw devsw[] = {
+ { "dk", blkdevstrategy, nullsys, nullsys, noioctl },
+};
+int ndevs = NENTS(devsw);
+
+const char *
+boot1(uint32_t *sector)
+{
+ struct stat sb;
+ int fd;
+
+ bios_sector = *sector;
+
+ putstr("\r\nOpenBSD/" MACHINE " Primary Bootstrap\r\n");
+
+ do {
+ /*
+ * Nothing at the start of the MBR partition, fallback on
+ * partition 'a' from the disklabel in this MBR partition.
+ */
+ if (ptn_disklabel.d_magic != DISKMAGIC)
+ break;
+ if (ptn_disklabel.d_magic2 != DISKMAGIC)
+ break;
+ if (ptn_disklabel.d_partitions[0].p_fstype == FS_UNUSED)
+ break;
+
+ bios_sector = ptn_disklabel.d_partitions[0].p_offset;
+ *sector = bios_sector;
+ fd = open("boot", 0);
+ } while (0);
+
+ if (fd == -1 || fstat(fd, &sb) == -1)
+ return "Can't open /boot.\r\n";
+
+#if 0
+ if (sb.st_size > SECONDARY_MAX_LOAD)
+ return "/boot too large.\r\n";
+#endif
+
+ if (read(fd, (void *)LOADADDRESS, sb.st_size) != sb.st_size)
+ return "/boot load failed.\r\n";
+
+ if (*(uint32_t *)(LOADADDRESS + 4) != 0x20041110)
+ return "Invalid /boot file format.\r\n";
+
+ return 0;
+}
+
+int
+blkdevstrategy(void *devdata, int flag, daddr_t dblk, size_t size, void *buf, size_t *rsize)
+{
+
+ if (flag != F_READ)
+ return EROFS;
+
+ if (size & (DEV_BSIZE - 1))
+ return EINVAL;
+
+ if (rsize)
+ *rsize = size;
+
+ if (size != 0 && readsects(0x40, bios_sector + dblk, buf,
+ size / DEV_BSIZE) != 0)
+ return EIO;
+
+ return 0;
+}
+
+/* ARGUSED */
+int
+raise(int sig)
+{
+
+ return 0;
+}
+
+void
+twiddle(void)
+{
+ static int pos;
+
+ putchar("|/-\\"[pos++ & 3]);
+ putchar('\b');
+}
+
+int
+devopen(struct open_file *f, const char *fname, char **file)
+{
+ *file = (char *)fname;
+ f->f_flags |= F_NODEV;
+ f->f_dev = &devsw[0];
+ return (0);
+}
diff --git a/sys/arch/landisk/stand/bootxx/bootxx.8 b/sys/arch/landisk/stand/bootxx/bootxx.8
new file mode 100644
index 00000000000..a2745b51778
--- /dev/null
+++ b/sys/arch/landisk/stand/bootxx/bootxx.8
@@ -0,0 +1,68 @@
+.\" $OpenBSD: bootxx.8,v 1.1 2006/10/06 21:48:50 mickey Exp $
+.\"
+.\" Copyright (c) 2006 Michael Shalayeff
+.\" All rights reserved.
+.\"
+.\" Permission to use, copy, modify, and distribute this software for any
+.\" purpose with or without fee is hereby granted, provided that the above
+.\" copyright notice and this permission notice appear in all copies.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+.\" WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN
+.\" AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+.\" OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+.\"
+.Dd October 5, 2006
+.Dt BOOTXX 8 landisk
+.Os
+.Sh NAME
+.Nm bootxx
+.Nd
+LANDISK-specific primary boot loader
+.Sh DESCRIPTION
+This small program, residing in the reserved sectors at the beginning
+of the root file system of the system, is responsible for loading
+the second-stage
+.Xr boot 8
+program (typically /boot), which in turn will load the kernel.
+.Pp
+To install (or update) your
+.Nm
+program use
+.Xr disklabel 8
+utility using -B switch.
+.Pp
+When
+.Nm
+receives control from the master boot record (MBR) it will print a banner:
+.Pp
+.Dl OpenBSD MBR
+.Pp
+followed by a little twiddler while reading the second-stage boot.
+.Sh DIAGNOSTIC
+.Nm
+will print messages indicating errors as returned from the firmware.
+.Sh FILES
+.Bl -tag -width /usr/mdec/bootxx -compact
+.It Pa /usr/mdec/mbr
+Master Boot Record block
+.It Pa /usr/mdec/bootxx
+primary bootstrap
+.It Pa /boot
+secondary bootstrap
+.It Pa /bsd
+.Ox
+kernel
+.It Pa /bsd.rd
+.Ox
+kernel for installation/recovery
+.El
+.Sh SEE ALSO
+.Xr boot 8 ,
+.Xr boot_landisk 8 ,
+.Xr disklabel 8 ,
+.Xr fdisk 8 ,
+.Xr mbr 8
diff --git a/sys/arch/landisk/stand/bootxx/bootxx.S b/sys/arch/landisk/stand/bootxx/bootxx.S
new file mode 100644
index 00000000000..0a7b9c34e4c
--- /dev/null
+++ b/sys/arch/landisk/stand/bootxx/bootxx.S
@@ -0,0 +1,137 @@
+/* $OpenBSD: bootxx.S,v 1.1 2006/10/06 21:48:50 mickey Exp $ */
+/* $NetBSD: bootxx.S,v 1.1 2006/09/01 21:26:19 uwe Exp $ */
+
+/*-
+ * Copyright (c) 2005 NONAKA Kimihiro
+ * 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 REGENTS AND CONTRIBUTORS ``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.
+ */
+
+#include <machine/asm.h>
+
+ENTRY(bootxx_start)
+ bra bootxx_start1
+ nop
+ .balign 4
+ENTRY(bootxx_magic)
+ .long 0x20031125
+boot_params:
+ .long 1f - boot_params
+
+ . = bootxx_start + 0x80
+bootxx_start1:
+ mov.l .L._end, r0 /* zero bss */
+ mov.l .L.__bss_start, r1
+ sub r1, r0
+ shlr2 r0 /* _end and __bss_start are aligned */
+ mov #0, r2
+1: mov.l r2, @r1
+ dt r0
+ bf/s 1b
+ add #4, r1
+
+ mov.l .L.2nd_loadaddr, r15 /* new stack pointer */
+ mov.l r4, @-r15
+ mov.l .L.boot1, r0
+ jsr @r0
+ mov r15, r4
+
+ tst r0, r0
+ bf/s boot_fail
+ mov.l @r15+, r5 /* pass boot sector to boot */
+
+ /* flush cache */
+ mov #0, r4
+ mov #6, r0
+ trapa #0x3f
+
+ mov.l .L.2nd_loadaddr, r0
+ mov.l .L.boot_params, r4
+ jmp @r0
+ nop
+
+boot_fail:
+ mov r0, r1
+ mova .L.errtxt, r0
+ mov r0, r4
+ mov #32, r0
+ trapa #0x3f
+ mov r1, r4
+ mov #32, r0
+ trapa #0x3f
+ mova .L.crlf, r0
+ mov r0, r4
+ mov #32, r0
+ trapa #0x3f
+99: bra 99b
+ nop
+
+
+ .align 2
+.L._end:
+ .long _end
+.L.__bss_start:
+ .long __bss_start
+.L.boot1:
+ .long _C_LABEL(boot1)
+.L.2nd_loadaddr:
+ .long LOADADDRESS
+.L.boot_params:
+ .long boot_params
+
+ .align 2
+.L.errtxt: .asciz "Error: "
+ .align 2
+.L.crlf: .asciz "\r\n"
+
+
+/*
+ * int readsects(int dev, uint32_t lba, void *buf, size_t size);
+ */
+ENTRY(readsects)
+ mov #2, r0
+ trapa #0x3f
+ rts
+ nop
+argerror:
+ rts
+ mov #-1, r0
+
+/*
+ * void putstr(const char *str);
+ */
+ENTRY(putstr)
+ mov #32, r0
+ trapa #0x3f
+ rts
+ nop
+
+/*
+ * void putchar(int c);
+ */
+ENTRY(putchar)
+ mov #31, r0
+ trapa #0x3f
+ rts
+ nop
+
diff --git a/sys/arch/landisk/stand/bootxx/pbr.S b/sys/arch/landisk/stand/bootxx/pbr.S
new file mode 100644
index 00000000000..8e17bef2d83
--- /dev/null
+++ b/sys/arch/landisk/stand/bootxx/pbr.S
@@ -0,0 +1,212 @@
+/* $OpenBSD: pbr.S,v 1.1 2006/10/06 21:48:50 mickey Exp $ */
+/* $NetBSD: pbr.S,v 1.1 2006/09/01 21:26:19 uwe Exp $ */
+
+/*-
+ * Copyright (c) 2005 NONAKA Kimihiro
+ * 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 REGENTS AND CONTRIBUTORS ``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.
+ */
+
+#include <machine/asm.h>
+
+#ifdef BOOT_FROM_FAT
+#define MBR_AFTERBPB 90 /* BPB size in FAT32 partition BR */
+#else
+#define MBR_AFTERBPB 62 /* BPB size in floppy master BR */
+#endif
+
+ENTRY(start)
+ bra start0
+ .byte 0x11 /* 0x4e11: cmp/pz r14... */
+ .asciz "OpenBSD"
+
+ . = _C_LABEL(start) + 0x0b /* move to start of BPB */
+
+ . = _C_LABEL(start) + 0x1c /* skip BPB */
+start0:
+ mova pbr_end, r0
+ mov.w pbr_size, r2
+ sub r2, r0
+ mov r0, r11 /* r11: own loaded address */
+
+ mov.w stack_offset, r1
+ add r1, r0
+ mov r0, r15 /* r15: stack pointer */
+ mov r0, r10 /* r10: load address */
+
+ /* enable/flush cache */
+ mov #0, r4
+ mov #6, r0
+ trapa #0x3f
+
+ /* Read from start of disk */
+ mov #0x40, r4 /* LBA */
+ mov #0, r5 /* LBA #0 */
+ mov r10, r6 /* buffer address */
+ bsr read_sectors_lba
+ mov #BOOTXX_SECTORS, r7 /* number of sectors */
+
+ mov.l @r11, r1
+ mov.l @r10, r2
+ cmp/eq r1, r2
+ bt/s pbr_read_ok
+ mov #0, r9 /* r9: sector # */
+
+ /* Search bootable partition */
+ mov.w part_offset, r12
+ add r10, r12 /* r12: pointer to partition entry */
+ mov #4, r8 /* r8: partition loop counter */
+loop_part:
+ mov.b @(4, r12), r0
+#ifdef BOOT_FROM_FAT
+ cmp/eq #MBR_PTYPE_FAT12, r0
+ bt found
+ cmp/eq #MBR_PTYPE_FAT16S, r0
+ bt found
+ cmp/eq #MBR_PTYPE_FAT16B, r0
+ bt found
+ cmp/eq #MBR_PTYPE_FAT32, r0
+ bt found
+ cmp/eq #MBR_PTYPE_FAT32L, r0
+ bt found
+ cmp/eq #MBR_PTYPE_FAT16L, r0
+ bt found
+#else
+ cmp/eq #0xa6, r0
+#endif
+ bf next_part
+
+found:
+ /* found boot partition */
+ mov.w @(8, r12), r0
+ mov r0, r1
+ mov.w @(10, r12), r0
+ extu.w r1, r1
+ shll16 r0
+ or r1, r0
+ tst r0, r0
+ bt next_part /* start LBA == 0 ? */
+
+ bra boot_lba
+ mov r0, r9
+
+next_part:
+ dt r8
+ bf/s loop_part
+ add #16, r12
+
+ptn_error:
+ /* Not found NetBSD partition */
+ mova ERR_PTN, r0
+error:
+ bsr message_crlf
+ mov r0, r4
+99: bra 99b
+ nop
+
+read_error:
+ bra error
+ mova ERR_READ, r0
+
+magic_error:
+ bra error
+ mova ERR_NO_BOOTXX, r0
+
+message_crlf:
+ mov #32, r0
+ trapa #0x3f
+ mova crlf, r0
+ mov r0, r4
+ mov #32, r0
+ trapa #0x3f
+ rts
+ nop
+
+read_sectors_lba:
+ mov #2, r0
+ trapa #0x3f
+ tst r0, r0
+ bf read_error
+ rts
+ nop
+
+boot_lba:
+ mov #0x40, r4 /* LBA */
+ mov r9, r5 /* LBA # */
+ mov r10, r6 /* buffer address */
+ bsr read_sectors_lba
+ mov #BOOTXX_SECTORS, r7 /* number of sectors */
+
+pbr_read_ok:
+ mov.l .L.bootxx_magic1, r1
+ mov.l .L.bootxx_magic, r2
+ mov.l @r2, r2
+ cmp/eq r1, r2
+ bf magic_error
+
+ /* flush cache */
+ mov #0, r4
+ mov #6, r0
+ trapa #0x3f
+
+ mov.l .L.bootxx_start, r13
+ jmp @r13 /* jump to bootxx */
+ mov r9, r4 /* pass sector address to bootxx */
+
+
+ .align 1
+pbr_size: .word pbr_end - _C_LABEL(start)
+ .align 1
+stack_offset: .word 0x1000
+ .align 1
+part_offset: .word 0x1be
+ .align 1
+magic_offset: .word 0x1fe
+
+ .align 2
+.L.bootxx_magic1:
+ .long 0x20031125
+.L.bootxx_magic:
+ .long _C_LABEL(bootxx_magic)
+.L.bootxx_start:
+ .long _C_LABEL(bootxx_start)
+
+ .align 2
+crlf: .asciz "\r\n"
+
+ .align 2
+ERR_READ: .asciz "Disk read"
+ .align 2
+ERR_NO_BOOTXX: .asciz "Not a bootxx image"
+ .align 2
+ERR_PTN: .asciz "No OpenBSD partition"
+
+
+ . = _C_LABEL(start) + 0x1fe
+magic:
+ .word 0xaa55
+pbr_end:
+
+ .global _C_LABEL(ptn_disklabel)
+_C_LABEL(ptn_disklabel):
+ .fill 512
diff --git a/sys/arch/landisk/stand/mbr/Makefile b/sys/arch/landisk/stand/mbr/Makefile
new file mode 100644
index 00000000000..e44acf8cee7
--- /dev/null
+++ b/sys/arch/landisk/stand/mbr/Makefile
@@ -0,0 +1,25 @@
+# $OpenBSD: Makefile,v 1.1 2006/10/06 21:48:50 mickey Exp $
+
+PROG= mbr
+SRCS= mbr.S
+MAN= mbr.8
+AFLAGS+=-nostdinc -I${.OBJDIR} -I${.CURDIR}/.. -I${.CURDIR}/../../.. #-Wa,a
+LDFLAGS+=-N -e start -Ttext 0x8c200200
+OBJCOPY?=objcopy
+
+INSTALL_STRIP=
+S= ${.CURDIR}/../../../..
+
+# Uncomment this to make mbr talk to a serial port.
+#CPPFLAGS+=-DSERIAL=0
+
+${PROG}: $(OBJS) $(DPADD)
+ $(LD) $(LDFLAGS) -o $(PROG) $(OBJS) $(LDADD)
+ @size $(PROG)
+ @if [ -x ${.OBJDIR}/${PROG} ]; then \
+ ${OBJCOPY} -O binary ${PROG} ${.OBJDIR}/.tmp;\
+ mv -f ${.OBJDIR}/.tmp ${.OBJDIR}/${PROG}; \
+ ls -l ${.OBJDIR}/${PROG}; \
+ fi
+
+.include <bsd.prog.mk>
diff --git a/sys/arch/landisk/stand/mbr/mbr.8 b/sys/arch/landisk/stand/mbr/mbr.8
new file mode 100644
index 00000000000..b724ca01cac
--- /dev/null
+++ b/sys/arch/landisk/stand/mbr/mbr.8
@@ -0,0 +1,60 @@
+.\" $OpenBSD: mbr.8,v 1.1 2006/10/06 21:48:50 mickey Exp $
+.\"
+.\" Copyright (c) 2006 Michael Shalayeff
+.\" All rights reserved.
+.\"
+.\" Permission to use, copy, modify, and distribute this software for any
+.\" purpose with or without fee is hereby granted, provided that the above
+.\" copyright notice and this permission notice appear in all copies.
+.\"
+.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+.\" WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER IN
+.\" AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
+.\" OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+.\"
+.Dd October 5, 2006
+.Dt MBR 8 landisk
+.Os
+.Sh NAME
+.Nm mbr
+.Nd
+LANDISK-specific Master Boot Record
+.Sh DESCRIPTION
+.Nm MBR
+program that is only one sector (512 bytes) and also includes
+a partition table for the disk is located in the 0th sector of the disk.
+Upon receiving control from the system firmware
+.Nm
+will scan the partition table for an active partition and continue
+loading the Primary Boot Record (PBR) from the beginnning of the
+partition, if found.
+.Pp
+.Nm
+is installed into the disk by the
+.Xr fdisk 8
+program that is also used to operate the partition table.
+.Pp
+Partition table sonsists of four entries only one of which may be
+marked as
+.Dq active
+that is where the PBR will be loaded from.
+.Sh DIAGNOSTICS
+A few messages are printed in case of errors:
+.Bl -tag -width no_active_partition
+.It "No active partition"
+Indicates that none of the partitions are marked
+.Dq active .
+.It Read error
+An error occured while fetching the primary boot loader.
+.It "No O/S"
+The partition table is empty.
+.El
+.Sh SEE ALSO
+.Xr boot 8 ,
+.Xr bootxx 8 ,
+.Xr boot_landisk 8 ,
+.Xr disklabel 8 ,
+.Xr fdisk 8
diff --git a/sys/arch/landisk/stand/mbr/mbr.S b/sys/arch/landisk/stand/mbr/mbr.S
new file mode 100644
index 00000000000..130da948972
--- /dev/null
+++ b/sys/arch/landisk/stand/mbr/mbr.S
@@ -0,0 +1,212 @@
+/* $OpenBSD: mbr.S,v 1.1 2006/10/06 21:48:50 mickey Exp $ */
+/* $NetBSD: mbr.S,v 1.1 2006/09/01 21:26:19 uwe Exp $ */
+
+/*-
+ * Copyright (c) 2005 NONAKA Kimihiro
+ * 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 REGENTS AND CONTRIBUTORS ``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.
+ */
+
+#include <machine/asm.h>
+
+ENTRY(start)
+ mova mbr_end, r0
+ mov r0, r11 /* r11: relocate address */
+
+ mov.w mbr_size, r2
+ sub r2, r0
+ mov r0, r10 /* r10: loaded address */
+
+ mov.w stack_offset, r1
+ add r1, r0
+ mov r0, r15 /* r15: stack pointer */
+
+ /* relocate code */
+ mova jmp_start, r0
+ mov r0, r13
+ add r2, r13 /* calc jump address */
+
+ mov r10, r0
+ mov r11, r1
+1: mov.b @r0+, r3
+ dt r2
+ mov.b r3, @r1
+ bf/s 1b
+ add #1, r1
+
+ jmp @r13
+ nop
+
+ .align 2
+jmp_start:
+ /* enable cache */
+ mov #0, r4
+ mov #6, r0
+ trapa #0x3f
+
+ /* print banner */
+ mova banner, r0
+ bsr message
+ mov r0, r4
+
+ /* search bootable partition */
+ mov.w part_offset, r12
+ add r11, r12 /* r12: pointer to partition entry */
+ mov #4, r8 /* r8: partition loop counter */
+loop_part:
+ mov.b @(4, r12), r0
+ cmp/eq #0x00, r0
+ bt next_part
+
+ /* check active partition */
+ mov.b @(0, r12), r0
+ cmp/eq #0x80, r0
+ bf next_part
+
+ /* found bootable partition */
+ mov.w @(8, r12), r0 /* load unaligned 32bit data */
+ mov r0, r1
+ mov.w @(10, r12), r0
+ extu.w r1, r1
+ shll16 r0
+ or r1, r0
+
+ mov r0, r3
+ mova found_sector, r0
+ bra boot_lba
+ mov.l r3, @r0
+
+next_part:
+ dt r8
+ bf/s loop_part
+ add #16, r12
+
+noos_error:
+ /* Not found bootable partition */
+ mova ERR_NOOS, r0
+error:
+ bsr message
+ mov r0, r4
+99: bra 99b
+ nop
+
+read_error:
+ bra error
+ mova ERR_READ, r0
+
+message:
+ mov #32, r0
+ trapa #0x3f
+ rts
+ nop
+
+read_sector_lba:
+ mov #1, r7
+ mov #2, r0
+ trapa #0x3f
+ tst r0, r0
+ bf read_error
+ rts
+ nop
+
+boot_lba:
+ /* read PBR sector */
+ mova found_sector, r0
+ mov #0x40, r4
+ mov.l @r0, r5
+ bsr read_sector_lba
+ mov r10, r6
+
+ /* flush cache */
+ mov #0, r4
+ mov #6, r0
+ trapa #0x3f
+
+ /* check signature */
+ mov.b @(0, r10), r0
+ tst r0, r0
+ bt noos_error /* first byte non-zero */
+ mov.w magic_offset, r0
+ mov.w @(r0, r10), r1
+ mov.w magic, r2
+ cmp/eq r1, r2
+ bf noos_error /* magic */
+
+ /* now jump to PBR */
+ mov r10, r0
+ jmp @r10
+ nop
+
+
+ .align 1
+mbr_size: .word mbr_end - _C_LABEL(start)
+ .align 1
+stack_offset: .word 0x1000
+ .align 1
+part_offset: .word 0x1be
+ .align 1
+magic_offset: .word 0x1fe
+
+ .align 2
+found_sector: .long 0
+
+ .align 2
+banner: .asciz "\r\nOpenBSD MBR\r\n"
+
+ .align 2
+ERR_INVPART: .asciz "No active partition\r\n"
+ .align 2
+ERR_READ: .asciz "Read error\r\n"
+ .align 2
+ERR_NOOS: .asciz "No O/S\r\n"
+
+
+/* space for mbr_dsn */
+ . = _C_LABEL(start) + 0x1b4
+ .long 0
+
+/* mbr_bootsel_magic */
+ . = _C_LABEL(start) + 0x1b8
+ .word 0
+
+/*
+ * MBR partition table
+ */
+ . = _C_LABEL(start) + 0x1be
+_pbr_part0:
+ .byte 0, 0, 0, 0, 0, 0, 0, 0
+ .byte 0, 0, 0, 0, 0, 0, 0, 0
+_pbr_part1:
+ .byte 0, 0, 0, 0, 0, 0, 0, 0
+ .byte 0, 0, 0, 0, 0, 0, 0, 0
+_pbr_part2:
+ .byte 0, 0, 0, 0, 0, 0, 0, 0
+ .byte 0, 0, 0, 0, 0, 0, 0, 0
+_pbr_part3:
+ .byte 0x80, 0, 1, 0, 0xa6, 255, 255, 255
+ .word 0, 0, 0xffff, 0x7fff
+
+ . = _C_LABEL(start) + 0x1fe
+magic:
+ .word 0xaa55
+mbr_end: