1 /* $NetBSD: boot.c,v 1.16 2008/07/16 13:19:20 tsutsui Exp $ */
4 * Copyright (c) 1999 Izumi Tsutsui. All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 * Copyright (C) 1999 Tsubai Masanari. All rights reserved.
30 * Redistribution and use in source and binary forms, with or without
31 * modification, are permitted provided that the following conditions
33 * 1. Redistributions of source code must retain the above copyright
34 * notice, this list of conditions and the following disclaimer.
35 * 2. Redistributions in binary form must reproduce the above copyright
36 * notice, this list of conditions and the following disclaimer in the
37 * documentation and/or other materials provided with the distribution.
38 * 3. The name of the author may not be used to endorse or promote products
39 * derived from this software without specific prior written permission.
41 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
42 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
43 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
44 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
45 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
46 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
47 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
48 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
49 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
50 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
53 #include <lib/libkern/libkern.h>
54 #include <lib/libsa/stand.h>
55 #include <lib/libsa/loadfile.h>
57 #include <machine/romcall.h>
59 void boot(uint32_t, uint32_t, uint32_t, uint32_t);
60 extern void ICIA(void);
62 /* version strings in vers.c (generated by newvers.sh) */
63 extern const char bootprog_name
[];
64 extern const char bootprog_rev
[];
65 extern const char bootprog_kernrev
[];
67 char *devs
[] = { "hd", "fh", "fd", NULL
, NULL
, "rd", "st" };
68 char *kernels
[] = { "/netbsd", "/netbsd.gz", NULL
};
71 # define DPRINTF printf
73 # define DPRINTF while (0) printf
77 boot(uint32_t d4
, uint32_t d5
, uint32_t d6
, uint32_t d7
)
80 int ctlr
, unit
, part
, type
;
81 uint32_t bootdev
= d6
;
82 char *netbsd
= (char *)d5
;
83 u_long marks
[MARK_MAX
];
84 static char devname
[32], file
[32];
88 printf("%s Secondary Boot, Revision %s (from NetBSD %s)\n",
89 bootprog_name
, bootprog_rev
, bootprog_kernrev
);
91 /* bootname is "boot" by default. */
92 if (netbsd
== NULL
|| strcmp(netbsd
, "boot") == 0 ||
93 strcmp(netbsd
, "/boot") == 0)
96 DPRINTF("howto = 0x%x\n", d7
);
97 DPRINTF("bootdev = 0x%x\n", bootdev
);
98 DPRINTF("bootname = %s\n", netbsd
);
99 DPRINTF("maxmem = 0x%x\n", d4
);
101 #define SET_MAGIC(bootdev, magic) ((bootdev & 0x0fffffff)| (magic << 28))
102 /* PROM monitor passes 0xa, but NEWS-OS /boot passed 0x5... */
103 bootdev
= SET_MAGIC(bootdev
, 5);
105 ctlr
= BOOTDEV_CTLR(bootdev
);
106 unit
= BOOTDEV_UNIT(bootdev
);
107 part
= BOOTDEV_PART(bootdev
);
108 type
= BOOTDEV_TYPE(bootdev
);
110 marks
[MARK_START
] = 0;
112 if (devs
[type
] == NULL
) {
113 printf("unknown bootdev (0x%x)\n", bootdev
);
117 sprintf(devname
, "%s(%d,%d,%d)", devs
[type
], ctlr
, unit
, part
);
118 printf("Booting %s%s\n", devname
, netbsd
);
120 /* use user specified kernel name if exists */
126 /* disable LOAD_NOTE on floppy to avoid backward seek across volumes */
127 loadflag
= LOAD_KERNEL
;
128 if (devname
[0] == 'f') /* XXX */
129 loadflag
&= ~LOAD_NOTE
;
131 for (i
= 0; kernels
[i
]; i
++) {
132 sprintf(file
, "%s%s", devname
, kernels
[i
]);
133 DPRINTF("trying %s...\n", file
);
134 fd
= loadfile(file
, marks
, loadflag
);
138 if (kernels
[i
] == NULL
) {
139 #if 0 /* bootxx() may be overrided by loaded kernel */
147 DPRINTF("entry = 0x%x\n", (int)marks
[MARK_ENTRY
]);
148 DPRINTF("ssym = 0x%x\n", (int)marks
[MARK_SYM
]);
149 DPRINTF("esym = 0x%x\n", (int)marks
[MARK_END
]);
151 entry
= (void *)marks
[MARK_ENTRY
];
156 __asm
volatile ("movl %0,%%d7" : : "m" (d7
));
157 __asm
volatile ("movl %0,%%d6" : : "m" (bootdev
));
158 __asm
volatile ("movl %0,%%d5" : : "m" (netbsd
));
159 __asm
volatile ("movl %0,%%d4" : : "m" (d4
));
160 __asm
volatile ("movl %0,%%d2" : : "m" (marks
[MARK_END
]));