CVS commit: src/sys/arch/amiga/stand/bootblock/boot

2022-04-27 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Apr 27 12:10:47 UTC 2022

Modified Files:
src/sys/arch/amiga/stand/bootblock/boot: Makefile

Log Message:
Sprinkle SA_HARDCODED_SECSIZE; now everything fits into
+/-32KB range visible for PC relative addressing mode.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/sys/arch/amiga/stand/bootblock/boot/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/amiga/stand/bootblock/boot

2022-04-27 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Apr 27 12:10:47 UTC 2022

Modified Files:
src/sys/arch/amiga/stand/bootblock/boot: Makefile

Log Message:
Sprinkle SA_HARDCODED_SECSIZE; now everything fits into
+/-32KB range visible for PC relative addressing mode.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/sys/arch/amiga/stand/bootblock/boot/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amiga/stand/bootblock/boot/Makefile
diff -u src/sys/arch/amiga/stand/bootblock/boot/Makefile:1.57 src/sys/arch/amiga/stand/bootblock/boot/Makefile:1.58
--- src/sys/arch/amiga/stand/bootblock/boot/Makefile:1.57	Thu Feb 25 03:42:14 2021
+++ src/sys/arch/amiga/stand/bootblock/boot/Makefile	Wed Apr 27 12:10:47 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.57 2021/02/25 03:42:14 rin Exp $
+#	$NetBSD: Makefile,v 1.58 2022/04/27 12:10:47 rin Exp $
 
 .include 
 .include 		# for HOST_SH
@@ -50,7 +50,7 @@ SOBJS += libstubs.o
 OBJS+=	$(SOBJS) $(COBJS)
 
 #XX#DEFS = -D_STANDALONE -DSA_EXEC_ANYOWNER -DDYNAMIC_CRC_TABLE -DNOBYFOUR -UBYFOUR 
-DEFS = -D_STANDALONE -DSA_EXEC_ANYOWNER 
+DEFS = -D_STANDALONE -DSA_EXEC_ANYOWNER -DSA_HARDCODED_SECSIZE
 DEFS += -D__INTERNAL_LIBSA_CREAD
 DEFS += -DSERCONSOLE
 SOBJS += cread.o



CVS commit: src/sys/arch/amiga/stand/bootblock/boot

2022-04-27 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Apr 27 14:50:35 UTC 2022

Modified Files:
src/sys/arch/amiga/stand/bootblock/boot: Makefile

Log Message:
Revert previous.

On 2022/04/27 21:10, Rin Okuyama wrote:
> Module Name:  src
> Committed By: rin
> Date: Wed Apr 27 12:10:47 UTC 2022
>
> Modified Files:
>   src/sys/arch/amiga/stand/bootblock/boot: Makefile
>
> Log Message:
> Sprinkle SA_HARDCODED_SECSIZE; now everything fits into
> +/-32KB range visible for PC relative addressing mode.
>
>
> To generate a diff of this commit:
> cvs rdiff -u -r1.57 -r1.58 src/sys/arch/amiga/stand/bootblock/boot/Makefile
>
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/arch/amiga/stand/bootblock/boot/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/amiga/stand/bootblock/boot

2022-04-27 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Apr 27 14:50:35 UTC 2022

Modified Files:
src/sys/arch/amiga/stand/bootblock/boot: Makefile

Log Message:
Revert previous.

On 2022/04/27 21:10, Rin Okuyama wrote:
> Module Name:  src
> Committed By: rin
> Date: Wed Apr 27 12:10:47 UTC 2022
>
> Modified Files:
>   src/sys/arch/amiga/stand/bootblock/boot: Makefile
>
> Log Message:
> Sprinkle SA_HARDCODED_SECSIZE; now everything fits into
> +/-32KB range visible for PC relative addressing mode.
>
>
> To generate a diff of this commit:
> cvs rdiff -u -r1.57 -r1.58 src/sys/arch/amiga/stand/bootblock/boot/Makefile
>
> Please note that diffs are not public domain; they are subject to the
> copyright notices on the relevant files.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/arch/amiga/stand/bootblock/boot/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amiga/stand/bootblock/boot/Makefile
diff -u src/sys/arch/amiga/stand/bootblock/boot/Makefile:1.58 src/sys/arch/amiga/stand/bootblock/boot/Makefile:1.59
--- src/sys/arch/amiga/stand/bootblock/boot/Makefile:1.58	Wed Apr 27 12:10:47 2022
+++ src/sys/arch/amiga/stand/bootblock/boot/Makefile	Wed Apr 27 14:50:35 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.58 2022/04/27 12:10:47 rin Exp $
+#	$NetBSD: Makefile,v 1.59 2022/04/27 14:50:35 rin Exp $
 
 .include 
 .include 		# for HOST_SH
@@ -50,7 +50,7 @@ SOBJS += libstubs.o
 OBJS+=	$(SOBJS) $(COBJS)
 
 #XX#DEFS = -D_STANDALONE -DSA_EXEC_ANYOWNER -DDYNAMIC_CRC_TABLE -DNOBYFOUR -UBYFOUR 
-DEFS = -D_STANDALONE -DSA_EXEC_ANYOWNER -DSA_HARDCODED_SECSIZE
+DEFS = -D_STANDALONE -DSA_EXEC_ANYOWNER 
 DEFS += -D__INTERNAL_LIBSA_CREAD
 DEFS += -DSERCONSOLE
 SOBJS += cread.o



CVS commit: src/sys/arch/amiga/stand/bootblock/boot

2022-04-28 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Apr 29 06:42:58 UTC 2022

Modified Files:
src/sys/arch/amiga/stand/bootblock/boot: bbstart.s

Log Message:
Fix boot.amiga when relocation table is located beyond 0x8000.

In this case, we cannot load reltab directly into %a2 by movw:

For m68k, movw is actually synonym for different instructions when
its destination is data or address register, respectively.

(1) For data register, it is for move.w, which loads source into lower
half word with upper wharf word being kept untouched.

(2) For address register, it is movea.w, which loads source with
*sign extension*.

XXX
We should really stop using movw, and use move.w or movea.w explicitly.
However, this will end up with BIG diff...

Thanks ryo@ and isaki@ for comments offlist.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/amiga/stand/bootblock/boot/bbstart.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/amiga/stand/bootblock/boot

2022-04-28 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Apr 29 06:42:58 UTC 2022

Modified Files:
src/sys/arch/amiga/stand/bootblock/boot: bbstart.s

Log Message:
Fix boot.amiga when relocation table is located beyond 0x8000.

In this case, we cannot load reltab directly into %a2 by movw:

For m68k, movw is actually synonym for different instructions when
its destination is data or address register, respectively.

(1) For data register, it is for move.w, which loads source into lower
half word with upper wharf word being kept untouched.

(2) For address register, it is movea.w, which loads source with
*sign extension*.

XXX
We should really stop using movw, and use move.w or movea.w explicitly.
However, this will end up with BIG diff...

Thanks ryo@ and isaki@ for comments offlist.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 src/sys/arch/amiga/stand/bootblock/boot/bbstart.s

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amiga/stand/bootblock/boot/bbstart.s
diff -u src/sys/arch/amiga/stand/bootblock/boot/bbstart.s:1.13 src/sys/arch/amiga/stand/bootblock/boot/bbstart.s:1.14
--- src/sys/arch/amiga/stand/bootblock/boot/bbstart.s:1.13	Tue Jul  6 05:59:57 2010
+++ src/sys/arch/amiga/stand/bootblock/boot/bbstart.s	Fri Apr 29 06:42:58 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: bbstart.s,v 1.13 2010/07/06 05:59:57 mrg Exp $ */
+/* $NetBSD: bbstart.s,v 1.14 2022/04/29 06:42:58 rin Exp $ */
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -143,7 +143,17 @@ Lioerr:
 Lrelocate:
 	lea	%pc@(Lzero),%a0
 	movl	%a0,%d1
-	movw	%pc@(Lreltab),%a2
+
+	/*
+	 * Here, we cannot use
+	 *	movw	%pc@(Lreltab),%a2
+	 * "movw" against An is synonym for "movea.w", which carries out
+	 * sign extension. This breaks things when reltab >= 0x8000.
+	 */
+	movq	#0,%d0
+	movw	%pc@(Lreltab),%d0
+	movl	%d0,%a2
+
 	addl	%d1,%a2
 	jra	Loopend
 	



CVS commit: src/sys/arch/amiga/stand/bootblock/boot

2022-04-28 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Apr 29 06:48:22 UTC 2022

Modified Files:
src/sys/arch/amiga/stand/bootblock/boot: Makefile

Log Message:
Compile boot.amiga without -l option for gas(1).

Fix build failure due to relocation overflows for R_68K_PC16.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/arch/amiga/stand/bootblock/boot/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/amiga/stand/bootblock/boot

2022-04-28 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Apr 29 06:48:22 UTC 2022

Modified Files:
src/sys/arch/amiga/stand/bootblock/boot: Makefile

Log Message:
Compile boot.amiga without -l option for gas(1).

Fix build failure due to relocation overflows for R_68K_PC16.


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/arch/amiga/stand/bootblock/boot/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amiga/stand/bootblock/boot/Makefile
diff -u src/sys/arch/amiga/stand/bootblock/boot/Makefile:1.59 src/sys/arch/amiga/stand/bootblock/boot/Makefile:1.60
--- src/sys/arch/amiga/stand/bootblock/boot/Makefile:1.59	Wed Apr 27 14:50:35 2022
+++ src/sys/arch/amiga/stand/bootblock/boot/Makefile	Fri Apr 29 06:48:22 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.59 2022/04/27 14:50:35 rin Exp $
+#	$NetBSD: Makefile,v 1.60 2022/04/29 06:48:22 rin Exp $
 
 .include 
 .include 		# for HOST_SH
@@ -84,11 +84,11 @@ INCPATH += -I${.CURDIR}
 INCPATH += -I${.CURDIR}/../../.. -I${.OBJDIR}
 INCPATH += -I${.CURDIR}/../elf2bb
 
-AFLAGS += -march=68030 -mcpu=68030 -l
-CAFLAGS += -Wa,-l -Wa,-march=68030 -Wa,-mcpu=68030 ${INCPATH}
+AFLAGS += -march=68030 -mcpu=68030
+CAFLAGS += -Wa,-march=68030 -Wa,-mcpu=68030 ${INCPATH}
 
 COPTIM= -Os -fomit-frame-pointer -fcse-follow-jumps -fcse-skip-blocks
-COPTIM+= -Wa,-l -m68060 -Wa,-march=68030 -Wa,-mcpu=68030 -fno-unwind-tables
+COPTIM+= -m68060 -Wa,-march=68030 -Wa,-mcpu=68030 -fno-unwind-tables
 CFLAGS= -ffreestanding ${COPTIM} ${INCPATH} ${DEFS}
 CFLAGS+= -Werror
 CFLAGS+= -Wall -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith



CVS commit: src/sys/arch/amiga/stand/bootblock/boot

2022-04-28 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Apr 29 06:56:56 UTC 2022

Modified Files:
src/sys/arch/amiga/stand/bootblock/boot: Makefile

Log Message:
Now, cread.c can be built with -Os.

It was not a compiler bug actually; object code generated with
"-Os -Wa,-l" contains R_68K_16, which is not supported by elf2bb(1).

We should have fixed elf2bb(1), but the problem is gone at the moment.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/sys/arch/amiga/stand/bootblock/boot/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/amiga/stand/bootblock/boot

2022-04-28 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Apr 29 06:56:56 UTC 2022

Modified Files:
src/sys/arch/amiga/stand/bootblock/boot: Makefile

Log Message:
Now, cread.c can be built with -Os.

It was not a compiler bug actually; object code generated with
"-Os -Wa,-l" contains R_68K_16, which is not supported by elf2bb(1).

We should have fixed elf2bb(1), but the problem is gone at the moment.


To generate a diff of this commit:
cvs rdiff -u -r1.60 -r1.61 src/sys/arch/amiga/stand/bootblock/boot/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amiga/stand/bootblock/boot/Makefile
diff -u src/sys/arch/amiga/stand/bootblock/boot/Makefile:1.60 src/sys/arch/amiga/stand/bootblock/boot/Makefile:1.61
--- src/sys/arch/amiga/stand/bootblock/boot/Makefile:1.60	Fri Apr 29 06:48:22 2022
+++ src/sys/arch/amiga/stand/bootblock/boot/Makefile	Fri Apr 29 06:56:56 2022
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.60 2022/04/29 06:48:22 rin Exp $
+#	$NetBSD: Makefile,v 1.61 2022/04/29 06:56:56 rin Exp $
 
 .include 
 .include 		# for HOST_SH
@@ -93,9 +93,6 @@ CFLAGS= -ffreestanding ${COPTIM} ${INCPA
 CFLAGS+= -Werror
 CFLAGS+= -Wall -Wmissing-prototypes -Wstrict-prototypes -Wpointer-arith
 
-# XXX work around a gcc 4.5 bug
-COPTS.cread.c = -O1
-
 .c.o:
 	${_MKTARGET_COMPILE}
 	${CC} ${CFLAGS} ${COPTS.${.IMPSRC:T}} -S $< -o $*.s



CVS commit: src/sys/arch/amiga/stand/bootblock/boot

2023-03-25 Thread David Brownlee
Module Name:src
Committed By:   abs
Date:   Sat Mar 25 20:14:26 UTC 2023

Modified Files:
src/sys/arch/amiga/stand/bootblock/boot: console.c libstubs.h
libstubs.s version

Log Message:
Fix NetBSD/amiga bootblocks for Kickstart 3.2 - from Karoly Balogh

Kickstart 3.2 changed to not initialize console.device before
bootstrap, so the previous NetBSD bootblocks would crash when they
tried to initialise console output.

With this change if the call to the OpenDevice() stub fails, the
code now calls FindResident() and InitResident() before retrying
the OpenDevice().

Many thanks to Karoly Balogh for tracking this down (and also for
knowing just who to poke to get insight into the 3.2 changes :)


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/amiga/stand/bootblock/boot/console.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/amiga/stand/bootblock/boot/libstubs.h
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/amiga/stand/bootblock/boot/libstubs.s
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/amiga/stand/bootblock/boot/version

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/sys/arch/amiga/stand/bootblock/boot

2023-03-25 Thread David Brownlee
Module Name:src
Committed By:   abs
Date:   Sat Mar 25 20:14:26 UTC 2023

Modified Files:
src/sys/arch/amiga/stand/bootblock/boot: console.c libstubs.h
libstubs.s version

Log Message:
Fix NetBSD/amiga bootblocks for Kickstart 3.2 - from Karoly Balogh

Kickstart 3.2 changed to not initialize console.device before
bootstrap, so the previous NetBSD bootblocks would crash when they
tried to initialise console output.

With this change if the call to the OpenDevice() stub fails, the
code now calls FindResident() and InitResident() before retrying
the OpenDevice().

Many thanks to Karoly Balogh for tracking this down (and also for
knowing just who to poke to get insight into the 3.2 changes :)


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/amiga/stand/bootblock/boot/console.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/amiga/stand/bootblock/boot/libstubs.h
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/amiga/stand/bootblock/boot/libstubs.s
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/amiga/stand/bootblock/boot/version

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/arch/amiga/stand/bootblock/boot/console.c
diff -u src/sys/arch/amiga/stand/bootblock/boot/console.c:1.15 src/sys/arch/amiga/stand/bootblock/boot/console.c:1.16
--- src/sys/arch/amiga/stand/bootblock/boot/console.c:1.15	Sun Dec 18 12:02:37 2016
+++ src/sys/arch/amiga/stand/bootblock/boot/console.c	Sat Mar 25 20:14:26 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: console.c,v 1.15 2016/12/18 12:02:37 mlelstv Exp $ */
+/* $NetBSD: console.c,v 1.16 2023/03/25 20:14:26 abs Exp $ */
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -138,8 +138,20 @@ consinit(void *consptr) {
 		goto err;
 
 	mc->cnior->buf = (void *)mc->w;
-	if (OpenDevice("console.device", 0, mc->cnior, 0))
-		goto err;
+	mc->cnior->length = 136; /* sizeof(struct Window) */
+	if (OpenDevice("console.device", 0, mc->cnior, 0)) {
+		/* Kickstart 3.2 decided not to initialize console.device
+before bootstrap, so we have to do it ourselves. */
+		void *res = FindResident("console.device");
+		if (!res)
+			goto err;
+
+		if (!InitResident(res, 0))
+			goto err;
+
+		if (OpenDevice("console.device", 0, mc->cnior, 0))
+			goto err;
+	}
 
 	mc->tmior = (struct TimerIO *)CreateIORequest(mc->cnmp, sizeof(struct TimerIO));
 	if (!mc->tmior)

Index: src/sys/arch/amiga/stand/bootblock/boot/libstubs.h
diff -u src/sys/arch/amiga/stand/bootblock/boot/libstubs.h:1.7 src/sys/arch/amiga/stand/bootblock/boot/libstubs.h:1.8
--- src/sys/arch/amiga/stand/bootblock/boot/libstubs.h:1.7	Sat Oct 17 11:18:18 2009
+++ src/sys/arch/amiga/stand/bootblock/boot/libstubs.h	Sat Mar 25 20:14:26 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: libstubs.h,v 1.7 2009/10/17 11:18:18 mlelstv Exp $ */
+/* $NetBSD: libstubs.h,v 1.8 2023/03/25 20:14:26 abs Exp $ */
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -65,6 +65,7 @@ void CloseDevice(struct AmigaIO *);
 #endif
 
 void *FindResident(const char *);
+void *InitResident(const char *, u_int32_t);
 void *OpenResource(const char *);
 
 u_int32_t CachePreDMA(u_int32_t, u_int32_t *, int);

Index: src/sys/arch/amiga/stand/bootblock/boot/libstubs.s
diff -u src/sys/arch/amiga/stand/bootblock/boot/libstubs.s:1.10 src/sys/arch/amiga/stand/bootblock/boot/libstubs.s:1.11
--- src/sys/arch/amiga/stand/bootblock/boot/libstubs.s:1.10	Sat Oct 17 11:18:18 2009
+++ src/sys/arch/amiga/stand/bootblock/boot/libstubs.s	Sat Mar 25 20:14:26 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: libstubs.s,v 1.10 2009/10/17 11:18:18 mlelstv Exp $ */
+/* $NetBSD: libstubs.s,v 1.11 2023/03/25 20:14:26 abs Exp $ */
 
 /*-
  * Copyright (c) 1996 The NetBSD Foundation, Inc.
@@ -208,6 +208,16 @@ ENTRY_NOPROFILE(FindResident)
 	movl	%d0,%a0			| Comply with ELF ABI
 	rts
 
+ENTRY_NOPROFILE(InitResident)
+	movl	%a6,%sp@-
+	movl	%pc@(_C_LABEL(SysBase):w),%a6
+	movl	%sp@(8),%a1
+	movl	%sp@(12),%d1
+	jsr	%a6@(-0x66)
+	movl	%sp@+,%a6
+	movl	%d0,%a0			| Comply with ELF ABI
+	rts
+
 ENTRY_NOPROFILE(OpenResource)
 	movl	%a6,%sp@-
 	movl	%pc@(_C_LABEL(SysBase):w),%a6

Index: src/sys/arch/amiga/stand/bootblock/boot/version
diff -u src/sys/arch/amiga/stand/bootblock/boot/version:1.2 src/sys/arch/amiga/stand/bootblock/boot/version:1.3
--- src/sys/arch/amiga/stand/bootblock/boot/version:1.2	Thu Feb 25 03:42:14 2021
+++ src/sys/arch/amiga/stand/bootblock/boot/version	Sat Mar 25 20:14:26 2023
@@ -1,4 +1,4 @@
-$NetBSD: version,v 1.2 2021/02/25 03:42:14 rin Exp $
+$NetBSD: version,v 1.3 2023/03/25 20:14:26 abs Exp $
 
 NOTE ANY CHANGES YOU MAKE TO THE BOOTBLOCKS HERE.  The format of this
 file is important - make sure the entries are appended on end, last item
@@ -12,3 +12,4 @@ is taken as the current.
 2.4:	Moved default command into fixed location for easy patching
 3.0:	Initial 2 stage amiga bootblocks
 3.1:	Add support for FFSv2
+3.2:	Fix booting with some "modern" Kickstart versions