From owner-svn-src-all@freebsd.org Thu Oct 8 15:38:35 2015 Return-Path: Delivered-To: svn-src-all@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 9B2809D1031; Thu, 8 Oct 2015 15:38:35 +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 58C127AB; Thu, 8 Oct 2015 15:38:35 +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 t98FcY3L002093; Thu, 8 Oct 2015 15:38:34 GMT (envelope-from cperciva@FreeBSD.org) Received: (from cperciva@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t98FcYaO002092; Thu, 8 Oct 2015 15:38:34 GMT (envelope-from cperciva@FreeBSD.org) Message-Id: <201510081538.t98FcYaO002092@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: cperciva set sender to cperciva@FreeBSD.org using -f From: Colin Percival Date: Thu, 8 Oct 2015 15:38:34 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r289031 - head/sys/boot/i386/gptboot X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.20 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: Thu, 08 Oct 2015 15:38:35 -0000 Author: cperciva Date: Thu Oct 8 15:38:34 2015 New Revision: 289031 URL: https://svnweb.freebsd.org/changeset/base/289031 Log: Change gptldr from relocating 0xfff1 bytes of boot2 to relocating 0x20000 bytes of boot2. Since we're in 16-bit mode, we can't copy all 128kB at once; instead we loop four times and copy 32 kB each time. This change was made necessary by an upcoming increase in the size of the boot2 binary; should it increase further, the COPY_BLKS value can be adjusted without anyone needing to remember 8086 assembly language again. Requested by: allanjude Tested by: allanjude MFC after: 1 week Modified: head/sys/boot/i386/gptboot/gptldr.S Modified: head/sys/boot/i386/gptboot/gptldr.S ============================================================================== --- head/sys/boot/i386/gptboot/gptldr.S Thu Oct 8 15:13:57 2015 (r289030) +++ head/sys/boot/i386/gptboot/gptldr.S Thu Oct 8 15:38:34 2015 (r289031) @@ -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