Skip to content

[bsp]增加超睿DP1000 bsp支持 #10338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 30, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/ALL_BSP_COMPILE.json
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,8 @@
"RTT_TOOL_CHAIN": "sourcery-riscv64-unknown-elf",
"SUB_RTT_BSP": [
"bluetrum/ab32vg1-ab-prougen",
"qemu-virt64-riscv"
"qemu-virt64-riscv",
"ultrarisc/ur_dp1000_evb"
]
},
{
Expand Down
4 changes: 4 additions & 0 deletions MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,7 @@ owners: supper thomas(supperthomas)<[email protected]>, Bingru Zhang(Rbb666)<75106
tag: gd32470z-lckfb-lcd
path: bsp/gd32/arm/gd32470z-lckfb/board/ports
owners: Wu Ying Xiang(godmial)<[email protected]>

tag: bsp_ultrarisc
path: bsp/ultrarisc/ur_dp1000_evb
owners: Zhang Jing(zhangjing0303)<[email protected]>
12 changes: 12 additions & 0 deletions bsp/ultrarisc/arch/ur-cp100/SConscript
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# RT-Thread building script for component

from building import *
cwd = GetCurrentDir()
src = Glob('*.c') + Glob('*.cpp')
CPPPATH = [cwd]

group = DefineGroup('arch', src, depend = [''], CPPPATH = CPPPATH)

objs = [group]

Return('objs')
45 changes: 45 additions & 0 deletions bsp/ultrarisc/arch/ur-cp100/cache.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright (c) 2006-2025 RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-01-29 lizhirui first version
* 2025-05-29 Zhang Jing remove redundant code
*/

#include <rthw.h>
#include <rtdef.h>
#include <board.h>
#include <riscv.h>
#include <cache.h>

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);
}
return;
}

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);
}
return;
}

void rt_hw_sync_cache_local(void *addr, int size)
{
rt_hw_cpu_dcache_clean_local(addr, size);
rt_hw_cpu_icache_invalidate_local(addr, size);
return;
}
92 changes: 92 additions & 0 deletions bsp/ultrarisc/arch/ur-cp100/cache.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* Copyright (c) 2006-2025 RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2022-11-09 RT-Thread The first version
*/
#ifndef __CACHE_H__
#define __CACHE_H__

#include <rtdef.h>

/**
* @brief These APIs may not be supported by a specified architecture
* But we have to include to all the cases to be 'general purpose'
*/

rt_always_inline void rt_hw_cpu_dcache_clean_local(void *addr, int size)
{
RT_UNUSED(addr);
RT_UNUSED(size);
}

rt_always_inline void rt_hw_cpu_dcache_invalidate_local(void *addr, int size)
{
RT_UNUSED(addr);
RT_UNUSED(size);
}

rt_always_inline void rt_hw_cpu_dcache_clean_and_invalidate_local(void *addr, int size)
{
RT_UNUSED(addr);
RT_UNUSED(size);
}

rt_always_inline void rt_hw_cpu_dcache_clean_all_local(void)
{
}

rt_always_inline void rt_hw_cpu_dcache_invalidate_all_local(void)
{
}

rt_always_inline void rt_hw_cpu_dcache_clean_and_invalidate_all_local(void)
{
}

/*use fence.i to invalidate all icache*/
rt_always_inline void rt_hw_cpu_icache_invalidate_local(void *addr, int size)
{
__asm__ __volatile__("fence.i" ::: "memory");
}
/*use fence.i to invalidate all icache*/
rt_always_inline void rt_hw_cpu_icache_invalidate_all_local(void)
{
__asm__ __volatile__("fence.i" ::: "memory");
}

/**
* @brief Multi-core
*/

#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_and_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_and_invalidate_all rt_hw_cpu_dcache_clean_and_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

#define rt_hw_icache_invalidate_all rt_hw_cpu_icache_invalidate_all

/** instruction barrier */
static inline void rt_hw_cpu_sync(void)
{
__asm__ __volatile__("fence.i" ::: "memory");
}

/**
* @brief local cpu icahce & dcache synchronization
*
* @param addr
* @param size
*/
void rt_hw_sync_cache_local(void *addr, int size);

#endif /* __CACHE_H__ */
92 changes: 92 additions & 0 deletions bsp/ultrarisc/arch/ur-cp100/interrupt.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* Copyright (c) 2006-2025 RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2018/10/01 Bernard The first version
* 2018/12/27 Jesven Change irq enable/disable to cpu0
*/
#include <plic.h>
#include "encoding.h"
#include "riscv.h"
#include "interrupt.h"

struct rt_irq_desc irq_desc[MAX_HANDLERS];

static rt_isr_handler_t rt_hw_interrupt_handle(rt_uint32_t vector, void *param)
{
rt_kprintf("UN-handled interrupt %d occurred!!!\n", vector);
return RT_NULL;
}

int rt_hw_plic_irq_enable(int irq_number)
{
plic_irq_enable(irq_number);
return 0;
}

int rt_hw_plic_irq_disable(int irq_number)
{
plic_irq_disable(irq_number);
return 0;
}

/**
* This function will un-mask a interrupt.
* @param vector the interrupt number
*/
void rt_hw_interrupt_umask(int vector)
{
plic_set_priority(vector, 1);

rt_hw_plic_irq_enable(vector);
}

/**
* This function will install a interrupt service routine to a interrupt.
* @param vector the interrupt number
* @param new_handler the interrupt service routine to be installed
* @param old_handler the old interrupt service routine
*/
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 < MAX_HANDLERS)
{
old_handler = irq_desc[vector].handler;
if (handler != RT_NULL)
{
irq_desc[vector].handler = (rt_isr_handler_t)handler;
irq_desc[vector].param = param;
#ifdef RT_USING_INTERRUPT_INFO
rt_snprintf(irq_desc[vector].name, RT_NAME_MAX - 1, "%s", name);
irq_desc[vector].counter = 0;
#endif
}
}

return old_handler;
}

void rt_hw_interrupt_init()
{
/* Enable machine external interrupts. */
/* set_csr(sie, SIP_SEIP); */
int idx = 0;
/* init exceptions table */
for (idx = 0; idx < MAX_HANDLERS; idx++)
{
irq_desc[idx].handler = (rt_isr_handler_t)rt_hw_interrupt_handle;
irq_desc[idx].param = RT_NULL;
#ifdef RT_USING_INTERRUPT_INFO
rt_snprintf(irq_desc[idx].name, RT_NAME_MAX - 1, "default");
irq_desc[idx].counter = 0;
#endif
}
/*init plic*/
plic_init();
}
46 changes: 46 additions & 0 deletions bsp/ultrarisc/arch/ur-cp100/interrupt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright (c) 2006-2025 RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2021-05-20 bigmagic The first version
*/

#ifndef INTERRUPT_H__
#define INTERRUPT_H__

#define MAX_HANDLERS 128

#include <rthw.h>
#include "stack.h"

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 */
};

int rt_hw_plic_irq_enable(int irq_number);
int rt_hw_plic_irq_disable(int irq_number);
void rt_hw_interrupt_init(void);
void rt_hw_interrupt_mask(int vector);
rt_isr_handler_t rt_hw_interrupt_install(int vector, rt_isr_handler_t handler, void *param, const char *name);
void handle_trap(rt_size_t xcause, rt_size_t xtval, rt_size_t xepc, struct rt_hw_stack_frame *sp);

#endif
40 changes: 40 additions & 0 deletions bsp/ultrarisc/arch/ur-cp100/opcode.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (c) 2006-2025 RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2022-11-09 Shell Add portable asm support
*/
#ifndef __OPCODE_H__
#define __OPCODE_H__

/**
* @brief binary opcode pseudo operations
* Used to bypass toolchain restriction on extension ISA
*
*/

/**
* @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)

#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__ */
Loading