Skip to content

Commit

Permalink
arch: add ARMv8-R support
Browse files Browse the repository at this point in the history
JIRA: RTOS-875
  • Loading branch information
lukileczo committed Aug 1, 2024
1 parent 85ceda0 commit 90f1198
Show file tree
Hide file tree
Showing 10 changed files with 403 additions and 0 deletions.
4 changes: 4 additions & 0 deletions arch/arm/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ ifneq (,$(findstring v7a,$(TARGET_SUFF)))
include arch/arm/v7a/Makefile
else ifneq (,$(findstring v7m,$(TARGET_SUFF)))
include arch/arm/v7m/Makefile
else ifneq (,$(findstring v8r,$(TARGET_SUFF)))
include arch/arm/v8r/Makefile
else
$(error Unsupported TARGET)
endif

OBJS += $(addprefix $(PREFIX_O)arch/arm/, jmp.o memcpy.o memset.o signal.o string.o)
Expand Down
9 changes: 9 additions & 0 deletions arch/arm/v8r/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#
# Makefile for libphoenix/arch/arm/v8r
#
# Copyright 2024 Phoenix Systems
#
# %LICENSE%
#

OBJS += $(addprefix $(PREFIX_O)arch/arm/v8r/, syscalls.o reboot.o)
42 changes: 42 additions & 0 deletions arch/arm/v8r/reboot.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Phoenix-RTOS
*
* libphoenix
*
* reboot.c
*
* Copyright 2024 Phoenix Systems
* Author: Lukasz Leczkowski
*
* This file is part of Phoenix-RTOS.
*
* %LICENSE%
*/

#include <sys/reboot.h>
#include <sys/platform.h>
#if defined(__CPU_MPS3AN536)
#include <phoenix/arch/armv8r/mps3an536/mps3an536.h>
#else
#error "Unsupported TARGET"
#endif


int reboot(int magic)
{
platformctl_t pctl = {
.action = pctl_set,
.type = pctl_reboot,
.task.reboot.magic = magic
};

return platformctl(&pctl);
}


int reboot_reason(uint32_t *val)
{
*val = 0u;

return 0;
}
52 changes: 52 additions & 0 deletions arch/arm/v8r/syscalls.S
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* Phoenix-RTOS
*
* libphoenix
*
* syscalls (armv8r)
*
* Copyright 2017, 2018, 2024 Phoenix Systems
* Author; Pawel Pisarczyk, Aleksander Kaminski
*
* This file is part of Phoenix-RTOS.
*
* %LICENSE%
*/

#define __ASSEMBLY__
#include <phoenix/syscalls.h>

.text


#define SYSCALLDEF(sym, sn) \
.globl sym; \
.type sym, %function; \
sym: \
.cfi_startproc; \
push {r0-r3}; \
.cfi_adjust_cfa_offset 16; \
.cfi_rel_offset r0, 0; \
.cfi_rel_offset r1, 4; \
.cfi_rel_offset r2, 8; \
.cfi_rel_offset r3, 12; \
svc $sn; \
add sp, #16; \
.cfi_adjust_cfa_offset -16; \
bx lr; \
.cfi_endproc; \
.size sym, .-sym


.globl vfork;
.type vfork, %function;
vfork:
b vforksvc
.size vfork, .-vfork


#define SYSCALLS_LIBC(name) \
SYSCALLDEF(name, __COUNTER__);


SYSCALLS(SYSCALLS_LIBC)
2 changes: 2 additions & 0 deletions include/arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#include <arch/armv7a/arch.h>
#elif defined(__ARM_ARCH_4T__) || defined(__ARM_ARCH_5TE__) /* not currently supported, map to 7M for libgcc to compile */
#include <arch/armv7m/arch.h>
#elif defined(__ARM_ARCH_8R__)
#include <arch/armv8r/arch.h>
#elif defined(__riscv) && (__riscv_xlen == 64)
#include <arch/riscv64/arch.h>
#elif defined(__sparc__)
Expand Down
64 changes: 64 additions & 0 deletions include/arch/armv8r/arch.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
/*
* Phoenix-RTOS
*
* libphoenix
*
* Architecture dependent part (arch/armv8r)
*
* Copyright 2017, 2024 Phoenix Systems
* Author: Pawel Pisarczyk, Lukasz Leczkowski
*
* This file is part of Phoenix-RTOS.
*
* %LICENSE%
*/

#ifndef _LIBPHOENIX_ARCH_ARMV8R_ARCH_H_
#define _LIBPHOENIX_ARCH_ARMV8R_ARCH_H_

#define __ARCH_STDINT <arch/armv8r/stdint.h>
#define __ARCH_LIMITS <arch/armv8r/limits.h>

#define __MEMCPY
#define __MEMCMP
#define __MEMSET
#define __STRLEN
#define __STRNLEN
#define __STRCMP
#define __STRNCMP
#define __STRCPY
#define __STRNCPY
#define __MEMMOVE

#if __ARM_PCS_VFP || (__VFP_FP__ && !__SOFTFP__)
#if __ARM_FP & 8
#define __IEEE754_SQRT

static inline double __ieee754_sqrt(double x)
{
/* clang-format off */
__asm__ volatile ("vsqrt.f64 %P0, %P1" : "=w"(x) : "w"(x));
/* clang-format on */

return x;
}
#endif

#define __IEEE754_SQRTF

static inline float __ieee754_sqrtf(float x)
{
/* clang-format off */
__asm__ volatile ("vsqrt.f32 %0, %1" : "=t"(x) : "t"(x));
/* clang-format on */

return x;
}
#endif

#define _PAGE_SIZE 0x200
#define SIZE_PAGE _Pragma("GCC warning \"'SIZE_PAGE' is deprecated. Use _PAGE_SIZE from arch.h or PAGE_SIZE from limits.h (POSIX only)\"") _PAGE_SIZE

#define __LIBPHOENIX_ARCH_TLS_SUPPORTED

#endif
66 changes: 66 additions & 0 deletions include/arch/armv8r/limits.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
* Phoenix-RTOS
*
* libphoenix
*
* Architecture dependent part of limits (arch/armv8r)
*
* Copyright 2017-2019, 2024 Phoenix Systems
* Author: Pawel Pisarczyk, Aleksander Kaminski, Andrzej Glowinski, Marek Bialowas
*
* This file is part of Phoenix-RTOS.
*
* %LICENSE%
*/

#ifndef _LIBPHOENIX_ARCH_ARMV8R_LIMITS_H_
#define _LIBPHOENIX_ARCH_ARMV8R_LIMITS_H_

#include "arch.h"

#define SCHAR_MIN -128
#define SCHAR_MAX 127
#define UCHAR_MAX 255

#define CHAR_MIN 0
#define CHAR_MAX UCHAR_MAX
#define CHAR_BIT 8

#define MB_LEN_MAX 4

#define SHRT_MIN -32768
#define SHRT_MAX 32767
#define USHRT_MAX 65535

#define INT_MIN -2147483648
#define INT_MAX 0x7fffffff
#define UINT_MAX 0xffffffff

#define LONG_MIN INT_MIN
#define LONG_MAX INT_MAX
#define ULONG_MAX UINT_MAX

#define LONG_LONG_MIN 0x8000000000000000LL
#define LONG_LONG_MAX 0x7fffffffffffffffLL
#define ULONG_LONG_MAX 0xffffffffffffffffLL
#define LLONG_MIN LONG_LONG_MIN
#define LLONG_MAX LONG_LONG_MAX
#define ULLONG_MAX ULONG_LONG_MAX

#define SSIZE_MAX INT_MAX

#define PAGE_SIZE _PAGE_SIZE
#define PAGESIZE _PAGE_SIZE

#define PTHREAD_STACK_MIN 256

/*** POSIX-required defines ***/

#define PATH_MAX 256 /* Maximum number of bytes the implementation will store as a pathname in a user-supplied buffer of unspecified size, including the terminating null character. MIN: 256 */
#define NAME_MAX 64 /* Maximum number of bytes in a filename (not including the terminating null of a filename string). MIN: 14 */
#define ARG_MAX 1500 /* Maximum length of argument to the exec functions including environment data. MIN: 4096 */
#define SYMLOOP_MAX 8 /* Maximum number of symbolic links that can be reliably traversed in the resolution of a pathname in the absence of a loop. MIN: 8 */

#define _POSIX2_RE_DUP_MAX 255

#endif
37 changes: 37 additions & 0 deletions include/arch/armv8r/setjmp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Phoenix-RTOS
*
* libphoenix
*
* arch-dependent part of setjmp.h
*
* Copyright 2024 Phoenix Systems
* Author: Lukasz Leczkowski
*
* This file is part of Phoenix-RTOS.
*
* %LICENSE%
*/

#ifndef _LIBPHOENIX_ARCH_ARMV8R_SETJMP_H_
#define _LIBPHOENIX_ARCH_ARMV8R_SETJMP_H_


#include <phoenix/arch/armv8r/stdtypes.h>


struct __jmp_buf {
__u32 sigFlg;
__u32 sigMsk;
__u32 sp;
__u32 r[8];
__u32 lr;

#ifndef __SOFTFP__
__u64 d[8];
__u32 fpscr;
#endif
} __attribute__((packed, aligned(8)));


#endif
Loading

0 comments on commit 90f1198

Please sign in to comment.