2021-05-18 09:57:25 +08:00
|
|
|
/*
|
2024-07-16 16:11:02 +08:00
|
|
|
* Copyright (c) 2006-2024, RT-Thread Development Team
|
2021-05-18 09:57:25 +08:00
|
|
|
*
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
*
|
|
|
|
* Change Logs:
|
|
|
|
* Date Author Notes
|
|
|
|
* 2018-10-03 Bernard The first version
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef CPUPORT_H__
|
|
|
|
#define CPUPORT_H__
|
|
|
|
|
|
|
|
#include <rtconfig.h>
|
|
|
|
|
|
|
|
/* bytes of register width */
|
|
|
|
#ifdef ARCH_CPU_64BIT
|
|
|
|
#define STORE sd
|
|
|
|
#define LOAD ld
|
2024-07-16 16:11:02 +08:00
|
|
|
#define FSTORE fsd
|
|
|
|
#define FLOAD fld
|
2021-05-18 09:57:25 +08:00
|
|
|
#define REGBYTES 8
|
|
|
|
#else
|
|
|
|
// error here, not portable
|
2022-12-03 12:07:44 +08:00
|
|
|
#error "Not supported XLEN"
|
2021-05-18 09:57:25 +08:00
|
|
|
#endif
|
|
|
|
|
2024-06-24 21:36:32 +08:00
|
|
|
/* 33 general register + 1 padding */
|
|
|
|
#define CTX_GENERAL_REG_NR 34
|
2022-12-03 12:07:44 +08:00
|
|
|
|
|
|
|
#ifdef ENABLE_FPU
|
|
|
|
/* 32 fpu register */
|
|
|
|
#define CTX_FPU_REG_NR 32
|
|
|
|
#else
|
|
|
|
#define CTX_FPU_REG_NR 0
|
2021-05-21 17:03:30 +08:00
|
|
|
#endif
|
|
|
|
|
2022-12-03 12:07:44 +08:00
|
|
|
#ifdef ENABLE_VECTOR
|
|
|
|
|
|
|
|
#if defined(ARCH_VECTOR_VLEN_128)
|
|
|
|
#define CTX_VECTOR_REGS 64
|
|
|
|
#elif defined(ARCH_VECTOR_VLEN_256)
|
|
|
|
#define CTX_VECTOR_REGS 128
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define CTX_VECTOR_REG_NR (CTX_VECTOR_REGS + 4)
|
2021-05-21 17:03:30 +08:00
|
|
|
#else
|
2022-12-03 12:07:44 +08:00
|
|
|
#define CTX_VECTOR_REG_NR 0
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/* all context registers */
|
|
|
|
#define CTX_REG_NR (CTX_GENERAL_REG_NR + CTX_FPU_REG_NR + CTX_VECTOR_REG_NR)
|
|
|
|
|
|
|
|
#ifdef RT_USING_SMP
|
|
|
|
typedef union {
|
|
|
|
unsigned long slock;
|
|
|
|
struct __arch_tickets {
|
|
|
|
unsigned short owner;
|
|
|
|
unsigned short next;
|
|
|
|
} tickets;
|
|
|
|
} rt_hw_spinlock_t;
|
2021-05-21 17:03:30 +08:00
|
|
|
#endif
|
|
|
|
|
2022-12-03 12:07:44 +08:00
|
|
|
#ifndef __ASSEMBLY__
|
2023-10-21 20:14:45 +08:00
|
|
|
#include <rtdef.h>
|
2024-02-21 11:45:04 +08:00
|
|
|
rt_inline void rt_hw_dsb(void)
|
2022-12-03 12:07:44 +08:00
|
|
|
{
|
|
|
|
asm volatile("fence":::"memory");
|
|
|
|
}
|
|
|
|
|
2024-02-21 11:45:04 +08:00
|
|
|
rt_inline void rt_hw_dmb(void)
|
2022-12-03 12:07:44 +08:00
|
|
|
{
|
|
|
|
asm volatile("fence":::"memory");
|
|
|
|
}
|
|
|
|
|
2024-02-21 11:45:04 +08:00
|
|
|
rt_inline void rt_hw_isb(void)
|
2022-12-03 12:07:44 +08:00
|
|
|
{
|
|
|
|
asm volatile(".long 0x0000100F":::"memory");
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#ifdef RISCV_U_MODE
|
|
|
|
#define RISCV_USER_ENTRY 0xFFFFFFE000000000ULL
|
2021-05-21 17:03:30 +08:00
|
|
|
#endif
|