Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 26 Jul 2011 13:24:52 +0000 (UTC)
From:      Marius Strobl <marius@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org
Subject:   svn commit: r224436 - stable/7/sys/boot/i386/boot2
Message-ID:  <201107261324.p6QDOqKC010412@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
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;
     }
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201107261324.p6QDOqKC010412>