Implemented the atomic functions to get in touch with PPC assembly.
git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3196 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
SubDir OBOS_TOP src kernel libroot os arch ppc ;
|
||||
|
||||
KernelMergeObject os_arch_$(OBOS_ARCH).o :
|
||||
# <$(SOURCE_GRIST)>atomic.S
|
||||
<$(SOURCE_GRIST)>atomic.S
|
||||
# <$(SOURCE_GRIST)>cpuid.S
|
||||
# <$(SOURCE_GRIST)>systeminfo.c
|
||||
# <$(SOURCE_GRIST)>thread.c
|
||||
@@ -11,7 +11,6 @@ KernelMergeObject os_arch_$(OBOS_ARCH).o :
|
||||
;
|
||||
|
||||
MergeObjectFromObjects kernel_os_arch_$(OBOS_ARCH).o :
|
||||
# ToDo: remove atomic_xxx() functions from the kernel's libx86.a
|
||||
#<$(SOURCE_GRIST)>atomic.o
|
||||
<$(SOURCE_GRIST)>atomic.o
|
||||
#<$(SOURCE_GRIST)>cpuid.o
|
||||
;
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
/*
|
||||
** 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
|
||||
|
||||
/* int atomic_add(int *value, int increment)
|
||||
* r3 r4
|
||||
*/
|
||||
FUNCTION(atomic_add):
|
||||
lost1: lwarx %r5, 0, %r3 // reserve memory address located in "r3"
|
||||
add %r0, %r5, %r4 // (contents are stored in "r5")
|
||||
stwcx. %r0, 0, %r3
|
||||
bne- lost1 // try again if reservation was lost
|
||||
mr %r3, %r5 // return old value (was in "r5")
|
||||
blr
|
||||
|
||||
/* int atomic_and(int *value, int andValue)
|
||||
* r3 r4
|
||||
*/
|
||||
FUNCTION(atomic_and):
|
||||
lost2: lwarx %r5, 0, %r3
|
||||
and %r0, %r5, %r4
|
||||
stwcx. %r0, 0, %r3
|
||||
bne- lost2
|
||||
mr %r3, %r5
|
||||
blr
|
||||
|
||||
/* int atomic_or(int *value, int orValue)
|
||||
* r3 r4
|
||||
*/
|
||||
FUNCTION(atomic_or):
|
||||
lost3: lwarx %r5, 0, %r3
|
||||
or %r0, %r5, %r4
|
||||
stwcx. %r0, 0, %r3
|
||||
bne- lost3
|
||||
mr %r3, %r5
|
||||
blr
|
||||
|
||||
/* int atomic_set(int *value, int setTo)
|
||||
* r3 r4
|
||||
*/
|
||||
FUNCTION(atomic_set):
|
||||
lost4: lwarx %r5, 0, %r3
|
||||
stwcx. %r4, 0, %r3
|
||||
bne- lost4
|
||||
mr %r3, %r5
|
||||
blr
|
||||
|
||||
/* int test_and_set(int *value, int setTo, int testValue)
|
||||
* r3 r4 r5
|
||||
*/
|
||||
FUNCTION(test_and_set):
|
||||
lost5: lwarx %r6, 0, %r3
|
||||
cmpw %r6, %r5
|
||||
bne out5
|
||||
stwcx. %r4, 0, %r3
|
||||
out5: mr %r3, %r6
|
||||
blr
|
||||
|
||||
Reference in New Issue
Block a user