Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/amiga/stand/bootblock/boot Fix NetBSD/amiga bootblo...



details:   https://anonhg.NetBSD.org/src/rev/f8987916462e
branches:  trunk
changeset: 374024:f8987916462e
user:      abs <abs%NetBSD.org@localhost>
date:      Sat Mar 25 20:14:26 2023 +0000

description:
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 :)

diffstat:

 sys/arch/amiga/stand/bootblock/boot/console.c  |  18 +++++++++++++++---
 sys/arch/amiga/stand/bootblock/boot/libstubs.h |   3 ++-
 sys/arch/amiga/stand/bootblock/boot/libstubs.s |  12 +++++++++++-
 sys/arch/amiga/stand/bootblock/boot/version    |   3 ++-
 4 files changed, 30 insertions(+), 6 deletions(-)

diffs (89 lines):

diff -r de5d367ed92a -r f8987916462e sys/arch/amiga/stand/bootblock/boot/console.c
--- a/sys/arch/amiga/stand/bootblock/boot/console.c     Sat Mar 25 11:04:34 2023 +0000
+++ b/sys/arch/amiga/stand/bootblock/boot/console.c     Sat Mar 25 20:14:26 2023 +0000
@@ -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)
diff -r de5d367ed92a -r f8987916462e sys/arch/amiga/stand/bootblock/boot/libstubs.h
--- a/sys/arch/amiga/stand/bootblock/boot/libstubs.h    Sat Mar 25 11:04:34 2023 +0000
+++ b/sys/arch/amiga/stand/bootblock/boot/libstubs.h    Sat Mar 25 20:14:26 2023 +0000
@@ -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);
diff -r de5d367ed92a -r f8987916462e sys/arch/amiga/stand/bootblock/boot/libstubs.s
--- a/sys/arch/amiga/stand/bootblock/boot/libstubs.s    Sat Mar 25 11:04:34 2023 +0000
+++ b/sys/arch/amiga/stand/bootblock/boot/libstubs.s    Sat Mar 25 20:14:26 2023 +0000
@@ -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
diff -r de5d367ed92a -r f8987916462e sys/arch/amiga/stand/bootblock/boot/version
--- a/sys/arch/amiga/stand/bootblock/boot/version       Sat Mar 25 11:04:34 2023 +0000
+++ b/sys/arch/amiga/stand/bootblock/boot/version       Sat Mar 25 20:14:26 2023 +0000
@@ -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 @@ 2.3:  ???
 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



Home | Main Index | Thread Index | Old Index