Port bootxx.
This commit is contained in:
parent
602233213e
commit
4c4c045f87
|
@ -1,13 +1,13 @@
|
|||
# $NetBSD: Makefile,v 1.14 2010/12/29 17:44:03 jakllsch Exp $
|
||||
|
||||
SUBDIR= bootxx_ffsv1 .WAIT bootxx_ffsv2 bootxx_lfsv1 bootxx_lfsv2
|
||||
SUBDIR+=bootxx_msdos bootxx_ustarfs
|
||||
#SUBDIR= bootxx_ffsv1 .WAIT bootxx_ffsv2 bootxx_lfsv1 bootxx_lfsv2
|
||||
#SUBDIR+=bootxx_msdos bootxx_ustarfs
|
||||
|
||||
# Ext2fs doesn't have enough free space (it has only 1KB)
|
||||
# to store this primary bootloader, but we can put it into
|
||||
# an independent small 'boot' partition as NetBSD/hp300 does.
|
||||
SUBDIR+=bootxx_ext2fs
|
||||
SUBDIR+=bootxx_minixfs3
|
||||
#SUBDIR+=bootxx_ext2fs
|
||||
SUBDIR=bootxx_minixfs3
|
||||
|
||||
LIBOBJ= ${.OBJDIR}
|
||||
.MAKEOVERRIDES+= LIBOBJ
|
||||
|
|
|
@ -50,12 +50,16 @@ CPPFLAGS+= -DXXfs_close=${FS}_close
|
|||
CPPFLAGS+= -DXXfs_read=${FS}_read
|
||||
CPPFLAGS+= -DXXfs_stat=${FS}_stat
|
||||
CPPFLAGS+= -DFS=${FS}
|
||||
# clang generates too big bootxx_xxx
|
||||
.if (${CC} == "clang")
|
||||
CPPFLAGS+= -Os
|
||||
.endif
|
||||
# CPPFLAGS+= -DBOOT_MSG_COM0
|
||||
|
||||
# Make sure we override any optimization options specified by the user
|
||||
.include "${.PARSEDIR}/../Makefile.inc"
|
||||
COPTS= ${OPT_SIZE.${ACTIVE_CC}}
|
||||
DBG=
|
||||
#.include "${.PARSEDIR}/../Makefile.inc"
|
||||
#COPTS= ${OPT_SIZE.${ACTIVE_CC}}
|
||||
#DBG=
|
||||
|
||||
CPPFLAGS+= -DNO_LBA_CHECK
|
||||
|
||||
|
|
|
@ -56,7 +56,11 @@ extern struct disklabel ptn_disklabel;
|
|||
static int
|
||||
ob(void)
|
||||
{
|
||||
#ifndef __minix
|
||||
return open("boot", 0);
|
||||
#else
|
||||
return open("boot_monitor", 0);
|
||||
#endif
|
||||
}
|
||||
|
||||
const char *
|
||||
|
@ -93,7 +97,7 @@ boot1(uint32_t biosdev, uint64_t *sector)
|
|||
|
||||
#ifdef BOOT_FROM_MINIXFS3
|
||||
bios_sector -= RF_PROTECTED_SECTORS;
|
||||
bios_sector += 32; /* XXX put somewhere as constant */
|
||||
bios_sector += MINIX3_FIRST_SUBP_OFFSET;
|
||||
*sector = bios_sector;
|
||||
|
||||
fd = ob();
|
||||
|
@ -118,8 +122,13 @@ boot1(uint32_t biosdev, uint64_t *sector)
|
|||
|
||||
done:
|
||||
/* if we fail here, so will fstat, so keep going */
|
||||
if (fd == -1 || fstat(fd, &sb) == -1)
|
||||
if (fd == -1 || fstat(fd, &sb) == -1) {
|
||||
#ifndef __minix
|
||||
return "Can't open /boot\r\n";
|
||||
#else
|
||||
return "Can't open /boot_monitor\r\n";
|
||||
#endif
|
||||
}
|
||||
|
||||
biosdev = (uint32_t)sb.st_size;
|
||||
#if 0
|
||||
|
@ -127,11 +136,21 @@ done:
|
|||
return "/boot too large\r\n";
|
||||
#endif
|
||||
|
||||
if (read(fd, (void *)SECONDARY_LOAD_ADDRESS, biosdev) != biosdev)
|
||||
if (read(fd, (void *)SECONDARY_LOAD_ADDRESS, biosdev) != biosdev) {
|
||||
#ifndef __minix
|
||||
return "/boot load failed\r\n";
|
||||
#else
|
||||
return "/boot_monitor load failed\r\n";
|
||||
#endif
|
||||
}
|
||||
|
||||
if (*(uint32_t *)(SECONDARY_LOAD_ADDRESS + 4) != X86_BOOT_MAGIC_2)
|
||||
if (*(uint32_t *)(SECONDARY_LOAD_ADDRESS + 4) != X86_BOOT_MAGIC_2) {
|
||||
#ifndef __minix
|
||||
return "Invalid /boot file format\r\n";
|
||||
#else
|
||||
return "Invalid /boot_monitor file format\r\n";
|
||||
#endif
|
||||
}
|
||||
|
||||
/* We need to jump to the secondary bootstrap in realmode */
|
||||
return 0;
|
||||
|
|
|
@ -90,7 +90,7 @@ boot_params: /* space for patchable variables */
|
|||
pop %ecx
|
||||
movl $boot_params, %esi
|
||||
orb $X86_BP_FLAGS_LBA64VALID, 4(%esi)
|
||||
lcall $SECONDARY_LOAD_ADDRESS/16, $0
|
||||
lcall $SECONDARY_LOAD_ADDRESS >> 4, $0
|
||||
|
||||
boot_fail:
|
||||
push %ax /* error string from boot1 */
|
||||
|
|
|
@ -2,6 +2,10 @@
|
|||
|
||||
PROG=bootxx_minixfs3
|
||||
FS=minixfs3
|
||||
CPPFLAGS=-DBOOT_FROM_MINIXFS3 -DTERSE_ERROR
|
||||
|
||||
MINIX3_FIRST_SUBP_OFFSET=32
|
||||
|
||||
CPPFLAGS= -DBOOT_FROM_MINIXFS3 -DTERSE_ERROR
|
||||
CPPFLAGS+= -DMINIX3_FIRST_SUBP_OFFSET=${MINIX3_FIRST_SUBP_OFFSET}
|
||||
|
||||
.include <../Makefile.bootxx>
|
||||
|
|
Loading…
Reference in a new issue