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 boot.amiga when relo...



details:   https://anonhg.NetBSD.org/src/rev/24fbf4f098af
branches:  trunk
changeset: 365853:24fbf4f098af
user:      rin <rin%NetBSD.org@localhost>
date:      Fri Apr 29 06:42:58 2022 +0000

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

diffstat:

 sys/arch/amiga/stand/bootblock/boot/bbstart.s |  14 ++++++++++++--
 1 files changed, 12 insertions(+), 2 deletions(-)

diffs (28 lines):

diff -r c8c5165ce334 -r 24fbf4f098af sys/arch/amiga/stand/bootblock/boot/bbstart.s
--- a/sys/arch/amiga/stand/bootblock/boot/bbstart.s     Fri Apr 29 06:40:51 2022 +0000
+++ b/sys/arch/amiga/stand/bootblock/boot/bbstart.s     Fri Apr 29 06:42:58 2022 +0000
@@ -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 @@
 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
        



Home | Main Index | Thread Index | Old Index