svn commit: r208388 - head/sys/boot/i386/zfsboot

John Baldwin jhb at FreeBSD.org
Fri May 21 16:58:53 UTC 2010


Author: jhb
Date: Fri May 21 16:58:52 2010
New Revision: 208388
URL: http://svn.freebsd.org/changeset/base/208388

Log:
  - Set 'dmadat' earlier so that we properly setup the heap if we fail to
    locate a high memory area for the heap using the SMAP.
  - Read the number of hard drive devices from the BIOS instead of hardcoding
    a limit of 128.  Some BIOSes duplicate disk devices once you get beyond
    the maximum drive number.
  
  MFC after:	1 month

Modified:
  head/sys/boot/i386/zfsboot/zfsboot.c

Modified: head/sys/boot/i386/zfsboot/zfsboot.c
==============================================================================
--- head/sys/boot/i386/zfsboot/zfsboot.c	Fri May 21 16:32:14 2010	(r208387)
+++ head/sys/boot/i386/zfsboot/zfsboot.c	Fri May 21 16:58:52 2010	(r208388)
@@ -94,6 +94,7 @@ __FBSDID("$FreeBSD$");
 #define V86_CY(x)	((x) & 1)
 #define V86_ZR(x)	((x) & 0x40)
 
+#define BIOS_NUMDRIVES		0x475
 #define DRV_HARD	0x80
 #define DRV_MASK	0x7f
 
@@ -467,6 +468,7 @@ getstr(void)
 static inline void
 putc(int c)
 {
+    v86.ctl = 0;
     v86.addr = 0x10;
     v86.eax = 0xe00 | (c & 0xff);
     v86.ebx = 0x7;
@@ -617,6 +619,8 @@ main(void)
     off_t off;
     struct dsk *dsk;
 
+    dmadat = (void *)(roundup2(__base + (int32_t)&_end, 0x10000) - __base);
+
     bios_getmem();
 
     if (high_heap_size > 0) {
@@ -627,9 +631,6 @@ main(void)
 	heap_end = (char *) PTOV(bios_basemem);
     }
 
-    dmadat = (void *)(roundup2(__base + (int32_t)&_end, 0x10000) - __base);
-    v86.ctl = V86_FLAGS;
-
     dsk = malloc(sizeof(struct dsk));
     dsk->drive = *(uint8_t *)PTOV(ARGS);
     dsk->type = dsk->drive & DRV_HARD ? TYPE_AD : TYPE_FD;
@@ -666,7 +667,7 @@ main(void)
      * will find any other available pools and it may fill in missing
      * vdevs for the boot pool.
      */
-    for (i = 0; i < 128; i++) {
+    for (i = 0; i < *(unsigned char *)PTOV(BIOS_NUMDRIVES); i++) {
 	if ((i | DRV_HARD) == *(uint8_t *)PTOV(ARGS))
 	    continue;
 
@@ -1157,6 +1158,7 @@ getc(int fn)
      * when no such key is pressed in reality. As far as I can tell,
      * this only happens shortly after a reboot.
      */
+    v86.ctl = V86_FLAGS;
     v86.addr = 0x16;
     v86.eax = fn << 8;
     v86int();


More information about the svn-src-all mailing list