*BSD News Article 17958


Return to BSD News archive

Xref: sserve comp.windows.x.i386unix:2331 comp.os.386bsd.bugs:1050
Path: sserve!newshost.anu.edu.au!munnari.oz.au!metro!sunb.ocs.mq.edu.au!macadam.mpce.mq.edu.au!acagney
From: acagney@macadam.mpce.mq.edu.au (Andrew Cagney - aka Noid)
Newsgroups: comp.windows.x.i386unix,comp.os.386bsd.bugs
Subject: X-Free86-1.3 crashes on 386BSD, BUG and FIX...
Followup-To: comp.windows.x.i386unix
Date: 5 Jul 1993 14:33:08 GMT
Organization: School of MPCE, Macquarie University, Australia.
Lines: 229
Distribution: world
Message-ID: <219e34$t5d@sunb.ocs.mq.edu.au>
NNTP-Posting-Host: macadam.mpce.mq.edu.au
Originator: acagney@macadam.mpce.mq.edu.au

Late last week there was a comment that X-Free86-1.3 crashed when run
under 386BSD.  Below is a patch to fix a bug that was causing this
problem (for me).  As suspected, its in the line drawing code.
Interestingly, the bug is not 386BSD specific and should have also
occured on other platforms.

Briefly, the routine `fastcfbBresS' suffered from an `out by one'
error when testing for the lowerbound of the memory mapping the vga
board ("<=" ie "JBE" instead of "<" ie "JB").

The patch below fixes this (expect an offset error):

*** fLineBres.s.dist	Sun Jul  4 11:43:55 1993
--- fLineBres.s	Sun Jul  4 11:17:00 1993
***************
*** 134,140 ****
  	ADD_L	(CONTENT(e3),e)
  .L3:	ADD_L	(signdx,addrb)
  	CMP_L	(CONTENT(GLNAME(vgaWriteBottom)),addrb)
! 	JBE	(.L4)
  	CMP_L	(CONTENT(GLNAME(vgaWriteTop)),addrb)
  	JAE	(.L9)
  	LOOP	(.writeloopC)
--- 134,141 ----
  	ADD_L	(CONTENT(e3),e)
  .L3:	ADD_L	(signdx,addrb)
  	CMP_L	(CONTENT(GLNAME(vgaWriteBottom)),addrb)
! /*	JBE	(.L4)*/
! 	JB	(.L4)
  	CMP_L	(CONTENT(GLNAME(vgaWriteTop)),addrb)
  	JAE	(.L9)
  	LOOP	(.writeloopC)

Because this file isn't part of the `server kit', my copy of the
assembler file (after being put through cpp) follows.  If you have the
`server kit', re-link XF86_SVGA including the file below before
`libvga256.a'.  (libvga256.a contains the buggy copy of this file).

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	fLineBres.i
#
echo x - fLineBres.i
sed 's/^X//' >fLineBres.i << 'END-of-fLineBres.i'
X# 1 "fLineBres.s"
X# 1 "assyntax.h" 1
X# 140 "assyntax.h"
X# 211 "assyntax.h"
X 
X 
X 
X 
X 
X# 21 "fLineBres.s" 2
X# 1 "vgaAsm.h" 1
X# 43 "vgaAsm.h"
X# 22 "fLineBres.s" 2
X .file "fLineBres.s" 
X 
X .data 
Xe3:
X .long 0
X.globl _eax_vgaSetWrite
X_eax_vgaSetWrite:
X .long 0
X.globl _eax_vgaWriteNextCall
X_eax_vgaWriteNextCall:
X .long 0
X.globl _eax_vgaWriteNext
X_eax_vgaWriteNext:
X .long 0
X.globl _eax_vgaWritePrevCall
X_eax_vgaWritePrevCall:
X .long 0
X.globl _eax_vgaWritePrev
X_eax_vgaWritePrev:
X .long 0
X.globl _eax_count
X_eax_count:
X .long 0
X .text 
X .align 2,0x90 
X .globl _fastcfbBresS 
X _fastcfbBresS:
X pushl %ebp 
X movl %esp ,%ebp 
X pushl %edi 
X pushl %esi 
X pushl %ebx 
X movl 60(%ebp ) , %ecx 
X cmpl $0 , %ecx 
X jz .allfinish 
X movb 12(%ebp ) ,%dh 
X movb 16(%ebp ) ,%dl 
X movl 48(%ebp ) ,%edi 
X movl 52(%ebp ) ,%esi 
X movl 56(%ebp ) ,%eax 
X subl %esi ,%eax 
X movl %eax , e3 
X shll $2 , 24(%ebp ) 
X movl 24(%ebp ) ,%eax 
X imull 44(%ebp ) ,%eax 
X addl 40(%ebp ) ,%eax 
X addl 20(%ebp ) ,%eax 
X movl %eax , %ebx 
X cmpl $0 , 32(%ebp ) 
X jge .L1 
X negl 24(%ebp ) 
X.L1: subl %esi ,%edi 
X cmpl $1 , 36(%ebp ) 
X jnz .L2 
X pushl 24(%ebp ) 
X pushl 28(%ebp ) 
X popl 24(%ebp ) 
X popl 28(%ebp ) 
X.L2: cmpl $3 , 8(%ebp ) 
X jnz .LSet 
X.LCopy: cmpl $0xFF000000 , 20(%ebp ) 
X jb .nocheckloopC 
X pushl %ebx 
X call _vgaSetWrite 
X movl %eax , _eax_vgaSetWrite 
X movl %eax , %ebx 
X addl $4 ,%esp 
X movl $0 , _eax_count 
X .align 2,0x90 
X.writeloopC:
X movb %dl , ( %ebx ) 
X addl %esi ,%edi 
X js .L3 
X addl 24(%ebp ) , %ebx 
X addl e3 ,%edi 
X.L3: addl 28(%ebp ) , %ebx 
X cmpl _vgaWriteBottom , %ebx 
X jb .L4 
X cmpl _vgaWriteTop , %ebx 
X jae .L9 
X loop .writeloopC 
X jmp .allfinish 
X.L9:
X pushl %ebx 
X call _vgaWriteNext 
X movl %eax , %ebx 
X addl $4 ,%esp 
X loop .writeloopC 
X jmp .allfinish 
X.L4:
X pushl %ebx 
X call _vgaWritePrev 
X movl %eax , %ebx 
X addl $4 ,%esp 
X loop .writeloopC 
X jmp .allfinish 
X .align 2,0x90 
X.nocheckloopC:
X movb %dl , ( %ebx ) 
X addl %esi ,%edi 
X js .L5 
X addl 24(%ebp ) , %ebx 
X addl e3 ,%edi 
X.L5: addl 28(%ebp ) , %ebx 
X loop .nocheckloopC 
X .align 2,0x90 
X.allfinish:
X popl %ebx 
X popl %esi 
X popl %edi 
X leave 
X ret 
X.LSet: cmpl $0xFF000000 , 20(%ebp ) 
X jb .nocheckloopS 
X pushl %ebx 
X call _vgaSetReadWrite 
X movl %eax , %ebx 
X addl $4 ,%esp 
X .align 2,0x90 
X.writeloopS:
X movb ( %ebx ) ,%al 
X andb %dh ,%al 
X xorb %dl ,%al 
X movb %al , ( %ebx ) 
X addl %esi ,%edi 
X js .L6 
X addl 24(%ebp ) , %ebx 
X addl e3 ,%edi 
X.L6: addl 28(%ebp ) , %ebx 
X cmpl _vgaWriteBottom , %ebx 
X jbe .L7 
X cmpl _vgaWriteTop , %ebx 
X jae .L10 
X loop .writeloopS 
X jmp .allfinish 
X.L10: pushl %ebx 
X call _vgaReadWriteNext 
X movl %eax , %ebx 
X addl $4 ,%esp 
X loop .writeloopS 
X jmp .allfinish 
X.L7: pushl %ebx 
X call _vgaReadWritePrev 
X movl %eax , %ebx 
X addl $4 ,%esp 
X loop .writeloopS 
X jmp .allfinish 
X .align 2,0x90 
X.nocheckloopS:
X movb ( %ebx ) ,%al 
X andb %dh ,%al 
X xorb %dl ,%al 
X movb %al , ( %ebx ) 
X addl %esi ,%edi 
X js .L8 
X addl 24(%ebp ) , %ebx 
X addl e3 ,%edi 
X.L8: addl 28(%ebp ) , %ebx 
X loop .nocheckloopS 
X jmp .allfinish 
END-of-fLineBres.i
exit

	`Yesterday upon the stair,
	 I met a bug that wasn't there.
	 It wasn't there again to day,
	 I wish this bug would go away.'