Sat Jan 11 08:07:16 2014 UTC ()
Add support to pass boothowto and bootdev info from bootloader to kernel.

Kernel side changes:
- use %d7 (boothowto) and %d6 (bootdev) to pass info and also use
  old macro in <sys/reboot.h> as ancient 4.4BSD did for simplicity
- add <machine/bootinfo.h> to define values as API to pass these info
- save boothowto and bootdev in registers right after zero'ing bss
- add MD device_register(9) to check booted_device per passed bootdev info
- merge old bootarg checks in rootconf() and luna68k_init() with
  tweaks for backward compatibility
  (direct boot a.out kernel from ROM monitor without bootloader still works)


(tsutsui)
diff -r0 -r1.1 src/sys/arch/luna68k/include/bootinfo.h
diff -r1.14 -r1.15 src/sys/arch/luna68k/luna68k/autoconf.c
diff -r1.53 -r1.54 src/sys/arch/luna68k/luna68k/locore.s
diff -r1.95 -r1.96 src/sys/arch/luna68k/luna68k/machdep.c

File Added: src/sys/arch/luna68k/include/bootinfo.h
/*	$NetBSD: bootinfo.h,v 1.1 2014/01/11 08:07:16 tsutsui Exp $	*/

/*-
 * Copyright (c) 2014 Izumi Tsutsui.  All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */

#ifndef __LUNA68K_BOOTINFO_H_
#define __LUNA68K_BOOTINFO_H_

/*
 * see also MAKEBOOTDEV macro in <sys/reboot.h>
 *
 * ADAPTOR:	SPC or LANCE
 * CONTROLLER:	SPC and LANCE unit number
 * UNIT:	SCSI ID of SPC devices (XXX: no LUN support)
 * PARTITION:	booted partition of the boot disk
 * TYPE:	unused
 */

#define LUNA68K_BOOTADPT_SPC	0
#define LUNA68K_BOOTADPT_LANCE	1

#define LUNA68K_BOOTADPT_SPC0_PA	0xe1000000
#define LUNA68K_BOOTADPT_SPC1_PA	0xe1000040
#define LUNA68K_BOOTADPT_LANCE0_PA	0xf1000000

#ifdef _KERNEL
extern uint32_t bootdev;
#endif

#endif /* __LUNA68K_BOOTINFO_H_ */

cvs diff -r1.14 -r1.15 src/sys/arch/luna68k/luna68k/autoconf.c (expand / switch to unified diff)

--- src/sys/arch/luna68k/luna68k/autoconf.c 2012/10/13 06:16:19 1.14
+++ src/sys/arch/luna68k/luna68k/autoconf.c 2014/01/11 08:07:16 1.15
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: autoconf.c,v 1.14 2012/10/13 06:16:19 tsutsui Exp $ */ 1/* $NetBSD: autoconf.c,v 1.15 2014/01/11 08:07:16 tsutsui Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2000 The NetBSD Foundation, Inc. 4 * Copyright (c) 2000 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Tohru Nishimura. 8 * by Tohru Nishimura.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -21,71 +21,119 @@ @@ -21,71 +21,119 @@
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ 32#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
33 33
34__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.14 2012/10/13 06:16:19 tsutsui Exp $"); 34__KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.15 2014/01/11 08:07:16 tsutsui Exp $");
35 35
36#include <sys/param.h> 36#include <sys/param.h>
37#include <sys/systm.h> 37#include <sys/systm.h>
38#include <sys/buf.h> 38#include <sys/buf.h>
39#include <sys/conf.h> 39#include <sys/conf.h>
40#include <sys/reboot.h> 40#include <sys/reboot.h>
41#include <sys/device.h> 41#include <sys/device.h>
42 42
 43#include <machine/autoconf.h>
 44#include <machine/bootinfo.h>
43#include <machine/disklabel.h> 45#include <machine/disklabel.h>
44#include <machine/cpu.h> 46#include <machine/cpu.h>
45 47
 48#include <dev/scsipi/scsi_all.h>
 49#include <dev/scsipi/scsipi_all.h>
 50#include <dev/scsipi/scsiconf.h>
 51
46#include <luna68k/luna68k/isr.h> 52#include <luna68k/luna68k/isr.h>
47 53
 54static uint booted_adpt, booted_ctlr, booted_unit, booted_part;
 55
48/* 56/*
49 * Determine mass storage and memory configuration for a machine. 57 * Determine mass storage and memory configuration for a machine.
50 */ 58 */
51void 59void
52cpu_configure(void) 60cpu_configure(void)
53{ 61{
 62
54 booted_device = NULL; /* set by device drivers (if found) */ 63 booted_device = NULL; /* set by device drivers (if found) */
55 64
 65 booted_adpt = B_ADAPTOR(bootdev);
 66 booted_ctlr = B_CONTROLLER(bootdev);
 67 booted_unit = B_UNIT(bootdev);
 68 booted_part = B_PARTITION(bootdev);
 69
56 (void)splhigh(); 70 (void)splhigh();
57 isrinit(); 71 isrinit();
58 if (config_rootfound("mainbus", NULL) == NULL) 72 if (config_rootfound("mainbus", NULL) == NULL)
59 panic("autoconfig failed, no root"); 73 panic("autoconfig failed, no root");
60 74
61 spl0(); 75 spl0();
62} 76}
63 77
64void 78void
65cpu_rootconf(void) 79device_register(device_t dev, void *aux)
66{ 80{
67#if 1 /* XXX to be reworked with helps of 2nd stage loaders XXX */ 81 static device_t booted_controller;
68 int i; 82 static bool bootdev_found;
69 const char *devname; 83
70 char *cp; 84 /*
71 extern char bootarg[64]; 85 * Check booted device.
72 86 */
73 cp = bootarg; 87 if (bootdev_found)
74 devname = "sd0"; 88 return;
75 for (i = 0; i < sizeof(bootarg); i++) { 89
76 if (*cp == '\0') 90 if (booted_adpt == LUNA68K_BOOTADPT_LANCE &&
77 break; 91 device_is_a(dev, "le")) {
78 if (*cp == 'E' && memcmp("ENADDR=", cp, 7) == 0) { 92 struct mainbus_attach_args *ma = aux;
79 devname = "le0"; 93
80 break; 94 if (booted_ctlr == 0 &&
 95 ma->ma_addr == LUNA68K_BOOTADPT_LANCE0_PA) {
 96 booted_device = dev;
 97 bootdev_found = true;
 98 }
 99 return;
 100 }
 101
 102 if (booted_adpt == LUNA68K_BOOTADPT_SPC &&
 103 device_is_a(dev, "spc")) {
 104 struct mainbus_attach_args *ma = aux;
 105
 106 if ((booted_ctlr == 0 &&
 107 (u_int)ma->ma_addr == LUNA68K_BOOTADPT_SPC0_PA) ||
 108 (booted_ctlr == 1 &&
 109 (u_int)ma->ma_addr == LUNA68K_BOOTADPT_SPC1_PA)) {
 110 booted_controller = dev;
81 } 111 }
82 cp++; 112 return;
 113 }
 114
 115 if (booted_controller != NULL &&
 116 (device_is_a(dev, "sd") || device_is_a(dev, "cd"))) {
 117 struct scsipibus_attach_args *sa = aux;
 118 device_t parent = device_parent(dev);
 119
 120 if (device_parent(parent) != booted_controller)
 121 return;
 122 if (booted_unit != sa->sa_periph->periph_target)
 123 return;
 124 booted_device = dev;
 125 booted_partition = booted_part;
 126 bootdev_found = true;
 127 return;
83 } 128 }
84 booted_device = device_find_by_xname(devname); 129}
 130
 131void
 132cpu_rootconf(void)
 133{
85 134
86#endif 
87 printf("boot device: %s\n", 135 printf("boot device: %s\n",
88 (booted_device) ? device_xname(booted_device) : "<unknown>"); 136 (booted_device) ? device_xname(booted_device) : "<unknown>");
89 137
90 rootconf(); 138 rootconf();
91} 139}

cvs diff -r1.53 -r1.54 src/sys/arch/luna68k/luna68k/locore.s (expand / switch to unified diff)

--- src/sys/arch/luna68k/luna68k/locore.s 2013/09/23 17:02:18 1.53
+++ src/sys/arch/luna68k/luna68k/locore.s 2014/01/11 08:07:16 1.54
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: locore.s,v 1.53 2013/09/23 17:02:18 tsutsui Exp $ */ 1/* $NetBSD: locore.s,v 1.54 2014/01/11 08:07:16 tsutsui Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1988 University of Utah. 4 * Copyright (c) 1988 University of Utah.
5 * Copyright (c) 1980, 1990, 1993 5 * Copyright (c) 1980, 1990, 1993
6 * The Regents of the University of California. All rights reserved. 6 * The Regents of the University of California. All rights reserved.
7 * 7 *
8 * This code is derived from software contributed to Berkeley by 8 * This code is derived from software contributed to Berkeley by
9 * the Systems Programming Group of the University of Utah Computer 9 * the Systems Programming Group of the University of Utah Computer
10 * Science Department. 10 * Science Department.
11 * 11 *
12 * Redistribution and use in source and binary forms, with or without 12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions 13 * modification, are permitted provided that the following conditions
14 * are met: 14 * are met:
@@ -92,39 +92,37 @@ BSS(esym,4) @@ -92,39 +92,37 @@ BSS(esym,4)
92 */ 92 */
93 .text 93 .text
94GLOBAL(kernel_text) 94GLOBAL(kernel_text)
95 95
96/* 96/*
97 * start of kernel and .text! 97 * start of kernel and .text!
98 */ 98 */
99ASENTRY_NOPROFILE(start) 99ASENTRY_NOPROFILE(start)
100 movw #PSL_HIGHIPL,%sr | no interrupts 100 movw #PSL_HIGHIPL,%sr | no interrupts
101 movl #0,%a5 | RAM starts at 0 101 movl #0,%a5 | RAM starts at 0
102 ASRELOC(tmpstk,%a0) 102 ASRELOC(tmpstk,%a0)
103 movl %a0,%sp | give ourselves a temporary stack 103 movl %a0,%sp | give ourselves a temporary stack
104 104
105#if 0 /* not sure useful values, need a bootloader tailored for us */ 
106 RELOC(boothowto,%a0) 
107 movl %d7,%a0@ | save boothowto 
108 RELOC(bootdev,%a0) 
109 movl %d6,%a0@ | save bootdev 
110#endif 
111 RELOC(edata,%a0) | clear out BSS 105 RELOC(edata,%a0) | clear out BSS
112 movl #_C_LABEL(end)-4,%d0 | (must be <= 256 kB) 106 movl #_C_LABEL(end)-4,%d0 | (must be <= 256 kB)
113 subl #_C_LABEL(edata),%d0 107 subl #_C_LABEL(edata),%d0
114 lsrl #2,%d0 108 lsrl #2,%d0
1151: clrl %a0@+ 1091: clrl %a0@+
116 dbra %d0,1b 110 dbra %d0,1b
117 111
 112 RELOC(boothowto,%a0)
 113 movl %d7,%a0@ | save boothowto
 114 RELOC(bootdev,%a0)
 115 movl %d6,%a0@ | save bootdev
118 RELOC(lowram,%a0) 116 RELOC(lowram,%a0)
119 movl %a5,%a0@ | store start of physical memory 117 movl %a5,%a0@ | store start of physical memory
120 118
121 movl #0x41000000,%a0 | available memory in bytes 119 movl #0x41000000,%a0 | available memory in bytes
122 movl %a0@(12),%a0 | (int *)base[3]) 120 movl %a0@(12),%a0 | (int *)base[3])
123 movl %a0@,%d5 121 movl %a0@,%d5
124 RELOC(memavail,%a0) 122 RELOC(memavail,%a0)
125 movl %d5,%a0@ | save memavail 123 movl %d5,%a0@ | save memavail
126 124
127 movl #0x41000000,%a0 | planemask; 0x0f or 0xff 125 movl #0x41000000,%a0 | planemask; 0x0f or 0xff
128 movl %a0@(184),%a0 | (int *)base[46] 126 movl %a0@(184),%a0 | (int *)base[46]
129 movl %a0@,%d5 127 movl %a0@,%d5
130 RELOC(hwplanemask,%a0) 128 RELOC(hwplanemask,%a0)

cvs diff -r1.95 -r1.96 src/sys/arch/luna68k/luna68k/machdep.c (expand / switch to unified diff)

--- src/sys/arch/luna68k/luna68k/machdep.c 2013/01/26 15:46:24 1.95
+++ src/sys/arch/luna68k/luna68k/machdep.c 2014/01/11 08:07:16 1.96
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: machdep.c,v 1.95 2013/01/26 15:46:24 tsutsui Exp $ */ 1/* $NetBSD: machdep.c,v 1.96 2014/01/11 08:07:16 tsutsui Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 2000 The NetBSD Foundation, Inc. 4 * Copyright (c) 2000 The NetBSD Foundation, Inc.
5 * All rights reserved. 5 * All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to The NetBSD Foundation 7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Tohru Nishimura. 8 * by Tohru Nishimura.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -21,27 +21,27 @@ @@ -21,27 +21,27 @@
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE. 29 * POSSIBILITY OF SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */ 32#include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
33 33
34__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.95 2013/01/26 15:46:24 tsutsui Exp $"); 34__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.96 2014/01/11 08:07:16 tsutsui Exp $");
35 35
36#include "opt_ddb.h" 36#include "opt_ddb.h"
37#include "opt_kgdb.h" 37#include "opt_kgdb.h"
38#include "opt_compat_sunos.h" 38#include "opt_compat_sunos.h"
39#include "opt_modular.h" 39#include "opt_modular.h"
40#include "opt_panicbutton.h" 40#include "opt_panicbutton.h"
41#include "opt_m68k_arch.h" 41#include "opt_m68k_arch.h"
42 42
43#include <sys/param.h> 43#include <sys/param.h>
44#include <sys/systm.h> 44#include <sys/systm.h>
45#include <sys/kernel.h> 45#include <sys/kernel.h>
46#include <sys/proc.h> 46#include <sys/proc.h>
47#include <sys/buf.h> 47#include <sys/buf.h>
@@ -65,26 +65,27 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v  @@ -65,26 +65,27 @@ __KERNEL_RCSID(0, "$NetBSD: machdep.c,v
65#include <sys/ksyms.h> 65#include <sys/ksyms.h>
66#include <sys/module.h> 66#include <sys/module.h>
67#ifdef KGDB 67#ifdef KGDB
68#include <sys/kgdb.h> 68#include <sys/kgdb.h>
69#endif 69#endif
70#include <sys/boot_flag.h> 70#include <sys/boot_flag.h>
71#define ELFSIZE 32 71#define ELFSIZE 32
72#include <sys/exec_elf.h> 72#include <sys/exec_elf.h>
73 73
74#include <uvm/uvm_extern.h> 74#include <uvm/uvm_extern.h>
75 75
76#include <sys/sysctl.h> 76#include <sys/sysctl.h>
77 77
 78#include <machine/bootinfo.h>
78#include <machine/cpu.h> 79#include <machine/cpu.h>
79#include <machine/reg.h> 80#include <machine/reg.h>
80#include <machine/pcb.h> 81#include <machine/pcb.h>
81#include <machine/psl.h> 82#include <machine/psl.h>
82#include <machine/pte.h> 83#include <machine/pte.h>
83#include <machine/kcore.h> /* XXX should be pulled in by sys/kcore.h */ 84#include <machine/kcore.h> /* XXX should be pulled in by sys/kcore.h */
84 85
85#include <dev/cons.h> 86#include <dev/cons.h>
86#include <dev/mm.h> 87#include <dev/mm.h>
87 88
88#if defined(DDB) 89#if defined(DDB)
89#include <machine/db_machdep.h> 90#include <machine/db_machdep.h>
90#include <ddb/db_sym.h> 91#include <ddb/db_sym.h>
@@ -184,48 +185,69 @@ luna68k_init(void) @@ -184,48 +185,69 @@ luna68k_init(void)
184 pmap_kenter_pa((vaddr_t)msgbufaddr + i * PAGE_SIZE, 185 pmap_kenter_pa((vaddr_t)msgbufaddr + i * PAGE_SIZE,
185 avail_end + i * PAGE_SIZE, VM_PROT_READ|VM_PROT_WRITE, 0); 186 avail_end + i * PAGE_SIZE, VM_PROT_READ|VM_PROT_WRITE, 0);
186 pmap_update(pmap_kernel()); 187 pmap_update(pmap_kernel());
187 initmsgbuf(msgbufaddr, m68k_round_page(MSGBUFSIZE)); 188 initmsgbuf(msgbufaddr, m68k_round_page(MSGBUFSIZE));
188 189
189 190
190 pio0[3] = 0xb6; 191 pio0[3] = 0xb6;
191 pio0[2] = 1 << 6; /* enable parity check */ 192 pio0[2] = 1 << 6; /* enable parity check */
192 pio0[3] = 0xb6; 193 pio0[3] = 0xb6;
193 sw1 = pio0[0]; /* dip sw1 value */ 194 sw1 = pio0[0]; /* dip sw1 value */
194 sw1 ^= 0xff; 195 sw1 ^= 0xff;
195 sysconsole = !(sw1 & 0x2); /* console selection */ 196 sysconsole = !(sw1 & 0x2); /* console selection */
196 197
 198 /*
 199 * Check if boothowto and bootdev values are passed by our bootloader.
 200 */
 201 if ((bootdev & B_MAGICMASK) == B_DEVMAGIC) {
 202 /* Valid value is set; no need to parse bootarg. */
 203 return;
 204 }
 205
 206 /*
 207 * No valid bootdev value is set.
 208 * Assume we are booted by ROM monitor directly using a.out kernel
 209 * and we have to parse bootarg passed from the monitor to set
 210 * proper boothowto and check netboot.
 211 */
 212
 213 /* set default to "sd0a" with no howto flags */
 214 bootdev = MAKEBOOTDEV(0, LUNA68K_BOOTADPT_SPC, 0, 0, 0);
197 boothowto = 0; 215 boothowto = 0;
198 i = 0; 216
199 /* 217 /*
200 * 'bootarg' on LUNA has: 218 * 'bootarg' on LUNA has:
201 * "<args of x command> ENADDR=<addr> HOST=<host> SERVER=<name>" 219 * "<args of x command> ENADDR=<addr> HOST=<host> SERVER=<name>"
202 * where <addr> is MAC address of which network loader used (not 220 * where <addr> is MAC address of which network loader used (not
203 * necessarily same as one at 0x4101.FFE0), <host> and <name> 221 * necessarily same as one at 0x4101.FFE0), <host> and <name>
204 * are the values of HOST and SERVER environment variables. 222 * are the values of HOST and SERVER environment variables.
205 * 223 *
206 * 'bootarg' on LUNA-II has "<args of x command>" only. 224 * 'bootarg' on LUNA-II has "<args of x command>" only.
207 * 225 *
208 * NetBSD/luna68k cares only the first argment; any of "sda". 226 * NetBSD/luna68k cares only the first argment; any of "sda".
209 */ 227 */
210 for (cp = bootarg; *cp != ' ' && *cp != 0; cp++) { 228 bootarg[63] = '\0';
211 BOOT_FLAG(*cp, boothowto); 229 for (cp = bootarg; *cp != '\0'; cp++) {
212 if (i++ >= sizeof(bootarg)) 230 if (*cp == '-') {
213 break; 231 char c;
 232 while ((c = *cp) != '\0' && c != ' ') {
 233 BOOT_FLAG(c, boothowto);
 234 cp++;
 235 }
 236 } else if (*cp == 'E' && memcmp("ENADDR=", cp, 7) == 0) {
 237 bootdev =
 238 MAKEBOOTDEV(0, LUNA68K_BOOTADPT_LANCE, 0, 0, 0);
 239 }
214 } 240 }
215#if 0 /* overload 1:sw1, which now means 'go ROM monitor' after poweron */ 
216 if (boothowto == 0) 
217 boothowto = (sw1 & 0x1) ? RB_SINGLE : 0; 
218#endif 
219} 241}
220 242
221/* 243/*
222 * Console initialization: called early on from main, 244 * Console initialization: called early on from main,
223 */ 245 */
224void 246void
225consinit(void) 247consinit(void)
226{ 248{
227 249
228 if (sysconsole == 0) 250 if (sysconsole == 0)
229 syscnattach(0); 251 syscnattach(0);
230 else { 252 else {
231 omfb_cnattach(); 253 omfb_cnattach();