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