diff options
author | 2013-10-29 21:49:07 +0000 | |
---|---|---|
committer | 2013-10-29 21:49:07 +0000 | |
commit | d2f66e2e1fe9ab9bfd87b4047b4988ef3b310a38 (patch) | |
tree | 9cd2e7ac69a05d8a62a35f06bed7fa22ab34fb41 /sys | |
parent | unbreak glxsb(4) by properly allocating it's key schedule; (diff) | |
download | wireguard-openbsd-d2f66e2e1fe9ab9bfd87b4047b4988ef3b310a38.tar.xz wireguard-openbsd-d2f66e2e1fe9ab9bfd87b4047b4988ef3b310a38.zip |
More cleanups:
- accept empty controller and partition numbers, as well as empty filenames,
and use defaults (0, 0 and "bsd") instead of complaining the boot path
is invalid.
- do not attempt to detect and report devices at boot, using a small
list of possible devices (only scsi id #6 and #5, come on!).
Instead, parse the user-supplied boot string to figure out which controller
and device to talk to. (still no SCSI LUN support, though).
Because of the last change, SCSI unit numbers ought to match the PROM
numbering now (10 * controller + 6 - device id).
Crank version to 0.2.
Diffstat (limited to 'sys')
21 files changed, 254 insertions, 1130 deletions
diff --git a/sys/arch/luna88k/stand/boot/Makefile b/sys/arch/luna88k/stand/boot/Makefile index 4c4f09d75ce..6cdac46e7aa 100644 --- a/sys/arch/luna88k/stand/boot/Makefile +++ b/sys/arch/luna88k/stand/boot/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.1 2013/10/28 22:13:12 miod Exp $ +# $OpenBSD: Makefile,v 1.2 2013/10/29 21:49:07 miod Exp $ # $NetBSD: Makefile,v 1.9 2013/01/22 15:48:40 tsutsui Exp $ # @(#)Makefile 8.2 (Berkeley) 8/15/93 @@ -23,7 +23,7 @@ LINKFORMAT= -static -N -Ttext ${TEXTADDR} -T ${LDSCRIPT} \ --warn-common -nopie SRCS= locore.S -SRCS+= init_main.c autoconf.c ioconf.c +SRCS+= init_main.c SRCS+= fault.c setjmp.S SRCS+= bcd.c SRCS+= devopen.c diff --git a/sys/arch/luna88k/stand/boot/autoconf.c b/sys/arch/luna88k/stand/boot/autoconf.c deleted file mode 100644 index d4a875a69af..00000000000 --- a/sys/arch/luna88k/stand/boot/autoconf.c +++ /dev/null @@ -1,445 +0,0 @@ -/* $OpenBSD: autoconf.c,v 1.2 2013/10/29 18:51:37 miod Exp $ */ -/* $NetBSD: autoconf.c,v 1.7 2013/01/22 15:48:40 tsutsui Exp $ */ - -/* - * Copyright (c) 1992 OMRON Corporation. - * - * This code is derived from software contributed to Berkeley by - * OMRON Corporation. - * - * 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 University of - * California, Berkeley and its contributors. - * 4. 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. - * - * @(#)autoconf.c 8.1 (Berkeley) 6/10/93 - */ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * OMRON Corporation. - * - * 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. - * - * @(#)autoconf.c 8.1 (Berkeley) 6/10/93 - */ - -/* - * autoconf.c -- Determine mass storage and memory configuration for a machine. - * by A.Fujita, NOV-30-1991 - * - * Modified by A.Fujita, FEB-04-1992 - */ - - -#include <sys/param.h> -#include <machine/board.h> -#include <lib/libkern/libkern.h> -#include <luna88k/stand/boot/samachdep.h> -#include <luna88k/stand/boot/device.h> - -struct hp_hw sc_table[MAX_CTLR]; - -#ifdef DEBUG -int acdebug = 1; -#endif - -static int find_controller(struct hp_hw *); -static int find_device(struct hp_hw *); -static void find_slaves(struct hp_ctlr *); -static int same_hw_device(struct hp_hw *, struct hp_device *); - -/* - * Determine mass storage and memory configuration for a machine. - */ -void -configure(void) -{ - struct hp_hw *hw; - int found; - - /* - * Look over each hardware device actually found and attempt - * to match it with an ioconf.c table entry. - */ - for (hw = sc_table; hw->hw_type; hw++) { - if (hw->hw_type & CONTROLLER) - found = find_controller(hw); - else - found = find_device(hw); -#ifdef DEBUG - if (!found) { - printf("unconfigured %s ", hw->hw_name); - printf("at 0x%x\n", (u_int)hw->hw_addr); - } -#endif - } - -} - -#define dr_type(d, s) \ - (strcmp((d)->d_name, (s)) == 0) - -#define same_hw_ctlr(hw, hc) \ - ((hw)->hw_type == SCSI && dr_type((hc)->hp_driver, "sc")) - -int -find_controller(struct hp_hw *hw) -{ - struct hp_ctlr *hc; - struct hp_ctlr *match_c; - uint8_t *addr, *oaddr; - -#ifdef DEBUG - if (acdebug) - printf("find_controller: hw: %s at %p, type %x...", - hw->hw_name, hw->hw_addr, hw->hw_type); -#endif - addr = hw->hw_addr; - match_c = NULL; - for (hc = hp_cinit; hc->hp_driver; hc++) { - if (hc->hp_alive) - continue; - /* - * Make sure we are looking at the right - * controller type. - */ - if (!same_hw_ctlr(hw, hc)) - continue; - /* - * Exact match; all done - */ - if (hc->hp_addr == addr) { - match_c = hc; - break; - } - /* - * Wildcard; possible match so remember first instance - * but continue looking for exact match. - */ - if ((int)hc->hp_addr == WILD_CARD_CTLR && match_c == NULL) - match_c = hc; - } -#ifdef DEBUG - if (acdebug) { - if (match_c) - printf("found %s%d\n", - match_c->hp_driver->d_name, - match_c->hp_unit); - else - printf("not found\n"); - } -#endif - /* - * Didn't find an ioconf entry for this piece of hardware, - * just ignore it. - */ - if (match_c == NULL) - return(0); - /* - * Found a match, attempt to initialize and configure all attached - * slaves. Note, we can still fail if HW won't initialize. - */ - hc = match_c; - oaddr = hc->hp_addr; - hc->hp_addr = hw->hw_addr; - if ((*hc->hp_driver->d_init)(hc)) { - hc->hp_alive = 1; - printf("%s%d", hc->hp_driver->d_name, hc->hp_unit); - printf(" at %p\n", hc->hp_addr); - find_slaves(hc); - } else - hc->hp_addr = oaddr; - return(1); -} - -int -find_device(struct hp_hw *hw) -{ - struct hp_device *hd; - struct hp_device *match_d; - uint8_t *addr, *oaddr; - -#ifdef DEBUG - if (acdebug) - printf("find_device: hw: %s at %p, type %x...", - hw->hw_name, hw->hw_addr, hw->hw_type); -#endif - match_d = NULL; - for (hd = hp_dinit; hd->hpd_driver; hd++) { - if (hd->hpd_alive) - continue; - /* Must not be a slave */ - if (hd->hpd_cdriver) - continue; - addr = hd->hpd_addr; - /* - * Exact match; all done. - */ - if (addr != NULL && addr == hw->hw_addr) { - match_d = hd; - break; - } - /* - * Wildcard; possible match so remember first instance - * but continue looking for exact match. - */ - if (addr == NULL && same_hw_device(hw, hd) && match_d == NULL) - match_d = hd; - } -#ifdef DEBUG - if (acdebug) { - if (match_d) - printf("found %s%d\n", - match_d->hpd_driver->d_name, - match_d->hpd_unit); - else - printf("not found\n"); - } -#endif - /* - * Didn't find an ioconf entry for this piece - * of hardware, just ignore it. - */ - if (match_d == NULL) - return(0); - /* - * Found a match, attempt to initialize. - * Note, we can still fail if HW won't initialize. - */ - hd = match_d; - oaddr = hd->hpd_addr; - hd->hpd_addr = hw->hw_addr; - if ((*hd->hpd_driver->d_init)(hd)) { - hd->hpd_alive = 1; - printf("%s%d", hd->hpd_driver->d_name, hd->hpd_unit); - printf(" at %p\n", hd->hpd_addr); - } else - hd->hpd_addr = oaddr; - return(1); -} - -/* - * Search each BUS controller found for slaves attached to it. - * The bad news is that we don't know how to uniquely identify all slaves - * (e.g. PPI devices on HP-IB). The good news is that we can at least - * differentiate those from slaves we can identify. At worst (a totally - * wildcarded entry) this will cause us to locate such a slave at the first - * unused position instead of where it really is. To save grief, non- - * identifing devices should always be fully qualified. - */ -void -find_slaves(struct hp_ctlr *hc) -{ - int s; - struct hp_device *hd; - struct hp_device *match_s; - int maxslaves = MAXSLAVES-1; - int new_s, new_c, old_s, old_c; - -#ifdef DEBUG - if (acdebug) - printf("find_slaves: for %s%d\n", - hc->hp_driver->d_name, hc->hp_unit); -#endif - new_s = new_c = -1; - for (s = 0; s < maxslaves; s++) { - match_s = NULL; - for (hd = hp_dinit; hd->hpd_driver; hd++) { - /* - * Rule out the easy ones: - * 1. slave already assigned or not a slave - * 2. not of the proper type - * 3. controller specified but not this one - * 4. slave specified but not this one - */ - if (hd->hpd_alive || hd->hpd_cdriver == NULL) - continue; - if (!dr_type(hc->hp_driver, hd->hpd_cdriver->d_name)) - continue; - if (hd->hpd_ctlr >= 0 && hd->hpd_ctlr != hc->hp_unit) - continue; - if (hd->hpd_slave >= 0 && hd->hpd_slave != s) - continue; - /* - * Case 0: first possible match. - * Remember it and keep looking for better. - */ - if (match_s == NULL) { - match_s = hd; - new_c = hc->hp_unit; - new_s = s; - continue; - } - /* - * Case 1: exact match. - * All done. Note that we do not attempt any other - * matches if this one fails. This allows us to - * "reserve" locations for dynamic addition of - * disk/tape drives by fully qualifing the location. - */ - if (hd->hpd_slave == s && hd->hpd_ctlr == hc->hp_unit) { - match_s = hd; - break; - } - /* - * Case 2: right controller, wildcarded slave. - * Remember first and keep looking for an exact match. - */ - if (hd->hpd_ctlr == hc->hp_unit && - match_s->hpd_ctlr < 0) { - match_s = hd; - new_s = s; - continue; - } - /* - * Case 3: right slave, wildcarded controller. - * Remember and keep looking for a better match. - */ - if (hd->hpd_slave == s && - match_s->hpd_ctlr < 0 && match_s->hpd_slave < 0) { - match_s = hd; - new_c = hc->hp_unit; - continue; - } - /* - * OW: we had a totally wildcarded spec. - * If we got this far, we have found a possible - * match already (match_s != NULL) so there is no - * reason to remember this one. - */ - continue; - } - /* - * Found a match. We need to set hp_ctlr/hp_slave properly - * for the init routines but we also need to remember all - * the old values in case this doesn't pan out. - */ - if (match_s) { - hd = match_s; - old_c = hd->hpd_ctlr; - old_s = hd->hpd_slave; - if (hd->hpd_ctlr < 0) - hd->hpd_ctlr = new_c; - if (hd->hpd_slave < 0) - hd->hpd_slave = new_s; -#ifdef DEBUG - if (acdebug) - printf("looking for %s%d at slave %d...", - hd->hpd_driver->d_name, - hd->hpd_unit, hd->hpd_slave); -#endif - - if ((*hd->hpd_driver->d_init)(hd)) { -#ifdef DEBUG - if (acdebug) - printf("found\n"); -#endif - printf("%s%d at %s%d, slave %d\n", - hd->hpd_driver->d_name, hd->hpd_unit, - hc->hp_driver->d_name, hd->hpd_ctlr, - hd->hpd_slave); - hd->hpd_alive = 1; - } else { -#ifdef DEBUG - if (acdebug) - printf("not found\n"); -#endif - hd->hpd_ctlr = old_c; - hd->hpd_slave = old_s; - } - } - } -} - -int -same_hw_device(struct hp_hw *hw, struct hp_device *hd) -{ - int found = 0; - - switch (hw->hw_type) { - case NET: - found = dr_type(hd->hpd_driver, "le"); - break; - case SCSI: - found = dr_type(hd->hpd_driver, "scsi"); - break; - } - return(found); -} - -#define setup_hw(hw, addr, type, name) \ - (hw)->hw_addr = addr; \ - (hw)->hw_type = type; \ - (hw)->hw_name = name - -void -find_devs(void) -{ - struct hp_hw *hw = sc_table; - - setup_hw(hw, (uint8_t *)0x51000000, SIO, "uPD7201A (SIO)"); - hw++; - - setup_hw(hw, (uint8_t *)0x51000004, KEYBOARD, "uPD7201A (KBD)"); - hw++; - - setup_hw(hw, (uint8_t *)0xe1000000, SCSI, "MB89352 (SPC)"); - hw++; - - if (machtype == LUNA_88K2 && badaddr((void *)0xe1000040, 4) == 0) { - setup_hw(hw, (uint8_t *)0xe1000040, SCSI, "MB89352 (SPC)"); - hw++; - } - if (badaddr((void *)0xf1000000, 4) == 0) { - setup_hw(hw, (uint8_t *)0xf1000000, NET, "Am7990 (LANCE)"); - hw++; - } -} diff --git a/sys/arch/luna88k/stand/boot/awaitkey.c b/sys/arch/luna88k/stand/boot/awaitkey.c index 82bb5d4ba90..990e98cf0e3 100644 --- a/sys/arch/luna88k/stand/boot/awaitkey.c +++ b/sys/arch/luna88k/stand/boot/awaitkey.c @@ -1,4 +1,4 @@ -/* $OpenBSD: awaitkey.c,v 1.1 2013/10/28 22:13:12 miod Exp $ */ +/* $OpenBSD: awaitkey.c,v 1.2 2013/10/29 21:49:07 miod Exp $ */ /* $NetBSD: awaitkey.c,v 1.1 2013/01/21 11:58:12 tsutsui Exp $ */ /*- @@ -80,7 +80,7 @@ awaitkey(const char *pfmt, int timeout, int tell) out: if (tell) { - printf(pfmt, 0); + printf(pfmt, timeout); printf("\n"); } return c; diff --git a/sys/arch/luna88k/stand/boot/bmd.c b/sys/arch/luna88k/stand/boot/bmd.c index 18bec2aa7ef..b7766ed166a 100644 --- a/sys/arch/luna88k/stand/boot/bmd.c +++ b/sys/arch/luna88k/stand/boot/bmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bmd.c,v 1.3 2013/10/29 18:51:37 miod Exp $ */ +/* $OpenBSD: bmd.c,v 1.4 2013/10/29 21:49:07 miod Exp $ */ /* $NetBSD: bmd.c,v 1.2 2013/01/20 13:35:43 tsutsui Exp $ */ /* @@ -79,6 +79,7 @@ #include <sys/param.h> +#include <machine/board.h> #include <luna88k/stand/boot/samachdep.h> /* @@ -279,8 +280,8 @@ bmd_escape_1(int c) void bmdinit(void) { - volatile uint32_t *bmd_rfcnt = (uint32_t *) 0xB1000000; - volatile long *bmd_bmsel = (long *)0xB1040000; + volatile uint32_t *bmd_rfcnt = (volatile uint32_t *)BMAP_RFCNT; + volatile long *bmd_bmsel = (volatile long *)BMAP_BMSEL; struct bmd_softc *bp = &bmd_softc; struct bmd_linec *bq; int i; @@ -290,8 +291,8 @@ bmdinit(void) * adjust plane position */ - bp->bc_raddr = (char *) 0xB10C0008; /* plane-0 hardware address */ - bp->bc_waddr = (char *) 0xB1080008; /* common bitmap hardware address */ + bp->bc_raddr = (char *)(BMAP_BMAP0 + 8); /* plane-0 hardware address */ + bp->bc_waddr = (char *)(BMAP_BMP + 8); /* common bitmap hardware address */ rfcnt.p.rfc_hcnt = 7; /* shift left 16 dot */ rfcnt.p.rfc_vcnt = -27; /* shift down 1 dot */ *bmd_rfcnt = rfcnt.u; @@ -333,7 +334,7 @@ bmdinit(void) void bmdadjust(short hcnt, short vcnt) { - volatile uint32_t *bmd_rfcnt = (uint32_t *) 0xB1000000; + volatile uint32_t *bmd_rfcnt = (volatile uint32_t *)BMAP_RFCNT; union bmd_rfcnt rfcnt; printf("bmdadjust: hcnt = %d, vcnt = %d\n", hcnt, vcnt); diff --git a/sys/arch/luna88k/stand/boot/dev_net.c b/sys/arch/luna88k/stand/boot/dev_net.c index 4014d72cf9e..f6ea191b1e0 100644 --- a/sys/arch/luna88k/stand/boot/dev_net.c +++ b/sys/arch/luna88k/stand/boot/dev_net.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dev_net.c,v 1.1 2013/10/28 22:13:12 miod Exp $ */ +/* $OpenBSD: dev_net.c,v 1.2 2013/10/29 21:49:07 miod Exp $ */ /* $NetBSD: dev_net.c,v 1.26 2011/07/17 20:54:52 joerg Exp $ */ /*- @@ -72,6 +72,10 @@ static int netdev_opens; static int net_getparams(int); +#ifdef DEBUG +int debug; +#endif + /* * Called by devopen after it sets f->f_dev to our devsw entry. * This opens the low-level device and sets f->f_devdata. diff --git a/sys/arch/luna88k/stand/boot/device.h b/sys/arch/luna88k/stand/boot/device.h deleted file mode 100644 index c464c8a7413..00000000000 --- a/sys/arch/luna88k/stand/boot/device.h +++ /dev/null @@ -1,119 +0,0 @@ -/* $OpenBSD: device.h,v 1.2 2013/10/29 18:51:37 miod Exp $ */ -/* $NetBSD: device.h,v 1.5 2013/01/14 12:28:11 tsutsui Exp $ */ - -/* - * Copyright (c) 1992 OMRON Corporation. - * - * This code is derived from software contributed to Berkeley by - * OMRON Corporation. - * - * 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 University of - * California, Berkeley and its contributors. - * 4. 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. - * - * @(#)device.h 8.1 (Berkeley) 6/10/93 - */ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * OMRON Corporation. - * - * 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. - * - * @(#)device.h 8.1 (Berkeley) 6/10/93 - */ - -struct driver { - int (*d_init)(void *); - char *d_name; -}; - -struct hp_ctlr { - struct driver *hp_driver; - int hp_unit; - int hp_alive; - uint8_t *hp_addr; - int hp_flags; -}; - -struct hp_device { - struct driver *hpd_driver; - struct driver *hpd_cdriver; - int hpd_unit; - int hpd_ctlr; - int hpd_slave; - uint8_t *hpd_addr; - int hpd_alive; -}; - -struct hp_hw { - uint8_t *hw_addr; /* physical address of registers */ - short hw_type; /* type (defined below) */ - char *hw_name; /* HP product name */ -}; - -#define MAX_CTLR 8 /* Totally arbitrary */ -#define MAXSLAVES 8 /* Currently the SCSI limit */ - -#define WILD_CARD_CTLR 0 - -/* A controller is a card which can have one or more slaves attached */ -#define CONTROLLER 0x10 -#define SCSI (CONTROLLER | 0) - -/* Non-disk device types */ -#define NET 1 -#define KEYBOARD 2 -#define SIO 3 - -extern struct hp_ctlr hp_cinit[]; -extern struct hp_device hp_dinit[]; -extern struct hp_hw sc_table[]; diff --git a/sys/arch/luna88k/stand/boot/devopen.c b/sys/arch/luna88k/stand/boot/devopen.c index cc88d887fb0..c296f82c0ca 100644 --- a/sys/arch/luna88k/stand/boot/devopen.c +++ b/sys/arch/luna88k/stand/boot/devopen.c @@ -1,4 +1,4 @@ -/* $OpenBSD: devopen.c,v 1.1 2013/10/28 22:13:12 miod Exp $ */ +/* $OpenBSD: devopen.c,v 1.2 2013/10/29 21:49:07 miod Exp $ */ /* $NetBSD: devopen.c,v 1.3 2013/01/16 15:46:20 tsutsui Exp $ */ /* @@ -75,6 +75,8 @@ #include <luna88k/stand/boot/samachdep.h> #include <machine/disklabel.h> +#define MAXDEVNAME 16 + static int make_device(const char *, int *, int *, int *, char **); int @@ -124,21 +126,21 @@ make_device(const char *str, int *devp, int *unitp, int *partp, char **fname) { const char *cp; struct devsw *dp; - int major, unit, part; + int major, unit = 0, part = 0; int i; char devname[MAXDEVNAME + 1]; /* * parse path strings */ - /* find end of dev type name */ + /* find end of dev type name */ for (cp = str, i = 0; *cp != '\0' && *cp != '(' && i < MAXDEVNAME; i++) devname[i] = *cp++; if (*cp != '(') { return (-1); } devname[i] = '\0'; - /* compare dev type name */ + /* compare dev type name */ for (dp = devsw; dp->dv_name; dp++) if (!strcmp(devname, dp->dv_name)) break; @@ -147,40 +149,44 @@ make_device(const char *str, int *devp, int *unitp, int *partp, char **fname) return (-1); } major = dp - devsw; - /* get unit number */ - unit = *cp++ - '0'; - if (*cp >= '0' && *cp <= '9') - unit = unit * 10 + *cp++ - '0'; - if (unit < 0 || unit > 63) { + /* get mixed controller and unit number */ + for (; *cp != ',' && *cp != ')'; cp++) { + if (*cp == '\0') + return -1; + if (*cp >= '0' && *cp <= '9') + unit = unit * 10 + *cp - '0'; + } + if (unit < 0 || unit >= 20 || (unit % 10) > 7) { #ifdef DEBUG printf("%s: invalid unit number (%d)\n", __func__, unit); #endif return (-1); } - /* get partition offset */ - if (*cp++ != ',') { - return (-1); - } - part = *cp - '0'; - /* check out end of dev spec */ - for (;;) { - if (*cp == ')') - break; - if (*cp++) - continue; - return (-1); + /* get optional partition number */ + if (*cp == ',') + cp++; + + for (; /* *cp != ',' && */ *cp != ')'; cp++) { + if (*cp == '\0') + return -1; + if (*cp >= '0' && *cp <= '9') + part = part * 10 + *cp - '0'; } - if (part < 0 || part > MAXPARTITIONS) { + if (part < 0 || part >= MAXPARTITIONS) { #ifdef DEBUG printf("%s: invalid partition number (%d)\n", __func__, part); #endif return (-1); } - + /* check out end of dev spec */ *devp = major; *unitp = unit; *partp = part; - *fname = (char *)cp + 1; /* XXX */ + cp++; + if (*cp == '\0') + *fname = "bsd"; + else + *fname = (char *)cp; /* XXX */ #ifdef DEBUG printf("%s: major = %d, unit = %d, part = %d, fname = %s\n", __func__, major, unit, part, *fname); diff --git a/sys/arch/luna88k/stand/boot/getline.c b/sys/arch/luna88k/stand/boot/getline.c index 2e400b720a2..48723f16630 100644 --- a/sys/arch/luna88k/stand/boot/getline.c +++ b/sys/arch/luna88k/stand/boot/getline.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getline.c,v 1.1 2013/10/28 22:13:12 miod Exp $ */ +/* $OpenBSD: getline.c,v 1.2 2013/10/29 21:49:07 miod Exp $ */ /* $NetBSD: getline.c,v 1.2 2013/01/20 07:32:45 tsutsui Exp $ */ /* @@ -80,7 +80,7 @@ #include <luna88k/stand/boot/samachdep.h> int -getline(char *prompt, char *buff) +getline(const char *prompt, char *buff) { int c; char *p = buff; diff --git a/sys/arch/luna88k/stand/boot/getsecs.c b/sys/arch/luna88k/stand/boot/getsecs.c index f5adf90bc47..b87ab406c28 100644 --- a/sys/arch/luna88k/stand/boot/getsecs.c +++ b/sys/arch/luna88k/stand/boot/getsecs.c @@ -1,4 +1,4 @@ -/* $OpenBSD: getsecs.c,v 1.1 2013/10/28 22:13:12 miod Exp $ */ +/* $OpenBSD: getsecs.c,v 1.2 2013/10/29 21:49:07 miod Exp $ */ /* $NetBSD: getsecs.c,v 1.1 2013/01/13 14:10:55 tsutsui Exp $ */ /*- @@ -46,14 +46,14 @@ getsecs(void) if (machtype == LUNA_88K) { volatile uint32_t *mclock = - (volatile uint32_t *)(0x45000000 + MK_NVRAM_SPACE); + (volatile uint32_t *)(NVRAM_ADDR + MK_NVRAM_SPACE); mclock[MK_CSR] |= MK_CSR_READ << 24; t = bcdtobin(mclock[MK_SEC] >> 24); t += bcdtobin(mclock[MK_MIN] >> 24) * 60; t += bcdtobin(mclock[MK_HOUR] >> 24) * 60 * 60; mclock[MK_CSR] &= ~(MK_CSR_READ << 24); } else { - volatile uint8_t *chiptime = (volatile uint8_t *)0x45000000; + volatile uint8_t *chiptime = (volatile uint8_t *)NVRAM_ADDR; volatile u_int8_t *chipdata = chiptime + 1; uint8_t c; diff --git a/sys/arch/luna88k/stand/boot/if_le.c b/sys/arch/luna88k/stand/boot/if_le.c index 704f7386324..33f0268840a 100644 --- a/sys/arch/luna88k/stand/boot/if_le.c +++ b/sys/arch/luna88k/stand/boot/if_le.c @@ -1,4 +1,4 @@ -/* $OpenBSD: if_le.c,v 1.2 2013/10/29 18:51:37 miod Exp $ */ +/* $OpenBSD: if_le.c,v 1.3 2013/10/29 21:49:07 miod Exp $ */ /* $NetBSD: if_le.c,v 1.3 2013/01/22 15:48:40 tsutsui Exp $ */ /* @@ -69,8 +69,6 @@ #include <lib/libsa/net.h> #include <lib/libsa/netif.h> -#include <luna88k/stand/boot/device.h> - /* libsa netif_driver glue functions */ static int le_match(struct netif *, void *); static int le_probe(struct netif *, void *); @@ -81,12 +79,6 @@ static void le_end(struct netif *); static void myetheraddr(uint8_t *); -/* luna88k driver glue stuff */ -struct driver ledriver = { - leinit, - "le" -}; - /* libsa netif glue stuff */ struct netif_stats le_stats; struct netif_dif le_ifs[] = { @@ -105,32 +97,26 @@ struct netif_driver le_netif_driver = { sizeof(le_ifs) / sizeof(le_ifs[0]), }; -#ifdef DEBUG -int debug; -#endif - int -leinit(void *arg) +leinit(void) { - struct hp_device *hd = arg; void *cookie; void *reg, *mem; uint8_t eaddr[6]; - reg = hd->hpd_addr; - mem = (void *)0x71010000; /* XXX */ + reg = (void *)LANCE_ADDR; + mem = (void *)(TRI_PORT_RAM + 0x010000); /* XXX */ + + if (badaddr(reg, 4) != 0) + return 0; myetheraddr(eaddr); - cookie = lance_attach(hd->hpd_unit, reg, mem, eaddr); + cookie = lance_attach(0, reg, mem, eaddr); if (cookie == NULL) return 0; - printf("%s%d: Am7990 LANCE Ethernet, mem at 0x%x\n", - hd->hpd_driver->d_name, hd->hpd_unit, (uint32_t)mem); - printf("%s%d: Ethernet address = %s\n", - hd->hpd_driver->d_name, hd->hpd_unit, - ether_sprintf(eaddr)); + printf("le0: Ethernet address %s\n", ether_sprintf(eaddr)); return 1; } @@ -144,6 +130,8 @@ le_match(struct netif *nif, void *machdep_hint) /* XXX should check nif_unit and unit number in machdep_hint path */ cookie = lance_cookie(nif->nif_unit); + if (cookie == NULL && nif->nif_unit == 0 && leinit() != 0) + cookie = lance_cookie(nif->nif_unit); if (cookie == NULL) return 0; @@ -259,7 +247,7 @@ myetheraddr(uint8_t *ether) } break; case LUNA_88K2: - ds1220 = (void *)0xF1000008; + ds1220 = (void *)(LANCE_ADDR + 8); loc = 12; for (i = 0; i < 6; i++) { unsigned int u, l, hex; diff --git a/sys/arch/luna88k/stand/boot/init_main.c b/sys/arch/luna88k/stand/boot/init_main.c index e5004f84396..d7741edded0 100644 --- a/sys/arch/luna88k/stand/boot/init_main.c +++ b/sys/arch/luna88k/stand/boot/init_main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: init_main.c,v 1.2 2013/10/29 18:51:37 miod Exp $ */ +/* $OpenBSD: init_main.c,v 1.3 2013/10/29 21:49:07 miod Exp $ */ /* $NetBSD: init_main.c,v 1.6 2013/03/05 15:34:53 tsutsui Exp $ */ /* @@ -101,7 +101,7 @@ char *argv[MAXARGS]; #define BOOT_TIMEOUT 5 int boot_timeout = BOOT_TIMEOUT; -char prompt[16] = "boot> "; +static const char prompt[] = "boot> "; int debug; @@ -119,7 +119,7 @@ char fuse_rom_data[FUSE_ROM_BYTES]; int main(void) { - int i, status = 0; + int status = ST_NORMAL; const char *machstr; int unit, part; @@ -134,10 +134,10 @@ main(void) * Initialize the console before we print anything out. */ if (machtype == LUNA_88K) { - machstr = "LUNA-88K"; + machstr = "luna88k"; cpuspeed = MHZ_25; } else { - machstr = "LUNA88K-2"; + machstr = "luna88k-2"; cpuspeed = MHZ_33; } @@ -145,14 +145,7 @@ main(void) cninit(); - printf("\nOpenBSD/luna88k boot 0.1\n"); - - i = *((int *)0x1104); - printf("Machine model = %s\n", machstr); - printf("Physical Memory = 0x%x ", i); - i >>= 20; - printf("(%d MB)\n", i); - printf("\n"); + printf("\nOpenBSD/%s boot 0.2\n\n", machstr); /* * IO configuration @@ -162,10 +155,6 @@ main(void) try_bootp = 1; #endif - find_devs(); - configure(); - printf("\n"); - unit = 0; /* XXX should parse monitor's Boot-file constant */ part = 0; snprintf(default_file, sizeof(default_file), @@ -198,11 +187,11 @@ main(void) status = parse(argc, argv); if (status == ST_NOTFOUND) - printf("Command \"%s\" is not found !!\n", argv[0]); + printf("unknown command \"%s\"\n", argv[0]); } - } while(status != ST_EXIT); + } while (status != ST_EXIT); - exit(); + _rtt(); /* NOTREACHED */ } @@ -238,7 +227,7 @@ get_fuse_rom_data(void) void _rtt(void) { - *(volatile unsigned int *)0x6d000010 = 0; + *(volatile unsigned int *)RESET_CPU_ALL = 0; for (;;) ; /* NOTREACHED */ } diff --git a/sys/arch/luna88k/stand/boot/ioconf.c b/sys/arch/luna88k/stand/boot/ioconf.c deleted file mode 100644 index 9d2c785f010..00000000000 --- a/sys/arch/luna88k/stand/boot/ioconf.c +++ /dev/null @@ -1,101 +0,0 @@ -/* $OpenBSD: ioconf.c,v 1.2 2013/10/29 18:51:37 miod Exp $ */ -/* $NetBSD: ioconf.c,v 1.3 2013/01/14 01:37:57 tsutsui Exp $ */ - -/* - * Copyright (c) 1992 OMRON Corporation. - * - * This code is derived from software contributed to Berkeley by - * OMRON Corporation. - * - * 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 University of - * California, Berkeley and its contributors. - * 4. 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. - * - * @(#)ioconf.c 8.1 (Berkeley) 6/10/93 - */ -/* - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * OMRON Corporation. - * - * 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. - * - * @(#)ioconf.c 8.1 (Berkeley) 6/10/93 - */ - -#include <sys/param.h> -#include <luna88k/stand/boot/samachdep.h> -#include <luna88k/stand/boot/device.h> - -extern struct driver scdriver; -extern struct driver sddriver; -extern struct driver ledriver; -extern struct driver stdriver; - -struct hp_ctlr hp_cinit[] = { -/* driver, unit, alive, addr, flags */ - { &scdriver, 0, 0, NULL, 0x0 }, - { &scdriver, 1, 0, NULL, 0x0 }, - {0}, -}; - -struct hp_device hp_dinit[] = { -/*driver, cdriver, unit, ctlr, slave */ -{ &sddriver, &scdriver, 0, 0, 6 }, -{ &sddriver, &scdriver, 1, 0, 5 }, -{ &sddriver, &scdriver, 2, 1, 6 }, -{ &sddriver, &scdriver, 3, 1, 5 }, -{ &ledriver, NULL, 0, 0, 0 }, -#ifdef notyet -{ &stdriver, &scdriver, 0, 0, 4 }, -#endif -{0} -}; diff --git a/sys/arch/luna88k/stand/boot/lance.c b/sys/arch/luna88k/stand/boot/lance.c index b939ab82a99..381dee155c0 100644 --- a/sys/arch/luna88k/stand/boot/lance.c +++ b/sys/arch/luna88k/stand/boot/lance.c @@ -1,4 +1,4 @@ -/* $OpenBSD: lance.c,v 1.1 2013/10/28 22:13:12 miod Exp $ */ +/* $OpenBSD: lance.c,v 1.2 2013/10/29 21:49:07 miod Exp $ */ /* $NetBSD: lance.c,v 1.1 2013/01/13 14:10:55 tsutsui Exp $ */ /* @@ -73,7 +73,7 @@ static int lance_do_initialize(struct le_softc *); static struct le_softc lesc[NLE]; void * -lance_attach(int unit, void *reg, void *mem, uint8_t *eaddr) +lance_attach(uint unit, void *reg, void *mem, uint8_t *eaddr) { struct le_softc *sc; @@ -95,7 +95,7 @@ lance_attach(int unit, void *reg, void *mem, uint8_t *eaddr) } void * -lance_cookie(int unit) +lance_cookie(uint unit) { struct le_softc *sc; diff --git a/sys/arch/luna88k/stand/boot/locore.S b/sys/arch/luna88k/stand/boot/locore.S index 708886d6a7b..cb3ae611e98 100644 --- a/sys/arch/luna88k/stand/boot/locore.S +++ b/sys/arch/luna88k/stand/boot/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.1 2013/10/28 22:13:12 miod Exp $ */ +/* $OpenBSD: locore.S,v 1.2 2013/10/29 21:49:07 miod Exp $ */ /* * Copyright (c) 2013 Miodrag Vallat. @@ -46,6 +46,7 @@ #define _LOCORE #include <machine/asm.h> +#include <machine/board.h> #include <machine/psl.h> .text @@ -93,10 +94,10 @@ ASLOCAL(main_start) or %r31, %r31, %lo16(_ASM_LABEL(__start)) /* read dip switch settings */ - or.u %r11, %r0, %hi16(0x49000000) - ld.bu %r10, %r11, %lo16(0x49000000) + or.u %r11, %r0, %hi16(OBIO_PIO0A) + ld.bu %r10, %r11, %lo16(OBIO_PIO0A) mak %r10, %r10, 0<8> - ld.bu %r12, %r11, %lo16(0x49000004) + ld.bu %r12, %r11, %lo16(OBIO_PIO0B) or %r10, %r10, %r12 or.u %r11, %r0, %hi16(_C_LABEL(dipswitch)) diff --git a/sys/arch/luna88k/stand/boot/samachdep.h b/sys/arch/luna88k/stand/boot/samachdep.h index d9a4e98d272..31e75490429 100644 --- a/sys/arch/luna88k/stand/boot/samachdep.h +++ b/sys/arch/luna88k/stand/boot/samachdep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: samachdep.h,v 1.2 2013/10/29 18:51:37 miod Exp $ */ +/* $OpenBSD: samachdep.h,v 1.3 2013/10/29 21:49:07 miod Exp $ */ /* $NetBSD: samachdep.h,v 1.10 2013/03/05 15:34:53 tsutsui Exp $ */ /* @@ -35,14 +35,9 @@ #include <sys/param.h> #include <lib/libsa/stand.h> -#define NSCSI 2 -#define NSD 8 - #define MHZ_25 25 #define MHZ_33 33 -#define MAXDEVNAME 16 - struct consdev; typedef struct label_t { long val[19]; @@ -85,10 +80,6 @@ void cninit(void); int cngetc(void); void cnputc(int); -/* devopen.c */ -extern u_int opendev; -int atoi(char *); - /* fault.c */ int badaddr(void *, int); @@ -96,10 +87,7 @@ int badaddr(void *, int); extern const u_short bmdfont[][20]; /* getline.c */ -int getline(char *, char *); - -/* if_le.c */ -int leinit(void *); +int getline(const char *, char *); /* init_main.c */ extern int cpuspeed; @@ -112,8 +100,8 @@ extern char fuse_rom_data[]; int kbd_decode(u_char); /* lance.c */ -void *lance_attach(int, void *, void *, uint8_t *); -void *lance_cookie(int); +void *lance_attach(uint, void *, void *, uint8_t *); +void *lance_cookie(uint); uint8_t *lance_eaddr(void *); int lance_init(void *); int lance_get(void *, void *, size_t); @@ -136,11 +124,13 @@ int parse(int, char **); int getargs(char *, char **, int); /* sc.c */ -struct scsi_fmt_cdb; -int scsi_immed_command(int, int, int, struct scsi_fmt_cdb *, u_char *, - unsigned int); -int scsi_request_sense(int, int, int, u_char *, unsigned int); -int scsi_test_unit_rdy(int, int, int); +struct scsi_softc; +int scinit(struct scsi_softc *, uint); +struct scsi_generic_cdb; +int scsi_immed_command(struct scsi_softc *, int, int, struct scsi_generic_cdb *, + u_char *, unsigned int); +int scsi_request_sense(struct scsi_softc *, int, int, u_char *, unsigned int); +int scsi_test_unit_rdy(struct scsi_softc *, int, int); /* sd.c */ int sdstrategy(void *, int, daddr32_t, size_t, void *, size_t *); @@ -156,7 +146,7 @@ void siocnputc(dev_t, int); void sioinit(void); /* ufs_disklabel.c */ -char *readdisklabel(int, int, struct disklabel *); +char *readdisklabel(struct scsi_softc *, uint, struct disklabel *); #define DELAY(n) delay(n) diff --git a/sys/arch/luna88k/stand/boot/sc.c b/sys/arch/luna88k/stand/boot/sc.c index b99ad8cd1e5..98765a6045f 100644 --- a/sys/arch/luna88k/stand/boot/sc.c +++ b/sys/arch/luna88k/stand/boot/sc.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sc.c,v 1.2 2013/10/29 18:51:37 miod Exp $ */ +/* $OpenBSD: sc.c,v 1.3 2013/10/29 21:49:07 miod Exp $ */ /* $NetBSD: sc.c,v 1.4 2013/01/22 15:48:40 tsutsui Exp $ */ /* @@ -76,53 +76,51 @@ * remaked by A.Fujita, MAR-11-199 */ - -#define NSC 2 - #include <sys/param.h> +#include <machine/board.h> #include <luna88k/stand/boot/samachdep.h> #include <luna88k/stand/boot/scsireg.h> -#include <luna88k/stand/boot/device.h> #include <luna88k/stand/boot/scsivar.h> #define SCSI_ID 7 -int scinit(void *); -int scintr(void); -void screset(int); +int scintr(struct scsi_softc *); +void screset(struct scsi_softc *); int issue_select(struct scsidevice *, u_char); void ixfer_start(struct scsidevice *, int, u_char, int); void ixfer_out(struct scsidevice *, int, u_char *); void ixfer_in(struct scsidevice *, int, u_char *); -int scrun(int, int, u_char *, int, u_char *, int, volatile int *); -int scfinish(int); +int scrun(struct scsi_softc *, uint, u_char *, int, u_char *, int, + volatile int *); +int scfinish(struct scsi_softc *); void scabort(struct scsi_softc *, struct scsidevice *); -struct driver scdriver = { - scinit, "sc" -}; - -struct scsi_softc scsi_softc[NSC]; - /* * Initialize SPC & Data Structure */ int -scinit(void *arg) +scinit(struct scsi_softc *hs, uint unit) { - struct hp_ctlr *hc = arg; - struct scsi_softc *hs; - int unit; - - unit = hc->hp_unit; - if (unit < 0 || unit >= NSC) + void *reg; + + switch (unit) { + case 0: + reg = (void *)SCSI_ADDR; + break; + case 1: + reg = (void *)(SCSI_ADDR + 0x40); + break; + default: return 0; + } - hs = &scsi_softc[unit]; + if (unit != 0 && machtype != LUNA_88K2) + return 0; - hs->sc_hc = hc; + hs->sc_sd = (struct scsidevice *)reg; + hs->sc_unit = unit; hs->sc_flags = 0; hs->sc_phase = BUS_FREE_PHASE; hs->sc_target = SCSI_ID; @@ -136,17 +134,18 @@ scinit(void *arg) hs->sc_stat = 0; hs->sc_msg[0] = 0; - screset(hc->hp_unit); + screset(hs); return(1); } void -screset(int unit) +screset(struct scsi_softc *hs) { - struct scsi_softc *hs = &scsi_softc[unit]; - struct scsidevice *hd = (struct scsidevice *)hs->sc_hc->hp_addr; + struct scsidevice *hd = hs->sc_sd; - printf("sc%d: ", unit); +#ifdef DEBUG + printf("sc%d: ", hs->sc_unit); +#endif /* * Disable interrupts then reset the FUJI chip. @@ -161,8 +160,10 @@ screset(int unit) hd->scsi_tcl = 0; hd->scsi_ints = 0; +#ifdef DEBUG /* We can use Asynchronous Transfer only */ printf("async"); +#endif /* * Configure MB89352 with its SCSI address, all @@ -172,12 +173,16 @@ screset(int unit) hd->scsi_sctl = SCTL_DISABLE | SCTL_ABRT_ENAB| SCTL_PARITY_ENAB | SCTL_RESEL_ENAB | SCTL_INTR_ENAB; +#ifdef DEBUG printf(", parity"); +#endif DELAY(400); hd->scsi_sctl &= ~SCTL_DISABLE; +#ifdef DEBUG printf(", scsi id %d\n", SCSI_ID); +#endif } @@ -251,24 +256,22 @@ ixfer_in(struct scsidevice *hd, int len, u_char *buf) */ int -scrun(int ctlr, int slave, u_char *cdb, int cdblen, u_char *buf, int len, - volatile int *lock) +scrun(struct scsi_softc *hs, uint target, u_char *cdb, int cdblen, u_char *buf, + int len, volatile int *lock) { - struct scsi_softc *hs; struct scsidevice *hd; - if (ctlr < 0 || ctlr >= NSC) - return 0; - - hs = &scsi_softc[ctlr]; - hd = (struct scsidevice *)hs->sc_hc->hp_addr; + hd = hs->sc_sd; if (hd->scsi_ssts & (SSTS_INITIATOR|SSTS_TARGET|SSTS_BUSY)) return(0); + if (target > 7) + return 0; + hs->sc_flags = 0; hs->sc_phase = ARB_SEL_PHASE; - hs->sc_target = slave; + hs->sc_target = target >= 7 ? target : 6 - target; hs->sc_cdb = cdb; hs->sc_cdblen = cdblen; @@ -286,9 +289,8 @@ scrun(int ctlr, int slave, u_char *cdb, int cdblen, u_char *buf, int len, } int -scfinish(int ctlr) +scfinish(struct scsi_softc *hs) { - struct scsi_softc *hs = &scsi_softc[ctlr]; int status = hs->sc_stat; hs->sc_flags = 0; @@ -314,8 +316,7 @@ scabort(struct scsi_softc *hs, struct scsidevice *hd) u_char junk; printf("sc%d: abort phase=0x%x, ssts=0x%x, ints=0x%x\n", - hs->sc_hc->hp_unit, hd->scsi_psns, hd->scsi_ssts, - hd->scsi_ints); + hs->sc_unit, hd->scsi_psns, hd->scsi_ssts, hd->scsi_ints); if (hd->scsi_ints != 0) hd->scsi_ints = hd->scsi_ints; @@ -365,7 +366,7 @@ out: */ if (len < 0 && hs) printf("sc%d: abort failed. phase=0x%x, ssts=0x%x\n", - hs->sc_hc->hp_unit, hd->scsi_psns, hd->scsi_ssts); + hs->sc_unit, hd->scsi_psns, hd->scsi_ssts); } @@ -374,19 +375,20 @@ out: */ int -scsi_test_unit_rdy(int ctlr, int slave, int unit) +scsi_test_unit_rdy(struct scsi_softc *sc, int target, int unit) { static struct scsi_cdb6 cdb = { CMD_TEST_UNIT_READY }; int status; volatile int lock; #ifdef DEBUG - printf("scsi_test_unit_rdy( %d, %d, %d): Start\n", ctlr, slave, unit); + printf("scsi_test_unit_rdy(%d,%d,%d): Start\n", + sc->sc_unit, target, unit); #endif cdb.lun = unit; - if (!(scrun(ctlr, slave, (void *)&cdb, 6, NULL, 0, &lock))) { + if (!(scrun(sc, target, (void *)&cdb, 6, NULL, 0, &lock))) { #ifdef DEBUG printf("scsi_test_unit_rdy: Command Transfer Failed.\n"); #endif @@ -394,11 +396,11 @@ scsi_test_unit_rdy(int ctlr, int slave, int unit) } while ((lock == SC_IN_PROGRESS) || (lock == SC_DISCONNECTED)) { - if (scintr()) + if (scintr(sc)) DELAY(10); } - status = scfinish(ctlr); + status = scfinish(sc); if (lock == SC_IO_COMPLETE) { #ifdef DEBUG @@ -411,7 +413,8 @@ scsi_test_unit_rdy(int ctlr, int slave, int unit) } int -scsi_request_sense(int ctlr, int slave, int unit, u_char *buf, unsigned int len) +scsi_request_sense(struct scsi_softc *sc, int target, int unit, u_char *buf, + unsigned int len) { static struct scsi_cdb6 cdb = { CMD_REQUEST_SENSE }; int status; @@ -421,18 +424,10 @@ scsi_request_sense(int ctlr, int slave, int unit, u_char *buf, unsigned int len) printf("scsi_request_sense: Start\n"); #endif - /* Request Sense$N>l9g!"E>Aw$5$l$k%G!<%?D9$O%?!<%2368H$K0MB8$7!" */ - /* %;%s%9%G!<%?$N#8/usr/src/sys/luna68k/stand/SCCS/s.sc.c$%HL\$NAddtional Sens Length$K$h$jF0E*$K7hDj$9$k!#*/ - /* $3$3$G$O%G!<%?!<E>Aw?t$rcdb$NAllocation Length$K:GDcD9$G$"$k#8/usr/src/sys/luna68k/stand/SCCS/s.sc.c$%H */ - /* $r8GDj$7$F!"#S#P#C$N=hM}%7!<%1%s%9$rJx$5$J$$$h$&$K$7$F$$$k!# */ - - /* %F!<@(#)sc.c 8.1f%K373H$N>uBV$rD4$Y$k$?$a!"Addtional Sens Field$r%"%/%;%9$9$k */ - /* I,MW$,$"$k$N$G6/10/93P%$%98.1i%$%PB&$Glen$r7hDj$9$k$3$H$K$9$k */ - cdb.lun = unit; cdb.len = len; - if (!(scrun(ctlr, slave, (void *)&cdb, 6, buf, len, &lock))) { + if (!(scrun(sc, target, (void *)&cdb, 6, buf, len, &lock))) { #ifdef DEBUG printf("scsi_request_sense: Command Transfer Failed.\n"); #endif @@ -440,11 +435,11 @@ scsi_request_sense(int ctlr, int slave, int unit, u_char *buf, unsigned int len) } while ((lock == SC_IN_PROGRESS) || (lock == SC_DISCONNECTED)) { - if (scintr()) + if (scintr(sc)) DELAY(10); } - status = scfinish(ctlr); + status = scfinish(sc); if (lock == SC_IO_COMPLETE) { #ifdef DEBUG @@ -457,20 +452,21 @@ scsi_request_sense(int ctlr, int slave, int unit, u_char *buf, unsigned int len) } int -scsi_immed_command(int ctlr, int slave, int unit, struct scsi_fmt_cdb *cdb, - u_char *buf, unsigned int len) +scsi_immed_command(struct scsi_softc *sc, int target, int unit, + struct scsi_generic_cdb *cdb, u_char *buf, unsigned int len) { int status; volatile int lock; #ifdef DEBUG printf("scsi_immed_command( %d, %d, %d, cdb(%d), buf, %d): Start\n", - ctlr, slave, unit, cdb->len, len); + sc->sc_unit, target, unit, cdb->len, len); #endif cdb->cdb[1] |= unit << 5; - if (!(scrun(ctlr, slave, (void *)&cdb->cdb[0], cdb->len, buf, len, &lock))) { + if (!(scrun(sc, target, (void *)&cdb->cdb[0], cdb->len, buf, len, + &lock))) { #ifdef DEBUG printf("scsi_immed_command: Command Transfer Failed.\n"); #endif @@ -478,11 +474,11 @@ scsi_immed_command(int ctlr, int slave, int unit, struct scsi_fmt_cdb *cdb, } while ((lock == SC_IN_PROGRESS) || (lock == SC_DISCONNECTED)) { - if (scintr()) + if (scintr(sc)) DELAY(10); } - status = scfinish(ctlr); + status = scfinish(sc); if (lock == SC_IO_COMPLETE) { #ifdef DEBUG @@ -499,33 +495,17 @@ scsi_immed_command(int ctlr, int slave, int unit, struct scsi_fmt_cdb *cdb, */ int -scintr(void) +scintr(struct scsi_softc *hs) { - struct scsi_softc *hs; struct scsidevice *hd; u_char ints, temp; - int i; u_char *buf; - int len; + int i, len; - for (i = 0; i < NSC; i++) { - hs = &scsi_softc[i]; - if (hs->sc_hc == NULL) - continue; - hd = (struct scsidevice *) hs->sc_hc->hp_addr; - if ((ints = hd->scsi_ints) != 0) - goto get_intr; - } - - /* Unknown Interrupt occured */ - return -1; - - - /* - * Interrupt - */ + hd = hs->sc_sd; + if ((ints = hd->scsi_ints) == 0) + return -1; - get_intr: #ifdef DEBUG printf("scintr: INTS 0x%x, SSTS 0x%x, PCTL 0x%x, PSNS 0x%x 0x%x\n", ints, hd->scsi_ssts, hd->scsi_pctl, hd->scsi_psns, @@ -542,7 +522,8 @@ scintr(void) } else goto abort; } else if (ints & INTS_DISCON) { - if ((hs->sc_msg[0] == MSG_CMD_COMPLETE) || (hs->sc_msg[0] == MSG_DISCONNECT)) { + if (hs->sc_msg[0] == MSG_CMD_COMPLETE || + hs->sc_msg[0] == MSG_DISCONNECT) { hs->sc_phase = BUS_FREE_PHASE; hs->sc_target = SCSI_ID; if (hs->sc_msg[0] == MSG_CMD_COMPLETE) @@ -606,7 +587,7 @@ scintr(void) hs->sc_phase = hd->scsi_psns & PHASE; - if ((hs->sc_phase == DATA_OUT_PHASE) || (hs->sc_phase == DATA_IN_PHASE)) { + if (hs->sc_phase == DATA_OUT_PHASE || hs->sc_phase == DATA_IN_PHASE) { len = hs->sc_len; buf = hs->sc_buf; } else if (hs->sc_phase == CMD_PHASE) { diff --git a/sys/arch/luna88k/stand/boot/scsireg.h b/sys/arch/luna88k/stand/boot/scsireg.h index 52b9fca8b21..f4a7515dbb8 100644 --- a/sys/arch/luna88k/stand/boot/scsireg.h +++ b/sys/arch/luna88k/stand/boot/scsireg.h @@ -1,4 +1,4 @@ -/* $OpenBSD: scsireg.h,v 1.1 2013/10/28 22:13:13 miod Exp $ */ +/* $OpenBSD: scsireg.h,v 1.2 2013/10/29 21:49:07 miod Exp $ */ /* $NetBSD: scsireg.h,v 1.2 2013/01/22 15:48:40 tsutsui Exp $ */ /* @@ -260,168 +260,7 @@ struct scsi_inquiry { char rev[4]; }; -struct scsi_format_parms { /* physical BFI format */ - u_short reserved; - u_short list_len; - struct defect { - unsigned cyl : 24; - unsigned head : 8; - long bytes_from_index; - } defect[127]; -}; - -struct scsi_reassign_parms { - u_short reserved; - u_short list_len; /* length in bytes of defects only */ - struct new_defect { - unsigned lba; /* logical block address */ - } new_defect[2]; -}; - -struct scsi_modesel_hdr { - u_char rsvd1; - u_char media_type; - u_char rsvd2; - u_char block_desc_len; - u_int density : 8; - u_int number_blocks :24; - u_int rsvd3 : 8; - u_int block_length :24; -}; - -struct scsi_modesense_hdr { - u_char len; - u_char media_type; - u_char wp : 1; - u_char rsvd1 : 7; - u_char block_desc_len; - u_int density : 8; - u_int number_blocks :24; - u_int rsvd2 : 8; - u_int block_length :24; -}; - -/* - * Mode Select / Mode sense "pages" - */ - -/* - * Page One - Error Recovery Parameters - */ -struct scsi_err_recovery { - u_char page_savable : 1; /* save parameters */ - u_char reserved : 1; - u_char page_code : 6; /* = 0x01 */ - u_char page_length; /* = 6 */ - u_char awre : 1; /* auto write realloc enabled */ - u_char arre : 1; /* auto read realloc enabled */ - u_char tb : 1; /* transfer block */ - u_char rc : 1; /* read continuous */ - u_char eec : 1; /* enable early correction */ - u_char per : 1; /* post error */ - u_char dte : 1; /* disable transfer on error */ - u_char dcr : 1; /* disable correction */ - u_char retry_count; - u_char correction_span; - u_char head_offset_count; - u_char strobe_offset_count; - u_char recovery_time_limit; -}; - -/* - * Page Two - Disconnect / Reconnect Control Parameters - */ -struct scsi_disco_reco { - u_char page_savable : 1; /* save parameters */ - u_char rsvd : 1; - u_char page_code : 6; /* = 0x02 */ - u_char page_length; /* = 10 */ - u_char buffer_full_ratio; /* write, how full before reconnect? */ - u_char buffer_empty_ratio; /* read, how full before reconnect? */ - - u_short bus_inactivity_limit; /* how much bus time for busy */ - u_short disconnect_time_limit; /* min to remain disconnected */ - u_short connect_time_limit; /* min to remain connected */ - u_short reserved_1; -}; - -/* - * Page Three - Direct Access Device Format Parameters - */ -struct scsi_format { - u_char page_savable : 1; /* save parameters */ - u_char rsvd : 1; - u_char page_code : 6; /* = 0x03 */ - u_char page_length; /* = 22 */ - u_short tracks_per_zone; /* Handling of Defects Fields */ - u_short alt_sect_zone; - u_short alt_tracks_zone; - u_short alt_tracks_vol; - u_short sect_track; /* Track Format Field */ - u_short data_sect; /* Sector Format Fields */ - u_short interleave; - u_short track_skew_factor; - u_short cyl_skew_factor; - u_char ssec : 1; /* Drive Type Field */ - u_char hsec : 1; - u_char rmb : 1; - u_char surf : 1; - u_char ins : 1; - u_char reserved_1 : 3; - u_char reserved_2; - u_char reserved_3; - u_char reserved_4; -}; - -/* - * Page Four - Rigid Disk Drive Geometry Parameters - */ -struct scsi_geometry { - u_char page_savable : 1; /* save parameters */ - u_char rsvd : 1; - u_char page_code : 6; /* = 0x04 */ - u_char page_length; /* = 18 */ - u_char cyl_ub; /* number of cylinders */ - u_char cyl_mb; - u_char cyl_lb; - u_char heads; /* number of heads */ - u_char precomp_cyl_ub; /* cylinder to start precomp */ - u_char precomp_cyl_mb; - u_char precomp_cyl_lb; - u_char current_cyl_ub; /* cyl to start reduced current */ - u_char current_cyl_mb; - u_char current_cyl_lb; - u_short step_rate; /* drive step rate */ - u_char landing_cyl_ub; /* landing zone cylinder */ - u_char landing_cyl_mb; - u_char landing_cyl_lb; - u_char reserved_1; - u_char reserved_2; - u_char reserved_3; -}; - -/* - * Page 0x38 - Cache Control Parameters - */ -struct scsi_cache { - u_char page_savable : 1; /* save parameters */ - u_char rsvd : 1; - u_char page_code : 6; /* = 0x38 */ - u_char page_length; /* = 14 */ - u_char rsvd_1 : 1; - u_char wie : 1; /* write index enable */ - u_char rsvd_2 : 1; - u_char ce : 1; /* cache enable */ - u_char table_size : 4; - u_char prefetch_threshold; - u_char maximum_threshold; - u_char maximumprefetch_multiplier; - u_char minimum_threshold; - u_char minimum_prefetch_multiplier; - u_char reserved[8]; -}; - -struct scsi_fmt_cdb { +struct scsi_generic_cdb { int len; /* cdb length (in bytes) */ u_char cdb[28]; /* cdb to use on next read/write */ }; diff --git a/sys/arch/luna88k/stand/boot/scsivar.h b/sys/arch/luna88k/stand/boot/scsivar.h index 405352e1bc6..ee084624122 100644 --- a/sys/arch/luna88k/stand/boot/scsivar.h +++ b/sys/arch/luna88k/stand/boot/scsivar.h @@ -1,4 +1,4 @@ -/* $OpenBSD: scsivar.h,v 1.1 2013/10/28 22:13:13 miod Exp $ */ +/* $OpenBSD: scsivar.h,v 1.2 2013/10/29 21:49:07 miod Exp $ */ /* $NetBSD: scsivar.h,v 1.1 2013/01/05 17:44:24 tsutsui Exp $ */ /* @@ -71,8 +71,11 @@ * @(#)scsivar.h 8.1 (Berkeley) 6/10/93 */ +struct scsidevice; + struct scsi_softc { - struct hp_ctlr *sc_hc; + struct scsidevice *sc_sd; + int sc_unit; u_char *sc_buf; /* Data Buffer Pointor*/ u_char *sc_cdb; /* CDB Buffer Pointor */ volatile int *sc_lock; /* Lock Flag addres */ diff --git a/sys/arch/luna88k/stand/boot/sd.c b/sys/arch/luna88k/stand/boot/sd.c index e87ed96d829..1656638ae66 100644 --- a/sys/arch/luna88k/stand/boot/sd.c +++ b/sys/arch/luna88k/stand/boot/sd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sd.c,v 1.2 2013/10/29 18:51:37 miod Exp $ */ +/* $OpenBSD: sd.c,v 1.3 2013/10/29 21:49:07 miod Exp $ */ /* $NetBSD: sd.c,v 1.5 2013/01/22 15:48:40 tsutsui Exp $ */ /* @@ -84,87 +84,77 @@ #include <sys/disklabel.h> #include <luna88k/stand/boot/samachdep.h> #include <luna88k/stand/boot/scsireg.h> -#include <luna88k/stand/boot/device.h> - -struct disklabel sdlabel[NSD]; +#include <luna88k/stand/boot/scsivar.h> struct sd_softc { - struct hp_device *sc_hd; - short sc_flags; + uint sc_ctlr; + uint sc_tgt; + uint sc_part; + short sc_type; /* drive type */ short sc_punit; /* physical unit (scsi lun) */ u_short sc_bshift; /* convert device blocks to DEV_BSIZE blks */ - u_int sc_blks; /* number of blocks on device */ + daddr32_t sc_blks; /* number of blocks on device */ int sc_blksize; /* device block size in bytes */ -}; - -struct sd_devdata { - int unit; /* drive number */ - int part; /* partition */ -}; -int sdinit(void *); -int sdident(struct sd_softc *, struct hp_device *); - -struct driver sddriver = { - sdinit, "sd" + struct disklabel sc_label; + struct scsi_softc sc_sc; }; -struct sd_softc sd_softc[NSD]; -struct sd_devdata sd_devdata[NSD]; - -/* sc_flags values */ -#define SDF_ALIVE 0x1 - -#define sdunit(x) ((minor(x) >> 3) & 0x7) -#define sdpart(x) (minor(x) & 0x7) +struct sd_softc *sdinit(uint, uint); +static int sdident(struct sd_softc *); static struct scsi_inquiry inqbuf; -static struct scsi_fmt_cdb inq = { +static struct scsi_generic_cdb inq = { 6, { CMD_INQUIRY, 0, 0, 0, sizeof(inqbuf), 0 } }; static u_long capbuf[2]; -struct scsi_fmt_cdb cap = { +struct scsi_generic_cdb cap = { 10, { CMD_READ_CAPACITY, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; int -sdident(struct sd_softc *sc, struct hp_device *hd) +sdident(struct sd_softc *sc) { +#ifdef DEBUG char idstr[32]; - int unit; - int ctlr, slave; +#endif + uint ctlr, target, unit; int i; int tries = 10; - ctlr = hd->hpd_ctlr; - slave = hd->hpd_slave; + ctlr = sc->sc_ctlr; + target = sc->sc_tgt; unit = sc->sc_punit; + if (scinit(&sc->sc_sc, ctlr) == 0) + return -1; + /* * See if unit exists and is a disk then read block size & nblocks. */ - while ((i = scsi_test_unit_rdy(ctlr, slave, unit)) != 0) { + while ((i = scsi_test_unit_rdy(&sc->sc_sc, target, unit)) != 0) { if (i < 0 || --tries < 0) return (-1); if (i == STS_CHECKCOND) { u_char sensebuf[8]; struct scsi_xsense *sp = (struct scsi_xsense *)sensebuf; - scsi_request_sense(ctlr, slave, unit, sensebuf, 8); + scsi_request_sense(&sc->sc_sc, target, unit, sensebuf, + sizeof sensebuf); if (sp->class == 7 && sp->key == 6) /* drive doing an RTZ -- give it a while */ DELAY(1000000); } DELAY(1000); } - if (scsi_immed_command(ctlr, slave, unit, &inq, (u_char *)&inqbuf, - sizeof(inqbuf)) || - scsi_immed_command(ctlr, slave, unit, &cap, (u_char *)&capbuf, - sizeof(capbuf))) + if (scsi_immed_command(&sc->sc_sc, target, unit, &inq, + (u_char *)&inqbuf, sizeof(inqbuf)) || + scsi_immed_command(&sc->sc_sc, target, unit, &cap, + (u_char *)&capbuf, sizeof(capbuf))) /* doesn't exist or not a CCS device */ return (-1); @@ -180,6 +170,7 @@ sdident(struct sd_softc *sc, struct hp_device *hd) sc->sc_blks = capbuf[0]; sc->sc_blksize = capbuf[1]; +#ifdef DEBUG memcpy(idstr, &inqbuf.vendor_id, 28); for (i = 27; i > 23; --i) if (idstr[i] != ' ') @@ -193,14 +184,15 @@ sdident(struct sd_softc *sc, struct hp_device *hd) if (idstr[i] != ' ') break; idstr[i+1] = 0; - printf("sd%d: %s %s rev %s", hd->hpd_unit, idstr, &idstr[8], + printf("sd(%d,%d): %s %s rev %s", ctlr, target, idstr, &idstr[8], &idstr[24]); printf(", %d bytes/sect x %d sectors\n", sc->sc_blksize, sc->sc_blks); +#endif if (sc->sc_blksize != DEV_BSIZE) { if (sc->sc_blksize < DEV_BSIZE) { - printf("sd%d: need %d byte blocks - drive ignored\n", - unit, DEV_BSIZE); + printf("sd(%d,%d): need %d byte blocks - drive ignored\n", + ctlr, target, DEV_BSIZE); return (-1); } for (i = sc->sc_blksize; i > DEV_BSIZE; i >>= 1) @@ -210,30 +202,36 @@ sdident(struct sd_softc *sc, struct hp_device *hd) return(inqbuf.type); } -int -sdinit(void *arg) +struct sd_softc * +sdinit(uint unit, uint part) { - struct hp_device *hd = arg; - struct sd_softc *sc = &sd_softc[hd->hpd_unit]; + struct sd_softc *sc; struct disklabel *lp; char *msg; + sc = alloc(sizeof *sc); + if (sc == NULL) + return NULL; + + memset(sc, 0, sizeof *sc); + + sc->sc_ctlr = unit / 10; + sc->sc_tgt = unit % 10; + sc->sc_part = part; #ifdef DEBUG - printf("sdinit: hd->hpd_unit = %d\n", hd->hpd_unit); - printf("sdinit: hd->hpd_ctlr = %d, hd->hpd_slave = %d\n", - hd->hpd_ctlr, hd->hpd_slave); + printf("sdinit: ctlr = %d tgt = %d part = %d\n", + sc->sc_ctlr, sc->sc_tgt, sc->sc_part); #endif - sc->sc_hd = hd; sc->sc_punit = 0; /* XXX no LUN support yet */ - sc->sc_type = sdident(sc, hd); + sc->sc_type = sdident(sc); if (sc->sc_type < 0) - return(0); + return(NULL); /* * Use the default sizes until we've read the label, * or longer if there isn't one there. */ - lp = &sdlabel[hd->hpd_unit]; + lp = &sc->sc_label; if (lp->d_secpercyl == 0) { lp->d_secsize = DEV_BSIZE; @@ -248,19 +246,18 @@ sdinit(void *arg) /* * read disklabel */ - msg = readdisklabel(hd->hpd_ctlr, hd->hpd_slave, lp); + msg = readdisklabel(&sc->sc_sc, sc->sc_tgt, lp); if (msg != NULL) - printf("sd%d: %s\n", hd->hpd_unit, msg); + printf("sd(%d,%d): %s\n", sc->sc_ctlr, sc->sc_tgt, msg); - sc->sc_flags = SDF_ALIVE; - return(1); + return sc; } int sdopen(struct open_file *f, ...) { va_list ap; - struct sd_devdata *sd; + struct sd_softc *sc; int unit, part; va_start(ap, f); @@ -268,37 +265,34 @@ sdopen(struct open_file *f, ...) part = va_arg(ap, int); va_end(ap); - if (unit < 0 || unit >= NSD) - return(-1); - if (part < 0 || part >= 8) + if (part < 0 || part >= MAXPARTITIONS) return(-1); - sd = &sd_devdata[unit]; - sd->unit = unit; - sd->part = part; - f->f_devdata = (void *)sd; + sc = sdinit(unit, part); + if (sc == NULL) + return -1; + f->f_devdata = (void *)sc; return 0; } int sdclose(struct open_file *f) { - struct sd_devdata *sd = f->f_devdata; + struct sd_softc *sc = f->f_devdata; - sd->unit = -1; - sd->part = -1; + free(sc, sizeof *sc); f->f_devdata = NULL; return 0; } -static struct scsi_fmt_cdb cdb_read = { +static struct scsi_generic_cdb cdb_read = { 10, { CMD_READ_EXT, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; -static struct scsi_fmt_cdb cdb_write = { +static struct scsi_generic_cdb cdb_write = { 6, { CMD_WRITE_EXT, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; @@ -307,28 +301,20 @@ int sdstrategy(void *devdata, int func, daddr32_t dblk, size_t size, void *v_buf, size_t *rsize) { - struct sd_devdata *sd = devdata; + struct sd_softc *sc = devdata; struct disklabel *lp; uint8_t *buf = v_buf; - int unit = sd->unit; - int part = sd->part; - struct sd_softc *sc = &sd_softc[unit]; - struct scsi_fmt_cdb *cdb; + int target = sc->sc_tgt; + struct scsi_generic_cdb *cdb; daddr32_t blk; u_int nblk = size >> sc->sc_bshift; - int stat, ctlr, slave; + int stat; #ifdef DEBUG int i; #endif - if (unit < 0 || unit >= NSD) - return(-1); - - ctlr = sc->sc_hd->hpd_ctlr; - slave = sc->sc_hd->hpd_slave; - - lp = &sdlabel[unit]; - blk = dblk + (lp->d_partitions[part].p_offset >> sc->sc_bshift); + lp = &sc->sc_label; + blk = dblk + (lp->d_partitions[sc->sc_part].p_offset >> sc->sc_bshift); if (func == F_READ) cdb = &cdb_read; @@ -344,13 +330,13 @@ sdstrategy(void *devdata, int func, daddr32_t dblk, size_t size, void *v_buf, cdb->cdb[8] = ((nblk >> _DEV_BSHIFT) & 0x00ff); #ifdef DEBUG - printf("sdstrategy: unit = %d\n", unit); - printf("sdstrategy: blk = %lu (0x%lx), nblk = %u (0x%x)\n", (u_long)blk, (long)blk, nblk, nblk); + printf("sdstrategy(%d,%d): blk = %lu (0x%lx), nblk = %u (0x%x)\n", + sc->sc_ctlr, sc->sc_tgt, (u_long)blk, (long)blk, nblk, nblk); for (i = 0; i < 10; i++) - printf("sdstrategy: cdb[%d] = 0x%x\n", i, cdb->cdb[i]); - printf("sdstrategy: ctlr = %d, slave = %d\n", ctlr, slave); + printf("cdb[%d] = 0x%x\n", i, cdb->cdb[i]); #endif - stat = scsi_immed_command(ctlr, slave, sc->sc_punit, cdb, buf, size); + stat = scsi_immed_command(&sc->sc_sc, target, sc->sc_punit, cdb, buf, + size); if (rsize) *rsize = size; diff --git a/sys/arch/luna88k/stand/boot/sio.c b/sys/arch/luna88k/stand/boot/sio.c index 5b0f8a2f52d..0fc7f40fe97 100644 --- a/sys/arch/luna88k/stand/boot/sio.c +++ b/sys/arch/luna88k/stand/boot/sio.c @@ -1,4 +1,4 @@ -/* $OpenBSD: sio.c,v 1.2 2013/10/29 18:51:37 miod Exp $ */ +/* $OpenBSD: sio.c,v 1.3 2013/10/29 21:49:07 miod Exp $ */ /* $NetBSD: sio.c,v 1.3 2013/01/21 11:58:12 tsutsui Exp $ */ /* @@ -76,6 +76,7 @@ #define NSIO 2 #include <sys/param.h> +#include <machine/board.h> #include <luna88k/stand/boot/samachdep.h> #include <luna88k/stand/boot/sioreg.h> #include <luna88k/stand/boot/rcvbuf.h> @@ -135,8 +136,8 @@ siointr(int unit) void siocnprobe(struct consdev *cp) { - sio_addr[0] = (struct siodevice *) 0x51000000; - sio_addr[1] = (struct siodevice *) 0x51000008; + sio_addr[0] = (struct siodevice *)OBIO_SIO; + sio_addr[1] = (struct siodevice *)OBIO_SIO + 1; /* make sure hardware exists */ if (badaddr(sio_addr[0], 4) != 0) { diff --git a/sys/arch/luna88k/stand/boot/ufs_disksubr.c b/sys/arch/luna88k/stand/boot/ufs_disksubr.c index bf7ffa1dc03..9976bb8b7c8 100644 --- a/sys/arch/luna88k/stand/boot/ufs_disksubr.c +++ b/sys/arch/luna88k/stand/boot/ufs_disksubr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ufs_disksubr.c,v 1.1 2013/10/28 22:13:13 miod Exp $ */ +/* $OpenBSD: ufs_disksubr.c,v 1.2 2013/10/29 21:49:07 miod Exp $ */ /* $NetBSD: ufs_disksubr.c,v 1.2 2013/01/14 01:37:57 tsutsui Exp $ */ /* @@ -113,7 +113,7 @@ sun_extended_sum(struct sun_disklabel *sl, void *end) * Returns null on success and an error string on failure. */ char * -readdisklabel(int ctlr, int id, struct disklabel *lp) +readdisklabel(struct scsi_softc *sc, uint tgt, struct disklabel *lp) { u_char *bp = lbl_buff; struct sun_disklabel *slp; @@ -121,7 +121,7 @@ readdisklabel(int ctlr, int id, struct disklabel *lp) struct sun_dkpart *spp; u_short cksum = 0, *sp1, *sp2; int i, secpercyl; - static struct scsi_fmt_cdb cdb = { + static struct scsi_generic_cdb cdb = { 6, { CMD_READ, 0, 0, 0, 1, 0 } }; @@ -133,7 +133,7 @@ readdisklabel(int ctlr, int id, struct disklabel *lp) lp->d_partitions[0].p_size = 0x1fffffff; lp->d_partitions[0].p_offset = 0; - if (scsi_immed_command(ctlr, id, 0, &cdb, bp, DEV_BSIZE) != 0) + if (scsi_immed_command(sc, tgt, 0, &cdb, bp, DEV_BSIZE) != 0) return "I/O error"; slp = (struct sun_disklabel *)bp; |