1 /* $NetBSD: boot.c,v 1.4 2007/01/24 13:08:12 hubertf Exp $ */
4 * Copyright (c) 2002 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Steve C. Woodford.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
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
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
29 * POSSIBILITY OF SUCH DAMAGE.
33 * Copyright (c) 1982, 1986, 1990, 1993
34 * The Regents of the University of California. All rights reserved.
36 * Redistribution and use in source and binary forms, with or without
37 * modification, are permitted provided that the following conditions
39 * 1. Redistributions of source code must retain the above copyright
40 * notice, this list of conditions and the following disclaimer.
41 * 2. Redistributions in binary form must reproduce the above copyright
42 * notice, this list of conditions and the following disclaimer in the
43 * documentation and/or other materials provided with the distribution.
44 * 3. Neither the name of the University nor the names of its contributors
45 * may be used to endorse or promote products derived from this software
46 * without specific prior written permission.
48 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
49 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
50 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
51 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
52 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
53 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
54 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
55 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
56 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
57 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
60 * @(#)boot.c 8.1 (Berkeley) 6/10/93
63 #include <sys/param.h>
64 #include <sys/reboot.h>
65 #include <sys/termios.h>
66 #include <sys/ttydefaults.h>
67 #include <machine/bootinfo.h>
69 #include <lib/libkern/libkern.h>
73 #include "bugsyscalls.h"
75 struct bug_bootinfo bug_bootinfo
;
76 struct mvmeppc_bootinfo bootinfo
;
78 static u_int32_t
ioctrl2cflag(u_int32_t
);
83 struct bug_buginfo
*bbi
;
84 struct bug_boardid
*bid
;
85 struct bug_ioinquiry
*ioi
, ioinq
;
86 struct bug_ioctrl ioctrl
;
87 char consname
[CONSOLEDEV_LEN
];
90 int ask
= 0, howto
, part
;
92 if (bug_bootinfo
.bbi_bugmode
== 0)
93 panic("mvmeppc-boot: PReP boot mode not supported!");
95 bbi
= &bug_bootinfo
.bbi_bi
.bbi
;
97 if ((bid
= bugsys_brdid()) == NULL
)
98 panic("mvmeppc-boot: bugsys_brdid() failed!");
100 ioinq
.ii_boardname
= consname
;
101 ioinq
.ii_ioctrl
= &ioctrl
;
102 ioinq
.ii_portnum
= BUG_IOINQ_PORT_CONSOLE
;
103 if ((ioi
= bugsys_ioinq(&ioinq
)) == NULL
)
104 panic("mvmeppc-boot: bugsys_ioinq() failed!");
106 if (bid
->bi_devtype
> 9)
107 panic("mvmeppc-boot: Bogus boot device type (%d)",
110 printf(">> MVMEPPC boot on MVME%x\n", bid
->bi_bnumber
);
112 parse_args(bbi
->bbi_argstart
, bbi
->bbi_argend
, &file
, &howto
, &part
);
118 if (strcmp(line
, "halt") == 0)
124 while (cp
< (line
+ sizeof(line
) - 1) && *cp
)
127 bbi
->bbi_argstart
= line
;
128 bbi
->bbi_argend
= cp
;
129 parse_args(bbi
->bbi_argstart
, bbi
->bbi_argend
,
130 &file
, &howto
, &part
);
134 bootinfo
.bi_boothowto
= howto
;
135 bootinfo
.bi_bootaddr
= bbi
->bbi_devaddr
;
136 bootinfo
.bi_bootclun
= bbi
->bbi_clun
;
137 bootinfo
.bi_bootclun
= bbi
->bbi_dlun
;
138 strncpy(bootinfo
.bi_bootline
, bbi
->bbi_argstart
,
139 MIN(BOOTLINE_LEN
, bbi
->bbi_argend
- bbi
->bbi_argstart
));
140 strncpy(bootinfo
.bi_consoledev
, consname
, CONSOLEDEV_LEN
);
141 bootinfo
.bi_consoleaddr
= ioi
->ii_devaddr
;
142 bootinfo
.bi_consolechan
= ioi
->ii_channel
;
143 bootinfo
.bi_consolespeed
= ioctrl
.ic_baud
;
144 bootinfo
.bi_consolecflag
= ioctrl2cflag(ioctrl
.ic_ctrlbits
);
145 bootinfo
.bi_modelnumber
= bid
->bi_bnumber
;
147 exec_mvme(file
, howto
, part
);
148 printf("boot: %s: %s\n", file
, strerror(errno
));
154 ioctrl2cflag(u_int32_t ctrlbits
)
158 rv
= TTYDEF_CFLAG
& ~(CSIZE
| CSTOPB
| PARENB
| PARODD
);
161 if (ctrlbits
& IOCTRL_PARITY_ODD
)
162 rv
|= PARENB
| PARODD
;
164 if (ctrlbits
& IOCTRL_PARITY_EVEN
)
167 /* Convert character length */
168 if (ctrlbits
& IOCTRL_BITS_8
)
171 if (ctrlbits
& IOCTRL_BITS_7
)
174 if (ctrlbits
& IOCTRL_BITS_6
)
177 if (ctrlbits
& IOCTRL_BITS_5
)
180 panic("ioctrl2cflag: Bad character length: 0x%x", ctrlbits
);
182 /* Convert number of stop bits */
183 if (ctrlbits
& IOCTRL_STOP_2
)
186 if ((ctrlbits
& IOCTRL_STOP_1
) == 0)
187 panic("ioctrl2cflag: Bad number of stop bits: 0x%x", ctrlbits
);