Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Keyboard Man_俊
rt-thread
提交
36b194ae
R
rt-thread
项目概览
Keyboard Man_俊
/
rt-thread
与 Fork 源项目一致
Fork自
RT-Thread / rt-thread
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rt-thread
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
36b194ae
编写于
12月 08, 2018
作者:
B
Bernard Xiong
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[BSP] Update Hifive1 BSP with unified RV porting.
上级
2a7d814f
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
271 addition
and
622 deletion
+271
-622
bsp/hifive1/.config
bsp/hifive1/.config
+100
-26
bsp/hifive1/SConstruct
bsp/hifive1/SConstruct
+1
-0
bsp/hifive1/freedom-e-sdk/bsp/env/coreplexip-e31-arty/init.c.orig
...ve1/freedom-e-sdk/bsp/env/coreplexip-e31-arty/init.c.orig
+0
-102
bsp/hifive1/freedom-e-sdk/bsp/env/freedom-e300-hifive1/init.c
...hifive1/freedom-e-sdk/bsp/env/freedom-e300-hifive1/init.c
+3
-4
bsp/hifive1/freedom-e-sdk/bsp/env/start.S
bsp/hifive1/freedom-e-sdk/bsp/env/start.S
+2
-1
bsp/hifive1/rtconfig.h
bsp/hifive1/rtconfig.h
+30
-10
bsp/hifive1/rtconfig.py
bsp/hifive1/rtconfig.py
+6
-3
libcpu/risc-v/e310/context_gcc.S
libcpu/risc-v/e310/context_gcc.S
+0
-227
libcpu/risc-v/e310/entry_gcc.S
libcpu/risc-v/e310/entry_gcc.S
+0
-145
libcpu/risc-v/e310/interrupt_gcc.S
libcpu/risc-v/e310/interrupt_gcc.S
+129
-0
libcpu/risc-v/e310/stack.c
libcpu/risc-v/e310/stack.c
+0
-104
未找到文件。
bsp/hifive1/.config
浏览文件 @
36b194ae
...
...
@@ -7,19 +7,30 @@
# RT-Thread Kernel
#
CONFIG_RT_NAME_MAX
=
32
# CONFIG_RT_USING_SMP is not set
CONFIG_RT_ALIGN_SIZE
=
4
# CONFIG_RT_THREAD_PRIORITY_8 is not set
# CONFIG_RT_THREAD_PRIORITY_32 is not set
CONFIG_RT_THREAD_PRIORITY_256
=
y
CONFIG_RT_THREAD_PRIORITY_MAX
=
256
CONFIG_RT_TICK_PER_SECOND
=
100
CONFIG_RT_DEBUG
=
y
CONFIG_RT_USING_OVERFLOW_CHECK
=
y
CONFIG_RT_DEBUG_INIT
=
0
CONFIG_RT_DEBUG_THREAD
=
0
CONFIG_RT_USING_HOOK
=
y
CONFIG_RT_USING_IDLE_HOOK
=
y
CONFIG_RT_IDEL_HOOK_LIST_SIZE
=
4
CONFIG_IDLE_THREAD_STACK_SIZE
=
1024
# CONFIG_RT_USING_TIMER_SOFT is not set
CONFIG_RT_DEBUG
=
y
# CONFIG_RT_DEBUG_INIT_CONFIG is not set
# CONFIG_RT_DEBUG_THREAD_CONFIG is not set
# CONFIG_RT_DEBUG_SCHEDULER_CONFIG is not set
# CONFIG_RT_DEBUG_IPC_CONFIG is not set
# CONFIG_RT_DEBUG_TIMER_CONFIG is not set
# CONFIG_RT_DEBUG_IRQ_CONFIG is not set
# CONFIG_RT_DEBUG_MEM_CONFIG is not set
# CONFIG_RT_DEBUG_SLAB_CONFIG is not set
# CONFIG_RT_DEBUG_MEMHEAP_CONFIG is not set
# CONFIG_RT_DEBUG_MODULE_CONFIG is not set
#
# Inter-Thread communication
...
...
@@ -46,11 +57,12 @@ CONFIG_RT_USING_HEAP=y
# Kernel Device Object
#
CONFIG_RT_USING_DEVICE
=
y
# CONFIG_RT_USING_DEVICE_OPS is not set
# CONFIG_RT_USING_INTERRUPT_INFO is not set
CONFIG_RT_USING_CONSOLE
=
y
CONFIG_RT_CONSOLEBUF_SIZE
=
128
CONFIG_RT_CONSOLE_DEVICE_NAME
=
"dusart"
# CONFIG_
RT_USING_MODULE
is not set
# CONFIG_
ARCH_CPU_STACK_GROWS_UPWARD
is not set
#
# RT-Thread Components
...
...
@@ -58,6 +70,7 @@ CONFIG_RT_CONSOLE_DEVICE_NAME="dusart"
CONFIG_RT_USING_COMPONENTS_INIT
=
y
CONFIG_RT_USING_USER_MAIN
=
y
CONFIG_RT_MAIN_THREAD_STACK_SIZE
=
2048
CONFIG_RT_MAIN_THREAD_PRIORITY
=
85
#
# C++ features
...
...
@@ -81,6 +94,7 @@ CONFIG_FINSH_CMD_SIZE=80
CONFIG_FINSH_USING_MSH
=
y
CONFIG_FINSH_USING_MSH_DEFAULT
=
y
CONFIG_FINSH_USING_MSH_ONLY
=
y
CONFIG_FINSH_ARG_MAX
=
10
#
# Device virtual file system
...
...
@@ -91,21 +105,30 @@ CONFIG_FINSH_USING_MSH_ONLY=y
# Device Drivers
#
CONFIG_RT_USING_DEVICE_IPC
=
y
CONFIG_RT_PIPE_BUFSZ
=
512
CONFIG_RT_USING_SERIAL
=
y
# CONFIG_RT_USING_CAN is not set
# CONFIG_RT_USING_HWTIMER is not set
# CONFIG_RT_USING_CPUTIME is not set
# CONFIG_RT_USING_I2C is not set
# CONFIG_RT_USING_PIN is not set
# CONFIG_RT_USING_ADC is not set
# CONFIG_RT_USING_PWM is not set
# CONFIG_RT_USING_MTD_NOR is not set
# CONFIG_RT_USING_MTD_NAND is not set
# CONFIG_RT_USING_MTD is not set
# CONFIG_RT_USING_PM is not set
# CONFIG_RT_USING_RTC is not set
# CONFIG_RT_USING_SDIO is not set
# CONFIG_RT_USING_SPI is not set
# CONFIG_RT_USING_WDT is not set
# CONFIG_RT_USING_WIFI is not set
# CONFIG_RT_USING_AUDIO is not set
#
# Using WiFi
#
# CONFIG_RT_USING_WIFI is not set
#
# Using USB
#
...
...
@@ -115,13 +138,18 @@ CONFIG_RT_USING_SERIAL=y
#
# POSIX layer and C standard library
#
CONFIG_RT_USING_LIBC
=
y
# CONFIG_RT_USING_LIBC is not set
# CONFIG_RT_USING_PTHREADS is not set
#
# Network
stack
# Network
#
#
# Socket abstraction layer
#
# CONFIG_RT_USING_SAL is not set
#
# light weight TCP/IP stack
#
...
...
@@ -132,6 +160,11 @@ CONFIG_RT_USING_LIBC=y
#
# CONFIG_RT_USING_MODBUS is not set
#
# AT commands
#
# CONFIG_RT_USING_AT is not set
#
# VBUS(Virtual Software BUS)
#
...
...
@@ -142,25 +175,12 @@ CONFIG_RT_USING_LIBC=y
#
# CONFIG_RT_USING_LOGTRACE is not set
# CONFIG_RT_USING_RYM is not set
# CONFIG_RT_USING_ULOG is not set
#
# RT-Thread online packages
#
#
# system packages
#
#
# RT-Thread GUI Engine
#
# CONFIG_PKG_USING_GUIENGINE is not set
# CONFIG_PKG_USING_LWEXT4 is not set
# CONFIG_PKG_USING_PARTITION is not set
# CONFIG_PKG_USING_SQLITE is not set
# CONFIG_PKG_USING_RTI is not set
# CONFIG_PKG_USING_LITTLEVGL2RTT is not set
#
# IoT - internet of things
#
...
...
@@ -169,10 +189,10 @@ CONFIG_RT_USING_LIBC=y
# CONFIG_PKG_USING_MONGOOSE is not set
# CONFIG_PKG_USING_WEBTERMINAL is not set
# CONFIG_PKG_USING_CJSON is not set
# CONFIG_PKG_USING_JSMN is not set
# CONFIG_PKG_USING_LJSON is not set
# CONFIG_PKG_USING_EZXML is not set
# CONFIG_PKG_USING_NANOPB is not set
# CONFIG_PKG_USING_GAGENT_CLOUD is not set
#
# Wi-Fi
...
...
@@ -190,7 +210,16 @@ CONFIG_RT_USING_LIBC=y
# CONFIG_PKG_USING_COAP is not set
# CONFIG_PKG_USING_NOPOLL is not set
# CONFIG_PKG_USING_NETUTILS is not set
# CONFIG_PKG_USING_AT_DEVICE is not set
# CONFIG_PKG_USING_WIZNET is not set
#
# IoT Cloud
#
# CONFIG_PKG_USING_ONENET is not set
# CONFIG_PKG_USING_GAGENT_CLOUD is not set
# CONFIG_PKG_USING_ALI_IOTKIT is not set
# CONFIG_PKG_USING_AZURE is not set
#
# security packages
...
...
@@ -202,6 +231,7 @@ CONFIG_RT_USING_LIBC=y
#
# language packages
#
# CONFIG_PKG_USING_LUA is not set
# CONFIG_PKG_USING_JERRYSCRIPT is not set
# CONFIG_PKG_USING_MICROPYTHON is not set
...
...
@@ -209,6 +239,7 @@ CONFIG_RT_USING_LIBC=y
# multimedia packages
#
# CONFIG_PKG_USING_OPENMV is not set
# CONFIG_PKG_USING_MUPDF is not set
#
# tools packages
...
...
@@ -217,17 +248,58 @@ CONFIG_RT_USING_LIBC=y
# CONFIG_PKG_USING_EASYFLASH is not set
# CONFIG_PKG_USING_EASYLOGGER is not set
# CONFIG_PKG_USING_SYSTEMVIEW is not set
# CONFIG_PKG_USING_IPERF is not set
# CONFIG_PKG_USING_RDB is not set
#
# system packages
#
# CONFIG_PKG_USING_GUIENGINE is not set
# CONFIG_PKG_USING_CAIRO is not set
# CONFIG_PKG_USING_PIXMAN is not set
# CONFIG_PKG_USING_LWEXT4 is not set
# CONFIG_PKG_USING_PARTITION is not set
# CONFIG_PKG_USING_FAL is not set
# CONFIG_PKG_USING_SQLITE is not set
# CONFIG_PKG_USING_RTI is not set
# CONFIG_PKG_USING_LITTLEVGL2RTT is not set
# CONFIG_PKG_USING_CMSIS is not set
# CONFIG_PKG_USING_DFS_YAFFS is not set
#
# peripheral libraries and drivers
#
# CONFIG_PKG_USING_REALTEK_AMEBA is not set
# CONFIG_PKG_USING_SHT2X is not set
# CONFIG_PKG_USING_AHT10 is not set
# CONFIG_PKG_USING_AP3216C is not set
# CONFIG_PKG_USING_STM32_SDIO is not set
# CONFIG_PKG_USING_ICM20608 is not set
# CONFIG_PKG_USING_U8G2 is not set
#
# miscellaneous packages
#
# CONFIG_PKG_USING_LIBCSV is not set
# CONFIG_PKG_USING_OPTPARSE is not set
# CONFIG_PKG_USING_FASTLZ is not set
# CONFIG_PKG_USING_MINILZO is not set
# CONFIG_PKG_USING_QUICKLZ is not set
# CONFIG_PKG_USING_MULTIBUTTON is not set
# CONFIG_PKG_USING_SAMPLES is not set
# CONFIG_PKG_USING_CANFESTIVAL is not set
# CONFIG_PKG_USING_ZLIB is not set
# CONFIG_PKG_USING_DSTR is not set
#
# sample package
#
#
# samples: kernel and components samples
#
# CONFIG_PKG_USING_KERNEL_SAMPLES is not set
# CONFIG_PKG_USING_FILESYSTEM_SAMPLES is not set
# CONFIG_PKG_USING_NETWORK_SAMPLES is not set
# CONFIG_PKG_USING_PERIPHERAL_SAMPLES is not set
#
# example package: hello
...
...
@@ -244,9 +316,11 @@ CONFIG_RT_USING_LIBC=y
#
# Network Utilities
#
# CONFIG_PKG_USING_W
LAN_WICED_SRC
is not set
# CONFIG_PKG_USING_W
ICED
is not set
# CONFIG_PKG_USING_CLOUDSDK is not set
# CONFIG_PKG_USING_COREMARK is not set
# CONFIG_PKG_USING_POWER_MANAGER is not set
# CONFIG_PKG_USING_RT_OTA is not set
# CONFIG_PKG_USING_RT_AT is not set
# CONFIG_PKG_USING_RDBD_SRC is not set
# CONFIG_PKG_USING_RTINSIGHT is not set
# CONFIG_PKG_USING_SMARTCONFIG is not set
bsp/hifive1/SConstruct
浏览文件 @
36b194ae
...
...
@@ -18,6 +18,7 @@ env = Environment(tools = ['mingw'],
AR
=
rtconfig
.
AR
,
ARFLAGS
=
'-rc'
,
LINK
=
rtconfig
.
LINK
,
LINKFLAGS
=
rtconfig
.
LFLAGS
)
env
.
PrependENVPath
(
'PATH'
,
rtconfig
.
EXEC_PATH
)
env
[
'ASCOM'
]
=
env
[
'ASPPCOM'
]
Export
(
'RTT_ROOT'
)
Export
(
'rtconfig'
)
...
...
bsp/hifive1/freedom-e-sdk/bsp/env/coreplexip-e31-arty/init.c.orig
已删除
100644 → 0
浏览文件 @
2a7d814f
//See LICENSE for license details.
#include <stdint.h>
#include <stdio.h>
#include <unistd.h>
#include "platform.h"
#include "encoding.h"
#define CPU_FREQ 65000000
#define XSTR(x) #x
#define STR(x) XSTR(x)
extern int main(int argc, char** argv);
extern void trap_entry();
static unsigned long get_cpu_freq()
{
return CPU_FREQ;
}
unsigned long get_timer_freq()
{
return get_cpu_freq();
}
uint64_t get_timer_value()
{
#if __riscv_xlen == 32
while (1) {
uint32_t hi = read_csr(mcycleh);
uint32_t lo = read_csr(mcycle);
if (hi == read_csr(mcycleh))
return ((uint64_t)hi << 32) | lo;
}
#else
return read_csr(mcycle);
#endif
}
static void uart_init(size_t baud_rate)
{
UART0_REG(UART_REG_DIV) = (get_cpu_freq() / 2) / baud_rate - 1;
UART0_REG(UART_REG_TXCTRL) |= UART_TXEN;
}
#ifdef USE_PLIC
extern void handle_m_ext_interrupt();
#endif
#ifdef USE_M_TIME
extern void handle_m_time_interrupt();
#endif
#ifdef USE_LOCAL_ISR
typedef void (*my_interrupt_function_ptr_t) (void);
extern my_interrupt_function_ptr_t localISR[];
#endif
uintptr_t handle_trap(uintptr_t mcause, uintptr_t epc)
{
if (0){
#ifdef USE_PLIC
// External Machine-Level interrupt from PLIC
} else if ((mcause & MCAUSE_INT) && ((mcause & MCAUSE_CAUSE) == IRQ_M_EXT)) {
handle_m_ext_interrupt();
#endif
#ifdef USE_M_TIME
// External Machine-Level interrupt from PLIC
} else if ((mcause & MCAUSE_INT) && ((mcause & MCAUSE_CAUSE) == IRQ_M_TIMER)){
handle_m_time_interrupt();
#endif
#ifdef USE_LOCAL_ISR
} else if (mcause & MCAUSE_INT) {
localISR[mcause & MCAUSE_CAUSE] ();
#endif
}
else {
write(1, "Unhandled Trap:\n", 16);
_exit(1 + mcause);
}
return epc;
}
void _init()
{
#ifndef NO_INIT
uart_init(115200);
<<<<<<< HEAD
puts("core freq at " STR(CPU_FREQ) " Hz\n");
=======
printf("core freq at %ld Hz\n", get_cpu_freq());
>>>>>>> 120f19bbe91e5bda3c777de44618e58d5c8fc2c4
write_csr(mtvec, &trap_entry);
#endif
}
void _fini()
{
}
\ No newline at end of file
bsp/hifive1/freedom-e-sdk/bsp/env/freedom-e300-hifive1/init.c
浏览文件 @
36b194ae
#include <stdint.h>
#include <stdio.h>
#include <
unistd
.h>
#include <
string
.h>
#include "platform.h"
#include "encoding.h"
...
...
@@ -208,8 +208,7 @@ uintptr_t handle_trap(uintptr_t mcause, uintptr_t epc)
#endif
}
else
{
write
(
1
,
"trap
\n
"
,
5
);
_exit
(
1
+
mcause
);
rt_kprintf
(
"Unhandled Trap.
\n
"
);
}
return
epc
;
}
...
...
@@ -222,7 +221,7 @@ void _init()
use_pll
(
0
,
0
,
1
,
31
,
1
);
uart_init
(
115200
);
printf
(
"core freq at %ld Hz
\n
"
,
get_cpu_freq
());
rt_k
printf
(
"core freq at %ld Hz
\n
"
,
get_cpu_freq
());
write_csr
(
mtvec
,
&
trap_entry
);
if
(
read_csr
(
misa
)
&
(
1
<<
(
'F'
-
'A'
)))
{
// if F extension is present
...
...
bsp/hifive1/freedom-e-sdk/bsp/env/start.S
浏览文件 @
36b194ae
...
...
@@ -80,7 +80,8 @@ _start:
li
a0
,
0
li
a1
,
0
call
entry
tail
exit
/
*
tail
exit
*/
1
:
j
1
b
...
...
bsp/hifive1/rtconfig.h
浏览文件 @
36b194ae
...
...
@@ -11,12 +11,12 @@
#define RT_THREAD_PRIORITY_256
#define RT_THREAD_PRIORITY_MAX 256
#define RT_TICK_PER_SECOND 100
#define RT_DEBUG
#define RT_USING_OVERFLOW_CHECK
#define RT_DEBUG_INIT 0
#define RT_DEBUG_THREAD 0
#define RT_USING_HOOK
#define RT_USING_IDLE_HOOK
#define RT_IDEL_HOOK_LIST_SIZE 4
#define IDLE_THREAD_STACK_SIZE 1024
#define RT_DEBUG
/* Inter-Thread communication */
...
...
@@ -45,6 +45,7 @@
#define RT_USING_COMPONENTS_INIT
#define RT_USING_USER_MAIN
#define RT_MAIN_THREAD_STACK_SIZE 2048
#define RT_MAIN_THREAD_PRIORITY 85
/* C++ features */
...
...
@@ -63,6 +64,7 @@
#define FINSH_USING_MSH
#define FINSH_USING_MSH_DEFAULT
#define FINSH_USING_MSH_ONLY
#define FINSH_ARG_MAX 10
/* Device virtual file system */
...
...
@@ -70,16 +72,22 @@
/* Device Drivers */
#define RT_USING_DEVICE_IPC
#define RT_PIPE_BUFSZ 512
#define RT_USING_SERIAL
/* Using WiFi */
/* Using USB */
/* POSIX layer and C standard library */
#define RT_USING_LIBC
/* Network stack */
/* Network */
/* Socket abstraction layer */
/* light weight TCP/IP stack */
...
...
@@ -87,6 +95,9 @@
/* Modbus master and slave stack */
/* AT commands */
/* VBUS(Virtual Software BUS) */
...
...
@@ -95,11 +106,6 @@
/* RT-Thread online packages */
/* system packages */
/* RT-Thread GUI Engine */
/* IoT - internet of things */
...
...
@@ -111,6 +117,9 @@
/* Wiced WiFi */
/* IoT Cloud */
/* security packages */
...
...
@@ -123,9 +132,20 @@
/* tools packages */
/* system packages */
/* peripheral libraries and drivers */
/* miscellaneous packages */
/* sample package */
/* samples: kernel and components samples */
/* example package: hello */
...
...
bsp/hifive1/rtconfig.py
浏览文件 @
36b194ae
...
...
@@ -10,8 +10,10 @@ if os.getenv('RTT_CC'):
if
CROSS_TOOL
==
'gcc'
:
PLATFORM
=
'gcc'
# EXEC_PATH = '/home/tanek/risc-v/e300/riscv64-unknown-elf-gcc-20170612-x86_64-linux-centos6/bin'
EXEC_PATH
=
'/home/tanek/risc-v/e300/riscv64-unknown-elf-gcc-20171231-x86_64-linux-centos6/bin'
EXEC_PATH
=
r
'/opt/unknown-gcc/bin'
else
:
print
(
'Please make sure your toolchains is GNU GCC!'
)
exit
(
0
)
if
os
.
getenv
(
'RTT_EXEC_PATH'
):
EXEC_PATH
=
os
.
getenv
(
'RTT_EXEC_PATH'
)
...
...
@@ -27,8 +29,9 @@ TARGET_NAME = 'rtthread.bin'
#------- GCC settings ----------------------------------------------------------
if
PLATFORM
==
'gcc'
:
# toolchains
PREFIX
=
'riscv
64-unknown-elf
-'
PREFIX
=
'riscv
-none-embed
-'
CC
=
PREFIX
+
'gcc'
CXX
=
PREFIX
+
'g++'
AS
=
PREFIX
+
'gcc'
AR
=
PREFIX
+
'ar'
LINK
=
PREFIX
+
'gcc'
...
...
libcpu/risc-v/e310/context_gcc.S
已删除
100644 → 0
浏览文件 @
2a7d814f
;/*
; * File : context_gcc.S
; * This file is part of RT-Thread RTOS
; * COPYRIGHT (C) 2018, RT-Thread Development Team
; *
; * This program is free software; you can redistribute it and/or modify
; * it under the terms of the GNU General Public License as published by
; * the Free Software Foundation; either version 2 of the License, or
; * (at your option) any later version.
; *
; * This program is distributed in the hope that it will be useful,
; * but WITHOUT ANY WARRANTY; without even the implied warranty of
; * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; * GNU General Public License for more details.
; *
; * You should have received a copy of the GNU General Public License along
; * with this program; if not, write to the Free Software Foundation, Inc.,
; * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
; *
; * Change Logs:
; * Date Author Notes
; * 2017-07-16 zhangjun for hifive1
; * 2018-05-29 tanek optimize rt_hw_interrupt_*
; * 2018-05-29 tanek add mie register to context
; */
/*
*
rt_base_t
rt_hw_interrupt_disable
(
void
)
;
*/
.
globl
rt_hw_interrupt_disable
rt_hw_interrupt_disable
:
csrrci
a0
,
mstatus
,
8
ret
/*
*
void
rt_hw_interrupt_enable
(
rt_base_t
level
)
;
*/
.
globl
rt_hw_interrupt_enable
rt_hw_interrupt_enable
:
csrw
mstatus
,
a0
ret
/*
*
void
rt_hw_context_switch
(
rt_uint32
from
,
rt_uint32
to
)
;
*
a0
-->
from
*
a1
-->
to
*/
.
globl
rt_hw_context_switch
rt_hw_context_switch
:
/
*
saved
from
thread
context
*
x1
/
ra
->
sp
(
0
)
*
x1
/
ra
->
sp
(
1
)
*
mstatus
.
mie
->
sp
(
2
)
*
x
(
i
)
->
sp
(
i
-
4
)
*/
addi
sp
,
sp
,
-
32
*
4
sw
sp
,
(
a0
)
sw
x1
,
0
*
4
(
sp
)
sw
x1
,
1
*
4
(
sp
)
csrr
a0
,
mstatus
andi
a0
,
a0
,
8
beqz
a0
,
save_mpie
li
a0
,
0x80
save_mpie
:
sw
a0
,
2
*
4
(
sp
)
sw
x4
,
4
*
4
(
sp
)
sw
x5
,
5
*
4
(
sp
)
sw
x6
,
6
*
4
(
sp
)
sw
x7
,
7
*
4
(
sp
)
sw
x8
,
8
*
4
(
sp
)
sw
x9
,
9
*
4
(
sp
)
sw
x10
,
10
*
4
(
sp
)
sw
x11
,
11
*
4
(
sp
)
sw
x12
,
12
*
4
(
sp
)
sw
x13
,
13
*
4
(
sp
)
sw
x14
,
14
*
4
(
sp
)
sw
x15
,
15
*
4
(
sp
)
sw
x16
,
16
*
4
(
sp
)
sw
x17
,
17
*
4
(
sp
)
sw
x18
,
18
*
4
(
sp
)
sw
x19
,
19
*
4
(
sp
)
sw
x20
,
20
*
4
(
sp
)
sw
x21
,
21
*
4
(
sp
)
sw
x22
,
22
*
4
(
sp
)
sw
x23
,
23
*
4
(
sp
)
sw
x24
,
24
*
4
(
sp
)
sw
x25
,
25
*
4
(
sp
)
sw
x26
,
26
*
4
(
sp
)
sw
x27
,
27
*
4
(
sp
)
sw
x28
,
28
*
4
(
sp
)
sw
x29
,
29
*
4
(
sp
)
sw
x30
,
30
*
4
(
sp
)
sw
x31
,
31
*
4
(
sp
)
/
*
restore
to
thread
context
*
sp
(
0
)
->
epc
;
*
sp
(
1
)
->
ra
;
*
sp
(
i
)
->
x
(
i
+
2
)
*/
lw
sp
,
(
a1
)
/
*
resw
ra
to
mepc
*/
lw
a1
,
0
*
4
(
sp
)
csrw
mepc
,
a1
lw
x1
,
1
*
4
(
sp
)
/
*
force
to
machin
mode
(
MPP
=
11
)
*/
li
a1
,
0x00001800
;
csrs
mstatus
,
a1
lw
a1
,
2
*
4
(
sp
)
csrs
mstatus
,
a1
lw
x4
,
4
*
4
(
sp
)
lw
x5
,
5
*
4
(
sp
)
lw
x6
,
6
*
4
(
sp
)
lw
x7
,
7
*
4
(
sp
)
lw
x8
,
8
*
4
(
sp
)
lw
x9
,
9
*
4
(
sp
)
lw
x10
,
10
*
4
(
sp
)
lw
x11
,
11
*
4
(
sp
)
lw
x12
,
12
*
4
(
sp
)
lw
x13
,
13
*
4
(
sp
)
lw
x14
,
14
*
4
(
sp
)
lw
x15
,
15
*
4
(
sp
)
lw
x16
,
16
*
4
(
sp
)
lw
x17
,
17
*
4
(
sp
)
lw
x18
,
18
*
4
(
sp
)
lw
x19
,
19
*
4
(
sp
)
lw
x20
,
20
*
4
(
sp
)
lw
x21
,
21
*
4
(
sp
)
lw
x22
,
22
*
4
(
sp
)
lw
x23
,
23
*
4
(
sp
)
lw
x24
,
24
*
4
(
sp
)
lw
x25
,
25
*
4
(
sp
)
lw
x26
,
26
*
4
(
sp
)
lw
x27
,
27
*
4
(
sp
)
lw
x28
,
28
*
4
(
sp
)
lw
x29
,
29
*
4
(
sp
)
lw
x30
,
30
*
4
(
sp
)
lw
x31
,
31
*
4
(
sp
)
addi
sp
,
sp
,
32
*
4
mret
/*
*
void
rt_hw_context_switch_to
(
rt_uint32
to
)
;
*
a0
-->
to
*/
.
globl
rt_hw_context_switch_to
rt_hw_context_switch_to
:
lw
sp
,
(
a0
)
/
*
load
epc
from
stack
*/
lw
a0
,
0
*
4
(
sp
)
csrw
mepc
,
a0
lw
x1
,
1
*
4
(
sp
)
/
*
load
mstatus
from
stack
*/
lw
a0
,
2
*
4
(
sp
)
csrw
mstatus
,
a0
lw
x4
,
4
*
4
(
sp
)
lw
x5
,
5
*
4
(
sp
)
lw
x6
,
6
*
4
(
sp
)
lw
x7
,
7
*
4
(
sp
)
lw
x8
,
8
*
4
(
sp
)
lw
x9
,
9
*
4
(
sp
)
lw
x10
,
10
*
4
(
sp
)
lw
x11
,
11
*
4
(
sp
)
lw
x12
,
12
*
4
(
sp
)
lw
x13
,
13
*
4
(
sp
)
lw
x14
,
14
*
4
(
sp
)
lw
x15
,
15
*
4
(
sp
)
lw
x16
,
16
*
4
(
sp
)
lw
x17
,
17
*
4
(
sp
)
lw
x18
,
18
*
4
(
sp
)
lw
x19
,
19
*
4
(
sp
)
lw
x20
,
20
*
4
(
sp
)
lw
x21
,
21
*
4
(
sp
)
lw
x22
,
22
*
4
(
sp
)
lw
x23
,
23
*
4
(
sp
)
lw
x24
,
24
*
4
(
sp
)
lw
x25
,
25
*
4
(
sp
)
lw
x26
,
26
*
4
(
sp
)
lw
x27
,
27
*
4
(
sp
)
lw
x28
,
28
*
4
(
sp
)
lw
x29
,
29
*
4
(
sp
)
lw
x30
,
30
*
4
(
sp
)
lw
x31
,
31
*
4
(
sp
)
addi
sp
,
sp
,
32
*
4
mret
/*
*
void
rt_hw_context_switch_interrupt
(
rt_uint32
from
,
rt_uint32
to
)
;
*/
.
globl
rt_thread_switch_interrupt_flag
.
globl
rt_interrupt_from_thread
.
globl
rt_interrupt_to_thread
.
globl
rt_hw_context_switch_interrupt
rt_hw_context_switch_interrupt
:
addi
sp
,
sp
,
-
16
sw
s0
,
12
(
sp
)
sw
a0
,
8
(
sp
)
sw
a5
,
4
(
sp
)
la
a0
,
rt_thread_switch_interrupt_flag
lw
a5
,
(
a0
)
bnez
a5
,
_reswitch
li
a5
,
1
sw
a5
,
(
a0
)
la
a5
,
rt_interrupt_from_thread
lw
a0
,
8
(
sp
)
sw
a0
,
(
a5
)
_reswitch
:
la
a5
,
rt_interrupt_to_thread
sw
a1
,
(
a5
)
lw
a5
,
4
(
sp
)
lw
a0
,
8
(
sp
)
lw
s0
,
12
(
sp
)
addi
sp
,
sp
,
16
ret
libcpu/risc-v/e310/entry_gcc.S
已删除
100644 → 0
浏览文件 @
2a7d814f
/*
*
File
:
context_gcc
.
S
*
This
file
is
part
of
RT
-
Thread
RTOS
*
COPYRIGHT
(
C
)
2018
,
RT
-
Thread
Development
Team
*
*
This
program
is
free
software
; you can redistribute it and/or modify
*
it
under
the
terms
of
the
GNU
General
Public
License
as
published
by
*
the
Free
Software
Foundation
; either version 2 of the License, or
*
(
at
your
option
)
any
later
version
.
*
*
This
program
is
distributed
in
the
hope
that
it
will
be
useful
,
*
but
WITHOUT
ANY
WARRANTY
; without even the implied warranty of
*
MERCHANTABILITY
or
FITNESS
FOR
A
PARTICULAR
PURPOSE
.
See
the
*
GNU
General
Public
License
for
more
details
.
*
*
You
should
have
received
a
copy
of
the
GNU
General
Public
License
along
*
with
this
program
; if not, write to the Free Software Foundation, Inc.,
*
51
Franklin
Street
,
Fifth
Floor
,
Boston
,
MA
02110
-
1301
USA
.
*
*
Change
Logs
:
*
Date
Author
Notes
*
2018
-
05
-
29
tanek
first
implementation
*/
.
section
.
text
.
entry
.
align
2
.
global
trap_entry
trap_entry
:
//
save
all
from
thread
context
addi
sp
,
sp
,
-
32
*
4
sw
x1
,
1
*
4
(
sp
)
li
t0
,
0x80
sw
t0
,
2
*
4
(
sp
)
sw
x4
,
4
*
4
(
sp
)
sw
x5
,
5
*
4
(
sp
)
sw
x6
,
6
*
4
(
sp
)
sw
x7
,
7
*
4
(
sp
)
sw
x8
,
8
*
4
(
sp
)
sw
x9
,
9
*
4
(
sp
)
sw
x10
,
10
*
4
(
sp
)
sw
x11
,
11
*
4
(
sp
)
sw
x12
,
12
*
4
(
sp
)
sw
x13
,
13
*
4
(
sp
)
sw
x14
,
14
*
4
(
sp
)
sw
x15
,
15
*
4
(
sp
)
sw
x16
,
16
*
4
(
sp
)
sw
x17
,
17
*
4
(
sp
)
sw
x18
,
18
*
4
(
sp
)
sw
x19
,
19
*
4
(
sp
)
sw
x20
,
20
*
4
(
sp
)
sw
x21
,
21
*
4
(
sp
)
sw
x22
,
22
*
4
(
sp
)
sw
x23
,
23
*
4
(
sp
)
sw
x24
,
24
*
4
(
sp
)
sw
x25
,
25
*
4
(
sp
)
sw
x26
,
26
*
4
(
sp
)
sw
x27
,
27
*
4
(
sp
)
sw
x28
,
28
*
4
(
sp
)
sw
x29
,
29
*
4
(
sp
)
sw
x30
,
30
*
4
(
sp
)
sw
x31
,
31
*
4
(
sp
)
//
switch
to
interrupt
stack
move
s0
,
sp
la
sp
,
_sp
//
interrupt
handle
call
rt_interrupt_enter
csrr
a0
,
mcause
csrr
a1
,
mepc
mv
a2
,
sp
call
handle_trap
call
rt_interrupt_leave
//
switch
to
from
thread
stack
move
sp
,
s0
//
need
to
switch
new
thread
la
s0
,
rt_thread_switch_interrupt_flag
lw
s2
,
0
(
s0
)
beqz
s2
,
spurious_interrupt
sw
zero
,
0
(
s0
)
csrr
a0
,
mepc
sw
a0
,
0
*
4
(
sp
)
la
s0
,
rt_interrupt_from_thread
lw
s1
,
0
(
s0
)
sw
sp
,
0
(
s1
)
la
s0
,
rt_interrupt_to_thread
lw
s1
,
0
(
s0
)
lw
sp
,
0
(
s1
)
lw
a0
,
0
*
4
(
sp
)
csrw
mepc
,
a0
spurious_interrupt
:
lw
x1
,
1
*
4
(
sp
)
//
Remain
in
M
-
mode
after
mret
li
t0
,
0x00001800
csrs
mstatus
,
t0
lw
t0
,
2
*
4
(
sp
)
csrs
mstatus
,
t0
lw
x4
,
4
*
4
(
sp
)
lw
x5
,
5
*
4
(
sp
)
lw
x6
,
6
*
4
(
sp
)
lw
x7
,
7
*
4
(
sp
)
lw
x8
,
8
*
4
(
sp
)
lw
x9
,
9
*
4
(
sp
)
lw
x10
,
10
*
4
(
sp
)
lw
x11
,
11
*
4
(
sp
)
lw
x12
,
12
*
4
(
sp
)
lw
x13
,
13
*
4
(
sp
)
lw
x14
,
14
*
4
(
sp
)
lw
x15
,
15
*
4
(
sp
)
lw
x16
,
16
*
4
(
sp
)
lw
x17
,
17
*
4
(
sp
)
lw
x18
,
18
*
4
(
sp
)
lw
x19
,
19
*
4
(
sp
)
lw
x20
,
20
*
4
(
sp
)
lw
x21
,
21
*
4
(
sp
)
lw
x22
,
22
*
4
(
sp
)
lw
x23
,
23
*
4
(
sp
)
lw
x24
,
24
*
4
(
sp
)
lw
x25
,
25
*
4
(
sp
)
lw
x26
,
26
*
4
(
sp
)
lw
x27
,
27
*
4
(
sp
)
lw
x28
,
28
*
4
(
sp
)
lw
x29
,
29
*
4
(
sp
)
lw
x30
,
30
*
4
(
sp
)
lw
x31
,
31
*
4
(
sp
)
addi
sp
,
sp
,
32
*
4
mret
.
weak
handle_trap
handle_trap
:
1
:
j
1
b
libcpu/risc-v/e310/interrupt_gcc.S
0 → 100644
浏览文件 @
36b194ae
/*
*
Copyright
(
c
)
2006
-
2018
,
RT
-
Thread
Development
Team
*
*
SPDX
-
License
-
Identifier
:
Apache
-
2
.0
*
*
Change
Logs
:
*
Date
Author
Notes
*
2018
/
10
/
02
Bernard
The
first
version
*/
#include "port.h"
.
section
.
text
.
entry
.
align
2
.
global
trap_entry
trap_entry
:
/
*
save
all
from
thread
context
*/
addi
sp
,
sp
,
-
32
*
REGBYTES
STORE
x1
,
1
*
REGBYTES
(
sp
)
li
t0
,
0x80
STORE
t0
,
2
*
REGBYTES
(
sp
)
STORE
x4
,
4
*
REGBYTES
(
sp
)
STORE
x5
,
5
*
REGBYTES
(
sp
)
STORE
x6
,
6
*
REGBYTES
(
sp
)
STORE
x7
,
7
*
REGBYTES
(
sp
)
STORE
x8
,
8
*
REGBYTES
(
sp
)
STORE
x9
,
9
*
REGBYTES
(
sp
)
STORE
x10
,
10
*
REGBYTES
(
sp
)
STORE
x11
,
11
*
REGBYTES
(
sp
)
STORE
x12
,
12
*
REGBYTES
(
sp
)
STORE
x13
,
13
*
REGBYTES
(
sp
)
STORE
x14
,
14
*
REGBYTES
(
sp
)
STORE
x15
,
15
*
REGBYTES
(
sp
)
STORE
x16
,
16
*
REGBYTES
(
sp
)
STORE
x17
,
17
*
REGBYTES
(
sp
)
STORE
x18
,
18
*
REGBYTES
(
sp
)
STORE
x19
,
19
*
REGBYTES
(
sp
)
STORE
x20
,
20
*
REGBYTES
(
sp
)
STORE
x21
,
21
*
REGBYTES
(
sp
)
STORE
x22
,
22
*
REGBYTES
(
sp
)
STORE
x23
,
23
*
REGBYTES
(
sp
)
STORE
x24
,
24
*
REGBYTES
(
sp
)
STORE
x25
,
25
*
REGBYTES
(
sp
)
STORE
x26
,
26
*
REGBYTES
(
sp
)
STORE
x27
,
27
*
REGBYTES
(
sp
)
STORE
x28
,
28
*
REGBYTES
(
sp
)
STORE
x29
,
29
*
REGBYTES
(
sp
)
STORE
x30
,
30
*
REGBYTES
(
sp
)
STORE
x31
,
31
*
REGBYTES
(
sp
)
/
*
save
break
thread
stack
to
s0
*/
move
s0
,
sp
/
*
switch
to
interrupt
stack
*/
la
sp
,
_sp
/
*
interrupt
handle
*/
call
rt_interrupt_enter
csrr
a0
,
mcause
csrr
a1
,
mepc
mv
a2
,
sp
call
handle_trap
call
rt_interrupt_leave
/
*
switch
to
from_thread
stack
*/
move
sp
,
s0
/
*
need
to
switch
new
thread
*/
la
s0
,
rt_thread_switch_interrupt_flag
LOAD
s2
,
0
(
s0
)
beqz
s2
,
spurious_interrupt
STORE
zero
,
0
(
s0
)
csrr
a0
,
mepc
STORE
a0
,
0
*
REGBYTES
(
sp
)
la
s0
,
rt_interrupt_from_thread
LOAD
s1
,
0
(
s0
)
STORE
sp
,
0
(
s1
)
la
s0
,
rt_interrupt_to_thread
LOAD
s1
,
0
(
s0
)
LOAD
sp
,
0
(
s1
)
LOAD
a0
,
0
*
REGBYTES
(
sp
)
csrw
mepc
,
a0
spurious_interrupt
:
LOAD
x1
,
1
*
REGBYTES
(
sp
)
/
*
Remain
in
M
-
mode
after
mret
*/
li
t0
,
0x00001800
csrs
mstatus
,
t0
LOAD
t0
,
2
*
REGBYTES
(
sp
)
csrs
mstatus
,
t0
LOAD
x4
,
4
*
REGBYTES
(
sp
)
LOAD
x5
,
5
*
REGBYTES
(
sp
)
LOAD
x6
,
6
*
REGBYTES
(
sp
)
LOAD
x7
,
7
*
REGBYTES
(
sp
)
LOAD
x8
,
8
*
REGBYTES
(
sp
)
LOAD
x9
,
9
*
REGBYTES
(
sp
)
LOAD
x10
,
10
*
REGBYTES
(
sp
)
LOAD
x11
,
11
*
REGBYTES
(
sp
)
LOAD
x12
,
12
*
REGBYTES
(
sp
)
LOAD
x13
,
13
*
REGBYTES
(
sp
)
LOAD
x14
,
14
*
REGBYTES
(
sp
)
LOAD
x15
,
15
*
REGBYTES
(
sp
)
LOAD
x16
,
16
*
REGBYTES
(
sp
)
LOAD
x17
,
17
*
REGBYTES
(
sp
)
LOAD
x18
,
18
*
REGBYTES
(
sp
)
LOAD
x19
,
19
*
REGBYTES
(
sp
)
LOAD
x20
,
20
*
REGBYTES
(
sp
)
LOAD
x21
,
21
*
REGBYTES
(
sp
)
LOAD
x22
,
22
*
REGBYTES
(
sp
)
LOAD
x23
,
23
*
REGBYTES
(
sp
)
LOAD
x24
,
24
*
REGBYTES
(
sp
)
LOAD
x25
,
25
*
REGBYTES
(
sp
)
LOAD
x26
,
26
*
REGBYTES
(
sp
)
LOAD
x27
,
27
*
REGBYTES
(
sp
)
LOAD
x28
,
28
*
REGBYTES
(
sp
)
LOAD
x29
,
29
*
REGBYTES
(
sp
)
LOAD
x30
,
30
*
REGBYTES
(
sp
)
LOAD
x31
,
31
*
REGBYTES
(
sp
)
addi
sp
,
sp
,
32
*
REGBYTES
mret
libcpu/risc-v/e310/stack.c
已删除
100644 → 0
浏览文件 @
2a7d814f
/*
* File : stack.c
* This file is part of RT-Thread RTOS
* COPYRIGHT (C) 2006, RT-Thread Development Team
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Change Logs:
* Date Author Notes
* 2017-07-31 tanek first implementation
*/
#include <rtthread.h>
/* flag in interrupt handling */
rt_uint32_t
rt_interrupt_from_thread
;
rt_uint32_t
rt_interrupt_to_thread
;
rt_uint32_t
rt_thread_switch_interrupt_flag
;
struct
stack_frame
{
rt_ubase_t
epc
;
/* epc - epc - program counter */
rt_ubase_t
ra
;
/* x1 - ra - return address for jumps */
rt_ubase_t
mstatus
;
/* - machine status register */
rt_ubase_t
gp
;
/* x3 - gp - global pointer */
rt_ubase_t
tp
;
/* x4 - tp - thread pointer */
rt_ubase_t
t0
;
/* x5 - t0 - temporary register 0 */
rt_ubase_t
t1
;
/* x6 - t1 - temporary register 1 */
rt_ubase_t
t2
;
/* x7 - t2 - temporary register 2 */
rt_ubase_t
s0_fp
;
/* x8 - s0/fp - saved register 0 or frame pointer */
rt_ubase_t
s1
;
/* x9 - s1 - saved register 1 */
rt_ubase_t
a0
;
/* x10 - a0 - return value or function argument 0 */
rt_ubase_t
a1
;
/* x11 - a1 - return value or function argument 1 */
rt_ubase_t
a2
;
/* x12 - a2 - function argument 2 */
rt_ubase_t
a3
;
/* x13 - a3 - function argument 3 */
rt_ubase_t
a4
;
/* x14 - a4 - function argument 4 */
rt_ubase_t
a5
;
/* x15 - a5 - function argument 5 */
rt_ubase_t
a6
;
/* x16 - a6 - function argument 6 */
rt_ubase_t
a7
;
/* x17 - s7 - function argument 7 */
rt_ubase_t
s2
;
/* x18 - s2 - saved register 2 */
rt_ubase_t
s3
;
/* x19 - s3 - saved register 3 */
rt_ubase_t
s4
;
/* x20 - s4 - saved register 4 */
rt_ubase_t
s5
;
/* x21 - s5 - saved register 5 */
rt_ubase_t
s6
;
/* x22 - s6 - saved register 6 */
rt_ubase_t
s7
;
/* x23 - s7 - saved register 7 */
rt_ubase_t
s8
;
/* x24 - s8 - saved register 8 */
rt_ubase_t
s9
;
/* x25 - s9 - saved register 9 */
rt_ubase_t
s10
;
/* x26 - s10 - saved register 10 */
rt_ubase_t
s11
;
/* x27 - s11 - saved register 11 */
rt_ubase_t
t3
;
/* x28 - t3 - temporary register 3 */
rt_ubase_t
t4
;
/* x29 - t4 - temporary register 4 */
rt_ubase_t
t5
;
/* x30 - t5 - temporary register 5 */
rt_ubase_t
t6
;
/* x31 - t6 - temporary register 6 */
};
/**
* This function will initialize thread stack
*
* @param tentry the entry of thread
* @param parameter the parameter of entry
* @param stack_addr the beginning stack address
* @param texit the function will be called when thread exit
*
* @return stack address
*/
rt_uint8_t
*
rt_hw_stack_init
(
void
*
tentry
,
void
*
parameter
,
rt_uint8_t
*
stack_addr
,
void
*
texit
)
{
struct
stack_frame
*
stack_frame
;
rt_uint8_t
*
stk
;
int
i
;
stk
=
stack_addr
+
sizeof
(
rt_uint32_t
);
stk
=
(
rt_uint8_t
*
)
RT_ALIGN_DOWN
((
rt_uint32_t
)
stk
,
8
);
stk
-=
sizeof
(
struct
stack_frame
);
stack_frame
=
(
struct
stack_frame
*
)
stk
;
for
(
i
=
0
;
i
<
sizeof
(
struct
stack_frame
)
/
sizeof
(
rt_ubase_t
);
i
++
)
{
((
rt_ubase_t
*
)
stack_frame
)[
i
]
=
0xdeadbeef
;
}
stack_frame
->
ra
=
(
rt_ubase_t
)
texit
;
stack_frame
->
a0
=
(
rt_ubase_t
)
parameter
;
stack_frame
->
epc
=
(
rt_ubase_t
)
tentry
;
// force to machine mode(MPP=11) and set MPIE to 1
stack_frame
->
mstatus
=
0x00001880
;
return
stk
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录