Add syscalls.

Fix CAS2 usage, only supports (An) addressing mode.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@22727 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
François Revol 2007-10-25 18:45:34 +00:00
parent 99d0c19e37
commit 2bbf13b7a5
2 changed files with 51 additions and 12 deletions

View File

@ -86,7 +86,9 @@ FUNCTION(atomic_get):
FUNCTION(atomic_add64):
move.l %d2,-(%a7)
move.l %d3,-(%a7)
move.l %a2,-(%a7)
move.l (4,%a7),%a1
lea.l (4,%a1),%a2
// addValue
move.l (12,%a7),%d2 /*LSB*/
move.l (8,%a7),%d3 /*MSB*/
@ -95,11 +97,12 @@ miss5: // old value
move.l (%a1),%d1 /*MSB*/
add.l %d0,%d2
addx.l %d1,%d3
cas2.l %d0:%d1,%d2:%d3,(4,%a1):(%a1)
cas2.l %d0:%d1,%d2:%d3,(%a2):(%a1)
bne miss5
// return value
move.l %d0,(4,%a0)
move.l %d1,(%a0)
move.l (%a7)+,%a2
move.l (%a7)+,%d3
move.l (%a7)+,%d2
rts
@ -108,7 +111,9 @@ miss5: // old value
FUNCTION(atomic_and64):
move.l %d2,-(%a7)
move.l %d3,-(%a7)
move.l %a2,-(%a7)
move.l (4,%a7),%a1
lea.l (4,%a1),%a2
// addValue
move.l (12,%a7),%d2 /*LSB*/
move.l (8,%a7),%d3 /*MSB*/
@ -117,11 +122,12 @@ miss6: // old value
move.l (%a1),%d1 /*MSB*/
and.l %d0,%d2
and.l %d1,%d3
cas2.l %d0:%d1,%d2:%d3,(4,%a1):(%a1)
cas2.l %d0:%d1,%d2:%d3,(%a2):(%a1)
bne miss6
// return value
move.l %d0,(4,%a0)
move.l %d1,(%a0)
move.l (%a7)+,%a2
move.l (%a7)+,%d3
move.l (%a7)+,%d2
rts
@ -130,7 +136,9 @@ miss6: // old value
FUNCTION(atomic_or64):
move.l %d2,-(%a7)
move.l %d3,-(%a7)
move.l %a2,-(%a7)
move.l (4,%a7),%a1
lea.l (4,%a1),%a2
// addValue
move.l (12,%a7),%d2 /*LSB*/
move.l (8,%a7),%d3 /*MSB*/
@ -139,11 +147,12 @@ miss7: // old value
move.l (%a1),%d1 /*MSB*/
or.l %d0,%d2
or.l %d1,%d3
cas2.l %d0:%d1,%d2:%d3,(4,%a1):(%a1)
cas2.l %d0:%d1,%d2:%d3,(%a2):(%a1)
bne miss7
// return value
move.l %d0,(4,%a0)
move.l %d1,(%a0)
move.l (%a7)+,%a2
move.l (%a7)+,%d3
move.l (%a7)+,%d2
rts
@ -152,18 +161,21 @@ miss7: // old value
FUNCTION(atomic_set64):
move.l %d2,-(%a7)
move.l %d3,-(%a7)
move.l %a2,-(%a7)
move.l (4,%a7),%a1
lea.l (4,%a1),%a2
// new value
move.l (12,%a7),%d2 /*LSB*/
move.l (8,%a7),%d3 /*MSB*/
// old value
move.l (4,%a1),%d0 /*LSB*/
move.l (%a1),%d1 /*MSB*/
miss8: cas2.l %d0:%d1,%d2:%d3,(4,%a1):(%a1)
miss8: cas2.l %d0:%d1,%d2:%d3,(%a2):(%a1)
bne miss8
// return value
move.l %d0,(4,%a0)
move.l %d1,(%a0)
move.l (%a7)+,%a2
move.l (%a7)+,%d3
move.l (%a7)+,%d2
rts
@ -172,17 +184,20 @@ miss8: cas2.l %d0:%d1,%d2:%d3,(4,%a1):(%a1)
FUNCTION(atomic_test_and_set64):
move.l %d2,-(%a7)
move.l %d3,-(%a7)
move.l %a2,-(%a7)
move.l (4,%a7),%a1
lea.l (4,%a1),%a2
// new value
move.l (12,%a7),%d2 /*LSB*/
move.l (8,%a7),%d3 /*MSB*/
// test against value
move.l (20,%a7),%d0 /*LSB*/
move.l (16,%a7),%d1 /*MSB*/
cas2.l %d0:%d1,%d2:%d3,(4,%a1):(%a1)
cas2.l %d0:%d1,%d2:%d3,(%a2):(%a1)
// return value
move.l %d0,(4,%a0)
move.l %d1,(%a0)
move.l (%a7)+,%a2
move.l (%a7)+,%d3
move.l (%a7)+,%d2
rts
@ -191,17 +206,20 @@ FUNCTION(atomic_test_and_set64):
FUNCTION(atomic_get64):
move.l %d2,-(%a7)
move.l %d3,-(%a7)
move.l %a2,-(%a7)
move.l (4,%a7),%a1
lea.l (4,%a1),%a2
move.l (4,%a1),%d0 /*LSB*/
move.l (%a1),%d1 /*MSB*/
move.l %d0,%d2
move.l %d1,%d3
// we must use cas... so we change to the same value if matching,
// else we get the correct one anyway
cas2.l %d0:%d1,%d2:%d3,(4,%a1):(%a1)
cas2.l %d0:%d1,%d2:%d3,(%a2):(%a1)
// return value
move.l %d0,(4,%a0)
move.l %d1,(%a0)
move.l (%a7)+,%a2
move.l (%a7)+,%d3
move.l (%a7)+,%d2
rts

View File

@ -2,52 +2,73 @@
** Copyright 2002, Travis Geiselbrecht. All rights reserved.
** Distributed under the terms of the NewOS License.
*/
#warning make sure $ isn't hex
/*
** arg layout:
** r4-r7: arg 1 - 4
** r0-r3: arg 5 - 8
** r8-r13: arg 8 - 13
*/
#define FUNC(name) .align 2 ; .globl _##name ; .type _##name,@function ; _##name:
#define SYSCALL0(name, n) \
FUNC(name) \
moveq.l #$n,%d0 ; \
trap #0 ; \
rts
#define SYSCALL1(name, n) \
FUNC(name) \
moveq.l #$n,%d0 ; \
trap #0 ; \
rts
#define SYSCALL2(name, n) \
FUNC(name) \
moveq.l #$n,%d0 ; \
trap #0 ; \
rts
#define SYSCALL3(name, n) \
FUNC(name) \
moveq.l #$n,%d0 ; \
trap #0 ; \
rts
#define SYSCALL4(name, n) \
FUNC(name) \
moveq.l #$n,%d0 ; \
trap #0 ; \
rts
#define SYSCALL5(name, n) \
FUNC(name) \
moveq.l #$n,%d0 ; \
trap #0 ; \
rts
#define SYSCALL6(name, n) \
FUNC(name) \
moveq.l #$n,%d0 ; \
trap #0 ; \
rts
#define SYSCALL7(name, n) \
FUNC(name) \
moveq.l #$n,%d0 ; \
trap #0 ; \
rts
#define SYSCALL8(name, n) \
FUNC(name) \
moveq.l #$n,%d0 ; \
trap #0 ; \
rts
#define SYSCALL9(name, n) \
FUNC(name) \
moveq.l #$n,%d0 ; \
trap #0 ; \
rts
#define SYSCALL10(name, n) \
FUNC(name) \
moveq.l #$n,%d0 ; \
trap #0 ; \
rts