From owner-p4-projects@FreeBSD.ORG Thu Mar 27 13:23:40 2003 Return-Path: Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id D121937B404; Thu, 27 Mar 2003 13:23:39 -0800 (PST) Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 59E3D37B401 for ; Thu, 27 Mar 2003 13:23:39 -0800 (PST) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id E85E543F93 for ; Thu, 27 Mar 2003 13:23:38 -0800 (PST) (envelope-from jhb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.12.6/8.12.6) with ESMTP id h2RLNc0U006132 for ; Thu, 27 Mar 2003 13:23:38 -0800 (PST) (envelope-from jhb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.12.6/8.12.6/Submit) id h2RLNcBr006129 for perforce@freebsd.org; Thu, 27 Mar 2003 13:23:38 -0800 (PST) Date: Thu, 27 Mar 2003 13:23:38 -0800 (PST) Message-Id: <200303272123.h2RLNcBr006129@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jhb@freebsd.org using -f From: John Baldwin To: Perforce Change Reviews X-Spam-Status: No, hits=-3.9 required=5.0 tests=AWL,PATCH_UNIFIED_DIFF,X_AUTH_WARNING autolearn=ham version=2.50 X-Spam-Level: X-Spam-Checker-Version: SpamAssassin 2.50 (1.173-2003-02-20-exp) Subject: PERFORCE change 27479 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 27 Mar 2003 21:23:42 -0000 http://perforce.freebsd.org/chv.cgi?CH=27479 Change 27479 by jhb@jhb_laptop on 2003/03/27 13:23:10 - Rework to allow for reading CR3 as well (and CR2). - Trim the int15_87 handler considerably by wiser choice of instructions. Affected files ... .. //depot/projects/smpng/sys/boot/i386/btx/btx/btx.s#5 edit Differences ... ==== //depot/projects/smpng/sys/boot/i386/btx/btx/btx.s#5 (text+ko) ==== @@ -493,10 +493,8 @@ je v86wrmsr # Yes cmpb $0x32,(%esi) # Is it a RDMSR? je v86rdmsr # Yes - cmpb $0x20,(%esi) # Is this a - jne v86mon.4 # MOV reg,CR[04] - testb $0x18,0x1(%esi) # instruction? - jz v86mov # Yes + cmpb $0x20,(%esi) # Is this a MOV reg,CRx? + je v86mov # Yes v86mon.4: cmpb $0xfa,%al # CLI? je v86cli # Yes cmpb $0xfb,%al # STI? @@ -527,14 +525,21 @@ leal 0x8(%esp,1),%esp # Discard int no, error iret # To V86 mode # -# Emulate MOV reg,CR[04]. +# Emulate MOV reg,CRx. # v86mov: movb 0x1(%esi),%bl # Fetch Mod R/M byte + testb $0x10,%bl # Read CR2 or CR3? + jnz v86mov.1 # Yes movl %cr0,%eax # Read CR0 testb $0x20,%bl # Read CR4 instead? - jz v86mov.1 # No + jz v86mov.2 # No movl %cr4,%eax # Read CR4 -v86mov.1: andl $0x7,%ebx # Compute offset in + jmp v86mov.2 +v86mov.1: movl %cr2,%eax # Read CR2 + testb $0x08,%bl # Read CR3 instead? + jz v86mov.2 # No + movl %cr3,%eax # Read CR3 +v86mov.2: andl $0x7,%ebx # Compute offset in shl $2,%ebx # frame of destination neg %ebx # register movl %eax,0x1c(%ebp,%ebx,1) # Store CR to reg @@ -613,41 +618,27 @@ # reads count of words from saved %cx # returns success by setting %ah to 0 # -int15_87: pushl %eax # Save - pushl %ebx # some information - pushl %esi # onto the stack. - pushl %edi - xorl %eax,%eax # clean EAX - xorl %ebx,%ebx # clean EBX - movl 0x4(%ebp),%esi # Get user's ESI - movl 0x3C(%ebp),%ebx # store ES - movw %si,%ax # store SI - shll $0x4,%ebx # Make it a seg. - addl %eax,%ebx # ebx=(es<<4)+si - movb 0x14(%ebx),%al # Grab the - movb 0x17(%ebx),%ah # necessary - shll $0x10,%eax # information - movw 0x12(%ebx),%ax # from - movl %eax,%esi # the - movb 0x1c(%ebx),%al # GDT in order to - movb 0x1f(%ebx),%ah # have %esi offset - shll $0x10,%eax # of source and %edi - movw 0x1a(%ebx),%ax # of destination. - movl %eax,%edi +int15_87: pushl %esi # Save + pushl %edi # registers + movzwl 0x4(%ebp),%eax # Load user's SI + movl 0x3C(%ebp),%edi # Load ES + leal (%eax,%edi,4),%edi # EDI = (ES << 4) + SI + movl 0x11(%edi),%eax # Read base of + movb 0x17(%edi),%al # GDT entry + ror $8,%eax # for source + movl %eax,%esi # into %esi + movl 0x19(%edi),%eax # Read base of + movb 0x1f(%edi),%al # GDT entry for + ror $8,%eax # destination + movl %eax,%edi # into %edi pushl %ds # Make: popl %es # es = ds - pushl %ecx # stash ECX - xorl %ecx,%ecx # highw of ECX is clear - movw 0x18(%ebp),%cx # Get user's ECX - shll $0x1,%ecx # Convert from num words to num - # bytes + movzwl 0x18(%ebp),%ecx # Get user's CX + shll $0x1,%ecx # Convert count from words rep # repeat... movsb # perform copy. - popl %ecx # Restore - popl %edi - popl %esi # previous - popl %ebx # register - popl %eax # values. + popl %edi # Restore + popl %esi # registers movb $0x0,0x1d(%ebp) # set ah = 0 to indicate # success andb $0xfe,%dl # clear CF