From owner-svn-src-all@FreeBSD.ORG Thu Mar 10 16:40:13 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 86556106567B; Thu, 10 Mar 2011 16:40:13 +0000 (UTC) (envelope-from rdivacky@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 745888FC21; Thu, 10 Mar 2011 16:40:13 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p2AGeD0O049515; Thu, 10 Mar 2011 16:40:13 GMT (envelope-from rdivacky@svn.freebsd.org) Received: (from rdivacky@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p2AGeDe4049512; Thu, 10 Mar 2011 16:40:13 GMT (envelope-from rdivacky@svn.freebsd.org) Message-Id: <201103101640.p2AGeDe4049512@svn.freebsd.org> From: Roman Divacky Date: Thu, 10 Mar 2011 16:40:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r219452 - in head/sys/boot: common i386/boot2 X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 10 Mar 2011 16:40:13 -0000 Author: rdivacky Date: Thu Mar 10 16:40:13 2011 New Revision: 219452 URL: http://svn.freebsd.org/changeset/base/219452 Log: Some more shrinking. o bunch of variables are turned into uint8_t o initial setting of namep[] in lookup() is removed as it's only overwritten a few lines down o kname is explicitly initialized in main() as BSS in boot2 is not zeroed o the setting and reading of "fmt" in load() is removed o buf in printf() is made static to save space Reviewed by: jhb Tested by: me and Fabian Keil Modified: head/sys/boot/common/ufsread.c head/sys/boot/i386/boot2/boot2.c Modified: head/sys/boot/common/ufsread.c ============================================================================== --- head/sys/boot/common/ufsread.c Thu Mar 10 13:59:17 2011 (r219451) +++ head/sys/boot/common/ufsread.c Thu Mar 10 16:40:13 2011 (r219452) @@ -87,7 +87,7 @@ static struct dmadat *dmadat; static ino_t lookup(const char *); static ssize_t fsread(ino_t, void *, size_t); -static int ls, dsk_meta; +static uint8_t ls, dsk_meta; static uint32_t fs_off; static __inline int @@ -126,8 +126,6 @@ lookup(const char *path) ino = ROOTINO; dt = DT_DIR; - name[0] = '/'; - name[1] = '\0'; for (;;) { if (*path == '/') path++; Modified: head/sys/boot/i386/boot2/boot2.c ============================================================================== --- head/sys/boot/i386/boot2/boot2.c Thu Mar 10 13:59:17 2011 (r219451) +++ head/sys/boot/i386/boot2/boot2.c Thu Mar 10 16:40:13 2011 (r219452) @@ -125,17 +125,17 @@ static struct dsk { unsigned drive; unsigned type; unsigned unit; - unsigned slice; - unsigned part; + uint8_t slice; + uint8_t part; unsigned start; int init; } dsk; static char cmd[512], cmddup[512]; -static const char *kname = NULL; +static const char *kname; static uint32_t opts; static int comspeed = SIOSPD; static struct bootinfo bootinfo; -static unsigned ioctrl = IO_KEYBOARD; +static uint8_t ioctrl = IO_KEYBOARD; void exit(int); static void load(void); @@ -226,6 +226,7 @@ main(void) uint8_t autoboot; ino_t ino; + kname = NULL; dmadat = (void *)(roundup2(__base + (int32_t)&_end, 0x10000) - __base); v86.ctl = V86_FLAGS; v86.efl = PSL_RESERVED_DEFAULT | PSL_I; @@ -306,9 +307,8 @@ load(void) static Elf32_Shdr es[2]; caddr_t p; ino_t ino; - uint32_t addr, x; + uint32_t addr; int i, j; - uint8_t fmt; if (!(ino = lookup(kname))) { if (!ls) @@ -317,15 +317,8 @@ load(void) } if (xfsread(ino, &hdr, sizeof(hdr))) return; - if (N_GETMAGIC(hdr.ex) == ZMAGIC) - fmt = 0; - else if (IS_ELF(hdr.eh)) - fmt = 1; - else { - printf("Invalid %s\n", "format"); - return; - } - if (fmt == 0) { + + if (N_GETMAGIC(hdr.ex) == ZMAGIC) { addr = hdr.ex.a_entry & 0xffffff; p = PTOV(addr); fs_off = PAGE_SIZE; @@ -334,7 +327,7 @@ load(void) p += roundup2(hdr.ex.a_text, PAGE_SIZE); if (xfsread(ino, p, hdr.ex.a_data)) return; - } else { + } else if (IS_ELF(hdr.eh)) { fs_off = hdr.eh.e_phoff; for (j = i = 0; i < hdr.eh.e_phnum && j < 2; i++) { if (xfsread(ino, ep + j, sizeof(ep[0]))) @@ -366,7 +359,11 @@ load(void) } addr = hdr.eh.e_entry & 0xffffff; bootinfo.bi_esymtab = VTOP(p); + } else { + printf("Invalid %s\n", "format"); + return; } + bootinfo.bi_kernelname = VTOP(kname); bootinfo.bi_bios_dev = dsk.drive; __exec((caddr_t)addr, RB_BOOTINFO | (opts & RBX_MASK), @@ -474,7 +471,8 @@ dskread(void *buf, unsigned lba, unsigne struct dos_partition *dp; struct disklabel *d; char *sec; - unsigned sl, i; + unsigned i; + uint8_t sl; if (!dsk_meta) { sec = dmadat->secbuf; @@ -534,7 +532,7 @@ static void printf(const char *fmt,...) { va_list ap; - char buf[10]; + static char buf[10]; char *s; unsigned u; int c;