Skip to content

Commit c3d33f3

Browse files
[bsp]增加超睿DP1000 bsp支持
1 parent 890a4ba commit c3d33f3

35 files changed

+4488
-2
lines changed

.github/ALL_BSP_COMPILE.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,8 @@
389389
"RTT_TOOL_CHAIN": "sourcery-riscv64-unknown-elf",
390390
"SUB_RTT_BSP": [
391391
"bluetrum/ab32vg1-ab-prougen",
392-
"qemu-virt64-riscv"
392+
"qemu-virt64-riscv",
393+
"ultrarisc/ur_dp1000_evb"
393394
]
394395
},
395396
{

MAINTAINERS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,3 +82,7 @@ owners: supper thomas(supperthomas)<[email protected]>, Bingru Zhang(Rbb666)<75106
8282
tag: gd32470z-lckfb-lcd
8383
path: bsp/gd32/arm/gd32470z-lckfb/board/ports
8484
owners: Wu Ying Xiang(godmial)<[email protected]>
85+
86+
tag: bsp_ultrarisc
87+
path: bsp/ultrarisc/ur_dp1000_evb
88+
owners: Zhang Jing(zhangjing0303)<[email protected]>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# RT-Thread building script for component
2+
3+
from building import *
4+
cwd = GetCurrentDir()
5+
src = Glob('*.c') + Glob('*.cpp')
6+
CPPPATH = [cwd]
7+
8+
group = DefineGroup('arch', src, depend = [''], CPPPATH = CPPPATH)
9+
10+
objs = [group]
11+
12+
Return('objs')

bsp/ultrarisc/arch/ur-cp100/cache.c

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright (c) 2006-2025 RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2021-01-29 lizhirui first version
9+
* 2025-05-29 Zhang Jing remove redundant code
10+
*/
11+
12+
#include <rthw.h>
13+
#include <rtdef.h>
14+
#include <board.h>
15+
#include <riscv.h>
16+
#include <cache.h>
17+
18+
void rt_hw_cpu_icache_ops(int ops, void *addr, int size)
19+
{
20+
if (ops == RT_HW_CACHE_INVALIDATE)
21+
{
22+
rt_hw_cpu_icache_invalidate(addr, size);
23+
}
24+
return;
25+
}
26+
27+
void rt_hw_cpu_dcache_ops(int ops, void *addr, int size)
28+
{
29+
if (ops == RT_HW_CACHE_FLUSH)
30+
{
31+
rt_hw_cpu_dcache_clean(addr, size);
32+
}
33+
else
34+
{
35+
rt_hw_cpu_dcache_invalidate(addr, size);
36+
}
37+
return;
38+
}
39+
40+
void rt_hw_sync_cache_local(void *addr, int size)
41+
{
42+
rt_hw_cpu_dcache_clean_local(addr, size);
43+
rt_hw_cpu_icache_invalidate_local(addr, size);
44+
return;
45+
}

bsp/ultrarisc/arch/ur-cp100/cache.h

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*
2+
* Copyright (c) 2006-2025 RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2022-11-09 RT-Thread The first version
9+
*/
10+
#ifndef __CACHE_H__
11+
#define __CACHE_H__
12+
13+
#include <rtdef.h>
14+
15+
/**
16+
* @brief These APIs may not be supported by a specified architecture
17+
* But we have to include to all the cases to be 'general purpose'
18+
*/
19+
20+
rt_always_inline void rt_hw_cpu_dcache_clean_local(void *addr, int size)
21+
{
22+
RT_UNUSED(addr);
23+
RT_UNUSED(size);
24+
}
25+
26+
rt_always_inline void rt_hw_cpu_dcache_invalidate_local(void *addr, int size)
27+
{
28+
RT_UNUSED(addr);
29+
RT_UNUSED(size);
30+
}
31+
32+
rt_always_inline void rt_hw_cpu_dcache_clean_and_invalidate_local(void *addr, int size)
33+
{
34+
RT_UNUSED(addr);
35+
RT_UNUSED(size);
36+
}
37+
38+
rt_always_inline void rt_hw_cpu_dcache_clean_all_local(void)
39+
{
40+
}
41+
42+
rt_always_inline void rt_hw_cpu_dcache_invalidate_all_local(void)
43+
{
44+
}
45+
46+
rt_always_inline void rt_hw_cpu_dcache_clean_and_invalidate_all_local(void)
47+
{
48+
}
49+
50+
/*use fence.i to invalidate all icache*/
51+
rt_always_inline void rt_hw_cpu_icache_invalidate_local(void *addr, int size)
52+
{
53+
__asm__ __volatile__("fence.i" ::: "memory");
54+
}
55+
/*use fence.i to invalidate all icache*/
56+
rt_always_inline void rt_hw_cpu_icache_invalidate_all_local(void)
57+
{
58+
__asm__ __volatile__("fence.i" ::: "memory");
59+
}
60+
61+
/**
62+
* @brief Multi-core
63+
*/
64+
65+
#define rt_hw_cpu_dcache_clean rt_hw_cpu_dcache_clean_local
66+
#define rt_hw_cpu_dcache_invalidate rt_hw_cpu_dcache_invalidate_local
67+
#define rt_hw_cpu_dcache_clean_and_invalidate rt_hw_cpu_dcache_clean_and_invalidate_local
68+
69+
#define rt_hw_cpu_dcache_clean_all rt_hw_cpu_dcache_clean_all_local
70+
#define rt_hw_cpu_dcache_invalidate_all rt_hw_cpu_dcache_invalidate_all_local
71+
#define rt_hw_cpu_dcache_clean_and_invalidate_all rt_hw_cpu_dcache_clean_and_invalidate_all_local
72+
73+
#define rt_hw_cpu_icache_invalidate rt_hw_cpu_icache_invalidate_local
74+
#define rt_hw_cpu_icache_invalidate_all rt_hw_cpu_icache_invalidate_all_local
75+
76+
#define rt_hw_icache_invalidate_all rt_hw_cpu_icache_invalidate_all
77+
78+
/** instruction barrier */
79+
static inline void rt_hw_cpu_sync(void)
80+
{
81+
__asm__ __volatile__("fence.i" ::: "memory");
82+
}
83+
84+
/**
85+
* @brief local cpu icahce & dcache synchronization
86+
*
87+
* @param addr
88+
* @param size
89+
*/
90+
void rt_hw_sync_cache_local(void *addr, int size);
91+
92+
#endif /* __CACHE_H__ */
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*
2+
* Copyright (c) 2006-2025 RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2018/10/01 Bernard The first version
9+
* 2018/12/27 Jesven Change irq enable/disable to cpu0
10+
*/
11+
#include <plic.h>
12+
#include "encoding.h"
13+
#include "riscv.h"
14+
#include "interrupt.h"
15+
16+
struct rt_irq_desc irq_desc[MAX_HANDLERS];
17+
18+
static rt_isr_handler_t rt_hw_interrupt_handle(rt_uint32_t vector, void *param)
19+
{
20+
rt_kprintf("UN-handled interrupt %d occurred!!!\n", vector);
21+
return RT_NULL;
22+
}
23+
24+
int rt_hw_plic_irq_enable(int irq_number)
25+
{
26+
plic_irq_enable(irq_number);
27+
return 0;
28+
}
29+
30+
int rt_hw_plic_irq_disable(int irq_number)
31+
{
32+
plic_irq_disable(irq_number);
33+
return 0;
34+
}
35+
36+
/**
37+
* This function will un-mask a interrupt.
38+
* @param vector the interrupt number
39+
*/
40+
void rt_hw_interrupt_umask(int vector)
41+
{
42+
plic_set_priority(vector, 1);
43+
44+
rt_hw_plic_irq_enable(vector);
45+
}
46+
47+
/**
48+
* This function will install a interrupt service routine to a interrupt.
49+
* @param vector the interrupt number
50+
* @param new_handler the interrupt service routine to be installed
51+
* @param old_handler the old interrupt service routine
52+
*/
53+
rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler,
54+
void *param, const char *name)
55+
{
56+
rt_isr_handler_t old_handler = RT_NULL;
57+
58+
if (vector < MAX_HANDLERS)
59+
{
60+
old_handler = irq_desc[vector].handler;
61+
if (handler != RT_NULL)
62+
{
63+
irq_desc[vector].handler = (rt_isr_handler_t)handler;
64+
irq_desc[vector].param = param;
65+
#ifdef RT_USING_INTERRUPT_INFO
66+
rt_snprintf(irq_desc[vector].name, RT_NAME_MAX - 1, "%s", name);
67+
irq_desc[vector].counter = 0;
68+
#endif
69+
}
70+
}
71+
72+
return old_handler;
73+
}
74+
75+
void rt_hw_interrupt_init()
76+
{
77+
/* Enable machine external interrupts. */
78+
/* set_csr(sie, SIP_SEIP); */
79+
int idx = 0;
80+
/* init exceptions table */
81+
for (idx = 0; idx < MAX_HANDLERS; idx++)
82+
{
83+
irq_desc[idx].handler = (rt_isr_handler_t)rt_hw_interrupt_handle;
84+
irq_desc[idx].param = RT_NULL;
85+
#ifdef RT_USING_INTERRUPT_INFO
86+
rt_snprintf(irq_desc[idx].name, RT_NAME_MAX - 1, "default");
87+
irq_desc[idx].counter = 0;
88+
#endif
89+
}
90+
/*init plic*/
91+
plic_init();
92+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright (c) 2006-2025 RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2021-05-20 bigmagic The first version
9+
*/
10+
11+
#ifndef INTERRUPT_H__
12+
#define INTERRUPT_H__
13+
14+
#define MAX_HANDLERS 128
15+
16+
#include <rthw.h>
17+
#include "stack.h"
18+
19+
enum
20+
{
21+
EP_INSTRUCTION_ADDRESS_MISALIGNED = 0,
22+
EP_INSTRUCTION_ACCESS_FAULT,
23+
EP_ILLEGAL_INSTRUCTION,
24+
EP_BREAKPOINT,
25+
EP_LOAD_ADDRESS_MISALIGNED,
26+
EP_LOAD_ACCESS_FAULT,
27+
EP_STORE_ADDRESS_MISALIGNED,
28+
EP_STORE_ACCESS_FAULT,
29+
EP_ENVIRONMENT_CALL_U_MODE,
30+
EP_ENVIRONMENT_CALL_S_MODE,
31+
EP_RESERVED10,
32+
EP_ENVIRONMENT_CALL_M_MODE,
33+
EP_INSTRUCTION_PAGE_FAULT, /* page attr */
34+
EP_LOAD_PAGE_FAULT, /* read data */
35+
EP_RESERVED14,
36+
EP_STORE_PAGE_FAULT, /* write data */
37+
};
38+
39+
int rt_hw_plic_irq_enable(int irq_number);
40+
int rt_hw_plic_irq_disable(int irq_number);
41+
void rt_hw_interrupt_init(void);
42+
void rt_hw_interrupt_mask(int vector);
43+
rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler, void *param, const char *name);
44+
void handle_trap(rt_size_t xcause, rt_size_t xtval, rt_size_t xepc, struct rt_hw_stack_frame *sp);
45+
46+
#endif

bsp/ultrarisc/arch/ur-cp100/opcode.h

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
* Copyright (c) 2006-2025 RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2022-11-09 Shell Add portable asm support
9+
*/
10+
#ifndef __OPCODE_H__
11+
#define __OPCODE_H__
12+
13+
/**
14+
* @brief binary opcode pseudo operations
15+
* Used to bypass toolchain restriction on extension ISA
16+
*
17+
*/
18+
19+
/**
20+
* @brief RISC-V instruction formats
21+
*/
22+
23+
/**
24+
* R type: .insn r opcode6, func3, func7, rd, rs1, rs2
25+
*
26+
* +-------+-----+-----+-------+----+---------+
27+
* | func7 | rs2 | rs1 | func3 | rd | opcode6 |
28+
* +-------+-----+-----+-------+----+---------+
29+
* 31 25 20 15 12 7 0
30+
*/
31+
#define __OPC_INSN_FORMAT_R(opcode, func3, func7, rd, rs1, rs2) \
32+
".insn r "RT_STRINGIFY(opcode)","RT_STRINGIFY(func3)","RT_STRINGIFY(func7)","RT_STRINGIFY(rd)","RT_STRINGIFY(rs1)","RT_STRINGIFY(rs2)
33+
34+
#ifdef _TOOLCHAIN_SUPP_ZIFENCEI_ISA_
35+
#define OPC_FENCE_I "fence.i"
36+
#else /* !_TOOLCHAIN_SUPP_ZIFENCEI_ISA_ */
37+
#define OPC_FENCE_I ".long 0x0000100F"
38+
#endif /* _TOOLCHAIN_SUPP_ZIFENCEI_ISA_ */
39+
40+
#endif /* __OPCODE_H__ */

0 commit comments

Comments
 (0)