From a7091d52fae1ddb548a2119032762a5f43843d27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Sat, 13 Sep 2003 00:02:54 +0000 Subject: [PATCH] Implemented PPC optimized byte order functions, and added them to the build. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@4665 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/libroot/os/arch/ppc/Jamfile | 2 + src/kernel/libroot/os/arch/ppc/byteorder.S | 43 ++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 src/kernel/libroot/os/arch/ppc/byteorder.S diff --git a/src/kernel/libroot/os/arch/ppc/Jamfile b/src/kernel/libroot/os/arch/ppc/Jamfile index ab7b97ab1c..65a7466001 100644 --- a/src/kernel/libroot/os/arch/ppc/Jamfile +++ b/src/kernel/libroot/os/arch/ppc/Jamfile @@ -2,6 +2,7 @@ SubDir OBOS_TOP src kernel libroot os arch ppc ; KernelMergeObject os_arch_$(OBOS_ARCH).o : <$(SOURCE_GRIST)>atomic.S + <$(SOURCE_GRIST)>byteorder.S # <$(SOURCE_GRIST)>systeminfo.c <$(SOURCE_GRIST)>system_time.S <$(SOURCE_GRIST)>tls.c @@ -11,5 +12,6 @@ KernelMergeObject os_arch_$(OBOS_ARCH).o : MergeObjectFromObjects kernel_os_arch_$(OBOS_ARCH).o : <$(SOURCE_GRIST)>atomic.o + <$(SOURCE_GRIST)>byteorder.o <$(SOURCE_GRIST)>system_time.o ; diff --git a/src/kernel/libroot/os/arch/ppc/byteorder.S b/src/kernel/libroot/os/arch/ppc/byteorder.S new file mode 100644 index 0000000000..7ad16f1d98 --- /dev/null +++ b/src/kernel/libroot/os/arch/ppc/byteorder.S @@ -0,0 +1,43 @@ +/* +** Copyright 2003, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the OpenBeOS License. +*/ + +#define FUNCTION(x) .global x; .type x,@function; x + +.text + +/* uint16 __swap_int16(uint16 value) + * r3 + */ +FUNCTION(__swap_int16): + rlwinm %r4, %r3, 8, 16, 23 // byte 4 -> byte 3 (clear other bits) + rlwimi %r4, %r3, 24, 24, 31 // byte 3 -> byte 4 (copy into) + mr %r3, %r4 // copy to result register + blr + + +/* uint32 __swap_int32(uint32 value) + * r3 + */ +FUNCTION(__swap_int32): + rlwinm %r4, %r3, 24, 0, 31 // byte 4 to 1, byte 2 to 3 + rlwimi %r4, %r3, 8, 8, 15 // byte 3 to 2 + rlwimi %r4, %r3, 8, 24, 31 // byte 1 to 4 + mr %r3, %r4 + blr + + +/* uint64 __swap_int64(uint64 value) + * r3/r4 + */ +FUNCTION(__swap_int64): + rlwinm %r5, %r3, 24, 0, 31 // byte 4 to 5, byte 2 to 7 + rlwimi %r5, %r3, 8, 8, 15 // byte 3 to 6 + rlwimi %r5, %r3, 8, 24, 31 // byte 1 to 8 + rlwinm %r3, %r4, 24, 0, 31 // byte 8 to 1, byte 6 to 3 + rlwimi %r3, %r4, 8, 8, 15 // byte 7 to 2 + rlwimi %r3, %r4, 8, 24, 31 // byte 5 to 4 + mr %r4, %r5 // copy lower 32 bits + blr +