From owner-svn-src-stable@FreeBSD.ORG  Wed Jun 23 17:56:20 2010
Return-Path: <owner-svn-src-stable@FreeBSD.ORG>
Delivered-To: svn-src-stable@freebsd.org
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 748DE106566B;
	Wed, 23 Jun 2010 17:56:20 +0000 (UTC) (envelope-from jhb@FreeBSD.org)
Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c])
	by mx1.freebsd.org (Postfix) with ESMTP id 49A0A8FC08;
	Wed, 23 Jun 2010 17:56:20 +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 o5NHuKMY038241;
	Wed, 23 Jun 2010 17:56:20 GMT (envelope-from jhb@svn.freebsd.org)
Received: (from jhb@localhost)
	by svn.freebsd.org (8.14.3/8.14.3/Submit) id o5NHuKo9038239;
	Wed, 23 Jun 2010 17:56:20 GMT (envelope-from jhb@svn.freebsd.org)
Message-Id: <201006231756.o5NHuKo9038239@svn.freebsd.org>
From: John Baldwin <jhb@FreeBSD.org>
Date: Wed, 23 Jun 2010 17:56:20 +0000 (UTC)
To: src-committers@freebsd.org, svn-src-all@freebsd.org,
	svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
X-SVN-Group: stable-8
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Cc: 
Subject: svn commit: r209474 - stable/8/sys/boot/i386/zfsboot
X-BeenThere: svn-src-stable@freebsd.org
X-Mailman-Version: 2.1.5
Precedence: list
List-Id: SVN commit messages for all the -stable branches of the src tree
	<svn-src-stable.freebsd.org>
List-Unsubscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-stable>, 
	<mailto:svn-src-stable-request@freebsd.org?subject=unsubscribe>
List-Archive: <http://lists.freebsd.org/pipermail/svn-src-stable>
List-Post: <mailto:svn-src-stable@freebsd.org>
List-Help: <mailto:svn-src-stable-request@freebsd.org?subject=help>
List-Subscribe: <http://lists.freebsd.org/mailman/listinfo/svn-src-stable>,
	<mailto:svn-src-stable-request@freebsd.org?subject=subscribe>
X-List-Received-Date: Wed, 23 Jun 2010 17:56:20 -0000

Author: jhb
Date: Wed Jun 23 17:56:20 2010
New Revision: 209474
URL: http://svn.freebsd.org/changeset/base/209474

Log:
  MFC 208388:
  - 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.

Modified:
  stable/8/sys/boot/i386/zfsboot/zfsboot.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/amd64/include/xen/   (props changed)
  stable/8/sys/cddl/contrib/opensolaris/   (props changed)
  stable/8/sys/contrib/dev/acpica/   (props changed)
  stable/8/sys/contrib/pf/   (props changed)
  stable/8/sys/dev/ixgbe/   (props changed)
  stable/8/sys/dev/xen/xenpci/   (props changed)
  stable/8/sys/geom/sched/   (props changed)

Modified: stable/8/sys/boot/i386/zfsboot/zfsboot.c
==============================================================================
--- stable/8/sys/boot/i386/zfsboot/zfsboot.c	Wed Jun 23 17:51:11 2010	(r209473)
+++ stable/8/sys/boot/i386/zfsboot/zfsboot.c	Wed Jun 23 17:56:20 2010	(r209474)
@@ -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();