From c621de8d2baa06bdbf3b93114c22d866f560ecdd Mon Sep 17 00:00:00 2001 From: r-a-sattarov Date: Sat, 23 Nov 2019 16:40:53 +0300 Subject: [PATCH] E2K: added initial support for MCST Elbrus 2000 --- src/nvcore/Debug.cpp | 7 +++++++ src/nvcore/nvcore.h | 3 +++ src/nvthread/Atomic.h | 17 ++++++++++++++++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/src/nvcore/Debug.cpp b/src/nvcore/Debug.cpp index 829410d..38429e9 100644 --- a/src/nvcore/Debug.cpp +++ b/src/nvcore/Debug.cpp @@ -668,6 +668,13 @@ namespace # elif NV_CPU_AARCH64 ucontext_t * ucp = (ucontext_t *)secret; return (void *) ucp->uc_mcontext.pc; +# elif NV_CPU_E2K /* MCST Elbrus 2000 */ + // e2k has 3 stacks - Procedure Stack (PS), Procedure Chain Stack (PCS) and User Stack (US) + // CR0 and CR1 (Chain Register) are the 128-bit registers of the Procedure Chain Stack (PCS) + // CR's divided into _HI and _LO 64-bit parts (as in x86, for example, AX is divided into AH and AL) + // CR0_HI stores an Instruction Pointer + ucontext_t * ucp = (ucontext_t *)secret; + return (void *) ucp->uc_mcontext.cr0_hi; # else # error "Unknown CPU" # endif diff --git a/src/nvcore/nvcore.h b/src/nvcore/nvcore.h index ecbaa5b..05a062e 100644 --- a/src/nvcore/nvcore.h +++ b/src/nvcore/nvcore.h @@ -98,6 +98,7 @@ // NV_CPU_PPC // NV_CPU_ARM // NV_CPU_ARM_64 +// NV_CPU_E2K #define NV_CPU_STRING POSH_CPU_STRING @@ -112,6 +113,8 @@ # define NV_CPU_ARM 1 #elif defined POSH_CPU_AARCH64 # define NV_CPU_ARM_64 1 +#elif defined POSH_CPU_E2K +# define NV_CPU_E2K 1 #else # error "Unsupported CPU" #endif diff --git a/src/nvthread/Atomic.h b/src/nvthread/Atomic.h index 970fec7..bf5fad2 100644 --- a/src/nvthread/Atomic.h +++ b/src/nvthread/Atomic.h @@ -61,7 +61,7 @@ namespace nv { #elif POSH_CPU_STRONGARM || POSH_CPU_AARCH64 // need more specific cpu type for armv7? // also utilizes a full barrier - // currently treating laod like x86 - this could be wrong + // currently treating load like x86 - this could be wrong // this is the easiest but slowest way to do this nvCompilerReadWriteBarrier(); @@ -78,6 +78,16 @@ namespace nv { uint32 ret = *ptr; // replace with ldrex? nvCompilerReadWriteBarrier(); return ret; +#elif POSH_CPU_E2K + // need more specific cpu type for e2k? + // also utilizes a full barrier + // currently treating load like x86 - this could be wrong + + // this is the easiest but slowest way to do this + nvCompilerReadWriteBarrier(); + uint32 ret = *ptr; // replace with ldrex? + nvCompilerReadWriteBarrier(); + return ret; #else #error "Not implemented" #endif @@ -102,6 +112,11 @@ namespace nv { nvCompilerReadWriteBarrier(); *ptr = value; //strex? nvCompilerReadWriteBarrier(); +#elif POSH_CPU_E2K + // this is the easiest but slowest way to do this + nvCompilerReadWriteBarrier(); + *ptr = value; //strex? + nvCompilerReadWriteBarrier(); #else #error "Atomics not implemented." #endif