Revert change; addis/ori requires different handling to addis/lwz due to ori's
authorDavid Given <dg@cowlark.com>
Sun, 15 Jan 2017 09:31:20 +0000 (10:31 +0100)
committerDavid Given <dg@cowlark.com>
Sun, 15 Jan 2017 09:31:20 +0000 (10:31 +0100)
payload being unsigned while lwz's payload is signed.

util/led/relocate.c

index 02b0be3..9e5c92b 100644 (file)
@@ -119,13 +119,14 @@ static uint32_t get_powerpc_valu(char* addr, uint16_t type)
                /* branch instruction */
                return opcode1 & 0x03fffffd;
        }
-       else
+       else if (((opcode1 & 0xfc1f0000) == 0x3c000000) &&
+                ((opcode2 & 0xfc000000) == 0x60000000))
        {
-               /* If it's not a branch, we're just going to assume that the user
-                * knows what they're doing and this is a addis/ori pair (or
-                * compatible). */
+               /* addis / ori instruction pair */
                return ((opcode1 & 0xffff) << 16) | (opcode2 & 0xffff);
        }
+
+       assert(0 && "unrecognised PowerPC instruction");
 }
 
 /*
@@ -259,17 +260,17 @@ static void put_powerpc_valu(char* addr, uint32_t value, uint16_t type)
                i |= value & 0x03fffffd;
                write4(i, addr, type);
        }
-       else
+       else if (((opcode1 & 0xfc1f0000) == 0x3c000000) &&
+                ((opcode2 & 0xfc000000) == 0x60000000))
        {
-               /* If it's not a branch, we're just going to assume that the user
-                * knows what they're doing and this is a addis/ori pair (or
-                * compatible). */
                uint16_t hi = value >> 16;
                uint16_t lo = value & 0xffff;
 
                write4((opcode1 & 0xffff0000) | hi, addr+0, type);
                write4((opcode2 & 0xffff0000) | lo, addr+4, type);
        }
+       else
+               assert(0 && "unrecognised PowerPC instruction");
 }
 
 /*