From owner-svn-src-all@FreeBSD.ORG Tue Jul 26 13:24:52 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 84B76106566C; Tue, 26 Jul 2011 13:24:52 +0000 (UTC) (envelope-from marius@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 73B468FC13; Tue, 26 Jul 2011 13:24:52 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p6QDOqox010414; Tue, 26 Jul 2011 13:24:52 GMT (envelope-from marius@svn.freebsd.org) Received: (from marius@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p6QDOqKC010412; Tue, 26 Jul 2011 13:24:52 GMT (envelope-from marius@svn.freebsd.org) Message-Id: <201107261324.p6QDOqKC010412@svn.freebsd.org> From: Marius Strobl Date: Tue, 26 Jul 2011 13:24:52 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224436 - stable/7/sys/boot/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: Tue, 26 Jul 2011 13:24:52 -0000 Author: marius Date: Tue Jul 26 13:24:52 2011 New Revision: 224436 URL: http://svn.freebsd.org/changeset/base/224436 Log: MFC: r219186 This patch shrinks boot2 a little. o It switches kname to be just a pointer instead of an array thus avoiding a couple of memcpy()s. o It changes ioctl to unsigned from uint8_t. o It changes the second keyhit limit to 3 seconds from 5 so that constant propagation can take place. o It changes the ticks overflow computation as suggested by bde@. o It removes bi_basemem/bi_extmem/bi_memsizes_valid setting from bootinfo as it is unused. Reviewed by: jhb Modified: stable/7/sys/boot/i386/boot2/boot2.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/boot/i386/boot2/boot2.c ============================================================================== --- stable/7/sys/boot/i386/boot2/boot2.c Tue Jul 26 13:23:26 2011 (r224435) +++ stable/7/sys/boot/i386/boot2/boot2.c Tue Jul 26 13:24:52 2011 (r224436) @@ -131,11 +131,11 @@ static struct dsk { int init; } dsk; static char cmd[512], cmddup[512]; -static char kname[1024]; +static const char *kname = NULL; static uint32_t opts; static int comspeed = SIOSPD; static struct bootinfo bootinfo; -static uint8_t ioctrl = IO_KEYBOARD; +static unsigned ioctrl = IO_KEYBOARD; void exit(int); static void load(void); @@ -144,7 +144,6 @@ static int xfsread(ino_t, void *, size_t static int dskread(void *, unsigned, unsigned); static void printf(const char *,...); static void putchar(int); -static uint32_t memsize(void); static int drvread(void *, unsigned, unsigned); static int keyhit(unsigned); static int xputc(int); @@ -182,15 +181,6 @@ xfsread(ino_t inode, void *buf, size_t n return 0; } -static inline uint32_t -memsize(void) -{ - v86.addr = MEM_EXT; - v86.eax = 0x8800; - v86int(); - return v86.eax; -} - static inline void getstr(void) { @@ -245,9 +235,6 @@ main(void) dsk.slice = *(uint8_t *)PTOV(ARGS + 1) + 1; bootinfo.bi_version = BOOTINFO_VERSION; bootinfo.bi_size = sizeof(bootinfo); - bootinfo.bi_basemem = 0; /* XXX will be filled by loader or kernel */ - bootinfo.bi_extmem = memsize(); - bootinfo.bi_memsizes_valid++; /* Process configuration file */ @@ -271,11 +258,11 @@ main(void) * or in case of failure, try to load a kernel directly instead. */ - if (autoboot && !*kname) { - memcpy(kname, PATH_BOOT3, sizeof(PATH_BOOT3)); + if (autoboot && !kname) { + kname = PATH_BOOT3; if (!keyhit(3*SECOND)) { load(); - memcpy(kname, PATH_KERNEL, sizeof(PATH_KERNEL)); + kname = PATH_KERNEL; } } @@ -290,7 +277,7 @@ main(void) 'a' + dsk.part, kname); if (ioctrl & IO_SERIAL) sio_flush(); - if (!autoboot || keyhit(5*SECOND)) + if (!autoboot || keyhit(3*SECOND)) getstr(); else if (!autoboot || !OPT_CHECK(RBX_QUIET)) putchar('\n'); @@ -474,11 +461,7 @@ parse() ? DRV_HARD : 0) + drv; dsk_meta = 0; } - if ((i = ep - arg)) { - if ((size_t)i >= sizeof(kname)) - return -1; - memcpy(kname, arg, i + 1); - } + kname = arg; } arg = p; } @@ -630,7 +613,7 @@ keyhit(unsigned ticks) t1 = *(uint32_t *)PTOV(0x46c); if (!t0) t0 = t1; - if (t1 < t0 || t1 >= t0 + ticks) + if ((uint32_t)(t1 - t0) >= ticks) return 0; } }