cdboot.c revision 1.1.4.2 1 1.1.4.2 rmind /* $NetBSD: cdboot.c,v 1.1.4.2 2014/05/18 17:45:11 rmind Exp $ */
2 1.1.4.2 rmind
3 1.1.4.2 rmind /*-
4 1.1.4.2 rmind * Copyright (c) 1982, 1986, 1990, 1993
5 1.1.4.2 rmind * The Regents of the University of California. All rights reserved.
6 1.1.4.2 rmind *
7 1.1.4.2 rmind * Redistribution and use in source and binary forms, with or without
8 1.1.4.2 rmind * modification, are permitted provided that the following conditions
9 1.1.4.2 rmind * are met:
10 1.1.4.2 rmind * 1. Redistributions of source code must retain the above copyright
11 1.1.4.2 rmind * notice, this list of conditions and the following disclaimer.
12 1.1.4.2 rmind * 2. Redistributions in binary form must reproduce the above copyright
13 1.1.4.2 rmind * notice, this list of conditions and the following disclaimer in the
14 1.1.4.2 rmind * documentation and/or other materials provided with the distribution.
15 1.1.4.2 rmind * 3. Neither the name of the University nor the names of its contributors
16 1.1.4.2 rmind * may be used to endorse or promote products derived from this software
17 1.1.4.2 rmind * without specific prior written permission.
18 1.1.4.2 rmind *
19 1.1.4.2 rmind * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 1.1.4.2 rmind * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 1.1.4.2 rmind * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 1.1.4.2 rmind * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 1.1.4.2 rmind * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 1.1.4.2 rmind * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 1.1.4.2 rmind * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 1.1.4.2 rmind * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 1.1.4.2 rmind * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 1.1.4.2 rmind * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 1.1.4.2 rmind * SUCH DAMAGE.
30 1.1.4.2 rmind *
31 1.1.4.2 rmind * @(#)boot.c 8.1 (Berkeley) 6/10/93
32 1.1.4.2 rmind */
33 1.1.4.2 rmind
34 1.1.4.2 rmind /*
35 1.1.4.2 rmind * Copyright (c) 1998-2004 Michael Shalayeff
36 1.1.4.2 rmind * All rights reserved.
37 1.1.4.2 rmind *
38 1.1.4.2 rmind * Redistribution and use in source and binary forms, with or without
39 1.1.4.2 rmind * modification, are permitted provided that the following conditions
40 1.1.4.2 rmind * are met:
41 1.1.4.2 rmind * 1. Redistributions of source code must retain the above copyright
42 1.1.4.2 rmind * notice, this list of conditions and the following disclaimer.
43 1.1.4.2 rmind * 2. Redistributions in binary form must reproduce the above copyright
44 1.1.4.2 rmind * notice, this list of conditions and the following disclaimer in the
45 1.1.4.2 rmind * documentation and/or other materials provided with the distribution.
46 1.1.4.2 rmind *
47 1.1.4.2 rmind * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
48 1.1.4.2 rmind * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
49 1.1.4.2 rmind * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
50 1.1.4.2 rmind * IN NO EVENT SHALL THE AUTHOR OR HIS RELATIVES BE LIABLE FOR ANY DIRECT,
51 1.1.4.2 rmind * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
52 1.1.4.2 rmind * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
53 1.1.4.2 rmind * SERVICES; LOSS OF MIND, USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
54 1.1.4.2 rmind * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
55 1.1.4.2 rmind * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
56 1.1.4.2 rmind * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
57 1.1.4.2 rmind * THE POSSIBILITY OF SUCH DAMAGE.
58 1.1.4.2 rmind *
59 1.1.4.2 rmind */
60 1.1.4.2 rmind
61 1.1.4.2 rmind #include <sys/param.h>
62 1.1.4.2 rmind #include <sys/reboot.h>
63 1.1.4.2 rmind #include <sys/boot_flag.h>
64 1.1.4.2 rmind
65 1.1.4.2 rmind #include <arch/hppa/stand/common/libsa.h>
66 1.1.4.2 rmind #include <lib/libsa/loadfile.h>
67 1.1.4.2 rmind
68 1.1.4.2 rmind #include <machine/pdc.h>
69 1.1.4.2 rmind #include <machine/vmparam.h>
70 1.1.4.2 rmind
71 1.1.4.2 rmind #include <arch/hppa/stand/common/dev_hppa.h>
72 1.1.4.2 rmind
73 1.1.4.2 rmind /*
74 1.1.4.2 rmind * Boot program... bits in `howto' determine whether boot stops to
75 1.1.4.2 rmind * ask for system name. Boot device is derived from ROM provided
76 1.1.4.2 rmind * information.
77 1.1.4.2 rmind */
78 1.1.4.2 rmind
79 1.1.4.2 rmind void boot(dev_t boot_dev);
80 1.1.4.2 rmind
81 1.1.4.2 rmind typedef void (*startfuncp)(int, int, int, int, int, int, void *)
82 1.1.4.2 rmind __attribute__ ((noreturn));
83 1.1.4.2 rmind
84 1.1.4.2 rmind void
85 1.1.4.2 rmind boot(dev_t boot_dev)
86 1.1.4.2 rmind {
87 1.1.4.2 rmind u_long marks[MARK_MAX];
88 1.1.4.2 rmind u_long loadaddr = 0;
89 1.1.4.2 rmind char path[128];
90 1.1.4.2 rmind int fd;
91 1.1.4.2 rmind
92 1.1.4.2 rmind machdep();
93 1.1.4.2 rmind #ifdef DEBUGBUG
94 1.1.4.2 rmind debug = 1;
95 1.1.4.2 rmind #endif
96 1.1.4.2 rmind devboot(boot_dev, path);
97 1.1.4.2 rmind
98 1.1.4.2 rmind strncpy(path + strlen(path), ":/netbsd", 9);
99 1.1.4.2 rmind printf(">> %s, Revision %s\n", bootprog_name, bootprog_rev);
100 1.1.4.2 rmind printf(">> Booting %s: ", path);
101 1.1.4.2 rmind
102 1.1.4.2 rmind #define round_to_size(x) \
103 1.1.4.2 rmind (((x) + sizeof(u_long) - 1) & ~(sizeof(u_long) - 1))
104 1.1.4.2 rmind
105 1.1.4.2 rmind #define BOOTARG_APIVER 2
106 1.1.4.2 rmind
107 1.1.4.2 rmind marks[MARK_START] = loadaddr;
108 1.1.4.2 rmind if ((fd = loadfile(path, marks, LOAD_KERNEL)) == -1)
109 1.1.4.2 rmind return;
110 1.1.4.2 rmind
111 1.1.4.2 rmind marks[MARK_END] = round_to_size(marks[MARK_END] - loadaddr);
112 1.1.4.2 rmind printf("Start @ 0x%lx [%ld=0x%lx-0x%lx]...\n",
113 1.1.4.2 rmind marks[MARK_ENTRY], marks[MARK_NSYM],
114 1.1.4.2 rmind marks[MARK_SYM], marks[MARK_END]);
115 1.1.4.2 rmind
116 1.1.4.2 rmind #ifdef EXEC_DEBUG
117 1.1.4.2 rmind if (debug) {
118 1.1.4.2 rmind printf("ep=0x%x [", marks[MARK_ENTRY]);
119 1.1.4.2 rmind for (i = 0; i < 10240; i++) {
120 1.1.4.2 rmind if (!(i % 8)) {
121 1.1.4.2 rmind printf("\b\n%p:", &((u_int *)marks[MARK_ENTRY])[i]);
122 1.1.4.2 rmind if (getchar() != ' ')
123 1.1.4.2 rmind break;
124 1.1.4.2 rmind }
125 1.1.4.2 rmind printf("%x,", ((int *)marks[MARK_ENTRY])[i]);
126 1.1.4.2 rmind }
127 1.1.4.2 rmind printf("\b\b ]\n");
128 1.1.4.2 rmind }
129 1.1.4.2 rmind #endif
130 1.1.4.2 rmind
131 1.1.4.2 rmind fcacheall();
132 1.1.4.2 rmind
133 1.1.4.2 rmind __asm("mtctl %r0, %cr17");
134 1.1.4.2 rmind __asm("mtctl %r0, %cr17");
135 1.1.4.2 rmind /* stack and the gung is ok at this point, so, no need for asm setup */
136 1.1.4.2 rmind (*(startfuncp)(marks[MARK_ENTRY])) ((int)pdc, 0, boot_dev, marks[MARK_END],
137 1.1.4.2 rmind BOOTARG_APIVER, 0, NULL);
138 1.1.4.2 rmind /* not reached */
139 1.1.4.2 rmind }
140