summaryrefslogtreecommitdiffstats
path: root/sys/boot/i386/boot2
diff options
context:
space:
mode:
authorsjg <sjg@FreeBSD.org>2015-05-27 01:19:58 +0000
committersjg <sjg@FreeBSD.org>2015-05-27 01:19:58 +0000
commit65145fa4c81da358fcbc3b650156dab705dfa34e (patch)
tree55c065b6730aaac2afb6c29933ee6ec5fa4c4249 /sys/boot/i386/boot2
parent60ff4eb0dff94a04d75d0d52a3957aaaf5f8c693 (diff)
parente6b664c390af88d4a87208bc042ce503da664c3b (diff)
downloadFreeBSD-src-65145fa4c81da358fcbc3b650156dab705dfa34e.zip
FreeBSD-src-65145fa4c81da358fcbc3b650156dab705dfa34e.tar.gz
Merge sync of head
Diffstat (limited to 'sys/boot/i386/boot2')
-rw-r--r--sys/boot/i386/boot2/Makefile16
-rw-r--r--sys/boot/i386/boot2/boot2.c34
2 files changed, 30 insertions, 20 deletions
diff --git a/sys/boot/i386/boot2/Makefile b/sys/boot/i386/boot2/Makefile
index 40413e9..56f74c1 100644
--- a/sys/boot/i386/boot2/Makefile
+++ b/sys/boot/i386/boot2/Makefile
@@ -22,8 +22,7 @@ BOOT2_UFS?= UFS1_AND_UFS2
#BOOT2_UFS?= UFS2_ONLY
#BOOT2_UFS?= UFS1_ONLY
-CFLAGS= -Os \
- -fomit-frame-pointer \
+CFLAGS= -fomit-frame-pointer \
-mrtd \
-mregparm=3 \
-DUSE_XREAD \
@@ -39,12 +38,15 @@ CFLAGS= -Os \
-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \
-Winline
-CFLAGS.gcc+= -fno-guess-branch-probability \
+CFLAGS.gcc+= -Os \
+ -fno-guess-branch-probability \
-fno-unit-at-a-time \
- -mno-align-long-strings \
--param max-inline-insns-single=100
+.if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} <= 40201
+CFLAGS.gcc+= -mno-align-long-strings
+.endif
-CFLAGS.clang+=${CLANG_OPT_SMALL}
+CFLAGS.clang+= -Oz ${CLANG_OPT_SMALL}
LD_FLAGS=-static -N --gc-sections
@@ -59,7 +61,7 @@ boot: boot1 boot2
CLEANFILES+= boot1 boot1.out boot1.o
boot1: boot1.out
- objcopy -S -O binary boot1.out ${.TARGET}
+ ${OBJCOPY} -S -O binary boot1.out ${.TARGET}
boot1.out: boot1.o
${LD} ${LD_FLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o
@@ -80,7 +82,7 @@ boot2.ldr:
dd if=/dev/zero of=${.TARGET} bs=512 count=1
boot2.bin: boot2.out
- objcopy -S -O binary boot2.out ${.TARGET}
+ ${OBJCOPY} -S -O binary boot2.out ${.TARGET}
boot2.out: ${BTXCRT} boot2.o sio.o
${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC}
diff --git a/sys/boot/i386/boot2/boot2.c b/sys/boot/i386/boot2/boot2.c
index cd384e5..75abc7e 100644
--- a/sys/boot/i386/boot2/boot2.c
+++ b/sys/boot/i386/boot2/boot2.c
@@ -323,7 +323,8 @@ load(void)
caddr_t p;
ufs_ino_t ino;
uint32_t addr;
- int i, j;
+ int k;
+ uint8_t i, j;
if (!(ino = lookup(kname))) {
if (!ls)
@@ -344,7 +345,7 @@ load(void)
return;
} else if (IS_ELF(hdr.eh)) {
fs_off = hdr.eh.e_phoff;
- for (j = i = 0; i < hdr.eh.e_phnum && j < 2; i++) {
+ for (j = k = 0; k < hdr.eh.e_phnum && j < 2; k++) {
if (xfsread(ino, ep + j, sizeof(ep[0])))
return;
if (ep[j].p_type == PT_LOAD)
@@ -394,6 +395,7 @@ parse()
const char *cp;
unsigned int drv;
int c, i, j;
+ size_t k;
while ((c = *arg++)) {
if (c == ' ' || c == '\t' || c == '\n')
@@ -479,10 +481,10 @@ parse()
? DRV_HARD : 0) + drv;
dsk_meta = 0;
}
- if ((i = ep - arg)) {
- if ((size_t)i >= sizeof(knamebuf))
+ if (k = ep - arg) {
+ if (k >= sizeof(knamebuf))
return -1;
- memcpy(knamebuf, arg, i + 1);
+ memcpy(knamebuf, arg, k + 1);
kname = knamebuf;
}
}
@@ -499,6 +501,7 @@ dskread(void *buf, unsigned lba, unsigned nblk)
char *sec;
unsigned i;
uint8_t sl;
+ const char *reason;
if (!dsk_meta) {
sec = dmadat->secbuf;
@@ -523,8 +526,8 @@ dskread(void *buf, unsigned lba, unsigned nblk)
if (sl != COMPATIBILITY_SLICE)
dp += sl - BASE_SLICE;
if (dp->dp_typ != DOSPTYP_386BSD) {
- printf("Invalid %s\n", "slice");
- return -1;
+ reason = "slice";
+ goto error;
}
dsk.start = dp->dp_start;
}
@@ -533,8 +536,8 @@ dskread(void *buf, unsigned lba, unsigned nblk)
d = (void *)(sec + LABELOFFSET);
if (d->d_magic != DISKMAGIC || d->d_magic2 != DISKMAGIC) {
if (dsk.part != RAW_PART) {
- printf("Invalid %s\n", "label");
- return -1;
+ reason = "label";
+ goto error;
}
} else {
if (!dsk.init) {
@@ -544,14 +547,17 @@ dskread(void *buf, unsigned lba, unsigned nblk)
}
if (dsk.part >= d->d_npartitions ||
!d->d_partitions[dsk.part].p_size) {
- printf("Invalid %s\n", "partition");
- return -1;
+ reason = "partition";
+ goto error;
}
dsk.start += d->d_partitions[dsk.part].p_offset;
dsk.start -= d->d_partitions[RAW_PART].p_offset;
}
}
return drvread(buf, dsk.start + lba, nblk);
+error:
+ printf("Invalid %s\n", reason);
+ return -1;
}
static void
@@ -605,8 +611,10 @@ drvread(void *buf, unsigned lba, unsigned nblk)
{
static unsigned c = 0x2d5c7c2f;
- if (!OPT_CHECK(RBX_QUIET))
- printf("%c\b", c = c << 8 | c >> 24);
+ if (!OPT_CHECK(RBX_QUIET)) {
+ xputc(c = c << 8 | c >> 24);
+ xputc('\b');
+ }
v86.ctl = V86_ADDR | V86_CALLF | V86_FLAGS;
v86.addr = XREADORG; /* call to xread in boot1 */
v86.es = VTOPSEG(buf);
OpenPOWER on IntegriCloud