9os

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit 39cb4f0d11e97be5acc091d1ab54f82d2716b550
parent 592cb48e76c4d2b35597dbb9074260c33c87cfac
Author: Dimitris Papastamos <dimitris.papastamos@arm.com>
Date:   Tue, 19 Feb 2019 10:40:03 +0000

Add spinlock implementation

Change-Id: I63422c2a6a7e0b304ff330e3850f3b16006122af
Signed-off-by: Dimitris Papastamos <dimitris.papastamos@arm.com>

Diffstat:
Mconfig/rmode-rcode.mk | 2+-
Mconfig/toolchain/gnu.mk | 3++-
Minclude/bits/amd64/arch/types.h | 2+-
Minclude/bits/arm32/arch/types.h | 2+-
Minclude/bits/arm64/arch/types.h | 2+-
Minclude/bits/i386/arch/types.h | 2+-
Minclude/bits/rmode/arch/types.h | 2+-
Mtarget/hosted/arch.c | 10++++++++++
Mtarget/native/arch.s | 18+++++++++++++++++-
9 files changed, 35 insertions(+), 8 deletions(-)

diff --git a/config/rmode-rcode.mk b/config/rmode-rcode.mk @@ -1,5 +1,5 @@ ARCH = rmode SYS = rcode MODE = native -SYSASFLAGS = $(RCODE_ASFLAGS) +SYSASFLAGS = $(RCODE_ASFLAGS) $(ARMV81_ASFLAGS) SYSCFLAGS = $(RCODE_CFLAGS) diff --git a/config/toolchain/gnu.mk b/config/toolchain/gnu.mk @@ -14,5 +14,6 @@ LINKSCRIPT = -T $(CONFDIR)/toolchain/gnu.ld NOPIE_CFLAGS = -nopie NOPIE_LDFLAGS = -nopie RCODE_CFLAGS = -mgeneral-regs-only -ARM32_CFLAGS = -marm +ARM32_CFLAGS = -marm ARM32_LDFLAGS = -lgcc +ARMV81_ASFLAGS = -march=armv8.1-a diff --git a/include/bits/amd64/arch/types.h b/include/bits/amd64/arch/types.h @@ -1,2 +1,2 @@ typedef int atomic_t; -typedef unsigned char mutex_t; +typedef unsigned long mutex_t; diff --git a/include/bits/arm32/arch/types.h b/include/bits/arm32/arch/types.h @@ -1,2 +1,2 @@ typedef int atomic_t; -typedef unsigned char mutex_t; +typedef unsigned long mutex_t; diff --git a/include/bits/arm64/arch/types.h b/include/bits/arm64/arch/types.h @@ -1,2 +1,2 @@ typedef int atomic_t; -typedef unsigned char mutex_t; +typedef unsigned long mutex_t; diff --git a/include/bits/i386/arch/types.h b/include/bits/i386/arch/types.h @@ -1,2 +1,2 @@ typedef int atomic_t; -typedef unsigned char mutex_t; +typedef unsigned long mutex_t; diff --git a/include/bits/rmode/arch/types.h b/include/bits/rmode/arch/types.h @@ -1,2 +1,2 @@ typedef int atomic_t; -typedef unsigned char mutex_t; +typedef unsigned long mutex_t; diff --git a/target/hosted/arch.c b/target/hosted/arch.c @@ -65,3 +65,13 @@ uint32_t outm32(uint32_t val, void *addr) { } + +void +lock(mutex_t *m) +{ +} + +void +unlock(mutex_t *m) +{ +} diff --git a/target/native/arch.s b/target/native/arch.s @@ -6,6 +6,7 @@ .globl outm8,outm16,outm32 .globl invdcachesetway,invicache,vectbl,doswtch .globl inm8,inm16,inm32,outm8,outm16,outm32 + .globl lock,unlock intr: cmp x0,#0 @@ -66,7 +67,22 @@ outm16: ret outm32: - str w0, [x1] + str w0,[x1] + ret + +lock: + mov w2,#1 + sevl +1: + wfe + mov w1,wzr + casa w1,w2,[x0] + cbnz w1,1b + ret + +unlock: + stlr wzr,[x0] + sev ret dohalt: