Subject: boot block diffs
To: None <port-amiga@NetBSD.ORG>
From: Christian E. Hopps <chopps@merit.edu>
List: port-amiga
Date: 05/08/1998 19:33:34
I'm going to change the boot blocks for 1.3.2.  I've tested all
the various modes of operation on my A3000 but it would be nice
to get more covereage.  Therfore can people try this patch out
and let me know if it works.  It would be good if this were done
before sunday.

Specifically it would be nice to know if:

	The boot blocks used to work and now don't after applying
	the patch.

	The boot blocks now work where they previously did not
	(e.g., if you experienced ``Error 27'' becuase you have
	more than one segment of fast ram).

Thanks,
Chris.



diff -rc obootblock/boot/Makefile bootblock/boot/Makefile
*** obootblock/boot/Makefile	Tue Jul 15 07:42:18 1997
--- bootblock/boot/Makefile	Fri May  8 19:06:45 1998
***************
*** 40,46 ****
  AFLAGS += -m68030 -l
  CAFLAGS += -Wa,-l -Wa,-m68030 ${INCPATH}
  
! COPTIM= -O2 -fomit-frame-pointer -fno-function-cse -Wa,-l -m68060 -Wa,-m68030
  CFLAGS = ${COPTIM} ${INCPATH} ${DEFS} -Wall #-Wstrict-prototypes
  
  .c.o:
--- 40,46 ----
  AFLAGS += -m68030 -l
  CAFLAGS += -Wa,-l -Wa,-m68030 ${INCPATH}
  
! COPTIM= -O -fomit-frame-pointer -fcse-follow-jumps -fcse-skip-blocks  -Wa,-l -m68060 -Wa,-m68030
  CFLAGS = ${COPTIM} ${INCPATH} ${DEFS} -Wall #-Wstrict-prototypes
  
  .c.o:
diff -rc obootblock/boot/main.c bootblock/boot/main.c
*** obootblock/boot/main.c	Tue May 20 07:18:20 1997
--- bootblock/boot/main.c	Fri May  8 19:15:50 1998
***************
*** 92,98 ****
--- 92,100 ----
  	u_int32_t cpuid = 0;
  	int	amiga_flags = 0;
  	u_int32_t I_flag = 0;
+ #if 0
  	int	k_flag = 0;
+ #endif
  	int	p_flag = 0;
  	int	Z_flag = 0;
  	int	m_value = 0;
***************
*** 169,177 ****
--- 171,181 ----
  				case 'c':	/* force machine model */
  					cpuid = get_number(&path) << 16;
  					break;
+ #if 0
  				case 'k':	/* Reserve first 4M fastmem */
  					k_flag++;
  					break;
+ #endif
  				case 'm':	/* Force fastmem size */
  					m_value = get_number(&path) * 1024;
  					break;
***************
*** 197,204 ****
  				case 'I':	/* inhibit sync negotiation */
  					I_flag = get_number(&path);
  					break;
  				case 'K':	/* remove 1st 4MB fastmem */
! 					break;
  				case 'S':	/* include debug symbols */
  					S_flag = 1;
  					break;
--- 201,210 ----
  				case 'I':	/* inhibit sync negotiation */
  					I_flag = get_number(&path);
  					break;
+ #if 0
  				case 'K':	/* remove 1st 4MB fastmem */
! 					break; 
! #endif
  				case 'S':	/* include debug symbols */
  					S_flag = 1;
  					break;
***************
*** 312,317 ****
--- 318,332 ----
  
  	/* Permit(); */
  
+ #if 0
+ 	if (k_flag) {
+ 		fmem += 4*1024*1024;
+ 		fmemsz -= 4*1024*1024;
+ 	}
+ #endif
+ 	if (m_value && m_value < fmemsz)
+ 		fmemsz = m_value;
+ 
  	printf("Loading %s: ", kernel_name);
  	io = open(kernel_name, 0);
  	if (io < 0)
***************
*** 417,426 ****
  		 * option was not specified.  Copy startup code to end
  		 * of kernel image and set start_it.
  		 */
- 		if ((u_int32_t)kp < fmem) {
- 			errno = EFBIG;
- 			goto err;
- 		}
  		memcpy(kp + ksize + 256, (char *)startit,
  		    (char *)startit_end - (char *)startit);
  		CacheClearU();
--- 432,437 ----
diff -rc obootblock/boot/startit.s bootblock/boot/startit.s
*** obootblock/boot/startit.s	Tue May 20 07:18:20 1997
--- bootblock/boot/startit.s	Fri May  8 19:12:29 1998
***************
*** 144,174 ****
  |	moveb	#24,0x200003c9
  |	moveb	#0,0x200003c9
  
  | ---- copy kernel start ----
  
  	tstl	a3			| Can we load to fastmem?
! 	jeq	L0			| No, leave destination at 0
  	movl	a0,a3			| Move to start of fastmem chunk
  	addl	a0,a6			| relocate kernel entry point
! L0:
! 	movl	a1@+,a3@+
  	subl	#4,d2
! 	bcc	L0
  
  	lea	pc@(ckend:w),a1
  	movl	a3,sp@-
  	pea	pc@(_startit_end:w)
! L1:
  	movl	a1@+,a3@+
  	cmpl	sp@,a1
! 	bcs	L1
  	addql	#4,sp
- 
- 	btst	#3,d5
- 	jeq	L2
- 	.word	0xf4f8
- L2:	movql	#0,d2			| switch off cache to ensure we use
- 	movec	d2,cacr			| valid kernel data
  
  #if TESTONAMIGA
  	movew	#0xFF0,0xdff180		| yellow
--- 144,225 ----
  |	moveb	#24,0x200003c9
  |	moveb	#0,0x200003c9
  
+ | ---- switch off cache ----
+ 	btst	#3,d5
+ 	jeq	L3
+ 	.word	0xf4f8
+ L3:	movl	d2,sp@-			| save d2
+ 	movql	#0,d2			| switch off cache to ensure we use
+ 	movec	d2,cacr			| valid kernel data
+ 	movl	sp@+,d2			| restore d2
+ 
  | ---- copy kernel start ----
  
  	tstl	a3			| Can we load to fastmem?
! 	jeq	L4			| No, leave destination at 0
  	movl	a0,a3			| Move to start of fastmem chunk
  	addl	a0,a6			| relocate kernel entry point
! 
! L4:
! 	addl	#3,d2
! 	andl	#0xfffffffc,d2		| round up.
! 
! 	| determine if the kernel need be copied upwards or downwards
! 
! 	cmpl	a1,a3			| a3-a1
! 	bcs	above			| source is above
! 
! 	movl	a0,sp
! 	addl	d0,sp			| move the stack to the end of segment
! 
! 	| copy from below upwards requires copying from end to start.
! 
! 	addl	d2,a3			| one long word past
! 	addl	d2,a1			| one long word past
! 
! 	subl	#4,sp			| alloc space
! 	movl	a1,sp@-			| save source
! 	movl	a3,sp@-			| save destination
! 
! 	| copy copier to end of segment
! 
! 	movl	sp,a3
! 	subl	#256,a3			| end of segment save our stack
! 
! 	lea	pc@(_startit_end:w),a1
! 	movl	a0,sp@-			| save segment start
! 	lea	pc@(below:w),a0
! 
! L0:	movw	a1@-,a3@-
! 	cmpl	a0,a1
! 	bne	L0
! 	movl	sp@,a0			| restore segment start
! 	movl	a3,sp@			| address of relocated below
! 	addl	#(ckend - below),a3
! 	movl	a3,sp@(12)		| address of ckend for later
! 	rts
! 
! below:	movl	sp@+,a3			| recover destination
! 	movl	sp@+,a1			| recover source
! 
! L1:	movl	a1@-,a3@-		| copy kernel
! 	subl	#4,d2
! 	bne	L1
! 
! 	rts				| jmps to relocated ckend
! 
! above:	movl	a1@+,a3@+
  	subl	#4,d2
! 	bne	above
  
  	lea	pc@(ckend:w),a1
  	movl	a3,sp@-
  	pea	pc@(_startit_end:w)
! L2:
  	movl	a1@+,a3@+
  	cmpl	sp@,a1
! 	bcs	L2
  	addql	#4,sp
  
  #if TESTONAMIGA
  	movew	#0xFF0,0xdff180		| yellow