From: Evgeniy Ivanov Date: Mon, 9 Jan 2012 14:11:34 +0000 (+0400) Subject: Port bootxx. X-Git-Tag: v3.2.0~76 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/zlib_tech.html?a=commitdiff_plain;h=4c4c045f873401a73529903bba39b9f80382619d;p=minix.git Port bootxx. --- diff --git a/sys/arch/i386/stand/bootxx/Makefile b/sys/arch/i386/stand/bootxx/Makefile index 05a3da261..8567456ad 100644 --- a/sys/arch/i386/stand/bootxx/Makefile +++ b/sys/arch/i386/stand/bootxx/Makefile @@ -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 diff --git a/sys/arch/i386/stand/bootxx/Makefile.bootxx b/sys/arch/i386/stand/bootxx/Makefile.bootxx index ab8074512..99da82618 100644 --- a/sys/arch/i386/stand/bootxx/Makefile.bootxx +++ b/sys/arch/i386/stand/bootxx/Makefile.bootxx @@ -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 diff --git a/sys/arch/i386/stand/bootxx/boot1.c b/sys/arch/i386/stand/bootxx/boot1.c index 9ecbb479a..6333f57ca 100644 --- a/sys/arch/i386/stand/bootxx/boot1.c +++ b/sys/arch/i386/stand/bootxx/boot1.c @@ -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; diff --git a/sys/arch/i386/stand/bootxx/bootxx.S b/sys/arch/i386/stand/bootxx/bootxx.S index ead430c41..3bed04f6e 100644 --- a/sys/arch/i386/stand/bootxx/bootxx.S +++ b/sys/arch/i386/stand/bootxx/bootxx.S @@ -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 */ diff --git a/sys/arch/i386/stand/bootxx/bootxx_minixfs3/Makefile b/sys/arch/i386/stand/bootxx/bootxx_minixfs3/Makefile index ba1e4e855..4519c4c51 100644 --- a/sys/arch/i386/stand/bootxx/bootxx_minixfs3/Makefile +++ b/sys/arch/i386/stand/bootxx/bootxx_minixfs3/Makefile @@ -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>