From owner-svn-src-stable-10@freebsd.org Thu Oct 15 03:48:04 2015 Return-Path: Delivered-To: svn-src-stable-10@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id A07B0A15F7E; Thu, 15 Oct 2015 03:48:04 +0000 (UTC) (envelope-from cperciva@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 59C511E3A; Thu, 15 Oct 2015 03:48:04 +0000 (UTC) (envelope-from cperciva@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t9F3m3Ow025660; Thu, 15 Oct 2015 03:48:03 GMT (envelope-from cperciva@FreeBSD.org) Received: (from cperciva@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t9F3m3D5025659; Thu, 15 Oct 2015 03:48:03 GMT (envelope-from cperciva@FreeBSD.org) Message-Id: <201510150348.t9F3m3D5025659@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cperciva set sender to cperciva@FreeBSD.org using -f From: Colin Percival Date: Thu, 15 Oct 2015 03:48:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r289358 - stable/10/sys/boot/i386/gptboot X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Oct 2015 03:48:04 -0000 Author: cperciva Date: Thu Oct 15 03:48:03 2015 New Revision: 289358 URL: https://svnweb.freebsd.org/changeset/base/289358 Log: MFC 289031: Teach gptldr to handle >64k boot2. Modified: stable/10/sys/boot/i386/gptboot/gptldr.S Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/boot/i386/gptboot/gptldr.S ============================================================================== --- stable/10/sys/boot/i386/gptboot/gptldr.S Thu Oct 15 03:12:19 2015 (r289357) +++ stable/10/sys/boot/i386/gptboot/gptldr.S Thu Oct 15 03:48:03 2015 (r289358) @@ -45,6 +45,10 @@ /* Misc. Constants */ .set SIZ_PAG,0x1000 # Page size .set SIZ_SEC,0x200 # Sector size + .set COPY_BLKS,0x4 # Number of blocks + # to copy for boot2 + .set COPY_BLK_SZ,0x8000 # Copy in 32k blocks; must be + # a multiple of 16 bytes .globl start .code16 @@ -68,26 +72,39 @@ start: xor %cx,%cx # Zero * its header to find boot2. We need to copy boot2 to MEM_USR and BTX * to MEM_BTX. Since those might overlap, we have to copy boot2 * backwards first and then copy BTX. We aren't sure exactly how long - * boot2 is, but we assume it can't be longer than 64k, so we just always - * copy 64k. + * boot2 is, but it's currently under 128kB so we'll copy 4 blocks of 32kB + * each; this can be adjusted via COPY_BLK and COPY_BLK_SZ above. */ mov $end,%bx # BTX mov 0xa(%bx),%si # Get BTX length and set add %bx,%si # %si to start of boot2 - mov %si,%ax # Align %ds:%si on a - shr $4,%ax # paragraph boundary - and $0xf,%si # with the smallest - mov %ax,%ds # possible %si - add $(64 * 1024 - 16),%si - mov $MEM_USR/16,%ax # Point %es:%di at end of - mov $(64 * 1024 - 16),%di # largest boot2 range + dec %si # Set %ds:%si to point at the + mov %si,%ax # last byte we want to copy + shr $4,%ax # from boot2, with %si made as + add $(COPY_BLKS*COPY_BLK_SZ/16),%ax # small as possible. + and $0xf,%si # + mov %ax,%ds # + mov $MEM_USR/16,%ax # Set %es:(-1) to point at + add $(COPY_BLKS*COPY_BLK_SZ/16),%ax # the last byte we + mov %ax,%es # want to copy boot2 into. + mov $COPY_BLKS,%bx # Copy COPY_BLKS 32k blocks +copyloop: + add $COPY_BLK_SZ,%si # Adjust %ds:%si to point at + mov %ds,%ax # the end of the next 32k to + sub $COPY_BLK_SZ/16,%ax # copy from boot2 + mov %ax,%ds + mov $COPY_BLK_SZ-1,%di # Adjust %es:%di to point at + mov %es,%ax # the end of the next 32k into + sub $COPY_BLK_SZ/16,%ax # which we want boot2 copied mov %ax,%es + mov $COPY_BLK_SZ,%cx # Copy 32k std - mov %di,%cx # Copy 64k - paragraph + 1 - inc %cx # bytes rep movsb + dec %bx + jnz copyloop mov %cx,%ds # Reset %ds and %es mov %cx,%es + mov $end,%bx # BTX mov 0xa(%bx),%cx # Get BTX length and set mov %bx,%si # %si to end of BTX mov $MEM_BTX,%di # %di -> end of BTX at