diff options
Diffstat (limited to 'sys/arch/aviion')
-rw-r--r-- | sys/arch/aviion/aviion/autoconf.c | 195 | ||||
-rw-r--r-- | sys/arch/aviion/aviion/av400_machdep.c | 31 | ||||
-rw-r--r-- | sys/arch/aviion/aviion/av530_machdep.c | 39 | ||||
-rw-r--r-- | sys/arch/aviion/aviion/locore.S | 32 | ||||
-rw-r--r-- | sys/arch/aviion/aviion/machdep.c | 3 | ||||
-rw-r--r-- | sys/arch/aviion/include/autoconf.h | 3 | ||||
-rw-r--r-- | sys/arch/aviion/include/av400.h | 3 | ||||
-rw-r--r-- | sys/arch/aviion/include/board.h | 5 | ||||
-rw-r--r-- | sys/arch/aviion/include/prom.h | 22 |
9 files changed, 214 insertions, 119 deletions
diff --git a/sys/arch/aviion/aviion/autoconf.c b/sys/arch/aviion/aviion/autoconf.c index 373112379eb..fbbebfef585 100644 --- a/sys/arch/aviion/aviion/autoconf.c +++ b/sys/arch/aviion/aviion/autoconf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.c,v 1.15 2013/10/09 21:28:33 miod Exp $ */ +/* $OpenBSD: autoconf.c,v 1.16 2013/10/10 21:24:58 miod Exp $ */ /* * Copyright (c) 1998 Steve Murphree, Jr. * Copyright (c) 1996 Nivas Madhur @@ -44,7 +44,7 @@ #include <machine/autoconf.h> #include <machine/board.h> #include <machine/cpu.h> -#include <machine/vmparam.h> +#include <machine/prom.h> #ifdef AV530 #include <machine/av530.h> @@ -68,25 +68,14 @@ void dumpconf(void); int cold = 1; /* 1 if still booting */ -struct device *bootdv; /* set by device drivers (if found) */ - -uint32_t bootdevtype; - -/* cied */ -#define BT_CIEN 0x6369656e -/* cimd */ -/* cird */ -/* cisc */ -#define BT_DGEN 0x6467656e -#define BT_DGSC 0x64677363 -/* hada */ -#define BT_HKEN 0x686b656e -#define BT_INEN 0x696e656e -#define BT_INSC 0x696e7363 -#define BT_NCSC 0x6e637363 -/* nvrd */ -/* pefn */ -/* vitr */ +static struct device *bootctrl; /* boot controller */ +static struct device *bootdv; /* boot device (if found) */ +u_int bootdev = 0; /* set in locore.S, can't be in .bss */ +u_int bootunit = 0; /* set in locore.S, can't be in .bss */ +u_int bootlun = 0; /* set in locore.S, can't be in .bss */ +u_int bootpart = 0; /* set in locore.S, can't be in .bss */ +static uint32_t bootdevtype; /* boot controller SCM name */ +static paddr_t bootctrlpaddr; /* boot controller address */ /* * called at boot time, configure all devices on the system. @@ -94,8 +83,8 @@ uint32_t bootdevtype; void cpu_configure() { - printf("bootpath: '%s' dev %u unit %u part %u\n", - bootargs, bootdev, bootunit, bootpart); + printf("bootpath: '%s' dev %u unit %u lun %u\n", + bootargs, bootdev, bootunit, bootlun); softintr_init(); @@ -146,11 +135,36 @@ stws(char *p) return (p); } +/* parse a positive base 10 number */ +static u_int strtoi(const char *); +static u_int +strtoi(const char *s) +{ + int c; + u_int val = 0; + + if (s == NULL || *s == '\0') + return 0; + + /* skip whitespace */ + do { + c = *s++; + } while (c == ' ' || c == '\t'); + + for (;;) { + if (c < '0' || c > '9') + break; + val *= 10; + val += c - '0'; + } + + return val; +} + void cmdline_parse(void) { char *p; - /* * If the boot commandline has been manually entered, it @@ -196,13 +210,33 @@ cmdline_parse(void) * However, in the sd() or st() cases, we need to figure out the * SCSI controller name (if not the default one) and address, if * provided. + * + * Note that we will override bootdev at this point. If no boot + * controller number or address was provided, bootdev will be set + * to zero anyway. */ if (memcmp(bootargs, "sd", 2) == 0 || memcmp(bootargs, "st", 2) == 0) { - bcopy(platform->default_boot, &bootdevtype, sizeof(uint32_t)); - /* search for a controller specification */ - } else + /* + * Either + * sd(bootdev,bootunit,bootlun) + * or + * sd(ctrl(bootdev,id),bootunit,bootlun) + * We already know bootdev, bootunit and bootlun. + * All we need here is to figure out the controller type + * and address. + */ + if (bootargs[7] == '(') { + bcopy(bootargs + 3, &bootdevtype, sizeof(uint32_t)); + bootdev = strtoi(bootargs + 8); + } + } else { bcopy(bootargs, &bootdevtype, sizeof(int)); + bootdev = strtoi(bootargs + 5); + } + + /* fill the holes */ + bootctrlpaddr = platform->get_boot_device(&bootdevtype, bootdev); } void @@ -210,85 +244,52 @@ device_register(struct device *dev, void *aux) { struct confargs *ca = (struct confargs *)aux; struct cfdriver *cf = dev->dv_cfdata->cf_driver; + struct device *parent = dev->dv_parent; if (bootdv != NULL) return; -/* SCSI -> match bootunit/bootpart as id:lun iff controller matches */ - switch (bootdevtype) { - /* - * Network devices - */ - - case BT_INEN: - /* - * Internal LANCE Ethernet is le at syscon only, and we do not - * care about controller and unit numbers. - */ - if (strcmp("le", cf->cd_name) == 0 && strcmp("syscon", - dev->dv_parent->dv_cfdata->cf_driver->cd_name) == 0) - bootdv = dev; - break; - case BT_DGEN: - /* - * Internal ILACC Ethernet is le at syscon only, and need to - * match the controller address. - */ - if (strcmp("le", cf->cd_name) == 0 && strcmp("syscon", - dev->dv_parent->dv_cfdata->cf_driver->cd_name) == 0) { - switch (cpuid) { -#ifdef AV530 - case AVIION_4600_530: - if ((bootdev == 0 && - ca->ca_paddr == AV530_LAN1) || - (bootdev == 1 && - ca->ca_paddr == AV530_LAN2)) - bootdv = dev; - break; -#endif - default: - break; - } - } - break; - - /* - * SCSI controllers - */ + if (bootctrl == NULL) { + if (ca->ca_paddr != bootctrlpaddr) + return; + + switch (bootdevtype) { + case SCM_INEN: + case SCM_DGEN: + if (strcmp("le", cf->cd_name) == 0 && + strcmp("syscon", + parent->dv_cfdata->cf_driver->cd_name) == 0) + bootctrl = dev; + break; - case BT_NCSC: - /* - * Internal 53C700 controller is oosiop at syscon only, and - * needs to match the controller address, as well as SCSI - * unit and lun numbers. - */ - { - struct scsi_attach_args *sa = aux; - struct device *grandp; - - if (memcmp(cf->cd_name, bootargs, 2) != 0 || - (strcmp("sd", cf->cd_name) != 0 && - strcmp("st", cf->cd_name) != 0) || - sa->sa_sc_link->target != bootunit || - sa->sa_sc_link->lun != bootpart) + case SCM_INSC: + if (strcmp("oaic", cf->cd_name) == 0 && + strcmp("syscon", + parent->dv_cfdata->cf_driver->cd_name) == 0) + bootctrl = dev; break; - grandp = dev->dv_parent->dv_parent; - if (strcmp("oosiop", - grandp->dv_cfdata->cf_driver->cd_name) == 0) { - bootdv = dev; /* XXX second controller */ + case SCM_NCSC: + if (strcmp("oosiop", cf->cd_name) == 0 && + strcmp("syscon", + parent->dv_cfdata->cf_driver->cd_name) == 0) + bootctrl = dev; + break; } - } - break; - case BT_INSC: - /* - * Internal AIC-6250 controller is oaic at syscon only, and - * needs to match the controller address, as well as SCSI - * unit and lun numbers. - */ - /* XXX TBD */ - break; + if (bootctrl != NULL && bootctrl->dv_class == DV_IFNET) + bootdv = bootctrl; + return; + } + + if (memcmp(cf->cd_name, bootargs, 2) == 0 && + (strcmp("sd", cf->cd_name) == 0 || + strcmp("st", cf->cd_name) == 0)) { + struct scsi_attach_args *saa = aux; + if (saa->sa_sc_link->target == bootunit && + saa->sa_sc_link->lun == bootlun && + parent->dv_parent == bootctrl) + bootdv = dev; } } diff --git a/sys/arch/aviion/aviion/av400_machdep.c b/sys/arch/aviion/aviion/av400_machdep.c index 4faa32433c0..ad06858f2d5 100644 --- a/sys/arch/aviion/aviion/av400_machdep.c +++ b/sys/arch/aviion/aviion/av400_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: av400_machdep.c,v 1.24 2013/10/09 21:28:33 miod Exp $ */ +/* $OpenBSD: av400_machdep.c,v 1.25 2013/10/10 21:24:58 miod Exp $ */ /* * Copyright (c) 2006, 2007, Miodrag Vallat. * @@ -193,6 +193,7 @@ const struct board board_av400 = { av400_bootstrap, av400_memsize, av400_startup, + av400_get_boot_device, av400_intr, cio_init_clocks, av400_getipl, @@ -206,8 +207,7 @@ const struct board board_av400 = { av400_exintsrc, av400_get_vme_ranges, - av400_ptable, - "insc" + av400_ptable }; /* @@ -310,6 +310,31 @@ av400_bootstrap() } /* + * Return the address of the boot device, providing the default boot device + * if none is requested. + */ +paddr_t +av400_get_boot_device(uint32_t *name, u_int unit) +{ + /* default boot device is on-board insc() */ + if (*name == 0) + *name = SCM_INSC; + + switch (*name) { + case SCM_INEN: + if (unit == 0) + return AV400_LAN; + break; + case SCM_INSC: + if (unit == 0) + return AV400_SCSI; + break; + } + + return 0; +} + +/* * Return the next ipl >= ``curlevel'' at which we can reenable interrupts * while keeping ``mask'' masked. */ diff --git a/sys/arch/aviion/aviion/av530_machdep.c b/sys/arch/aviion/aviion/av530_machdep.c index a74636cbb5c..c0603e9b740 100644 --- a/sys/arch/aviion/aviion/av530_machdep.c +++ b/sys/arch/aviion/aviion/av530_machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: av530_machdep.c,v 1.10 2013/10/09 21:28:33 miod Exp $ */ +/* $OpenBSD: av530_machdep.c,v 1.11 2013/10/10 21:24:58 miod Exp $ */ /* * Copyright (c) 2006, 2007, 2010 Miodrag Vallat. * @@ -82,6 +82,7 @@ const struct board board_av530 = { av530_bootstrap, av530_memsize, av530_startup, + av530_get_boot_device, av530_intr, rtc_init_clocks, av530_getipl, @@ -95,8 +96,7 @@ const struct board board_av530 = { av530_exintsrc, av530_get_vme_ranges, - av530_ptable, - "ncsc" + av530_ptable }; /* @@ -197,6 +197,39 @@ av530_bootstrap() } /* + * Return the address of the boot device, providing the default boot device + * if none is requested. + */ +paddr_t +av530_get_boot_device(uint32_t *name, u_int unit) +{ + /* default boot device is on-board ncsc() */ + if (*name == 0) + *name = SCM_NCSC; + + switch (*name) { + case SCM_DGEN: + switch (unit) { + case 0: + return AV530_LAN1; + case 1: + return AV530_LAN2; + } + break; + case SCM_NCSC: + switch (unit) { + case 0: + return AV530_SCSI1; + case 1: + return AV530_SCSI1; + } + break; + } + + return 0; +} + +/* * Return the next ipl >= ``curlevel'' at which we can reenable interrupts * while keeping ``mask'' and ``exmask'' masked. */ diff --git a/sys/arch/aviion/aviion/locore.S b/sys/arch/aviion/aviion/locore.S index 2b924365288..4dffeaf315b 100644 --- a/sys/arch/aviion/aviion/locore.S +++ b/sys/arch/aviion/aviion/locore.S @@ -1,4 +1,4 @@ -/* $OpenBSD: locore.S,v 1.19 2013/10/07 19:10:40 miod Exp $ */ +/* $OpenBSD: locore.S,v 1.20 2013/10/10 21:24:59 miod Exp $ */ /* * Copyright (c) 2005, Miodrag Vallat. * Copyright (c) 1998 Steve Murphree, Jr. @@ -68,7 +68,7 @@ #include <machine/trap.h> #include <machine/vmparam.h> -#define SYM_MAGIC 0x6274ef2e +#define BOOT_MAGIC 0x6274ef2e .text @@ -123,18 +123,34 @@ ASLOCAL(main_start) st %r3, %r13, %lo16(_C_LABEL(bootdev)) or.u %r13, %r0, %hi16(_C_LABEL(bootunit)) st %r4, %r13, %lo16(_C_LABEL(bootunit)) + or.u %r13, %r0, %hi16(_C_LABEL(bootlun)) + st %r5, %r13, %lo16(_C_LABEL(bootlun)) + + or.u %r12, %r0, %hi16(BOOT_MAGIC) + or %r12, %r12, %lo16(BOOT_MAGIC) + cmp %r2, %r6, %r12 + bb1 eq, %r2, 1f + addu %r12, %r12, 1 /* BOOT_MAGIC + 1 */ + cmp %r2, %r6, %r12 + bb1 ne, %r2, 2f + + /* BOOT_MAGIC + 1 */ or.u %r13, %r0, %hi16(_C_LABEL(bootpart)) - st %r5, %r13, %lo16(_C_LABEL(bootpart)) + st %r7, %r13, %lo16(_C_LABEL(bootpart)) #if defined(DDB) || NKSYMS > 0 - or.u %r12, %r0, %hi16(SYM_MAGIC) - or %r12, %r12, %lo16(SYM_MAGIC) - cmp %r2, %r6, %r12 - bb1 ne, %r2, 1f or.u %r13, %r0, %hi16(_C_LABEL(esym)) - st %r7, %r13, %lo16(_C_LABEL(esym)) + st %r8, %r13, %lo16(_C_LABEL(esym)) +#endif + br 2f + + /* BOOT_MAGIC */ 1: +#if defined(DDB) || NKSYMS > 0 + or.u %r13, %r0, %hi16(_C_LABEL(esym)) + st %r7, %r13, %lo16(_C_LABEL(esym)) #endif +2: /* set cputyp */ ldcr %r1, PID extu %r8, %r1, 8<8> diff --git a/sys/arch/aviion/aviion/machdep.c b/sys/arch/aviion/aviion/machdep.c index 6e9febe5673..cef8e4944ba 100644 --- a/sys/arch/aviion/aviion/machdep.c +++ b/sys/arch/aviion/aviion/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.56 2013/10/07 19:11:39 miod Exp $ */ +/* $OpenBSD: machdep.c,v 1.57 2013/10/10 21:24:59 miod Exp $ */ /* * Copyright (c) 2007 Miodrag Vallat. * @@ -151,7 +151,6 @@ extern vaddr_t esym; const char *prom_bootargs; /* set in locore.S */ char bootargs[256]; /* local copy */ -u_int bootdev, bootunit, bootpart; /* set in locore.S */ int32_t cpuid; diff --git a/sys/arch/aviion/include/autoconf.h b/sys/arch/aviion/include/autoconf.h index 8e5f8c86086..87c4fac0de6 100644 --- a/sys/arch/aviion/include/autoconf.h +++ b/sys/arch/aviion/include/autoconf.h @@ -1,4 +1,4 @@ -/* $OpenBSD: autoconf.h,v 1.2 2011/03/23 16:54:34 pirofti Exp $ */ +/* $OpenBSD: autoconf.h,v 1.3 2013/10/10 21:24:59 miod Exp $ */ /* * Copyright (c) 1999, Steve Murphree, Jr. * Copyright (c) 1996 Nivas Madhur @@ -49,7 +49,6 @@ struct confargs { void cmdline_parse(void); void myetheraddr(u_char *); -extern u_int bootdev, bootunit, bootpart; extern char bootargs[256]; #endif diff --git a/sys/arch/aviion/include/av400.h b/sys/arch/aviion/include/av400.h index e95c8a7fe4e..f680189fa6e 100644 --- a/sys/arch/aviion/include/av400.h +++ b/sys/arch/aviion/include/av400.h @@ -1,4 +1,4 @@ -/* $OpenBSD: av400.h,v 1.9 2013/09/24 20:14:35 miod Exp $ */ +/* $OpenBSD: av400.h,v 1.10 2013/10/10 21:24:59 miod Exp $ */ /* * Copyright (c) 1999 Steve Murphree, Jr. * All rights reserved. @@ -130,6 +130,7 @@ * Onboard device addresses */ +#define AV400_SCSI 0xfff8a000 #define AV400_LAN 0xfff8c000 /* diff --git a/sys/arch/aviion/include/board.h b/sys/arch/aviion/include/board.h index b7647a0ae26..6946b1ad329 100644 --- a/sys/arch/aviion/include/board.h +++ b/sys/arch/aviion/include/board.h @@ -1,4 +1,4 @@ -/* $OpenBSD: board.h,v 1.12 2013/10/09 21:28:33 miod Exp $ */ +/* $OpenBSD: board.h,v 1.13 2013/10/10 21:24:59 miod Exp $ */ /* * Copyright (c) 2006, 2007, Miodrag Vallat * @@ -78,6 +78,7 @@ struct board { u_int (*bootstrap)(void); vaddr_t (*memsize)(void); void (*startup)(void); + paddr_t (*get_boot_device)(uint32_t *, u_int); void (*intr)(struct trapframe *); void (*init_clocks)(void); @@ -94,7 +95,6 @@ struct board { const struct vme_range *(*get_vme_ranges)(void); const struct pmap_table *ptable; - const char *default_boot; }; #define md_interrupt_func(f) platform->intr(f) @@ -104,6 +104,7 @@ extern const struct board board_av##b; \ u_int av##b##_bootstrap(void); \ vaddr_t av##b##_memsize(void); \ void av##b##_startup(void); \ +paddr_t av##b##_get_boot_device(uint32_t *, u_int); \ void av##b##_intr(struct trapframe *); \ void av##b##_init_clocks(void); \ u_int av##b##_getipl(void); \ diff --git a/sys/arch/aviion/include/prom.h b/sys/arch/aviion/include/prom.h index d6a0f254933..ce577504523 100644 --- a/sys/arch/aviion/include/prom.h +++ b/sys/arch/aviion/include/prom.h @@ -1,4 +1,4 @@ -/* $OpenBSD: prom.h,v 1.5 2011/03/23 16:54:34 pirofti Exp $ */ +/* $OpenBSD: prom.h,v 1.6 2013/10/10 21:24:59 miod Exp $ */ /* * Copyright (c) 2006, Miodrag Vallat. * @@ -82,4 +82,24 @@ void scm_putcrlf(void); __dead void scm_reboot(const char *); u_int scm_sysid(void); +/* + * SCM boot device names + */ + +/* cied */ +#define SCM_CIEN 0x6369656e +/* cimd */ +/* cird */ +/* cisc */ +#define SCM_DGEN 0x6467656e +#define SCM_DGSC 0x64677363 +/* hada */ +#define SCM_HKEN 0x686b656e +#define SCM_INEN 0x696e656e +#define SCM_INSC 0x696e7363 +#define SCM_NCSC 0x6e637363 +/* nvrd */ +/* pefn */ +/* vitr */ + #endif /* _MACHINE_PROM_H_ */ |