Skip to content
Permalink
Browse files

arc: Add support for unaligned access

ARCv2 cores may access data not aligned by the data size boundary.
I.e. read entire 32-bit word from address 0x1.

This feature is configurable for ARC EM cores excluding those with
secure shield 2+2 mode. When it's available in hardware it's required
to enable that feature in run-time as well setting status32.AD bit.

Signed-off-by: Alexey Brodkin <abrodkin@synopsys.com>
  • Loading branch information...
abrodkin authored and andrewboie committed Jul 16, 2019
1 parent a312c7a commit 59470146858407c053f80ea1fc9e2f9855cf7ba0
Showing with 24 additions and 0 deletions.
  1. +2 −0 arch/arc/CMakeLists.txt
  2. +9 −0 arch/arc/Kconfig
  3. +7 −0 arch/arc/core/reset.S
  4. +4 −0 arch/arc/core/thread.c
  5. +2 −0 include/arch/arc/v2/aux_regs.h
@@ -10,4 +10,6 @@ zephyr_cc_option(-g3 -gdwarf-2)
# See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63691
zephyr_cc_option(-fno-delete-null-pointer-checks)

zephyr_cc_option_ifdef(CONFIG_ARC_USE_UNALIGNED_MEM_ACCESS -munaligned-access)

add_subdirectory(core)
@@ -116,6 +116,15 @@ config ARC_STACK_PROTECTION
selection of the ARC stack checking is
prioritized over the MPU-based stack guard.

config ARC_USE_UNALIGNED_MEM_ACCESS
bool "Enable unaligned access in HW"
default n if CPU_ARCEM
depends on (CPU_ARCEM && !ARC_HAS_SECURE)
help
ARC EM cores w/o secure shield 2+2 mode support might be configured
to support unaligned memory access which is then disabled by default.
Enable unaligned access in hardware and make software to use it.

config FAULT_DUMP
int "Fault dump level"
default 2
@@ -71,6 +71,13 @@ SECTION_FUNC(TEXT,__start)
bset r0, r0, _ARC_V2_STATUS32_US_BIT
kflag r0
#endif

#ifdef CONFIG_ARC_USE_UNALIGNED_MEM_ACCESS
lr r0, [_ARC_V2_STATUS32]
bset r0, r0, _ARC_V2_STATUS32_AD_BIT
kflag r0
#endif

mov r1, 1

invalidate_and_disable_icache:
@@ -213,6 +213,10 @@ void z_new_thread(struct k_thread *thread, k_thread_stack_t *stack,
#endif
#endif

#ifdef CONFIG_ARC_USE_UNALIGNED_MEM_ACCESS
pInitCtx->status32 |= _ARC_V2_STATUS32_AD;
#endif

thread->switch_handle = thread;
thread->arch.relinquish_cause = _CAUSE_COOP;
thread->callee_saved.sp =
@@ -124,6 +124,8 @@ extern "C" {
#define _ARC_V2_STATUS32_SC (1 << _ARC_V2_STATUS32_SC_BIT)
#define _ARC_V2_STATUS32_ES (1 << 15)
#define _ARC_V2_STATUS32_RB(x) ((x) << 16)
#define _ARC_V2_STATUS32_AD_BIT 19
#define _ARC_V2_STATUS32_AD (1 << _ARC_V2_STATUS32_AD_BIT)
#define _ARC_V2_STATUS32_US_BIT 20
#define _ARC_V2_STATUS32_US (1 << _ARC_V2_STATUS32_US_BIT)
#define _ARC_V2_STATUS32_IE (1 << 31)

0 comments on commit 5947014

Please sign in to comment.
You can’t perform that action at this time.