Subject: kern/787: booting problem under amiga/m68k
To: None <gnats-admin@NetBSD.ORG>
From: Superuser <root@arresum.inka.de>
List: netbsd-bugs
Date: 02/07/1995 16:35:03
>Number:         787
>Category:       kern
>Synopsis:       problem with ARG_MAX on m68k
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    kern-bug-people (Kernel Bug People)
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Feb  7 16:35:02 1995
>Originator:     Superuser
>Organization:
	
>Release:        NetBSD-current 07-Feb-95
>Environment:
	
System: NetBSD arresum.inka.de 1.0A NetBSD 1.0A (VEEGO) #35: Tue Feb 7 23:37:35 GMT+0100 1995 root@arresum.inka.de:/src/sys/arch/amiga/compile/VEEGO amiga


>Description:
	maxlength only works with <64k
>How-To-Repeat:
	starting of scripts doesn't work, so /etc/rc isn't started
>Fix:
	This is a patch to fix that problem it come from
	niklas@appli.se (Niklas Hallqvist)
	I am working now with that fix.

*** /src/sys/arch/m68k/m68k/copy.s-orig	Wed Oct 26 08:51:01 1994
--- /src/sys/arch/m68k/m68k/copy.s	Tue Feb  7 23:06:07 1995
***************
*** 80,92 ****
  	jlt	Lcisflt1		| negative count, error
  	jeq	Lcisdone		| zero count, all done
  	movw	sp@(18),d0		| d0 = maxlength LSW
! 	jeq	Lcoloop			| low-order word zero
  	subql	#1,d0			| set up for dbeq
  Lcisloop:
  	movsb	a0@+,d1			| grab a byte
  	movb	d1,a1@+			| copy it
  	dbeq	d0,Lcisloop		| if !null and more, continue
! 	jne	Lcoloop			| down to zero...
  	moveq	#0,d0			| got a null, all done
  Lcisdone:
  	RESTORE_SFC
--- 80,92 ----
  	jlt	Lcisflt1		| negative count, error
  	jeq	Lcisdone		| zero count, all done
  	movw	sp@(18),d0		| d0 = maxlength LSW
! 	jeq	Lcisoloop		| low-order word zero
  	subql	#1,d0			| set up for dbeq
  Lcisloop:
  	movsb	a0@+,d1			| grab a byte
  	movb	d1,a1@+			| copy it
  	dbeq	d0,Lcisloop		| if !null and more, continue
! 	jne	Lcisoloop		| down to zero...
  	moveq	#0,d0			| got a null, all done
  Lcisdone:
  	RESTORE_SFC
***************
*** 100,106 ****
  	clrl	a0@(PCB_ONFAULT) 	| clear fault addr
  	movl	sp@+, d2
  	rts
! Lcoloop:
  	subql	#1, d2
  	jeq	Lcisflt2
  	movw	#0xffff, d0
--- 100,106 ----
  	clrl	a0@(PCB_ONFAULT) 	| clear fault addr
  	movl	sp@+, d2
  	rts
! Lcisoloop:
  	subql	#1, d2
  	jeq	Lcisflt2
  	movw	#0xffff, d0
***************
*** 117,152 ****
   *
   * Copy a null terminated string from the kernel
   * address space to the user address space.
-  * NOTE: maxlength must be < 64K
   */
  ENTRY(copyoutstr)
  	movl	_curpcb,a0		| current pcb
  	movl	#Lcosflt1,a0@(PCB_ONFAULT) | set up to catch faults
! 	movl	sp@(4),a0		| a0 = fromaddr
! 	movl	sp@(8),a1		| a1 = toaddr
! 	SETUP_DFC
! 	moveq	#0,d0
! 	movw	sp@(14),d0		| d0 = maxlength
  	jlt	Lcosflt1		| negative count, error
  	jeq	Lcosdone		| zero count, all done
  	subql	#1,d0			| set up for dbeq
  Lcosloop:
  	movb	a0@+,d1			| grab a byte
  	movsb	d1,a1@+			| copy it
  	dbeq	d0,Lcosloop		| if !null and more, continue
! 	jne	Lcosflt2		| ran out of room, error
  	moveq	#0,d0			| got a null, all done
  Lcosdone:
! 	RESTORE_DFC
! 	tstl	sp@(16)			| return length desired?
  	jeq	Lcosret			| no, just return
! 	subl	sp@(4),a0		| determine how much was copied
! 	movl	sp@(16),a1		| return location
  	movl	a0,a1@			| stash it
  Lcosret:
  	movl	_curpcb,a0		| current pcb
  	clrl	a0@(PCB_ONFAULT) 	| clear fault addr
  	rts
  Lcosflt1:
  	moveq	#EFAULT,d0		| copy fault
  	jra	Lcosdone
--- 117,161 ----
   *
   * Copy a null terminated string from the kernel
   * address space to the user address space.
   */
  ENTRY(copyoutstr)
+ 	movl	d2,sp@-			| high counter
  	movl	_curpcb,a0		| current pcb
  	movl	#Lcosflt1,a0@(PCB_ONFAULT) | set up to catch faults
! 	movl	sp@(8),a0		| a0 = fromaddr
! 	movl	sp@(12),a1		| a1 = toaddr
! 	SETUP_SFC
! 	moveq	#0,d2
! 	movw	sp@(16),d2		| d2 = maxlength MSW
! 	movl	sp@(16),d0		| d0 = maxlength
  	jlt	Lcosflt1		| negative count, error
  	jeq	Lcosdone		| zero count, all done
+ 	movw	sp@(18),d0		| d0 = maxlength LSW
+ 	jeq	Lcosoloop		| low-order word zero
  	subql	#1,d0			| set up for dbeq
  Lcosloop:
  	movb	a0@+,d1			| grab a byte
  	movsb	d1,a1@+			| copy it
  	dbeq	d0,Lcosloop		| if !null and more, continue
! 	jne	Lcosoloop		| down to zero...
  	moveq	#0,d0			| got a null, all done
  Lcosdone:
! 	RESTORE_SFC
! 	tstl	sp@(20)			| return length desired?
  	jeq	Lcosret			| no, just return
! 	subl	sp@(8),a0		| determine how much was copied
! 	movl	sp@(20),a1		| return location
  	movl	a0,a1@			| stash it
  Lcosret:
  	movl	_curpcb,a0		| current pcb
  	clrl	a0@(PCB_ONFAULT) 	| clear fault addr
+ 	movl	sp@+, d2
  	rts
+ Lcosoloop:
+ 	subql	#1, d2
+ 	jeq	Lcosflt2
+ 	movw	#0xffff, d0
+ 	jra	Lcosloop
  Lcosflt1:
  	moveq	#EFAULT,d0		| copy fault
  	jra	Lcosdone
***************
*** 159,187 ****
   *
   * Copy a null terminated string from one point to another in
   * the kernel address space.
-  * NOTE: maxlength must be < 64K
   */
  ENTRY(copystr)
! 	movl	sp@(4),a0		| a0 = fromaddr
! 	movl	sp@(8),a1		| a1 = toaddr
! 	moveq	#0,d0
! 	movw	sp@(14),d0		| d0 = maxlength
  	jlt	Lcsflt1			| negative count, error
  	jeq	Lcsdone			| zero count, all done
  	subql	#1,d0			| set up for dbeq
  Lcsloop:
  	movb	a0@+,a1@+		| copy a byte
  	dbeq	d0,Lcsloop		| if !null and more, continue
! 	jne	Lcsflt2			| ran out of room, error
  	moveq	#0,d0			| got a null, all done
  Lcsdone:
! 	tstl	sp@(16)			| return length desired?
  	jeq	Lcsret			| no, just return
! 	subl	sp@(4),a0		| determine how much was copied
! 	movl	sp@(16),a1		| return location
  	movl	a0,a1@			| stash it
  Lcsret:
  	rts
  Lcsflt1:
  	moveq	#EFAULT,d0		| copy fault
  	jra	Lcsdone
--- 168,205 ----
   *
   * Copy a null terminated string from one point to another in
   * the kernel address space.
   */
  ENTRY(copystr)
! 	movl	d2,sp@-			| high counter
! 	movl	sp@(8),a0		| a0 = fromaddr
! 	movl	sp@(12),a1		| a1 = toaddr
! 	moveq	#0,d2
! 	movw	sp@(16),d2		| d2 = maxlength MSW
! 	movl	sp@(16),d0		| d0 = maxlength
  	jlt	Lcsflt1			| negative count, error
  	jeq	Lcsdone			| zero count, all done
+ 	movw	sp@(18),d0		| d0 = maxlength LSW
+ 	jeq	Lcsoloop			| low-order word zero
  	subql	#1,d0			| set up for dbeq
  Lcsloop:
  	movb	a0@+,a1@+		| copy a byte
  	dbeq	d0,Lcsloop		| if !null and more, continue
! 	jne	Lcsoloop			| down to zero...
  	moveq	#0,d0			| got a null, all done
  Lcsdone:
! 	tstl	sp@(20)			| return length desired?
  	jeq	Lcsret			| no, just return
! 	subl	sp@(8),a0		| determine how much was copied
! 	movl	sp@(20),a1		| return location
  	movl	a0,a1@			| stash it
  Lcsret:
+ 	movl	sp@+, d2
  	rts
+ Lcsoloop:
+ 	subql	#1, d2
+ 	jeq	Lcsflt2
+ 	movw	#0xffff, d0
+ 	jra	Lcsloop
  Lcsflt1:
  	moveq	#EFAULT,d0		| copy fault
  	jra	Lcsdone
>Audit-Trail:
>Unformatted: