* Copyright (c) 1990 The Regents of the University of California.
* This code is derived from software contributed to Berkeley by
* %sccs.include.noredist.c%
* @(#)bootxx.c 7.1 (Berkeley) %G%
extern int howto
, bootdev
, unit
, cyloffset
, boottype
;
* Boot program... arguments passed in r10 and r11
* are passed through to the full boot program.
register int io
, partition
; register char *bp
;
extern struct disklabel disklabel
;
/* are we a disk, if so look at disklabel and do things */
if (bootdev
== 0 || bootdev
== 3) {
* Synthesize bootdev from unit, type and partition
* It's dirty work, but someone's got to do it, and
* we always seem to get it.
for (io
= 0; io
< 8; io
++)
if (bootdev
> 0) { /* XXX should check dk_type == DTYPE_SCSI */
if (disklabel
.dk_partition
[io
].cyloff
== cyloffset
* disklabel
.dk_secpercyl
)
if (disklabel
.dk_partition
[io
].cyloff
== cyloffset
)
if (io
== 8) io
= 0; /* probably a bad or non-existant disklabel */
bootdev
= makedev(bootdev
, make_minor(unit
, io
));
} else { io
= 0 ; howto
= (howto
&0x7) | 3 ; }
while (*bp
!= '0') bp
++ ; /* n-char device names instead of 2 */
*bp
++ = unit
% 10 + '0' ;
/* bootprog[3] = unit % 10 + '0';
bootprog[4] = io % 10 + 'a';*/
printf("loading %s\n", bootprog
);
i
= read(io
, (char *)&x
, sizeof x
);
(x
.a_magic
!= 0407 && x
.a_magic
!= 0413 && x
.a_magic
!= 0410))
if ((x
.a_magic
== 0413 || x
.a_magic
== 0410) &&
lseek(io
, 0x400, 0) == -1)
if (read(io
, (char *)0, x
.a_text
) != x
.a_text
)
if (x
.a_magic
== 0413 || x
.a_magic
== 0410)
while ((int)addr
& CLOFSET
)
if (read(io
, addr
, x
.a_data
) != x
.a_data
)
x
.a_bss
+= 128*512; /* slop */
for (i
= 0; i
< x
.a_bss
; i
++)
(*((int (*)()) x
.a_entry
))();