2 * $FreeBSD: src/sys/boot/alpha/boot1/boot1.c,v 1.7.2.1 2000/10/28 01:03:33 gallatin Exp $
3 * $DragonFly: src/sys/boot/alpha/boot1/Attic/boot1.c,v 1.3 2003/08/27 11:42:33 rob Exp $
4 * From $NetBSD: bootxx.c,v 1.4 1997/09/06 14:08:29 drochner Exp $
8 * Copyright (c) 1995 Carnegie-Mellon University.
11 * Author: Chris G. Demetriou
13 * Permission to use, copy, modify and distribute this software and
14 * its documentation is hereby granted, provided that both the copyright
15 * notice and this permission notice appear in all copies of the
16 * software, derivative works or modified versions, and any portions
17 * thereof, and that both notices appear in supporting documentation.
19 * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
20 * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND
21 * FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE.
23 * Carnegie Mellon requests users of this software to return to
25 * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU
26 * School of Computer Science
27 * Carnegie Mellon University
28 * Pittsburgh PA 15213-3890
30 * any improvements or extensions that they make and grant Carnegie the
31 * rights to redistribute these changes.
35 #include <sys/param.h>
37 #include <machine/prom.h>
38 #include <machine/rpb.h>
45 char *heap = (char*) end;
58 return prom_getchar();
78 size = (size + 7) & ~7;
89 panic(const char *message, ...)
107 ret.bits = prom_getenv(PROM_E_BOOTED_DEV, devname, sizeof devname);
109 ret.bits = prom_open(devname, ret.u.retval + 1);
111 panic("devopen: open failed\n");
113 prom_fd = ret.u.retval;
115 /* XXX read disklabel and setup partition offset */
126 char hex[] = "0123456789abcdef";
133 for (digit = 0; v >= (0x10L << digit); digit += 4)
136 for (; digit >= 0; digit -= 4)
137 putchar(hex[(v >> digit) & 0xf]);
143 devread(char *buf, int block, size_t size)
155 prom_read(prom_fd, size, buf, block);
168 getfilename(char *filename, const char *defname)
175 while ((c = getchar()) != '\r') {
176 if (c == '\b' || c == 0177) {
189 strcpy(filename, defname);
194 loadfile(char *name, char *addr)
204 puts("Can't open file ");
220 static inline u_long rpcc()
223 __asm__ __volatile__ ("rpcc %0" : "=r"(v));
224 return v & 0xffffffff;
230 char *loadaddr = (char*) SECONDARY_LOAD_ADDRESS;
231 char *name = "/boot/loader";
234 void (*entry) (void);
241 freq = ((struct rpb *)HWRPB_ADDR)->rpb_cc_freq;
242 while (((rpcc() - start) & 0xffffffff) < freq) {
245 getfilename(filename, name);
251 loadfile(name, loadaddr);
253 entry = (void (*)())loadaddr;