From 2bbf13b7a5d10443a0130c8024f14b76320886f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Revol?= Date: Thu, 25 Oct 2007 18:45:34 +0000 Subject: [PATCH] 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 --- src/system/libroot/os/arch/m68k/atomic.S | 30 ++++++++++++++---- src/system/libroot/os/arch/m68k/syscalls.inc | 33 ++++++++++++++++---- 2 files changed, 51 insertions(+), 12 deletions(-) diff --git a/src/system/libroot/os/arch/m68k/atomic.S b/src/system/libroot/os/arch/m68k/atomic.S index a87321d177..65b4b6b861 100644 --- a/src/system/libroot/os/arch/m68k/atomic.S +++ b/src/system/libroot/os/arch/m68k/atomic.S @@ -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 diff --git a/src/system/libroot/os/arch/m68k/syscalls.inc b/src/system/libroot/os/arch/m68k/syscalls.inc index 5db2e2d663..5af91bd307 100644 --- a/src/system/libroot/os/arch/m68k/syscalls.inc +++ b/src/system/libroot/os/arch/m68k/syscalls.inc @@ -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