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