From f1304e1a3c2a6d32bf156dfbb8541d317bfd1e9a Mon Sep 17 00:00:00 2001 From: George Koehler Date: Thu, 11 Jan 2018 20:04:27 -0500 Subject: [PATCH] Use extended mnemonics and ha16/lo16. Remove wrong comment: that's a right shift, not a left shift. --- plat/linuxppc/boot.s | 2 +- plat/linuxppc/libsys/_syscall.s | 37 +++++++++++++-------------------- plat/osxppc/boot.s | 2 +- plat/osxppc/libsys/set_errno.s | 8 +++---- 4 files changed, 20 insertions(+), 29 deletions(-) diff --git a/plat/linuxppc/boot.s b/plat/linuxppc/boot.s index 2da5dd556..33b2abd61 100644 --- a/plat/linuxppc/boot.s +++ b/plat/linuxppc/boot.s @@ -32,7 +32,7 @@ begtext: lwz r3, 0(sp) ! r3 = argc addi r4, sp, 4 ! r4 = argv - rlwinm r5, r3, 32-2, 2, 31 ! shift left 2 bits + srwi r5, r3, 2 add r5, r5, r4 addi r5, r5, 8 ! r5 = env diff --git a/plat/linuxppc/libsys/_syscall.s b/plat/linuxppc/libsys/_syscall.s index c7e818830..f60423bea 100644 --- a/plat/linuxppc/libsys/_syscall.s +++ b/plat/linuxppc/libsys/_syscall.s @@ -12,17 +12,8 @@ .sect .text -EINVAL = 22 +#define EINVAL 22 -#define IFFALSE 4 -#define IFTRUE 12 -#define ALWAYS 20 - -#define LT 0 -#define GT 1 -#define EQ 2 -#define OV 3 - ! Perform a Linux system call. .define __syscall @@ -32,21 +23,21 @@ __syscall: lwz r4, 8(sp) lwz r5, 12(sp) sc 0 - bclr IFFALSE, OV, 0 - + bnslr + ! On error, r3 contains the errno. ! It just so happens that errnos 1-34 are the same in Linux as in ACK. - cmpi cr0, 0, r3, 1 - bc IFTRUE, LT, 2f - cmpi cr0, 0, r3, 34 - bc IFTRUE, GT, 2f - + cmpwi r3, 1 + blt 2f + cmpwi r3, 34 + bgt 2f + 3: - li32 r4, _errno - stw r3, 0(r4) - addi r3, r0, -1 - bclr ALWAYS, 0, 0 - + lis r4, ha16[_errno] + stw r3, lo16[_errno](r4) + li r3, -1 + blr + 2: - addi r3, r0, EINVAL + li r3, EINVAL b 3b diff --git a/plat/osxppc/boot.s b/plat/osxppc/boot.s index e96198eb4..1517ee377 100644 --- a/plat/osxppc/boot.s +++ b/plat/osxppc/boot.s @@ -29,7 +29,7 @@ begtext: lwz r3, 0(sp) ! r3 = argc addi r4, sp, 4 ! r4 = argv - rlwinm r5, r3, 32-2, 2, 31 ! shift left 2 bits + srwi r5, r3, 2 add r5, r5, r4 addi r5, r5, 8 ! r5 = env diff --git a/plat/osxppc/libsys/set_errno.s b/plat/osxppc/libsys/set_errno.s index e406865a6..beb124a7c 100644 --- a/plat/osxppc/libsys/set_errno.s +++ b/plat/osxppc/libsys/set_errno.s @@ -1,7 +1,7 @@ .sect .text .define .set_errno .set_errno: - li32 r10, _errno - stw r3, 0(r10) ! set errno - addi r3, r0, -1 ! return -1 - bclr 20, 0, 0 + lis r4, ha16[_errno] + stw r3, lo16[_errno](r4) ! set errno + li r3, -1 ! return -1 + blr