mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-11-17 07:05:31 +08:00
[libcpu]rv添加c908 cpu
This commit is contained in:
1 parent
cee64a41a4
commit
af5ca55736
14 files changed
+1387
-1
No files matched your search
@@ -5,7 +5,7 @@ from building import *
|
||||
|
||||
Import('rtconfig')
|
||||
|
||||
common64_arch = ['virt64', 'c906']
|
||||
common64_arch = ['virt64', 'c906', 'c908']
|
||||
cwd = GetCurrentDir()
|
||||
group = []
|
||||
list = os.listdir(cwd)
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
# RT-Thread building script for component
|
||||
|
||||
from building import *
|
||||
cwd = GetCurrentDir()
|
||||
src = Glob('*.c') + Glob('*.cpp') + Glob('*_gcc.S')
|
||||
CPPPATH = [cwd]
|
||||
|
||||
if not GetDepend('ARCH_USING_ASID'):
|
||||
SrcRemove(src, ['asid.c'])
|
||||
|
||||
group = DefineGroup('libcpu', src, depend = [''], CPPPATH = CPPPATH)
|
||||
|
||||
Return('group')
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifndef _SBI_ASM_H
|
||||
#define _SBI_ASM_H
|
||||
|
||||
.macro SBI_CALL which
|
||||
li a7, \which
|
||||
ecall
|
||||
nop
|
||||
.endm
|
||||
|
||||
#endif /* _SBI_ASM_H */
|
||||
@@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Copyright (c) 2019-2020, Xim
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
*/
|
||||
#ifndef _ASM_SBI_DEF_H
|
||||
#define _ASM_SBI_DEF_H
|
||||
|
||||
#define SBI_SET_TIMER 0
|
||||
#define SBI_CONSOLE_PUTCHAR 1
|
||||
#define SBI_CONSOLE_GETCHAR 2
|
||||
#define SBI_CLEAR_IPI 3
|
||||
#define SBI_SEND_IPI 4
|
||||
#define SBI_REMOTE_FENCE_I 5
|
||||
#define SBI_REMOTE_SFENCE_VMA 6
|
||||
#define SBI_REMOTE_SFENCE_VMA_ASID 7
|
||||
#define SBI_SHUTDOWN 8
|
||||
|
||||
#define SBI_CONSOLE_PUTSTR 9
|
||||
|
||||
#define SBI_SD_WRITE 10
|
||||
#define SBI_SD_READ 11
|
||||
#define SBI_NET_WRITE 12
|
||||
#define SBI_NET_READ 13
|
||||
|
||||
#endif /* _ASM_SBI_DEF_H */
|
||||
@@ -0,0 +1,140 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-01-29 lizhirui first version
|
||||
* 2021-11-05 JasonHu add C908 cache inst
|
||||
* 2022-11-09 WangXiaoyao Support cache coherence operations;
|
||||
* improve portability and make
|
||||
* no assumption on undefined behavior
|
||||
*/
|
||||
|
||||
#include <rthw.h>
|
||||
#include <rtdef.h>
|
||||
#include <board.h>
|
||||
#include <riscv.h>
|
||||
|
||||
#include "opcode.h"
|
||||
#include "cache.h"
|
||||
|
||||
#define L1_CACHE_BYTES (64)
|
||||
|
||||
/**
|
||||
* GCC version not support t-head cache flush, so we use fixed code to achieve.
|
||||
* The following function cannot be optimized.
|
||||
*/
|
||||
static void dcache_wb_range(unsigned long start, unsigned long end) __attribute__((optimize("O0")));
|
||||
static void dcache_inv_range(unsigned long start, unsigned long end) __attribute__((optimize("O0")));
|
||||
static void dcache_wbinv_range(unsigned long start, unsigned long end) __attribute__((optimize("O0")));
|
||||
static void icache_inv_range(unsigned long start, unsigned long end) __attribute__((optimize("O0")));
|
||||
|
||||
#define CACHE_OP_RS1 %0
|
||||
#define CACHE_OP_RANGE(instr) \
|
||||
{ \
|
||||
rt_ubase_t i = start & ~(L1_CACHE_BYTES - 1); \
|
||||
for (; i < end; i += L1_CACHE_BYTES) \
|
||||
{ \
|
||||
__asm__ volatile(instr ::"r"(i) \
|
||||
: "memory"); \
|
||||
} \
|
||||
}
|
||||
|
||||
static void dcache_wb_range(unsigned long start, unsigned long end)
|
||||
{
|
||||
CACHE_OP_RANGE(OPC_DCACHE_CVA(CACHE_OP_RS1));
|
||||
}
|
||||
|
||||
static void dcachel1_wb_range(unsigned long start, unsigned long end)
|
||||
{
|
||||
CACHE_OP_RANGE(OPC_DCACHE_CVAL1(CACHE_OP_RS1));
|
||||
}
|
||||
|
||||
static void dcache_inv_range(unsigned long start, unsigned long end)
|
||||
{
|
||||
CACHE_OP_RANGE(OPC_DCACHE_IVA(CACHE_OP_RS1));
|
||||
}
|
||||
|
||||
static void dcache_wbinv_range(unsigned long start, unsigned long end)
|
||||
{
|
||||
CACHE_OP_RANGE(OPC_DCACHE_CIVA(CACHE_OP_RS1));
|
||||
}
|
||||
|
||||
static void icache_inv_range(unsigned long start, unsigned long end)
|
||||
{
|
||||
CACHE_OP_RANGE(OPC_ICACHE_IVA(CACHE_OP_RS1));
|
||||
}
|
||||
|
||||
rt_inline rt_uint32_t rt_cpu_icache_line_size(void)
|
||||
{
|
||||
return L1_CACHE_BYTES;
|
||||
}
|
||||
|
||||
rt_inline rt_uint32_t rt_cpu_dcache_line_size(void)
|
||||
{
|
||||
return L1_CACHE_BYTES;
|
||||
}
|
||||
|
||||
void rt_hw_cpu_icache_invalidate_local(void *addr, int size)
|
||||
{
|
||||
icache_inv_range((unsigned long)addr, (unsigned long)((unsigned char *)addr + size));
|
||||
rt_hw_cpu_sync_i();
|
||||
}
|
||||
|
||||
void rt_hw_cpu_dcache_invalidate_local(void *addr, int size)
|
||||
{
|
||||
dcache_inv_range((unsigned long)addr, (unsigned long)((unsigned char *)addr + size));
|
||||
rt_hw_cpu_sync();
|
||||
}
|
||||
|
||||
void rt_hw_cpu_dcache_clean_local(void *addr, int size)
|
||||
{
|
||||
dcache_wb_range((unsigned long)addr, (unsigned long)((unsigned char *)addr + size));
|
||||
rt_hw_cpu_sync();
|
||||
}
|
||||
|
||||
void rt_hw_cpu_dcache_clean_invalidate_local(void *addr, int size)
|
||||
{
|
||||
dcache_wbinv_range((unsigned long)addr, (unsigned long)((unsigned char *)addr + size));
|
||||
rt_hw_cpu_sync();
|
||||
}
|
||||
|
||||
void rt_hw_cpu_dcachel1_clean_local(void *addr, int size)
|
||||
{
|
||||
__asm__ volatile(OPC_DCACHE_CVAL1(a0)::
|
||||
: "memory");
|
||||
}
|
||||
|
||||
/**
|
||||
* =====================================================
|
||||
* Architecture Independent API
|
||||
* =====================================================
|
||||
*/
|
||||
|
||||
void rt_hw_cpu_icache_ops(int ops, void *addr, int size)
|
||||
{
|
||||
if (ops == RT_HW_CACHE_INVALIDATE)
|
||||
{
|
||||
rt_hw_cpu_icache_invalidate(addr, size);
|
||||
}
|
||||
}
|
||||
|
||||
void rt_hw_cpu_dcache_ops(int ops, void *addr, int size)
|
||||
{
|
||||
if (ops == RT_HW_CACHE_FLUSH)
|
||||
{
|
||||
rt_hw_cpu_dcache_clean(addr, size);
|
||||
}
|
||||
else
|
||||
{
|
||||
rt_hw_cpu_dcache_invalidate(addr, size);
|
||||
}
|
||||
}
|
||||
|
||||
void rt_hw_sync_cache_local(void *addr, int size)
|
||||
{
|
||||
rt_hw_cpu_dcachel1_clean_local(addr, size);
|
||||
rt_hw_cpu_icache_invalidate_local(addr, size);
|
||||
}
|
||||
@@ -0,0 +1,127 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-11-05 JasonHu The first version
|
||||
* 2022-11-09 WangXiaoyao Distinguish local and broadcast operations
|
||||
*/
|
||||
|
||||
#ifndef CACHE_H__
|
||||
#define CACHE_H__
|
||||
|
||||
#include "opcode.h"
|
||||
|
||||
#ifndef ALWAYS_INLINE
|
||||
#define ALWAYS_INLINE inline __attribute__((always_inline))
|
||||
#endif
|
||||
|
||||
ALWAYS_INLINE void rt_hw_cpu_sync(void)
|
||||
{
|
||||
asm volatile(OPC_SYNC::
|
||||
: "memory");
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void rt_hw_cpu_sync_i(void)
|
||||
{
|
||||
asm volatile(OPC_SYNC_I::
|
||||
: "memory");
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void rt_hw_cpu_sync_s(void)
|
||||
{
|
||||
asm volatile(OPC_SYNC_S::
|
||||
: "memory");
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void rt_hw_cpu_sync_is(void)
|
||||
{
|
||||
asm volatile(OPC_SYNC_IS::
|
||||
: "memory");
|
||||
}
|
||||
|
||||
/**
|
||||
* ========================================
|
||||
* Local cpu cache maintainence operations
|
||||
* ========================================
|
||||
*/
|
||||
|
||||
void rt_hw_cpu_dcache_clean_local(void *addr, int size);
|
||||
void rt_hw_cpu_dcache_invalidate_local(void *addr, int size);
|
||||
void rt_hw_cpu_dcache_clean_invalidate_local(void *addr, int size);
|
||||
|
||||
void rt_hw_cpu_icache_invalidate_local(void *addr, int size);
|
||||
|
||||
ALWAYS_INLINE void rt_hw_cpu_dcache_clean_all_local(void)
|
||||
{
|
||||
__asm__ volatile(OPC_DCACHE_CALL ::
|
||||
: "memory");
|
||||
rt_hw_cpu_sync();
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void rt_hw_cpu_dcache_invalidate_all_local(void)
|
||||
{
|
||||
__asm__ volatile(OPC_DCACHE_IALL ::
|
||||
: "memory");
|
||||
rt_hw_cpu_sync();
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void rt_hw_cpu_dcache_clean_invalidate_all_local(void)
|
||||
{
|
||||
__asm__ volatile(OPC_DCACHE_CIALL ::
|
||||
: "memory");
|
||||
rt_hw_cpu_sync();
|
||||
}
|
||||
|
||||
ALWAYS_INLINE void rt_hw_cpu_icache_invalidate_all_local(void)
|
||||
{
|
||||
__asm__ volatile(OPC_ICACHE_IALL ::
|
||||
: "memory");
|
||||
rt_hw_cpu_sync_i();
|
||||
}
|
||||
|
||||
#define rt_hw_icache_invalidate_all rt_hw_cpu_icache_invalidate_all
|
||||
|
||||
/**
|
||||
* ========================================
|
||||
* Multi-core cache maintainence operations
|
||||
* ========================================
|
||||
*/
|
||||
|
||||
#ifdef RT_USING_SMP
|
||||
#error "TODO: cache maintainence have not ported to RISC-V SMP yet"
|
||||
|
||||
void rt_hw_cpu_dcache_clean(void *addr, int size);
|
||||
void rt_hw_cpu_dcache_invalidate(void *addr, int size);
|
||||
void rt_hw_cpu_dcache_clean_invalidate(void *addr, int size);
|
||||
|
||||
void rt_hw_cpu_dcache_clean_all(void);
|
||||
void rt_hw_cpu_dcache_invalidate_all(void);
|
||||
void rt_hw_cpu_dcache_clean_invalidate_all(void);
|
||||
|
||||
void rt_hw_cpu_icache_invalidate(void *addr, int size);
|
||||
void rt_hw_cpu_icache_invalidate_all(void);
|
||||
|
||||
#else /* !RT_USING_SMP */
|
||||
|
||||
#define rt_hw_cpu_dcache_clean rt_hw_cpu_dcache_clean_local
|
||||
#define rt_hw_cpu_dcache_invalidate rt_hw_cpu_dcache_invalidate_local
|
||||
#define rt_hw_cpu_dcache_clean_and_invalidate rt_hw_cpu_dcache_clean_invalidate_local
|
||||
|
||||
#define rt_hw_cpu_dcache_clean_all rt_hw_cpu_dcache_clean_all_local
|
||||
#define rt_hw_cpu_dcache_invalidate_all rt_hw_cpu_dcache_invalidate_all_local
|
||||
#define rt_hw_cpu_dcache_clean_invalidate_all rt_hw_cpu_dcache_clean_invalidate_all_local
|
||||
|
||||
#define rt_hw_cpu_icache_invalidate rt_hw_cpu_icache_invalidate_local
|
||||
#define rt_hw_cpu_icache_invalidate_all rt_hw_cpu_icache_invalidate_all_local
|
||||
|
||||
#endif /* RT_USING_SMP */
|
||||
|
||||
/**
|
||||
* @brief Synchronize cache to Point of Unification
|
||||
*/
|
||||
void rt_hw_sync_cache_local(void *addr, int size);
|
||||
|
||||
#endif /* CACHE_H__ */
|
||||
@@ -0,0 +1,105 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-10-19 JasonHu first version
|
||||
*/
|
||||
|
||||
#include <rthw.h>
|
||||
#include <rtthread.h>
|
||||
|
||||
#include "interrupt.h"
|
||||
#include "riscv.h"
|
||||
#include "plic.h"
|
||||
|
||||
extern rt_uint32_t rt_interrupt_nest;
|
||||
extern rt_uint32_t rt_interrupt_from_thread, rt_interrupt_to_thread;
|
||||
extern rt_uint32_t rt_thread_switch_interrupt_flag;
|
||||
|
||||
struct rt_irq_desc isr_table[INTERRUPTS_MAX];
|
||||
|
||||
static void rt_hw_interrupt_handler(int vector, void *param)
|
||||
{
|
||||
rt_kprintf("Unhandled interrupt %d occured!!!\n", vector);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will initialize hardware interrupt
|
||||
*/
|
||||
void rt_hw_interrupt_init(void)
|
||||
{
|
||||
/* init interrupt controller */
|
||||
plic_init();
|
||||
|
||||
rt_int32_t idx;
|
||||
|
||||
rt_memset(isr_table, 0x00, sizeof(isr_table));
|
||||
for (idx = 0; idx < INTERRUPTS_MAX; idx++)
|
||||
{
|
||||
isr_table[idx].handler = rt_hw_interrupt_handler;
|
||||
}
|
||||
|
||||
/* init interrupt nest, and context in thread sp */
|
||||
rt_interrupt_nest = 0;
|
||||
rt_interrupt_from_thread = 0;
|
||||
rt_interrupt_to_thread = 0;
|
||||
rt_thread_switch_interrupt_flag = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will mask a interrupt.
|
||||
* @param vector the interrupt number
|
||||
*/
|
||||
void rt_hw_interrupt_mask(int vector)
|
||||
{
|
||||
if ((vector < 0) || (vector > IRQ_MAX_NR))
|
||||
{
|
||||
return;
|
||||
}
|
||||
plic_disable_irq(vector);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
* This function will un-mask a interrupt.
|
||||
* @param vector the interrupt number
|
||||
*/
|
||||
void rt_hw_interrupt_umask(int vector)
|
||||
{
|
||||
if ((vector < 0) || (vector > IRQ_MAX_NR))
|
||||
{
|
||||
return;
|
||||
}
|
||||
plic_enable_irq(vector);
|
||||
}
|
||||
|
||||
/**
|
||||
* This function will install a interrupt service routine to a interrupt.
|
||||
* @param vector the interrupt number
|
||||
* @param handler the interrupt service routine to be installed
|
||||
* @param param the interrupt service function parameter
|
||||
* @param name the interrupt name
|
||||
* @return old handler
|
||||
*/
|
||||
rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler,
|
||||
void *param, const char *name)
|
||||
{
|
||||
rt_isr_handler_t old_handler = RT_NULL;
|
||||
if ((vector < 0) || (vector > IRQ_MAX_NR))
|
||||
{
|
||||
return old_handler;
|
||||
}
|
||||
|
||||
old_handler = isr_table[IRQ_OFFSET + vector].handler;
|
||||
|
||||
#ifdef RT_USING_INTERRUPT_INFO
|
||||
rt_strncpy(isr_table[IRQ_OFFSET + vector].name, name, RT_NAME_MAX);
|
||||
#endif /* RT_USING_INTERRUPT_INFO */
|
||||
isr_table[IRQ_OFFSET + vector].handler = handler;
|
||||
isr_table[IRQ_OFFSET + vector].param = param;
|
||||
|
||||
return old_handler;
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2023, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-10-19 JasonHu first version
|
||||
*/
|
||||
|
||||
#ifndef __INTERRUPT_H__
|
||||
#define __INTERRUPT_H__
|
||||
|
||||
#include <rthw.h>
|
||||
|
||||
#define NR_CPUS 1
|
||||
|
||||
#define IRQ_OFFSET 16
|
||||
#ifndef IRQ_MAX_NR
|
||||
#define IRQ_MAX_NR 200
|
||||
#endif
|
||||
#define INTERRUPTS_MAX (IRQ_OFFSET + IRQ_MAX_NR)
|
||||
|
||||
enum {
|
||||
EP_INSTRUCTION_ADDRESS_MISALIGNED = 0,
|
||||
EP_INSTRUCTION_ACCESS_FAULT,
|
||||
EP_ILLEGAL_INSTRUCTION,
|
||||
EP_BREAKPOINT,
|
||||
EP_LOAD_ADDRESS_MISALIGNED,
|
||||
EP_LOAD_ACCESS_FAULT,
|
||||
EP_STORE_ADDRESS_MISALIGNED,
|
||||
EP_STORE_ACCESS_FAULT,
|
||||
EP_ENVIRONMENT_CALL_U_MODE,
|
||||
EP_ENVIRONMENT_CALL_S_MODE,
|
||||
EP_RESERVED10,
|
||||
EP_ENVIRONMENT_CALL_M_MODE,
|
||||
EP_INSTRUCTION_PAGE_FAULT, /* page attr */
|
||||
EP_LOAD_PAGE_FAULT, /* read data */
|
||||
EP_RESERVED14,
|
||||
EP_STORE_PAGE_FAULT, /* write data */
|
||||
};
|
||||
|
||||
void rt_hw_interrupt_init(void);
|
||||
void rt_hw_interrupt_mask(int vector);
|
||||
void rt_hw_interrupt_umask(int vector);
|
||||
rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler, void *param, const char *name);
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,92 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2021, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2022-11-09 WangXiaoyao Add portable asm support
|
||||
* 2022-03-16 WangXiaoyao Porting to xtheadsync & xtheadcmo ISA extension
|
||||
*/
|
||||
#ifndef __OPCODE_H__
|
||||
#define __OPCODE_H__
|
||||
|
||||
/**
|
||||
* @brief binary opcode pseudo operations
|
||||
* Used to bypass toolchain restriction on extension ISA
|
||||
*
|
||||
* WARNING: Xuantie ISAs are not compatible to each other in opcode.
|
||||
* It's painful to port this file, and should be really careful.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @brief RISC-V instruction formats
|
||||
*/
|
||||
|
||||
/**
|
||||
* R type: .insn r opcode6, func3, func7, rd, rs1, rs2
|
||||
*
|
||||
* +-------+-----+-----+-------+----+---------+
|
||||
* | func7 | rs2 | rs1 | func3 | rd | opcode6 |
|
||||
* +-------+-----+-----+-------+----+---------+
|
||||
* 31 25 20 15 12 7 0
|
||||
*/
|
||||
#define __OPC_INSN_FORMAT_R(opcode, func3, func7, rd, rs1, rs2) \
|
||||
".insn r "RT_STRINGIFY(opcode)","RT_STRINGIFY(func3)","RT_STRINGIFY(func7)","RT_STRINGIFY(rd)","RT_STRINGIFY(rs1)","RT_STRINGIFY(rs2)
|
||||
|
||||
/**
|
||||
* @brief Xuantie T-HEAD extension ISA format
|
||||
* Compatible to Xuantie C908 user manual v03
|
||||
*/
|
||||
#define __OPC_INSN_FORMAT_CACHE(func7, rs2, rs1) \
|
||||
__OPC_INSN_FORMAT_R(0x0b, 0x0, func7, x0, rs1, rs2)
|
||||
|
||||
#ifdef _TOOLCHAIN_SUPP_XTHEADE_ISA_
|
||||
#define OPC_SYNC "sync"
|
||||
#define OPC_SYNC_S "sync.s"
|
||||
#define OPC_SYNC_I "sync.i"
|
||||
#define OPC_SYNC_IS "sync.is"
|
||||
|
||||
#define OPC_DCACHE_CALL "dcache.call"
|
||||
#define OPC_DCACHE_IALL "dcache.iall"
|
||||
#define OPC_DCACHE_CIALL "dcache.ciall"
|
||||
#define OPC_DCACHE_CVAL1(rs1) "dcache.cval1 "_TOSTR(rs1)
|
||||
|
||||
#define OPC_ICACHE_IALL "icache.iall"
|
||||
|
||||
#define OPC_DCACHE_CVA(rs1) "dcache.cva "RT_STRINGIFY(rs1)
|
||||
#define OPC_DCACHE_IVA(rs1) "dcache.iva "RT_STRINGIFY(rs1)
|
||||
#define OPC_DCACHE_CIVA(rs1) "dcache.civa "RT_STRINGIFY(rs1)
|
||||
|
||||
#define OPC_ICACHE_IVA(rs1) "icache.iva "RT_STRINGIFY(rs1)
|
||||
#else /* !_TOOLCHAIN_NOT_SUPP_THEAD_ISA_ */
|
||||
|
||||
#define OPC_SYNC ".long 0x0180000B"
|
||||
#define OPC_SYNC_S ".long 0x0190000B"
|
||||
#define OPC_SYNC_I ".long 0x01A0000B"
|
||||
#define OPC_SYNC_IS ".long 0x01B0000B"
|
||||
|
||||
#define OPC_DCACHE_CALL ".long 0x0010000B"
|
||||
#define OPC_DCACHE_IALL ".long 0x0020000B"
|
||||
#define OPC_DCACHE_CIALL ".long 0x0030000B"
|
||||
#define OPC_DCACHE_CVAL1(rs1) __OPC_INSN_FORMAT_CACHE(0x1, x4, rs1)
|
||||
|
||||
#define OPC_ICACHE_IALL ".long 0x0100000B"
|
||||
|
||||
#define OPC_DCACHE_CVA(rs1) __OPC_INSN_FORMAT_CACHE(0x1, x5, rs1)
|
||||
#define OPC_DCACHE_IVA(rs1) __OPC_INSN_FORMAT_CACHE(0x1, x6, rs1)
|
||||
#define OPC_DCACHE_CIVA(rs1) __OPC_INSN_FORMAT_CACHE(0x1, x7, rs1)
|
||||
|
||||
#define OPC_ICACHE_IVA(rs1) __OPC_INSN_FORMAT_CACHE(0x1, x16, rs1)
|
||||
#endif /* _TOOLCHAIN_NOT_SUPP_THEAD_ISA_ */
|
||||
|
||||
/**
|
||||
* @brief RISC-V zifencei ISA
|
||||
*/
|
||||
#ifdef _TOOLCHAIN_SUPP_ZIFENCEI_ISA_
|
||||
#define OPC_FENCE_I "fence.i"
|
||||
#else /* !_TOOLCHAIN_SUPP_ZIFENCEI_ISA_ */
|
||||
#define OPC_FENCE_I ".long 0x0000100F"
|
||||
#endif /* _TOOLCHAIN_SUPP_ZIFENCEI_ISA_ */
|
||||
|
||||
#endif /* __OPCODE_H__ */
|
||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,60 @@
|
||||
/*
|
||||
* Copyright (c) 2006-2023, RT-Thread Development Team
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-10-19 JasonHu first version
|
||||
* 2023-04-22 flyingcys add C906_PLIC_PHY_ADDR macro judge
|
||||
*/
|
||||
|
||||
#ifndef __RISCV64_PLIC_H__
|
||||
#define __RISCV64_PLIC_H__
|
||||
|
||||
#include <interrupt.h>
|
||||
|
||||
#ifndef C908_PLIC_PHY_ADDR
|
||||
#define C908_PLIC_PHY_ADDR (0xF00000000UL)
|
||||
#endif
|
||||
#define C908_PLIC_NR_EXT_IRQS (IRQ_MAX_NR)
|
||||
#define C908_NR_CPUS (NR_CPUS)
|
||||
|
||||
/* M and S mode context. */
|
||||
#define C908_NR_CONTEXT (2)
|
||||
|
||||
#define MAX_DEVICES 1024
|
||||
#define MAX_CONTEXTS 15872
|
||||
|
||||
/*
|
||||
* Each interrupt source has a priority register associated with it.
|
||||
* We always hardwire it to one in Linux.
|
||||
*/
|
||||
#define PRIORITY_BASE 0
|
||||
#define PRIORITY_PER_ID 4
|
||||
|
||||
/*
|
||||
* Each hart context has a vector of interrupt enable bits associated with it.
|
||||
* There's one bit for each interrupt source.
|
||||
*/
|
||||
#define ENABLE_BASE 0x2000
|
||||
#define ENABLE_PER_HART 0x80
|
||||
|
||||
/*
|
||||
* Each hart context has a set of control registers associated with it. Right
|
||||
* now there's only two: a source priority threshold over which the hart will
|
||||
* take an interrupt, and a register to claim interrupts.
|
||||
*/
|
||||
#define CONTEXT_BASE 0x200000
|
||||
#define CONTEXT_PER_HART 0x1000
|
||||
#define CONTEXT_THRESHOLD 0x00
|
||||
#define CONTEXT_CLAIM 0x04
|
||||
|
||||
void plic_init(void);
|
||||
void plic_enable_irq(int irqno);
|
||||
void plic_disable_irq(int irqno);
|
||||
// tell PLIC that we've served this IRQ
|
||||
void plic_complete(int irq);
|
||||
void plic_handle_irq(void);
|
||||
|
||||
#endif
|
||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,44 @@
|
||||
/*
|
||||
* Copyright lizhirui
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Change Logs:
|
||||
* Date Author Notes
|
||||
* 2021-05-18 lizhirui the first version
|
||||
* 2021-05-20 lizhirui add os debug support
|
||||
*/
|
||||
|
||||
#ifndef __SYMBOL_ANALYSIS_H__
|
||||
#define __SYMBOL_ANALYSIS_H__
|
||||
|
||||
#include <rtthread.h>
|
||||
|
||||
//osdebug节区头描述结构体
|
||||
typedef struct os_symtab_header
|
||||
{
|
||||
rt_size_t function_table_offset;//函数表的偏移地址(相对于节区起始地址,下同)
|
||||
rt_size_t function_table_num;//函数表中的符号数量
|
||||
rt_size_t object_table_offset;//对象表的偏移地址
|
||||
rt_size_t object_table_num;//对象表中的符号数量
|
||||
rt_size_t general_symbol_table_offset;//一般符号(指代类型虽为NONE但带有GLOBAL的符号)表的偏移地址
|
||||
rt_size_t general_symbol_table_num;//一般符号表中的符号数量
|
||||
rt_size_t string_table_offset;//字符串表的偏移地址
|
||||
rt_size_t string_table_size;//字符串表的大小(字节为单位)
|
||||
}os_symtab_header;
|
||||
|
||||
//符号描述结构体
|
||||
typedef struct os_symtab_item
|
||||
{
|
||||
rt_size_t name_offset;//符号名称在字符串表中的偏移地址
|
||||
rt_size_t address;//该符号所代表的地址
|
||||
rt_size_t size;//该符号所代表的大小
|
||||
}os_symtab_item;
|
||||
|
||||
os_symtab_item *find_symbol_table(rt_size_t symbol_table_addr,rt_size_t symbol_num,rt_size_t address);
|
||||
const char *get_symbol_name(os_symtab_item *symbol);
|
||||
void print_symbol(os_symtab_item *symbol,rt_size_t address);
|
||||
void print_symbol_info(rt_size_t address,rt_bool_t function);
|
||||
void print_stacktrace(rt_size_t epc,rt_size_t fp);
|
||||
|
||||
#endif
|
||||
Reference in new issue
Block a user