Compare commits
61 Commits
feature_re
...
master
Author | SHA1 | Date | |
---|---|---|---|
e144544d17 | |||
|
7bba75753c | ||
|
9028cb29f7 | ||
|
6d702e579f | ||
|
2d894b4102 | ||
|
03cd2c005d | ||
|
84e8c65683 | ||
|
000887795f | ||
|
9fdd46fa8b | ||
|
fc73538153 | ||
|
6bde1c520d | ||
|
1572cda572 | ||
|
efa6eb1dc2 | ||
0e88d49e77 | |||
|
192b177518 | ||
|
0d737de882 | ||
|
2725e412ea | ||
|
2fa6b67412 | ||
|
04ceae4349 | ||
|
095872e914 | ||
|
e5f0b628f2 | ||
|
5b895ad7a4 | ||
|
3b161b58f2 | ||
|
8b73db6c03 | ||
|
4a43d3cdae | ||
|
e0b04166e8 | ||
|
c5a9371131 | ||
|
9ef9e4b0f8 | ||
|
bc7a43bdaf | ||
|
fcb9fd5ded | ||
|
366fea22dc | ||
|
738d03f22b | ||
|
c2e6f20caf | ||
|
312897d2ce | ||
|
622fa0e7ce | ||
|
3bfb9eec25 | ||
|
28125ab9df | ||
|
09375e8a96 | ||
|
b8a6b1e38a | ||
|
ea48042fe3 | ||
|
651149fcbb | ||
|
d06f9ac9df | ||
6a8edc0932 | |||
2cc76bb50c | |||
|
033e5f4fd4 | ||
|
382c330725 | ||
|
8215a83523 | ||
e071b9b4d1 | |||
bdc8da5546 | |||
|
18510fa80f | ||
|
c90b449dac | ||
|
fe77341621 | ||
e20c5edd75 | |||
|
495927696e | ||
|
b571cd8899 | ||
|
33753f6331 | ||
|
d948dba42a | ||
|
fd209cb880 | ||
|
250de62d5c | ||
|
68edd04cbb | ||
|
3a83e5524f |
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -3,7 +3,7 @@
|
|||||||
"files.exclude": {
|
"files.exclude": {
|
||||||
"**/.git": true,
|
"**/.git": true,
|
||||||
"**/build": true,
|
"**/build": true,
|
||||||
"bsp" : true,
|
// "bsp" : true,
|
||||||
},
|
},
|
||||||
"editor.renderWhitespace": "all"
|
"editor.renderWhitespace": "all"
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -74,6 +74,7 @@ CONFIG_ARCH_ARM_CORTEX_A9=y
|
|||||||
CONFIG_RT_USING_COMPONENTS_INIT=y
|
CONFIG_RT_USING_COMPONENTS_INIT=y
|
||||||
CONFIG_RT_USING_USER_MAIN=y
|
CONFIG_RT_USING_USER_MAIN=y
|
||||||
CONFIG_RT_MAIN_THREAD_STACK_SIZE=2048
|
CONFIG_RT_MAIN_THREAD_STACK_SIZE=2048
|
||||||
|
CONFIG_RT_MAIN_THREAD_PRIORITY=10
|
||||||
|
|
||||||
#
|
#
|
||||||
# C++ features
|
# C++ features
|
||||||
@ -107,6 +108,7 @@ CONFIG_DFS_USING_WORKDIR=y
|
|||||||
CONFIG_DFS_FILESYSTEMS_MAX=2
|
CONFIG_DFS_FILESYSTEMS_MAX=2
|
||||||
CONFIG_DFS_FILESYSTEM_TYPES_MAX=2
|
CONFIG_DFS_FILESYSTEM_TYPES_MAX=2
|
||||||
CONFIG_DFS_FD_MAX=16
|
CONFIG_DFS_FD_MAX=16
|
||||||
|
# CONFIG_RT_USING_DFS_MNTTABLE is not set
|
||||||
CONFIG_RT_USING_DFS_ELMFAT=y
|
CONFIG_RT_USING_DFS_ELMFAT=y
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -251,11 +253,18 @@ CONFIG_LWIP_SO_SNDTIMEO=1
|
|||||||
CONFIG_LWIP_SO_RCVBUF=1
|
CONFIG_LWIP_SO_RCVBUF=1
|
||||||
# CONFIG_RT_LWIP_NETIF_LOOPBACK is not set
|
# CONFIG_RT_LWIP_NETIF_LOOPBACK is not set
|
||||||
CONFIG_LWIP_NETIF_LOOPBACK=0
|
CONFIG_LWIP_NETIF_LOOPBACK=0
|
||||||
|
# CONFIG_RT_LWIP_STATS is not set
|
||||||
|
# CONFIG_RT_LWIP_DEBUG is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# Modbus master and slave stack
|
# Modbus master and slave stack
|
||||||
#
|
#
|
||||||
# CONFIG_RT_USING_MODBUS is not set
|
# CONFIG_RT_USING_MODBUS is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# AT commands
|
||||||
|
#
|
||||||
|
# CONFIG_RT_USING_AT is not set
|
||||||
# CONFIG_LWIP_USING_DHCPD is not set
|
# CONFIG_LWIP_USING_DHCPD is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
@ -293,7 +302,6 @@ CONFIG_LOG_TRACE_USING_LEVEL_INFO=y
|
|||||||
# CONFIG_PKG_USING_LJSON is not set
|
# CONFIG_PKG_USING_LJSON is not set
|
||||||
# CONFIG_PKG_USING_EZXML is not set
|
# CONFIG_PKG_USING_EZXML is not set
|
||||||
# CONFIG_PKG_USING_NANOPB is not set
|
# CONFIG_PKG_USING_NANOPB is not set
|
||||||
# CONFIG_PKG_USING_GAGENT_CLOUD is not set
|
|
||||||
|
|
||||||
#
|
#
|
||||||
# Wi-Fi
|
# Wi-Fi
|
||||||
@ -311,9 +319,15 @@ CONFIG_LOG_TRACE_USING_LEVEL_INFO=y
|
|||||||
# CONFIG_PKG_USING_COAP is not set
|
# CONFIG_PKG_USING_COAP is not set
|
||||||
# CONFIG_PKG_USING_NOPOLL is not set
|
# CONFIG_PKG_USING_NOPOLL is not set
|
||||||
# CONFIG_PKG_USING_NETUTILS is not set
|
# CONFIG_PKG_USING_NETUTILS is not set
|
||||||
# CONFIG_PKG_USING_ONENET is not set
|
|
||||||
# CONFIG_PKG_USING_AT_DEVICE is not set
|
# CONFIG_PKG_USING_AT_DEVICE 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
|
||||||
|
|
||||||
#
|
#
|
||||||
# security packages
|
# security packages
|
||||||
#
|
#
|
||||||
@ -362,10 +376,12 @@ CONFIG_LOG_TRACE_USING_LEVEL_INFO=y
|
|||||||
# CONFIG_PKG_USING_STM32F4_HAL is not set
|
# CONFIG_PKG_USING_STM32F4_HAL is not set
|
||||||
# CONFIG_PKG_USING_STM32F4_DRIVERS is not set
|
# CONFIG_PKG_USING_STM32F4_DRIVERS is not set
|
||||||
# CONFIG_PKG_USING_REALTEK_AMEBA is not set
|
# CONFIG_PKG_USING_REALTEK_AMEBA is not set
|
||||||
|
# CONFIG_PKG_USING_SHT2X is not set
|
||||||
|
|
||||||
#
|
#
|
||||||
# miscellaneous packages
|
# miscellaneous packages
|
||||||
#
|
#
|
||||||
|
# CONFIG_PKG_USING_LIBCSV is not set
|
||||||
# CONFIG_PKG_USING_OPTPARSE is not set
|
# CONFIG_PKG_USING_OPTPARSE is not set
|
||||||
# CONFIG_PKG_USING_FASTLZ is not set
|
# CONFIG_PKG_USING_FASTLZ is not set
|
||||||
# CONFIG_PKG_USING_MINILZO is not set
|
# CONFIG_PKG_USING_MINILZO is not set
|
||||||
|
96
bsp/qemu-vexpress-a9/.vscode/launch.json
vendored
Normal file
96
bsp/qemu-vexpress-a9/.vscode/launch.json
vendored
Normal file
@ -0,0 +1,96 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Debug @ Mac/Linux",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceRoot}/rtthread.elf",
|
||||||
|
"args": [],
|
||||||
|
"stopAtEntry": true,
|
||||||
|
"cwd": "${workspaceRoot}",
|
||||||
|
"environment": [],
|
||||||
|
"externalConsole": true,
|
||||||
|
"miDebuggerServerAddress": "localhost:1234",
|
||||||
|
"serverLaunchTimeout": 2000,
|
||||||
|
"targetArchitecture": "ARM",
|
||||||
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"text": "cd ${workspaceRoot}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "shell qemu-dbg.sh"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "target remote localhost:1234"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "file rtthread.elf"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "break application_start"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"customLaunchSetupCommands": [],
|
||||||
|
"launchCompleteCommand": "exec-run",
|
||||||
|
"preLaunchTask": "qemu debug",
|
||||||
|
"osx": {
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"miDebuggerPath": "arm-none-eabi-gdb"
|
||||||
|
},
|
||||||
|
"linux": {
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"miDebuggerPath": "arm-none-eabi-gdb"
|
||||||
|
},
|
||||||
|
"windows": {
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"miDebuggerPath": "arm-none-eabi-gdb.exe"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Debug @ Windows",
|
||||||
|
"type": "cppdbg",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceRoot}\\rtthread.elf",
|
||||||
|
"args": [],
|
||||||
|
"stopAtEntry": true,
|
||||||
|
"cwd": "${workspaceRoot}",
|
||||||
|
"environment": [],
|
||||||
|
"externalConsole": true,
|
||||||
|
"miDebuggerServerAddress": "localhost:1234",
|
||||||
|
"serverLaunchTimeout": 2000,
|
||||||
|
"targetArchitecture": "ARM",
|
||||||
|
"setupCommands": [
|
||||||
|
{
|
||||||
|
"text": "cd ${workspaceRoot}"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "shell qemu-dbg.bat"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "target remote localhost:1234"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "file rtthread.elf"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"text": "break main"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"customLaunchSetupCommands": [],
|
||||||
|
"launchCompleteCommand": "exec-run",
|
||||||
|
"osx": {
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"miDebuggerPath": "arm-none-eabi-gdb"
|
||||||
|
},
|
||||||
|
"linux": {
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"miDebuggerPath": "arm-none-eabi-gdb"
|
||||||
|
},
|
||||||
|
"windows": {
|
||||||
|
"MIMode": "gdb",
|
||||||
|
"miDebuggerPath": "arm-none-eabi-gdb.exe"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
10
bsp/qemu-vexpress-a9/.vscode/settings.json
vendored
Normal file
10
bsp/qemu-vexpress-a9/.vscode/settings.json
vendored
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"C_Cpp.dimInactiveRegions": false,
|
||||||
|
"files.exclude": {
|
||||||
|
"**/.git": true,
|
||||||
|
"**/GPUCache" : true,
|
||||||
|
"**/build" : true,
|
||||||
|
"**/*.pyc" : true
|
||||||
|
},
|
||||||
|
"editor.renderWhitespace": "all"
|
||||||
|
}
|
45
bsp/qemu-vexpress-a9/.vscode/tasks.json
vendored
Normal file
45
bsp/qemu-vexpress-a9/.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
{
|
||||||
|
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||||
|
// for the documentation about the tasks.json format
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "build",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "scons",
|
||||||
|
"problemMatcher": [
|
||||||
|
"$gcc"
|
||||||
|
],
|
||||||
|
"presentation": {
|
||||||
|
"echo": true,
|
||||||
|
"reveal": "always",
|
||||||
|
"focus": true,
|
||||||
|
"panel": "shared",
|
||||||
|
"showReuseMessage": true
|
||||||
|
},
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "clean",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "scons -c",
|
||||||
|
"problemMatcher": [],
|
||||||
|
"presentation": {
|
||||||
|
"echo": true,
|
||||||
|
"reveal": "always",
|
||||||
|
"focus": true,
|
||||||
|
"panel": "shared",
|
||||||
|
"showReuseMessage": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "qemu simulator",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "qemu.bat",
|
||||||
|
"problemMatcher" : []
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -60,10 +60,46 @@ msh />
|
|||||||
| Mouse | 支持 | |
|
| Mouse | 支持 | |
|
||||||
| EMAC | 支持 | |
|
| EMAC | 支持 | |
|
||||||
|
|
||||||
|
### 4.1 使用VSCode编辑、编译、调试
|
||||||
|
|
||||||
|
在qemu-vexpress-a9中已经携带了部分vscode的配置,需要配合着env一起来使用。步骤包括:
|
||||||
|
|
||||||
|
先使用env打开console,然后在console中切换都qemu-vexpress-a9 bsp的目录下,
|
||||||
|
|
||||||
|
```bash
|
||||||
|
scons --target=vsc -s
|
||||||
|
```
|
||||||
|
|
||||||
|
更新vscode需要用到的C/C++头文件搜索路径信息(不是每次都需要更新,只有在使用了menuconfig重新配置了RT-Thread或更改了rtconfig.h头文件时才需要)
|
||||||
|
|
||||||
|
然后在console下输入
|
||||||
|
|
||||||
|
```bash
|
||||||
|
code .
|
||||||
|
```
|
||||||
|
|
||||||
|
启动vscode。使用vscode,目前包含如下的一些功能:
|
||||||
|
|
||||||
|
* 编译 `Ctrl+Shift+B` - 开启vscode内置终端,调用scons进行编译;如果有编译错误也会侦测问题,双击问题跳到指定代码文件、代码行;
|
||||||
|
* 包含执行`qemu`模拟器,`scons -c`进行目标文件清理的任务
|
||||||
|
* `F5` 一键开启QEMU调试模式,并断点停留在`main`函数上;(需要更改下qemu-dbg.bat文件,在qemu-system-arm前加入`start`),即
|
||||||
|
|
||||||
|
```batch
|
||||||
|
@echo off
|
||||||
|
if exist sd.bin goto run
|
||||||
|
qemu-img create -f raw sd.bin 64M
|
||||||
|
|
||||||
|
:run
|
||||||
|
start qemu-system-arm -M vexpress-a9 -kernel rtthread.elf -serial stdio -sd sd.bin -S -s
|
||||||
|
```
|
||||||
|
|
||||||
|
**已知问题** 如果在vscode的目录中额外添加了文件夹,会导致调试不能够启动。
|
||||||
|
|
||||||
## 5. 联系人信息
|
## 5. 联系人信息
|
||||||
|
|
||||||
维护人:bernard
|
维护人:[bernard][4]
|
||||||
|
|
||||||
[1]: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.subset.boards.express/index.html
|
[1]: http://infocenter.arm.com/help/index.jsp?topic=/com.arm.doc.subset.boards.express/index.html
|
||||||
[2]: https://www.rt-thread.org/page/download.html
|
[2]: https://www.rt-thread.org/page/download.html
|
||||||
[3]: https://launchpad.net/gcc-arm-embedded/5.0/5-2016-q3-update/+download/gcc-arm-none-eabi-5_4-2016q3-20160926-linux.tar.bz2
|
[3]: https://launchpad.net/gcc-arm-embedded/5.0/5-2016-q3-update/+download/gcc-arm-none-eabi-5_4-2016q3-20160926-linux.tar.bz2
|
||||||
|
[4]: https://github.com/BernardXiong
|
||||||
|
@ -3,4 +3,4 @@ if exist sd.bin goto run
|
|||||||
qemu-img create -f raw sd.bin 64M
|
qemu-img create -f raw sd.bin 64M
|
||||||
|
|
||||||
:run
|
:run
|
||||||
qemu-system-arm -M vexpress-a9 -kernel rtthread.elf -serial vc -serial vc -sd sd.bin -S -s
|
qemu-system-arm -M vexpress-a9 -kernel rtthread.elf -serial stdio -sd sd.bin -S -s
|
||||||
|
@ -53,6 +53,7 @@
|
|||||||
#define RT_USING_COMPONENTS_INIT
|
#define RT_USING_COMPONENTS_INIT
|
||||||
#define RT_USING_USER_MAIN
|
#define RT_USING_USER_MAIN
|
||||||
#define RT_MAIN_THREAD_STACK_SIZE 2048
|
#define RT_MAIN_THREAD_STACK_SIZE 2048
|
||||||
|
#define RT_MAIN_THREAD_PRIORITY 10
|
||||||
|
|
||||||
/* C++ features */
|
/* C++ features */
|
||||||
|
|
||||||
@ -188,6 +189,9 @@
|
|||||||
/* Modbus master and slave stack */
|
/* Modbus master and slave stack */
|
||||||
|
|
||||||
|
|
||||||
|
/* AT commands */
|
||||||
|
|
||||||
|
|
||||||
/* VBUS(Virtual Software BUS) */
|
/* VBUS(Virtual Software BUS) */
|
||||||
|
|
||||||
|
|
||||||
@ -210,6 +214,9 @@
|
|||||||
/* Wiced WiFi */
|
/* Wiced WiFi */
|
||||||
|
|
||||||
|
|
||||||
|
/* IoT Cloud */
|
||||||
|
|
||||||
|
|
||||||
/* security packages */
|
/* security packages */
|
||||||
|
|
||||||
|
|
||||||
|
322
bsp/qemu-vexpress-gemini/.config
Normal file
322
bsp/qemu-vexpress-gemini/.config
Normal file
@ -0,0 +1,322 @@
|
|||||||
|
#
|
||||||
|
# Automatically generated file; DO NOT EDIT.
|
||||||
|
# RT-Thread Project Configuration
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# RT-Thread Kernel
|
||||||
|
#
|
||||||
|
CONFIG_RT_NAME_MAX=6
|
||||||
|
CONFIG_RT_ALIGN_SIZE=4
|
||||||
|
# CONFIG_RT_THREAD_PRIORITY_8 is not set
|
||||||
|
CONFIG_RT_THREAD_PRIORITY_32=y
|
||||||
|
# CONFIG_RT_THREAD_PRIORITY_256 is not set
|
||||||
|
CONFIG_RT_THREAD_PRIORITY_MAX=32
|
||||||
|
CONFIG_RT_TICK_PER_SECOND=1000
|
||||||
|
CONFIG_RT_USING_OVERFLOW_CHECK=y
|
||||||
|
CONFIG_RT_USING_HOOK=y
|
||||||
|
CONFIG_RT_IDEL_HOOK_LIST_SIZE=4
|
||||||
|
CONFIG_IDLE_THREAD_STACK_SIZE=512
|
||||||
|
# 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
|
||||||
|
#
|
||||||
|
CONFIG_RT_USING_SEMAPHORE=y
|
||||||
|
CONFIG_RT_USING_MUTEX=y
|
||||||
|
CONFIG_RT_USING_EVENT=y
|
||||||
|
CONFIG_RT_USING_MAILBOX=y
|
||||||
|
CONFIG_RT_USING_MESSAGEQUEUE=y
|
||||||
|
# CONFIG_RT_USING_SIGNALS is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# Memory Management
|
||||||
|
#
|
||||||
|
CONFIG_RT_USING_MEMPOOL=y
|
||||||
|
# CONFIG_RT_USING_MEMHEAP is not set
|
||||||
|
# CONFIG_RT_USING_NOHEAP is not set
|
||||||
|
CONFIG_RT_USING_SMALL_MEM=y
|
||||||
|
# CONFIG_RT_USING_SLAB is not set
|
||||||
|
# CONFIG_RT_USING_MEMTRACE is not set
|
||||||
|
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=y
|
||||||
|
CONFIG_RT_USING_CONSOLE=y
|
||||||
|
CONFIG_RT_CONSOLEBUF_SIZE=128
|
||||||
|
CONFIG_RT_CONSOLE_DEVICE_NAME="uart1"
|
||||||
|
# CONFIG_RT_USING_MODULE is not set
|
||||||
|
CONFIG_ARCH_ARM=y
|
||||||
|
CONFIG_ARCH_ARM_CORTEX_A=y
|
||||||
|
CONFIG_ARCH_ARM_CORTEX_A9=y
|
||||||
|
|
||||||
|
#
|
||||||
|
# RT-Thread Components
|
||||||
|
#
|
||||||
|
CONFIG_RT_USING_COMPONENTS_INIT=y
|
||||||
|
# CONFIG_RT_USING_USER_MAIN is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# C++ features
|
||||||
|
#
|
||||||
|
# CONFIG_RT_USING_CPLUSPLUS is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# Command shell
|
||||||
|
#
|
||||||
|
CONFIG_RT_USING_FINSH=y
|
||||||
|
CONFIG_FINSH_THREAD_NAME="tshell"
|
||||||
|
CONFIG_FINSH_USING_HISTORY=y
|
||||||
|
CONFIG_FINSH_HISTORY_LINES=5
|
||||||
|
CONFIG_FINSH_USING_SYMTAB=y
|
||||||
|
CONFIG_FINSH_USING_DESCRIPTION=y
|
||||||
|
# CONFIG_FINSH_ECHO_DISABLE_DEFAULT is not set
|
||||||
|
CONFIG_FINSH_THREAD_PRIORITY=20
|
||||||
|
CONFIG_FINSH_THREAD_STACK_SIZE=4096
|
||||||
|
CONFIG_FINSH_CMD_SIZE=80
|
||||||
|
# CONFIG_FINSH_USING_AUTH is not set
|
||||||
|
CONFIG_FINSH_USING_MSH=y
|
||||||
|
CONFIG_FINSH_USING_MSH_DEFAULT=y
|
||||||
|
# CONFIG_FINSH_USING_MSH_ONLY is not set
|
||||||
|
CONFIG_FINSH_ARG_MAX=10
|
||||||
|
|
||||||
|
#
|
||||||
|
# Device virtual file system
|
||||||
|
#
|
||||||
|
CONFIG_RT_USING_DFS=y
|
||||||
|
CONFIG_DFS_USING_WORKDIR=y
|
||||||
|
CONFIG_DFS_FILESYSTEMS_MAX=2
|
||||||
|
CONFIG_DFS_FILESYSTEM_TYPES_MAX=2
|
||||||
|
CONFIG_DFS_FD_MAX=4
|
||||||
|
# CONFIG_RT_USING_DFS_MNTTABLE is not set
|
||||||
|
# CONFIG_RT_USING_DFS_ELMFAT is not set
|
||||||
|
CONFIG_RT_USING_DFS_DEVFS=y
|
||||||
|
# CONFIG_RT_USING_DFS_ROMFS is not set
|
||||||
|
# CONFIG_RT_USING_DFS_RAMFS is not set
|
||||||
|
# CONFIG_RT_USING_DFS_UFFS is not set
|
||||||
|
# CONFIG_RT_USING_DFS_JFFS2 is not set
|
||||||
|
# CONFIG_RT_USING_DFS_NFS is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# 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=y
|
||||||
|
# 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_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 USB
|
||||||
|
#
|
||||||
|
# CONFIG_RT_USING_USB_HOST is not set
|
||||||
|
# CONFIG_RT_USING_USB_DEVICE is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# POSIX layer and C standard library
|
||||||
|
#
|
||||||
|
CONFIG_RT_USING_LIBC=y
|
||||||
|
CONFIG_RT_USING_PTHREADS=y
|
||||||
|
CONFIG_RT_USING_POSIX=y
|
||||||
|
# CONFIG_RT_USING_POSIX_MMAP is not set
|
||||||
|
# CONFIG_RT_USING_POSIX_TERMIOS is not set
|
||||||
|
# CONFIG_RT_USING_POSIX_AIO is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# Network
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# Socket abstraction layer
|
||||||
|
#
|
||||||
|
# CONFIG_RT_USING_SAL is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# light weight TCP/IP stack
|
||||||
|
#
|
||||||
|
# CONFIG_RT_USING_LWIP is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# Modbus master and slave stack
|
||||||
|
#
|
||||||
|
# CONFIG_RT_USING_MODBUS is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# AT commands
|
||||||
|
#
|
||||||
|
# CONFIG_RT_USING_AT is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# VBUS(Virtual Software BUS)
|
||||||
|
#
|
||||||
|
CONFIG_RT_USING_VBUS=y
|
||||||
|
# CONFIG_RT_USING_VBUS_RFS is not set
|
||||||
|
# CONFIG_RT_USING_VBUS_RSHELL is not set
|
||||||
|
CONFIG_RT_VBUS_USING_TESTS=y
|
||||||
|
CONFIG__RT_VBUS_RING_BASE=0x6f800000
|
||||||
|
CONFIG__RT_VBUS_RING_SZ=2097152
|
||||||
|
CONFIG_RT_VBUS_GUEST_VIRQ=14
|
||||||
|
CONFIG_RT_VBUS_HOST_VIRQ=15
|
||||||
|
CONFIG_RT_VBUS_SHELL_DEV_NAME="vbser0"
|
||||||
|
CONFIG_RT_VBUS_RFS_DEV_NAME="rfs"
|
||||||
|
|
||||||
|
#
|
||||||
|
# Utilities
|
||||||
|
#
|
||||||
|
CONFIG_RT_USING_LOGTRACE=y
|
||||||
|
CONFIG_LOG_TRACE_MAX_SESSION=16
|
||||||
|
# CONFIG_LOG_TRACE_USING_LEVEL_NOTRACE is not set
|
||||||
|
# CONFIG_LOG_TRACE_USING_LEVEL_ERROR is not set
|
||||||
|
# CONFIG_LOG_TRACE_USING_LEVEL_WARNING is not set
|
||||||
|
CONFIG_LOG_TRACE_USING_LEVEL_INFO=y
|
||||||
|
# CONFIG_LOG_TRACE_USING_LEVEL_VERBOSE is not set
|
||||||
|
# CONFIG_LOG_TRACE_USING_LEVEL_DEBUG is not set
|
||||||
|
# CONFIG_LOG_TRACE_USING_MEMLOG is not set
|
||||||
|
# CONFIG_RT_USING_RYM is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# RT-Thread online packages
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# IoT - internet of things
|
||||||
|
#
|
||||||
|
# CONFIG_PKG_USING_PAHOMQTT is not set
|
||||||
|
# CONFIG_PKG_USING_WEBCLIENT is not set
|
||||||
|
# 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
|
||||||
|
|
||||||
|
#
|
||||||
|
# Wi-Fi
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# Marvell WiFi
|
||||||
|
#
|
||||||
|
# CONFIG_PKG_USING_WLANMARVELL is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# Wiced WiFi
|
||||||
|
#
|
||||||
|
# CONFIG_PKG_USING_WLAN_WICED is not set
|
||||||
|
# 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
|
||||||
|
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
#
|
||||||
|
# CONFIG_PKG_USING_MBEDTLS is not set
|
||||||
|
# CONFIG_PKG_USING_libsodium is not set
|
||||||
|
# CONFIG_PKG_USING_TINYCRYPT is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# language packages
|
||||||
|
#
|
||||||
|
# CONFIG_PKG_USING_LUA is not set
|
||||||
|
# CONFIG_PKG_USING_JERRYSCRIPT is not set
|
||||||
|
# CONFIG_PKG_USING_MICROPYTHON is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# multimedia packages
|
||||||
|
#
|
||||||
|
# CONFIG_PKG_USING_OPENMV is not set
|
||||||
|
# CONFIG_PKG_USING_MUPDF is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# tools packages
|
||||||
|
#
|
||||||
|
# CONFIG_PKG_USING_CMBACKTRACE is not set
|
||||||
|
# CONFIG_PKG_USING_EASYFLASH is not set
|
||||||
|
# CONFIG_PKG_USING_EASYLOGGER is not set
|
||||||
|
# CONFIG_PKG_USING_SYSTEMVIEW is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# system packages
|
||||||
|
#
|
||||||
|
# CONFIG_PKG_USING_GUIENGINE is not set
|
||||||
|
# CONFIG_PKG_USING_PERSIMMON 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
|
||||||
|
|
||||||
|
#
|
||||||
|
# peripheral libraries and drivers
|
||||||
|
#
|
||||||
|
# CONFIG_PKG_USING_STM32F4_HAL is not set
|
||||||
|
# CONFIG_PKG_USING_STM32F4_DRIVERS is not set
|
||||||
|
# CONFIG_PKG_USING_REALTEK_AMEBA is not set
|
||||||
|
# CONFIG_PKG_USING_SHT2X is not set
|
||||||
|
# CONFIG_PKG_USING_AHT10 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_CANFESTIVAL is not set
|
||||||
|
# CONFIG_PKG_USING_ZLIB is not set
|
||||||
|
# CONFIG_PKG_USING_DSTR is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# sample package
|
||||||
|
#
|
||||||
|
# CONFIG_PKG_USING_SAMPLES is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# example package: hello
|
||||||
|
#
|
||||||
|
# CONFIG_PKG_USING_HELLO is not set
|
||||||
|
CONFIG_SOC_VEXPRESS_GEMINI=y
|
||||||
|
# CONFIG_RT_USING_UART0 is not set
|
||||||
|
CONFIG_RT_USING_UART1=y
|
26
bsp/qemu-vexpress-gemini/Kconfig
Normal file
26
bsp/qemu-vexpress-gemini/Kconfig
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
mainmenu "RT-Thread Project Configuration"
|
||||||
|
|
||||||
|
config $BSP_DIR
|
||||||
|
string
|
||||||
|
option env="BSP_ROOT"
|
||||||
|
default "."
|
||||||
|
|
||||||
|
config $RTT_DIR
|
||||||
|
string
|
||||||
|
option env="RTT_ROOT"
|
||||||
|
default "../.."
|
||||||
|
|
||||||
|
config $PKGS_DIR
|
||||||
|
string
|
||||||
|
option env="PKGS_ROOT"
|
||||||
|
default "packages"
|
||||||
|
|
||||||
|
source "$RTT_DIR/Kconfig"
|
||||||
|
source "$PKGS_DIR/Kconfig"
|
||||||
|
|
||||||
|
config SOC_VEXPRESS_GEMINI
|
||||||
|
bool
|
||||||
|
select ARCH_ARM_CORTEX_A9
|
||||||
|
default y
|
||||||
|
|
||||||
|
source "$BSP_DIR/drivers/Kconfig"
|
14
bsp/qemu-vexpress-gemini/SConscript
Normal file
14
bsp/qemu-vexpress-gemini/SConscript
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# for module compiling
|
||||||
|
import os
|
||||||
|
Import('RTT_ROOT')
|
||||||
|
|
||||||
|
cwd = str(Dir('#'))
|
||||||
|
objs = []
|
||||||
|
list = os.listdir(cwd)
|
||||||
|
|
||||||
|
for d in list:
|
||||||
|
path = os.path.join(cwd, d)
|
||||||
|
if os.path.isfile(os.path.join(path, 'SConscript')):
|
||||||
|
objs = objs + SConscript(os.path.join(d, 'SConscript'))
|
||||||
|
|
||||||
|
Return('objs')
|
29
bsp/qemu-vexpress-gemini/SConstruct
Normal file
29
bsp/qemu-vexpress-gemini/SConstruct
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import rtconfig
|
||||||
|
|
||||||
|
if os.getenv('RTT_ROOT'):
|
||||||
|
RTT_ROOT = os.getenv('RTT_ROOT')
|
||||||
|
else:
|
||||||
|
RTT_ROOT = os.path.normpath(os.getcwd() + '/rt-thread')
|
||||||
|
|
||||||
|
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
|
||||||
|
from building import *
|
||||||
|
|
||||||
|
TARGET = 'rtthread-vexpress.' + rtconfig.TARGET_EXT
|
||||||
|
|
||||||
|
env = Environment(tools = ['mingw'],
|
||||||
|
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
|
||||||
|
CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
|
||||||
|
AR = rtconfig.AR, ARFLAGS = '-rc',
|
||||||
|
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
|
||||||
|
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
|
||||||
|
|
||||||
|
Export('RTT_ROOT')
|
||||||
|
Export('rtconfig')
|
||||||
|
|
||||||
|
# prepare building environment
|
||||||
|
objs = PrepareBuilding(env, RTT_ROOT,has_libcpu=True)
|
||||||
|
|
||||||
|
# make a building
|
||||||
|
DoBuilding(TARGET, objs)
|
11
bsp/qemu-vexpress-gemini/applications/SConscript
Normal file
11
bsp/qemu-vexpress-gemini/applications/SConscript
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
Import('RTT_ROOT')
|
||||||
|
Import('rtconfig')
|
||||||
|
from building import *
|
||||||
|
|
||||||
|
cwd = os.path.join(str(Dir('#')), 'applications')
|
||||||
|
src = Glob('*.c')
|
||||||
|
CPPPATH = [cwd, str(Dir('#'))]
|
||||||
|
|
||||||
|
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
|
||||||
|
|
||||||
|
Return('group')
|
31
bsp/qemu-vexpress-gemini/applications/application.c
Normal file
31
bsp/qemu-vexpress-gemini/applications/application.c
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* File : application.c
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2012, RT-Thread Development Team
|
||||||
|
*
|
||||||
|
* The license and distribution terms for this file may be
|
||||||
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://www.rt-thread.org/license/LICENSE
|
||||||
|
*
|
||||||
|
* Change Logs:
|
||||||
|
* Date Author Notes
|
||||||
|
* 2012-11-20 Bernard the first version
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <rtthread.h>
|
||||||
|
|
||||||
|
void init_thread(void* parameter)
|
||||||
|
{
|
||||||
|
rt_components_init();
|
||||||
|
}
|
||||||
|
|
||||||
|
int rt_application_init()
|
||||||
|
{
|
||||||
|
rt_thread_t tid;
|
||||||
|
|
||||||
|
tid = rt_thread_create("init", init_thread, RT_NULL,
|
||||||
|
1024, RT_THREAD_PRIORITY_MAX/3, 10);
|
||||||
|
if (tid != RT_NULL) rt_thread_startup(tid);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
72
bsp/qemu-vexpress-gemini/applications/startup.c
Normal file
72
bsp/qemu-vexpress-gemini/applications/startup.c
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* File : startup.c
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2006, RT-Thread Develop Team
|
||||||
|
*
|
||||||
|
* The license and distribution terms for this file may be
|
||||||
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://www.rt-thread.org/license/LICENSE
|
||||||
|
*
|
||||||
|
* Change Logs:
|
||||||
|
* Date Author Notes
|
||||||
|
* 2012-12-05 Bernard the first version
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <rthw.h>
|
||||||
|
#include <rtthread.h>
|
||||||
|
|
||||||
|
#include <board.h>
|
||||||
|
|
||||||
|
extern int rt_application_init(void);
|
||||||
|
extern void rt_hw_board_init(void);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function will startup RT-Thread RTOS.
|
||||||
|
*/
|
||||||
|
void rtthread_startup(void)
|
||||||
|
{
|
||||||
|
/* initialzie hardware interrupt */
|
||||||
|
rt_hw_interrupt_init();
|
||||||
|
|
||||||
|
/* initialize board */
|
||||||
|
rt_hw_board_init();
|
||||||
|
|
||||||
|
/* show RT-Thread version */
|
||||||
|
rt_show_version();
|
||||||
|
|
||||||
|
/* initialize memory system */
|
||||||
|
#ifdef RT_USING_HEAP
|
||||||
|
rt_system_heap_init(HEAP_BEGIN, HEAP_END);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* initialize scheduler system */
|
||||||
|
rt_system_scheduler_init();
|
||||||
|
|
||||||
|
/* initialize timer and soft timer thread */
|
||||||
|
rt_system_timer_init();
|
||||||
|
rt_system_timer_thread_init();
|
||||||
|
|
||||||
|
/* initialize application */
|
||||||
|
rt_application_init();
|
||||||
|
|
||||||
|
/* initialize idle thread */
|
||||||
|
rt_thread_idle_init();
|
||||||
|
|
||||||
|
/* start scheduler */
|
||||||
|
rt_system_scheduler_start();
|
||||||
|
|
||||||
|
/* never reach here */
|
||||||
|
return ;
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
/* disable interrupt first */
|
||||||
|
rt_hw_interrupt_disable();
|
||||||
|
|
||||||
|
/* invoke rtthread_startup */
|
||||||
|
rtthread_startup();
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
108
bsp/qemu-vexpress-gemini/applications/vbus_echo.c
Normal file
108
bsp/qemu-vexpress-gemini/applications/vbus_echo.c
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
#include <stdlib.h>
|
||||||
|
#include <rtthread.h>
|
||||||
|
#include <rtdevice.h>
|
||||||
|
|
||||||
|
#include <vbus.h>
|
||||||
|
|
||||||
|
#define BUFLEN 1024
|
||||||
|
static char buf[BUFLEN];
|
||||||
|
|
||||||
|
static void _vbus_on_tx_cmp(void *p)
|
||||||
|
{
|
||||||
|
struct rt_completion *cmp = p;
|
||||||
|
|
||||||
|
rt_completion_done(cmp);
|
||||||
|
}
|
||||||
|
|
||||||
|
static rt_size_t _vbus_write_sync(rt_device_t dev, void *buf, rt_size_t len)
|
||||||
|
{
|
||||||
|
rt_size_t sd;
|
||||||
|
struct rt_completion cmp;
|
||||||
|
struct rt_vbus_dev_liscfg liscfg;
|
||||||
|
|
||||||
|
rt_completion_init(&cmp);
|
||||||
|
liscfg.event = RT_VBUS_EVENT_ID_TX;
|
||||||
|
liscfg.listener = _vbus_on_tx_cmp;
|
||||||
|
liscfg.ctx = &cmp;
|
||||||
|
|
||||||
|
rt_device_control(dev, VBUS_IOC_LISCFG, &liscfg);
|
||||||
|
sd = rt_device_write(dev, 0, buf, len);
|
||||||
|
|
||||||
|
rt_completion_wait(&cmp, RT_WAITING_FOREVER);
|
||||||
|
|
||||||
|
return sd;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _rev_str(char *buf, rt_size_t len)
|
||||||
|
{
|
||||||
|
char tmp;
|
||||||
|
rt_size_t i, mid;
|
||||||
|
|
||||||
|
RT_ASSERT(buf);
|
||||||
|
|
||||||
|
if (!len)
|
||||||
|
return;
|
||||||
|
|
||||||
|
mid = len / 2;
|
||||||
|
for (i = 0; i < mid; i++)
|
||||||
|
{
|
||||||
|
tmp = buf[i];
|
||||||
|
buf[i] = buf[len - 1 - i];
|
||||||
|
buf[len - 1 - i] = tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void _test_write(void *devname)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
rt_device_t dev;
|
||||||
|
|
||||||
|
dev = rt_device_find(devname);
|
||||||
|
|
||||||
|
if (!dev)
|
||||||
|
{
|
||||||
|
rt_kprintf("could not find %s\n", devname);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
again:
|
||||||
|
i = rt_device_open(dev, RT_DEVICE_OFLAG_RDWR);
|
||||||
|
if (i)
|
||||||
|
{
|
||||||
|
rt_kprintf("open dev err:%d\n", i);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < sizeof(buf) - 1;i++)
|
||||||
|
{
|
||||||
|
int len;
|
||||||
|
|
||||||
|
len = rt_device_read(dev, 0, buf + i, 1);
|
||||||
|
if (len != 1 || buf[i] == '\n')
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
buf[i] = '\0';
|
||||||
|
rt_kprintf("recv: %s\n", buf);
|
||||||
|
/* Don't swap the \n. */
|
||||||
|
_rev_str(buf, i - 1);
|
||||||
|
/* Don't write the \0. */
|
||||||
|
rt_kprintf("write: %s\n", buf);
|
||||||
|
_vbus_write_sync(dev, buf, i - 1);
|
||||||
|
|
||||||
|
rt_device_close(dev);
|
||||||
|
goto again;
|
||||||
|
}
|
||||||
|
|
||||||
|
int vser_echo_init(void)
|
||||||
|
{
|
||||||
|
rt_thread_t tid;
|
||||||
|
|
||||||
|
tid = rt_thread_create("vecho", _test_write, "vecho",
|
||||||
|
1024, 0, 20);
|
||||||
|
RT_ASSERT(tid);
|
||||||
|
return rt_thread_startup(tid);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef RT_USING_COMPONENTS_INIT
|
||||||
|
INIT_APP_EXPORT(vser_echo_init);
|
||||||
|
#endif
|
2
bsp/qemu-vexpress-gemini/build.sh
Executable file
2
bsp/qemu-vexpress-gemini/build.sh
Executable file
@ -0,0 +1,2 @@
|
|||||||
|
scons
|
||||||
|
cp rtthread.bin $MO_DIR
|
17
bsp/qemu-vexpress-gemini/cpu/SConscript
Normal file
17
bsp/qemu-vexpress-gemini/cpu/SConscript
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
Import('rtconfig')
|
||||||
|
from building import *
|
||||||
|
|
||||||
|
cwd = GetCurrentDir()
|
||||||
|
src = Glob('*.c')
|
||||||
|
CPPPATH = [cwd]
|
||||||
|
|
||||||
|
if rtconfig.PLATFORM == 'iar':
|
||||||
|
src += Glob('*_iar.S')
|
||||||
|
elif rtconfig.PLATFORM == 'gcc':
|
||||||
|
src += Glob('*_gcc.S')
|
||||||
|
elif rtconfig.PLATFORM == 'armcc':
|
||||||
|
src += Glob('*_rvds.S')
|
||||||
|
|
||||||
|
group = DefineGroup('AM335x', src, depend = [''], CPPPATH = CPPPATH)
|
||||||
|
|
||||||
|
Return('group')
|
64
bsp/qemu-vexpress-gemini/cpu/armv7.h
Normal file
64
bsp/qemu-vexpress-gemini/cpu/armv7.h
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
#ifndef __ARMV7_H__
|
||||||
|
#define __ARMV7_H__
|
||||||
|
|
||||||
|
/* the exception stack without VFP registers */
|
||||||
|
struct rt_hw_exp_stack
|
||||||
|
{
|
||||||
|
unsigned long r0;
|
||||||
|
unsigned long r1;
|
||||||
|
unsigned long r2;
|
||||||
|
unsigned long r3;
|
||||||
|
unsigned long r4;
|
||||||
|
unsigned long r5;
|
||||||
|
unsigned long r6;
|
||||||
|
unsigned long r7;
|
||||||
|
unsigned long r8;
|
||||||
|
unsigned long r9;
|
||||||
|
unsigned long r10;
|
||||||
|
unsigned long fp;
|
||||||
|
unsigned long ip;
|
||||||
|
unsigned long sp;
|
||||||
|
unsigned long lr;
|
||||||
|
unsigned long pc;
|
||||||
|
unsigned long cpsr;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct rt_hw_stack
|
||||||
|
{
|
||||||
|
unsigned long cpsr;
|
||||||
|
unsigned long r0;
|
||||||
|
unsigned long r1;
|
||||||
|
unsigned long r2;
|
||||||
|
unsigned long r3;
|
||||||
|
unsigned long r4;
|
||||||
|
unsigned long r5;
|
||||||
|
unsigned long r6;
|
||||||
|
unsigned long r7;
|
||||||
|
unsigned long r8;
|
||||||
|
unsigned long r9;
|
||||||
|
unsigned long r10;
|
||||||
|
unsigned long fp;
|
||||||
|
unsigned long ip;
|
||||||
|
unsigned long lr;
|
||||||
|
unsigned long pc;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define USERMODE 0x10
|
||||||
|
#define FIQMODE 0x11
|
||||||
|
#define IRQMODE 0x12
|
||||||
|
#define SVCMODE 0x13
|
||||||
|
#define MONITORMODE 0x16
|
||||||
|
#define ABORTMODE 0x17
|
||||||
|
#define HYPMODE 0x1b
|
||||||
|
#define UNDEFMODE 0x1b
|
||||||
|
#define MODEMASK 0x1f
|
||||||
|
#define NOINT 0xc0
|
||||||
|
|
||||||
|
#define T_Bit (1<<5)
|
||||||
|
#define F_Bit (1<<6)
|
||||||
|
#define I_Bit (1<<7)
|
||||||
|
#define A_Bit (1<<8)
|
||||||
|
#define E_Bit (1<<9)
|
||||||
|
#define J_Bit (1<<24)
|
||||||
|
|
||||||
|
#endif
|
105
bsp/qemu-vexpress-gemini/cpu/context_gcc.S
Normal file
105
bsp/qemu-vexpress-gemini/cpu/context_gcc.S
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
/*
|
||||||
|
* File : context.S
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2013, 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
|
||||||
|
* 2013-07-05 Bernard the first version
|
||||||
|
*/
|
||||||
|
|
||||||
|
.section .text, "ax"
|
||||||
|
/*
|
||||||
|
* rt_base_t rt_hw_interrupt_disable();
|
||||||
|
*/
|
||||||
|
.globl rt_hw_interrupt_disable
|
||||||
|
rt_hw_interrupt_disable:
|
||||||
|
mrs r0, cpsr
|
||||||
|
cpsid i
|
||||||
|
bx lr
|
||||||
|
|
||||||
|
/*
|
||||||
|
* void rt_hw_interrupt_enable(rt_base_t level);
|
||||||
|
*/
|
||||||
|
.globl rt_hw_interrupt_enable
|
||||||
|
rt_hw_interrupt_enable:
|
||||||
|
msr cpsr, r0
|
||||||
|
bx lr
|
||||||
|
|
||||||
|
/*
|
||||||
|
* void rt_hw_context_switch_to(rt_uint32 to);
|
||||||
|
* r0 --> to
|
||||||
|
*/
|
||||||
|
.globl rt_hw_context_switch_to
|
||||||
|
rt_hw_context_switch_to:
|
||||||
|
ldr sp, [r0] @ get new task stack pointer
|
||||||
|
|
||||||
|
ldmfd sp!, {r4} @ pop new task spsr
|
||||||
|
msr spsr_cxsf, r4
|
||||||
|
|
||||||
|
ldmfd sp!, {r0-r12, lr, pc}^ @ pop new task r0-r12, lr & pc
|
||||||
|
|
||||||
|
.section .bss.share.isr
|
||||||
|
_guest_switch_lvl:
|
||||||
|
.word 0
|
||||||
|
|
||||||
|
.globl vmm_virq_update
|
||||||
|
|
||||||
|
.section .text.isr, "ax"
|
||||||
|
/*
|
||||||
|
* void rt_hw_context_switch(rt_uint32 from, rt_uint32 to);
|
||||||
|
* r0 --> from
|
||||||
|
* r1 --> to
|
||||||
|
*/
|
||||||
|
.globl rt_hw_context_switch
|
||||||
|
rt_hw_context_switch:
|
||||||
|
stmfd sp!, {lr} @ push pc (lr should be pushed in place of PC)
|
||||||
|
stmfd sp!, {r0-r12, lr} @ push lr & register file
|
||||||
|
|
||||||
|
mrs r4, cpsr
|
||||||
|
tst lr, #0x01
|
||||||
|
orrne r4, r4, #0x20 @ it's thumb code
|
||||||
|
|
||||||
|
stmfd sp!, {r4} @ push cpsr
|
||||||
|
|
||||||
|
str sp, [r0] @ store sp in preempted tasks TCB
|
||||||
|
ldr sp, [r1] @ get new task stack pointer
|
||||||
|
|
||||||
|
ldmfd sp!, {r4} @ pop new task cpsr to spsr
|
||||||
|
msr spsr_cxsf, r4
|
||||||
|
ldmfd sp!, {r0-r12, lr, pc}^ @ pop new task r0-r12, lr & pc, copy spsr to cpsr
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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:
|
||||||
|
ldr r2, =rt_thread_switch_interrupt_flag
|
||||||
|
ldr r3, [r2]
|
||||||
|
cmp r3, #1
|
||||||
|
beq _reswitch
|
||||||
|
ldr ip, =rt_interrupt_from_thread @ set rt_interrupt_from_thread
|
||||||
|
mov r3, #1 @ set rt_thread_switch_interrupt_flag to 1
|
||||||
|
str r0, [ip]
|
||||||
|
str r3, [r2]
|
||||||
|
_reswitch:
|
||||||
|
ldr r2, =rt_interrupt_to_thread @ set rt_interrupt_to_thread
|
||||||
|
str r1, [r2]
|
||||||
|
bx lr
|
12
bsp/qemu-vexpress-gemini/cpu/cp15.h
Normal file
12
bsp/qemu-vexpress-gemini/cpu/cp15.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#ifndef __CP15_H__
|
||||||
|
#define __CP15_H__
|
||||||
|
|
||||||
|
unsigned long rt_cpu_get_smp_id(void);
|
||||||
|
|
||||||
|
void rt_cpu_mmu_disable(void);
|
||||||
|
void rt_cpu_mmu_enable(void);
|
||||||
|
void rt_cpu_tlb_set(volatile unsigned long*);
|
||||||
|
|
||||||
|
void rt_cpu_vector_set_base(unsigned int addr);
|
||||||
|
|
||||||
|
#endif
|
140
bsp/qemu-vexpress-gemini/cpu/cp15_gcc.S
Normal file
140
bsp/qemu-vexpress-gemini/cpu/cp15_gcc.S
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
/*
|
||||||
|
* File : cp15_gcc.S
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2013, RT-Thread Development Team
|
||||||
|
* http://www.rt-thread.org
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* 2013-07-05 Bernard the first version
|
||||||
|
*/
|
||||||
|
|
||||||
|
.globl rt_cpu_get_smp_id
|
||||||
|
rt_cpu_get_smp_id:
|
||||||
|
mrc p15, #0, r0, c0, c0, #5
|
||||||
|
bx lr
|
||||||
|
|
||||||
|
.globl rt_cpu_vector_set_base
|
||||||
|
rt_cpu_vector_set_base:
|
||||||
|
mcr p15, #0, r0, c12, c0, #0
|
||||||
|
dsb
|
||||||
|
bx lr
|
||||||
|
|
||||||
|
.globl rt_hw_cpu_dcache_enable
|
||||||
|
rt_hw_cpu_dcache_enable:
|
||||||
|
mrc p15, #0, r0, c1, c0, #0
|
||||||
|
orr r0, r0, #0x00000004
|
||||||
|
mcr p15, #0, r0, c1, c0, #0
|
||||||
|
bx lr
|
||||||
|
|
||||||
|
.globl rt_hw_cpu_icache_enable
|
||||||
|
rt_hw_cpu_icache_enable:
|
||||||
|
mrc p15, #0, r0, c1, c0, #0
|
||||||
|
orr r0, r0, #0x00001000
|
||||||
|
mcr p15, #0, r0, c1, c0, #0
|
||||||
|
bx lr
|
||||||
|
|
||||||
|
_FLD_MAX_WAY:
|
||||||
|
.word 0x3ff
|
||||||
|
_FLD_MAX_IDX:
|
||||||
|
.word 0x7ff
|
||||||
|
|
||||||
|
.globl rt_cpu_dcache_clean_flush
|
||||||
|
rt_cpu_dcache_clean_flush:
|
||||||
|
push {r4-r11}
|
||||||
|
dmb
|
||||||
|
mrc p15, #1, r0, c0, c0, #1 @ read clid register
|
||||||
|
ands r3, r0, #0x7000000 @ get level of coherency
|
||||||
|
mov r3, r3, lsr #23
|
||||||
|
beq finished
|
||||||
|
mov r10, #0
|
||||||
|
loop1:
|
||||||
|
add r2, r10, r10, lsr #1
|
||||||
|
mov r1, r0, lsr r2
|
||||||
|
and r1, r1, #7
|
||||||
|
cmp r1, #2
|
||||||
|
blt skip
|
||||||
|
mcr p15, #2, r10, c0, c0, #0
|
||||||
|
isb
|
||||||
|
mrc p15, #1, r1, c0, c0, #0
|
||||||
|
and r2, r1, #7
|
||||||
|
add r2, r2, #4
|
||||||
|
ldr r4, _FLD_MAX_WAY
|
||||||
|
ands r4, r4, r1, lsr #3
|
||||||
|
clz r5, r4
|
||||||
|
ldr r7, _FLD_MAX_IDX
|
||||||
|
ands r7, r7, r1, lsr #13
|
||||||
|
loop2:
|
||||||
|
mov r9, r4
|
||||||
|
loop3:
|
||||||
|
orr r11, r10, r9, lsl r5
|
||||||
|
orr r11, r11, r7, lsl r2
|
||||||
|
mcr p15, #0, r11, c7, c14, #2
|
||||||
|
subs r9, r9, #1
|
||||||
|
bge loop3
|
||||||
|
subs r7, r7, #1
|
||||||
|
bge loop2
|
||||||
|
skip:
|
||||||
|
add r10, r10, #2
|
||||||
|
cmp r3, r10
|
||||||
|
bgt loop1
|
||||||
|
|
||||||
|
finished:
|
||||||
|
dsb
|
||||||
|
isb
|
||||||
|
pop {r4-r11}
|
||||||
|
bx lr
|
||||||
|
|
||||||
|
.globl rt_hw_cpu_dcache_disable
|
||||||
|
rt_hw_cpu_dcache_disable:
|
||||||
|
push {r4-r11, lr}
|
||||||
|
bl rt_cpu_dcache_clean_flush
|
||||||
|
mrc p15, #0, r0, c1, c0, #0
|
||||||
|
bic r0, r0, #0x00000004
|
||||||
|
mcr p15, #0, r0, c1, c0, #0
|
||||||
|
pop {r4-r11, lr}
|
||||||
|
bx lr
|
||||||
|
|
||||||
|
.globl rt_hw_cpu_icache_disable
|
||||||
|
rt_hw_cpu_icache_disable:
|
||||||
|
mrc p15, #0, r0, c1, c0, #0
|
||||||
|
bic r0, r0, #0x00001000
|
||||||
|
mcr p15, #0, r0, c1, c0, #0
|
||||||
|
bx lr
|
||||||
|
|
||||||
|
.globl rt_cpu_mmu_disable
|
||||||
|
rt_cpu_mmu_disable:
|
||||||
|
mcr p15, #0, r0, c8, c7, #0 @ invalidate tlb
|
||||||
|
mrc p15, #0, r0, c1, c0, #0
|
||||||
|
bic r0, r0, #1
|
||||||
|
mcr p15, #0, r0, c1, c0, #0 @ clear mmu bit
|
||||||
|
dsb
|
||||||
|
bx lr
|
||||||
|
|
||||||
|
.globl rt_cpu_mmu_enable
|
||||||
|
rt_cpu_mmu_enable:
|
||||||
|
mrc p15, #0, r0, c1, c0, #0
|
||||||
|
orr r0, r0, #0x001
|
||||||
|
mcr p15, #0, r0, c1, c0, #0 @ set mmu enable bit
|
||||||
|
dsb
|
||||||
|
bx lr
|
||||||
|
|
||||||
|
.globl rt_cpu_tlb_set
|
||||||
|
rt_cpu_tlb_set:
|
||||||
|
mcr p15, #0, r0, c2, c0, #0
|
||||||
|
dmb
|
||||||
|
bx lr
|
37
bsp/qemu-vexpress-gemini/cpu/cpu.c
Normal file
37
bsp/qemu-vexpress-gemini/cpu/cpu.c
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* File : cpu.c
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2006, RT-Thread Develop Team
|
||||||
|
*
|
||||||
|
* The license and distribution terms for this file may be
|
||||||
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://www.rt-thread.org/license/LICENSE
|
||||||
|
*
|
||||||
|
* Change Logs:
|
||||||
|
* Date Author Notes
|
||||||
|
* 2011-09-15 Bernard first version
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <rthw.h>
|
||||||
|
#include <rtthread.h>
|
||||||
|
#include <board.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup AM33xx
|
||||||
|
*/
|
||||||
|
/*@{*/
|
||||||
|
|
||||||
|
/** shutdown CPU */
|
||||||
|
void rt_hw_cpu_shutdown()
|
||||||
|
{
|
||||||
|
rt_uint32_t level;
|
||||||
|
rt_kprintf("shutdown...\n");
|
||||||
|
|
||||||
|
level = rt_hw_interrupt_disable();
|
||||||
|
while (level)
|
||||||
|
{
|
||||||
|
RT_ASSERT(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*@}*/
|
316
bsp/qemu-vexpress-gemini/cpu/gic.c
Normal file
316
bsp/qemu-vexpress-gemini/cpu/gic.c
Normal file
@ -0,0 +1,316 @@
|
|||||||
|
/*
|
||||||
|
* File : gic.c, ARM Generic Interrupt Controller
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2013-2014, RT-Thread Develop Team
|
||||||
|
*
|
||||||
|
* The license and distribution terms for this file may be
|
||||||
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://www.rt-thread.org/license/LICENSE
|
||||||
|
*
|
||||||
|
* Change Logs:
|
||||||
|
* Date Author Notes
|
||||||
|
* 2013-07-20 Bernard first version
|
||||||
|
* 2014-04-03 Grissiom many enhancements
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <rtthread.h>
|
||||||
|
#include <board.h>
|
||||||
|
|
||||||
|
#include "gic.h"
|
||||||
|
#include "cp15.h"
|
||||||
|
|
||||||
|
struct arm_gic
|
||||||
|
{
|
||||||
|
rt_uint32_t offset;
|
||||||
|
|
||||||
|
rt_uint32_t dist_hw_base;
|
||||||
|
rt_uint32_t cpu_hw_base;
|
||||||
|
};
|
||||||
|
static struct arm_gic _gic_table[ARM_GIC_MAX_NR];
|
||||||
|
|
||||||
|
#define GIC_CPU_CTRL(hw_base) __REG32((hw_base) + 0x00)
|
||||||
|
#define GIC_CPU_PRIMASK(hw_base) __REG32((hw_base) + 0x04)
|
||||||
|
#define GIC_CPU_BINPOINT(hw_base) __REG32((hw_base) + 0x08)
|
||||||
|
#define GIC_CPU_INTACK(hw_base) __REG32((hw_base) + 0x0c)
|
||||||
|
#define GIC_CPU_EOI(hw_base) __REG32((hw_base) + 0x10)
|
||||||
|
#define GIC_CPU_RUNNINGPRI(hw_base) __REG32((hw_base) + 0x14)
|
||||||
|
#define GIC_CPU_HIGHPRI(hw_base) __REG32((hw_base) + 0x18)
|
||||||
|
|
||||||
|
#define GIC_DIST_CTRL(hw_base) __REG32((hw_base) + 0x000)
|
||||||
|
#define GIC_DIST_TYPE(hw_base) __REG32((hw_base) + 0x004)
|
||||||
|
#define GIC_DIST_IGROUP(hw_base, n) __REG32((hw_base) + 0x080 + ((n)/32) * 4)
|
||||||
|
#define GIC_DIST_ENABLE_SET(hw_base, n) __REG32((hw_base) + 0x100 + ((n)/32) * 4)
|
||||||
|
#define GIC_DIST_ENABLE_CLEAR(hw_base, n) __REG32((hw_base) + 0x180 + ((n)/32) * 4)
|
||||||
|
#define GIC_DIST_PENDING_SET(hw_base, n) __REG32((hw_base) + 0x200 + ((n)/32) * 4)
|
||||||
|
#define GIC_DIST_PENDING_CLEAR(hw_base, n) __REG32((hw_base) + 0x280 + ((n)/32) * 4)
|
||||||
|
#define GIC_DIST_ACTIVE_SET(hw_base, n) __REG32((hw_base) + 0x300 + ((n)/32) * 4)
|
||||||
|
#define GIC_DIST_ACTIVE_CLEAR(hw_base, n) __REG32((hw_base) + 0x380 + ((n)/32) * 4)
|
||||||
|
#define GIC_DIST_PRI(hw_base, n) __REG32((hw_base) + 0x400 + ((n)/4) * 4)
|
||||||
|
#define GIC_DIST_TARGET(hw_base, n) __REG32((hw_base) + 0x800 + ((n)/4) * 4)
|
||||||
|
#define GIC_DIST_CONFIG(hw_base, n) __REG32((hw_base) + 0xc00 + ((n)/16) * 4)
|
||||||
|
#define GIC_DIST_SOFTINT(hw_base) __REG32((hw_base) + 0xf00)
|
||||||
|
#define GIC_DIST_CPENDSGI(hw_base, n) __REG32((hw_base) + 0xf10 + ((n)/4) * 4)
|
||||||
|
#define GIC_DIST_ICPIDR2(hw_base) __REG32((hw_base) + 0xfe8)
|
||||||
|
|
||||||
|
static unsigned int _gic_max_irq;
|
||||||
|
|
||||||
|
int arm_gic_get_active_irq(rt_uint32_t index)
|
||||||
|
{
|
||||||
|
int irq;
|
||||||
|
|
||||||
|
RT_ASSERT(index < ARM_GIC_MAX_NR);
|
||||||
|
|
||||||
|
irq = GIC_CPU_INTACK(_gic_table[index].cpu_hw_base);
|
||||||
|
irq += _gic_table[index].offset;
|
||||||
|
return irq;
|
||||||
|
}
|
||||||
|
|
||||||
|
void arm_gic_ack(rt_uint32_t index, int irq)
|
||||||
|
{
|
||||||
|
rt_uint32_t mask = 1 << (irq % 32);
|
||||||
|
|
||||||
|
RT_ASSERT(index < ARM_GIC_MAX_NR);
|
||||||
|
|
||||||
|
irq = irq - _gic_table[index].offset;
|
||||||
|
RT_ASSERT(irq >= 0);
|
||||||
|
|
||||||
|
GIC_DIST_ENABLE_CLEAR(_gic_table[index].dist_hw_base, irq) = mask;
|
||||||
|
GIC_CPU_EOI(_gic_table[index].cpu_hw_base) = irq;
|
||||||
|
GIC_DIST_ENABLE_SET(_gic_table[index].dist_hw_base, irq) = mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
void arm_gic_mask(rt_uint32_t index, int irq)
|
||||||
|
{
|
||||||
|
rt_uint32_t mask = 1 << (irq % 32);
|
||||||
|
|
||||||
|
RT_ASSERT(index < ARM_GIC_MAX_NR);
|
||||||
|
|
||||||
|
irq = irq - _gic_table[index].offset;
|
||||||
|
RT_ASSERT(irq >= 0);
|
||||||
|
|
||||||
|
GIC_DIST_ENABLE_CLEAR(_gic_table[index].dist_hw_base, irq) = mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
void arm_gic_clear_pending(rt_uint32_t index, int irq)
|
||||||
|
{
|
||||||
|
rt_uint32_t mask = 1 << (irq % 32);
|
||||||
|
|
||||||
|
RT_ASSERT(index < ARM_GIC_MAX_NR);
|
||||||
|
|
||||||
|
irq = irq - _gic_table[index].offset;
|
||||||
|
RT_ASSERT(irq >= 0);
|
||||||
|
|
||||||
|
GIC_DIST_PENDING_CLEAR(_gic_table[index].dist_hw_base, irq) = mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
void arm_gic_clear_active(rt_uint32_t index, int irq)
|
||||||
|
{
|
||||||
|
rt_uint32_t mask = 1 << (irq % 32);
|
||||||
|
|
||||||
|
RT_ASSERT(index < ARM_GIC_MAX_NR);
|
||||||
|
|
||||||
|
irq = irq - _gic_table[index].offset;
|
||||||
|
RT_ASSERT(irq >= 0);
|
||||||
|
|
||||||
|
GIC_DIST_ACTIVE_CLEAR(_gic_table[index].dist_hw_base, irq) = mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
void arm_gic_set_cpu(rt_uint32_t index, int irq, unsigned int cpumask)
|
||||||
|
{
|
||||||
|
rt_uint32_t old_tgt;
|
||||||
|
|
||||||
|
RT_ASSERT(index < ARM_GIC_MAX_NR);
|
||||||
|
|
||||||
|
irq = irq - _gic_table[index].offset;
|
||||||
|
RT_ASSERT(irq >= 0);
|
||||||
|
|
||||||
|
old_tgt = GIC_DIST_TARGET(_gic_table[index].dist_hw_base, irq);
|
||||||
|
|
||||||
|
old_tgt &= ~(0x0FFUL << ((irq % 4)*8));
|
||||||
|
old_tgt |= cpumask << ((irq % 4)*8);
|
||||||
|
|
||||||
|
GIC_DIST_TARGET(_gic_table[index].dist_hw_base, irq) = old_tgt;
|
||||||
|
}
|
||||||
|
|
||||||
|
void arm_gic_umask(rt_uint32_t index, int irq)
|
||||||
|
{
|
||||||
|
rt_uint32_t mask = 1 << (irq % 32);
|
||||||
|
|
||||||
|
RT_ASSERT(index < ARM_GIC_MAX_NR);
|
||||||
|
|
||||||
|
irq = irq - _gic_table[index].offset;
|
||||||
|
RT_ASSERT(irq >= 0);
|
||||||
|
|
||||||
|
GIC_DIST_ENABLE_SET(_gic_table[index].dist_hw_base, irq) = mask;
|
||||||
|
}
|
||||||
|
|
||||||
|
void arm_gic_dump_type(rt_uint32_t index)
|
||||||
|
{
|
||||||
|
unsigned int gic_type;
|
||||||
|
|
||||||
|
gic_type = GIC_DIST_TYPE(_gic_table[index].dist_hw_base);
|
||||||
|
rt_kprintf("GICv%d on %p, max IRQs: %d, %s security extension(%08x)\n",
|
||||||
|
(GIC_DIST_ICPIDR2(_gic_table[index].dist_hw_base) >> 4) & 0xf,
|
||||||
|
_gic_table[index].dist_hw_base,
|
||||||
|
_gic_max_irq,
|
||||||
|
gic_type & (1 << 10) ? "has" : "no",
|
||||||
|
gic_type);
|
||||||
|
}
|
||||||
|
|
||||||
|
void arm_gic_dump(rt_uint32_t index)
|
||||||
|
{
|
||||||
|
unsigned int i, k;
|
||||||
|
|
||||||
|
k = GIC_CPU_HIGHPRI(_gic_table[index].cpu_hw_base);
|
||||||
|
rt_kprintf("--- high pending priority: %d(%08x)\n", k, k);
|
||||||
|
rt_kprintf("--- hw mask ---\n");
|
||||||
|
for (i = 0; i < _gic_max_irq / 32; i++)
|
||||||
|
{
|
||||||
|
rt_kprintf("0x%08x, ",
|
||||||
|
GIC_DIST_ENABLE_SET(_gic_table[index].dist_hw_base,
|
||||||
|
i * 32));
|
||||||
|
}
|
||||||
|
rt_kprintf("\n--- hw pending ---\n");
|
||||||
|
for (i = 0; i < _gic_max_irq / 32; i++)
|
||||||
|
{
|
||||||
|
rt_kprintf("0x%08x, ",
|
||||||
|
GIC_DIST_PENDING_SET(_gic_table[index].dist_hw_base,
|
||||||
|
i * 32));
|
||||||
|
}
|
||||||
|
rt_kprintf("\n--- hw active ---\n");
|
||||||
|
for (i = 0; i < _gic_max_irq / 32; i++)
|
||||||
|
{
|
||||||
|
rt_kprintf("0x%08x, ",
|
||||||
|
GIC_DIST_ACTIVE_SET(_gic_table[index].dist_hw_base,
|
||||||
|
i * 32));
|
||||||
|
}
|
||||||
|
rt_kprintf("\n");
|
||||||
|
}
|
||||||
|
#ifdef RT_USING_FINSH
|
||||||
|
#include <finsh.h>
|
||||||
|
FINSH_FUNCTION_EXPORT_ALIAS(arm_gic_dump, gic, show gic status);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int arm_gic_dist_init(rt_uint32_t index, rt_uint32_t dist_base, int irq_start)
|
||||||
|
{
|
||||||
|
unsigned int gic_type, i;
|
||||||
|
rt_uint32_t cpumask = 1 << 0;
|
||||||
|
|
||||||
|
RT_ASSERT(index < ARM_GIC_MAX_NR);
|
||||||
|
|
||||||
|
_gic_table[index].dist_hw_base = dist_base;
|
||||||
|
_gic_table[index].offset = irq_start;
|
||||||
|
|
||||||
|
/* Find out how many interrupts are supported. */
|
||||||
|
gic_type = GIC_DIST_TYPE(dist_base);
|
||||||
|
_gic_max_irq = ((gic_type & 0x1f) + 1) * 32;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* The GIC only supports up to 1020 interrupt sources.
|
||||||
|
* Limit this to either the architected maximum, or the
|
||||||
|
* platform maximum.
|
||||||
|
*/
|
||||||
|
if (_gic_max_irq > 1020)
|
||||||
|
_gic_max_irq = 1020;
|
||||||
|
if (_gic_max_irq > ARM_GIC_NR_IRQS)
|
||||||
|
_gic_max_irq = ARM_GIC_NR_IRQS;
|
||||||
|
|
||||||
|
#ifndef RT_PRETENT_AS_CPU0
|
||||||
|
/* If we are run on the second core, the GIC should have already been setup
|
||||||
|
* by BootStrapProcessor. */
|
||||||
|
if ((rt_cpu_get_smp_id() & 0xF) != 0)
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
#ifdef RT_USING_VMM
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
cpumask |= cpumask << 8;
|
||||||
|
cpumask |= cpumask << 16;
|
||||||
|
|
||||||
|
GIC_DIST_CTRL(dist_base) = 0x0;
|
||||||
|
|
||||||
|
/* Set all global interrupts to be level triggered, active low. */
|
||||||
|
for (i = 32; i < _gic_max_irq; i += 16)
|
||||||
|
GIC_DIST_CONFIG(dist_base, i) = 0x0;
|
||||||
|
|
||||||
|
/* Set all global interrupts to this CPU only. */
|
||||||
|
for (i = 32; i < _gic_max_irq; i += 4)
|
||||||
|
GIC_DIST_TARGET(dist_base, i) = cpumask;
|
||||||
|
|
||||||
|
/* Set priority on all interrupts. */
|
||||||
|
for (i = 0; i < _gic_max_irq; i += 4)
|
||||||
|
GIC_DIST_PRI(dist_base, i) = 0xa0a0a0a0;
|
||||||
|
|
||||||
|
/* Disable all interrupts. */
|
||||||
|
for (i = 0; i < _gic_max_irq; i += 32)
|
||||||
|
GIC_DIST_ENABLE_CLEAR(dist_base, i) = 0xffffffff;
|
||||||
|
/* All interrupts defaults to IGROUP1(IRQ). */
|
||||||
|
for (i = 0; i < _gic_max_irq; i += 32)
|
||||||
|
GIC_DIST_IGROUP(dist_base, i) = 0xffffffff;
|
||||||
|
|
||||||
|
/* Enable group0 and group1 interrupt forwarding. */
|
||||||
|
GIC_DIST_CTRL(dist_base) = 0x03;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int arm_gic_cpu_init(rt_uint32_t index, rt_uint32_t cpu_base)
|
||||||
|
{
|
||||||
|
RT_ASSERT(index < ARM_GIC_MAX_NR);
|
||||||
|
|
||||||
|
_gic_table[index].cpu_hw_base = cpu_base;
|
||||||
|
|
||||||
|
#ifndef RT_PRETENT_AS_CPU0
|
||||||
|
/* If we are run on the second core, the GIC should have already been setup
|
||||||
|
* by BootStrapProcessor. */
|
||||||
|
if ((rt_cpu_get_smp_id() & 0xF) != 0)
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
#ifdef RT_USING_VMM
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
GIC_CPU_PRIMASK(cpu_base) = 0xf0;
|
||||||
|
/* Enable CPU interrupt */
|
||||||
|
GIC_CPU_CTRL(cpu_base) = 0x01;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void arm_gic_set_group(rt_uint32_t index, int vector, int group)
|
||||||
|
{
|
||||||
|
/* As for GICv2, there are only group0 and group1. */
|
||||||
|
RT_ASSERT(group <= 1);
|
||||||
|
RT_ASSERT(vector < _gic_max_irq);
|
||||||
|
|
||||||
|
if (group == 0)
|
||||||
|
{
|
||||||
|
GIC_DIST_IGROUP(_gic_table[index].dist_hw_base,
|
||||||
|
vector) &= ~(1 << (vector % 32));
|
||||||
|
}
|
||||||
|
else if (group == 1)
|
||||||
|
{
|
||||||
|
GIC_DIST_IGROUP(_gic_table[index].dist_hw_base,
|
||||||
|
vector) |= (1 << (vector % 32));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void arm_gic_trigger(rt_uint32_t index, int target_cpu, int irq)
|
||||||
|
{
|
||||||
|
unsigned int reg;
|
||||||
|
|
||||||
|
RT_ASSERT(irq <= 15);
|
||||||
|
RT_ASSERT(target_cpu <= 255);
|
||||||
|
|
||||||
|
reg = (target_cpu << 16) | irq;
|
||||||
|
GIC_DIST_SOFTINT(_gic_table[index].dist_hw_base) = reg;
|
||||||
|
}
|
||||||
|
|
||||||
|
void arm_gic_clear_sgi(rt_uint32_t index, int target_cpu, int irq)
|
||||||
|
{
|
||||||
|
RT_ASSERT(irq <= 15);
|
||||||
|
RT_ASSERT(target_cpu <= 255);
|
||||||
|
|
||||||
|
GIC_DIST_CPENDSGI(_gic_table[index].dist_hw_base, irq) = target_cpu << (irq % 4);
|
||||||
|
}
|
35
bsp/qemu-vexpress-gemini/cpu/gic.h
Normal file
35
bsp/qemu-vexpress-gemini/cpu/gic.h
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* File : gic.h, ARM Generic Interrupt Controller
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2013, RT-Thread Develop Team
|
||||||
|
*
|
||||||
|
* The license and distribution terms for this file may be
|
||||||
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://www.rt-thread.org/license/LICENSE
|
||||||
|
*
|
||||||
|
* Change Logs:
|
||||||
|
* Date Author Notes
|
||||||
|
* 2013-07-20 Bernard first version
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __GIC_H__
|
||||||
|
#define __GIC_H__
|
||||||
|
|
||||||
|
int arm_gic_dist_init(rt_uint32_t index, rt_uint32_t dist_base, int irq_start);
|
||||||
|
int arm_gic_cpu_init(rt_uint32_t index, rt_uint32_t cpu_base);
|
||||||
|
|
||||||
|
void arm_gic_mask(rt_uint32_t index, int irq);
|
||||||
|
void arm_gic_umask(rt_uint32_t index, int irq);
|
||||||
|
void arm_gic_set_cpu(rt_uint32_t index, int irq, unsigned int cpumask);
|
||||||
|
void arm_gic_set_group(rt_uint32_t index, int vector, int group);
|
||||||
|
|
||||||
|
int arm_gic_get_active_irq(rt_uint32_t index);
|
||||||
|
void arm_gic_ack(rt_uint32_t index, int irq);
|
||||||
|
|
||||||
|
void arm_gic_trigger(rt_uint32_t index, int target_cpu, int irq);
|
||||||
|
void arm_gic_clear_sgi(rt_uint32_t index, int target_cpu, int irq);
|
||||||
|
|
||||||
|
void arm_gic_dump_type(rt_uint32_t index);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
146
bsp/qemu-vexpress-gemini/cpu/interrupt.c
Normal file
146
bsp/qemu-vexpress-gemini/cpu/interrupt.c
Normal file
@ -0,0 +1,146 @@
|
|||||||
|
/*
|
||||||
|
* File : interrupt.c
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2013-2014, RT-Thread Development Team
|
||||||
|
*
|
||||||
|
* The license and distribution terms for this file may be
|
||||||
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://www.rt-thread.org/license/LICENSE
|
||||||
|
*
|
||||||
|
* Change Logs:
|
||||||
|
* Date Author Notes
|
||||||
|
* 2013-07-06 Bernard first version
|
||||||
|
* 2014-04-03 Grissiom port to VMM
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <rthw.h>
|
||||||
|
#include <rtthread.h>
|
||||||
|
#include "realview.h"
|
||||||
|
#include "gic.h"
|
||||||
|
#include "cp15.h"
|
||||||
|
|
||||||
|
#ifdef RT_USING_VMM
|
||||||
|
#include <vmm.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define MAX_HANDLERS NR_IRQS_PBA8
|
||||||
|
|
||||||
|
extern volatile rt_uint8_t rt_interrupt_nest;
|
||||||
|
|
||||||
|
/* exception and interrupt handler table */
|
||||||
|
struct rt_irq_desc isr_table[MAX_HANDLERS];
|
||||||
|
|
||||||
|
rt_uint32_t rt_interrupt_from_thread;
|
||||||
|
rt_uint32_t rt_interrupt_to_thread;
|
||||||
|
rt_uint32_t rt_thread_switch_interrupt_flag;
|
||||||
|
|
||||||
|
extern void rt_cpu_vector_set_base(unsigned int addr);
|
||||||
|
extern int system_vectors;
|
||||||
|
|
||||||
|
static void rt_hw_vector_init(void)
|
||||||
|
{
|
||||||
|
int sctrl;
|
||||||
|
unsigned int *src = (unsigned int *)&system_vectors;
|
||||||
|
|
||||||
|
/* C12-C0 is only active when SCTLR.V = 0 */
|
||||||
|
asm volatile ("mrc p15, #0, %0, c1, c0, #0"
|
||||||
|
:"=r" (sctrl));
|
||||||
|
sctrl &= ~(1 << 13);
|
||||||
|
asm volatile ("mcr p15, #0, %0, c1, c0, #0"
|
||||||
|
:
|
||||||
|
:"r" (sctrl));
|
||||||
|
|
||||||
|
asm volatile ("mcr p15, #0, %0, c12, c0, #0"
|
||||||
|
:
|
||||||
|
:"r" (src));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function will initialize hardware interrupt
|
||||||
|
*/
|
||||||
|
void rt_hw_interrupt_init(void)
|
||||||
|
{
|
||||||
|
rt_uint32_t gic_cpu_base;
|
||||||
|
rt_uint32_t gic_dist_base;
|
||||||
|
|
||||||
|
/* initialize vector table */
|
||||||
|
rt_hw_vector_init();
|
||||||
|
|
||||||
|
/* initialize exceptions table */
|
||||||
|
rt_memset(isr_table, 0x00, sizeof(isr_table));
|
||||||
|
|
||||||
|
/* initialize ARM GIC */
|
||||||
|
gic_dist_base = REALVIEW_GIC_DIST_BASE;
|
||||||
|
gic_cpu_base = REALVIEW_GIC_CPU_BASE;
|
||||||
|
arm_gic_dist_init(0, gic_dist_base, 0);
|
||||||
|
arm_gic_cpu_init(0, gic_cpu_base);
|
||||||
|
/*arm_gic_dump_type(0);*/
|
||||||
|
|
||||||
|
/* 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)
|
||||||
|
{
|
||||||
|
arm_gic_mask(0, vector);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function will un-mask a interrupt.
|
||||||
|
* @param vector the interrupt number
|
||||||
|
*/
|
||||||
|
void rt_hw_interrupt_umask(int vector)
|
||||||
|
{
|
||||||
|
arm_gic_umask(0, 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, char *name)
|
||||||
|
{
|
||||||
|
rt_isr_handler_t old_handler = RT_NULL;
|
||||||
|
|
||||||
|
if (vector < MAX_HANDLERS)
|
||||||
|
{
|
||||||
|
old_handler = isr_table[vector].handler;
|
||||||
|
|
||||||
|
if (handler != RT_NULL)
|
||||||
|
{
|
||||||
|
#ifdef RT_USING_INTERRUPT_INFO
|
||||||
|
rt_strncpy(isr_table[vector].name, name, RT_NAME_MAX);
|
||||||
|
#endif /* RT_USING_INTERRUPT_INFO */
|
||||||
|
isr_table[vector].handler = handler;
|
||||||
|
isr_table[vector].param = param;
|
||||||
|
}
|
||||||
|
arm_gic_set_cpu(0, vector, 1 << rt_cpu_get_smp_id());
|
||||||
|
}
|
||||||
|
|
||||||
|
return old_handler;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Trigger a software IRQ
|
||||||
|
*
|
||||||
|
* Since we are running in single core, the target CPU are always CPU0.
|
||||||
|
*/
|
||||||
|
void rt_hw_interrupt_trigger(int vector)
|
||||||
|
{
|
||||||
|
arm_gic_trigger(0, 1, vector);
|
||||||
|
}
|
||||||
|
|
||||||
|
void rt_hw_interrupt_clear(int vector)
|
||||||
|
{
|
||||||
|
arm_gic_clear_sgi(0, 1, vector);
|
||||||
|
}
|
50
bsp/qemu-vexpress-gemini/cpu/interrupt.h
Normal file
50
bsp/qemu-vexpress-gemini/cpu/interrupt.h
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
/*
|
||||||
|
* File : interrupt.h
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2011, RT-Thread Development Team
|
||||||
|
*
|
||||||
|
* The license and distribution terms for this file may be
|
||||||
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://www.rt-thread.org/license/LICENSE
|
||||||
|
*
|
||||||
|
* Change Logs:
|
||||||
|
* Date Author Notes
|
||||||
|
* 2013-07-06 Bernard first version
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __INTERRUPT_H__
|
||||||
|
#define __INTERRUPT_H__
|
||||||
|
|
||||||
|
#define INT_IRQ 0x00
|
||||||
|
#define INT_FIQ 0x01
|
||||||
|
|
||||||
|
#define INTC_REVISION(hw_base) REG32((hw_base) + 0x0)
|
||||||
|
#define INTC_SYSCONFIG(hw_base) REG32((hw_base) + 0x10)
|
||||||
|
#define INTC_SYSSTATUS(hw_base) REG32((hw_base) + 0x14)
|
||||||
|
#define INTC_SIR_IRQ(hw_base) REG32((hw_base) + 0x40)
|
||||||
|
#define INTC_SIR_FIQ(hw_base) REG32((hw_base) + 0x44)
|
||||||
|
#define INTC_CONTROL(hw_base) REG32((hw_base) + 0x48)
|
||||||
|
#define INTC_PROTECTION(hw_base) REG32((hw_base) + 0x4c)
|
||||||
|
#define INTC_IDLE(hw_base) REG32((hw_base) + 0x50)
|
||||||
|
#define INTC_IRQ_PRIORITY(hw_base) REG32((hw_base) + 0x60)
|
||||||
|
#define INTC_FIQ_PRIORITY(hw_base) REG32((hw_base) + 0x64)
|
||||||
|
#define INTC_THRESHOLD(hw_base) REG32((hw_base) + 0x68)
|
||||||
|
#define INTC_SICR(hw_base) REG32((hw_base) + 0x6c)
|
||||||
|
#define INTC_SCR(hw_base, n) REG32((hw_base) + 0x70 + ((n) * 0x04))
|
||||||
|
#define INTC_ITR(hw_base, n) REG32((hw_base) + 0x80 + ((n) * 0x20))
|
||||||
|
#define INTC_MIR(hw_base, n) REG32((hw_base) + 0x84 + ((n) * 0x20))
|
||||||
|
#define INTC_MIR_CLEAR(hw_base, n) REG32((hw_base) + 0x88 + ((n) * 0x20))
|
||||||
|
#define INTC_MIR_SET(hw_base, n) REG32((hw_base) + 0x8c + ((n) * 0x20))
|
||||||
|
#define INTC_ISR_SET(hw_base, n) REG32((hw_base) + 0x90 + ((n) * 0x20))
|
||||||
|
#define INTC_ISR_CLEAR(hw_base, n) REG32((hw_base) + 0x94 + ((n) * 0x20))
|
||||||
|
#define INTC_PENDING_IRQ(hw_base, n) REG32((hw_base) + 0x98 + ((n) * 0x20))
|
||||||
|
#define INTC_PENDING_FIQ(hw_base, n) REG32((hw_base) + 0x9c + ((n) * 0x20))
|
||||||
|
#define INTC_ILR(hw_base, n) REG32((hw_base) + 0x100 + ((n) * 0x04))
|
||||||
|
|
||||||
|
void rt_hw_interrupt_control(int vector, int priority, int route);
|
||||||
|
int rt_hw_interrupt_get_active(int fiq_irq);
|
||||||
|
void rt_hw_interrupt_ack(int fiq_irq);
|
||||||
|
void rt_hw_interrupt_trigger(int vector);
|
||||||
|
void rt_hw_interrupt_clear(int vector);
|
||||||
|
|
||||||
|
#endif
|
207
bsp/qemu-vexpress-gemini/cpu/mmu.c
Normal file
207
bsp/qemu-vexpress-gemini/cpu/mmu.c
Normal file
@ -0,0 +1,207 @@
|
|||||||
|
/*
|
||||||
|
* File : mmu.c
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2006, RT-Thread Development Team
|
||||||
|
*
|
||||||
|
* The license and distribution terms for this file may be
|
||||||
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://www.rt-thread.org/license/LICENSE
|
||||||
|
*
|
||||||
|
* Change Logs:
|
||||||
|
* Date Author Notes
|
||||||
|
* 2012-01-10 bernard porting to AM1808
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <rtthread.h>
|
||||||
|
#include <rthw.h>
|
||||||
|
#include <board.h>
|
||||||
|
|
||||||
|
#include "cp15.h"
|
||||||
|
|
||||||
|
#define DESC_SEC (0x2)
|
||||||
|
#define CB (3<<2) //cache_on, write_back
|
||||||
|
#define CNB (2<<2) //cache_on, write_through
|
||||||
|
#define NCB (1<<2) //cache_off,WR_BUF on
|
||||||
|
#define NCNB (0<<2) //cache_off,WR_BUF off
|
||||||
|
#define AP_RW (3<<10) //supervisor=RW, user=RW
|
||||||
|
#define AP_RO (2<<10) //supervisor=RW, user=RO
|
||||||
|
#define XN (1<<4) // eXecute Never
|
||||||
|
|
||||||
|
#define DOMAIN_FAULT (0x0)
|
||||||
|
#define DOMAIN_CHK (0x1)
|
||||||
|
#define DOMAIN_NOTCHK (0x3)
|
||||||
|
#define DOMAIN0 (0x0<<5)
|
||||||
|
#define DOMAIN1 (0x1<<5)
|
||||||
|
|
||||||
|
#define DOMAIN0_ATTR (DOMAIN_CHK<<0)
|
||||||
|
#define DOMAIN1_ATTR (DOMAIN_FAULT<<2)
|
||||||
|
|
||||||
|
/* Read/Write, cache, write back */
|
||||||
|
#define RW_CB (AP_RW|DOMAIN0|CB|DESC_SEC)
|
||||||
|
/* Read/Write, cache, write through */
|
||||||
|
#define RW_CNB (AP_RW|DOMAIN0|CNB|DESC_SEC)
|
||||||
|
/* Read/Write without cache and write buffer */
|
||||||
|
#define RW_NCNB (AP_RW|DOMAIN0|NCNB|DESC_SEC)
|
||||||
|
/* Read/Write without cache and write buffer, no execute */
|
||||||
|
#define RW_NCNBXN (AP_RW|DOMAIN0|NCNB|DESC_SEC|XN)
|
||||||
|
/* Read/Write without cache and write buffer */
|
||||||
|
#define RW_FAULT (AP_RW|DOMAIN1|NCNB|DESC_SEC)
|
||||||
|
|
||||||
|
/* dump 2nd level page table */
|
||||||
|
void rt_hw_cpu_dump_page_table_2nd(rt_uint32_t *ptb)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int fcnt = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < 256; i++)
|
||||||
|
{
|
||||||
|
rt_uint32_t pte2 = ptb[i];
|
||||||
|
if ((pte2 & 0x3) == 0)
|
||||||
|
{
|
||||||
|
if (fcnt == 0)
|
||||||
|
rt_kprintf(" ");
|
||||||
|
rt_kprintf("%04x: ", i);
|
||||||
|
fcnt++;
|
||||||
|
if (fcnt == 16)
|
||||||
|
{
|
||||||
|
rt_kprintf("fault\n");
|
||||||
|
fcnt = 0;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (fcnt != 0)
|
||||||
|
{
|
||||||
|
rt_kprintf("fault\n");
|
||||||
|
fcnt = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
rt_kprintf(" %04x: %x: ", i, pte2);
|
||||||
|
if ((pte2 & 0x3) == 0x1)
|
||||||
|
{
|
||||||
|
rt_kprintf("L,ap:%x,xn:%d,texcb:%02x\n",
|
||||||
|
((pte2 >> 7) | (pte2 >> 4))& 0xf,
|
||||||
|
(pte2 >> 15) & 0x1,
|
||||||
|
((pte2 >> 10) | (pte2 >> 2)) & 0x1f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rt_kprintf("S,ap:%x,xn:%d,texcb:%02x\n",
|
||||||
|
((pte2 >> 7) | (pte2 >> 4))& 0xf, pte2 & 0x1,
|
||||||
|
((pte2 >> 4) | (pte2 >> 2)) & 0x1f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void rt_hw_cpu_dump_page_table(rt_uint32_t *ptb)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int fcnt = 0;
|
||||||
|
|
||||||
|
rt_kprintf("page table@%p\n", ptb);
|
||||||
|
for (i = 0; i < 1024*4; i++)
|
||||||
|
{
|
||||||
|
rt_uint32_t pte1 = ptb[i];
|
||||||
|
if ((pte1 & 0x3) == 0)
|
||||||
|
{
|
||||||
|
rt_kprintf("%03x: ", i);
|
||||||
|
fcnt++;
|
||||||
|
if (fcnt == 16)
|
||||||
|
{
|
||||||
|
rt_kprintf("fault\n");
|
||||||
|
fcnt = 0;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (fcnt != 0)
|
||||||
|
{
|
||||||
|
rt_kprintf("fault\n");
|
||||||
|
fcnt = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
rt_kprintf("%03x: %08x: ", i, pte1);
|
||||||
|
if ((pte1 & 0x3) == 0x3)
|
||||||
|
{
|
||||||
|
rt_kprintf("LPAE\n");
|
||||||
|
}
|
||||||
|
else if ((pte1 & 0x3) == 0x1)
|
||||||
|
{
|
||||||
|
rt_kprintf("pte,ns:%d,domain:%d\n",
|
||||||
|
(pte1 >> 3) & 0x1, (pte1 >> 5) & 0xf);
|
||||||
|
/*
|
||||||
|
*rt_hw_cpu_dump_page_table_2nd((void*)((pte1 & 0xfffffc000)
|
||||||
|
* - 0x80000000 + 0xC0000000));
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
else if (pte1 & (1 << 18))
|
||||||
|
{
|
||||||
|
rt_kprintf("super section,ns:%d,ap:%x,xn:%d,texcb:%02x\n",
|
||||||
|
(pte1 >> 19) & 0x1,
|
||||||
|
((pte1 >> 13) | (pte1 >> 10))& 0xf,
|
||||||
|
(pte1 >> 4) & 0x1,
|
||||||
|
((pte1 >> 10) | (pte1 >> 2)) & 0x1f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rt_kprintf("section,ns:%d,ap:%x,"
|
||||||
|
"xn:%d,texcb:%02x,domain:%d\n",
|
||||||
|
(pte1 >> 19) & 0x1,
|
||||||
|
((pte1 >> 13) | (pte1 >> 10))& 0xf,
|
||||||
|
(pte1 >> 4) & 0x1,
|
||||||
|
(((pte1 & (0x7 << 12)) >> 10) |
|
||||||
|
((pte1 & 0x0c) >> 2)) & 0x1f,
|
||||||
|
(pte1 >> 5) & 0xf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* level1 page table, each entry for 1MB memory. */
|
||||||
|
volatile static unsigned long MMUTable[4*1024] __attribute__((aligned(16*1024)));
|
||||||
|
void rt_hw_mmu_setmtt(rt_uint32_t vaddrStart,
|
||||||
|
rt_uint32_t vaddrEnd,
|
||||||
|
rt_uint32_t paddrStart,
|
||||||
|
rt_uint32_t attr)
|
||||||
|
{
|
||||||
|
volatile rt_uint32_t *pTT;
|
||||||
|
volatile int i, nSec;
|
||||||
|
pTT = (rt_uint32_t *)MMUTable + (vaddrStart >> 20);
|
||||||
|
nSec = (vaddrEnd >> 20) - (vaddrStart >> 20);
|
||||||
|
for(i = 0; i <= nSec; i++)
|
||||||
|
{
|
||||||
|
*pTT = attr | (((paddrStart >> 20) + i) << 20);
|
||||||
|
pTT++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long rt_hw_set_domain_register(unsigned long domain_val)
|
||||||
|
{
|
||||||
|
unsigned long old_domain;
|
||||||
|
|
||||||
|
asm volatile ("mrc p15, 0, %0, c3, c0\n" : "=r" (old_domain));
|
||||||
|
asm volatile ("mcr p15, 0, %0, c3, c0\n" : :"r" (domain_val) : "memory");
|
||||||
|
|
||||||
|
return old_domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
void rt_hw_mmu_init(void)
|
||||||
|
{
|
||||||
|
rt_hw_cpu_dcache_disable();
|
||||||
|
rt_hw_cpu_icache_disable();
|
||||||
|
rt_cpu_mmu_disable();
|
||||||
|
|
||||||
|
/* set page table */
|
||||||
|
/* 4G 1:1 memory */
|
||||||
|
rt_hw_mmu_setmtt(0, 0xffffffff-1, 0, RW_CB);
|
||||||
|
/* IO memory region */
|
||||||
|
rt_hw_mmu_setmtt(0x44000000, 0x80000000-1, 0x44000000, RW_NCNBXN);
|
||||||
|
|
||||||
|
/*rt_hw_cpu_dump_page_table(MMUTable);*/
|
||||||
|
rt_hw_set_domain_register(0x55555555);
|
||||||
|
|
||||||
|
rt_cpu_tlb_set(MMUTable);
|
||||||
|
|
||||||
|
rt_cpu_mmu_enable();
|
||||||
|
|
||||||
|
rt_hw_cpu_icache_enable();
|
||||||
|
rt_hw_cpu_dcache_enable();
|
||||||
|
}
|
||||||
|
|
12
bsp/qemu-vexpress-gemini/cpu/pmu.c
Normal file
12
bsp/qemu-vexpress-gemini/cpu/pmu.c
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#include <rtthread.h>
|
||||||
|
#include "pmu.h"
|
||||||
|
|
||||||
|
void rt_hw_pmu_dump_feature(void)
|
||||||
|
{
|
||||||
|
unsigned long reg;
|
||||||
|
|
||||||
|
reg = rt_hw_pmu_get_control();
|
||||||
|
rt_kprintf("ARM PMU Implementor: %c, ID code: %02x, %d counters\n",
|
||||||
|
reg >> 24, (reg >> 16) & 0xff, (reg >> 11) & 0x1f);
|
||||||
|
RT_ASSERT(ARM_PMU_CNTER_NR == ((reg >> 11) & 0x1f));
|
||||||
|
}
|
151
bsp/qemu-vexpress-gemini/cpu/pmu.h
Normal file
151
bsp/qemu-vexpress-gemini/cpu/pmu.h
Normal file
@ -0,0 +1,151 @@
|
|||||||
|
#ifndef __PMU_H__
|
||||||
|
#define __PMU_H__
|
||||||
|
|
||||||
|
#include "board.h"
|
||||||
|
|
||||||
|
/* Number of counters */
|
||||||
|
#define ARM_PMU_CNTER_NR 4
|
||||||
|
|
||||||
|
enum rt_hw_pmu_event_type {
|
||||||
|
ARM_PMU_EVENT_PMNC_SW_INCR = 0x00,
|
||||||
|
ARM_PMU_EVENT_L1_ICACHE_REFILL = 0x01,
|
||||||
|
ARM_PMU_EVENT_ITLB_REFILL = 0x02,
|
||||||
|
ARM_PMU_EVENT_L1_DCACHE_REFILL = 0x03,
|
||||||
|
ARM_PMU_EVENT_L1_DCACHE_ACCESS = 0x04,
|
||||||
|
ARM_PMU_EVENT_DTLB_REFILL = 0x05,
|
||||||
|
ARM_PMU_EVENT_MEM_READ = 0x06,
|
||||||
|
ARM_PMU_EVENT_MEM_WRITE = 0x07,
|
||||||
|
ARM_PMU_EVENT_INSTR_EXECUTED = 0x08,
|
||||||
|
ARM_PMU_EVENT_EXC_TAKEN = 0x09,
|
||||||
|
ARM_PMU_EVENT_EXC_EXECUTED = 0x0A,
|
||||||
|
ARM_PMU_EVENT_CID_WRITE = 0x0B,
|
||||||
|
};
|
||||||
|
|
||||||
|
/* Enable bit */
|
||||||
|
#define ARM_PMU_PMCR_E (0x01 << 0)
|
||||||
|
/* Event counter reset */
|
||||||
|
#define ARM_PMU_PMCR_P (0x01 << 1)
|
||||||
|
/* Cycle counter reset */
|
||||||
|
#define ARM_PMU_PMCR_C (0x01 << 2)
|
||||||
|
/* Cycle counter divider */
|
||||||
|
#define ARM_PMU_PMCR_D (0x01 << 3)
|
||||||
|
|
||||||
|
#ifdef __GNUC__
|
||||||
|
rt_inline void rt_hw_pmu_enable_cnt(int divide64)
|
||||||
|
{
|
||||||
|
unsigned long pmcr;
|
||||||
|
unsigned long pmcntenset;
|
||||||
|
|
||||||
|
asm volatile ("mrc p15, 0, %0, c9, c12, 0" : "=r"(pmcr));
|
||||||
|
pmcr |= ARM_PMU_PMCR_E | ARM_PMU_PMCR_P | ARM_PMU_PMCR_C;
|
||||||
|
if (divide64)
|
||||||
|
pmcr |= ARM_PMU_PMCR_D;
|
||||||
|
else
|
||||||
|
pmcr &= ~ARM_PMU_PMCR_D;
|
||||||
|
asm volatile ("mcr p15, 0, %0, c9, c12, 0" :: "r"(pmcr));
|
||||||
|
|
||||||
|
/* enable all the counters */
|
||||||
|
pmcntenset = ~0;
|
||||||
|
asm volatile ("mcr p15, 0, %0, c9, c12, 1" :: "r"(pmcntenset));
|
||||||
|
/* clear overflows(just in case) */
|
||||||
|
asm volatile ("mcr p15, 0, %0, c9, c12, 3" :: "r"(pmcntenset));
|
||||||
|
}
|
||||||
|
|
||||||
|
rt_inline unsigned long rt_hw_pmu_get_control(void)
|
||||||
|
{
|
||||||
|
unsigned long pmcr;
|
||||||
|
asm ("mrc p15, 0, %0, c9, c12, 0" : "=r"(pmcr));
|
||||||
|
return pmcr;
|
||||||
|
}
|
||||||
|
|
||||||
|
rt_inline unsigned long rt_hw_pmu_get_ceid(void)
|
||||||
|
{
|
||||||
|
unsigned long reg;
|
||||||
|
/* only PMCEID0 is supported, PMCEID1 is RAZ. */
|
||||||
|
asm ("mrc p15, 0, %0, c9, c12, 6" : "=r"(reg));
|
||||||
|
return reg;
|
||||||
|
}
|
||||||
|
|
||||||
|
rt_inline unsigned long rt_hw_pmu_get_cnten(void)
|
||||||
|
{
|
||||||
|
unsigned long pmcnt;
|
||||||
|
asm ("mrc p15, 0, %0, c9, c12, 1" : "=r"(pmcnt));
|
||||||
|
return pmcnt;
|
||||||
|
}
|
||||||
|
|
||||||
|
rt_inline void rt_hw_pmu_reset_cycle(void)
|
||||||
|
{
|
||||||
|
unsigned long pmcr;
|
||||||
|
|
||||||
|
asm volatile ("mrc p15, 0, %0, c9, c12, 0" : "=r"(pmcr));
|
||||||
|
pmcr |= ARM_PMU_PMCR_C;
|
||||||
|
asm volatile ("mcr p15, 0, %0, c9, c12, 0" :: "r"(pmcr));
|
||||||
|
asm volatile ("isb");
|
||||||
|
}
|
||||||
|
|
||||||
|
rt_inline void rt_hw_pmu_reset_event(void)
|
||||||
|
{
|
||||||
|
unsigned long pmcr;
|
||||||
|
|
||||||
|
asm volatile ("mrc p15, 0, %0, c9, c12, 0" : "=r"(pmcr));
|
||||||
|
pmcr |= ARM_PMU_PMCR_P;
|
||||||
|
asm volatile ("mcr p15, 0, %0, c9, c12, 0" :: "r"(pmcr));
|
||||||
|
asm volatile ("isb");
|
||||||
|
}
|
||||||
|
|
||||||
|
rt_inline unsigned long rt_hw_pmu_get_cycle(void)
|
||||||
|
{
|
||||||
|
unsigned long cyc;
|
||||||
|
asm volatile ("isb");
|
||||||
|
asm volatile ("mrc p15, 0, %0, c9, c13, 0" : "=r"(cyc));
|
||||||
|
return cyc;
|
||||||
|
}
|
||||||
|
|
||||||
|
rt_inline void rt_hw_pmu_select_counter(int idx)
|
||||||
|
{
|
||||||
|
RT_ASSERT(idx < ARM_PMU_CNTER_NR);
|
||||||
|
|
||||||
|
asm volatile ("mcr p15, 0, %0, c9, c12, 5" : : "r"(idx));
|
||||||
|
/* Linux add an isb here, don't know why here. */
|
||||||
|
asm volatile ("isb");
|
||||||
|
}
|
||||||
|
|
||||||
|
rt_inline void rt_hw_pmu_select_event(int idx,
|
||||||
|
enum rt_hw_pmu_event_type eve)
|
||||||
|
{
|
||||||
|
RT_ASSERT(idx < ARM_PMU_CNTER_NR);
|
||||||
|
|
||||||
|
rt_hw_pmu_select_counter(idx);
|
||||||
|
asm volatile ("mcr p15, 0, %0, c9, c13, 1" : : "r"(eve));
|
||||||
|
}
|
||||||
|
|
||||||
|
rt_inline unsigned long rt_hw_pmu_read_counter(int idx)
|
||||||
|
{
|
||||||
|
unsigned long reg;
|
||||||
|
|
||||||
|
rt_hw_pmu_select_counter(idx);
|
||||||
|
asm volatile ("isb");
|
||||||
|
asm volatile ("mrc p15, 0, %0, c9, c13, 2" : "=r"(reg));
|
||||||
|
return reg;
|
||||||
|
}
|
||||||
|
|
||||||
|
rt_inline unsigned long rt_hw_pmu_get_ovsr(void)
|
||||||
|
{
|
||||||
|
unsigned long reg;
|
||||||
|
asm volatile ("isb");
|
||||||
|
asm ("mrc p15, 0, %0, c9, c12, 3" : "=r"(reg));
|
||||||
|
return reg;
|
||||||
|
}
|
||||||
|
|
||||||
|
rt_inline void rt_hw_pmu_clear_ovsr(unsigned long reg)
|
||||||
|
{
|
||||||
|
asm ("mcr p15, 0, %0, c9, c12, 3" : : "r"(reg));
|
||||||
|
asm volatile ("isb");
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
void rt_hw_pmu_dump_feature(void);
|
||||||
|
|
||||||
|
#endif /* end of include guard: __PMU_H__ */
|
||||||
|
|
65
bsp/qemu-vexpress-gemini/cpu/stack.c
Normal file
65
bsp/qemu-vexpress-gemini/cpu/stack.c
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* File : stack.c
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2011, RT-Thread Development Team
|
||||||
|
*
|
||||||
|
* The license and distribution terms for this file may be
|
||||||
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://www.rt-thread.org/license/LICENSE
|
||||||
|
*
|
||||||
|
* Change Logs:
|
||||||
|
* Date Author Notes
|
||||||
|
* 2011-09-23 Bernard the first version
|
||||||
|
* 2011-10-05 Bernard add thumb mode
|
||||||
|
*/
|
||||||
|
#include <rtthread.h>
|
||||||
|
#include <board.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup AM33xx
|
||||||
|
*/
|
||||||
|
/*@{*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
rt_uint32_t *stk;
|
||||||
|
|
||||||
|
stk = (rt_uint32_t*)stack_addr;
|
||||||
|
*(stk) = (rt_uint32_t)tentry; /* entry point */
|
||||||
|
*(--stk) = (rt_uint32_t)texit; /* lr */
|
||||||
|
*(--stk) = 0; /* r12 */
|
||||||
|
*(--stk) = 0; /* r11 */
|
||||||
|
*(--stk) = 0; /* r10 */
|
||||||
|
*(--stk) = 0; /* r9 */
|
||||||
|
*(--stk) = 0; /* r8 */
|
||||||
|
*(--stk) = 0; /* r7 */
|
||||||
|
*(--stk) = 0; /* r6 */
|
||||||
|
*(--stk) = 0; /* r5 */
|
||||||
|
*(--stk) = 0; /* r4 */
|
||||||
|
*(--stk) = 0; /* r3 */
|
||||||
|
*(--stk) = 0; /* r2 */
|
||||||
|
*(--stk) = 0; /* r1 */
|
||||||
|
*(--stk) = (rt_uint32_t)parameter; /* r0 : argument */
|
||||||
|
|
||||||
|
/* cpsr */
|
||||||
|
if ((rt_uint32_t)tentry & 0x01)
|
||||||
|
*(--stk) = SVCMODE | 0x20; /* thumb mode */
|
||||||
|
else
|
||||||
|
*(--stk) = SVCMODE; /* arm mode */
|
||||||
|
|
||||||
|
/* return task's current stack address */
|
||||||
|
return (rt_uint8_t *)stk;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*@}*/
|
249
bsp/qemu-vexpress-gemini/cpu/start_gcc.S
Normal file
249
bsp/qemu-vexpress-gemini/cpu/start_gcc.S
Normal file
@ -0,0 +1,249 @@
|
|||||||
|
/*
|
||||||
|
* File : start_gcc.S
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2013-2014, 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
|
||||||
|
* 2013-07-05 Bernard the first version
|
||||||
|
*/
|
||||||
|
|
||||||
|
.equ Mode_USR, 0x10
|
||||||
|
.equ Mode_FIQ, 0x11
|
||||||
|
.equ Mode_IRQ, 0x12
|
||||||
|
.equ Mode_SVC, 0x13
|
||||||
|
.equ Mode_ABT, 0x17
|
||||||
|
.equ Mode_UND, 0x1B
|
||||||
|
.equ Mode_SYS, 0x1F
|
||||||
|
|
||||||
|
.equ I_Bit, 0x80 @ when I bit is set, IRQ is disabled
|
||||||
|
.equ F_Bit, 0x40 @ when F bit is set, FIQ is disabled
|
||||||
|
|
||||||
|
.equ UND_Stack_Size, 0x00000000
|
||||||
|
.equ SVC_Stack_Size, 0x00000100
|
||||||
|
.equ ABT_Stack_Size, 0x00000000
|
||||||
|
.equ RT_FIQ_STACK_PGSZ, 0x00000000
|
||||||
|
.equ RT_IRQ_STACK_PGSZ, 0x00000100
|
||||||
|
.equ USR_Stack_Size, 0x00000100
|
||||||
|
|
||||||
|
#define ISR_Stack_Size (UND_Stack_Size + SVC_Stack_Size + ABT_Stack_Size + \
|
||||||
|
RT_FIQ_STACK_PGSZ + RT_IRQ_STACK_PGSZ)
|
||||||
|
|
||||||
|
.section .data.share.isr
|
||||||
|
/* stack */
|
||||||
|
.globl stack_start
|
||||||
|
.globl stack_top
|
||||||
|
|
||||||
|
stack_start:
|
||||||
|
.rept ISR_Stack_Size
|
||||||
|
.byte 0
|
||||||
|
.endr
|
||||||
|
stack_top:
|
||||||
|
|
||||||
|
.text
|
||||||
|
/* reset entry */
|
||||||
|
.globl _reset
|
||||||
|
_reset:
|
||||||
|
bl rt_cpu_mmu_disable
|
||||||
|
/* set the cpu to SVC32 mode and disable interrupt */
|
||||||
|
mrs r0, cpsr
|
||||||
|
bic r0, r0, #0x1f
|
||||||
|
orr r0, r0, #0x13
|
||||||
|
msr cpsr_c, r0
|
||||||
|
|
||||||
|
/* setup stack */
|
||||||
|
bl stack_setup
|
||||||
|
|
||||||
|
/* clear .bss */
|
||||||
|
mov r0,#0 /* get a zero */
|
||||||
|
ldr r1,=__bss_start /* bss start */
|
||||||
|
ldr r2,=__bss_end /* bss end */
|
||||||
|
|
||||||
|
bss_loop:
|
||||||
|
cmp r1,r2 /* check if data to clear */
|
||||||
|
strlo r0,[r1],#4 /* clear 4 bytes */
|
||||||
|
blo bss_loop /* loop until done */
|
||||||
|
|
||||||
|
/* call C++ constructors of global objects */
|
||||||
|
ldr r0, =__ctors_start__
|
||||||
|
ldr r1, =__ctors_end__
|
||||||
|
|
||||||
|
ctor_loop:
|
||||||
|
cmp r0, r1
|
||||||
|
beq ctor_end
|
||||||
|
ldr r2, [r0], #4
|
||||||
|
stmfd sp!, {r0-r1}
|
||||||
|
mov lr, pc
|
||||||
|
bx r2
|
||||||
|
ldmfd sp!, {r0-r1}
|
||||||
|
b ctor_loop
|
||||||
|
ctor_end:
|
||||||
|
|
||||||
|
/* start RT-Thread Kernel */
|
||||||
|
ldr pc, _rtthread_startup
|
||||||
|
_rtthread_startup:
|
||||||
|
.word rtthread_startup
|
||||||
|
|
||||||
|
stack_setup:
|
||||||
|
ldr r0, =stack_top
|
||||||
|
|
||||||
|
@ Set the startup stack for svc
|
||||||
|
mov sp, r0
|
||||||
|
|
||||||
|
@ Enter Undefined Instruction Mode and set its Stack Pointer
|
||||||
|
msr cpsr_c, #Mode_UND|I_Bit|F_Bit
|
||||||
|
mov sp, r0
|
||||||
|
sub r0, r0, #UND_Stack_Size
|
||||||
|
|
||||||
|
@ Enter Abort Mode and set its Stack Pointer
|
||||||
|
msr cpsr_c, #Mode_ABT|I_Bit|F_Bit
|
||||||
|
mov sp, r0
|
||||||
|
sub r0, r0, #ABT_Stack_Size
|
||||||
|
|
||||||
|
@ Enter FIQ Mode and set its Stack Pointer
|
||||||
|
msr cpsr_c, #Mode_FIQ|I_Bit|F_Bit
|
||||||
|
mov sp, r0
|
||||||
|
sub r0, r0, #RT_FIQ_STACK_PGSZ
|
||||||
|
|
||||||
|
@ Enter IRQ Mode and set its Stack Pointer
|
||||||
|
msr cpsr_c, #Mode_IRQ|I_Bit|F_Bit
|
||||||
|
mov sp, r0
|
||||||
|
sub r0, r0, #RT_IRQ_STACK_PGSZ
|
||||||
|
|
||||||
|
/* come back to SVC mode */
|
||||||
|
msr cpsr_c, #Mode_SVC|I_Bit|F_Bit
|
||||||
|
bx lr
|
||||||
|
|
||||||
|
/* exception handlers: undef, swi, padt, dabt, resv, irq, fiq */
|
||||||
|
.section .text.isr, "ax"
|
||||||
|
.align 5
|
||||||
|
.globl vector_fiq
|
||||||
|
vector_fiq:
|
||||||
|
stmfd sp!,{r0-r7,lr}
|
||||||
|
bl rt_hw_trap_fiq
|
||||||
|
ldmfd sp!,{r0-r7,lr}
|
||||||
|
subs pc, lr, #4
|
||||||
|
|
||||||
|
.globl rt_interrupt_enter
|
||||||
|
.globl rt_interrupt_leave
|
||||||
|
.globl rt_thread_switch_interrupt_flag
|
||||||
|
.globl rt_interrupt_from_thread
|
||||||
|
.globl rt_interrupt_to_thread
|
||||||
|
|
||||||
|
.globl rt_current_thread
|
||||||
|
.globl vmm_thread
|
||||||
|
.globl vmm_virq_check
|
||||||
|
|
||||||
|
.align 5
|
||||||
|
.globl vector_irq
|
||||||
|
vector_irq:
|
||||||
|
stmfd sp!, {r0-r12,lr}
|
||||||
|
|
||||||
|
bl rt_interrupt_enter
|
||||||
|
bl rt_hw_trap_irq
|
||||||
|
bl rt_interrupt_leave
|
||||||
|
|
||||||
|
@ if rt_thread_switch_interrupt_flag set, jump to
|
||||||
|
@ rt_hw_context_switch_interrupt_do and don't return
|
||||||
|
ldr r0, =rt_thread_switch_interrupt_flag
|
||||||
|
ldr r1, [r0]
|
||||||
|
cmp r1, #1
|
||||||
|
beq rt_hw_context_switch_interrupt_do
|
||||||
|
|
||||||
|
ldmfd sp!, {r0-r12,lr}
|
||||||
|
subs pc, lr, #4
|
||||||
|
|
||||||
|
rt_hw_context_switch_interrupt_do:
|
||||||
|
mov r1, #0 @ clear flag
|
||||||
|
str r1, [r0]
|
||||||
|
|
||||||
|
mov r1, sp @ r1 point to {r0-r3} in stack
|
||||||
|
add sp, sp, #4*4
|
||||||
|
ldmfd sp!, {r4-r12,lr}@ reload saved registers
|
||||||
|
mrs r0, spsr @ get cpsr of interrupt thread
|
||||||
|
sub r2, lr, #4 @ save old task's pc to r2
|
||||||
|
|
||||||
|
@ Switch to SVC mode with no interrupt. If the usr mode guest is
|
||||||
|
@ interrupted, this will just switch to the stack of kernel space.
|
||||||
|
@ save the registers in kernel space won't trigger data abort.
|
||||||
|
msr cpsr_c, #I_Bit|F_Bit|Mode_SVC
|
||||||
|
|
||||||
|
stmfd sp!, {r2} @ push old task's pc
|
||||||
|
stmfd sp!, {r4-r12,lr}@ push old task's lr,r12-r4
|
||||||
|
ldmfd r1, {r1-r4} @ restore r0-r3 of the interrupt thread
|
||||||
|
stmfd sp!, {r1-r4} @ push old task's r0-r3
|
||||||
|
stmfd sp!, {r0} @ push old task's cpsr
|
||||||
|
|
||||||
|
ldr r4, =rt_interrupt_from_thread
|
||||||
|
ldr r5, [r4]
|
||||||
|
str sp, [r5] @ store sp in preempted tasks's TCB
|
||||||
|
|
||||||
|
ldr r6, =rt_interrupt_to_thread
|
||||||
|
ldr r6, [r6]
|
||||||
|
ldr sp, [r6] @ get new task's stack pointer
|
||||||
|
|
||||||
|
ldmfd sp!, {r4} @ pop new task's cpsr to spsr
|
||||||
|
msr spsr_cxsf, r4
|
||||||
|
|
||||||
|
ldmfd sp!, {r0-r12,lr,pc}^ @ pop new task's r0-r12,lr & pc, copy spsr to cpsr
|
||||||
|
|
||||||
|
.macro push_svc_reg
|
||||||
|
sub sp, sp, #17 * 4 @/* Sizeof(struct rt_hw_exp_stack) */
|
||||||
|
stmia sp, {r0 - r12} @/* Calling r0-r12 */
|
||||||
|
mov r0, sp
|
||||||
|
mrs r6, spsr @/* Save CPSR */
|
||||||
|
str lr, [r0, #15*4] @/* Push PC */
|
||||||
|
str r6, [r0, #16*4] @/* Push CPSR */
|
||||||
|
cps #Mode_SVC
|
||||||
|
str sp, [r0, #13*4] @/* Save calling SP */
|
||||||
|
str lr, [r0, #14*4] @/* Save calling PC */
|
||||||
|
.endm
|
||||||
|
|
||||||
|
.align 5
|
||||||
|
.globl vector_swi
|
||||||
|
vector_swi:
|
||||||
|
push_svc_reg
|
||||||
|
bl rt_hw_trap_swi
|
||||||
|
b .
|
||||||
|
|
||||||
|
.align 5
|
||||||
|
.globl vector_undef
|
||||||
|
vector_undef:
|
||||||
|
push_svc_reg
|
||||||
|
bl rt_hw_trap_undef
|
||||||
|
b .
|
||||||
|
|
||||||
|
.align 5
|
||||||
|
.globl vector_pabt
|
||||||
|
vector_pabt:
|
||||||
|
push_svc_reg
|
||||||
|
bl rt_hw_trap_pabt
|
||||||
|
b .
|
||||||
|
|
||||||
|
.align 5
|
||||||
|
.globl vector_dabt
|
||||||
|
vector_dabt:
|
||||||
|
push_svc_reg
|
||||||
|
bl rt_hw_trap_dabt
|
||||||
|
b .
|
||||||
|
|
||||||
|
.align 5
|
||||||
|
.globl vector_resv
|
||||||
|
vector_resv:
|
||||||
|
push_svc_reg
|
||||||
|
bl rt_hw_trap_resv
|
||||||
|
b .
|
204
bsp/qemu-vexpress-gemini/cpu/trap.c
Normal file
204
bsp/qemu-vexpress-gemini/cpu/trap.c
Normal file
@ -0,0 +1,204 @@
|
|||||||
|
/*
|
||||||
|
* File : trap.c
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2013, RT-Thread Develop Team
|
||||||
|
*
|
||||||
|
* The license and distribution terms for this file may be
|
||||||
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://www.rt-thread.org/license/LICENSE
|
||||||
|
*
|
||||||
|
* Change Logs:
|
||||||
|
* Date Author Notes
|
||||||
|
* 2013-07-20 Bernard first version
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <rtthread.h>
|
||||||
|
#include <rthw.h>
|
||||||
|
#include <board.h>
|
||||||
|
|
||||||
|
#include "armv7.h"
|
||||||
|
|
||||||
|
#ifdef RT_USING_VMM
|
||||||
|
#include <vmm_context.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include "gic.h"
|
||||||
|
|
||||||
|
extern struct rt_thread *rt_current_thread;
|
||||||
|
#ifdef RT_USING_FINSH
|
||||||
|
extern long list_thread(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this function will show registers of CPU
|
||||||
|
*
|
||||||
|
* @param regs the registers point
|
||||||
|
*/
|
||||||
|
void rt_hw_show_register(struct rt_hw_exp_stack *regs)
|
||||||
|
{
|
||||||
|
rt_kprintf("Execption:\n");
|
||||||
|
rt_kprintf("r00:0x%08x r01:0x%08x r02:0x%08x r03:0x%08x\n", regs->r0, regs->r1, regs->r2, regs->r3);
|
||||||
|
rt_kprintf("r04:0x%08x r05:0x%08x r06:0x%08x r07:0x%08x\n", regs->r4, regs->r5, regs->r6, regs->r7);
|
||||||
|
rt_kprintf("r08:0x%08x r09:0x%08x r10:0x%08x\n", regs->r8, regs->r9, regs->r10);
|
||||||
|
rt_kprintf("fp :0x%08x ip :0x%08x\n", regs->fp, regs->ip);
|
||||||
|
rt_kprintf("sp :0x%08x lr :0x%08x pc :0x%08x\n", regs->sp, regs->lr, regs->pc);
|
||||||
|
rt_kprintf("cpsr:0x%08x\n", regs->cpsr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When comes across an instruction which it cannot handle,
|
||||||
|
* it takes the undefined instruction trap.
|
||||||
|
*
|
||||||
|
* @param regs system registers
|
||||||
|
*
|
||||||
|
* @note never invoke this function in application
|
||||||
|
*/
|
||||||
|
void rt_hw_trap_undef(struct rt_hw_exp_stack *regs)
|
||||||
|
{
|
||||||
|
rt_kprintf("undefined instruction:\n");
|
||||||
|
rt_hw_show_register(regs);
|
||||||
|
#ifdef RT_USING_FINSH
|
||||||
|
list_thread();
|
||||||
|
#endif
|
||||||
|
rt_hw_cpu_shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The software interrupt instruction (SWI) is used for entering
|
||||||
|
* Supervisor mode, usually to request a particular supervisor
|
||||||
|
* function.
|
||||||
|
*
|
||||||
|
* @param regs system registers
|
||||||
|
*
|
||||||
|
* @note never invoke this function in application
|
||||||
|
*/
|
||||||
|
void rt_hw_trap_swi(struct rt_hw_exp_stack *regs)
|
||||||
|
{
|
||||||
|
rt_kprintf("software interrupt:\n");
|
||||||
|
rt_hw_show_register(regs);
|
||||||
|
#ifdef RT_USING_FINSH
|
||||||
|
list_thread();
|
||||||
|
#endif
|
||||||
|
rt_hw_cpu_shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An abort indicates that the current memory access cannot be completed,
|
||||||
|
* which occurs during an instruction prefetch.
|
||||||
|
*
|
||||||
|
* @param regs system registers
|
||||||
|
*
|
||||||
|
* @note never invoke this function in application
|
||||||
|
*/
|
||||||
|
void rt_hw_trap_pabt(struct rt_hw_exp_stack *regs)
|
||||||
|
{
|
||||||
|
rt_kprintf("prefetch abort:\n");
|
||||||
|
rt_hw_show_register(regs);
|
||||||
|
#ifdef RT_USING_FINSH
|
||||||
|
list_thread();
|
||||||
|
#endif
|
||||||
|
rt_hw_cpu_shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An abort indicates that the current memory access cannot be completed,
|
||||||
|
* which occurs during a data access.
|
||||||
|
*
|
||||||
|
* @param regs system registers
|
||||||
|
*
|
||||||
|
* @note never invoke this function in application
|
||||||
|
*/
|
||||||
|
void rt_hw_trap_dabt(struct rt_hw_exp_stack *regs)
|
||||||
|
{
|
||||||
|
rt_kprintf("data abort:");
|
||||||
|
rt_hw_show_register(regs);
|
||||||
|
#ifdef RT_USING_FINSH
|
||||||
|
list_thread();
|
||||||
|
#endif
|
||||||
|
rt_hw_cpu_shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normally, system will never reach here
|
||||||
|
*
|
||||||
|
* @param regs system registers
|
||||||
|
*
|
||||||
|
* @note never invoke this function in application
|
||||||
|
*/
|
||||||
|
void rt_hw_trap_resv(struct rt_hw_exp_stack *regs)
|
||||||
|
{
|
||||||
|
rt_kprintf("reserved trap:\n");
|
||||||
|
rt_hw_show_register(regs);
|
||||||
|
#ifdef RT_USING_FINSH
|
||||||
|
list_thread();
|
||||||
|
#endif
|
||||||
|
rt_hw_cpu_shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
#define GIC_ACK_INTID_MASK 0x000003ff
|
||||||
|
|
||||||
|
void rt_hw_trap_irq(void)
|
||||||
|
{
|
||||||
|
void *param;
|
||||||
|
unsigned long ir;
|
||||||
|
unsigned long fullir;
|
||||||
|
rt_isr_handler_t isr_func;
|
||||||
|
extern struct rt_irq_desc isr_table[];
|
||||||
|
|
||||||
|
fullir = arm_gic_get_active_irq(0);
|
||||||
|
ir = fullir & GIC_ACK_INTID_MASK;
|
||||||
|
|
||||||
|
if (ir == 1023)
|
||||||
|
{
|
||||||
|
/* Spurious interrupt */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* get interrupt service routine */
|
||||||
|
isr_func = isr_table[ir].handler;
|
||||||
|
#ifdef RT_USING_INTERRUPT_INFO
|
||||||
|
isr_table[ir].counter++;
|
||||||
|
#endif
|
||||||
|
if (isr_func)
|
||||||
|
{
|
||||||
|
/* Interrupt for myself. */
|
||||||
|
param = isr_table[ir].param;
|
||||||
|
/* turn to interrupt service routine */
|
||||||
|
isr_func(ir, param);
|
||||||
|
}
|
||||||
|
#ifdef RT_USING_VMM
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* We have to EOI before masking the interrupts */
|
||||||
|
arm_gic_ack(0, fullir);
|
||||||
|
vmm_virq_pending(ir);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* end of interrupt */
|
||||||
|
arm_gic_ack(0, fullir);
|
||||||
|
}
|
||||||
|
|
||||||
|
void rt_hw_trap_fiq(void)
|
||||||
|
{
|
||||||
|
void *param;
|
||||||
|
unsigned long ir;
|
||||||
|
unsigned long fullir;
|
||||||
|
rt_isr_handler_t isr_func;
|
||||||
|
extern struct rt_irq_desc isr_table[];
|
||||||
|
|
||||||
|
fullir = arm_gic_get_active_irq(0);
|
||||||
|
ir = fullir & GIC_ACK_INTID_MASK;
|
||||||
|
|
||||||
|
/* get interrupt service routine */
|
||||||
|
isr_func = isr_table[ir].handler;
|
||||||
|
param = isr_table[ir].param;
|
||||||
|
|
||||||
|
/* turn to interrupt service routine */
|
||||||
|
isr_func(ir, param);
|
||||||
|
|
||||||
|
/* end of interrupt */
|
||||||
|
arm_gic_ack(0, fullir);
|
||||||
|
}
|
||||||
|
|
65
bsp/qemu-vexpress-gemini/cpu/vector_gcc.S
Normal file
65
bsp/qemu-vexpress-gemini/cpu/vector_gcc.S
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* File : vector_gcc.S
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2013, 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
|
||||||
|
* 2013-07-05 Bernard the first version
|
||||||
|
*/
|
||||||
|
|
||||||
|
.section .vectors, "ax"
|
||||||
|
.code 32
|
||||||
|
|
||||||
|
.globl system_vectors
|
||||||
|
system_vectors:
|
||||||
|
ldr pc, _vector_reset
|
||||||
|
ldr pc, _vector_undef
|
||||||
|
ldr pc, _vector_swi
|
||||||
|
ldr pc, _vector_pabt
|
||||||
|
ldr pc, _vector_dabt
|
||||||
|
ldr pc, _vector_resv
|
||||||
|
ldr pc, _vector_irq
|
||||||
|
ldr pc, _vector_fiq
|
||||||
|
|
||||||
|
.globl _reset
|
||||||
|
.globl vector_undef
|
||||||
|
.globl vector_swi
|
||||||
|
.globl vector_pabt
|
||||||
|
.globl vector_dabt
|
||||||
|
.globl vector_resv
|
||||||
|
.globl vector_irq
|
||||||
|
.globl vector_fiq
|
||||||
|
|
||||||
|
_vector_reset:
|
||||||
|
.word _reset
|
||||||
|
_vector_undef:
|
||||||
|
.word vector_undef
|
||||||
|
_vector_swi:
|
||||||
|
.word vector_swi
|
||||||
|
_vector_pabt:
|
||||||
|
.word vector_pabt
|
||||||
|
_vector_dabt:
|
||||||
|
.word vector_dabt
|
||||||
|
_vector_resv:
|
||||||
|
.word vector_resv
|
||||||
|
_vector_irq:
|
||||||
|
.word vector_irq
|
||||||
|
_vector_fiq:
|
||||||
|
.word vector_fiq
|
||||||
|
|
||||||
|
.balignl 16,0xdeadbeef
|
7
bsp/qemu-vexpress-gemini/drivers/Kconfig
Normal file
7
bsp/qemu-vexpress-gemini/drivers/Kconfig
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
config RT_USING_UART0
|
||||||
|
bool "Enable UART0"
|
||||||
|
default n
|
||||||
|
|
||||||
|
config RT_USING_UART1
|
||||||
|
bool "Enable UART1"
|
||||||
|
default y
|
13
bsp/qemu-vexpress-gemini/drivers/SConscript
Normal file
13
bsp/qemu-vexpress-gemini/drivers/SConscript
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
import copy
|
||||||
|
Import('RTT_ROOT')
|
||||||
|
Import('rtconfig')
|
||||||
|
from building import *
|
||||||
|
|
||||||
|
cwd = GetCurrentDir()
|
||||||
|
src = Glob('*.c')
|
||||||
|
|
||||||
|
CPPPATH = [cwd]
|
||||||
|
|
||||||
|
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH)
|
||||||
|
|
||||||
|
Return('group')
|
87
bsp/qemu-vexpress-gemini/drivers/board.c
Normal file
87
bsp/qemu-vexpress-gemini/drivers/board.c
Normal file
@ -0,0 +1,87 @@
|
|||||||
|
/*
|
||||||
|
* File : board.c
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2012, RT-Thread Development Team
|
||||||
|
*
|
||||||
|
* The license and distribution terms for this file may be
|
||||||
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://www.rt-thread.org/license/LICENSE
|
||||||
|
*
|
||||||
|
* Change Logs:
|
||||||
|
* Date Author Notes
|
||||||
|
* 2012-11-20 Bernard the first version
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <rthw.h>
|
||||||
|
#include <rtthread.h>
|
||||||
|
|
||||||
|
#include "board.h"
|
||||||
|
|
||||||
|
#define TIMER_LOAD(hw_base) __REG32(hw_base + 0x00)
|
||||||
|
#define TIMER_VALUE(hw_base) __REG32(hw_base + 0x04)
|
||||||
|
#define TIMER_CTRL(hw_base) __REG32(hw_base + 0x08)
|
||||||
|
#define TIMER_CTRL_ONESHOT (1 << 0)
|
||||||
|
#define TIMER_CTRL_32BIT (1 << 1)
|
||||||
|
#define TIMER_CTRL_DIV1 (0 << 2)
|
||||||
|
#define TIMER_CTRL_DIV16 (1 << 2)
|
||||||
|
#define TIMER_CTRL_DIV256 (2 << 2)
|
||||||
|
#define TIMER_CTRL_IE (1 << 5) /* Interrupt Enable (versatile only) */
|
||||||
|
#define TIMER_CTRL_PERIODIC (1 << 6)
|
||||||
|
#define TIMER_CTRL_ENABLE (1 << 7)
|
||||||
|
|
||||||
|
#define TIMER_INTCLR(hw_base) __REG32(hw_base + 0x0c)
|
||||||
|
#define TIMER_RIS(hw_base) __REG32(hw_base + 0x10)
|
||||||
|
#define TIMER_MIS(hw_base) __REG32(hw_base + 0x14)
|
||||||
|
#define TIMER_BGLOAD(hw_base) __REG32(hw_base + 0x18)
|
||||||
|
|
||||||
|
#define SYS_CTRL __REG32(REALVIEW_SCTL_BASE)
|
||||||
|
|
||||||
|
#define TIMER_HW_BASE REALVIEW_TIMER2_3_BASE
|
||||||
|
|
||||||
|
void rt_hw_timer_ack(void)
|
||||||
|
{
|
||||||
|
/* clear interrupt */
|
||||||
|
TIMER_INTCLR(TIMER_HW_BASE) = 0x01;
|
||||||
|
}
|
||||||
|
|
||||||
|
static void rt_hw_timer_isr(int vector, void *param)
|
||||||
|
{
|
||||||
|
rt_tick_increase();
|
||||||
|
|
||||||
|
rt_hw_timer_ack();
|
||||||
|
}
|
||||||
|
|
||||||
|
int rt_hw_timer_init(void)
|
||||||
|
{
|
||||||
|
rt_uint32_t val;
|
||||||
|
|
||||||
|
SYS_CTRL |= REALVIEW_REFCLK;
|
||||||
|
|
||||||
|
/* Setup Timer0 for generating irq */
|
||||||
|
val = TIMER_CTRL(TIMER_HW_BASE);
|
||||||
|
val &= ~TIMER_CTRL_ENABLE;
|
||||||
|
val |= (TIMER_CTRL_32BIT | TIMER_CTRL_PERIODIC | TIMER_CTRL_IE);
|
||||||
|
TIMER_CTRL(TIMER_HW_BASE) = val;
|
||||||
|
|
||||||
|
TIMER_LOAD(TIMER_HW_BASE) = 1000;
|
||||||
|
|
||||||
|
/* enable timer */
|
||||||
|
TIMER_CTRL(TIMER_HW_BASE) |= TIMER_CTRL_ENABLE;
|
||||||
|
|
||||||
|
rt_hw_interrupt_install(IRQ_PBA8_TIMER2_3, rt_hw_timer_isr, RT_NULL, "tick");
|
||||||
|
rt_hw_interrupt_umask(IRQ_PBA8_TIMER2_3);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
INIT_BOARD_EXPORT(rt_hw_timer_init);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function will initialize beaglebone board
|
||||||
|
*/
|
||||||
|
void rt_hw_board_init(void)
|
||||||
|
{
|
||||||
|
rt_components_board_init();
|
||||||
|
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*@}*/
|
32
bsp/qemu-vexpress-gemini/drivers/board.h
Normal file
32
bsp/qemu-vexpress-gemini/drivers/board.h
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
/*
|
||||||
|
* File : board.h
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2013, RT-Thread Development Team
|
||||||
|
*
|
||||||
|
* The license and distribution terms for this file may be
|
||||||
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://www.rt-thread.org/license/LICENSE
|
||||||
|
*
|
||||||
|
* Change Logs:
|
||||||
|
* Date Author Notes
|
||||||
|
* 2013-07-06 Bernard the first version
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __BOARD_H__
|
||||||
|
#define __BOARD_H__
|
||||||
|
|
||||||
|
#include <realview.h>
|
||||||
|
|
||||||
|
#if defined(__CC_ARM)
|
||||||
|
extern int Image$$RW_IRAM1$$ZI$$Limit;
|
||||||
|
#define HEAP_BEGIN ((void*)&Image$$RW_IRAM1$$ZI$$Limit)
|
||||||
|
#elif defined(__GNUC__)
|
||||||
|
extern int __bss_end;
|
||||||
|
#define HEAP_BEGIN ((void*)&__bss_end)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define HEAP_END (void*)(0x70000000)
|
||||||
|
|
||||||
|
void rt_hw_board_init(void);
|
||||||
|
|
||||||
|
#endif
|
342
bsp/qemu-vexpress-gemini/drivers/realview.h
Normal file
342
bsp/qemu-vexpress-gemini/drivers/realview.h
Normal file
@ -0,0 +1,342 @@
|
|||||||
|
#ifndef __AM33XX_H__
|
||||||
|
#define __AM33XX_H__
|
||||||
|
|
||||||
|
#define __REG32(x) (*((volatile unsigned int *)(x)))
|
||||||
|
#define __REG16(x) (*((volatile unsigned short *)(x)))
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Peripheral memory map
|
||||||
|
* Address range Size Description
|
||||||
|
* 0xE000_0000-0xFFFF_FFFF 512MB External AXI between daughterboards
|
||||||
|
* 0xA000_0000-0xDFFF_FFFF 1GB Daughterboard, private
|
||||||
|
* 0x8000_0000-0x9FFF_FFFF 512MB Local DDR2
|
||||||
|
* 0x8000_0000-0x81FF_FFFF 64MB Remappable memory location
|
||||||
|
* 0x6000_0000-0x7FFF_FFFF 512MB Local DDR2 lower
|
||||||
|
* 0x5C00-0000-0x5FFF_FFFF 64MB Reserved
|
||||||
|
* 0x4000_0000-0x5BFF_FFFF 448MB Motherboard peripherals, typically, memory devices
|
||||||
|
* 0x2000_0000-0x3FFF_FFFF 512MB Reserved
|
||||||
|
* 0x1002_0000-0x1FFF_FFFF ~256MB Daughterboard, private
|
||||||
|
* 0x1000_0000-0x1001_FFFF 128KB Motherboard peripherals, CS7
|
||||||
|
* 0x0000_0000-0x0FFF_FFFF 64MB Remappable memory section
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Peripheral addresses
|
||||||
|
*/
|
||||||
|
#define REALVIEW_UART0_BASE 0x10009000 /* UART 0 */
|
||||||
|
#define REALVIEW_UART1_BASE 0x1000A000 /* UART 1 */
|
||||||
|
#define REALVIEW_UART2_BASE 0x1000B000 /* UART 2 */
|
||||||
|
#define REALVIEW_UART3_BASE 0x1000C000 /* UART 3 */
|
||||||
|
#define REALVIEW_SSP_BASE 0x1000D000 /* Synchronous Serial Port */
|
||||||
|
#define REALVIEW_WATCHDOG0_BASE 0x1000F000 /* Watchdog 0 */
|
||||||
|
#define REALVIEW_WATCHDOG_BASE 0x10010000 /* watchdog interface */
|
||||||
|
#define REALVIEW_TIMER0_1_BASE 0x10011000 /* Timer 0 and 1 */
|
||||||
|
#define REALVIEW_TIMER2_3_BASE 0x10012000 /* Timer 2 and 3 */
|
||||||
|
#define REALVIEW_GPIO0_BASE 0x10013000 /* GPIO port 0 */
|
||||||
|
#define REALVIEW_RTC_BASE 0x10017000 /* Real Time Clock */
|
||||||
|
#define REALVIEW_TIMER4_5_BASE 0x10018000 /* Timer 4/5 */
|
||||||
|
#define REALVIEW_TIMER6_7_BASE 0x10019000 /* Timer 6/7 */
|
||||||
|
#define REALVIEW_SCTL_BASE 0x1001A000 /* System Controller */
|
||||||
|
#define REALVIEW_CLCD_BASE 0x10020000 /* CLCD */
|
||||||
|
#define REALVIEW_ONB_SRAM_BASE 0x10060000 /* On-board SRAM */
|
||||||
|
#define REALVIEW_DMC_BASE 0x100E0000 /* DMC configuration */
|
||||||
|
#define REALVIEW_SMC_BASE 0x100E1000 /* SMC configuration */
|
||||||
|
#define REALVIEW_CAN_BASE 0x100E2000 /* CAN bus */
|
||||||
|
|
||||||
|
#define REALVIEW_GIC_CPU_BASE 0x1E000100 /* Generic interrupt controller CPU interface */
|
||||||
|
#define REALVIEW_GIC_DIST_BASE 0x1E001000 /* Generic interrupt controller distributor */
|
||||||
|
|
||||||
|
#define REALVIEW_FLASH0_BASE 0x40000000
|
||||||
|
#define REALVIEW_FLASH0_SIZE SZ_64M
|
||||||
|
#define REALVIEW_FLASH1_BASE 0x44000000
|
||||||
|
#define REALVIEW_FLASH1_SIZE SZ_64M
|
||||||
|
#define REALVIEW_ETH_BASE 0x4E000000 /* Ethernet */
|
||||||
|
#define REALVIEW_USB_BASE 0x4F000000 /* USB */
|
||||||
|
#define REALVIEW_LT_BASE 0xC0000000 /* Logic Tile expansion */
|
||||||
|
#define REALVIEW_SDRAM6_BASE 0x60000000 /* SDRAM bank 6 256MB */
|
||||||
|
#define REALVIEW_SDRAM7_BASE 0x80000000 /* SDRAM bank 7 256MB */
|
||||||
|
|
||||||
|
#define REALVIEW_SYS_PLD_CTRL1 0x74
|
||||||
|
|
||||||
|
/*
|
||||||
|
* PCI regions
|
||||||
|
*/
|
||||||
|
#define REALVIEW_PCI_BASE 0x90040000 /* PCI-X Unit base */
|
||||||
|
#define REALVIEW_PCI_IO_BASE 0x90050000 /* IO Region on AHB */
|
||||||
|
#define REALVIEW_PCI_MEM_BASE 0xA0000000 /* MEM Region on AHB */
|
||||||
|
|
||||||
|
#define REALVIEW_PCI_BASE_SIZE 0x10000 /* 16 Kb */
|
||||||
|
#define REALVIEW_PCI_IO_SIZE 0x1000 /* 4 Kb */
|
||||||
|
#define REALVIEW_PCI_MEM_SIZE 0x20000000 /* 512 MB */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Memory definitions
|
||||||
|
*/
|
||||||
|
#define REALVIEW_BOOT_ROM_LO 0x30000000 /* DoC Base (64Mb)... */
|
||||||
|
#define REALVIEW_BOOT_ROM_HI 0x30000000
|
||||||
|
#define REALVIEW_BOOT_ROM_BASE REALVIEW_BOOT_ROM_HI /* Normal position */
|
||||||
|
#define REALVIEW_BOOT_ROM_SIZE SZ_64M
|
||||||
|
|
||||||
|
#define REALVIEW_SSRAM_BASE /* REALVIEW_SSMC_BASE ? */
|
||||||
|
#define REALVIEW_SSRAM_SIZE SZ_2M
|
||||||
|
|
||||||
|
/*
|
||||||
|
* SDRAM
|
||||||
|
*/
|
||||||
|
#define REALVIEW_SDRAM_BASE 0x00000000
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Logic expansion modules
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#define IRQ_PBA8_GIC_START 32
|
||||||
|
|
||||||
|
/*
|
||||||
|
* PB-A8 on-board gic irq sources
|
||||||
|
*/
|
||||||
|
#define IRQ_PBA8_WATCHDOG (IRQ_PBA8_GIC_START + 0) /* Watchdog timer */
|
||||||
|
#define IRQ_PBA8_SOFT (IRQ_PBA8_GIC_START + 1) /* Software interrupt */
|
||||||
|
#define IRQ_PBA8_COMMRx (IRQ_PBA8_GIC_START + 2) /* Debug Comm Rx interrupt */
|
||||||
|
#define IRQ_PBA8_COMMTx (IRQ_PBA8_GIC_START + 3) /* Debug Comm Tx interrupt */
|
||||||
|
#define IRQ_PBA8_TIMER0_1 (IRQ_PBA8_GIC_START + 2) /* Timer 0/1 (default timer) */
|
||||||
|
#define IRQ_PBA8_TIMER2_3 (IRQ_PBA8_GIC_START + 3) /* Timer 2/3 */
|
||||||
|
#define IRQ_PBA8_GPIO0 (IRQ_PBA8_GIC_START + 6) /* GPIO 0 */
|
||||||
|
#define IRQ_PBA8_GPIO1 (IRQ_PBA8_GIC_START + 7) /* GPIO 1 */
|
||||||
|
#define IRQ_PBA8_GPIO2 (IRQ_PBA8_GIC_START + 8) /* GPIO 2 */
|
||||||
|
/* 9 reserved */
|
||||||
|
#define IRQ_PBA8_RTC (IRQ_PBA8_GIC_START + 4) /* Real Time Clock */
|
||||||
|
#define IRQ_PBA8_SSP (IRQ_PBA8_GIC_START + 11) /* Synchronous Serial Port */
|
||||||
|
#define IRQ_PBA8_UART0 (IRQ_PBA8_GIC_START + 5) /* UART 0 on development chip */
|
||||||
|
#define IRQ_PBA8_UART1 (IRQ_PBA8_GIC_START + 6) /* UART 1 on development chip */
|
||||||
|
#define IRQ_PBA8_UART2 (IRQ_PBA8_GIC_START + 7) /* UART 2 on development chip */
|
||||||
|
#define IRQ_PBA8_UART3 (IRQ_PBA8_GIC_START + 8) /* UART 3 on development chip */
|
||||||
|
#define IRQ_PBA8_SCI (IRQ_PBA8_GIC_START + 16) /* Smart Card Interface */
|
||||||
|
#define IRQ_PBA8_MMCI0A (IRQ_PBA8_GIC_START + 17) /* Multimedia Card 0A */
|
||||||
|
#define IRQ_PBA8_MMCI0B (IRQ_PBA8_GIC_START + 18) /* Multimedia Card 0B */
|
||||||
|
#define IRQ_PBA8_AACI (IRQ_PBA8_GIC_START + 19) /* Audio Codec */
|
||||||
|
#define IRQ_PBA8_KMI0 (IRQ_PBA8_GIC_START + 20) /* Keyboard/Mouse port 0 */
|
||||||
|
#define IRQ_PBA8_KMI1 (IRQ_PBA8_GIC_START + 21) /* Keyboard/Mouse port 1 */
|
||||||
|
#define IRQ_PBA8_CHARLCD (IRQ_PBA8_GIC_START + 22) /* Character LCD */
|
||||||
|
#define IRQ_PBA8_CLCD (IRQ_PBA8_GIC_START + 23) /* CLCD controller */
|
||||||
|
#define IRQ_PBA8_DMAC (IRQ_PBA8_GIC_START + 24) /* DMA controller */
|
||||||
|
#define IRQ_PBA8_PWRFAIL (IRQ_PBA8_GIC_START + 25) /* Power failure */
|
||||||
|
#define IRQ_PBA8_PISMO (IRQ_PBA8_GIC_START + 26) /* PISMO interface */
|
||||||
|
#define IRQ_PBA8_DoC (IRQ_PBA8_GIC_START + 27) /* Disk on Chip memory controller */
|
||||||
|
#define IRQ_PBA8_ETH (IRQ_PBA8_GIC_START + 28) /* Ethernet controller */
|
||||||
|
#define IRQ_PBA8_USB (IRQ_PBA8_GIC_START + 29) /* USB controller */
|
||||||
|
#define IRQ_PBA8_TSPEN (IRQ_PBA8_GIC_START + 30) /* Touchscreen pen */
|
||||||
|
#define IRQ_PBA8_TSKPAD (IRQ_PBA8_GIC_START + 31) /* Touchscreen keypad */
|
||||||
|
|
||||||
|
#define IRQ_PBA8_PMU (IRQ_PBA8_GIC_START + 47) /* Cortex-A8 PMU */
|
||||||
|
|
||||||
|
/* ... */
|
||||||
|
#define IRQ_PBA8_PCI0 (IRQ_PBA8_GIC_START + 50)
|
||||||
|
#define IRQ_PBA8_PCI1 (IRQ_PBA8_GIC_START + 51)
|
||||||
|
#define IRQ_PBA8_PCI2 (IRQ_PBA8_GIC_START + 52)
|
||||||
|
#define IRQ_PBA8_PCI3 (IRQ_PBA8_GIC_START + 53)
|
||||||
|
|
||||||
|
#define IRQ_PBA8_SMC -1
|
||||||
|
#define IRQ_PBA8_SCTL -1
|
||||||
|
|
||||||
|
#define NR_GIC_PBA8 1
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Only define NR_IRQS if less than NR_IRQS_PBA8
|
||||||
|
*/
|
||||||
|
#define NR_IRQS_PBA8 (IRQ_PBA8_GIC_START + 64)
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------
|
||||||
|
* RealView Registers
|
||||||
|
* ------------------------------------------------------------------------
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#define REALVIEW_SYS_ID_OFFSET 0x00
|
||||||
|
#define REALVIEW_SYS_SW_OFFSET 0x04
|
||||||
|
#define REALVIEW_SYS_LED_OFFSET 0x08
|
||||||
|
#define REALVIEW_SYS_OSC0_OFFSET 0x0C
|
||||||
|
|
||||||
|
#define REALVIEW_SYS_OSC1_OFFSET 0x10
|
||||||
|
#define REALVIEW_SYS_OSC2_OFFSET 0x14
|
||||||
|
#define REALVIEW_SYS_OSC3_OFFSET 0x18
|
||||||
|
#define REALVIEW_SYS_OSC4_OFFSET 0x1C /* OSC1 for RealView/AB */
|
||||||
|
|
||||||
|
#define REALVIEW_SYS_LOCK_OFFSET 0x20
|
||||||
|
#define REALVIEW_SYS_100HZ_OFFSET 0x24
|
||||||
|
#define REALVIEW_SYS_CFGDATA1_OFFSET 0x28
|
||||||
|
#define REALVIEW_SYS_CFGDATA2_OFFSET 0x2C
|
||||||
|
#define REALVIEW_SYS_FLAGS_OFFSET 0x30
|
||||||
|
#define REALVIEW_SYS_FLAGSSET_OFFSET 0x30
|
||||||
|
#define REALVIEW_SYS_FLAGSCLR_OFFSET 0x34
|
||||||
|
#define REALVIEW_SYS_NVFLAGS_OFFSET 0x38
|
||||||
|
#define REALVIEW_SYS_NVFLAGSSET_OFFSET 0x38
|
||||||
|
#define REALVIEW_SYS_NVFLAGSCLR_OFFSET 0x3C
|
||||||
|
#define REALVIEW_SYS_RESETCTL_OFFSET 0x40
|
||||||
|
#define REALVIEW_SYS_PCICTL_OFFSET 0x44
|
||||||
|
#define REALVIEW_SYS_MCI_OFFSET 0x48
|
||||||
|
#define REALVIEW_SYS_FLASH_OFFSET 0x4C
|
||||||
|
#define REALVIEW_SYS_CLCD_OFFSET 0x50
|
||||||
|
#define REALVIEW_SYS_CLCDSER_OFFSET 0x54
|
||||||
|
#define REALVIEW_SYS_BOOTCS_OFFSET 0x58
|
||||||
|
#define REALVIEW_SYS_24MHz_OFFSET 0x5C
|
||||||
|
#define REALVIEW_SYS_MISC_OFFSET 0x60
|
||||||
|
#define REALVIEW_SYS_IOSEL_OFFSET 0x70
|
||||||
|
#define REALVIEW_SYS_PROCID_OFFSET 0x84
|
||||||
|
#define REALVIEW_SYS_TEST_OSC0_OFFSET 0xC0
|
||||||
|
#define REALVIEW_SYS_TEST_OSC1_OFFSET 0xC4
|
||||||
|
#define REALVIEW_SYS_TEST_OSC2_OFFSET 0xC8
|
||||||
|
#define REALVIEW_SYS_TEST_OSC3_OFFSET 0xCC
|
||||||
|
#define REALVIEW_SYS_TEST_OSC4_OFFSET 0xD0
|
||||||
|
|
||||||
|
#define REALVIEW_SYS_BASE 0x10000000
|
||||||
|
#define REALVIEW_SYS_ID (REALVIEW_SYS_BASE + REALVIEW_SYS_ID_OFFSET)
|
||||||
|
#define REALVIEW_SYS_SW (REALVIEW_SYS_BASE + REALVIEW_SYS_SW_OFFSET)
|
||||||
|
#define REALVIEW_SYS_LED (REALVIEW_SYS_BASE + REALVIEW_SYS_LED_OFFSET)
|
||||||
|
#define REALVIEW_SYS_OSC0 (REALVIEW_SYS_BASE + REALVIEW_SYS_OSC0_OFFSET)
|
||||||
|
#define REALVIEW_SYS_OSC1 (REALVIEW_SYS_BASE + REALVIEW_SYS_OSC1_OFFSET)
|
||||||
|
|
||||||
|
#define REALVIEW_SYS_LOCK (REALVIEW_SYS_BASE + REALVIEW_SYS_LOCK_OFFSET)
|
||||||
|
#define REALVIEW_SYS_100HZ (REALVIEW_SYS_BASE + REALVIEW_SYS_100HZ_OFFSET)
|
||||||
|
#define REALVIEW_SYS_CFGDATA1 (REALVIEW_SYS_BASE + REALVIEW_SYS_CFGDATA1_OFFSET)
|
||||||
|
#define REALVIEW_SYS_CFGDATA2 (REALVIEW_SYS_BASE + REALVIEW_SYS_CFGDATA2_OFFSET)
|
||||||
|
#define REALVIEW_SYS_FLAGS (REALVIEW_SYS_BASE + REALVIEW_SYS_FLAGS_OFFSET)
|
||||||
|
#define REALVIEW_SYS_FLAGSSET (REALVIEW_SYS_BASE + REALVIEW_SYS_FLAGSSET_OFFSET)
|
||||||
|
#define REALVIEW_SYS_FLAGSCLR (REALVIEW_SYS_BASE + REALVIEW_SYS_FLAGSCLR_OFFSET)
|
||||||
|
#define REALVIEW_SYS_NVFLAGS (REALVIEW_SYS_BASE + REALVIEW_SYS_NVFLAGS_OFFSET)
|
||||||
|
#define REALVIEW_SYS_NVFLAGSSET (REALVIEW_SYS_BASE + REALVIEW_SYS_NVFLAGSSET_OFFSET)
|
||||||
|
#define REALVIEW_SYS_NVFLAGSCLR (REALVIEW_SYS_BASE + REALVIEW_SYS_NVFLAGSCLR_OFFSET)
|
||||||
|
#define REALVIEW_SYS_RESETCTL (REALVIEW_SYS_BASE + REALVIEW_SYS_RESETCTL_OFFSET)
|
||||||
|
#define REALVIEW_SYS_PCICTL (REALVIEW_SYS_BASE + REALVIEW_SYS_PCICTL_OFFSET)
|
||||||
|
#define REALVIEW_SYS_MCI (REALVIEW_SYS_BASE + REALVIEW_SYS_MCI_OFFSET)
|
||||||
|
#define REALVIEW_SYS_FLASH (REALVIEW_SYS_BASE + REALVIEW_SYS_FLASH_OFFSET)
|
||||||
|
#define REALVIEW_SYS_CLCD (REALVIEW_SYS_BASE + REALVIEW_SYS_CLCD_OFFSET)
|
||||||
|
#define REALVIEW_SYS_CLCDSER (REALVIEW_SYS_BASE + REALVIEW_SYS_CLCDSER_OFFSET)
|
||||||
|
#define REALVIEW_SYS_BOOTCS (REALVIEW_SYS_BASE + REALVIEW_SYS_BOOTCS_OFFSET)
|
||||||
|
#define REALVIEW_SYS_24MHz (REALVIEW_SYS_BASE + REALVIEW_SYS_24MHz_OFFSET)
|
||||||
|
#define REALVIEW_SYS_MISC (REALVIEW_SYS_BASE + REALVIEW_SYS_MISC_OFFSET)
|
||||||
|
#define REALVIEW_SYS_IOSEL (REALVIEW_SYS_BASE + REALVIEW_SYS_IOSEL_OFFSET)
|
||||||
|
#define REALVIEW_SYS_PROCID (REALVIEW_SYS_BASE + REALVIEW_SYS_PROCID_OFFSET)
|
||||||
|
#define REALVIEW_SYS_TEST_OSC0 (REALVIEW_SYS_BASE + REALVIEW_SYS_TEST_OSC0_OFFSET)
|
||||||
|
#define REALVIEW_SYS_TEST_OSC1 (REALVIEW_SYS_BASE + REALVIEW_SYS_TEST_OSC1_OFFSET)
|
||||||
|
#define REALVIEW_SYS_TEST_OSC2 (REALVIEW_SYS_BASE + REALVIEW_SYS_TEST_OSC2_OFFSET)
|
||||||
|
#define REALVIEW_SYS_TEST_OSC3 (REALVIEW_SYS_BASE + REALVIEW_SYS_TEST_OSC3_OFFSET)
|
||||||
|
#define REALVIEW_SYS_TEST_OSC4 (REALVIEW_SYS_BASE + REALVIEW_SYS_TEST_OSC4_OFFSET)
|
||||||
|
|
||||||
|
#define REALVIEW_SYS_CTRL_LED (1 << 0)
|
||||||
|
|
||||||
|
/* ------------------------------------------------------------------------
|
||||||
|
* RealView control registers
|
||||||
|
* ------------------------------------------------------------------------
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* REALVIEW_IDFIELD
|
||||||
|
*
|
||||||
|
* 31:24 = manufacturer (0x41 = ARM)
|
||||||
|
* 23:16 = architecture (0x08 = AHB system bus, ASB processor bus)
|
||||||
|
* 15:12 = FPGA (0x3 = XVC600 or XVC600E)
|
||||||
|
* 11:4 = build value
|
||||||
|
* 3:0 = revision number (0x1 = rev B (AHB))
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* REALVIEW_SYS_LOCK
|
||||||
|
* control access to SYS_OSCx, SYS_CFGDATAx, SYS_RESETCTL,
|
||||||
|
* SYS_CLD, SYS_BOOTCS
|
||||||
|
*/
|
||||||
|
#define REALVIEW_SYS_LOCK_LOCKED (1 << 16)
|
||||||
|
#define REALVIEW_SYS_LOCKVAL 0xA05F
|
||||||
|
#define REALVIEW_SYS_LOCKVAL_MASK 0xFFFF /* write 0xA05F to enable write access */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* REALVIEW_SYS_FLASH
|
||||||
|
*/
|
||||||
|
#define REALVIEW_FLASHPROG_FLVPPEN (1 << 0) /* Enable writing to flash */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* REALVIEW_INTREG
|
||||||
|
* - used to acknowledge and control MMCI and UART interrupts
|
||||||
|
*/
|
||||||
|
#define REALVIEW_INTREG_WPROT 0x00 /* MMC protection status (no interrupt generated) */
|
||||||
|
#define REALVIEW_INTREG_RI0 0x01 /* Ring indicator UART0 is asserted, */
|
||||||
|
#define REALVIEW_INTREG_CARDIN 0x08 /* MMCI card in detect */
|
||||||
|
/* write 1 to acknowledge and clear */
|
||||||
|
#define REALVIEW_INTREG_RI1 0x02 /* Ring indicator UART1 is asserted, */
|
||||||
|
#define REALVIEW_INTREG_CARDINSERT 0x03 /* Signal insertion of MMC card */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* LED settings, bits [7:0]
|
||||||
|
*/
|
||||||
|
#define REALVIEW_SYS_LED0 (1 << 0)
|
||||||
|
#define REALVIEW_SYS_LED1 (1 << 1)
|
||||||
|
#define REALVIEW_SYS_LED2 (1 << 2)
|
||||||
|
#define REALVIEW_SYS_LED3 (1 << 3)
|
||||||
|
#define REALVIEW_SYS_LED4 (1 << 4)
|
||||||
|
#define REALVIEW_SYS_LED5 (1 << 5)
|
||||||
|
#define REALVIEW_SYS_LED6 (1 << 6)
|
||||||
|
#define REALVIEW_SYS_LED7 (1 << 7)
|
||||||
|
|
||||||
|
#define ALL_LEDS 0xFF
|
||||||
|
|
||||||
|
#define LED_BANK REALVIEW_SYS_LED
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Control registers
|
||||||
|
*/
|
||||||
|
#define REALVIEW_IDFIELD_OFFSET 0x0 /* RealView build information */
|
||||||
|
#define REALVIEW_FLASHPROG_OFFSET 0x4 /* Flash devices */
|
||||||
|
#define REALVIEW_INTREG_OFFSET 0x8 /* Interrupt control */
|
||||||
|
#define REALVIEW_DECODE_OFFSET 0xC /* Fitted logic modules */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Clean base - dummy
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
#define CLEAN_BASE REALVIEW_BOOT_ROM_HI
|
||||||
|
|
||||||
|
/*
|
||||||
|
* System controller bit assignment
|
||||||
|
*/
|
||||||
|
#define REALVIEW_REFCLK 0
|
||||||
|
#define REALVIEW_TIMCLK 1
|
||||||
|
|
||||||
|
#define REALVIEW_TIMER1_EnSel 15
|
||||||
|
#define REALVIEW_TIMER2_EnSel 17
|
||||||
|
#define REALVIEW_TIMER3_EnSel 19
|
||||||
|
#define REALVIEW_TIMER4_EnSel 21
|
||||||
|
|
||||||
|
/*
|
||||||
|
*struct rt_hw_register
|
||||||
|
*{
|
||||||
|
* unsigned long r0;
|
||||||
|
* unsigned long r1;
|
||||||
|
* unsigned long r2;
|
||||||
|
* unsigned long r3;
|
||||||
|
* unsigned long r4;
|
||||||
|
* unsigned long r5;
|
||||||
|
* unsigned long r6;
|
||||||
|
* unsigned long r7;
|
||||||
|
* unsigned long r8;
|
||||||
|
* unsigned long r9;
|
||||||
|
* unsigned long r10;
|
||||||
|
* unsigned long fp;
|
||||||
|
* unsigned long ip;
|
||||||
|
* unsigned long sp;
|
||||||
|
* unsigned long lr;
|
||||||
|
* unsigned long pc;
|
||||||
|
* unsigned long cpsr;
|
||||||
|
* unsigned long ORIG_r0;
|
||||||
|
*};
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <armv7.h>
|
||||||
|
|
||||||
|
/* Interrupt Control Interface */
|
||||||
|
#define ARM_GIC_CPU_BASE 0x1E000000
|
||||||
|
|
||||||
|
/* number of interrupts on board */
|
||||||
|
#define ARM_GIC_NR_IRQS 96
|
||||||
|
/* only one GIC available */
|
||||||
|
#define ARM_GIC_MAX_NR 1
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
195
bsp/qemu-vexpress-gemini/drivers/serial.c
Normal file
195
bsp/qemu-vexpress-gemini/drivers/serial.c
Normal file
@ -0,0 +1,195 @@
|
|||||||
|
/*
|
||||||
|
* serial.c UART driver
|
||||||
|
*
|
||||||
|
* COPYRIGHT (C) 2013, Shanghai Real-Thread Technology Co., Ltd
|
||||||
|
*
|
||||||
|
* This file is part of RT-Thread (http://www.rt-thread.org)
|
||||||
|
* Maintainer: bernard.xiong <bernard.xiong at gmail.com>
|
||||||
|
*
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* 2013-03-30 Bernard the first verion
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <rthw.h>
|
||||||
|
#include <rtdevice.h>
|
||||||
|
|
||||||
|
#include "serial.h"
|
||||||
|
|
||||||
|
struct hw_uart_device
|
||||||
|
{
|
||||||
|
rt_uint32_t hw_base;
|
||||||
|
rt_uint32_t irqno;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define UART_DR(base) __REG32(base + 0x00)
|
||||||
|
#define UART_FR(base) __REG32(base + 0x18)
|
||||||
|
#define UART_CR(base) __REG32(base + 0x30)
|
||||||
|
#define UART_IMSC(base) __REG32(base + 0x38)
|
||||||
|
#define UART_ICR(base) __REG32(base + 0x44)
|
||||||
|
|
||||||
|
#define UARTFR_RXFE 0x10
|
||||||
|
#define UARTFR_TXFF 0x20
|
||||||
|
#define UARTIMSC_RXIM 0x10
|
||||||
|
#define UARTIMSC_TXIM 0x20
|
||||||
|
#define UARTICR_RXIC 0x10
|
||||||
|
#define UARTICR_TXIC 0x20
|
||||||
|
|
||||||
|
static void rt_hw_uart_isr(int irqno, void *param)
|
||||||
|
{
|
||||||
|
struct rt_serial_device *serial = (struct rt_serial_device *)param;
|
||||||
|
|
||||||
|
rt_hw_serial_isr(serial, RT_SERIAL_EVENT_RX_IND);
|
||||||
|
}
|
||||||
|
|
||||||
|
static rt_err_t uart_configure(struct rt_serial_device *serial, struct serial_configure *cfg)
|
||||||
|
{
|
||||||
|
return RT_EOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static rt_err_t uart_control(struct rt_serial_device *serial, int cmd, void *arg)
|
||||||
|
{
|
||||||
|
struct hw_uart_device *uart;
|
||||||
|
|
||||||
|
RT_ASSERT(serial != RT_NULL);
|
||||||
|
uart = (struct hw_uart_device *)serial->parent.user_data;
|
||||||
|
|
||||||
|
switch (cmd)
|
||||||
|
{
|
||||||
|
case RT_DEVICE_CTRL_CLR_INT:
|
||||||
|
/* disable rx irq */
|
||||||
|
UART_IMSC(uart->hw_base) &= ~UARTIMSC_RXIM;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RT_DEVICE_CTRL_SET_INT:
|
||||||
|
/* enable rx irq */
|
||||||
|
UART_IMSC(uart->hw_base) |= UARTIMSC_RXIM;
|
||||||
|
rt_hw_interrupt_install(uart->irqno, rt_hw_uart_isr, serial, "uart");
|
||||||
|
rt_hw_interrupt_umask(uart->irqno);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return RT_EOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int uart_putc(struct rt_serial_device *serial, char c)
|
||||||
|
{
|
||||||
|
struct hw_uart_device *uart;
|
||||||
|
|
||||||
|
RT_ASSERT(serial != RT_NULL);
|
||||||
|
uart = (struct hw_uart_device *)serial->parent.user_data;
|
||||||
|
|
||||||
|
while (UART_FR(uart->hw_base) & UARTFR_TXFF);
|
||||||
|
UART_DR(uart->hw_base) = c;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int uart_getc(struct rt_serial_device *serial)
|
||||||
|
{
|
||||||
|
int ch;
|
||||||
|
struct hw_uart_device *uart;
|
||||||
|
|
||||||
|
RT_ASSERT(serial != RT_NULL);
|
||||||
|
uart = (struct hw_uart_device *)serial->parent.user_data;
|
||||||
|
|
||||||
|
ch = -1;
|
||||||
|
if (!(UART_FR(uart->hw_base) & UARTFR_RXFE))
|
||||||
|
{
|
||||||
|
ch = UART_DR(uart->hw_base) & 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ch;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct rt_uart_ops _uart_ops =
|
||||||
|
{
|
||||||
|
uart_configure,
|
||||||
|
uart_control,
|
||||||
|
uart_putc,
|
||||||
|
uart_getc,
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef RT_USING_UART0
|
||||||
|
/* UART device driver structure */
|
||||||
|
static struct hw_uart_device _uart0_device =
|
||||||
|
{
|
||||||
|
REALVIEW_UART0_BASE,
|
||||||
|
IRQ_PBA8_UART0,
|
||||||
|
};
|
||||||
|
static struct rt_serial_device _serial0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef RT_USING_UART1
|
||||||
|
/* UART1 device driver structure */
|
||||||
|
static struct hw_uart_device _uart1_device =
|
||||||
|
{
|
||||||
|
REALVIEW_UART1_BASE,
|
||||||
|
IRQ_PBA8_UART1,
|
||||||
|
};
|
||||||
|
static struct rt_serial_device _serial1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int uart_isr_test(void)
|
||||||
|
{
|
||||||
|
return uart_getc(&_serial1);
|
||||||
|
}
|
||||||
|
|
||||||
|
int rt_hw_uart_init(void)
|
||||||
|
{
|
||||||
|
struct hw_uart_device *uart;
|
||||||
|
struct serial_configure config;
|
||||||
|
|
||||||
|
config.baud_rate = BAUD_RATE_115200;
|
||||||
|
config.bit_order = BIT_ORDER_LSB;
|
||||||
|
config.data_bits = DATA_BITS_8;
|
||||||
|
config.parity = PARITY_NONE;
|
||||||
|
config.stop_bits = STOP_BITS_1;
|
||||||
|
config.invert = NRZ_NORMAL;
|
||||||
|
config.bufsz = RT_SERIAL_RB_BUFSZ;
|
||||||
|
|
||||||
|
#ifdef RT_USING_UART0
|
||||||
|
uart = &_uart0_device;
|
||||||
|
|
||||||
|
_serial0.ops = &_uart_ops;
|
||||||
|
_serial0.config = config;
|
||||||
|
|
||||||
|
/* register UART1 device */
|
||||||
|
rt_hw_serial_register(&_serial0, "uart0",
|
||||||
|
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
|
||||||
|
uart);
|
||||||
|
/* enable Rx and Tx of UART */
|
||||||
|
UART_CR(uart->hw_base) = (1 << 0) | (1 << 8) | (1 << 9);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef RT_USING_UART1
|
||||||
|
uart = &_uart1_device;
|
||||||
|
_serial1.ops = &_uart_ops;
|
||||||
|
_serial1.config = config;
|
||||||
|
|
||||||
|
/* register UART1 device */
|
||||||
|
rt_hw_serial_register(&_serial1, "uart1",
|
||||||
|
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX, uart);
|
||||||
|
/* enable Rx and Tx of UART */
|
||||||
|
UART_CR(uart->hw_base) = (1 << 0) | (1 << 8) | (1 << 9);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
INIT_BOARD_EXPORT(rt_hw_uart_init);
|
39
bsp/qemu-vexpress-gemini/drivers/serial.h
Normal file
39
bsp/qemu-vexpress-gemini/drivers/serial.h
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* UART driver
|
||||||
|
*
|
||||||
|
* COPYRIGHT (C) 2013, Shanghai Real-Thread Technology Co., Ltd
|
||||||
|
*
|
||||||
|
* This file is part of RT-Thread (http://www.rt-thread.org)
|
||||||
|
* Maintainer: bernard.xiong <bernard.xiong at gmail.com>
|
||||||
|
*
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* 2013-03-30 Bernard the first verion
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef __UART_H__
|
||||||
|
#define __UART_H__
|
||||||
|
|
||||||
|
#include <board.h>
|
||||||
|
|
||||||
|
int rt_hw_uart_init(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
120
bsp/qemu-vexpress-gemini/drivers/vbus_drv.c
Normal file
120
bsp/qemu-vexpress-gemini/drivers/vbus_drv.c
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
/*
|
||||||
|
* VMM Bus Driver
|
||||||
|
*
|
||||||
|
* COPYRIGHT (C) 2015, Shanghai Real-Thread Technology Co., Ltd
|
||||||
|
* http://www.rt-thread.com
|
||||||
|
*
|
||||||
|
* This file is part of RT-Thread (http://www.rt-thread.org)
|
||||||
|
*
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* 2015-01-07 Grissiom add comment
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <rtthread.h>
|
||||||
|
|
||||||
|
#ifdef RT_USING_VBUS
|
||||||
|
#include <rtdevice.h>
|
||||||
|
#include <rthw.h>
|
||||||
|
#include <interrupt.h>
|
||||||
|
#include <vbus.h>
|
||||||
|
#include <board.h>
|
||||||
|
|
||||||
|
int rt_vbus_do_init(void)
|
||||||
|
{
|
||||||
|
return rt_vbus_init((void*)_RT_VBUS_RING_BASE,
|
||||||
|
(void*)(_RT_VBUS_RING_BASE + _RT_VBUS_RING_SZ));
|
||||||
|
}
|
||||||
|
INIT_COMPONENT_EXPORT(rt_vbus_do_init);
|
||||||
|
|
||||||
|
static void _bus_resume_in_thread(int irqnr, void *param)
|
||||||
|
{
|
||||||
|
rt_vbus_isr(irqnr, RT_NULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
int rt_vbus_hw_init(void)
|
||||||
|
{
|
||||||
|
rt_kprintf("install irq: %d\n", RT_VBUS_HOST_VIRQ);
|
||||||
|
rt_hw_interrupt_install(RT_VBUS_HOST_VIRQ,
|
||||||
|
_bus_resume_in_thread, RT_NULL,
|
||||||
|
"vbusin");
|
||||||
|
rt_hw_interrupt_umask(RT_VBUS_HOST_VIRQ);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int rt_vbus_hw_eoi(int irqnr, void *param)
|
||||||
|
{
|
||||||
|
rt_hw_interrupt_clear(irqnr);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
#define RT_VBUS_SER_PRIO 20
|
||||||
|
#define RT_VBUS_RFS_PRIO 19
|
||||||
|
#define RT_VBUS_TASK2_PRIO 6
|
||||||
|
#define RT_VBUS_INT_PRIO 4
|
||||||
|
|
||||||
|
struct rt_vbus_dev rt_vbus_chn_devx[] = {
|
||||||
|
{
|
||||||
|
.req =
|
||||||
|
{
|
||||||
|
.prio = RT_VBUS_SER_PRIO,
|
||||||
|
.name = RT_VBUS_SHELL_DEV_NAME,
|
||||||
|
.is_server = 1,
|
||||||
|
.recv_wm.low = RT_VMM_RB_BLK_NR / 3,
|
||||||
|
.recv_wm.high = RT_VMM_RB_BLK_NR * 2 / 3,
|
||||||
|
.post_wm.low = RT_VMM_RB_BLK_NR / 3,
|
||||||
|
.post_wm.high = RT_VMM_RB_BLK_NR * 2 / 3,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.req =
|
||||||
|
{
|
||||||
|
.prio = 23,
|
||||||
|
.name = RT_VBUS_RFS_DEV_NAME,
|
||||||
|
.is_server = 0,
|
||||||
|
.recv_wm.low = RT_VMM_RB_BLK_NR / 3,
|
||||||
|
.recv_wm.high = RT_VMM_RB_BLK_NR * 2 / 3,
|
||||||
|
.post_wm.low = RT_VMM_RB_BLK_NR / 3,
|
||||||
|
.post_wm.high = RT_VMM_RB_BLK_NR * 2 / 3,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.req =
|
||||||
|
{
|
||||||
|
.prio = 30,
|
||||||
|
.name = "vecho",
|
||||||
|
.is_server = 1,
|
||||||
|
.recv_wm.low = RT_VMM_RB_BLK_NR / 3,
|
||||||
|
.recv_wm.high = RT_VMM_RB_BLK_NR * 2 / 3,
|
||||||
|
.post_wm.low = RT_VMM_RB_BLK_NR / 3,
|
||||||
|
.post_wm.high = RT_VMM_RB_BLK_NR * 2 / 3,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.req =
|
||||||
|
{
|
||||||
|
.name = RT_NULL,
|
||||||
|
}
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* RT_USING_VBUS */
|
||||||
|
|
54
bsp/qemu-vexpress-gemini/drivers/vbus_hw.h
Normal file
54
bsp/qemu-vexpress-gemini/drivers/vbus_hw.h
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* VMM Bus
|
||||||
|
*
|
||||||
|
* COPYRIGHT (C) 2015, Shanghai Real-Thread Technology Co., Ltd
|
||||||
|
*
|
||||||
|
* This file is part of RT-Thread (http://www.rt-thread.org)
|
||||||
|
*
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* 2015-01-07 Grissiom init commit
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <rtthread.h>
|
||||||
|
#include <stddef.h>
|
||||||
|
#include <gic.h>
|
||||||
|
|
||||||
|
rt_inline void rt_vbus_tick(unsigned int target_cpu, unsigned int irqnr)
|
||||||
|
{
|
||||||
|
arm_gic_trigger(0, 1, irqnr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Read memory barrier. */
|
||||||
|
rt_inline void rt_vbus_smp_rmb(void)
|
||||||
|
{
|
||||||
|
asm volatile ("dsb" : : : "memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Write memory barrier. */
|
||||||
|
rt_inline void rt_vbus_smp_wmb(void)
|
||||||
|
{
|
||||||
|
asm volatile ("dsb" : : : "memory");
|
||||||
|
}
|
||||||
|
|
||||||
|
/* General memory barrier. */
|
||||||
|
rt_inline void rt_vbus_smp_mb(void)
|
||||||
|
{
|
||||||
|
asm volatile ("dsb" : : : "memory");
|
||||||
|
}
|
1
bsp/qemu-vexpress-gemini/qemu.sh
Executable file
1
bsp/qemu-vexpress-gemini/qemu.sh
Executable file
@ -0,0 +1 @@
|
|||||||
|
qemu-system-arm -M vexpress-a9 -cpu cortex-a9 -m 256M -kernel rtthread-vexpress.elf -serial vc -serial vc
|
289
bsp/qemu-vexpress-gemini/rtconfig.h
Normal file
289
bsp/qemu-vexpress-gemini/rtconfig.h
Normal file
@ -0,0 +1,289 @@
|
|||||||
|
#ifndef RT_CONFIG_H__
|
||||||
|
#define RT_CONFIG_H__
|
||||||
|
|
||||||
|
/* Automatically generated file; DO NOT EDIT. */
|
||||||
|
/* RT-Thread Project Configuration */
|
||||||
|
|
||||||
|
/* RT-Thread Kernel */
|
||||||
|
|
||||||
|
#define RT_NAME_MAX 6
|
||||||
|
#define RT_ALIGN_SIZE 4
|
||||||
|
/* RT_THREAD_PRIORITY_8 is not set */
|
||||||
|
#define RT_THREAD_PRIORITY_32
|
||||||
|
/* RT_THREAD_PRIORITY_256 is not set */
|
||||||
|
#define RT_THREAD_PRIORITY_MAX 32
|
||||||
|
#define RT_TICK_PER_SECOND 1000
|
||||||
|
#define RT_USING_OVERFLOW_CHECK
|
||||||
|
#define RT_USING_HOOK
|
||||||
|
#define RT_IDEL_HOOK_LIST_SIZE 4
|
||||||
|
#define IDLE_THREAD_STACK_SIZE 512
|
||||||
|
/* RT_USING_TIMER_SOFT is not set */
|
||||||
|
#define RT_DEBUG
|
||||||
|
/* RT_DEBUG_INIT_CONFIG is not set */
|
||||||
|
/* RT_DEBUG_THREAD_CONFIG is not set */
|
||||||
|
/* RT_DEBUG_SCHEDULER_CONFIG is not set */
|
||||||
|
/* RT_DEBUG_IPC_CONFIG is not set */
|
||||||
|
/* RT_DEBUG_TIMER_CONFIG is not set */
|
||||||
|
/* RT_DEBUG_IRQ_CONFIG is not set */
|
||||||
|
/* RT_DEBUG_MEM_CONFIG is not set */
|
||||||
|
/* RT_DEBUG_SLAB_CONFIG is not set */
|
||||||
|
/* RT_DEBUG_MEMHEAP_CONFIG is not set */
|
||||||
|
/* RT_DEBUG_MODULE_CONFIG is not set */
|
||||||
|
|
||||||
|
/* Inter-Thread communication */
|
||||||
|
|
||||||
|
#define RT_USING_SEMAPHORE
|
||||||
|
#define RT_USING_MUTEX
|
||||||
|
#define RT_USING_EVENT
|
||||||
|
#define RT_USING_MAILBOX
|
||||||
|
#define RT_USING_MESSAGEQUEUE
|
||||||
|
/* RT_USING_SIGNALS is not set */
|
||||||
|
|
||||||
|
/* Memory Management */
|
||||||
|
|
||||||
|
#define RT_USING_MEMPOOL
|
||||||
|
/* RT_USING_MEMHEAP is not set */
|
||||||
|
/* RT_USING_NOHEAP is not set */
|
||||||
|
#define RT_USING_SMALL_MEM
|
||||||
|
/* RT_USING_SLAB is not set */
|
||||||
|
/* RT_USING_MEMTRACE is not set */
|
||||||
|
#define RT_USING_HEAP
|
||||||
|
|
||||||
|
/* Kernel Device Object */
|
||||||
|
|
||||||
|
#define RT_USING_DEVICE
|
||||||
|
/* RT_USING_DEVICE_OPS is not set */
|
||||||
|
#define RT_USING_INTERRUPT_INFO
|
||||||
|
#define RT_USING_CONSOLE
|
||||||
|
#define RT_CONSOLEBUF_SIZE 128
|
||||||
|
#define RT_CONSOLE_DEVICE_NAME "uart1"
|
||||||
|
/* RT_USING_MODULE is not set */
|
||||||
|
#define ARCH_ARM
|
||||||
|
#define ARCH_ARM_CORTEX_A
|
||||||
|
#define ARCH_ARM_CORTEX_A9
|
||||||
|
|
||||||
|
/* RT-Thread Components */
|
||||||
|
|
||||||
|
#define RT_USING_COMPONENTS_INIT
|
||||||
|
/* RT_USING_USER_MAIN is not set */
|
||||||
|
|
||||||
|
/* C++ features */
|
||||||
|
|
||||||
|
/* RT_USING_CPLUSPLUS is not set */
|
||||||
|
|
||||||
|
/* Command shell */
|
||||||
|
|
||||||
|
#define RT_USING_FINSH
|
||||||
|
#define FINSH_THREAD_NAME "tshell"
|
||||||
|
#define FINSH_USING_HISTORY
|
||||||
|
#define FINSH_HISTORY_LINES 5
|
||||||
|
#define FINSH_USING_SYMTAB
|
||||||
|
#define FINSH_USING_DESCRIPTION
|
||||||
|
/* FINSH_ECHO_DISABLE_DEFAULT is not set */
|
||||||
|
#define FINSH_THREAD_PRIORITY 20
|
||||||
|
#define FINSH_THREAD_STACK_SIZE 4096
|
||||||
|
#define FINSH_CMD_SIZE 80
|
||||||
|
/* FINSH_USING_AUTH is not set */
|
||||||
|
#define FINSH_USING_MSH
|
||||||
|
#define FINSH_USING_MSH_DEFAULT
|
||||||
|
/* FINSH_USING_MSH_ONLY is not set */
|
||||||
|
#define FINSH_ARG_MAX 10
|
||||||
|
|
||||||
|
/* Device virtual file system */
|
||||||
|
|
||||||
|
#define RT_USING_DFS
|
||||||
|
#define DFS_USING_WORKDIR
|
||||||
|
#define DFS_FILESYSTEMS_MAX 2
|
||||||
|
#define DFS_FILESYSTEM_TYPES_MAX 2
|
||||||
|
#define DFS_FD_MAX 4
|
||||||
|
/* RT_USING_DFS_MNTTABLE is not set */
|
||||||
|
/* RT_USING_DFS_ELMFAT is not set */
|
||||||
|
#define RT_USING_DFS_DEVFS
|
||||||
|
/* RT_USING_DFS_ROMFS is not set */
|
||||||
|
/* RT_USING_DFS_RAMFS is not set */
|
||||||
|
/* RT_USING_DFS_UFFS is not set */
|
||||||
|
/* RT_USING_DFS_JFFS2 is not set */
|
||||||
|
/* RT_USING_DFS_NFS is not set */
|
||||||
|
|
||||||
|
/* Device Drivers */
|
||||||
|
|
||||||
|
#define RT_USING_DEVICE_IPC
|
||||||
|
#define RT_PIPE_BUFSZ 512
|
||||||
|
#define RT_USING_SERIAL
|
||||||
|
/* RT_USING_CAN is not set */
|
||||||
|
/* RT_USING_HWTIMER is not set */
|
||||||
|
/* RT_USING_CPUTIME is not set */
|
||||||
|
/* RT_USING_I2C is not set */
|
||||||
|
#define RT_USING_PIN
|
||||||
|
/* RT_USING_PWM is not set */
|
||||||
|
/* RT_USING_MTD_NOR is not set */
|
||||||
|
/* RT_USING_MTD_NAND is not set */
|
||||||
|
/* RT_USING_RTC is not set */
|
||||||
|
/* RT_USING_SDIO is not set */
|
||||||
|
/* RT_USING_SPI is not set */
|
||||||
|
/* RT_USING_WDT is not set */
|
||||||
|
/* RT_USING_WIFI is not set */
|
||||||
|
/* RT_USING_AUDIO is not set */
|
||||||
|
|
||||||
|
/* Using USB */
|
||||||
|
|
||||||
|
/* RT_USING_USB_HOST is not set */
|
||||||
|
/* RT_USING_USB_DEVICE is not set */
|
||||||
|
|
||||||
|
/* POSIX layer and C standard library */
|
||||||
|
|
||||||
|
#define RT_USING_LIBC
|
||||||
|
#define RT_USING_PTHREADS
|
||||||
|
#define RT_USING_POSIX
|
||||||
|
/* RT_USING_POSIX_MMAP is not set */
|
||||||
|
/* RT_USING_POSIX_TERMIOS is not set */
|
||||||
|
/* RT_USING_POSIX_AIO is not set */
|
||||||
|
|
||||||
|
/* Network */
|
||||||
|
|
||||||
|
/* Socket abstraction layer */
|
||||||
|
|
||||||
|
/* RT_USING_SAL is not set */
|
||||||
|
|
||||||
|
/* light weight TCP/IP stack */
|
||||||
|
|
||||||
|
/* RT_USING_LWIP is not set */
|
||||||
|
|
||||||
|
/* Modbus master and slave stack */
|
||||||
|
|
||||||
|
/* RT_USING_MODBUS is not set */
|
||||||
|
|
||||||
|
/* AT commands */
|
||||||
|
|
||||||
|
/* RT_USING_AT is not set */
|
||||||
|
|
||||||
|
/* VBUS(Virtual Software BUS) */
|
||||||
|
|
||||||
|
#define RT_USING_VBUS
|
||||||
|
/* RT_USING_VBUS_RFS is not set */
|
||||||
|
/* RT_USING_VBUS_RSHELL is not set */
|
||||||
|
#define RT_VBUS_USING_TESTS
|
||||||
|
#define _RT_VBUS_RING_BASE 0x6f800000
|
||||||
|
#define _RT_VBUS_RING_SZ 2097152
|
||||||
|
#define RT_VBUS_GUEST_VIRQ 14
|
||||||
|
#define RT_VBUS_HOST_VIRQ 15
|
||||||
|
#define RT_VBUS_SHELL_DEV_NAME "vbser0"
|
||||||
|
#define RT_VBUS_RFS_DEV_NAME "rfs"
|
||||||
|
|
||||||
|
/* Utilities */
|
||||||
|
|
||||||
|
#define RT_USING_LOGTRACE
|
||||||
|
#define LOG_TRACE_MAX_SESSION 16
|
||||||
|
/* LOG_TRACE_USING_LEVEL_NOTRACE is not set */
|
||||||
|
/* LOG_TRACE_USING_LEVEL_ERROR is not set */
|
||||||
|
/* LOG_TRACE_USING_LEVEL_WARNING is not set */
|
||||||
|
#define LOG_TRACE_USING_LEVEL_INFO
|
||||||
|
/* LOG_TRACE_USING_LEVEL_VERBOSE is not set */
|
||||||
|
/* LOG_TRACE_USING_LEVEL_DEBUG is not set */
|
||||||
|
/* LOG_TRACE_USING_MEMLOG is not set */
|
||||||
|
/* RT_USING_RYM is not set */
|
||||||
|
|
||||||
|
/* RT-Thread online packages */
|
||||||
|
|
||||||
|
/* IoT - internet of things */
|
||||||
|
|
||||||
|
/* PKG_USING_PAHOMQTT is not set */
|
||||||
|
/* PKG_USING_WEBCLIENT is not set */
|
||||||
|
/* PKG_USING_MONGOOSE is not set */
|
||||||
|
/* PKG_USING_WEBTERMINAL is not set */
|
||||||
|
/* PKG_USING_CJSON is not set */
|
||||||
|
/* PKG_USING_JSMN is not set */
|
||||||
|
/* PKG_USING_LJSON is not set */
|
||||||
|
/* PKG_USING_EZXML is not set */
|
||||||
|
/* PKG_USING_NANOPB is not set */
|
||||||
|
|
||||||
|
/* Wi-Fi */
|
||||||
|
|
||||||
|
/* Marvell WiFi */
|
||||||
|
|
||||||
|
/* PKG_USING_WLANMARVELL is not set */
|
||||||
|
|
||||||
|
/* Wiced WiFi */
|
||||||
|
|
||||||
|
/* PKG_USING_WLAN_WICED is not set */
|
||||||
|
/* PKG_USING_COAP is not set */
|
||||||
|
/* PKG_USING_NOPOLL is not set */
|
||||||
|
/* PKG_USING_NETUTILS is not set */
|
||||||
|
/* PKG_USING_AT_DEVICE is not set */
|
||||||
|
|
||||||
|
/* IoT Cloud */
|
||||||
|
|
||||||
|
/* PKG_USING_ONENET is not set */
|
||||||
|
/* PKG_USING_GAGENT_CLOUD is not set */
|
||||||
|
/* PKG_USING_ALI_IOTKIT is not set */
|
||||||
|
/* PKG_USING_AZURE is not set */
|
||||||
|
|
||||||
|
/* security packages */
|
||||||
|
|
||||||
|
/* PKG_USING_MBEDTLS is not set */
|
||||||
|
/* PKG_USING_libsodium is not set */
|
||||||
|
/* PKG_USING_TINYCRYPT is not set */
|
||||||
|
|
||||||
|
/* language packages */
|
||||||
|
|
||||||
|
/* PKG_USING_LUA is not set */
|
||||||
|
/* PKG_USING_JERRYSCRIPT is not set */
|
||||||
|
/* PKG_USING_MICROPYTHON is not set */
|
||||||
|
|
||||||
|
/* multimedia packages */
|
||||||
|
|
||||||
|
/* PKG_USING_OPENMV is not set */
|
||||||
|
/* PKG_USING_MUPDF is not set */
|
||||||
|
|
||||||
|
/* tools packages */
|
||||||
|
|
||||||
|
/* PKG_USING_CMBACKTRACE is not set */
|
||||||
|
/* PKG_USING_EASYFLASH is not set */
|
||||||
|
/* PKG_USING_EASYLOGGER is not set */
|
||||||
|
/* PKG_USING_SYSTEMVIEW is not set */
|
||||||
|
|
||||||
|
/* system packages */
|
||||||
|
|
||||||
|
/* PKG_USING_GUIENGINE is not set */
|
||||||
|
/* PKG_USING_PERSIMMON is not set */
|
||||||
|
/* PKG_USING_CAIRO is not set */
|
||||||
|
/* PKG_USING_PIXMAN is not set */
|
||||||
|
/* PKG_USING_LWEXT4 is not set */
|
||||||
|
/* PKG_USING_PARTITION is not set */
|
||||||
|
/* PKG_USING_FAL is not set */
|
||||||
|
/* PKG_USING_SQLITE is not set */
|
||||||
|
/* PKG_USING_RTI is not set */
|
||||||
|
/* PKG_USING_LITTLEVGL2RTT is not set */
|
||||||
|
|
||||||
|
/* peripheral libraries and drivers */
|
||||||
|
|
||||||
|
/* PKG_USING_STM32F4_HAL is not set */
|
||||||
|
/* PKG_USING_STM32F4_DRIVERS is not set */
|
||||||
|
/* PKG_USING_REALTEK_AMEBA is not set */
|
||||||
|
/* PKG_USING_SHT2X is not set */
|
||||||
|
/* PKG_USING_AHT10 is not set */
|
||||||
|
|
||||||
|
/* miscellaneous packages */
|
||||||
|
|
||||||
|
/* PKG_USING_LIBCSV is not set */
|
||||||
|
/* PKG_USING_OPTPARSE is not set */
|
||||||
|
/* PKG_USING_FASTLZ is not set */
|
||||||
|
/* PKG_USING_MINILZO is not set */
|
||||||
|
/* PKG_USING_QUICKLZ is not set */
|
||||||
|
/* PKG_USING_MULTIBUTTON is not set */
|
||||||
|
/* PKG_USING_CANFESTIVAL is not set */
|
||||||
|
/* PKG_USING_ZLIB is not set */
|
||||||
|
/* PKG_USING_DSTR is not set */
|
||||||
|
|
||||||
|
/* sample package */
|
||||||
|
|
||||||
|
/* PKG_USING_SAMPLES is not set */
|
||||||
|
|
||||||
|
/* example package: hello */
|
||||||
|
|
||||||
|
/* PKG_USING_HELLO is not set */
|
||||||
|
#define SOC_VEXPRESS_GEMINI
|
||||||
|
/* RT_USING_UART0 is not set */
|
||||||
|
#define RT_USING_UART1
|
||||||
|
|
||||||
|
#endif
|
103
bsp/qemu-vexpress-gemini/rtconfig.py
Normal file
103
bsp/qemu-vexpress-gemini/rtconfig.py
Normal file
@ -0,0 +1,103 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
# toolchains options
|
||||||
|
ARCH='arm'
|
||||||
|
CPU='vexpress-a9'
|
||||||
|
CROSS_TOOL='gcc'
|
||||||
|
|
||||||
|
if os.getenv('RTT_CC'):
|
||||||
|
CROSS_TOOL = os.getenv('RTT_CC')
|
||||||
|
|
||||||
|
if CROSS_TOOL == 'gcc':
|
||||||
|
PLATFORM = 'gcc'
|
||||||
|
# EXEC_PATH = r'/opt/arm-2012.09/bin'
|
||||||
|
EXEC_PATH = r'C:\Program Files (x86)\CodeSourcery\Sourcery_CodeBench_Lite_for_ARM_EABI\bin'
|
||||||
|
EXEC_PATH = '/opt/gcc-arm-none-eabi-4_8-2014q1_gri/bin'
|
||||||
|
elif CROSS_TOOL == 'keil':
|
||||||
|
PLATFORM = 'armcc'
|
||||||
|
EXEC_PATH = 'C:/Keil'
|
||||||
|
|
||||||
|
if os.getenv('RTT_EXEC_PATH'):
|
||||||
|
EXEC_PATH = os.getenv('RTT_EXEC_PATH')
|
||||||
|
|
||||||
|
BUILD = 'debug'
|
||||||
|
|
||||||
|
if PLATFORM == 'gcc':
|
||||||
|
# toolchains
|
||||||
|
PREFIX = 'arm-none-eabi-'
|
||||||
|
CC = PREFIX + 'gcc'
|
||||||
|
CXX = PREFIX + 'g++'
|
||||||
|
AS = PREFIX + 'gcc'
|
||||||
|
AR = PREFIX + 'ar'
|
||||||
|
LINK = PREFIX + 'gcc'
|
||||||
|
TARGET_EXT = 'elf'
|
||||||
|
SIZE = PREFIX + 'size'
|
||||||
|
OBJDUMP = PREFIX + 'objdump'
|
||||||
|
OBJCPY = PREFIX + 'objcopy'
|
||||||
|
|
||||||
|
DEVICE = ' -march=armv7-a -mtune=cortex-a9 -mfpu=vfpv3-d16 -ftree-vectorize -ffast-math -mfloat-abi=softfp'
|
||||||
|
CFLAGS = DEVICE + ' -Wall'
|
||||||
|
AFLAGS = ' -c' + DEVICE + ' -x assembler-with-cpp -D__ASSEMBLY__'
|
||||||
|
LINK_SCRIPT = 'vexpress.lds'
|
||||||
|
LFLAGS = DEVICE + ' -Wl,--gc-sections,-Map=vexpress.map,-cref,-u,system_vectors'+\
|
||||||
|
' -T %s' % LINK_SCRIPT
|
||||||
|
|
||||||
|
CPATH = ''
|
||||||
|
LPATH = ''
|
||||||
|
|
||||||
|
# generate debug info in all cases
|
||||||
|
AFLAGS += ' -gdwarf-2'
|
||||||
|
CFLAGS += ' -g -gdwarf-2'
|
||||||
|
|
||||||
|
if BUILD == 'debug':
|
||||||
|
CFLAGS += ' -O0'
|
||||||
|
else:
|
||||||
|
CFLAGS += ' -O2'
|
||||||
|
|
||||||
|
POST_ACTION = OBJCPY + ' -O binary $TARGET rtthread.bin\n' +\
|
||||||
|
SIZE + ' $TARGET \n'
|
||||||
|
|
||||||
|
elif PLATFORM == 'armcc':
|
||||||
|
# toolchains
|
||||||
|
CC = 'armcc'
|
||||||
|
CXX = 'armcc'
|
||||||
|
AS = 'armasm'
|
||||||
|
AR = 'armar'
|
||||||
|
LINK = 'armlink'
|
||||||
|
TARGET_EXT = 'axf'
|
||||||
|
|
||||||
|
DEVICE = ' --device DARMP'
|
||||||
|
CFLAGS = DEVICE + ' --apcs=interwork'
|
||||||
|
AFLAGS = DEVICE
|
||||||
|
LFLAGS = DEVICE + ' --info sizes --info totals --info unused --info veneers --list rtthread-vexpress.map --scatter vexpress.sct'
|
||||||
|
|
||||||
|
CFLAGS += ' -I' + EXEC_PATH + '/ARM/RV31/INC'
|
||||||
|
LFLAGS += ' --libpath ' + EXEC_PATH + '/ARM/RV31/LIB'
|
||||||
|
|
||||||
|
EXEC_PATH += '/arm/bin40/'
|
||||||
|
|
||||||
|
if BUILD == 'debug':
|
||||||
|
CFLAGS += ' -g -O0'
|
||||||
|
AFLAGS += ' -g'
|
||||||
|
else:
|
||||||
|
CFLAGS += ' -O2'
|
||||||
|
|
||||||
|
POST_ACTION = 'fromelf --bin $TARGET --output rtthread.bin \nfromelf -z $TARGET'
|
||||||
|
|
||||||
|
elif PLATFORM == 'iar':
|
||||||
|
# toolchains
|
||||||
|
CC = 'iccarm'
|
||||||
|
AS = 'iasmarm'
|
||||||
|
AR = 'iarchive'
|
||||||
|
LINK = 'ilinkarm'
|
||||||
|
TARGET_EXT = 'out'
|
||||||
|
|
||||||
|
DEVICE = ' --cpu DARMP'
|
||||||
|
|
||||||
|
CFLAGS = ''
|
||||||
|
AFLAGS = ''
|
||||||
|
LFLAGS = ' --config vexpress.icf'
|
||||||
|
|
||||||
|
EXEC_PATH += '/arm/bin/'
|
||||||
|
RT_USING_MINILIBC = False
|
||||||
|
POST_ACTION = ''
|
91
bsp/qemu-vexpress-gemini/vexpress.lds
Normal file
91
bsp/qemu-vexpress-gemini/vexpress.lds
Normal file
@ -0,0 +1,91 @@
|
|||||||
|
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
|
||||||
|
OUTPUT_ARCH(arm)
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
. = 0x6FC00000;
|
||||||
|
|
||||||
|
__text_start = .;
|
||||||
|
.text :
|
||||||
|
{
|
||||||
|
*(.vectors)
|
||||||
|
*(.text)
|
||||||
|
*(.text.*)
|
||||||
|
|
||||||
|
/* section information for finsh shell */
|
||||||
|
. = ALIGN(4);
|
||||||
|
__fsymtab_start = .;
|
||||||
|
KEEP(*(FSymTab))
|
||||||
|
__fsymtab_end = .;
|
||||||
|
. = ALIGN(4);
|
||||||
|
__vsymtab_start = .;
|
||||||
|
KEEP(*(VSymTab))
|
||||||
|
__vsymtab_end = .;
|
||||||
|
. = ALIGN(4);
|
||||||
|
|
||||||
|
/* section information for modules */
|
||||||
|
. = ALIGN(4);
|
||||||
|
__rtmsymtab_start = .;
|
||||||
|
KEEP(*(RTMSymTab))
|
||||||
|
__rtmsymtab_end = .;
|
||||||
|
|
||||||
|
/* section information for initialization */
|
||||||
|
. = ALIGN(4);
|
||||||
|
__rt_init_start = .;
|
||||||
|
KEEP(*(SORT(.rti_fn*)))
|
||||||
|
__rt_init_end = .;
|
||||||
|
} =0
|
||||||
|
__text_end = .;
|
||||||
|
|
||||||
|
__rodata_start = .;
|
||||||
|
.rodata : { *(.rodata) *(.rodata.*) }
|
||||||
|
__rodata_end = .;
|
||||||
|
|
||||||
|
. = ALIGN(4);
|
||||||
|
.ctors :
|
||||||
|
{
|
||||||
|
PROVIDE(__ctors_start__ = .);
|
||||||
|
KEEP(*(SORT(.ctors.*)))
|
||||||
|
KEEP(*(.ctors))
|
||||||
|
PROVIDE(__ctors_end__ = .);
|
||||||
|
}
|
||||||
|
|
||||||
|
.dtors :
|
||||||
|
{
|
||||||
|
PROVIDE(__dtors_start__ = .);
|
||||||
|
KEEP(*(SORT(.dtors.*)))
|
||||||
|
KEEP(*(.dtors))
|
||||||
|
PROVIDE(__dtors_end__ = .);
|
||||||
|
}
|
||||||
|
|
||||||
|
__data_start = .;
|
||||||
|
. = ALIGN(4);
|
||||||
|
.data :
|
||||||
|
{
|
||||||
|
*(.data)
|
||||||
|
*(.data.*)
|
||||||
|
}
|
||||||
|
__data_end = .;
|
||||||
|
|
||||||
|
. = ALIGN(4);
|
||||||
|
__bss_start = __data_end;
|
||||||
|
.bss :
|
||||||
|
{
|
||||||
|
*(.bss)
|
||||||
|
*(.bss.*)
|
||||||
|
*(COMMON)
|
||||||
|
. = ALIGN(4);
|
||||||
|
}
|
||||||
|
. = ALIGN(4);
|
||||||
|
__bss_end = .;
|
||||||
|
|
||||||
|
/* Stabs debugging sections. */
|
||||||
|
.stab 0 : { *(.stab) }
|
||||||
|
.stabstr 0 : { *(.stabstr) }
|
||||||
|
.stab.excl 0 : { *(.stab.excl) }
|
||||||
|
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||||
|
.stab.index 0 : { *(.stab.index) }
|
||||||
|
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||||
|
.comment 0 : { *(.comment) }
|
||||||
|
|
||||||
|
_end = .;
|
||||||
|
}
|
290
bsp/raspi2/.config
Normal file
290
bsp/raspi2/.config
Normal file
@ -0,0 +1,290 @@
|
|||||||
|
#
|
||||||
|
# Automatically generated file; DO NOT EDIT.
|
||||||
|
# RT-Thread Project Configuration
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# RT-Thread Kernel
|
||||||
|
#
|
||||||
|
CONFIG_RT_NAME_MAX=8
|
||||||
|
CONFIG_RT_ALIGN_SIZE=4
|
||||||
|
# CONFIG_RT_THREAD_PRIORITY_8 is not set
|
||||||
|
CONFIG_RT_THREAD_PRIORITY_32=y
|
||||||
|
# CONFIG_RT_THREAD_PRIORITY_256 is not set
|
||||||
|
CONFIG_RT_THREAD_PRIORITY_MAX=32
|
||||||
|
CONFIG_RT_TICK_PER_SECOND=100
|
||||||
|
CONFIG_RT_USING_OVERFLOW_CHECK=y
|
||||||
|
CONFIG_RT_USING_HOOK=y
|
||||||
|
CONFIG_RT_IDEL_HOOK_LIST_SIZE=4
|
||||||
|
CONFIG_IDLE_THREAD_STACK_SIZE=256
|
||||||
|
# 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
|
||||||
|
#
|
||||||
|
CONFIG_RT_USING_SEMAPHORE=y
|
||||||
|
CONFIG_RT_USING_MUTEX=y
|
||||||
|
CONFIG_RT_USING_EVENT=y
|
||||||
|
CONFIG_RT_USING_MAILBOX=y
|
||||||
|
CONFIG_RT_USING_MESSAGEQUEUE=y
|
||||||
|
# CONFIG_RT_USING_SIGNALS is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# Memory Management
|
||||||
|
#
|
||||||
|
CONFIG_RT_USING_MEMPOOL=y
|
||||||
|
# CONFIG_RT_USING_MEMHEAP is not set
|
||||||
|
# CONFIG_RT_USING_NOHEAP is not set
|
||||||
|
CONFIG_RT_USING_SMALL_MEM=y
|
||||||
|
# CONFIG_RT_USING_SLAB is not set
|
||||||
|
# CONFIG_RT_USING_MEMTRACE is not set
|
||||||
|
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="uart1"
|
||||||
|
# CONFIG_RT_USING_MODULE is not set
|
||||||
|
CONFIG_ARCH_ARM=y
|
||||||
|
CONFIG_ARCH_ARM_CORTEX_A=y
|
||||||
|
CONFIG_ARCH_ARM_CORTEX_A7=y
|
||||||
|
|
||||||
|
#
|
||||||
|
# RT-Thread Components
|
||||||
|
#
|
||||||
|
CONFIG_RT_USING_COMPONENTS_INIT=y
|
||||||
|
CONFIG_RT_USING_USER_MAIN=y
|
||||||
|
CONFIG_RT_MAIN_THREAD_STACK_SIZE=2048
|
||||||
|
CONFIG_RT_MAIN_THREAD_PRIORITY=10
|
||||||
|
|
||||||
|
#
|
||||||
|
# C++ features
|
||||||
|
#
|
||||||
|
# CONFIG_RT_USING_CPLUSPLUS is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# Command shell
|
||||||
|
#
|
||||||
|
CONFIG_RT_USING_FINSH=y
|
||||||
|
CONFIG_FINSH_THREAD_NAME="tshell"
|
||||||
|
CONFIG_FINSH_USING_HISTORY=y
|
||||||
|
CONFIG_FINSH_HISTORY_LINES=5
|
||||||
|
CONFIG_FINSH_USING_SYMTAB=y
|
||||||
|
CONFIG_FINSH_USING_DESCRIPTION=y
|
||||||
|
# CONFIG_FINSH_ECHO_DISABLE_DEFAULT is not set
|
||||||
|
CONFIG_FINSH_THREAD_PRIORITY=20
|
||||||
|
CONFIG_FINSH_THREAD_STACK_SIZE=4096
|
||||||
|
CONFIG_FINSH_CMD_SIZE=80
|
||||||
|
# CONFIG_FINSH_USING_AUTH is not set
|
||||||
|
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
|
||||||
|
#
|
||||||
|
# CONFIG_RT_USING_DFS is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# 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_PWM is not set
|
||||||
|
# CONFIG_RT_USING_MTD_NOR is not set
|
||||||
|
# CONFIG_RT_USING_MTD_NAND 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 USB
|
||||||
|
#
|
||||||
|
# CONFIG_RT_USING_USB_HOST is not set
|
||||||
|
# CONFIG_RT_USING_USB_DEVICE is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# POSIX layer and C standard library
|
||||||
|
#
|
||||||
|
# CONFIG_RT_USING_LIBC is not set
|
||||||
|
# CONFIG_RT_USING_PTHREADS is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# Network
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# Socket abstraction layer
|
||||||
|
#
|
||||||
|
# CONFIG_RT_USING_SAL is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# light weight TCP/IP stack
|
||||||
|
#
|
||||||
|
# CONFIG_RT_USING_LWIP is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# Modbus master and slave stack
|
||||||
|
#
|
||||||
|
# CONFIG_RT_USING_MODBUS is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# AT commands
|
||||||
|
#
|
||||||
|
# CONFIG_RT_USING_AT is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# VBUS(Virtual Software BUS)
|
||||||
|
#
|
||||||
|
# CONFIG_RT_USING_VBUS is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# Utilities
|
||||||
|
#
|
||||||
|
# CONFIG_RT_USING_LOGTRACE is not set
|
||||||
|
# CONFIG_RT_USING_RYM is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# RT-Thread online packages
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# IoT - internet of things
|
||||||
|
#
|
||||||
|
# CONFIG_PKG_USING_PAHOMQTT is not set
|
||||||
|
# CONFIG_PKG_USING_WEBCLIENT is not set
|
||||||
|
# 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
|
||||||
|
|
||||||
|
#
|
||||||
|
# Wi-Fi
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# Marvell WiFi
|
||||||
|
#
|
||||||
|
# CONFIG_PKG_USING_WLANMARVELL is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# Wiced WiFi
|
||||||
|
#
|
||||||
|
# CONFIG_PKG_USING_WLAN_WICED is not set
|
||||||
|
# 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
|
||||||
|
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
#
|
||||||
|
# CONFIG_PKG_USING_MBEDTLS is not set
|
||||||
|
# CONFIG_PKG_USING_libsodium is not set
|
||||||
|
# CONFIG_PKG_USING_TINYCRYPT is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# language packages
|
||||||
|
#
|
||||||
|
# CONFIG_PKG_USING_LUA is not set
|
||||||
|
# CONFIG_PKG_USING_JERRYSCRIPT is not set
|
||||||
|
# CONFIG_PKG_USING_MICROPYTHON is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# multimedia packages
|
||||||
|
#
|
||||||
|
# CONFIG_PKG_USING_OPENMV is not set
|
||||||
|
# CONFIG_PKG_USING_MUPDF is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# tools packages
|
||||||
|
#
|
||||||
|
# CONFIG_PKG_USING_CMBACKTRACE is not set
|
||||||
|
# CONFIG_PKG_USING_EASYFLASH is not set
|
||||||
|
# CONFIG_PKG_USING_EASYLOGGER is not set
|
||||||
|
# CONFIG_PKG_USING_SYSTEMVIEW is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# system packages
|
||||||
|
#
|
||||||
|
# CONFIG_PKG_USING_GUIENGINE is not set
|
||||||
|
# CONFIG_PKG_USING_PERSIMMON 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
|
||||||
|
|
||||||
|
#
|
||||||
|
# peripheral libraries and drivers
|
||||||
|
#
|
||||||
|
# CONFIG_PKG_USING_STM32F4_HAL is not set
|
||||||
|
# CONFIG_PKG_USING_STM32F4_DRIVERS is not set
|
||||||
|
# CONFIG_PKG_USING_REALTEK_AMEBA is not set
|
||||||
|
# CONFIG_PKG_USING_SHT2X is not set
|
||||||
|
# CONFIG_PKG_USING_AHT10 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_CANFESTIVAL is not set
|
||||||
|
# CONFIG_PKG_USING_ZLIB is not set
|
||||||
|
# CONFIG_PKG_USING_DSTR is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# sample package
|
||||||
|
#
|
||||||
|
# CONFIG_PKG_USING_SAMPLES is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# example package: hello
|
||||||
|
#
|
||||||
|
# CONFIG_PKG_USING_HELLO is not set
|
||||||
|
CONFIG_BCM2836_SOC=y
|
||||||
|
CONFIG_RT_USING_UART1=y
|
26
bsp/raspi2/Kconfig
Normal file
26
bsp/raspi2/Kconfig
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
mainmenu "RT-Thread Project Configuration"
|
||||||
|
|
||||||
|
config $BSP_DIR
|
||||||
|
string
|
||||||
|
option env="BSP_ROOT"
|
||||||
|
default "."
|
||||||
|
|
||||||
|
config $RTT_DIR
|
||||||
|
string
|
||||||
|
option env="RTT_ROOT"
|
||||||
|
default "../.."
|
||||||
|
|
||||||
|
config $PKGS_DIR
|
||||||
|
string
|
||||||
|
option env="PKGS_ROOT"
|
||||||
|
default "packages"
|
||||||
|
|
||||||
|
source "$RTT_DIR/Kconfig"
|
||||||
|
source "$PKGS_DIR/Kconfig"
|
||||||
|
|
||||||
|
config BCM2836_SOC
|
||||||
|
bool
|
||||||
|
select ARCH_ARM_CORTEX_A7
|
||||||
|
default y
|
||||||
|
|
||||||
|
source "driver/Kconfig"
|
106
bsp/raspi2/README.md
Normal file
106
bsp/raspi2/README.md
Normal file
@ -0,0 +1,106 @@
|
|||||||
|
# Raspberry PI 2B板级支持包说明
|
||||||
|
|
||||||
|
## 1. 简介
|
||||||
|
|
||||||
|
树莓派由注册于英国的慈善组织“Raspberry Pi 基金会”开发,莓派2采用4核Broadcom BCM2836 (ARMv7-A)芯片、双核VideoCore IV GPU和1GB内存。
|
||||||
|
|
||||||
|
这份RT-Thread BSP是针对 Raspberry Pi 2B 的一份移植,树莓派价格便宜, 使用者甚众,是研究和运行RT-Thread的可选平台之一。
|
||||||
|
|
||||||
|
![raspi2](figures/raspi2.png)
|
||||||
|
|
||||||
|
当前Raspberry Pi 2B对应的硬件特性:
|
||||||
|
|
||||||
|
| 硬件 | 描述 |
|
||||||
|
|------- | ------------------------------- |
|
||||||
|
| CPU | ARM Cortex-A7(4核心) |
|
||||||
|
| 主频 | 900M |
|
||||||
|
| Memory | 1GB (0x0000000 - 0x40000000) |
|
||||||
|
| | 其中0x3f000000 - 0x40000000为peripheral |
|
||||||
|
|
||||||
|
## 2. 编译说明
|
||||||
|
|
||||||
|
Windows环境下推荐使用[env工具][1]进行编译。
|
||||||
|
|
||||||
|
Linux下推荐使用gcc工具 [gcc-arm-none-eabi-4_8-2014q1_linux][2],如果还没有编译工具,下载后,解开文件。
|
||||||
|
|
||||||
|
```
|
||||||
|
tar vxf gcc-arm-none-eabi-4_8-2014q1_linux.tar.bz2
|
||||||
|
```
|
||||||
|
|
||||||
|
Linux环境下需要修改编译器目录设置,修改`bsp/raspi2/rtconfig.py`中的
|
||||||
|
|
||||||
|
```
|
||||||
|
EXEC_PATH = r'/opt/gcc-arm-none-eabi-4_8-2014q1_gri/bin'
|
||||||
|
```
|
||||||
|
|
||||||
|
为编译工具的实际所在目录,这里注意要加上后缀 `/bin`
|
||||||
|
|
||||||
|
进入到`rt-thread/bsp/raspi2`目录中,运行以下命令:
|
||||||
|
|
||||||
|
```
|
||||||
|
scons
|
||||||
|
```
|
||||||
|
|
||||||
|
来编译这个板级支持包。如果编译正确无误,会产生kernel.elf、kernel.img文件。
|
||||||
|
kernel.img即是要cp到raspberry SD卡中根目录的文件
|
||||||
|
|
||||||
|
## 3. 执行
|
||||||
|
|
||||||
|
### 3.1 下载[raspbian镜像][3],生成可以运行的raspbian SD卡
|
||||||
|
|
||||||
|
Windows下,去[etcher.io][4]下载etcher,这是个可以烧写img的工具
|
||||||
|
|
||||||
|
解开下载的镜像文件, linux下使用如下的命令
|
||||||
|
|
||||||
|
```
|
||||||
|
unzip 2018-06-27-raspbian-stretch-lite.zip
|
||||||
|
```
|
||||||
|
|
||||||
|
准备一张空SD卡,linux环境下,插入电脑并执行
|
||||||
|
|
||||||
|
```
|
||||||
|
sudo dd if=2018-06-27-raspbian-stretch-lite.img of=/dev/xxx bs=32M conv=fsync
|
||||||
|
```
|
||||||
|
|
||||||
|
**注意: /dev/xxx 要换成真实环境中的SD卡所在设置,千万不要弄错。**
|
||||||
|
|
||||||
|
Windows环境下,执行etcher选择解压后的2018-06-27-raspbian-stretch-lite.img文件和SD卡就可以开始烧写了。
|
||||||
|
|
||||||
|
最后把kernel7.img放入SD boot分区,覆盖原来的文件。
|
||||||
|
|
||||||
|
### 3.2 准备好串口线
|
||||||
|
|
||||||
|
目前版本是使用raspi2的 GPIO 14, GPIO 15来作路口输出,连线情况如下图所示:
|
||||||
|
|
||||||
|
![raspi2](figures/raspi_uart.png)
|
||||||
|
|
||||||
|
串口参数: 115200 8N1 ,硬件和软件流控为关。
|
||||||
|
|
||||||
|
按上面的方法做好SD卡后,插入树莓派2B,通电可以在串口上看到如下所示的输出信息:
|
||||||
|
|
||||||
|
```text
|
||||||
|
heap: 0x00020b20 - 0x00400000
|
||||||
|
|
||||||
|
\ | /
|
||||||
|
- RT - Thread Operating System
|
||||||
|
/ | \ 3.1.0 build Aug 23 2018
|
||||||
|
2006 - 2018 Copyright by rt-thread team
|
||||||
|
Hello RT-Thread!
|
||||||
|
msh >
|
||||||
|
```
|
||||||
|
|
||||||
|
## 4. 支持情况
|
||||||
|
|
||||||
|
| 驱动 | 支持情况 | 备注 |
|
||||||
|
| ------ | ---- | :------: |
|
||||||
|
| UART | 支持 | UART0|
|
||||||
|
|
||||||
|
## 5. 联系人信息
|
||||||
|
|
||||||
|
维护人:[bernard][5]
|
||||||
|
|
||||||
|
[1]: https://www.rt-thread.org/page/download.html
|
||||||
|
[2]: https://launchpad.net/gcc-arm-embedded/4.8/4.8-2014-q1-update/+download/gcc-arm-none-eabi-4_8-2014q1-20140314-linux.tar.bz2
|
||||||
|
[3]: https://downloads.raspberrypi.org/raspbian_lite_latest
|
||||||
|
[4]: https://etcher.io
|
||||||
|
[5]: https://github.com/BernardXiong
|
14
bsp/raspi2/SConscript
Normal file
14
bsp/raspi2/SConscript
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
# for module compiling
|
||||||
|
import os
|
||||||
|
from building import *
|
||||||
|
|
||||||
|
cwd = GetCurrentDir()
|
||||||
|
objs = []
|
||||||
|
list = os.listdir(cwd)
|
||||||
|
|
||||||
|
for d in list:
|
||||||
|
path = os.path.join(cwd, d)
|
||||||
|
if os.path.isfile(os.path.join(path, 'SConscript')):
|
||||||
|
objs = objs + SConscript(os.path.join(d, 'SConscript'))
|
||||||
|
|
||||||
|
Return('objs')
|
27
bsp/raspi2/SConstruct
Normal file
27
bsp/raspi2/SConstruct
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import rtconfig
|
||||||
|
|
||||||
|
from rtconfig import RTT_ROOT
|
||||||
|
|
||||||
|
sys.path = sys.path + [os.path.join(RTT_ROOT, 'tools')]
|
||||||
|
from building import *
|
||||||
|
|
||||||
|
TARGET = 'rtthread.' + rtconfig.TARGET_EXT
|
||||||
|
|
||||||
|
env = Environment(tools = ['mingw'],
|
||||||
|
AS = rtconfig.AS, ASFLAGS = rtconfig.AFLAGS,
|
||||||
|
CC = rtconfig.CC, CCFLAGS = rtconfig.CFLAGS,
|
||||||
|
CXX = rtconfig.CXX, CXXFLAGS = rtconfig.CXXFLAGS,
|
||||||
|
AR = rtconfig.AR, ARFLAGS = '-rc',
|
||||||
|
LINK = rtconfig.LINK, LINKFLAGS = rtconfig.LFLAGS)
|
||||||
|
env.PrependENVPath('PATH', rtconfig.EXEC_PATH)
|
||||||
|
|
||||||
|
Export('RTT_ROOT')
|
||||||
|
Export('rtconfig')
|
||||||
|
|
||||||
|
# prepare building environment
|
||||||
|
objs = PrepareBuilding(env, RTT_ROOT, has_libcpu=True)
|
||||||
|
|
||||||
|
# make a building
|
||||||
|
DoBuilding(TARGET, objs)
|
9
bsp/raspi2/applications/SConscript
Normal file
9
bsp/raspi2/applications/SConscript
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
from building import *
|
||||||
|
|
||||||
|
cwd = GetCurrentDir()
|
||||||
|
src = Glob('*.c') + Glob('*.cpp')
|
||||||
|
CPPPATH = [cwd, str(Dir('#'))]
|
||||||
|
|
||||||
|
group = DefineGroup('Applications', src, depend = [''], CPPPATH = CPPPATH)
|
||||||
|
|
||||||
|
Return('group')
|
36
bsp/raspi2/applications/main.c
Normal file
36
bsp/raspi2/applications/main.c
Normal file
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* File : main.c
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2017, 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-5-30 Bernard the first version
|
||||||
|
*/
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <rtthread.h>
|
||||||
|
|
||||||
|
int main(int argc, char** argv)
|
||||||
|
{
|
||||||
|
rt_kprintf("Hello RT-Thread!\n");
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
29
bsp/raspi2/applications/mnt.c
Normal file
29
bsp/raspi2/applications/mnt.c
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
/*
|
||||||
|
* File : mnt.c
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2017, 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <rtthread.h>
|
||||||
|
|
||||||
|
int mnt_init(void)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
9
bsp/raspi2/cpu/SConscript
Normal file
9
bsp/raspi2/cpu/SConscript
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
from building import *
|
||||||
|
|
||||||
|
cwd = GetCurrentDir()
|
||||||
|
src = Glob('*.c') + Glob('*.cpp') + Glob('*_gcc.S')
|
||||||
|
CPPPATH = [cwd]
|
||||||
|
|
||||||
|
group = DefineGroup('cpu', src, depend = [''], CPPPATH = CPPPATH)
|
||||||
|
|
||||||
|
Return('group')
|
64
bsp/raspi2/cpu/armv7.h
Normal file
64
bsp/raspi2/cpu/armv7.h
Normal file
@ -0,0 +1,64 @@
|
|||||||
|
#ifndef __ARMV7_H__
|
||||||
|
#define __ARMV7_H__
|
||||||
|
|
||||||
|
/* the exception stack without VFP registers */
|
||||||
|
struct rt_hw_exp_stack
|
||||||
|
{
|
||||||
|
unsigned long r0;
|
||||||
|
unsigned long r1;
|
||||||
|
unsigned long r2;
|
||||||
|
unsigned long r3;
|
||||||
|
unsigned long r4;
|
||||||
|
unsigned long r5;
|
||||||
|
unsigned long r6;
|
||||||
|
unsigned long r7;
|
||||||
|
unsigned long r8;
|
||||||
|
unsigned long r9;
|
||||||
|
unsigned long r10;
|
||||||
|
unsigned long fp;
|
||||||
|
unsigned long ip;
|
||||||
|
unsigned long sp;
|
||||||
|
unsigned long lr;
|
||||||
|
unsigned long pc;
|
||||||
|
unsigned long cpsr;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct rt_hw_stack
|
||||||
|
{
|
||||||
|
unsigned long cpsr;
|
||||||
|
unsigned long r0;
|
||||||
|
unsigned long r1;
|
||||||
|
unsigned long r2;
|
||||||
|
unsigned long r3;
|
||||||
|
unsigned long r4;
|
||||||
|
unsigned long r5;
|
||||||
|
unsigned long r6;
|
||||||
|
unsigned long r7;
|
||||||
|
unsigned long r8;
|
||||||
|
unsigned long r9;
|
||||||
|
unsigned long r10;
|
||||||
|
unsigned long fp;
|
||||||
|
unsigned long ip;
|
||||||
|
unsigned long lr;
|
||||||
|
unsigned long pc;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define USERMODE 0x10
|
||||||
|
#define FIQMODE 0x11
|
||||||
|
#define IRQMODE 0x12
|
||||||
|
#define SVCMODE 0x13
|
||||||
|
#define MONITORMODE 0x16
|
||||||
|
#define ABORTMODE 0x17
|
||||||
|
#define HYPMODE 0x1b
|
||||||
|
#define UNDEFMODE 0x1b
|
||||||
|
#define MODEMASK 0x1f
|
||||||
|
#define NOINT 0xc0
|
||||||
|
|
||||||
|
#define T_Bit (1<<5)
|
||||||
|
#define F_Bit (1<<6)
|
||||||
|
#define I_Bit (1<<7)
|
||||||
|
#define A_Bit (1<<8)
|
||||||
|
#define E_Bit (1<<9)
|
||||||
|
#define J_Bit (1<<24)
|
||||||
|
|
||||||
|
#endif
|
105
bsp/raspi2/cpu/context_gcc.S
Normal file
105
bsp/raspi2/cpu/context_gcc.S
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
/*
|
||||||
|
* File : context.S
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2013, 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
|
||||||
|
* 2013-07-05 Bernard the first version
|
||||||
|
*/
|
||||||
|
|
||||||
|
.section .text, "ax"
|
||||||
|
/*
|
||||||
|
* rt_base_t rt_hw_interrupt_disable();
|
||||||
|
*/
|
||||||
|
.globl rt_hw_interrupt_disable
|
||||||
|
rt_hw_interrupt_disable:
|
||||||
|
mrs r0, cpsr
|
||||||
|
cpsid i
|
||||||
|
bx lr
|
||||||
|
|
||||||
|
/*
|
||||||
|
* void rt_hw_interrupt_enable(rt_base_t level);
|
||||||
|
*/
|
||||||
|
.globl rt_hw_interrupt_enable
|
||||||
|
rt_hw_interrupt_enable:
|
||||||
|
msr cpsr_c, r0
|
||||||
|
bx lr
|
||||||
|
|
||||||
|
/*
|
||||||
|
* void rt_hw_context_switch_to(rt_uint32 to);
|
||||||
|
* r0 --> to
|
||||||
|
*/
|
||||||
|
.globl rt_hw_context_switch_to
|
||||||
|
rt_hw_context_switch_to:
|
||||||
|
ldr sp, [r0] @ get new task stack pointer
|
||||||
|
|
||||||
|
ldmfd sp!, {r4} @ pop new task spsr
|
||||||
|
msr spsr_cxsf, r4
|
||||||
|
|
||||||
|
ldmfd sp!, {r0-r12, lr, pc}^ @ pop new task r0-r12, lr & pc
|
||||||
|
|
||||||
|
.section .bss.share.isr
|
||||||
|
_guest_switch_lvl:
|
||||||
|
.word 0
|
||||||
|
|
||||||
|
.globl vmm_virq_update
|
||||||
|
|
||||||
|
.section .text.isr, "ax"
|
||||||
|
/*
|
||||||
|
* void rt_hw_context_switch(rt_uint32 from, rt_uint32 to);
|
||||||
|
* r0 --> from
|
||||||
|
* r1 --> to
|
||||||
|
*/
|
||||||
|
.globl rt_hw_context_switch
|
||||||
|
rt_hw_context_switch:
|
||||||
|
stmfd sp!, {lr} @ push pc (lr should be pushed in place of PC)
|
||||||
|
stmfd sp!, {r0-r12, lr} @ push lr & register file
|
||||||
|
|
||||||
|
mrs r4, cpsr
|
||||||
|
tst lr, #0x01
|
||||||
|
orrne r4, r4, #0x20 @ it's thumb code
|
||||||
|
|
||||||
|
stmfd sp!, {r4} @ push cpsr
|
||||||
|
|
||||||
|
str sp, [r0] @ store sp in preempted tasks TCB
|
||||||
|
ldr sp, [r1] @ get new task stack pointer
|
||||||
|
|
||||||
|
ldmfd sp!, {r4} @ pop new task cpsr to spsr
|
||||||
|
msr spsr_cxsf, r4
|
||||||
|
ldmfd sp!, {r0-r12, lr, pc}^ @ pop new task r0-r12, lr & pc, copy spsr to cpsr
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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:
|
||||||
|
ldr r2, =rt_thread_switch_interrupt_flag
|
||||||
|
ldr r3, [r2]
|
||||||
|
cmp r3, #1
|
||||||
|
beq _reswitch
|
||||||
|
ldr ip, =rt_interrupt_from_thread @ set rt_interrupt_from_thread
|
||||||
|
mov r3, #1 @ set rt_thread_switch_interrupt_flag to 1
|
||||||
|
str r0, [ip]
|
||||||
|
str r3, [r2]
|
||||||
|
_reswitch:
|
||||||
|
ldr r2, =rt_interrupt_to_thread @ set rt_interrupt_to_thread
|
||||||
|
str r1, [r2]
|
||||||
|
bx lr
|
12
bsp/raspi2/cpu/cp15.h
Normal file
12
bsp/raspi2/cpu/cp15.h
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
#ifndef __CP15_H__
|
||||||
|
#define __CP15_H__
|
||||||
|
|
||||||
|
unsigned long rt_cpu_get_smp_id(void);
|
||||||
|
|
||||||
|
void rt_cpu_mmu_disable(void);
|
||||||
|
void rt_cpu_mmu_enable(void);
|
||||||
|
void rt_cpu_tlb_set(volatile unsigned long*);
|
||||||
|
|
||||||
|
void rt_cpu_vector_set_base(unsigned int addr);
|
||||||
|
|
||||||
|
#endif
|
140
bsp/raspi2/cpu/cp15_gcc.S
Normal file
140
bsp/raspi2/cpu/cp15_gcc.S
Normal file
@ -0,0 +1,140 @@
|
|||||||
|
/*
|
||||||
|
* File : cp15_gcc.S
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2013, RT-Thread Development Team
|
||||||
|
* http://www.rt-thread.org
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
* 2013-07-05 Bernard the first version
|
||||||
|
*/
|
||||||
|
|
||||||
|
.globl rt_cpu_get_smp_id
|
||||||
|
rt_cpu_get_smp_id:
|
||||||
|
mrc p15, #0, r0, c0, c0, #5
|
||||||
|
bx lr
|
||||||
|
|
||||||
|
.globl rt_cpu_vector_set_base
|
||||||
|
rt_cpu_vector_set_base:
|
||||||
|
mcr p15, #0, r0, c12, c0, #0
|
||||||
|
dsb
|
||||||
|
bx lr
|
||||||
|
|
||||||
|
.globl rt_hw_cpu_dcache_enable
|
||||||
|
rt_hw_cpu_dcache_enable:
|
||||||
|
mrc p15, #0, r0, c1, c0, #0
|
||||||
|
orr r0, r0, #0x00000004
|
||||||
|
mcr p15, #0, r0, c1, c0, #0
|
||||||
|
bx lr
|
||||||
|
|
||||||
|
.globl rt_hw_cpu_icache_enable
|
||||||
|
rt_hw_cpu_icache_enable:
|
||||||
|
mrc p15, #0, r0, c1, c0, #0
|
||||||
|
orr r0, r0, #0x00001000
|
||||||
|
mcr p15, #0, r0, c1, c0, #0
|
||||||
|
bx lr
|
||||||
|
|
||||||
|
_FLD_MAX_WAY:
|
||||||
|
.word 0x3ff
|
||||||
|
_FLD_MAX_IDX:
|
||||||
|
.word 0x7ff
|
||||||
|
|
||||||
|
.globl rt_cpu_dcache_clean_flush
|
||||||
|
rt_cpu_dcache_clean_flush:
|
||||||
|
push {r4-r11}
|
||||||
|
dmb
|
||||||
|
mrc p15, #1, r0, c0, c0, #1 @ read clid register
|
||||||
|
ands r3, r0, #0x7000000 @ get level of coherency
|
||||||
|
mov r3, r3, lsr #23
|
||||||
|
beq finished
|
||||||
|
mov r10, #0
|
||||||
|
loop1:
|
||||||
|
add r2, r10, r10, lsr #1
|
||||||
|
mov r1, r0, lsr r2
|
||||||
|
and r1, r1, #7
|
||||||
|
cmp r1, #2
|
||||||
|
blt skip
|
||||||
|
mcr p15, #2, r10, c0, c0, #0
|
||||||
|
isb
|
||||||
|
mrc p15, #1, r1, c0, c0, #0
|
||||||
|
and r2, r1, #7
|
||||||
|
add r2, r2, #4
|
||||||
|
ldr r4, _FLD_MAX_WAY
|
||||||
|
ands r4, r4, r1, lsr #3
|
||||||
|
clz r5, r4
|
||||||
|
ldr r7, _FLD_MAX_IDX
|
||||||
|
ands r7, r7, r1, lsr #13
|
||||||
|
loop2:
|
||||||
|
mov r9, r4
|
||||||
|
loop3:
|
||||||
|
orr r11, r10, r9, lsl r5
|
||||||
|
orr r11, r11, r7, lsl r2
|
||||||
|
mcr p15, #0, r11, c7, c14, #2
|
||||||
|
subs r9, r9, #1
|
||||||
|
bge loop3
|
||||||
|
subs r7, r7, #1
|
||||||
|
bge loop2
|
||||||
|
skip:
|
||||||
|
add r10, r10, #2
|
||||||
|
cmp r3, r10
|
||||||
|
bgt loop1
|
||||||
|
|
||||||
|
finished:
|
||||||
|
dsb
|
||||||
|
isb
|
||||||
|
pop {r4-r11}
|
||||||
|
bx lr
|
||||||
|
|
||||||
|
.globl rt_hw_cpu_dcache_disable
|
||||||
|
rt_hw_cpu_dcache_disable:
|
||||||
|
push {r4-r11, lr}
|
||||||
|
bl rt_cpu_dcache_clean_flush
|
||||||
|
mrc p15, #0, r0, c1, c0, #0
|
||||||
|
bic r0, r0, #0x00000004
|
||||||
|
mcr p15, #0, r0, c1, c0, #0
|
||||||
|
pop {r4-r11, lr}
|
||||||
|
bx lr
|
||||||
|
|
||||||
|
.globl rt_hw_cpu_icache_disable
|
||||||
|
rt_hw_cpu_icache_disable:
|
||||||
|
mrc p15, #0, r0, c1, c0, #0
|
||||||
|
bic r0, r0, #0x00001000
|
||||||
|
mcr p15, #0, r0, c1, c0, #0
|
||||||
|
bx lr
|
||||||
|
|
||||||
|
.globl rt_cpu_mmu_disable
|
||||||
|
rt_cpu_mmu_disable:
|
||||||
|
mcr p15, #0, r0, c8, c7, #0 @ invalidate tlb
|
||||||
|
mrc p15, #0, r0, c1, c0, #0
|
||||||
|
bic r0, r0, #1
|
||||||
|
mcr p15, #0, r0, c1, c0, #0 @ clear mmu bit
|
||||||
|
dsb
|
||||||
|
bx lr
|
||||||
|
|
||||||
|
.globl rt_cpu_mmu_enable
|
||||||
|
rt_cpu_mmu_enable:
|
||||||
|
mrc p15, #0, r0, c1, c0, #0
|
||||||
|
orr r0, r0, #0x001
|
||||||
|
mcr p15, #0, r0, c1, c0, #0 @ set mmu enable bit
|
||||||
|
dsb
|
||||||
|
bx lr
|
||||||
|
|
||||||
|
.globl rt_cpu_tlb_set
|
||||||
|
rt_cpu_tlb_set:
|
||||||
|
mcr p15, #0, r0, c2, c0, #0
|
||||||
|
dmb
|
||||||
|
bx lr
|
37
bsp/raspi2/cpu/cpu.c
Normal file
37
bsp/raspi2/cpu/cpu.c
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* File : cpu.c
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2006, RT-Thread Develop Team
|
||||||
|
*
|
||||||
|
* The license and distribution terms for this file may be
|
||||||
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://www.rt-thread.org/license/LICENSE
|
||||||
|
*
|
||||||
|
* Change Logs:
|
||||||
|
* Date Author Notes
|
||||||
|
* 2011-09-15 Bernard first version
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <rthw.h>
|
||||||
|
#include <rtthread.h>
|
||||||
|
#include <board.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup AM33xx
|
||||||
|
*/
|
||||||
|
/*@{*/
|
||||||
|
|
||||||
|
/** shutdown CPU */
|
||||||
|
void rt_hw_cpu_shutdown()
|
||||||
|
{
|
||||||
|
rt_uint32_t level;
|
||||||
|
rt_kprintf("shutdown...\n");
|
||||||
|
|
||||||
|
level = rt_hw_interrupt_disable();
|
||||||
|
while (level)
|
||||||
|
{
|
||||||
|
RT_ASSERT(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*@}*/
|
136
bsp/raspi2/cpu/interrupt.c
Normal file
136
bsp/raspi2/cpu/interrupt.c
Normal file
@ -0,0 +1,136 @@
|
|||||||
|
/*
|
||||||
|
* File : interrupt.c
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2013-2014, RT-Thread Development Team
|
||||||
|
*
|
||||||
|
* The license and distribution terms for this file may be
|
||||||
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://www.rt-thread.org/license/LICENSE
|
||||||
|
*
|
||||||
|
* Change Logs:
|
||||||
|
* Date Author Notes
|
||||||
|
* 2018/5/3 Bernard first version
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <rthw.h>
|
||||||
|
#include <rtthread.h>
|
||||||
|
|
||||||
|
#include "cp15.h"
|
||||||
|
#include <board.h>
|
||||||
|
|
||||||
|
#define MAX_HANDLERS 64
|
||||||
|
|
||||||
|
extern volatile rt_uint8_t rt_interrupt_nest;
|
||||||
|
|
||||||
|
/* exception and interrupt handler table */
|
||||||
|
struct rt_irq_desc isr_table[MAX_HANDLERS];
|
||||||
|
|
||||||
|
rt_uint32_t rt_interrupt_from_thread;
|
||||||
|
rt_uint32_t rt_interrupt_to_thread;
|
||||||
|
rt_uint32_t rt_thread_switch_interrupt_flag;
|
||||||
|
|
||||||
|
extern int system_vectors;
|
||||||
|
|
||||||
|
static void default_isr_handler(int vector, void *param)
|
||||||
|
{
|
||||||
|
rt_kprintf("unhandled irq: %d\n", vector);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function will initialize hardware interrupt
|
||||||
|
*/
|
||||||
|
void rt_hw_interrupt_init(void)
|
||||||
|
{
|
||||||
|
uint32_t index;
|
||||||
|
|
||||||
|
/* mask all of interrupts */
|
||||||
|
IRQ_DISABLE_BASIC = 0x000000ff;
|
||||||
|
IRQ_DISABLE1 = 0xffffffff;
|
||||||
|
IRQ_DISABLE2 = 0xffffffff;
|
||||||
|
|
||||||
|
for (index = 0; index < MAX_HANDLERS; index ++)
|
||||||
|
{
|
||||||
|
isr_table[index].handler = default_isr_handler;
|
||||||
|
isr_table[index].param = NULL;
|
||||||
|
#ifdef RT_USING_INTERRUPT_INFO
|
||||||
|
rt_strncpy(isr_table[index].name, "unknown", RT_NAME_MAX);
|
||||||
|
isr_table[index].counter = 0;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 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 < 8)
|
||||||
|
{
|
||||||
|
IRQ_DISABLE_BASIC = (1 << vector);
|
||||||
|
}
|
||||||
|
else if (vector < 32)
|
||||||
|
{
|
||||||
|
IRQ_DISABLE1 = (1 << vector);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vector = vector % 32;
|
||||||
|
IRQ_DISABLE2 = (1 << vector);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function will un-mask a interrupt.
|
||||||
|
* @param vector the interrupt number
|
||||||
|
*/
|
||||||
|
void rt_hw_interrupt_umask(int vector)
|
||||||
|
{
|
||||||
|
if (vector < 8)
|
||||||
|
{
|
||||||
|
IRQ_ENABLE_BASIC = (1 << vector);
|
||||||
|
}
|
||||||
|
else if (vector < 32)
|
||||||
|
{
|
||||||
|
IRQ_ENABLE1 = (1 << vector);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
vector = vector % 32;
|
||||||
|
IRQ_ENABLE2 = (1 << 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, char *name)
|
||||||
|
{
|
||||||
|
rt_isr_handler_t old_handler = RT_NULL;
|
||||||
|
|
||||||
|
if (vector < MAX_HANDLERS)
|
||||||
|
{
|
||||||
|
old_handler = isr_table[vector].handler;
|
||||||
|
|
||||||
|
if (handler != RT_NULL)
|
||||||
|
{
|
||||||
|
#ifdef RT_USING_INTERRUPT_INFO
|
||||||
|
rt_strncpy(isr_table[vector].name, name, RT_NAME_MAX);
|
||||||
|
#endif /* RT_USING_INTERRUPT_INFO */
|
||||||
|
isr_table[vector].handler = handler;
|
||||||
|
isr_table[vector].param = param;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return old_handler;
|
||||||
|
}
|
207
bsp/raspi2/cpu/mmu.c
Normal file
207
bsp/raspi2/cpu/mmu.c
Normal file
@ -0,0 +1,207 @@
|
|||||||
|
/*
|
||||||
|
* File : mmu.c
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2006, RT-Thread Development Team
|
||||||
|
*
|
||||||
|
* The license and distribution terms for this file may be
|
||||||
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://www.rt-thread.org/license/LICENSE
|
||||||
|
*
|
||||||
|
* Change Logs:
|
||||||
|
* Date Author Notes
|
||||||
|
* 2012-01-10 bernard porting to AM1808
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <rtthread.h>
|
||||||
|
#include <rthw.h>
|
||||||
|
#include <board.h>
|
||||||
|
|
||||||
|
#include "cp15.h"
|
||||||
|
|
||||||
|
#define DESC_SEC (0x2)
|
||||||
|
#define CB (3<<2) //cache_on, write_back
|
||||||
|
#define CNB (2<<2) //cache_on, write_through
|
||||||
|
#define NCB (1<<2) //cache_off,WR_BUF on
|
||||||
|
#define NCNB (0<<2) //cache_off,WR_BUF off
|
||||||
|
#define AP_RW (3<<10) //supervisor=RW, user=RW
|
||||||
|
#define AP_RO (2<<10) //supervisor=RW, user=RO
|
||||||
|
#define XN (1<<4) // eXecute Never
|
||||||
|
|
||||||
|
#define DOMAIN_FAULT (0x0)
|
||||||
|
#define DOMAIN_CHK (0x1)
|
||||||
|
#define DOMAIN_NOTCHK (0x3)
|
||||||
|
#define DOMAIN0 (0x0<<5)
|
||||||
|
#define DOMAIN1 (0x1<<5)
|
||||||
|
|
||||||
|
#define DOMAIN0_ATTR (DOMAIN_CHK<<0)
|
||||||
|
#define DOMAIN1_ATTR (DOMAIN_FAULT<<2)
|
||||||
|
|
||||||
|
/* Read/Write, cache, write back */
|
||||||
|
#define RW_CB (AP_RW|DOMAIN0|CB|DESC_SEC)
|
||||||
|
/* Read/Write, cache, write through */
|
||||||
|
#define RW_CNB (AP_RW|DOMAIN0|CNB|DESC_SEC)
|
||||||
|
/* Read/Write without cache and write buffer */
|
||||||
|
#define RW_NCNB (AP_RW|DOMAIN0|NCNB|DESC_SEC)
|
||||||
|
/* Read/Write without cache and write buffer, no execute */
|
||||||
|
#define RW_NCNBXN (AP_RW|DOMAIN0|NCNB|DESC_SEC|XN)
|
||||||
|
/* Read/Write without cache and write buffer */
|
||||||
|
#define RW_FAULT (AP_RW|DOMAIN1|NCNB|DESC_SEC)
|
||||||
|
|
||||||
|
/* dump 2nd level page table */
|
||||||
|
void rt_hw_cpu_dump_page_table_2nd(rt_uint32_t *ptb)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int fcnt = 0;
|
||||||
|
|
||||||
|
for (i = 0; i < 256; i++)
|
||||||
|
{
|
||||||
|
rt_uint32_t pte2 = ptb[i];
|
||||||
|
if ((pte2 & 0x3) == 0)
|
||||||
|
{
|
||||||
|
if (fcnt == 0)
|
||||||
|
rt_kprintf(" ");
|
||||||
|
rt_kprintf("%04x: ", i);
|
||||||
|
fcnt++;
|
||||||
|
if (fcnt == 16)
|
||||||
|
{
|
||||||
|
rt_kprintf("fault\n");
|
||||||
|
fcnt = 0;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (fcnt != 0)
|
||||||
|
{
|
||||||
|
rt_kprintf("fault\n");
|
||||||
|
fcnt = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
rt_kprintf(" %04x: %x: ", i, pte2);
|
||||||
|
if ((pte2 & 0x3) == 0x1)
|
||||||
|
{
|
||||||
|
rt_kprintf("L,ap:%x,xn:%d,texcb:%02x\n",
|
||||||
|
((pte2 >> 7) | (pte2 >> 4))& 0xf,
|
||||||
|
(pte2 >> 15) & 0x1,
|
||||||
|
((pte2 >> 10) | (pte2 >> 2)) & 0x1f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rt_kprintf("S,ap:%x,xn:%d,texcb:%02x\n",
|
||||||
|
((pte2 >> 7) | (pte2 >> 4))& 0xf, pte2 & 0x1,
|
||||||
|
((pte2 >> 4) | (pte2 >> 2)) & 0x1f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void rt_hw_cpu_dump_page_table(rt_uint32_t *ptb)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
int fcnt = 0;
|
||||||
|
|
||||||
|
rt_kprintf("page table@%p\n", ptb);
|
||||||
|
for (i = 0; i < 1024*4; i++)
|
||||||
|
{
|
||||||
|
rt_uint32_t pte1 = ptb[i];
|
||||||
|
if ((pte1 & 0x3) == 0)
|
||||||
|
{
|
||||||
|
rt_kprintf("%03x: ", i);
|
||||||
|
fcnt++;
|
||||||
|
if (fcnt == 16)
|
||||||
|
{
|
||||||
|
rt_kprintf("fault\n");
|
||||||
|
fcnt = 0;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (fcnt != 0)
|
||||||
|
{
|
||||||
|
rt_kprintf("fault\n");
|
||||||
|
fcnt = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
rt_kprintf("%03x: %08x: ", i, pte1);
|
||||||
|
if ((pte1 & 0x3) == 0x3)
|
||||||
|
{
|
||||||
|
rt_kprintf("LPAE\n");
|
||||||
|
}
|
||||||
|
else if ((pte1 & 0x3) == 0x1)
|
||||||
|
{
|
||||||
|
rt_kprintf("pte,ns:%d,domain:%d\n",
|
||||||
|
(pte1 >> 3) & 0x1, (pte1 >> 5) & 0xf);
|
||||||
|
/*
|
||||||
|
*rt_hw_cpu_dump_page_table_2nd((void*)((pte1 & 0xfffffc000)
|
||||||
|
* - 0x80000000 + 0xC0000000));
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
else if (pte1 & (1 << 18))
|
||||||
|
{
|
||||||
|
rt_kprintf("super section,ns:%d,ap:%x,xn:%d,texcb:%02x\n",
|
||||||
|
(pte1 >> 19) & 0x1,
|
||||||
|
((pte1 >> 13) | (pte1 >> 10))& 0xf,
|
||||||
|
(pte1 >> 4) & 0x1,
|
||||||
|
((pte1 >> 10) | (pte1 >> 2)) & 0x1f);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
rt_kprintf("section,ns:%d,ap:%x,"
|
||||||
|
"xn:%d,texcb:%02x,domain:%d\n",
|
||||||
|
(pte1 >> 19) & 0x1,
|
||||||
|
((pte1 >> 13) | (pte1 >> 10))& 0xf,
|
||||||
|
(pte1 >> 4) & 0x1,
|
||||||
|
(((pte1 & (0x7 << 12)) >> 10) |
|
||||||
|
((pte1 & 0x0c) >> 2)) & 0x1f,
|
||||||
|
(pte1 >> 5) & 0xf);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* level1 page table, each entry for 1MB memory. */
|
||||||
|
volatile static unsigned long MMUTable[4*1024] __attribute__((aligned(16*1024)));
|
||||||
|
void rt_hw_mmu_setmtt(rt_uint32_t vaddrStart,
|
||||||
|
rt_uint32_t vaddrEnd,
|
||||||
|
rt_uint32_t paddrStart,
|
||||||
|
rt_uint32_t attr)
|
||||||
|
{
|
||||||
|
volatile rt_uint32_t *pTT;
|
||||||
|
volatile int i, nSec;
|
||||||
|
pTT = (rt_uint32_t *)MMUTable + (vaddrStart >> 20);
|
||||||
|
nSec = (vaddrEnd >> 20) - (vaddrStart >> 20);
|
||||||
|
for(i = 0; i <= nSec; i++)
|
||||||
|
{
|
||||||
|
*pTT = attr | (((paddrStart >> 20) + i) << 20);
|
||||||
|
pTT++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned long rt_hw_set_domain_register(unsigned long domain_val)
|
||||||
|
{
|
||||||
|
unsigned long old_domain;
|
||||||
|
|
||||||
|
asm volatile ("mrc p15, 0, %0, c3, c0\n" : "=r" (old_domain));
|
||||||
|
asm volatile ("mcr p15, 0, %0, c3, c0\n" : :"r" (domain_val) : "memory");
|
||||||
|
|
||||||
|
return old_domain;
|
||||||
|
}
|
||||||
|
|
||||||
|
void rt_hw_mmu_init(void)
|
||||||
|
{
|
||||||
|
rt_hw_cpu_dcache_disable();
|
||||||
|
rt_hw_cpu_icache_disable();
|
||||||
|
rt_cpu_mmu_disable();
|
||||||
|
|
||||||
|
/* set page table */
|
||||||
|
/* 4G 1:1 memory */
|
||||||
|
rt_hw_mmu_setmtt(0, 0xffffffff-1, 0, RW_CB);
|
||||||
|
/* IO memory region */
|
||||||
|
rt_hw_mmu_setmtt(0x44000000, 0x80000000-1, 0x44000000, RW_NCNBXN);
|
||||||
|
|
||||||
|
/*rt_hw_cpu_dump_page_table(MMUTable);*/
|
||||||
|
rt_hw_set_domain_register(0x55555555);
|
||||||
|
|
||||||
|
rt_cpu_tlb_set(MMUTable);
|
||||||
|
|
||||||
|
rt_cpu_mmu_enable();
|
||||||
|
|
||||||
|
rt_hw_cpu_icache_enable();
|
||||||
|
rt_hw_cpu_dcache_enable();
|
||||||
|
}
|
||||||
|
|
68
bsp/raspi2/cpu/stack.c
Normal file
68
bsp/raspi2/cpu/stack.c
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
/*
|
||||||
|
* File : stack.c
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2011, RT-Thread Development Team
|
||||||
|
*
|
||||||
|
* The license and distribution terms for this file may be
|
||||||
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://www.rt-thread.org/license/LICENSE
|
||||||
|
*
|
||||||
|
* Change Logs:
|
||||||
|
* Date Author Notes
|
||||||
|
* 2011-09-23 Bernard the first version
|
||||||
|
* 2011-10-05 Bernard add thumb mode
|
||||||
|
*/
|
||||||
|
#include <rtthread.h>
|
||||||
|
#include <board.h>
|
||||||
|
#include <armv7.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup AM33xx
|
||||||
|
*/
|
||||||
|
/*@{*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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)
|
||||||
|
{
|
||||||
|
rt_uint32_t *stk;
|
||||||
|
|
||||||
|
stack_addr += sizeof(rt_uint32_t);
|
||||||
|
stack_addr = (rt_uint8_t *)RT_ALIGN_DOWN((rt_uint32_t)stack_addr, 8);
|
||||||
|
stk = (rt_uint32_t *)stack_addr;
|
||||||
|
*(--stk) = (rt_uint32_t)tentry; /* entry point */
|
||||||
|
*(--stk) = (rt_uint32_t)texit; /* lr */
|
||||||
|
*(--stk) = 0xdeadbeef; /* r12 */
|
||||||
|
*(--stk) = 0xdeadbeef; /* r11 */
|
||||||
|
*(--stk) = 0xdeadbeef; /* r10 */
|
||||||
|
*(--stk) = 0xdeadbeef; /* r9 */
|
||||||
|
*(--stk) = 0xdeadbeef; /* r8 */
|
||||||
|
*(--stk) = 0xdeadbeef; /* r7 */
|
||||||
|
*(--stk) = 0xdeadbeef; /* r6 */
|
||||||
|
*(--stk) = 0xdeadbeef; /* r5 */
|
||||||
|
*(--stk) = 0xdeadbeef; /* r4 */
|
||||||
|
*(--stk) = 0xdeadbeef; /* r3 */
|
||||||
|
*(--stk) = 0xdeadbeef; /* r2 */
|
||||||
|
*(--stk) = 0xdeadbeef; /* r1 */
|
||||||
|
*(--stk) = (rt_uint32_t)parameter; /* r0 : argument */
|
||||||
|
|
||||||
|
/* cpsr */
|
||||||
|
if ((rt_uint32_t)tentry & 0x01)
|
||||||
|
*(--stk) = SVCMODE | 0x20; /* thumb mode */
|
||||||
|
else
|
||||||
|
*(--stk) = SVCMODE; /* arm mode */
|
||||||
|
|
||||||
|
/* return task's current stack address */
|
||||||
|
return (rt_uint8_t *)stk;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*@}*/
|
279
bsp/raspi2/cpu/start_gcc.S
Normal file
279
bsp/raspi2/cpu/start_gcc.S
Normal file
@ -0,0 +1,279 @@
|
|||||||
|
/*
|
||||||
|
* File : start_gcc.S
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2013-2014, 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
|
||||||
|
* 2013-07-05 Bernard the first version
|
||||||
|
*/
|
||||||
|
|
||||||
|
.equ Mode_USR, 0x10
|
||||||
|
.equ Mode_FIQ, 0x11
|
||||||
|
.equ Mode_IRQ, 0x12
|
||||||
|
.equ Mode_SVC, 0x13
|
||||||
|
.equ Mode_ABT, 0x17
|
||||||
|
.equ Mode_UND, 0x1B
|
||||||
|
.equ Mode_SYS, 0x1F
|
||||||
|
|
||||||
|
.equ I_Bit, 0x80 @ when I bit is set, IRQ is disabled
|
||||||
|
.equ F_Bit, 0x40 @ when F bit is set, FIQ is disabled
|
||||||
|
|
||||||
|
.equ UND_Stack_Size, 0x00000000
|
||||||
|
.equ SVC_Stack_Size, 0x00000100
|
||||||
|
.equ ABT_Stack_Size, 0x00000000
|
||||||
|
.equ RT_FIQ_STACK_PGSZ, 0x00000000
|
||||||
|
.equ RT_IRQ_STACK_PGSZ, 0x00000100
|
||||||
|
.equ USR_Stack_Size, 0x00000100
|
||||||
|
|
||||||
|
#define ISR_Stack_Size (UND_Stack_Size + SVC_Stack_Size + ABT_Stack_Size + \
|
||||||
|
RT_FIQ_STACK_PGSZ + RT_IRQ_STACK_PGSZ)
|
||||||
|
|
||||||
|
.section .data.share.isr
|
||||||
|
/* stack */
|
||||||
|
.globl stack_start
|
||||||
|
.globl stack_top
|
||||||
|
|
||||||
|
stack_start:
|
||||||
|
.rept ISR_Stack_Size
|
||||||
|
.byte 0
|
||||||
|
.endr
|
||||||
|
stack_top:
|
||||||
|
|
||||||
|
.text
|
||||||
|
/* reset entry */
|
||||||
|
.globl _reset
|
||||||
|
_reset:
|
||||||
|
/* Disable IRQ & FIQ */
|
||||||
|
cpsid if
|
||||||
|
|
||||||
|
/* Check for HYP mode */
|
||||||
|
mrs r0, cpsr_all
|
||||||
|
and r0, r0, #0x1F
|
||||||
|
mov r8, #0x1A
|
||||||
|
cmp r0, r8
|
||||||
|
beq overHyped
|
||||||
|
b continue
|
||||||
|
|
||||||
|
overHyped: /* Get out of HYP mode */
|
||||||
|
ldr r1, =continue
|
||||||
|
msr ELR_hyp, r1
|
||||||
|
mrs r1, cpsr_all
|
||||||
|
and r1, r1, #0x1f ;@ CPSR_MODE_MASK
|
||||||
|
orr r1, r1, #0x13 ;@ CPSR_MODE_SUPERVISOR
|
||||||
|
msr SPSR_hyp, r1
|
||||||
|
eret
|
||||||
|
|
||||||
|
continue:
|
||||||
|
|
||||||
|
/* disable smp */
|
||||||
|
bl arm_smp_disable
|
||||||
|
|
||||||
|
/* disable mmu */
|
||||||
|
bl rt_cpu_mmu_disable
|
||||||
|
/* set the cpu to SVC32 mode and disable interrupt */
|
||||||
|
mrs r0, cpsr
|
||||||
|
bic r0, r0, #0x1f
|
||||||
|
orr r0, r0, #0x13
|
||||||
|
msr cpsr_c, r0
|
||||||
|
|
||||||
|
/* setup stack */
|
||||||
|
bl stack_setup
|
||||||
|
|
||||||
|
/* clear .bss */
|
||||||
|
mov r0,#0 /* get a zero */
|
||||||
|
ldr r1,=__bss_start /* bss start */
|
||||||
|
ldr r2,=__bss_end /* bss end */
|
||||||
|
|
||||||
|
bss_loop:
|
||||||
|
cmp r1,r2 /* check if data to clear */
|
||||||
|
strlo r0,[r1],#4 /* clear 4 bytes */
|
||||||
|
blo bss_loop /* loop until done */
|
||||||
|
|
||||||
|
/* start RT-Thread Kernel */
|
||||||
|
ldr pc, _rtthread_startup
|
||||||
|
_rtthread_startup:
|
||||||
|
.word rtthread_startup
|
||||||
|
|
||||||
|
stack_setup:
|
||||||
|
ldr r0, =stack_top
|
||||||
|
|
||||||
|
@ Set the startup stack for svc
|
||||||
|
mov sp, r0
|
||||||
|
sub r0, r0, #SVC_Stack_Size
|
||||||
|
|
||||||
|
@ Enter Undefined Instruction Mode and set its Stack Pointer
|
||||||
|
msr cpsr_c, #Mode_UND|I_Bit|F_Bit
|
||||||
|
mov sp, r0
|
||||||
|
sub r0, r0, #UND_Stack_Size
|
||||||
|
|
||||||
|
@ Enter Abort Mode and set its Stack Pointer
|
||||||
|
msr cpsr_c, #Mode_ABT|I_Bit|F_Bit
|
||||||
|
mov sp, r0
|
||||||
|
sub r0, r0, #ABT_Stack_Size
|
||||||
|
|
||||||
|
@ Enter FIQ Mode and set its Stack Pointer
|
||||||
|
msr cpsr_c, #Mode_FIQ|I_Bit|F_Bit
|
||||||
|
mov sp, r0
|
||||||
|
sub r0, r0, #RT_FIQ_STACK_PGSZ
|
||||||
|
|
||||||
|
@ Enter IRQ Mode and set its Stack Pointer
|
||||||
|
msr cpsr_c, #Mode_IRQ|I_Bit|F_Bit
|
||||||
|
mov sp, r0
|
||||||
|
sub r0, r0, #RT_IRQ_STACK_PGSZ
|
||||||
|
|
||||||
|
/* come back to SVC mode */
|
||||||
|
msr cpsr_c, #Mode_SVC|I_Bit|F_Bit
|
||||||
|
bx lr
|
||||||
|
|
||||||
|
.text
|
||||||
|
;@ void arm_smp_enable(void);
|
||||||
|
.globl arm_smp_enable
|
||||||
|
arm_smp_enable:
|
||||||
|
mrc p15, 0, r0, c1, c0, 1 ;@ set SMP bit in ACTLR
|
||||||
|
orr r0, r0, #0x40
|
||||||
|
mcr p15, 0, r0, c1, c0, 1
|
||||||
|
bx lr
|
||||||
|
|
||||||
|
.text
|
||||||
|
;@ void arm_smp_disable(void);
|
||||||
|
.globl arm_smp_disable
|
||||||
|
arm_smp_disable:
|
||||||
|
mrc p15, 0, r0, c1, c0, 1 ;@ clear SMP bit in ACTLR
|
||||||
|
bic r0, r0, #0x40
|
||||||
|
mcr p15, 0, r0, c1, c0, 1
|
||||||
|
bx lr
|
||||||
|
|
||||||
|
/* exception handlers: undef, swi, padt, dabt, resv, irq, fiq */
|
||||||
|
.section .text.isr, "ax"
|
||||||
|
.align 5
|
||||||
|
.globl vector_fiq
|
||||||
|
vector_fiq:
|
||||||
|
stmfd sp!,{r0-r7,lr}
|
||||||
|
bl rt_hw_trap_fiq
|
||||||
|
ldmfd sp!,{r0-r7,lr}
|
||||||
|
subs pc, lr, #4
|
||||||
|
|
||||||
|
.globl rt_interrupt_enter
|
||||||
|
.globl rt_interrupt_leave
|
||||||
|
.globl rt_thread_switch_interrupt_flag
|
||||||
|
.globl rt_interrupt_from_thread
|
||||||
|
.globl rt_interrupt_to_thread
|
||||||
|
|
||||||
|
.globl rt_current_thread
|
||||||
|
.globl vmm_thread
|
||||||
|
.globl vmm_virq_check
|
||||||
|
|
||||||
|
.align 5
|
||||||
|
.globl vector_irq
|
||||||
|
vector_irq:
|
||||||
|
stmfd sp!, {r0-r12,lr}
|
||||||
|
|
||||||
|
bl rt_interrupt_enter
|
||||||
|
bl rt_hw_trap_irq
|
||||||
|
bl rt_interrupt_leave
|
||||||
|
|
||||||
|
@ if rt_thread_switch_interrupt_flag set, jump to
|
||||||
|
@ rt_hw_context_switch_interrupt_do and don't return
|
||||||
|
ldr r0, =rt_thread_switch_interrupt_flag
|
||||||
|
ldr r1, [r0]
|
||||||
|
cmp r1, #1
|
||||||
|
beq rt_hw_context_switch_interrupt_do
|
||||||
|
|
||||||
|
ldmfd sp!, {r0-r12,lr}
|
||||||
|
subs pc, lr, #4
|
||||||
|
|
||||||
|
rt_hw_context_switch_interrupt_do:
|
||||||
|
mov r1, #0 @ clear flag
|
||||||
|
str r1, [r0]
|
||||||
|
|
||||||
|
mov r1, sp @ r1 point to {r0-r3} in stack
|
||||||
|
add sp, sp, #4*4
|
||||||
|
ldmfd sp!, {r4-r12,lr}@ reload saved registers
|
||||||
|
mrs r0, spsr @ get cpsr of interrupt thread
|
||||||
|
sub r2, lr, #4 @ save old task's pc to r2
|
||||||
|
|
||||||
|
@ Switch to SVC mode with no interrupt. If the usr mode guest is
|
||||||
|
@ interrupted, this will just switch to the stack of kernel space.
|
||||||
|
@ save the registers in kernel space won't trigger data abort.
|
||||||
|
msr cpsr_c, #I_Bit|F_Bit|Mode_SVC
|
||||||
|
|
||||||
|
stmfd sp!, {r2} @ push old task's pc
|
||||||
|
stmfd sp!, {r4-r12,lr}@ push old task's lr,r12-r4
|
||||||
|
ldmfd r1, {r1-r4} @ restore r0-r3 of the interrupt thread
|
||||||
|
stmfd sp!, {r1-r4} @ push old task's r0-r3
|
||||||
|
stmfd sp!, {r0} @ push old task's cpsr
|
||||||
|
|
||||||
|
ldr r4, =rt_interrupt_from_thread
|
||||||
|
ldr r5, [r4]
|
||||||
|
str sp, [r5] @ store sp in preempted tasks's TCB
|
||||||
|
|
||||||
|
ldr r6, =rt_interrupt_to_thread
|
||||||
|
ldr r6, [r6]
|
||||||
|
ldr sp, [r6] @ get new task's stack pointer
|
||||||
|
|
||||||
|
ldmfd sp!, {r4} @ pop new task's cpsr to spsr
|
||||||
|
msr spsr_cxsf, r4
|
||||||
|
|
||||||
|
ldmfd sp!, {r0-r12,lr,pc}^ @ pop new task's r0-r12,lr & pc, copy spsr to cpsr
|
||||||
|
|
||||||
|
.macro push_svc_reg
|
||||||
|
sub sp, sp, #17 * 4 @/* Sizeof(struct rt_hw_exp_stack) */
|
||||||
|
stmia sp, {r0 - r12} @/* Calling r0-r12 */
|
||||||
|
mov r0, sp
|
||||||
|
mrs r6, spsr @/* Save CPSR */
|
||||||
|
str lr, [r0, #15*4] @/* Push PC */
|
||||||
|
str r6, [r0, #16*4] @/* Push CPSR */
|
||||||
|
cps #Mode_SVC
|
||||||
|
str sp, [r0, #13*4] @/* Save calling SP */
|
||||||
|
str lr, [r0, #14*4] @/* Save calling PC */
|
||||||
|
.endm
|
||||||
|
|
||||||
|
.align 5
|
||||||
|
.globl vector_swi
|
||||||
|
vector_swi:
|
||||||
|
push_svc_reg
|
||||||
|
bl rt_hw_trap_swi
|
||||||
|
b .
|
||||||
|
|
||||||
|
.align 5
|
||||||
|
.globl vector_undef
|
||||||
|
vector_undef:
|
||||||
|
push_svc_reg
|
||||||
|
bl rt_hw_trap_undef
|
||||||
|
b .
|
||||||
|
|
||||||
|
.align 5
|
||||||
|
.globl vector_pabt
|
||||||
|
vector_pabt:
|
||||||
|
push_svc_reg
|
||||||
|
bl rt_hw_trap_pabt
|
||||||
|
b .
|
||||||
|
|
||||||
|
.align 5
|
||||||
|
.globl vector_dabt
|
||||||
|
vector_dabt:
|
||||||
|
push_svc_reg
|
||||||
|
bl rt_hw_trap_dabt
|
||||||
|
b .
|
||||||
|
|
||||||
|
.align 5
|
||||||
|
.globl vector_resv
|
||||||
|
vector_resv:
|
||||||
|
push_svc_reg
|
||||||
|
bl rt_hw_trap_resv
|
||||||
|
b .
|
183
bsp/raspi2/cpu/trap.c
Normal file
183
bsp/raspi2/cpu/trap.c
Normal file
@ -0,0 +1,183 @@
|
|||||||
|
/*
|
||||||
|
* File : trap.c
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2013, RT-Thread Develop Team
|
||||||
|
*
|
||||||
|
* The license and distribution terms for this file may be
|
||||||
|
* found in the file LICENSE in this distribution or at
|
||||||
|
* http://www.rt-thread.org/license/LICENSE
|
||||||
|
*
|
||||||
|
* Change Logs:
|
||||||
|
* Date Author Notes
|
||||||
|
* 2013-07-20 Bernard first version
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <rthw.h>
|
||||||
|
#include <board.h>
|
||||||
|
#include <rtthread.h>
|
||||||
|
|
||||||
|
#include "armv7.h"
|
||||||
|
|
||||||
|
extern struct rt_thread *rt_current_thread;
|
||||||
|
#ifdef RT_USING_FINSH
|
||||||
|
extern long list_thread(void);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this function will show registers of CPU
|
||||||
|
*
|
||||||
|
* @param regs the registers point
|
||||||
|
*/
|
||||||
|
void rt_hw_show_register(struct rt_hw_exp_stack *regs)
|
||||||
|
{
|
||||||
|
rt_kprintf("Execption:\n");
|
||||||
|
rt_kprintf("r00:0x%08x r01:0x%08x r02:0x%08x r03:0x%08x\n", regs->r0, regs->r1, regs->r2, regs->r3);
|
||||||
|
rt_kprintf("r04:0x%08x r05:0x%08x r06:0x%08x r07:0x%08x\n", regs->r4, regs->r5, regs->r6, regs->r7);
|
||||||
|
rt_kprintf("r08:0x%08x r09:0x%08x r10:0x%08x\n", regs->r8, regs->r9, regs->r10);
|
||||||
|
rt_kprintf("fp :0x%08x ip :0x%08x\n", regs->fp, regs->ip);
|
||||||
|
rt_kprintf("sp :0x%08x lr :0x%08x pc :0x%08x\n", regs->sp, regs->lr, regs->pc);
|
||||||
|
rt_kprintf("cpsr:0x%08x\n", regs->cpsr);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* When comes across an instruction which it cannot handle,
|
||||||
|
* it takes the undefined instruction trap.
|
||||||
|
*
|
||||||
|
* @param regs system registers
|
||||||
|
*
|
||||||
|
* @note never invoke this function in application
|
||||||
|
*/
|
||||||
|
void rt_hw_trap_undef(struct rt_hw_exp_stack *regs)
|
||||||
|
{
|
||||||
|
rt_kprintf("undefined instruction:\n");
|
||||||
|
rt_hw_show_register(regs);
|
||||||
|
#ifdef RT_USING_FINSH
|
||||||
|
list_thread();
|
||||||
|
#endif
|
||||||
|
rt_hw_cpu_shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The software interrupt instruction (SWI) is used for entering
|
||||||
|
* Supervisor mode, usually to request a particular supervisor
|
||||||
|
* function.
|
||||||
|
*
|
||||||
|
* @param regs system registers
|
||||||
|
*
|
||||||
|
* @note never invoke this function in application
|
||||||
|
*/
|
||||||
|
void rt_hw_trap_swi(struct rt_hw_exp_stack *regs)
|
||||||
|
{
|
||||||
|
rt_kprintf("software interrupt:\n");
|
||||||
|
rt_hw_show_register(regs);
|
||||||
|
#ifdef RT_USING_FINSH
|
||||||
|
list_thread();
|
||||||
|
#endif
|
||||||
|
rt_hw_cpu_shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An abort indicates that the current memory access cannot be completed,
|
||||||
|
* which occurs during an instruction prefetch.
|
||||||
|
*
|
||||||
|
* @param regs system registers
|
||||||
|
*
|
||||||
|
* @note never invoke this function in application
|
||||||
|
*/
|
||||||
|
void rt_hw_trap_pabt(struct rt_hw_exp_stack *regs)
|
||||||
|
{
|
||||||
|
rt_kprintf("prefetch abort:\n");
|
||||||
|
rt_hw_show_register(regs);
|
||||||
|
#ifdef RT_USING_FINSH
|
||||||
|
list_thread();
|
||||||
|
#endif
|
||||||
|
rt_hw_cpu_shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An abort indicates that the current memory access cannot be completed,
|
||||||
|
* which occurs during a data access.
|
||||||
|
*
|
||||||
|
* @param regs system registers
|
||||||
|
*
|
||||||
|
* @note never invoke this function in application
|
||||||
|
*/
|
||||||
|
void rt_hw_trap_dabt(struct rt_hw_exp_stack *regs)
|
||||||
|
{
|
||||||
|
rt_kprintf("data abort:");
|
||||||
|
rt_hw_show_register(regs);
|
||||||
|
#ifdef RT_USING_FINSH
|
||||||
|
list_thread();
|
||||||
|
#endif
|
||||||
|
rt_hw_cpu_shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normally, system will never reach here
|
||||||
|
*
|
||||||
|
* @param regs system registers
|
||||||
|
*
|
||||||
|
* @note never invoke this function in application
|
||||||
|
*/
|
||||||
|
void rt_hw_trap_resv(struct rt_hw_exp_stack *regs)
|
||||||
|
{
|
||||||
|
rt_kprintf("reserved trap:\n");
|
||||||
|
rt_hw_show_register(regs);
|
||||||
|
#ifdef RT_USING_FINSH
|
||||||
|
list_thread();
|
||||||
|
#endif
|
||||||
|
rt_hw_cpu_shutdown();
|
||||||
|
}
|
||||||
|
|
||||||
|
void rt_hw_trap_irq(void)
|
||||||
|
{
|
||||||
|
void *param;
|
||||||
|
rt_isr_handler_t isr_func;
|
||||||
|
extern struct rt_irq_desc isr_table[];
|
||||||
|
|
||||||
|
uint32_t value = 0;
|
||||||
|
|
||||||
|
// rt_kprintf("pend basic: 0x%08x\n", IRQ_PEND_BASIC);
|
||||||
|
// rt_kprintf(" pend1: 0x%08x\n", IRQ_PEND1);
|
||||||
|
// rt_kprintf(" pend2: 0x%08x\n", IRQ_PEND2);
|
||||||
|
|
||||||
|
value = IRQ_PEND_BASIC & 0x3ff;
|
||||||
|
if (value)
|
||||||
|
{
|
||||||
|
uint32_t irq;
|
||||||
|
|
||||||
|
if (value & (1 << 8))
|
||||||
|
{
|
||||||
|
value = IRQ_PEND1;
|
||||||
|
irq = __rt_ffs(value) - 1;
|
||||||
|
}
|
||||||
|
else if (value & (1 << 9))
|
||||||
|
{
|
||||||
|
value = IRQ_PEND2;
|
||||||
|
irq = __rt_ffs(value) + 31;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
value &= 0x0f;
|
||||||
|
irq = __rt_ffs(value) - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* get interrupt service routine */
|
||||||
|
isr_func = isr_table[irq].handler;
|
||||||
|
#ifdef RT_USING_INTERRUPT_INFO
|
||||||
|
isr_table[irq].counter++;
|
||||||
|
#endif
|
||||||
|
if (isr_func)
|
||||||
|
{
|
||||||
|
/* Interrupt for myself. */
|
||||||
|
param = isr_table[irq].param;
|
||||||
|
/* turn to interrupt service routine */
|
||||||
|
isr_func(irq, param);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void rt_hw_trap_fiq(void)
|
||||||
|
{
|
||||||
|
/* TODO */
|
||||||
|
}
|
65
bsp/raspi2/cpu/vector_gcc.S
Normal file
65
bsp/raspi2/cpu/vector_gcc.S
Normal file
@ -0,0 +1,65 @@
|
|||||||
|
/*
|
||||||
|
* File : vector_gcc.S
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2013, 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
|
||||||
|
* 2013-07-05 Bernard the first version
|
||||||
|
*/
|
||||||
|
|
||||||
|
.section .vectors, "ax"
|
||||||
|
.code 32
|
||||||
|
|
||||||
|
.globl system_vectors
|
||||||
|
system_vectors:
|
||||||
|
ldr pc, _vector_reset
|
||||||
|
ldr pc, _vector_undef
|
||||||
|
ldr pc, _vector_swi
|
||||||
|
ldr pc, _vector_pabt
|
||||||
|
ldr pc, _vector_dabt
|
||||||
|
ldr pc, _vector_resv
|
||||||
|
ldr pc, _vector_irq
|
||||||
|
ldr pc, _vector_fiq
|
||||||
|
|
||||||
|
.globl _reset
|
||||||
|
.globl vector_undef
|
||||||
|
.globl vector_swi
|
||||||
|
.globl vector_pabt
|
||||||
|
.globl vector_dabt
|
||||||
|
.globl vector_resv
|
||||||
|
.globl vector_irq
|
||||||
|
.globl vector_fiq
|
||||||
|
|
||||||
|
_vector_reset:
|
||||||
|
.word _reset
|
||||||
|
_vector_undef:
|
||||||
|
.word vector_undef
|
||||||
|
_vector_swi:
|
||||||
|
.word vector_swi
|
||||||
|
_vector_pabt:
|
||||||
|
.word vector_pabt
|
||||||
|
_vector_dabt:
|
||||||
|
.word vector_dabt
|
||||||
|
_vector_resv:
|
||||||
|
.word vector_resv
|
||||||
|
_vector_irq:
|
||||||
|
.word vector_irq
|
||||||
|
_vector_fiq:
|
||||||
|
.word vector_fiq
|
||||||
|
|
||||||
|
.balignl 16,0xdeadbeef
|
3
bsp/raspi2/driver/Kconfig
Normal file
3
bsp/raspi2/driver/Kconfig
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
config RT_USING_UART1
|
||||||
|
bool "Enable UART1"
|
||||||
|
default y
|
17
bsp/raspi2/driver/SConscript
Normal file
17
bsp/raspi2/driver/SConscript
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
# RT-Thread building script for component
|
||||||
|
|
||||||
|
from building import *
|
||||||
|
|
||||||
|
cwd = GetCurrentDir()
|
||||||
|
src = Split('''
|
||||||
|
board.c
|
||||||
|
drv_uart.c
|
||||||
|
''')
|
||||||
|
CPPPATH = [cwd]
|
||||||
|
|
||||||
|
if GetDepend('RT_USING_PIN'):
|
||||||
|
src += ['drv_gpio.c']
|
||||||
|
|
||||||
|
group = DefineGroup('Drivers', src, depend = [''], CPPPATH = CPPPATH)
|
||||||
|
|
||||||
|
Return('group')
|
125
bsp/raspi2/driver/bcm283x.h
Normal file
125
bsp/raspi2/driver/bcm283x.h
Normal file
@ -0,0 +1,125 @@
|
|||||||
|
#ifndef BCM283X_H__
|
||||||
|
#define BCM283X_H__
|
||||||
|
|
||||||
|
#include <rthw.h>
|
||||||
|
|
||||||
|
#define PER_BASE (0x3F000000)
|
||||||
|
#define PER_BASE_40000000 (0x40000000)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* GPIO
|
||||||
|
*/
|
||||||
|
#define GPIO_BASE (PER_BASE + 0x200000)
|
||||||
|
#define GPIO_GPFSEL0 HWREG32(GPIO_BASE + 0x00) /* GPIO Function Select 0 32bit R/W */
|
||||||
|
#define GPIO_GPFSEL1 HWREG32(GPIO_BASE + 0x04) /* GPIO Function Select 1 32bit R/W */
|
||||||
|
#define GPIO_GPFSEL2 HWREG32(GPIO_BASE + 0x08) /* GPIO Function Select 2 32bit R/W */
|
||||||
|
#define GPIO_GPFSEL4 HWREG32(GPIO_BASE + 0x10) /* GPIO Function Select 4 32bit R/W */
|
||||||
|
#define GPIO_GPSET0 HWREG32(GPIO_BASE + 0x1C)
|
||||||
|
#define GPIO_GPCLR0 HWREG32(GPIO_BASE + 0x28)
|
||||||
|
#define GPIO_GPPUD HWREG32(GPIO_BASE + 0x94) /* GPIO Pin Pull-up/down Enable */
|
||||||
|
#define GPIO_GPPUDCLK0 HWREG32(GPIO_BASE + 0x98) /* GPIO Pin Pull-up/down Enable Clock 0 */
|
||||||
|
#define GPIO_GPPUDCLK1 HWREG32(GPIO_BASE + 0x9C) /* GPIO Pin Pull-up/down Enable Clock 1 */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Interrupt Controler
|
||||||
|
*/
|
||||||
|
#define IRQ_BASE (PER_BASE + 0xB200)
|
||||||
|
#define IRQ_PEND_BASIC HWREG32(IRQ_BASE + 0x00)
|
||||||
|
#define IRQ_PEND1 HWREG32(IRQ_BASE + 0x04)
|
||||||
|
#define IRQ_PEND2 HWREG32(IRQ_BASE + 0x08)
|
||||||
|
#define IRQ_FIQ_CONTROL HWREG32(IRQ_BASE + 0x0C)
|
||||||
|
#define IRQ_ENABLE1 HWREG32(IRQ_BASE + 0x10)
|
||||||
|
#define IRQ_ENABLE2 HWREG32(IRQ_BASE + 0x14)
|
||||||
|
#define IRQ_ENABLE_BASIC HWREG32(IRQ_BASE + 0x18)
|
||||||
|
#define IRQ_DISABLE1 HWREG32(IRQ_BASE + 0x1C)
|
||||||
|
#define IRQ_DISABLE2 HWREG32(IRQ_BASE + 0x20)
|
||||||
|
#define IRQ_DISABLE_BASIC HWREG32(IRQ_BASE + 0x24)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* System Timer
|
||||||
|
*/
|
||||||
|
#define STIMER_BASE (PER_BASE + 0x3000)
|
||||||
|
#define STIMER_CS HWREG32(STIMER_BASE + 0x00)
|
||||||
|
#define STIMER_CLO HWREG32(STIMER_BASE + 0x04)
|
||||||
|
#define STIMER_CHI HWREG32(STIMER_BASE + 0x08)
|
||||||
|
#define STIMER_C0 HWREG32(STIMER_BASE + 0x0C)
|
||||||
|
#define STIMER_C1 HWREG32(STIMER_BASE + 0x10)
|
||||||
|
#define STIMER_C2 HWREG32(STIMER_BASE + 0x14)
|
||||||
|
#define STIMER_C3 HWREG32(STIMER_BASE + 0x18)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ARM Timer
|
||||||
|
*/
|
||||||
|
#define ARM_TIMER_BASE (PER_BASE + 0xB000)
|
||||||
|
|
||||||
|
#define ARM_TIMER_LOAD HWREG32(ARM_TIMER_BASE + 0x400)
|
||||||
|
#define ARM_TIMER_VALUE HWREG32(ARM_TIMER_BASE + 0x404)
|
||||||
|
#define ARM_TIMER_CTRL HWREG32(ARM_TIMER_BASE + 0x408)
|
||||||
|
#define ARM_TIMER_IRQCLR HWREG32(ARM_TIMER_BASE + 0x40C)
|
||||||
|
#define ARM_TIMER_RAWIRQ HWREG32(ARM_TIMER_BASE + 0x410)
|
||||||
|
#define ARM_TIMER_MASKIRQ HWREG32(ARM_TIMER_BASE + 0x414)
|
||||||
|
#define ARM_TIMER_RELOAD HWREG32(ARM_TIMER_BASE + 0x418)
|
||||||
|
#define ARM_TIMER_PREDIV HWREG32(ARM_TIMER_BASE + 0x41C)
|
||||||
|
#define ARM_TIMER_CNTR HWREG32(ARM_TIMER_BASE + 0x420)
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Core Timer
|
||||||
|
*/
|
||||||
|
#define CTIMER_CTL HWREG32(PER_BASE_40000000 + 0x00) /* Control register */
|
||||||
|
#define CTIMER_PRE HWREG32(PER_BASE_40000000 + 0x08) /* Core timer prescaler */
|
||||||
|
#define CTIMER_LS32B HWREG32(PER_BASE_40000000 + 0x1C) /* Core timer access LS 32 bits */
|
||||||
|
#define CTIMER_MS32B HWREG32(PER_BASE_40000000 + 0x20) /* Core timer access MS 32 bits */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ARM Core Timer
|
||||||
|
*/
|
||||||
|
#define C0TIMER_INTCTL HWREG32(PER_BASE_40000000 + 0x40) /* Core0 timers Interrupt control */
|
||||||
|
#define C1TIMER_INTCTL HWREG32(PER_BASE_40000000 + 0x44) /* Core1 timers Interrupt control */
|
||||||
|
#define C2TIMER_INTCTL HWREG32(PER_BASE_40000000 + 0x48) /* Core2 timers Interrupt control */
|
||||||
|
#define C3TIMER_INTCTL HWREG32(PER_BASE_40000000 + 0x4C) /* Core3 timers Interrupt control */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ARM Core Mailbox interrupt
|
||||||
|
*/
|
||||||
|
#define C0MB_INTCTL HWREG32(PER_BASE_40000000 + 0x50) /* Core0 Mailboxes Interrupt control */
|
||||||
|
#define C1MB_INTCTL HWREG32(PER_BASE_40000000 + 0x54) /* Core1 Mailboxes Interrupt control */
|
||||||
|
#define C2MB_INTCTL HWREG32(PER_BASE_40000000 + 0x58) /* Core2 Mailboxes Interrupt control */
|
||||||
|
#define C3MB_INTCTL HWREG32(PER_BASE_40000000 + 0x5C) /* Core3 Mailboxes Interrupt control */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* ARM Core IRQ/FIQ status
|
||||||
|
*/
|
||||||
|
#define C0_IRQSOURCE HWREG32(PER_BASE_40000000 + 0x60) /* Core0 IRQ Source */
|
||||||
|
#define C1_IRQSOURCE HWREG32(PER_BASE_40000000 + 0x64) /* Core1 IRQ Source */
|
||||||
|
#define C2_IRQSOURCE HWREG32(PER_BASE_40000000 + 0x68) /* Core2 IRQ Source */
|
||||||
|
#define C3_IRQSOURCE HWREG32(PER_BASE_40000000 + 0x6C) /* Core3 IRQ Source */
|
||||||
|
#define C0_FIQSOURCE HWREG32(PER_BASE_40000000 + 0x70) /* Core0 FIQ Source */
|
||||||
|
#define C1_FIQSOURCE HWREG32(PER_BASE_40000000 + 0x74) /* Core1 FIQ Source */
|
||||||
|
#define C2_FIQSOURCE HWREG32(PER_BASE_40000000 + 0x78) /* Core2 FIQ Source */
|
||||||
|
#define C3_FIQSOURCE HWREG32(PER_BASE_40000000 + 0x7C) /* Core3 FIQ Source */
|
||||||
|
|
||||||
|
#define IRQ_ARM_TIMER 0
|
||||||
|
#define IRQ_ARM_MAILBOX 1
|
||||||
|
#define IRQ_ARM_DB0 2
|
||||||
|
#define IRQ_ARM_DB1 3
|
||||||
|
#define IRQ_ARM_GPU0_HALT 4
|
||||||
|
#define IRQ_ARM_GPU1_HALT 5
|
||||||
|
#define IRQ_ARM_ILLEGAL_ACC1 6
|
||||||
|
#define IRQ_ARM_ILLEGAL_ACC0 7
|
||||||
|
|
||||||
|
#define IRQ_AUX 29
|
||||||
|
#define IRQ_IIC_SPI_SLV 43
|
||||||
|
#define IRQ_PWA0 45
|
||||||
|
#define IRQ_PWA1 46
|
||||||
|
#define IRQ_SMI 48
|
||||||
|
#define IRQ_GPIO0 49
|
||||||
|
#define IRQ_GPIO1 50
|
||||||
|
#define IRQ_GPIO2 51
|
||||||
|
#define IRQ_GPIO3 52
|
||||||
|
#define IRQ_IIC 53
|
||||||
|
#define IRQ_SPI 54
|
||||||
|
#define IRQ_PCM 55
|
||||||
|
#define IRQ_UART 57
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
90
bsp/raspi2/driver/board.c
Normal file
90
bsp/raspi2/driver/board.c
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
/*
|
||||||
|
* File : board.c
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2017, 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
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <rthw.h>
|
||||||
|
#include <rtthread.h>
|
||||||
|
|
||||||
|
#include "board.h"
|
||||||
|
#include "drv_uart.h"
|
||||||
|
|
||||||
|
void rt_hw_timer_isr(int vector, void *parameter)
|
||||||
|
{
|
||||||
|
ARM_TIMER_IRQCLR = 0;
|
||||||
|
|
||||||
|
rt_tick_increase();
|
||||||
|
}
|
||||||
|
|
||||||
|
int rt_hw_timer_init(void)
|
||||||
|
{
|
||||||
|
/* timer_clock = apb_clock/(pre_divider + 1) */
|
||||||
|
ARM_TIMER_PREDIV = (250 - 1);
|
||||||
|
|
||||||
|
ARM_TIMER_RELOAD = 0;
|
||||||
|
ARM_TIMER_LOAD = 0;
|
||||||
|
ARM_TIMER_IRQCLR = 0;
|
||||||
|
ARM_TIMER_CTRL = 0;
|
||||||
|
|
||||||
|
ARM_TIMER_RELOAD = 10000;
|
||||||
|
ARM_TIMER_LOAD = 10000;
|
||||||
|
|
||||||
|
/* 23-bit counter, enable interrupt, enable timer */
|
||||||
|
ARM_TIMER_CTRL = (1 << 1) | (1 << 5) | (1 << 7);
|
||||||
|
|
||||||
|
rt_hw_interrupt_install(IRQ_ARM_TIMER, rt_hw_timer_isr, RT_NULL, "tick");
|
||||||
|
rt_hw_interrupt_umask(IRQ_ARM_TIMER);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void vector_copy(void)
|
||||||
|
{
|
||||||
|
rt_memcpy((void*)0x0, (void*)0x8000, 64);
|
||||||
|
}
|
||||||
|
|
||||||
|
void rt_hw_board_init(void)
|
||||||
|
{
|
||||||
|
/* initialize hardware interrupt */
|
||||||
|
rt_hw_interrupt_init();
|
||||||
|
vector_copy();
|
||||||
|
|
||||||
|
/* initialize uart */
|
||||||
|
rt_hw_uart_init();
|
||||||
|
|
||||||
|
#ifdef RT_USING_CONSOLE
|
||||||
|
/* set console device */
|
||||||
|
rt_console_set_device(RT_CONSOLE_DEVICE_NAME);
|
||||||
|
#endif /* RT_USING_CONSOLE */
|
||||||
|
|
||||||
|
#ifdef RT_USING_HEAP
|
||||||
|
/* initialize memory system */
|
||||||
|
rt_kprintf("heap: 0x%08x - 0x%08x\n", RT_HW_HEAP_BEGIN, RT_HW_HEAP_END);
|
||||||
|
rt_system_heap_init(RT_HW_HEAP_BEGIN, RT_HW_HEAP_END);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* initialize timer for os tick */
|
||||||
|
// rt_hw_timer_init();
|
||||||
|
|
||||||
|
#ifdef RT_USING_COMPONENTS_INIT
|
||||||
|
rt_components_board_init();
|
||||||
|
#endif
|
||||||
|
}
|
42
bsp/raspi2/driver/board.h
Normal file
42
bsp/raspi2/driver/board.h
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* File : board.h
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2017, 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-5-30 Bernard the first version
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef BOARD_H__
|
||||||
|
#define BOARD_H__
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
#include <rthw.h>
|
||||||
|
#include <bcm283x.h>
|
||||||
|
|
||||||
|
extern unsigned char __bss_start;
|
||||||
|
extern unsigned char __bss_end;
|
||||||
|
|
||||||
|
#define RT_HW_HEAP_BEGIN (void*)&__bss_end
|
||||||
|
#define RT_HW_HEAP_END (void*)(0x0 + 4 * 1024 * 1024)
|
||||||
|
|
||||||
|
void rt_hw_board_init(void);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
199
bsp/raspi2/driver/drv_uart.c
Normal file
199
bsp/raspi2/driver/drv_uart.c
Normal file
@ -0,0 +1,199 @@
|
|||||||
|
/*
|
||||||
|
* File : drv_uart.c
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2017, 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/5/5 Bernard The first version
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <rthw.h>
|
||||||
|
#include <rtthread.h>
|
||||||
|
#include <rtdevice.h>
|
||||||
|
|
||||||
|
#include "board.h"
|
||||||
|
#include "drv_uart.h"
|
||||||
|
|
||||||
|
#include <rtdevice.h>
|
||||||
|
|
||||||
|
#define AUX_BASE (0x3F000000 + 0x215000)
|
||||||
|
|
||||||
|
struct hw_uart_device
|
||||||
|
{
|
||||||
|
rt_uint32_t hw_base;
|
||||||
|
rt_uint32_t irqno;
|
||||||
|
};
|
||||||
|
|
||||||
|
static rt_err_t uart_configure(struct rt_serial_device *serial, struct serial_configure *cfg)
|
||||||
|
{
|
||||||
|
struct hw_uart_device *uart;
|
||||||
|
|
||||||
|
RT_ASSERT(serial != RT_NULL);
|
||||||
|
uart = (struct hw_uart_device *)serial->parent.user_data;
|
||||||
|
|
||||||
|
if (uart->hw_base == AUX_BASE)
|
||||||
|
{
|
||||||
|
uint32_t value;
|
||||||
|
|
||||||
|
/* GPIO function set */
|
||||||
|
value = GPIO_GPFSEL1;
|
||||||
|
value &= ~(7<<12); /* GPIO14 */
|
||||||
|
value |= 2<<12 ; /* ALT5 */
|
||||||
|
value &= ~(7<<15); /* GPIO15 */
|
||||||
|
value |= 2<<15 ; /* ALT5 */
|
||||||
|
GPIO_GPFSEL1 = value;
|
||||||
|
|
||||||
|
/* PullUD disable */
|
||||||
|
GPIO_GPPUD = 0;
|
||||||
|
GPIO_GPPUDCLK0 = (1 << 14) | (1 << 15);
|
||||||
|
GPIO_GPPUDCLK0 = 0;
|
||||||
|
|
||||||
|
AUX_ENABLES(uart->hw_base) = 1; /* Enable UART1 */
|
||||||
|
AUX_MU_IER_REG(uart->hw_base) = 0; /* Disable interrupt */
|
||||||
|
AUX_MU_CNTL_REG(uart->hw_base) = 0; /* Disable Transmitter and Receiver */
|
||||||
|
AUX_MU_LCR_REG(uart->hw_base) = 3; /* Works in 8-bit mode */
|
||||||
|
AUX_MU_MCR_REG(uart->hw_base) = 0; /* Disable RTS */
|
||||||
|
AUX_MU_IIR_REG(uart->hw_base) = 0xC6; /* Enable FIFO, Clear FIFO */
|
||||||
|
AUX_MU_BAUD_REG(uart->hw_base) = 270; /* 115200 = system clock 250MHz / (8 * (baud + 1)), baud = 270 */
|
||||||
|
AUX_MU_CNTL_REG(uart->hw_base) = 3; /* Enable Transmitter and Receiver */
|
||||||
|
}
|
||||||
|
|
||||||
|
return RT_EOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static rt_err_t uart_control(struct rt_serial_device *serial, int cmd, void *arg)
|
||||||
|
{
|
||||||
|
struct hw_uart_device *uart;
|
||||||
|
|
||||||
|
RT_ASSERT(serial != RT_NULL);
|
||||||
|
uart = (struct hw_uart_device *)serial->parent.user_data;
|
||||||
|
|
||||||
|
switch (cmd)
|
||||||
|
{
|
||||||
|
case RT_DEVICE_CTRL_CLR_INT:
|
||||||
|
/* disable rx irq */
|
||||||
|
AUX_MU_IER_REG(uart->hw_base) = 0x0;
|
||||||
|
rt_hw_interrupt_mask(uart->irqno);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case RT_DEVICE_CTRL_SET_INT:
|
||||||
|
/* enable rx irq */
|
||||||
|
AUX_MU_IER_REG(uart->hw_base) = 0x1;
|
||||||
|
rt_hw_interrupt_umask(uart->irqno);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return RT_EOK;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int uart_putc(struct rt_serial_device *serial, char c)
|
||||||
|
{
|
||||||
|
struct hw_uart_device *uart;
|
||||||
|
|
||||||
|
RT_ASSERT(serial != RT_NULL);
|
||||||
|
uart = (struct hw_uart_device *)serial->parent.user_data;
|
||||||
|
|
||||||
|
while (!(AUX_MU_LSR_REG(uart->hw_base) & 0x20));
|
||||||
|
AUX_MU_IO_REG(uart->hw_base) = c;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
static int uart_getc(struct rt_serial_device *serial)
|
||||||
|
{
|
||||||
|
int ch = -1;
|
||||||
|
struct hw_uart_device *uart;
|
||||||
|
|
||||||
|
RT_ASSERT(serial != RT_NULL);
|
||||||
|
uart = (struct hw_uart_device *)serial->parent.user_data;
|
||||||
|
|
||||||
|
if ((AUX_MU_LSR_REG(uart->hw_base) & 0x01))
|
||||||
|
{
|
||||||
|
ch = AUX_MU_IO_REG(uart->hw_base) & 0xff;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ch;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const struct rt_uart_ops _uart_ops =
|
||||||
|
{
|
||||||
|
uart_configure,
|
||||||
|
uart_control,
|
||||||
|
uart_putc,
|
||||||
|
uart_getc,
|
||||||
|
};
|
||||||
|
|
||||||
|
static void rt_hw_uart_isr(int irqno, void *param)
|
||||||
|
{
|
||||||
|
struct rt_serial_device *serial = (struct rt_serial_device*)param;
|
||||||
|
|
||||||
|
rt_hw_serial_isr(serial, RT_SERIAL_EVENT_RX_IND);
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef RT_USING_UART0
|
||||||
|
/* UART device driver structure */
|
||||||
|
static struct hw_uart_device _uart0_device =
|
||||||
|
{
|
||||||
|
RPI_UART0_BASE,
|
||||||
|
IRQ_PBA8_UART0,
|
||||||
|
};
|
||||||
|
static struct rt_serial_device _serial0;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef RT_USING_UART1
|
||||||
|
/* UART1 device driver structure */
|
||||||
|
static struct hw_uart_device _uart1_device =
|
||||||
|
{
|
||||||
|
AUX_BASE,
|
||||||
|
IRQ_AUX,
|
||||||
|
};
|
||||||
|
static struct rt_serial_device _serial1;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
int rt_hw_uart_init(void)
|
||||||
|
{
|
||||||
|
struct hw_uart_device *uart;
|
||||||
|
struct serial_configure config = RT_SERIAL_CONFIG_DEFAULT;
|
||||||
|
|
||||||
|
#ifdef RT_USING_UART0
|
||||||
|
uart = &_uart0_device;
|
||||||
|
|
||||||
|
_serial0.ops = &_uart_ops;
|
||||||
|
_serial0.config = config;
|
||||||
|
|
||||||
|
/* register UART1 device */
|
||||||
|
rt_hw_serial_register(&_serial0, "uart0",
|
||||||
|
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX,
|
||||||
|
uart);
|
||||||
|
rt_hw_interrupt_install(uart->irqno, rt_hw_uart_isr, &_serial0, "uart0");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef RT_USING_UART1
|
||||||
|
uart = &_uart1_device;
|
||||||
|
_serial1.ops = &_uart_ops;
|
||||||
|
_serial1.config = config;
|
||||||
|
|
||||||
|
/* register UART1 device */
|
||||||
|
rt_hw_serial_register(&_serial1, "uart1",
|
||||||
|
RT_DEVICE_FLAG_RDWR | RT_DEVICE_FLAG_INT_RX, uart);
|
||||||
|
/* enable Rx and Tx of UART */
|
||||||
|
rt_hw_interrupt_install(uart->irqno, rt_hw_uart_isr, &_serial1, "uart1");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
56
bsp/raspi2/driver/drv_uart.h
Normal file
56
bsp/raspi2/driver/drv_uart.h
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* File : drv_uart.h
|
||||||
|
* This file is part of RT-Thread RTOS
|
||||||
|
* COPYRIGHT (C) 2017, 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-5-30 Bernard the first version
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef DRV_UART_H__
|
||||||
|
#define DRV_UART_H__
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Auxiliary
|
||||||
|
*/
|
||||||
|
#define AUX_IRQ(BASE) HWREG32(BASE + 0x00) /* Auxiliary Interrupt status 3 */
|
||||||
|
#define AUX_ENABLES(BASE) HWREG32(BASE + 0x04) /* Auxiliary enables 3bit */
|
||||||
|
#define AUX_MU_IO_REG(BASE) HWREG32(BASE + 0x40) /* Mini Uart I/O Data 8bit */
|
||||||
|
#define AUX_MU_IER_REG(BASE) HWREG32(BASE + 0x44) /* Mini Uart Interrupt Enable 8bit */
|
||||||
|
#define AUX_MU_IIR_REG(BASE) HWREG32(BASE + 0x48) /* Mini Uart Interrupt Identify 8bit */
|
||||||
|
#define AUX_MU_LCR_REG(BASE) HWREG32(BASE + 0x4C) /* Mini Uart Line Control 8bit */
|
||||||
|
#define AUX_MU_MCR_REG(BASE) HWREG32(BASE + 0x50) /* Mini Uart Modem Control 8bit */
|
||||||
|
#define AUX_MU_LSR_REG(BASE) HWREG32(BASE + 0x54) /* Mini Uart Line Status 8bit */
|
||||||
|
#define AUX_MU_MSR_REG(BASE) HWREG32(BASE + 0x58) /* Mini Uart Modem Status 8bit */
|
||||||
|
#define AUX_MU_SCRATCH(BASE) HWREG32(BASE + 0x5C) /* Mini Uart Scratch 8bit */
|
||||||
|
#define AUX_MU_CNTL_REG(BASE) HWREG32(BASE + 0x60) /* Mini Uart Extra Control 8bit */
|
||||||
|
#define AUX_MU_STAT_REG(BASE) HWREG32(BASE + 0x64) /* Mini Uart Extra Status 32bit */
|
||||||
|
#define AUX_MU_BAUD_REG(BASE) HWREG32(BASE + 0x68) /* Mini Uart Baudrate 16bit */
|
||||||
|
#define AUX_SPI0_CNTL0_REG(BASE) HWREG32(BASE + 0x80) /* SPI 1 Control register 0 32bit */
|
||||||
|
#define AUX_SPI0_CNTL1_REG(BASE) HWREG32(BASE + 0x84) /* SPI 1 Control register 1 8bit */
|
||||||
|
#define AUX_SPI0_STAT_REG(BASE) HWREG32(BASE + 0x88) /* SPI 1 Status 32bit */
|
||||||
|
#define AUX_SPI0_IO_REG(BASE) HWREG32(BASE + 0x90) /* SPI 1 Data 32bit */
|
||||||
|
#define AUX_SPI0_PEEK_REG(BASE) HWREG32(BASE + 0x94) /* SPI 1 Peek 16bit */
|
||||||
|
#define AUX_SPI1_CNTL0_REG(BASE) HWREG32(BASE + 0xC0) /* SPI 2 Control register 0 32bit */
|
||||||
|
#define AUX_SPI1_CNTL1_REG(BASE) HWREG32(BASE + 0xC4) /* SPI 2 Control register 1 8bit */
|
||||||
|
|
||||||
|
int rt_hw_uart_init(void);
|
||||||
|
|
||||||
|
#endif /* DRV_UART_H__ */
|
||||||
|
|
BIN
bsp/raspi2/figures/raspi2.png
Normal file
BIN
bsp/raspi2/figures/raspi2.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 880 KiB |
BIN
bsp/raspi2/figures/raspi_uart.png
Normal file
BIN
bsp/raspi2/figures/raspi_uart.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.0 MiB |
149
bsp/raspi2/link.lds
Normal file
149
bsp/raspi2/link.lds
Normal file
@ -0,0 +1,149 @@
|
|||||||
|
/*
|
||||||
|
* File : link.lds
|
||||||
|
* COPYRIGHT (C) 2017, 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:
|
||||||
|
* 2017-5-30 bernard first version
|
||||||
|
*/
|
||||||
|
|
||||||
|
OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
|
||||||
|
OUTPUT_ARCH(arm)
|
||||||
|
|
||||||
|
SECTIONS
|
||||||
|
{
|
||||||
|
. = 0x00008000;
|
||||||
|
. = ALIGN(4);
|
||||||
|
.text :
|
||||||
|
{
|
||||||
|
*(.vectors)
|
||||||
|
*(.text) /* remaining code */
|
||||||
|
*(.text.*) /* remaining code */
|
||||||
|
|
||||||
|
*(.rodata) /* read-only data (constants) */
|
||||||
|
*(.rodata*)
|
||||||
|
*(.glue_7)
|
||||||
|
*(.glue_7t)
|
||||||
|
*(.gnu.linkonce.t*)
|
||||||
|
|
||||||
|
/* section information for finsh shell */
|
||||||
|
. = ALIGN(4);
|
||||||
|
__fsymtab_start = .;
|
||||||
|
KEEP(*(FSymTab))
|
||||||
|
__fsymtab_end = .;
|
||||||
|
. = ALIGN(4);
|
||||||
|
__vsymtab_start = .;
|
||||||
|
KEEP(*(VSymTab))
|
||||||
|
__vsymtab_end = .;
|
||||||
|
. = ALIGN(4);
|
||||||
|
|
||||||
|
/* section information for initial. */
|
||||||
|
. = ALIGN(4);
|
||||||
|
__rt_init_start = .;
|
||||||
|
KEEP(*(SORT(.rti_fn*)))
|
||||||
|
__rt_init_end = .;
|
||||||
|
. = ALIGN(4);
|
||||||
|
|
||||||
|
. = ALIGN(4);
|
||||||
|
_etext = .;
|
||||||
|
}
|
||||||
|
|
||||||
|
.eh_frame_hdr :
|
||||||
|
{
|
||||||
|
*(.eh_frame_hdr)
|
||||||
|
*(.eh_frame_entry)
|
||||||
|
}
|
||||||
|
.eh_frame : ONLY_IF_RO { KEEP (*(.eh_frame)) }
|
||||||
|
|
||||||
|
. = ALIGN(4);
|
||||||
|
.data :
|
||||||
|
{
|
||||||
|
*(.data)
|
||||||
|
*(.data.*)
|
||||||
|
|
||||||
|
*(.data1)
|
||||||
|
*(.data1.*)
|
||||||
|
|
||||||
|
. = ALIGN(8);
|
||||||
|
_gp = ABSOLUTE(.); /* Base of small data */
|
||||||
|
|
||||||
|
*(.sdata)
|
||||||
|
*(.sdata.*)
|
||||||
|
}
|
||||||
|
|
||||||
|
. = ALIGN(4);
|
||||||
|
.ctors :
|
||||||
|
{
|
||||||
|
PROVIDE(__ctors_start__ = .);
|
||||||
|
KEEP(*(SORT(.ctors.*)))
|
||||||
|
KEEP(*(.ctors))
|
||||||
|
PROVIDE(__ctors_end__ = .);
|
||||||
|
}
|
||||||
|
|
||||||
|
.dtors :
|
||||||
|
{
|
||||||
|
PROVIDE(__dtors_start__ = .);
|
||||||
|
KEEP(*(SORT(.dtors.*)))
|
||||||
|
KEEP(*(.dtors))
|
||||||
|
PROVIDE(__dtors_end__ = .);
|
||||||
|
}
|
||||||
|
|
||||||
|
. = ALIGN(4);
|
||||||
|
.bss :
|
||||||
|
{
|
||||||
|
PROVIDE(__bss_start = .);
|
||||||
|
*(.bss)
|
||||||
|
*(.bss.*)
|
||||||
|
*(.dynbss)
|
||||||
|
*(COMMON)
|
||||||
|
PROVIDE(__bss_end = .);
|
||||||
|
}
|
||||||
|
_end = .;
|
||||||
|
|
||||||
|
/* Stabs debugging sections. */
|
||||||
|
.stab 0 : { *(.stab) }
|
||||||
|
.stabstr 0 : { *(.stabstr) }
|
||||||
|
.stab.excl 0 : { *(.stab.excl) }
|
||||||
|
.stab.exclstr 0 : { *(.stab.exclstr) }
|
||||||
|
.stab.index 0 : { *(.stab.index) }
|
||||||
|
.stab.indexstr 0 : { *(.stab.indexstr) }
|
||||||
|
.comment 0 : { *(.comment) }
|
||||||
|
/* DWARF debug sections.
|
||||||
|
* Symbols in the DWARF debugging sections are relative to the beginning
|
||||||
|
* of the section so we begin them at 0. */
|
||||||
|
/* DWARF 1 */
|
||||||
|
.debug 0 : { *(.debug) }
|
||||||
|
.line 0 : { *(.line) }
|
||||||
|
/* GNU DWARF 1 extensions */
|
||||||
|
.debug_srcinfo 0 : { *(.debug_srcinfo) }
|
||||||
|
.debug_sfnames 0 : { *(.debug_sfnames) }
|
||||||
|
/* DWARF 1.1 and DWARF 2 */
|
||||||
|
.debug_aranges 0 : { *(.debug_aranges) }
|
||||||
|
.debug_pubnames 0 : { *(.debug_pubnames) }
|
||||||
|
/* DWARF 2 */
|
||||||
|
.debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
|
||||||
|
.debug_abbrev 0 : { *(.debug_abbrev) }
|
||||||
|
.debug_line 0 : { *(.debug_line) }
|
||||||
|
.debug_frame 0 : { *(.debug_frame) }
|
||||||
|
.debug_str 0 : { *(.debug_str) }
|
||||||
|
.debug_loc 0 : { *(.debug_loc) }
|
||||||
|
.debug_macinfo 0 : { *(.debug_macinfo) }
|
||||||
|
/* SGI/MIPS DWARF 2 extensions */
|
||||||
|
.debug_weaknames 0 : { *(.debug_weaknames) }
|
||||||
|
.debug_funcnames 0 : { *(.debug_funcnames) }
|
||||||
|
.debug_typenames 0 : { *(.debug_typenames) }
|
||||||
|
.debug_varnames 0 : { *(.debug_varnames) }
|
||||||
|
}
|
257
bsp/raspi2/rtconfig.h
Normal file
257
bsp/raspi2/rtconfig.h
Normal file
@ -0,0 +1,257 @@
|
|||||||
|
#ifndef RT_CONFIG_H__
|
||||||
|
#define RT_CONFIG_H__
|
||||||
|
|
||||||
|
/* Automatically generated file; DO NOT EDIT. */
|
||||||
|
/* RT-Thread Project Configuration */
|
||||||
|
|
||||||
|
/* RT-Thread Kernel */
|
||||||
|
|
||||||
|
#define RT_NAME_MAX 8
|
||||||
|
#define RT_ALIGN_SIZE 4
|
||||||
|
/* RT_THREAD_PRIORITY_8 is not set */
|
||||||
|
#define RT_THREAD_PRIORITY_32
|
||||||
|
/* RT_THREAD_PRIORITY_256 is not set */
|
||||||
|
#define RT_THREAD_PRIORITY_MAX 32
|
||||||
|
#define RT_TICK_PER_SECOND 100
|
||||||
|
#define RT_USING_OVERFLOW_CHECK
|
||||||
|
#define RT_USING_HOOK
|
||||||
|
#define RT_IDEL_HOOK_LIST_SIZE 4
|
||||||
|
#define IDLE_THREAD_STACK_SIZE 256
|
||||||
|
/* RT_USING_TIMER_SOFT is not set */
|
||||||
|
#define RT_DEBUG
|
||||||
|
/* RT_DEBUG_INIT_CONFIG is not set */
|
||||||
|
/* RT_DEBUG_THREAD_CONFIG is not set */
|
||||||
|
/* RT_DEBUG_SCHEDULER_CONFIG is not set */
|
||||||
|
/* RT_DEBUG_IPC_CONFIG is not set */
|
||||||
|
/* RT_DEBUG_TIMER_CONFIG is not set */
|
||||||
|
/* RT_DEBUG_IRQ_CONFIG is not set */
|
||||||
|
/* RT_DEBUG_MEM_CONFIG is not set */
|
||||||
|
/* RT_DEBUG_SLAB_CONFIG is not set */
|
||||||
|
/* RT_DEBUG_MEMHEAP_CONFIG is not set */
|
||||||
|
/* RT_DEBUG_MODULE_CONFIG is not set */
|
||||||
|
|
||||||
|
/* Inter-Thread communication */
|
||||||
|
|
||||||
|
#define RT_USING_SEMAPHORE
|
||||||
|
#define RT_USING_MUTEX
|
||||||
|
#define RT_USING_EVENT
|
||||||
|
#define RT_USING_MAILBOX
|
||||||
|
#define RT_USING_MESSAGEQUEUE
|
||||||
|
/* RT_USING_SIGNALS is not set */
|
||||||
|
|
||||||
|
/* Memory Management */
|
||||||
|
|
||||||
|
#define RT_USING_MEMPOOL
|
||||||
|
/* RT_USING_MEMHEAP is not set */
|
||||||
|
/* RT_USING_NOHEAP is not set */
|
||||||
|
#define RT_USING_SMALL_MEM
|
||||||
|
/* RT_USING_SLAB is not set */
|
||||||
|
/* RT_USING_MEMTRACE is not set */
|
||||||
|
#define RT_USING_HEAP
|
||||||
|
|
||||||
|
/* Kernel Device Object */
|
||||||
|
|
||||||
|
#define RT_USING_DEVICE
|
||||||
|
/* RT_USING_DEVICE_OPS is not set */
|
||||||
|
/* RT_USING_INTERRUPT_INFO is not set */
|
||||||
|
#define RT_USING_CONSOLE
|
||||||
|
#define RT_CONSOLEBUF_SIZE 128
|
||||||
|
#define RT_CONSOLE_DEVICE_NAME "uart1"
|
||||||
|
/* RT_USING_MODULE is not set */
|
||||||
|
#define ARCH_ARM
|
||||||
|
#define ARCH_ARM_CORTEX_A
|
||||||
|
#define ARCH_ARM_CORTEX_A7
|
||||||
|
|
||||||
|
/* RT-Thread Components */
|
||||||
|
|
||||||
|
#define RT_USING_COMPONENTS_INIT
|
||||||
|
#define RT_USING_USER_MAIN
|
||||||
|
#define RT_MAIN_THREAD_STACK_SIZE 2048
|
||||||
|
#define RT_MAIN_THREAD_PRIORITY 10
|
||||||
|
|
||||||
|
/* C++ features */
|
||||||
|
|
||||||
|
/* RT_USING_CPLUSPLUS is not set */
|
||||||
|
|
||||||
|
/* Command shell */
|
||||||
|
|
||||||
|
#define RT_USING_FINSH
|
||||||
|
#define FINSH_THREAD_NAME "tshell"
|
||||||
|
#define FINSH_USING_HISTORY
|
||||||
|
#define FINSH_HISTORY_LINES 5
|
||||||
|
#define FINSH_USING_SYMTAB
|
||||||
|
#define FINSH_USING_DESCRIPTION
|
||||||
|
/* FINSH_ECHO_DISABLE_DEFAULT is not set */
|
||||||
|
#define FINSH_THREAD_PRIORITY 20
|
||||||
|
#define FINSH_THREAD_STACK_SIZE 4096
|
||||||
|
#define FINSH_CMD_SIZE 80
|
||||||
|
/* FINSH_USING_AUTH is not set */
|
||||||
|
#define FINSH_USING_MSH
|
||||||
|
#define FINSH_USING_MSH_DEFAULT
|
||||||
|
#define FINSH_USING_MSH_ONLY
|
||||||
|
#define FINSH_ARG_MAX 10
|
||||||
|
|
||||||
|
/* Device virtual file system */
|
||||||
|
|
||||||
|
/* RT_USING_DFS is not set */
|
||||||
|
|
||||||
|
/* Device Drivers */
|
||||||
|
|
||||||
|
#define RT_USING_DEVICE_IPC
|
||||||
|
#define RT_PIPE_BUFSZ 512
|
||||||
|
#define RT_USING_SERIAL
|
||||||
|
/* RT_USING_CAN is not set */
|
||||||
|
/* RT_USING_HWTIMER is not set */
|
||||||
|
/* RT_USING_CPUTIME is not set */
|
||||||
|
/* RT_USING_I2C is not set */
|
||||||
|
/* RT_USING_PIN is not set */
|
||||||
|
/* RT_USING_PWM is not set */
|
||||||
|
/* RT_USING_MTD_NOR is not set */
|
||||||
|
/* RT_USING_MTD_NAND is not set */
|
||||||
|
/* RT_USING_RTC is not set */
|
||||||
|
/* RT_USING_SDIO is not set */
|
||||||
|
/* RT_USING_SPI is not set */
|
||||||
|
/* RT_USING_WDT is not set */
|
||||||
|
/* RT_USING_WIFI is not set */
|
||||||
|
/* RT_USING_AUDIO is not set */
|
||||||
|
|
||||||
|
/* Using USB */
|
||||||
|
|
||||||
|
/* RT_USING_USB_HOST is not set */
|
||||||
|
/* RT_USING_USB_DEVICE is not set */
|
||||||
|
|
||||||
|
/* POSIX layer and C standard library */
|
||||||
|
|
||||||
|
/* RT_USING_LIBC is not set */
|
||||||
|
/* RT_USING_PTHREADS is not set */
|
||||||
|
|
||||||
|
/* Network */
|
||||||
|
|
||||||
|
/* Socket abstraction layer */
|
||||||
|
|
||||||
|
/* RT_USING_SAL is not set */
|
||||||
|
|
||||||
|
/* light weight TCP/IP stack */
|
||||||
|
|
||||||
|
/* RT_USING_LWIP is not set */
|
||||||
|
|
||||||
|
/* Modbus master and slave stack */
|
||||||
|
|
||||||
|
/* RT_USING_MODBUS is not set */
|
||||||
|
|
||||||
|
/* AT commands */
|
||||||
|
|
||||||
|
/* RT_USING_AT is not set */
|
||||||
|
|
||||||
|
/* VBUS(Virtual Software BUS) */
|
||||||
|
|
||||||
|
/* RT_USING_VBUS is not set */
|
||||||
|
|
||||||
|
/* Utilities */
|
||||||
|
|
||||||
|
/* RT_USING_LOGTRACE is not set */
|
||||||
|
/* RT_USING_RYM is not set */
|
||||||
|
|
||||||
|
/* RT-Thread online packages */
|
||||||
|
|
||||||
|
/* IoT - internet of things */
|
||||||
|
|
||||||
|
/* PKG_USING_PAHOMQTT is not set */
|
||||||
|
/* PKG_USING_WEBCLIENT is not set */
|
||||||
|
/* PKG_USING_MONGOOSE is not set */
|
||||||
|
/* PKG_USING_WEBTERMINAL is not set */
|
||||||
|
/* PKG_USING_CJSON is not set */
|
||||||
|
/* PKG_USING_JSMN is not set */
|
||||||
|
/* PKG_USING_LJSON is not set */
|
||||||
|
/* PKG_USING_EZXML is not set */
|
||||||
|
/* PKG_USING_NANOPB is not set */
|
||||||
|
|
||||||
|
/* Wi-Fi */
|
||||||
|
|
||||||
|
/* Marvell WiFi */
|
||||||
|
|
||||||
|
/* PKG_USING_WLANMARVELL is not set */
|
||||||
|
|
||||||
|
/* Wiced WiFi */
|
||||||
|
|
||||||
|
/* PKG_USING_WLAN_WICED is not set */
|
||||||
|
/* PKG_USING_COAP is not set */
|
||||||
|
/* PKG_USING_NOPOLL is not set */
|
||||||
|
/* PKG_USING_NETUTILS is not set */
|
||||||
|
/* PKG_USING_AT_DEVICE is not set */
|
||||||
|
|
||||||
|
/* IoT Cloud */
|
||||||
|
|
||||||
|
/* PKG_USING_ONENET is not set */
|
||||||
|
/* PKG_USING_GAGENT_CLOUD is not set */
|
||||||
|
/* PKG_USING_ALI_IOTKIT is not set */
|
||||||
|
/* PKG_USING_AZURE is not set */
|
||||||
|
|
||||||
|
/* security packages */
|
||||||
|
|
||||||
|
/* PKG_USING_MBEDTLS is not set */
|
||||||
|
/* PKG_USING_libsodium is not set */
|
||||||
|
/* PKG_USING_TINYCRYPT is not set */
|
||||||
|
|
||||||
|
/* language packages */
|
||||||
|
|
||||||
|
/* PKG_USING_LUA is not set */
|
||||||
|
/* PKG_USING_JERRYSCRIPT is not set */
|
||||||
|
/* PKG_USING_MICROPYTHON is not set */
|
||||||
|
|
||||||
|
/* multimedia packages */
|
||||||
|
|
||||||
|
/* PKG_USING_OPENMV is not set */
|
||||||
|
/* PKG_USING_MUPDF is not set */
|
||||||
|
|
||||||
|
/* tools packages */
|
||||||
|
|
||||||
|
/* PKG_USING_CMBACKTRACE is not set */
|
||||||
|
/* PKG_USING_EASYFLASH is not set */
|
||||||
|
/* PKG_USING_EASYLOGGER is not set */
|
||||||
|
/* PKG_USING_SYSTEMVIEW is not set */
|
||||||
|
|
||||||
|
/* system packages */
|
||||||
|
|
||||||
|
/* PKG_USING_GUIENGINE is not set */
|
||||||
|
/* PKG_USING_PERSIMMON is not set */
|
||||||
|
/* PKG_USING_CAIRO is not set */
|
||||||
|
/* PKG_USING_PIXMAN is not set */
|
||||||
|
/* PKG_USING_LWEXT4 is not set */
|
||||||
|
/* PKG_USING_PARTITION is not set */
|
||||||
|
/* PKG_USING_FAL is not set */
|
||||||
|
/* PKG_USING_SQLITE is not set */
|
||||||
|
/* PKG_USING_RTI is not set */
|
||||||
|
/* PKG_USING_LITTLEVGL2RTT is not set */
|
||||||
|
|
||||||
|
/* peripheral libraries and drivers */
|
||||||
|
|
||||||
|
/* PKG_USING_STM32F4_HAL is not set */
|
||||||
|
/* PKG_USING_STM32F4_DRIVERS is not set */
|
||||||
|
/* PKG_USING_REALTEK_AMEBA is not set */
|
||||||
|
/* PKG_USING_SHT2X is not set */
|
||||||
|
/* PKG_USING_AHT10 is not set */
|
||||||
|
|
||||||
|
/* miscellaneous packages */
|
||||||
|
|
||||||
|
/* PKG_USING_LIBCSV is not set */
|
||||||
|
/* PKG_USING_OPTPARSE is not set */
|
||||||
|
/* PKG_USING_FASTLZ is not set */
|
||||||
|
/* PKG_USING_MINILZO is not set */
|
||||||
|
/* PKG_USING_QUICKLZ is not set */
|
||||||
|
/* PKG_USING_MULTIBUTTON is not set */
|
||||||
|
/* PKG_USING_CANFESTIVAL is not set */
|
||||||
|
/* PKG_USING_ZLIB is not set */
|
||||||
|
/* PKG_USING_DSTR is not set */
|
||||||
|
|
||||||
|
/* sample package */
|
||||||
|
|
||||||
|
/* PKG_USING_SAMPLES is not set */
|
||||||
|
|
||||||
|
/* example package: hello */
|
||||||
|
|
||||||
|
/* PKG_USING_HELLO is not set */
|
||||||
|
#define BCM2836_SOC
|
||||||
|
#define RT_USING_UART1
|
||||||
|
|
||||||
|
#endif
|
53
bsp/raspi2/rtconfig.py
Normal file
53
bsp/raspi2/rtconfig.py
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
|
# toolchains options
|
||||||
|
ARCH ='arm'
|
||||||
|
CPU ='cortex-a7'
|
||||||
|
CROSS_TOOL ='gcc'
|
||||||
|
|
||||||
|
if os.getenv('RTT_ROOT'):
|
||||||
|
RTT_ROOT = os.getenv('RTT_ROOT')
|
||||||
|
else:
|
||||||
|
RTT_ROOT = r'../..'
|
||||||
|
|
||||||
|
if os.getenv('RTT_CC'):
|
||||||
|
CROSS_TOOL = os.getenv('RTT_CC')
|
||||||
|
|
||||||
|
PLATFORM = 'gcc'
|
||||||
|
EXEC_PATH = r'/opt/gcc-arm-none-eabi-4_8-2014q1_gri/bin'
|
||||||
|
|
||||||
|
if os.getenv('RTT_EXEC_PATH'):
|
||||||
|
EXEC_PATH = os.getenv('RTT_EXEC_PATH')
|
||||||
|
|
||||||
|
BUILD = 'debug'
|
||||||
|
|
||||||
|
if PLATFORM == 'gcc':
|
||||||
|
# toolchains
|
||||||
|
PREFIX = 'arm-none-eabi-'
|
||||||
|
CC = PREFIX + 'gcc'
|
||||||
|
CXX = PREFIX + 'g++'
|
||||||
|
AS = PREFIX + 'gcc'
|
||||||
|
AR = PREFIX + 'ar'
|
||||||
|
LINK = PREFIX + 'gcc'
|
||||||
|
TARGET_EXT = 'elf'
|
||||||
|
SIZE = PREFIX + 'size'
|
||||||
|
OBJDUMP = PREFIX + 'objdump'
|
||||||
|
OBJCPY = PREFIX + 'objcopy'
|
||||||
|
|
||||||
|
DEVICE = ' -mfpu=neon-vfpv4 -mfloat-abi=softfp -march=armv7-a -mtune=cortex-a7 -ftree-vectorize -ffast-math'
|
||||||
|
CFLAGS = DEVICE + ' -Wall'
|
||||||
|
AFLAGS = ' -c' + ' -x assembler-with-cpp -D__ASSEMBLY__'
|
||||||
|
LFLAGS = DEVICE + ' -nostartfiles -Wl,--gc-sections,-Map=rtthread.map,-cref,-u,system_vectors -T link.lds'
|
||||||
|
CPATH = ''
|
||||||
|
LPATH = ''
|
||||||
|
|
||||||
|
if BUILD == 'debug':
|
||||||
|
CFLAGS += ' -O0 -gdwarf-2'
|
||||||
|
AFLAGS += ' -gdwarf-2'
|
||||||
|
else:
|
||||||
|
CFLAGS += ' -O2'
|
||||||
|
|
||||||
|
CXXFLAGS = CFLAGS
|
||||||
|
|
||||||
|
DUMP_ACTION = OBJDUMP + ' -D -S $TARGET > rtt.asm\n'
|
||||||
|
POST_ACTION = OBJCPY + ' -O binary $TARGET kernel7.img\n' + SIZE + ' $TARGET \n'
|
246
bsp/stm32f0/.config
Normal file
246
bsp/stm32f0/.config
Normal file
@ -0,0 +1,246 @@
|
|||||||
|
#
|
||||||
|
# Automatically generated file; DO NOT EDIT.
|
||||||
|
# RT-Thread Configuration
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# RT-Thread Kernel
|
||||||
|
#
|
||||||
|
CONFIG_RT_NAME_MAX=8
|
||||||
|
CONFIG_RT_ALIGN_SIZE=4
|
||||||
|
# CONFIG_RT_THREAD_PRIORITY_8 is not set
|
||||||
|
CONFIG_RT_THREAD_PRIORITY_32=y
|
||||||
|
# CONFIG_RT_THREAD_PRIORITY_256 is not set
|
||||||
|
CONFIG_RT_THREAD_PRIORITY_MAX=32
|
||||||
|
CONFIG_RT_TICK_PER_SECOND=100
|
||||||
|
CONFIG_RT_USING_OVERFLOW_CHECK=y
|
||||||
|
CONFIG_RT_USING_HOOK=y
|
||||||
|
CONFIG_RT_IDEL_HOOK_LIST_SIZE=4
|
||||||
|
CONFIG_IDLE_THREAD_STACK_SIZE=256
|
||||||
|
# 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
|
||||||
|
#
|
||||||
|
CONFIG_RT_USING_SEMAPHORE=y
|
||||||
|
CONFIG_RT_USING_MUTEX=y
|
||||||
|
CONFIG_RT_USING_EVENT=y
|
||||||
|
CONFIG_RT_USING_MAILBOX=y
|
||||||
|
CONFIG_RT_USING_MESSAGEQUEUE=y
|
||||||
|
# CONFIG_RT_USING_SIGNALS is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# Memory Management
|
||||||
|
#
|
||||||
|
CONFIG_RT_USING_MEMPOOL=y
|
||||||
|
CONFIG_RT_USING_MEMHEAP=y
|
||||||
|
# CONFIG_RT_USING_NOHEAP is not set
|
||||||
|
CONFIG_RT_USING_SMALL_MEM=y
|
||||||
|
# CONFIG_RT_USING_SLAB is not set
|
||||||
|
# CONFIG_RT_USING_MEMHEAP_AS_HEAP is not set
|
||||||
|
# CONFIG_RT_USING_MEMTRACE is not set
|
||||||
|
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="uart2"
|
||||||
|
# CONFIG_RT_USING_MODULE is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# RT-Thread Components
|
||||||
|
#
|
||||||
|
CONFIG_RT_USING_COMPONENTS_INIT=y
|
||||||
|
CONFIG_RT_USING_USER_MAIN=y
|
||||||
|
CONFIG_RT_MAIN_THREAD_STACK_SIZE=2048
|
||||||
|
CONFIG_RT_MAIN_THREAD_PRIORITY=10
|
||||||
|
|
||||||
|
#
|
||||||
|
# C++ features
|
||||||
|
#
|
||||||
|
# CONFIG_RT_USING_CPLUSPLUS is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# Command shell
|
||||||
|
#
|
||||||
|
# CONFIG_RT_USING_FINSH is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# Device virtual file system
|
||||||
|
#
|
||||||
|
# CONFIG_RT_USING_DFS is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# 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=y
|
||||||
|
# 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_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 USB
|
||||||
|
#
|
||||||
|
# CONFIG_RT_USING_USB_HOST is not set
|
||||||
|
# CONFIG_RT_USING_USB_DEVICE is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# POSIX layer and C standard library
|
||||||
|
#
|
||||||
|
CONFIG_RT_USING_LIBC=y
|
||||||
|
# CONFIG_RT_USING_PTHREADS is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# Network
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# Socket abstraction layer
|
||||||
|
#
|
||||||
|
# CONFIG_RT_USING_SAL is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# light weight TCP/IP stack
|
||||||
|
#
|
||||||
|
# CONFIG_RT_USING_LWIP is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# Modbus master and slave stack
|
||||||
|
#
|
||||||
|
# CONFIG_RT_USING_MODBUS is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# AT commands
|
||||||
|
#
|
||||||
|
# CONFIG_RT_USING_AT is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# VBUS(Virtual Software BUS)
|
||||||
|
#
|
||||||
|
# CONFIG_RT_USING_VBUS is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# Utilities
|
||||||
|
#
|
||||||
|
# CONFIG_RT_USING_LOGTRACE is not set
|
||||||
|
# CONFIG_RT_USING_RYM 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
|
||||||
|
|
||||||
|
#
|
||||||
|
# IoT - internet of things
|
||||||
|
#
|
||||||
|
# CONFIG_PKG_USING_PAHOMQTT is not set
|
||||||
|
# CONFIG_PKG_USING_WEBCLIENT is not set
|
||||||
|
# CONFIG_PKG_USING_MONGOOSE is not set
|
||||||
|
# CONFIG_PKG_USING_WEBTERMINAL is not set
|
||||||
|
# CONFIG_PKG_USING_CJSON 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
|
||||||
|
#
|
||||||
|
|
||||||
|
#
|
||||||
|
# Marvell WiFi
|
||||||
|
#
|
||||||
|
# CONFIG_PKG_USING_WLANMARVELL is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# Wiced WiFi
|
||||||
|
#
|
||||||
|
# CONFIG_PKG_USING_WLAN_WICED is not set
|
||||||
|
# CONFIG_PKG_USING_COAP is not set
|
||||||
|
# CONFIG_PKG_USING_NOPOLL is not set
|
||||||
|
# CONFIG_PKG_USING_NETUTILS is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# security packages
|
||||||
|
#
|
||||||
|
# CONFIG_PKG_USING_MBEDTLS is not set
|
||||||
|
# CONFIG_PKG_USING_libsodium is not set
|
||||||
|
# CONFIG_PKG_USING_TINYCRYPT is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# language packages
|
||||||
|
#
|
||||||
|
# CONFIG_PKG_USING_JERRYSCRIPT is not set
|
||||||
|
# CONFIG_PKG_USING_MICROPYTHON is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# multimedia packages
|
||||||
|
#
|
||||||
|
# CONFIG_PKG_USING_OPENMV is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# tools packages
|
||||||
|
#
|
||||||
|
# CONFIG_PKG_USING_CMBACKTRACE is not set
|
||||||
|
# CONFIG_PKG_USING_EASYLOGGER is not set
|
||||||
|
# CONFIG_PKG_USING_SYSTEMVIEW is not set
|
||||||
|
# CONFIG_PKG_USING_IPERF is not set
|
||||||
|
|
||||||
|
#
|
||||||
|
# miscellaneous packages
|
||||||
|
#
|
||||||
|
# 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
|
||||||
|
|
||||||
|
#
|
||||||
|
# example package: hello
|
||||||
|
#
|
||||||
|
# CONFIG_PKG_USING_HELLO is not set
|
||||||
|
CONFIG_STM32F030R8=y
|
||||||
|
# CONFIG_RT_USING_HSI is not set
|
||||||
|
CONFIG_RT_HSE_VALUE=8000000
|
||||||
|
# CONFIG_RT_USING_UART1 is not set
|
||||||
|
CONFIG_RT_USING_UART2=y
|
58
bsp/stm32f0/Kconfig
Normal file
58
bsp/stm32f0/Kconfig
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
mainmenu "RT-Thread Configuration"
|
||||||
|
|
||||||
|
config $BSP_DIR
|
||||||
|
string
|
||||||
|
option env="BSP_ROOT"
|
||||||
|
default "."
|
||||||
|
|
||||||
|
config $RTT_DIR
|
||||||
|
string
|
||||||
|
option env="RTT_ROOT"
|
||||||
|
default "../.."
|
||||||
|
|
||||||
|
config $PKGS_DIR
|
||||||
|
string
|
||||||
|
option env="PKGS_ROOT"
|
||||||
|
default "packages"
|
||||||
|
|
||||||
|
source "$RTT_DIR/Kconfig"
|
||||||
|
source "$PKGS_DIR/Kconfig"
|
||||||
|
|
||||||
|
choice
|
||||||
|
prompt "Device type"
|
||||||
|
default STM32F030R8
|
||||||
|
config STM32F030R8
|
||||||
|
bool "STM32F030R8"
|
||||||
|
|
||||||
|
endchoice
|
||||||
|
|
||||||
|
config RT_USING_HSI
|
||||||
|
bool "Using HSI as clock source"
|
||||||
|
default n
|
||||||
|
config RT_HSE_VALUE
|
||||||
|
int "HSE Value"
|
||||||
|
default 8000000
|
||||||
|
depends on !RT_USING_HSI
|
||||||
|
|
||||||
|
|
||||||
|
if RT_USING_SERIAL
|
||||||
|
|
||||||
|
config RT_USING_UART1
|
||||||
|
bool "Using uart1"
|
||||||
|
default y
|
||||||
|
|
||||||
|
config RT_USING_UART2
|
||||||
|
bool "Using uart2"
|
||||||
|
default n
|
||||||
|
|
||||||
|
endif
|
||||||
|
|
||||||
|
if RT_USING_SPI
|
||||||
|
config RT_USING_SPI1
|
||||||
|
bool "Using spi1"
|
||||||
|
default y
|
||||||
|
config RT_USING_SPI2
|
||||||
|
bool "Using spi2"
|
||||||
|
default n
|
||||||
|
endif
|
||||||
|
|
@ -0,0 +1,165 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
* Copyright (C) 2010-2014 ARM Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* $Date: 19. March 2015
|
||||||
|
* $Revision: V.1.4.5
|
||||||
|
*
|
||||||
|
* Project: CMSIS DSP Library
|
||||||
|
* Title: arm_abs_f32.c
|
||||||
|
*
|
||||||
|
* Description: Vector absolute value.
|
||||||
|
*
|
||||||
|
* Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* - Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* - Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* - Neither the name of ARM LIMITED nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this
|
||||||
|
* software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
* ---------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#include "arm_math.h"
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup groupMath
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @defgroup BasicAbs Vector Absolute Value
|
||||||
|
*
|
||||||
|
* Computes the absolute value of a vector on an element-by-element basis.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* pDst[n] = abs(pSrc[n]), 0 <= n < blockSize.
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* The functions support in-place computation allowing the source and
|
||||||
|
* destination pointers to reference the same memory buffer.
|
||||||
|
* There are separate functions for floating-point, Q7, Q15, and Q31 data types.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup BasicAbs
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Floating-point vector absolute value.
|
||||||
|
* @param[in] *pSrc points to the input buffer
|
||||||
|
* @param[out] *pDst points to the output buffer
|
||||||
|
* @param[in] blockSize number of samples in each vector
|
||||||
|
* @return none.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void arm_abs_f32(
|
||||||
|
float32_t * pSrc,
|
||||||
|
float32_t * pDst,
|
||||||
|
uint32_t blockSize)
|
||||||
|
{
|
||||||
|
uint32_t blkCnt; /* loop counter */
|
||||||
|
|
||||||
|
#ifndef ARM_MATH_CM0_FAMILY
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M4 and Cortex-M3 */
|
||||||
|
float32_t in1, in2, in3, in4; /* temporary variables */
|
||||||
|
|
||||||
|
/*loop Unrolling */
|
||||||
|
blkCnt = blockSize >> 2u;
|
||||||
|
|
||||||
|
/* First part of the processing with loop unrolling. Compute 4 outputs at a time.
|
||||||
|
** a second loop below computes the remaining 1 to 3 samples. */
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = |A| */
|
||||||
|
/* Calculate absolute and then store the results in the destination buffer. */
|
||||||
|
/* read sample from source */
|
||||||
|
in1 = *pSrc;
|
||||||
|
in2 = *(pSrc + 1);
|
||||||
|
in3 = *(pSrc + 2);
|
||||||
|
|
||||||
|
/* find absolute value */
|
||||||
|
in1 = fabsf(in1);
|
||||||
|
|
||||||
|
/* read sample from source */
|
||||||
|
in4 = *(pSrc + 3);
|
||||||
|
|
||||||
|
/* find absolute value */
|
||||||
|
in2 = fabsf(in2);
|
||||||
|
|
||||||
|
/* read sample from source */
|
||||||
|
*pDst = in1;
|
||||||
|
|
||||||
|
/* find absolute value */
|
||||||
|
in3 = fabsf(in3);
|
||||||
|
|
||||||
|
/* find absolute value */
|
||||||
|
in4 = fabsf(in4);
|
||||||
|
|
||||||
|
/* store result to destination */
|
||||||
|
*(pDst + 1) = in2;
|
||||||
|
|
||||||
|
/* store result to destination */
|
||||||
|
*(pDst + 2) = in3;
|
||||||
|
|
||||||
|
/* store result to destination */
|
||||||
|
*(pDst + 3) = in4;
|
||||||
|
|
||||||
|
|
||||||
|
/* Update source pointer to process next sampels */
|
||||||
|
pSrc += 4u;
|
||||||
|
|
||||||
|
/* Update destination pointer to process next sampels */
|
||||||
|
pDst += 4u;
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the blockSize is not a multiple of 4, compute any remaining output samples here.
|
||||||
|
** No loop unrolling is used. */
|
||||||
|
blkCnt = blockSize % 0x4u;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M0 */
|
||||||
|
|
||||||
|
/* Initialize blkCnt with number of samples */
|
||||||
|
blkCnt = blockSize;
|
||||||
|
|
||||||
|
#endif /* #ifndef ARM_MATH_CM0_FAMILY */
|
||||||
|
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = |A| */
|
||||||
|
/* Calculate absolute and then store the results in the destination buffer. */
|
||||||
|
*pDst++ = fabsf(*pSrc++);
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @} end of BasicAbs group
|
||||||
|
*/
|
@ -0,0 +1,179 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
* Copyright (C) 2010-2014 ARM Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* $Date: 19. March 2015
|
||||||
|
* $Revision: V.1.4.5
|
||||||
|
*
|
||||||
|
* Project: CMSIS DSP Library
|
||||||
|
* Title: arm_abs_q15.c
|
||||||
|
*
|
||||||
|
* Description: Q15 vector absolute value.
|
||||||
|
*
|
||||||
|
* Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* - Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* - Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* - Neither the name of ARM LIMITED nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this
|
||||||
|
* software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#include "arm_math.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup groupMath
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup BasicAbs
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Q15 vector absolute value.
|
||||||
|
* @param[in] *pSrc points to the input buffer
|
||||||
|
* @param[out] *pDst points to the output buffer
|
||||||
|
* @param[in] blockSize number of samples in each vector
|
||||||
|
* @return none.
|
||||||
|
*
|
||||||
|
* <b>Scaling and Overflow Behavior:</b>
|
||||||
|
* \par
|
||||||
|
* The function uses saturating arithmetic.
|
||||||
|
* The Q15 value -1 (0x8000) will be saturated to the maximum allowable positive value 0x7FFF.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void arm_abs_q15(
|
||||||
|
q15_t * pSrc,
|
||||||
|
q15_t * pDst,
|
||||||
|
uint32_t blockSize)
|
||||||
|
{
|
||||||
|
uint32_t blkCnt; /* loop counter */
|
||||||
|
|
||||||
|
#ifndef ARM_MATH_CM0_FAMILY
|
||||||
|
__SIMD32_TYPE *simd;
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M4 and Cortex-M3 */
|
||||||
|
|
||||||
|
q15_t in1; /* Input value1 */
|
||||||
|
q15_t in2; /* Input value2 */
|
||||||
|
|
||||||
|
|
||||||
|
/*loop Unrolling */
|
||||||
|
blkCnt = blockSize >> 2u;
|
||||||
|
|
||||||
|
/* First part of the processing with loop unrolling. Compute 4 outputs at a time.
|
||||||
|
** a second loop below computes the remaining 1 to 3 samples. */
|
||||||
|
simd = __SIMD32_CONST(pDst);
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = |A| */
|
||||||
|
/* Read two inputs */
|
||||||
|
in1 = *pSrc++;
|
||||||
|
in2 = *pSrc++;
|
||||||
|
|
||||||
|
|
||||||
|
/* Store the Absolute result in the destination buffer by packing the two values, in a single cycle */
|
||||||
|
#ifndef ARM_MATH_BIG_ENDIAN
|
||||||
|
*simd++ =
|
||||||
|
__PKHBT(((in1 > 0) ? in1 : (q15_t)__QSUB16(0, in1)),
|
||||||
|
((in2 > 0) ? in2 : (q15_t)__QSUB16(0, in2)), 16);
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
|
||||||
|
*simd++ =
|
||||||
|
__PKHBT(((in2 > 0) ? in2 : (q15_t)__QSUB16(0, in2)),
|
||||||
|
((in1 > 0) ? in1 : (q15_t)__QSUB16(0, in1)), 16);
|
||||||
|
|
||||||
|
#endif /* #ifndef ARM_MATH_BIG_ENDIAN */
|
||||||
|
|
||||||
|
in1 = *pSrc++;
|
||||||
|
in2 = *pSrc++;
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef ARM_MATH_BIG_ENDIAN
|
||||||
|
|
||||||
|
*simd++ =
|
||||||
|
__PKHBT(((in1 > 0) ? in1 : (q15_t)__QSUB16(0, in1)),
|
||||||
|
((in2 > 0) ? in2 : (q15_t)__QSUB16(0, in2)), 16);
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
|
||||||
|
*simd++ =
|
||||||
|
__PKHBT(((in2 > 0) ? in2 : (q15_t)__QSUB16(0, in2)),
|
||||||
|
((in1 > 0) ? in1 : (q15_t)__QSUB16(0, in1)), 16);
|
||||||
|
|
||||||
|
#endif /* #ifndef ARM_MATH_BIG_ENDIAN */
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
pDst = (q15_t *)simd;
|
||||||
|
|
||||||
|
/* If the blockSize is not a multiple of 4, compute any remaining output samples here.
|
||||||
|
** No loop unrolling is used. */
|
||||||
|
blkCnt = blockSize % 0x4u;
|
||||||
|
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = |A| */
|
||||||
|
/* Read the input */
|
||||||
|
in1 = *pSrc++;
|
||||||
|
|
||||||
|
/* Calculate absolute value of input and then store the result in the destination buffer. */
|
||||||
|
*pDst++ = (in1 > 0) ? in1 : (q15_t)__QSUB16(0, in1);
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M0 */
|
||||||
|
|
||||||
|
q15_t in; /* Temporary input variable */
|
||||||
|
|
||||||
|
/* Initialize blkCnt with number of samples */
|
||||||
|
blkCnt = blockSize;
|
||||||
|
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = |A| */
|
||||||
|
/* Read the input */
|
||||||
|
in = *pSrc++;
|
||||||
|
|
||||||
|
/* Calculate absolute value of input and then store the result in the destination buffer. */
|
||||||
|
*pDst++ = (in > 0) ? in : ((in == (q15_t) 0x8000) ? 0x7fff : -in);
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* #ifndef ARM_MATH_CM0_FAMILY */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @} end of BasicAbs group
|
||||||
|
*/
|
@ -0,0 +1,130 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
* Copyright (C) 2010-2014 ARM Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* $Date: 19. March 2015
|
||||||
|
* $Revision: V.1.4.5
|
||||||
|
*
|
||||||
|
* Project: CMSIS DSP Library
|
||||||
|
* Title: arm_abs_q31.c
|
||||||
|
*
|
||||||
|
* Description: Q31 vector absolute value.
|
||||||
|
*
|
||||||
|
* Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* - Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* - Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* - Neither the name of ARM LIMITED nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this
|
||||||
|
* software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#include "arm_math.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup groupMath
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup BasicAbs
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Q31 vector absolute value.
|
||||||
|
* @param[in] *pSrc points to the input buffer
|
||||||
|
* @param[out] *pDst points to the output buffer
|
||||||
|
* @param[in] blockSize number of samples in each vector
|
||||||
|
* @return none.
|
||||||
|
*
|
||||||
|
* <b>Scaling and Overflow Behavior:</b>
|
||||||
|
* \par
|
||||||
|
* The function uses saturating arithmetic.
|
||||||
|
* The Q31 value -1 (0x80000000) will be saturated to the maximum allowable positive value 0x7FFFFFFF.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void arm_abs_q31(
|
||||||
|
q31_t * pSrc,
|
||||||
|
q31_t * pDst,
|
||||||
|
uint32_t blockSize)
|
||||||
|
{
|
||||||
|
uint32_t blkCnt; /* loop counter */
|
||||||
|
q31_t in; /* Input value */
|
||||||
|
|
||||||
|
#ifndef ARM_MATH_CM0_FAMILY
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M4 and Cortex-M3 */
|
||||||
|
q31_t in1, in2, in3, in4;
|
||||||
|
|
||||||
|
/*loop Unrolling */
|
||||||
|
blkCnt = blockSize >> 2u;
|
||||||
|
|
||||||
|
/* First part of the processing with loop unrolling. Compute 4 outputs at a time.
|
||||||
|
** a second loop below computes the remaining 1 to 3 samples. */
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = |A| */
|
||||||
|
/* Calculate absolute of input (if -1 then saturated to 0x7fffffff) and then store the results in the destination buffer. */
|
||||||
|
in1 = *pSrc++;
|
||||||
|
in2 = *pSrc++;
|
||||||
|
in3 = *pSrc++;
|
||||||
|
in4 = *pSrc++;
|
||||||
|
|
||||||
|
*pDst++ = (in1 > 0) ? in1 : (q31_t)__QSUB(0, in1);
|
||||||
|
*pDst++ = (in2 > 0) ? in2 : (q31_t)__QSUB(0, in2);
|
||||||
|
*pDst++ = (in3 > 0) ? in3 : (q31_t)__QSUB(0, in3);
|
||||||
|
*pDst++ = (in4 > 0) ? in4 : (q31_t)__QSUB(0, in4);
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the blockSize is not a multiple of 4, compute any remaining output samples here.
|
||||||
|
** No loop unrolling is used. */
|
||||||
|
blkCnt = blockSize % 0x4u;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M0 */
|
||||||
|
|
||||||
|
/* Initialize blkCnt with number of samples */
|
||||||
|
blkCnt = blockSize;
|
||||||
|
|
||||||
|
#endif /* #ifndef ARM_MATH_CM0_FAMILY */
|
||||||
|
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = |A| */
|
||||||
|
/* Calculate absolute value of the input (if -1 then saturated to 0x7fffffff) and then store the results in the destination buffer. */
|
||||||
|
in = *pSrc++;
|
||||||
|
*pDst++ = (in > 0) ? in : ((in == INT32_MIN) ? INT32_MAX : -in);
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @} end of BasicAbs group
|
||||||
|
*/
|
@ -0,0 +1,157 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
* Copyright (C) 2010-2014 ARM Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* $Date: 19. March 2015
|
||||||
|
* $Revision: V.1.4.5
|
||||||
|
*
|
||||||
|
* Project: CMSIS DSP Library
|
||||||
|
* Title: arm_abs_q7.c
|
||||||
|
*
|
||||||
|
* Description: Q7 vector absolute value.
|
||||||
|
*
|
||||||
|
* Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* - Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* - Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* - Neither the name of ARM LIMITED nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this
|
||||||
|
* software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#include "arm_math.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup groupMath
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup BasicAbs
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Q7 vector absolute value.
|
||||||
|
* @param[in] *pSrc points to the input buffer
|
||||||
|
* @param[out] *pDst points to the output buffer
|
||||||
|
* @param[in] blockSize number of samples in each vector
|
||||||
|
* @return none.
|
||||||
|
*
|
||||||
|
* \par Conditions for optimum performance
|
||||||
|
* Input and output buffers should be aligned by 32-bit
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* <b>Scaling and Overflow Behavior:</b>
|
||||||
|
* \par
|
||||||
|
* The function uses saturating arithmetic.
|
||||||
|
* The Q7 value -1 (0x80) will be saturated to the maximum allowable positive value 0x7F.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void arm_abs_q7(
|
||||||
|
q7_t * pSrc,
|
||||||
|
q7_t * pDst,
|
||||||
|
uint32_t blockSize)
|
||||||
|
{
|
||||||
|
uint32_t blkCnt; /* loop counter */
|
||||||
|
q7_t in; /* Input value1 */
|
||||||
|
|
||||||
|
#ifndef ARM_MATH_CM0_FAMILY
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M4 and Cortex-M3 */
|
||||||
|
q31_t in1, in2, in3, in4; /* temporary input variables */
|
||||||
|
q31_t out1, out2, out3, out4; /* temporary output variables */
|
||||||
|
|
||||||
|
/*loop Unrolling */
|
||||||
|
blkCnt = blockSize >> 2u;
|
||||||
|
|
||||||
|
/* First part of the processing with loop unrolling. Compute 4 outputs at a time.
|
||||||
|
** a second loop below computes the remaining 1 to 3 samples. */
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = |A| */
|
||||||
|
/* Read inputs */
|
||||||
|
in1 = (q31_t) * pSrc;
|
||||||
|
in2 = (q31_t) * (pSrc + 1);
|
||||||
|
in3 = (q31_t) * (pSrc + 2);
|
||||||
|
|
||||||
|
/* find absolute value */
|
||||||
|
out1 = (in1 > 0) ? in1 : (q31_t)__QSUB8(0, in1);
|
||||||
|
|
||||||
|
/* read input */
|
||||||
|
in4 = (q31_t) * (pSrc + 3);
|
||||||
|
|
||||||
|
/* find absolute value */
|
||||||
|
out2 = (in2 > 0) ? in2 : (q31_t)__QSUB8(0, in2);
|
||||||
|
|
||||||
|
/* store result to destination */
|
||||||
|
*pDst = (q7_t) out1;
|
||||||
|
|
||||||
|
/* find absolute value */
|
||||||
|
out3 = (in3 > 0) ? in3 : (q31_t)__QSUB8(0, in3);
|
||||||
|
|
||||||
|
/* find absolute value */
|
||||||
|
out4 = (in4 > 0) ? in4 : (q31_t)__QSUB8(0, in4);
|
||||||
|
|
||||||
|
/* store result to destination */
|
||||||
|
*(pDst + 1) = (q7_t) out2;
|
||||||
|
|
||||||
|
/* store result to destination */
|
||||||
|
*(pDst + 2) = (q7_t) out3;
|
||||||
|
|
||||||
|
/* store result to destination */
|
||||||
|
*(pDst + 3) = (q7_t) out4;
|
||||||
|
|
||||||
|
/* update pointers to process next samples */
|
||||||
|
pSrc += 4u;
|
||||||
|
pDst += 4u;
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the blockSize is not a multiple of 4, compute any remaining output samples here.
|
||||||
|
** No loop unrolling is used. */
|
||||||
|
blkCnt = blockSize % 0x4u;
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M0 */
|
||||||
|
blkCnt = blockSize;
|
||||||
|
|
||||||
|
#endif /* #define ARM_MATH_CM0_FAMILY */
|
||||||
|
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = |A| */
|
||||||
|
/* Read the input */
|
||||||
|
in = *pSrc++;
|
||||||
|
|
||||||
|
/* Store the Absolute result in the destination buffer */
|
||||||
|
*pDst++ = (in > 0) ? in : ((in == (q7_t) 0x80) ? 0x7f : -in);
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @} end of BasicAbs group
|
||||||
|
*/
|
@ -0,0 +1,150 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
* Copyright (C) 2010-2014 ARM Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* $Date: 19. March 2015
|
||||||
|
* $Revision: V.1.4.5
|
||||||
|
*
|
||||||
|
* Project: CMSIS DSP Library
|
||||||
|
* Title: arm_add_f32.c
|
||||||
|
*
|
||||||
|
* Description: Floating-point vector addition.
|
||||||
|
*
|
||||||
|
* Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* - Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* - Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* - Neither the name of ARM LIMITED nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this
|
||||||
|
* software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
* ---------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#include "arm_math.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup groupMath
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @defgroup BasicAdd Vector Addition
|
||||||
|
*
|
||||||
|
* Element-by-element addition of two vectors.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* pDst[n] = pSrcA[n] + pSrcB[n], 0 <= n < blockSize.
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* There are separate functions for floating-point, Q7, Q15, and Q31 data types.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup BasicAdd
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Floating-point vector addition.
|
||||||
|
* @param[in] *pSrcA points to the first input vector
|
||||||
|
* @param[in] *pSrcB points to the second input vector
|
||||||
|
* @param[out] *pDst points to the output vector
|
||||||
|
* @param[in] blockSize number of samples in each vector
|
||||||
|
* @return none.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void arm_add_f32(
|
||||||
|
float32_t * pSrcA,
|
||||||
|
float32_t * pSrcB,
|
||||||
|
float32_t * pDst,
|
||||||
|
uint32_t blockSize)
|
||||||
|
{
|
||||||
|
uint32_t blkCnt; /* loop counter */
|
||||||
|
|
||||||
|
#ifndef ARM_MATH_CM0_FAMILY
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M4 and Cortex-M3 */
|
||||||
|
float32_t inA1, inA2, inA3, inA4; /* temporary input variabels */
|
||||||
|
float32_t inB1, inB2, inB3, inB4; /* temporary input variables */
|
||||||
|
|
||||||
|
/*loop Unrolling */
|
||||||
|
blkCnt = blockSize >> 2u;
|
||||||
|
|
||||||
|
/* First part of the processing with loop unrolling. Compute 4 outputs at a time.
|
||||||
|
** a second loop below computes the remaining 1 to 3 samples. */
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = A + B */
|
||||||
|
/* Add and then store the results in the destination buffer. */
|
||||||
|
|
||||||
|
/* read four inputs from sourceA and four inputs from sourceB */
|
||||||
|
inA1 = *pSrcA;
|
||||||
|
inB1 = *pSrcB;
|
||||||
|
inA2 = *(pSrcA + 1);
|
||||||
|
inB2 = *(pSrcB + 1);
|
||||||
|
inA3 = *(pSrcA + 2);
|
||||||
|
inB3 = *(pSrcB + 2);
|
||||||
|
inA4 = *(pSrcA + 3);
|
||||||
|
inB4 = *(pSrcB + 3);
|
||||||
|
|
||||||
|
/* C = A + B */
|
||||||
|
/* add and store result to destination */
|
||||||
|
*pDst = inA1 + inB1;
|
||||||
|
*(pDst + 1) = inA2 + inB2;
|
||||||
|
*(pDst + 2) = inA3 + inB3;
|
||||||
|
*(pDst + 3) = inA4 + inB4;
|
||||||
|
|
||||||
|
/* update pointers to process next samples */
|
||||||
|
pSrcA += 4u;
|
||||||
|
pSrcB += 4u;
|
||||||
|
pDst += 4u;
|
||||||
|
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the blockSize is not a multiple of 4, compute any remaining output samples here.
|
||||||
|
** No loop unrolling is used. */
|
||||||
|
blkCnt = blockSize % 0x4u;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M0 */
|
||||||
|
|
||||||
|
/* Initialize blkCnt with number of samples */
|
||||||
|
blkCnt = blockSize;
|
||||||
|
|
||||||
|
#endif /* #ifndef ARM_MATH_CM0_FAMILY */
|
||||||
|
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = A + B */
|
||||||
|
/* Add and then store the results in the destination buffer. */
|
||||||
|
*pDst++ = (*pSrcA++) + (*pSrcB++);
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @} end of BasicAdd group
|
||||||
|
*/
|
@ -0,0 +1,140 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
* Copyright (C) 2010-2014 ARM Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* $Date: 19. March 2015
|
||||||
|
* $Revision: V.1.4.5
|
||||||
|
*
|
||||||
|
* Project: CMSIS DSP Library
|
||||||
|
* Title: arm_add_q15.c
|
||||||
|
*
|
||||||
|
* Description: Q15 vector addition
|
||||||
|
*
|
||||||
|
* Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* - Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* - Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* - Neither the name of ARM LIMITED nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this
|
||||||
|
* software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#include "arm_math.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup groupMath
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup BasicAdd
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Q15 vector addition.
|
||||||
|
* @param[in] *pSrcA points to the first input vector
|
||||||
|
* @param[in] *pSrcB points to the second input vector
|
||||||
|
* @param[out] *pDst points to the output vector
|
||||||
|
* @param[in] blockSize number of samples in each vector
|
||||||
|
* @return none.
|
||||||
|
*
|
||||||
|
* <b>Scaling and Overflow Behavior:</b>
|
||||||
|
* \par
|
||||||
|
* The function uses saturating arithmetic.
|
||||||
|
* Results outside of the allowable Q15 range [0x8000 0x7FFF] will be saturated.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void arm_add_q15(
|
||||||
|
q15_t * pSrcA,
|
||||||
|
q15_t * pSrcB,
|
||||||
|
q15_t * pDst,
|
||||||
|
uint32_t blockSize)
|
||||||
|
{
|
||||||
|
uint32_t blkCnt; /* loop counter */
|
||||||
|
|
||||||
|
#ifndef ARM_MATH_CM0_FAMILY
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M4 and Cortex-M3 */
|
||||||
|
q31_t inA1, inA2, inB1, inB2;
|
||||||
|
|
||||||
|
/*loop Unrolling */
|
||||||
|
blkCnt = blockSize >> 2u;
|
||||||
|
|
||||||
|
/* First part of the processing with loop unrolling. Compute 4 outputs at a time.
|
||||||
|
** a second loop below computes the remaining 1 to 3 samples. */
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = A + B */
|
||||||
|
/* Add and then store the results in the destination buffer. */
|
||||||
|
inA1 = *__SIMD32(pSrcA)++;
|
||||||
|
inA2 = *__SIMD32(pSrcA)++;
|
||||||
|
inB1 = *__SIMD32(pSrcB)++;
|
||||||
|
inB2 = *__SIMD32(pSrcB)++;
|
||||||
|
|
||||||
|
*__SIMD32(pDst)++ = __QADD16(inA1, inB1);
|
||||||
|
*__SIMD32(pDst)++ = __QADD16(inA2, inB2);
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the blockSize is not a multiple of 4, compute any remaining output samples here.
|
||||||
|
** No loop unrolling is used. */
|
||||||
|
blkCnt = blockSize % 0x4u;
|
||||||
|
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = A + B */
|
||||||
|
/* Add and then store the results in the destination buffer. */
|
||||||
|
*pDst++ = (q15_t) __QADD16(*pSrcA++, *pSrcB++);
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M0 */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Initialize blkCnt with number of samples */
|
||||||
|
blkCnt = blockSize;
|
||||||
|
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = A + B */
|
||||||
|
/* Add and then store the results in the destination buffer. */
|
||||||
|
*pDst++ = (q15_t) __SSAT(((q31_t) * pSrcA++ + *pSrcB++), 16);
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* #ifndef ARM_MATH_CM0_FAMILY */
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @} end of BasicAdd group
|
||||||
|
*/
|
@ -0,0 +1,148 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
* Copyright (C) 2010-2014 ARM Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* $Date: 19. March 2015
|
||||||
|
* $Revision: V.1.4.5
|
||||||
|
*
|
||||||
|
* Project: CMSIS DSP Library
|
||||||
|
* Title: arm_add_q31.c
|
||||||
|
*
|
||||||
|
* Description: Q31 vector addition.
|
||||||
|
*
|
||||||
|
* Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* - Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* - Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* - Neither the name of ARM LIMITED nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this
|
||||||
|
* software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#include "arm_math.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup groupMath
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup BasicAdd
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Q31 vector addition.
|
||||||
|
* @param[in] *pSrcA points to the first input vector
|
||||||
|
* @param[in] *pSrcB points to the second input vector
|
||||||
|
* @param[out] *pDst points to the output vector
|
||||||
|
* @param[in] blockSize number of samples in each vector
|
||||||
|
* @return none.
|
||||||
|
*
|
||||||
|
* <b>Scaling and Overflow Behavior:</b>
|
||||||
|
* \par
|
||||||
|
* The function uses saturating arithmetic.
|
||||||
|
* Results outside of the allowable Q31 range[0x80000000 0x7FFFFFFF] will be saturated.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void arm_add_q31(
|
||||||
|
q31_t * pSrcA,
|
||||||
|
q31_t * pSrcB,
|
||||||
|
q31_t * pDst,
|
||||||
|
uint32_t blockSize)
|
||||||
|
{
|
||||||
|
uint32_t blkCnt; /* loop counter */
|
||||||
|
|
||||||
|
#ifndef ARM_MATH_CM0_FAMILY
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M4 and Cortex-M3 */
|
||||||
|
q31_t inA1, inA2, inA3, inA4;
|
||||||
|
q31_t inB1, inB2, inB3, inB4;
|
||||||
|
|
||||||
|
/*loop Unrolling */
|
||||||
|
blkCnt = blockSize >> 2u;
|
||||||
|
|
||||||
|
/* First part of the processing with loop unrolling. Compute 4 outputs at a time.
|
||||||
|
** a second loop below computes the remaining 1 to 3 samples. */
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = A + B */
|
||||||
|
/* Add and then store the results in the destination buffer. */
|
||||||
|
inA1 = *pSrcA++;
|
||||||
|
inA2 = *pSrcA++;
|
||||||
|
inB1 = *pSrcB++;
|
||||||
|
inB2 = *pSrcB++;
|
||||||
|
|
||||||
|
inA3 = *pSrcA++;
|
||||||
|
inA4 = *pSrcA++;
|
||||||
|
inB3 = *pSrcB++;
|
||||||
|
inB4 = *pSrcB++;
|
||||||
|
|
||||||
|
*pDst++ = __QADD(inA1, inB1);
|
||||||
|
*pDst++ = __QADD(inA2, inB2);
|
||||||
|
*pDst++ = __QADD(inA3, inB3);
|
||||||
|
*pDst++ = __QADD(inA4, inB4);
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the blockSize is not a multiple of 4, compute any remaining output samples here.
|
||||||
|
** No loop unrolling is used. */
|
||||||
|
blkCnt = blockSize % 0x4u;
|
||||||
|
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = A + B */
|
||||||
|
/* Add and then store the results in the destination buffer. */
|
||||||
|
*pDst++ = __QADD(*pSrcA++, *pSrcB++);
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M0 */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Initialize blkCnt with number of samples */
|
||||||
|
blkCnt = blockSize;
|
||||||
|
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = A + B */
|
||||||
|
/* Add and then store the results in the destination buffer. */
|
||||||
|
*pDst++ = (q31_t) clip_q63_to_q31((q63_t) * pSrcA++ + *pSrcB++);
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* #ifndef ARM_MATH_CM0_FAMILY */
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @} end of BasicAdd group
|
||||||
|
*/
|
@ -0,0 +1,134 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
* Copyright (C) 2010-2014 ARM Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* $Date: 19. March 2015
|
||||||
|
* $Revision: V.1.4.5
|
||||||
|
*
|
||||||
|
* Project: CMSIS DSP Library
|
||||||
|
* Title: arm_add_q7.c
|
||||||
|
*
|
||||||
|
* Description: Q7 vector addition.
|
||||||
|
*
|
||||||
|
* Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* - Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* - Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* - Neither the name of ARM LIMITED nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this
|
||||||
|
* software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#include "arm_math.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup groupMath
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup BasicAdd
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Q7 vector addition.
|
||||||
|
* @param[in] *pSrcA points to the first input vector
|
||||||
|
* @param[in] *pSrcB points to the second input vector
|
||||||
|
* @param[out] *pDst points to the output vector
|
||||||
|
* @param[in] blockSize number of samples in each vector
|
||||||
|
* @return none.
|
||||||
|
*
|
||||||
|
* <b>Scaling and Overflow Behavior:</b>
|
||||||
|
* \par
|
||||||
|
* The function uses saturating arithmetic.
|
||||||
|
* Results outside of the allowable Q7 range [0x80 0x7F] will be saturated.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void arm_add_q7(
|
||||||
|
q7_t * pSrcA,
|
||||||
|
q7_t * pSrcB,
|
||||||
|
q7_t * pDst,
|
||||||
|
uint32_t blockSize)
|
||||||
|
{
|
||||||
|
uint32_t blkCnt; /* loop counter */
|
||||||
|
|
||||||
|
#ifndef ARM_MATH_CM0_FAMILY
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M4 and Cortex-M3 */
|
||||||
|
|
||||||
|
|
||||||
|
/*loop Unrolling */
|
||||||
|
blkCnt = blockSize >> 2u;
|
||||||
|
|
||||||
|
/* First part of the processing with loop unrolling. Compute 4 outputs at a time.
|
||||||
|
** a second loop below computes the remaining 1 to 3 samples. */
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = A + B */
|
||||||
|
/* Add and then store the results in the destination buffer. */
|
||||||
|
*__SIMD32(pDst)++ = __QADD8(*__SIMD32(pSrcA)++, *__SIMD32(pSrcB)++);
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the blockSize is not a multiple of 4, compute any remaining output samples here.
|
||||||
|
** No loop unrolling is used. */
|
||||||
|
blkCnt = blockSize % 0x4u;
|
||||||
|
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = A + B */
|
||||||
|
/* Add and then store the results in the destination buffer. */
|
||||||
|
*pDst++ = (q7_t) __SSAT(*pSrcA++ + *pSrcB++, 8);
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M0 */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Initialize blkCnt with number of samples */
|
||||||
|
blkCnt = blockSize;
|
||||||
|
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = A + B */
|
||||||
|
/* Add and then store the results in the destination buffer. */
|
||||||
|
*pDst++ = (q7_t) __SSAT((q15_t) * pSrcA++ + *pSrcB++, 8);
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* #ifndef ARM_MATH_CM0_FAMILY */
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @} end of BasicAdd group
|
||||||
|
*/
|
@ -0,0 +1,135 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
* Copyright (C) 2010-2014 ARM Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* $Date: 19. March 2015
|
||||||
|
* $Revision: V.1.4.5
|
||||||
|
*
|
||||||
|
* Project: CMSIS DSP Library
|
||||||
|
* Title: arm_dot_prod_f32.c
|
||||||
|
*
|
||||||
|
* Description: Floating-point dot product.
|
||||||
|
*
|
||||||
|
* Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* - Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* - Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* - Neither the name of ARM LIMITED nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this
|
||||||
|
* software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
* ---------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#include "arm_math.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup groupMath
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @defgroup dot_prod Vector Dot Product
|
||||||
|
*
|
||||||
|
* Computes the dot product of two vectors.
|
||||||
|
* The vectors are multiplied element-by-element and then summed.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* sum = pSrcA[0]*pSrcB[0] + pSrcA[1]*pSrcB[1] + ... + pSrcA[blockSize-1]*pSrcB[blockSize-1]
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* There are separate functions for floating-point, Q7, Q15, and Q31 data types.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup dot_prod
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dot product of floating-point vectors.
|
||||||
|
* @param[in] *pSrcA points to the first input vector
|
||||||
|
* @param[in] *pSrcB points to the second input vector
|
||||||
|
* @param[in] blockSize number of samples in each vector
|
||||||
|
* @param[out] *result output result returned here
|
||||||
|
* @return none.
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
void arm_dot_prod_f32(
|
||||||
|
float32_t * pSrcA,
|
||||||
|
float32_t * pSrcB,
|
||||||
|
uint32_t blockSize,
|
||||||
|
float32_t * result)
|
||||||
|
{
|
||||||
|
float32_t sum = 0.0f; /* Temporary result storage */
|
||||||
|
uint32_t blkCnt; /* loop counter */
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef ARM_MATH_CM0_FAMILY
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M4 and Cortex-M3 */
|
||||||
|
/*loop Unrolling */
|
||||||
|
blkCnt = blockSize >> 2u;
|
||||||
|
|
||||||
|
/* First part of the processing with loop unrolling. Compute 4 outputs at a time.
|
||||||
|
** a second loop below computes the remaining 1 to 3 samples. */
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = A[0]* B[0] + A[1]* B[1] + A[2]* B[2] + .....+ A[blockSize-1]* B[blockSize-1] */
|
||||||
|
/* Calculate dot product and then store the result in a temporary buffer */
|
||||||
|
sum += (*pSrcA++) * (*pSrcB++);
|
||||||
|
sum += (*pSrcA++) * (*pSrcB++);
|
||||||
|
sum += (*pSrcA++) * (*pSrcB++);
|
||||||
|
sum += (*pSrcA++) * (*pSrcB++);
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the blockSize is not a multiple of 4, compute any remaining output samples here.
|
||||||
|
** No loop unrolling is used. */
|
||||||
|
blkCnt = blockSize % 0x4u;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M0 */
|
||||||
|
|
||||||
|
/* Initialize blkCnt with number of samples */
|
||||||
|
blkCnt = blockSize;
|
||||||
|
|
||||||
|
#endif /* #ifndef ARM_MATH_CM0_FAMILY */
|
||||||
|
|
||||||
|
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = A[0]* B[0] + A[1]* B[1] + A[2]* B[2] + .....+ A[blockSize-1]* B[blockSize-1] */
|
||||||
|
/* Calculate dot product and then store the result in a temporary buffer. */
|
||||||
|
sum += (*pSrcA++) * (*pSrcB++);
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
/* Store the result back in the destination buffer */
|
||||||
|
*result = sum;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @} end of dot_prod group
|
||||||
|
*/
|
@ -0,0 +1,140 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
* Copyright (C) 2010-2014 ARM Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* $Date: 19. March 2015
|
||||||
|
* $Revision: V.1.4.5
|
||||||
|
*
|
||||||
|
* Project: CMSIS DSP Library
|
||||||
|
* Title: arm_dot_prod_q15.c
|
||||||
|
*
|
||||||
|
* Description: Q15 dot product.
|
||||||
|
*
|
||||||
|
* Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* - Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* - Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* - Neither the name of ARM LIMITED nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this
|
||||||
|
* software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#include "arm_math.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup groupMath
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup dot_prod
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dot product of Q15 vectors.
|
||||||
|
* @param[in] *pSrcA points to the first input vector
|
||||||
|
* @param[in] *pSrcB points to the second input vector
|
||||||
|
* @param[in] blockSize number of samples in each vector
|
||||||
|
* @param[out] *result output result returned here
|
||||||
|
* @return none.
|
||||||
|
*
|
||||||
|
* <b>Scaling and Overflow Behavior:</b>
|
||||||
|
* \par
|
||||||
|
* The intermediate multiplications are in 1.15 x 1.15 = 2.30 format and these
|
||||||
|
* results are added to a 64-bit accumulator in 34.30 format.
|
||||||
|
* Nonsaturating additions are used and given that there are 33 guard bits in the accumulator
|
||||||
|
* there is no risk of overflow.
|
||||||
|
* The return result is in 34.30 format.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void arm_dot_prod_q15(
|
||||||
|
q15_t * pSrcA,
|
||||||
|
q15_t * pSrcB,
|
||||||
|
uint32_t blockSize,
|
||||||
|
q63_t * result)
|
||||||
|
{
|
||||||
|
q63_t sum = 0; /* Temporary result storage */
|
||||||
|
uint32_t blkCnt; /* loop counter */
|
||||||
|
|
||||||
|
#ifndef ARM_MATH_CM0_FAMILY
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M4 and Cortex-M3 */
|
||||||
|
|
||||||
|
|
||||||
|
/*loop Unrolling */
|
||||||
|
blkCnt = blockSize >> 2u;
|
||||||
|
|
||||||
|
/* First part of the processing with loop unrolling. Compute 4 outputs at a time.
|
||||||
|
** a second loop below computes the remaining 1 to 3 samples. */
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = A[0]* B[0] + A[1]* B[1] + A[2]* B[2] + .....+ A[blockSize-1]* B[blockSize-1] */
|
||||||
|
/* Calculate dot product and then store the result in a temporary buffer. */
|
||||||
|
sum = __SMLALD(*__SIMD32(pSrcA)++, *__SIMD32(pSrcB)++, sum);
|
||||||
|
sum = __SMLALD(*__SIMD32(pSrcA)++, *__SIMD32(pSrcB)++, sum);
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the blockSize is not a multiple of 4, compute any remaining output samples here.
|
||||||
|
** No loop unrolling is used. */
|
||||||
|
blkCnt = blockSize % 0x4u;
|
||||||
|
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = A[0]* B[0] + A[1]* B[1] + A[2]* B[2] + .....+ A[blockSize-1]* B[blockSize-1] */
|
||||||
|
/* Calculate dot product and then store the results in a temporary buffer. */
|
||||||
|
sum = __SMLALD(*pSrcA++, *pSrcB++, sum);
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M0 */
|
||||||
|
|
||||||
|
/* Initialize blkCnt with number of samples */
|
||||||
|
blkCnt = blockSize;
|
||||||
|
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = A[0]* B[0] + A[1]* B[1] + A[2]* B[2] + .....+ A[blockSize-1]* B[blockSize-1] */
|
||||||
|
/* Calculate dot product and then store the results in a temporary buffer. */
|
||||||
|
sum += (q63_t) ((q31_t) * pSrcA++ * *pSrcB++);
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* #ifndef ARM_MATH_CM0_FAMILY */
|
||||||
|
|
||||||
|
/* Store the result in the destination buffer in 34.30 format */
|
||||||
|
*result = sum;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @} end of dot_prod group
|
||||||
|
*/
|
@ -0,0 +1,143 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
* Copyright (C) 2010-2014 ARM Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* $Date: 19. March 2015
|
||||||
|
* $Revision: V.1.4.5
|
||||||
|
*
|
||||||
|
* Project: CMSIS DSP Library
|
||||||
|
* Title: arm_dot_prod_q31.c
|
||||||
|
*
|
||||||
|
* Description: Q31 dot product.
|
||||||
|
*
|
||||||
|
* Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* - Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* - Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* - Neither the name of ARM LIMITED nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this
|
||||||
|
* software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#include "arm_math.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup groupMath
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup dot_prod
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dot product of Q31 vectors.
|
||||||
|
* @param[in] *pSrcA points to the first input vector
|
||||||
|
* @param[in] *pSrcB points to the second input vector
|
||||||
|
* @param[in] blockSize number of samples in each vector
|
||||||
|
* @param[out] *result output result returned here
|
||||||
|
* @return none.
|
||||||
|
*
|
||||||
|
* <b>Scaling and Overflow Behavior:</b>
|
||||||
|
* \par
|
||||||
|
* The intermediate multiplications are in 1.31 x 1.31 = 2.62 format and these
|
||||||
|
* are truncated to 2.48 format by discarding the lower 14 bits.
|
||||||
|
* The 2.48 result is then added without saturation to a 64-bit accumulator in 16.48 format.
|
||||||
|
* There are 15 guard bits in the accumulator and there is no risk of overflow as long as
|
||||||
|
* the length of the vectors is less than 2^16 elements.
|
||||||
|
* The return result is in 16.48 format.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void arm_dot_prod_q31(
|
||||||
|
q31_t * pSrcA,
|
||||||
|
q31_t * pSrcB,
|
||||||
|
uint32_t blockSize,
|
||||||
|
q63_t * result)
|
||||||
|
{
|
||||||
|
q63_t sum = 0; /* Temporary result storage */
|
||||||
|
uint32_t blkCnt; /* loop counter */
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef ARM_MATH_CM0_FAMILY
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M4 and Cortex-M3 */
|
||||||
|
q31_t inA1, inA2, inA3, inA4;
|
||||||
|
q31_t inB1, inB2, inB3, inB4;
|
||||||
|
|
||||||
|
/*loop Unrolling */
|
||||||
|
blkCnt = blockSize >> 2u;
|
||||||
|
|
||||||
|
/* First part of the processing with loop unrolling. Compute 4 outputs at a time.
|
||||||
|
** a second loop below computes the remaining 1 to 3 samples. */
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = A[0]* B[0] + A[1]* B[1] + A[2]* B[2] + .....+ A[blockSize-1]* B[blockSize-1] */
|
||||||
|
/* Calculate dot product and then store the result in a temporary buffer. */
|
||||||
|
inA1 = *pSrcA++;
|
||||||
|
inA2 = *pSrcA++;
|
||||||
|
inA3 = *pSrcA++;
|
||||||
|
inA4 = *pSrcA++;
|
||||||
|
inB1 = *pSrcB++;
|
||||||
|
inB2 = *pSrcB++;
|
||||||
|
inB3 = *pSrcB++;
|
||||||
|
inB4 = *pSrcB++;
|
||||||
|
|
||||||
|
sum += ((q63_t) inA1 * inB1) >> 14u;
|
||||||
|
sum += ((q63_t) inA2 * inB2) >> 14u;
|
||||||
|
sum += ((q63_t) inA3 * inB3) >> 14u;
|
||||||
|
sum += ((q63_t) inA4 * inB4) >> 14u;
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the blockSize is not a multiple of 4, compute any remaining output samples here.
|
||||||
|
** No loop unrolling is used. */
|
||||||
|
blkCnt = blockSize % 0x4u;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M0 */
|
||||||
|
|
||||||
|
/* Initialize blkCnt with number of samples */
|
||||||
|
blkCnt = blockSize;
|
||||||
|
|
||||||
|
#endif /* #ifndef ARM_MATH_CM0_FAMILY */
|
||||||
|
|
||||||
|
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = A[0]* B[0] + A[1]* B[1] + A[2]* B[2] + .....+ A[blockSize-1]* B[blockSize-1] */
|
||||||
|
/* Calculate dot product and then store the result in a temporary buffer. */
|
||||||
|
sum += ((q63_t) * pSrcA++ * *pSrcB++) >> 14u;
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Store the result in the destination buffer in 16.48 format */
|
||||||
|
*result = sum;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @} end of dot_prod group
|
||||||
|
*/
|
@ -0,0 +1,159 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
* Copyright (C) 2010-2014 ARM Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* $Date: 19. March 2015
|
||||||
|
* $Revision: V.1.4.5
|
||||||
|
*
|
||||||
|
* Project: CMSIS DSP Library
|
||||||
|
* Title: arm_dot_prod_q7.c
|
||||||
|
*
|
||||||
|
* Description: Q7 dot product.
|
||||||
|
*
|
||||||
|
* Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* - Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* - Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* - Neither the name of ARM LIMITED nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this
|
||||||
|
* software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#include "arm_math.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup groupMath
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup dot_prod
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Dot product of Q7 vectors.
|
||||||
|
* @param[in] *pSrcA points to the first input vector
|
||||||
|
* @param[in] *pSrcB points to the second input vector
|
||||||
|
* @param[in] blockSize number of samples in each vector
|
||||||
|
* @param[out] *result output result returned here
|
||||||
|
* @return none.
|
||||||
|
*
|
||||||
|
* <b>Scaling and Overflow Behavior:</b>
|
||||||
|
* \par
|
||||||
|
* The intermediate multiplications are in 1.7 x 1.7 = 2.14 format and these
|
||||||
|
* results are added to an accumulator in 18.14 format.
|
||||||
|
* Nonsaturating additions are used and there is no danger of wrap around as long as
|
||||||
|
* the vectors are less than 2^18 elements long.
|
||||||
|
* The return result is in 18.14 format.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void arm_dot_prod_q7(
|
||||||
|
q7_t * pSrcA,
|
||||||
|
q7_t * pSrcB,
|
||||||
|
uint32_t blockSize,
|
||||||
|
q31_t * result)
|
||||||
|
{
|
||||||
|
uint32_t blkCnt; /* loop counter */
|
||||||
|
|
||||||
|
q31_t sum = 0; /* Temporary variables to store output */
|
||||||
|
|
||||||
|
#ifndef ARM_MATH_CM0_FAMILY
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M4 and Cortex-M3 */
|
||||||
|
|
||||||
|
q31_t input1, input2; /* Temporary variables to store input */
|
||||||
|
q31_t inA1, inA2, inB1, inB2; /* Temporary variables to store input */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*loop Unrolling */
|
||||||
|
blkCnt = blockSize >> 2u;
|
||||||
|
|
||||||
|
/* First part of the processing with loop unrolling. Compute 4 outputs at a time.
|
||||||
|
** a second loop below computes the remaining 1 to 3 samples. */
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* read 4 samples at a time from sourceA */
|
||||||
|
input1 = *__SIMD32(pSrcA)++;
|
||||||
|
/* read 4 samples at a time from sourceB */
|
||||||
|
input2 = *__SIMD32(pSrcB)++;
|
||||||
|
|
||||||
|
/* extract two q7_t samples to q15_t samples */
|
||||||
|
inA1 = __SXTB16(__ROR(input1, 8));
|
||||||
|
/* extract reminaing two samples */
|
||||||
|
inA2 = __SXTB16(input1);
|
||||||
|
/* extract two q7_t samples to q15_t samples */
|
||||||
|
inB1 = __SXTB16(__ROR(input2, 8));
|
||||||
|
/* extract reminaing two samples */
|
||||||
|
inB2 = __SXTB16(input2);
|
||||||
|
|
||||||
|
/* multiply and accumulate two samples at a time */
|
||||||
|
sum = __SMLAD(inA1, inB1, sum);
|
||||||
|
sum = __SMLAD(inA2, inB2, sum);
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the blockSize is not a multiple of 4, compute any remaining output samples here.
|
||||||
|
** No loop unrolling is used. */
|
||||||
|
blkCnt = blockSize % 0x4u;
|
||||||
|
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = A[0]* B[0] + A[1]* B[1] + A[2]* B[2] + .....+ A[blockSize-1]* B[blockSize-1] */
|
||||||
|
/* Dot product and then store the results in a temporary buffer. */
|
||||||
|
sum = __SMLAD(*pSrcA++, *pSrcB++, sum);
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M0 */
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/* Initialize blkCnt with number of samples */
|
||||||
|
blkCnt = blockSize;
|
||||||
|
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = A[0]* B[0] + A[1]* B[1] + A[2]* B[2] + .....+ A[blockSize-1]* B[blockSize-1] */
|
||||||
|
/* Dot product and then store the results in a temporary buffer. */
|
||||||
|
sum += (q31_t) ((q15_t) * pSrcA++ * *pSrcB++);
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* #ifndef ARM_MATH_CM0_FAMILY */
|
||||||
|
|
||||||
|
|
||||||
|
/* Store the result in the destination buffer in 18.14 format */
|
||||||
|
*result = sum;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @} end of dot_prod group
|
||||||
|
*/
|
@ -0,0 +1,174 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
* Copyright (C) 2010-2014 ARM Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* $Date: 19. March 2015
|
||||||
|
* $Revision: V.1.4.5
|
||||||
|
*
|
||||||
|
* Project: CMSIS DSP Library
|
||||||
|
* Title: arm_mult_f32.c
|
||||||
|
*
|
||||||
|
* Description: Floating-point vector multiplication.
|
||||||
|
*
|
||||||
|
* Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* - Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* - Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* - Neither the name of ARM LIMITED nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this
|
||||||
|
* software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#include "arm_math.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup groupMath
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @defgroup BasicMult Vector Multiplication
|
||||||
|
*
|
||||||
|
* Element-by-element multiplication of two vectors.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* pDst[n] = pSrcA[n] * pSrcB[n], 0 <= n < blockSize.
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* There are separate functions for floating-point, Q7, Q15, and Q31 data types.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup BasicMult
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Floating-point vector multiplication.
|
||||||
|
* @param[in] *pSrcA points to the first input vector
|
||||||
|
* @param[in] *pSrcB points to the second input vector
|
||||||
|
* @param[out] *pDst points to the output vector
|
||||||
|
* @param[in] blockSize number of samples in each vector
|
||||||
|
* @return none.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void arm_mult_f32(
|
||||||
|
float32_t * pSrcA,
|
||||||
|
float32_t * pSrcB,
|
||||||
|
float32_t * pDst,
|
||||||
|
uint32_t blockSize)
|
||||||
|
{
|
||||||
|
uint32_t blkCnt; /* loop counters */
|
||||||
|
#ifndef ARM_MATH_CM0_FAMILY
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M4 and Cortex-M3 */
|
||||||
|
float32_t inA1, inA2, inA3, inA4; /* temporary input variables */
|
||||||
|
float32_t inB1, inB2, inB3, inB4; /* temporary input variables */
|
||||||
|
float32_t out1, out2, out3, out4; /* temporary output variables */
|
||||||
|
|
||||||
|
/* loop Unrolling */
|
||||||
|
blkCnt = blockSize >> 2u;
|
||||||
|
|
||||||
|
/* First part of the processing with loop unrolling. Compute 4 outputs at a time.
|
||||||
|
** a second loop below computes the remaining 1 to 3 samples. */
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = A * B */
|
||||||
|
/* Multiply the inputs and store the results in output buffer */
|
||||||
|
/* read sample from sourceA */
|
||||||
|
inA1 = *pSrcA;
|
||||||
|
/* read sample from sourceB */
|
||||||
|
inB1 = *pSrcB;
|
||||||
|
/* read sample from sourceA */
|
||||||
|
inA2 = *(pSrcA + 1);
|
||||||
|
/* read sample from sourceB */
|
||||||
|
inB2 = *(pSrcB + 1);
|
||||||
|
|
||||||
|
/* out = sourceA * sourceB */
|
||||||
|
out1 = inA1 * inB1;
|
||||||
|
|
||||||
|
/* read sample from sourceA */
|
||||||
|
inA3 = *(pSrcA + 2);
|
||||||
|
/* read sample from sourceB */
|
||||||
|
inB3 = *(pSrcB + 2);
|
||||||
|
|
||||||
|
/* out = sourceA * sourceB */
|
||||||
|
out2 = inA2 * inB2;
|
||||||
|
|
||||||
|
/* read sample from sourceA */
|
||||||
|
inA4 = *(pSrcA + 3);
|
||||||
|
|
||||||
|
/* store result to destination buffer */
|
||||||
|
*pDst = out1;
|
||||||
|
|
||||||
|
/* read sample from sourceB */
|
||||||
|
inB4 = *(pSrcB + 3);
|
||||||
|
|
||||||
|
/* out = sourceA * sourceB */
|
||||||
|
out3 = inA3 * inB3;
|
||||||
|
|
||||||
|
/* store result to destination buffer */
|
||||||
|
*(pDst + 1) = out2;
|
||||||
|
|
||||||
|
/* out = sourceA * sourceB */
|
||||||
|
out4 = inA4 * inB4;
|
||||||
|
/* store result to destination buffer */
|
||||||
|
*(pDst + 2) = out3;
|
||||||
|
/* store result to destination buffer */
|
||||||
|
*(pDst + 3) = out4;
|
||||||
|
|
||||||
|
|
||||||
|
/* update pointers to process next samples */
|
||||||
|
pSrcA += 4u;
|
||||||
|
pSrcB += 4u;
|
||||||
|
pDst += 4u;
|
||||||
|
|
||||||
|
/* Decrement the blockSize loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the blockSize is not a multiple of 4, compute any remaining output samples here.
|
||||||
|
** No loop unrolling is used. */
|
||||||
|
blkCnt = blockSize % 0x4u;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M0 */
|
||||||
|
|
||||||
|
/* Initialize blkCnt with number of samples */
|
||||||
|
blkCnt = blockSize;
|
||||||
|
|
||||||
|
#endif /* #ifndef ARM_MATH_CM0_FAMILY */
|
||||||
|
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = A * B */
|
||||||
|
/* Multiply the inputs and store the results in output buffer */
|
||||||
|
*pDst++ = (*pSrcA++) * (*pSrcB++);
|
||||||
|
|
||||||
|
/* Decrement the blockSize loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @} end of BasicMult group
|
||||||
|
*/
|
@ -0,0 +1,154 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
* Copyright (C) 2010-2014 ARM Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* $Date: 19. October 2015
|
||||||
|
* $Revision: V.1.4.5 a
|
||||||
|
*
|
||||||
|
* Project: CMSIS DSP Library
|
||||||
|
* Title: arm_mult_q15.c
|
||||||
|
*
|
||||||
|
* Description: Q15 vector multiplication.
|
||||||
|
*
|
||||||
|
* Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* - Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* - Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* - Neither the name of ARM LIMITED nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this
|
||||||
|
* software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#include "arm_math.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup groupMath
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup BasicMult
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Q15 vector multiplication
|
||||||
|
* @param[in] *pSrcA points to the first input vector
|
||||||
|
* @param[in] *pSrcB points to the second input vector
|
||||||
|
* @param[out] *pDst points to the output vector
|
||||||
|
* @param[in] blockSize number of samples in each vector
|
||||||
|
* @return none.
|
||||||
|
*
|
||||||
|
* <b>Scaling and Overflow Behavior:</b>
|
||||||
|
* \par
|
||||||
|
* The function uses saturating arithmetic.
|
||||||
|
* Results outside of the allowable Q15 range [0x8000 0x7FFF] will be saturated.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void arm_mult_q15(
|
||||||
|
q15_t * pSrcA,
|
||||||
|
q15_t * pSrcB,
|
||||||
|
q15_t * pDst,
|
||||||
|
uint32_t blockSize)
|
||||||
|
{
|
||||||
|
uint32_t blkCnt; /* loop counters */
|
||||||
|
|
||||||
|
#ifndef ARM_MATH_CM0_FAMILY
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M4 and Cortex-M3 */
|
||||||
|
q31_t inA1, inA2, inB1, inB2; /* temporary input variables */
|
||||||
|
q15_t out1, out2, out3, out4; /* temporary output variables */
|
||||||
|
q31_t mul1, mul2, mul3, mul4; /* temporary variables */
|
||||||
|
|
||||||
|
/* loop Unrolling */
|
||||||
|
blkCnt = blockSize >> 2u;
|
||||||
|
|
||||||
|
/* First part of the processing with loop unrolling. Compute 4 outputs at a time.
|
||||||
|
** a second loop below computes the remaining 1 to 3 samples. */
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* read two samples at a time from sourceA */
|
||||||
|
inA1 = *__SIMD32(pSrcA)++;
|
||||||
|
/* read two samples at a time from sourceB */
|
||||||
|
inB1 = *__SIMD32(pSrcB)++;
|
||||||
|
/* read two samples at a time from sourceA */
|
||||||
|
inA2 = *__SIMD32(pSrcA)++;
|
||||||
|
/* read two samples at a time from sourceB */
|
||||||
|
inB2 = *__SIMD32(pSrcB)++;
|
||||||
|
|
||||||
|
/* multiply mul = sourceA * sourceB */
|
||||||
|
mul1 = (q31_t) ((q15_t) (inA1 >> 16) * (q15_t) (inB1 >> 16));
|
||||||
|
mul2 = (q31_t) ((q15_t) inA1 * (q15_t) inB1);
|
||||||
|
mul3 = (q31_t) ((q15_t) (inA2 >> 16) * (q15_t) (inB2 >> 16));
|
||||||
|
mul4 = (q31_t) ((q15_t) inA2 * (q15_t) inB2);
|
||||||
|
|
||||||
|
/* saturate result to 16 bit */
|
||||||
|
out1 = (q15_t) __SSAT(mul1 >> 15, 16);
|
||||||
|
out2 = (q15_t) __SSAT(mul2 >> 15, 16);
|
||||||
|
out3 = (q15_t) __SSAT(mul3 >> 15, 16);
|
||||||
|
out4 = (q15_t) __SSAT(mul4 >> 15, 16);
|
||||||
|
|
||||||
|
/* store the result */
|
||||||
|
#ifndef ARM_MATH_BIG_ENDIAN
|
||||||
|
|
||||||
|
*__SIMD32(pDst)++ = __PKHBT(out2, out1, 16);
|
||||||
|
*__SIMD32(pDst)++ = __PKHBT(out4, out3, 16);
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
*__SIMD32(pDst)++ = __PKHBT(out2, out1, 16);
|
||||||
|
*__SIMD32(pDst)++ = __PKHBT(out4, out3, 16);
|
||||||
|
|
||||||
|
#endif /* #ifndef ARM_MATH_BIG_ENDIAN */
|
||||||
|
|
||||||
|
/* Decrement the blockSize loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the blockSize is not a multiple of 4, compute any remaining output samples here.
|
||||||
|
** No loop unrolling is used. */
|
||||||
|
blkCnt = blockSize % 0x4u;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M0 */
|
||||||
|
|
||||||
|
/* Initialize blkCnt with number of samples */
|
||||||
|
blkCnt = blockSize;
|
||||||
|
|
||||||
|
#endif /* #ifndef ARM_MATH_CM0_FAMILY */
|
||||||
|
|
||||||
|
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = A * B */
|
||||||
|
/* Multiply the inputs and store the result in the destination buffer */
|
||||||
|
*pDst++ = (q15_t) __SSAT((((q31_t) (*pSrcA++) * (*pSrcB++)) >> 15), 16);
|
||||||
|
|
||||||
|
/* Decrement the blockSize loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @} end of BasicMult group
|
||||||
|
*/
|
@ -0,0 +1,160 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
* Copyright (C) 2010-2014 ARM Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* $Date: 19. March 2015
|
||||||
|
* $Revision: V.1.4.5
|
||||||
|
*
|
||||||
|
* Project: CMSIS DSP Library
|
||||||
|
* Title: arm_mult_q31.c
|
||||||
|
*
|
||||||
|
* Description: Q31 vector multiplication.
|
||||||
|
*
|
||||||
|
* Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* - Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* - Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* - Neither the name of ARM LIMITED nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this
|
||||||
|
* software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#include "arm_math.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup groupMath
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup BasicMult
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Q31 vector multiplication.
|
||||||
|
* @param[in] *pSrcA points to the first input vector
|
||||||
|
* @param[in] *pSrcB points to the second input vector
|
||||||
|
* @param[out] *pDst points to the output vector
|
||||||
|
* @param[in] blockSize number of samples in each vector
|
||||||
|
* @return none.
|
||||||
|
*
|
||||||
|
* <b>Scaling and Overflow Behavior:</b>
|
||||||
|
* \par
|
||||||
|
* The function uses saturating arithmetic.
|
||||||
|
* Results outside of the allowable Q31 range[0x80000000 0x7FFFFFFF] will be saturated.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void arm_mult_q31(
|
||||||
|
q31_t * pSrcA,
|
||||||
|
q31_t * pSrcB,
|
||||||
|
q31_t * pDst,
|
||||||
|
uint32_t blockSize)
|
||||||
|
{
|
||||||
|
uint32_t blkCnt; /* loop counters */
|
||||||
|
|
||||||
|
#ifndef ARM_MATH_CM0_FAMILY
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M4 and Cortex-M3 */
|
||||||
|
q31_t inA1, inA2, inA3, inA4; /* temporary input variables */
|
||||||
|
q31_t inB1, inB2, inB3, inB4; /* temporary input variables */
|
||||||
|
q31_t out1, out2, out3, out4; /* temporary output variables */
|
||||||
|
|
||||||
|
/* loop Unrolling */
|
||||||
|
blkCnt = blockSize >> 2u;
|
||||||
|
|
||||||
|
/* First part of the processing with loop unrolling. Compute 4 outputs at a time.
|
||||||
|
** a second loop below computes the remaining 1 to 3 samples. */
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = A * B */
|
||||||
|
/* Multiply the inputs and then store the results in the destination buffer. */
|
||||||
|
inA1 = *pSrcA++;
|
||||||
|
inA2 = *pSrcA++;
|
||||||
|
inA3 = *pSrcA++;
|
||||||
|
inA4 = *pSrcA++;
|
||||||
|
inB1 = *pSrcB++;
|
||||||
|
inB2 = *pSrcB++;
|
||||||
|
inB3 = *pSrcB++;
|
||||||
|
inB4 = *pSrcB++;
|
||||||
|
|
||||||
|
out1 = ((q63_t) inA1 * inB1) >> 32;
|
||||||
|
out2 = ((q63_t) inA2 * inB2) >> 32;
|
||||||
|
out3 = ((q63_t) inA3 * inB3) >> 32;
|
||||||
|
out4 = ((q63_t) inA4 * inB4) >> 32;
|
||||||
|
|
||||||
|
out1 = __SSAT(out1, 31);
|
||||||
|
out2 = __SSAT(out2, 31);
|
||||||
|
out3 = __SSAT(out3, 31);
|
||||||
|
out4 = __SSAT(out4, 31);
|
||||||
|
|
||||||
|
*pDst++ = out1 << 1u;
|
||||||
|
*pDst++ = out2 << 1u;
|
||||||
|
*pDst++ = out3 << 1u;
|
||||||
|
*pDst++ = out4 << 1u;
|
||||||
|
|
||||||
|
/* Decrement the blockSize loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the blockSize is not a multiple of 4, compute any remaining output samples here.
|
||||||
|
** No loop unrolling is used. */
|
||||||
|
blkCnt = blockSize % 0x4u;
|
||||||
|
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = A * B */
|
||||||
|
/* Multiply the inputs and then store the results in the destination buffer. */
|
||||||
|
inA1 = *pSrcA++;
|
||||||
|
inB1 = *pSrcB++;
|
||||||
|
out1 = ((q63_t) inA1 * inB1) >> 32;
|
||||||
|
out1 = __SSAT(out1, 31);
|
||||||
|
*pDst++ = out1 << 1u;
|
||||||
|
|
||||||
|
/* Decrement the blockSize loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M0 */
|
||||||
|
|
||||||
|
/* Initialize blkCnt with number of samples */
|
||||||
|
blkCnt = blockSize;
|
||||||
|
|
||||||
|
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = A * B */
|
||||||
|
/* Multiply the inputs and then store the results in the destination buffer. */
|
||||||
|
*pDst++ =
|
||||||
|
(q31_t) clip_q63_to_q31(((q63_t) (*pSrcA++) * (*pSrcB++)) >> 31);
|
||||||
|
|
||||||
|
/* Decrement the blockSize loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif /* #ifndef ARM_MATH_CM0_FAMILY */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @} end of BasicMult group
|
||||||
|
*/
|
@ -0,0 +1,127 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
* Copyright (C) 2010-2014 ARM Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* $Date: 19. March 2015
|
||||||
|
* $Revision: V.1.4.5
|
||||||
|
*
|
||||||
|
* Project: CMSIS DSP Library
|
||||||
|
* Title: arm_mult_q7.c
|
||||||
|
*
|
||||||
|
* Description: Q7 vector multiplication.
|
||||||
|
*
|
||||||
|
* Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* - Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* - Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* - Neither the name of ARM LIMITED nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this
|
||||||
|
* software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
* -------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#include "arm_math.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup groupMath
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup BasicMult
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Q7 vector multiplication
|
||||||
|
* @param[in] *pSrcA points to the first input vector
|
||||||
|
* @param[in] *pSrcB points to the second input vector
|
||||||
|
* @param[out] *pDst points to the output vector
|
||||||
|
* @param[in] blockSize number of samples in each vector
|
||||||
|
* @return none.
|
||||||
|
*
|
||||||
|
* <b>Scaling and Overflow Behavior:</b>
|
||||||
|
* \par
|
||||||
|
* The function uses saturating arithmetic.
|
||||||
|
* Results outside of the allowable Q7 range [0x80 0x7F] will be saturated.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void arm_mult_q7(
|
||||||
|
q7_t * pSrcA,
|
||||||
|
q7_t * pSrcB,
|
||||||
|
q7_t * pDst,
|
||||||
|
uint32_t blockSize)
|
||||||
|
{
|
||||||
|
uint32_t blkCnt; /* loop counters */
|
||||||
|
|
||||||
|
#ifndef ARM_MATH_CM0_FAMILY
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M4 and Cortex-M3 */
|
||||||
|
q7_t out1, out2, out3, out4; /* Temporary variables to store the product */
|
||||||
|
|
||||||
|
/* loop Unrolling */
|
||||||
|
blkCnt = blockSize >> 2u;
|
||||||
|
|
||||||
|
/* First part of the processing with loop unrolling. Compute 4 outputs at a time.
|
||||||
|
** a second loop below computes the remaining 1 to 3 samples. */
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = A * B */
|
||||||
|
/* Multiply the inputs and store the results in temporary variables */
|
||||||
|
out1 = (q7_t) __SSAT((((q15_t) (*pSrcA++) * (*pSrcB++)) >> 7), 8);
|
||||||
|
out2 = (q7_t) __SSAT((((q15_t) (*pSrcA++) * (*pSrcB++)) >> 7), 8);
|
||||||
|
out3 = (q7_t) __SSAT((((q15_t) (*pSrcA++) * (*pSrcB++)) >> 7), 8);
|
||||||
|
out4 = (q7_t) __SSAT((((q15_t) (*pSrcA++) * (*pSrcB++)) >> 7), 8);
|
||||||
|
|
||||||
|
/* Store the results of 4 inputs in the destination buffer in single cycle by packing */
|
||||||
|
*__SIMD32(pDst)++ = __PACKq7(out1, out2, out3, out4);
|
||||||
|
|
||||||
|
/* Decrement the blockSize loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the blockSize is not a multiple of 4, compute any remaining output samples here.
|
||||||
|
** No loop unrolling is used. */
|
||||||
|
blkCnt = blockSize % 0x4u;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M0 */
|
||||||
|
|
||||||
|
/* Initialize blkCnt with number of samples */
|
||||||
|
blkCnt = blockSize;
|
||||||
|
|
||||||
|
#endif /* #ifndef ARM_MATH_CM0_FAMILY */
|
||||||
|
|
||||||
|
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = A * B */
|
||||||
|
/* Multiply the inputs and store the result in the destination buffer */
|
||||||
|
*pDst++ = (q7_t) __SSAT((((q15_t) (*pSrcA++) * (*pSrcB++)) >> 7), 8);
|
||||||
|
|
||||||
|
/* Decrement the blockSize loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @} end of BasicMult group
|
||||||
|
*/
|
@ -0,0 +1,146 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
* Copyright (C) 2010-2014 ARM Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* $Date: 19. March 2015
|
||||||
|
* $Revision: V.1.4.5
|
||||||
|
*
|
||||||
|
* Project: CMSIS DSP Library
|
||||||
|
* Title: arm_negate_f32.c
|
||||||
|
*
|
||||||
|
* Description: Negates floating-point vectors.
|
||||||
|
*
|
||||||
|
* Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* - Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* - Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* - Neither the name of ARM LIMITED nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this
|
||||||
|
* software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
* ---------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
#include "arm_math.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup groupMath
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @defgroup negate Vector Negate
|
||||||
|
*
|
||||||
|
* Negates the elements of a vector.
|
||||||
|
*
|
||||||
|
* <pre>
|
||||||
|
* pDst[n] = -pSrc[n], 0 <= n < blockSize.
|
||||||
|
* </pre>
|
||||||
|
*
|
||||||
|
* The functions support in-place computation allowing the source and
|
||||||
|
* destination pointers to reference the same memory buffer.
|
||||||
|
* There are separate functions for floating-point, Q7, Q15, and Q31 data types.
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup negate
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Negates the elements of a floating-point vector.
|
||||||
|
* @param[in] *pSrc points to the input vector
|
||||||
|
* @param[out] *pDst points to the output vector
|
||||||
|
* @param[in] blockSize number of samples in the vector
|
||||||
|
* @return none.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void arm_negate_f32(
|
||||||
|
float32_t * pSrc,
|
||||||
|
float32_t * pDst,
|
||||||
|
uint32_t blockSize)
|
||||||
|
{
|
||||||
|
uint32_t blkCnt; /* loop counter */
|
||||||
|
|
||||||
|
|
||||||
|
#ifndef ARM_MATH_CM0_FAMILY
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M4 and Cortex-M3 */
|
||||||
|
float32_t in1, in2, in3, in4; /* temporary variables */
|
||||||
|
|
||||||
|
/*loop Unrolling */
|
||||||
|
blkCnt = blockSize >> 2u;
|
||||||
|
|
||||||
|
/* First part of the processing with loop unrolling. Compute 4 outputs at a time.
|
||||||
|
** a second loop below computes the remaining 1 to 3 samples. */
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* read inputs from source */
|
||||||
|
in1 = *pSrc;
|
||||||
|
in2 = *(pSrc + 1);
|
||||||
|
in3 = *(pSrc + 2);
|
||||||
|
in4 = *(pSrc + 3);
|
||||||
|
|
||||||
|
/* negate the input */
|
||||||
|
in1 = -in1;
|
||||||
|
in2 = -in2;
|
||||||
|
in3 = -in3;
|
||||||
|
in4 = -in4;
|
||||||
|
|
||||||
|
/* store the result to destination */
|
||||||
|
*pDst = in1;
|
||||||
|
*(pDst + 1) = in2;
|
||||||
|
*(pDst + 2) = in3;
|
||||||
|
*(pDst + 3) = in4;
|
||||||
|
|
||||||
|
/* update pointers to process next samples */
|
||||||
|
pSrc += 4u;
|
||||||
|
pDst += 4u;
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the blockSize is not a multiple of 4, compute any remaining output samples here.
|
||||||
|
** No loop unrolling is used. */
|
||||||
|
blkCnt = blockSize % 0x4u;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M0 */
|
||||||
|
|
||||||
|
/* Initialize blkCnt with number of samples */
|
||||||
|
blkCnt = blockSize;
|
||||||
|
|
||||||
|
#endif /* #ifndef ARM_MATH_CM0_FAMILY */
|
||||||
|
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = -A */
|
||||||
|
/* Negate and then store the results in the destination buffer. */
|
||||||
|
*pDst++ = -*pSrc++;
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @} end of negate group
|
||||||
|
*/
|
@ -0,0 +1,142 @@
|
|||||||
|
/* ----------------------------------------------------------------------
|
||||||
|
* Copyright (C) 2010-2014 ARM Limited. All rights reserved.
|
||||||
|
*
|
||||||
|
* $Date: 19. March 2015
|
||||||
|
* $Revision: V.1.4.5
|
||||||
|
*
|
||||||
|
* Project: CMSIS DSP Library
|
||||||
|
* Title: arm_negate_q15.c
|
||||||
|
*
|
||||||
|
* Description: Negates Q15 vectors.
|
||||||
|
*
|
||||||
|
* Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without
|
||||||
|
* modification, are permitted provided that the following conditions
|
||||||
|
* are met:
|
||||||
|
* - Redistributions of source code must retain the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer.
|
||||||
|
* - Redistributions in binary form must reproduce the above copyright
|
||||||
|
* notice, this list of conditions and the following disclaimer in
|
||||||
|
* the documentation and/or other materials provided with the
|
||||||
|
* distribution.
|
||||||
|
* - Neither the name of ARM LIMITED nor the names of its contributors
|
||||||
|
* may be used to endorse or promote products derived from this
|
||||||
|
* software without specific prior written permission.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||||
|
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||||
|
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
* POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
* -------------------------------------------------------------------- */
|
||||||
|
#include "arm_math.h"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @ingroup groupMath
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @addtogroup negate
|
||||||
|
* @{
|
||||||
|
*/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Negates the elements of a Q15 vector.
|
||||||
|
* @param[in] *pSrc points to the input vector
|
||||||
|
* @param[out] *pDst points to the output vector
|
||||||
|
* @param[in] blockSize number of samples in the vector
|
||||||
|
* @return none.
|
||||||
|
*
|
||||||
|
* \par Conditions for optimum performance
|
||||||
|
* Input and output buffers should be aligned by 32-bit
|
||||||
|
*
|
||||||
|
*
|
||||||
|
* <b>Scaling and Overflow Behavior:</b>
|
||||||
|
* \par
|
||||||
|
* The function uses saturating arithmetic.
|
||||||
|
* The Q15 value -1 (0x8000) will be saturated to the maximum allowable positive value 0x7FFF.
|
||||||
|
*/
|
||||||
|
|
||||||
|
void arm_negate_q15(
|
||||||
|
q15_t * pSrc,
|
||||||
|
q15_t * pDst,
|
||||||
|
uint32_t blockSize)
|
||||||
|
{
|
||||||
|
uint32_t blkCnt; /* loop counter */
|
||||||
|
q15_t in;
|
||||||
|
|
||||||
|
#ifndef ARM_MATH_CM0_FAMILY
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M4 and Cortex-M3 */
|
||||||
|
|
||||||
|
q31_t in1, in2; /* Temporary variables */
|
||||||
|
|
||||||
|
|
||||||
|
/*loop Unrolling */
|
||||||
|
blkCnt = blockSize >> 2u;
|
||||||
|
|
||||||
|
/* First part of the processing with loop unrolling. Compute 4 outputs at a time.
|
||||||
|
** a second loop below computes the remaining 1 to 3 samples. */
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = -A */
|
||||||
|
/* Read two inputs at a time */
|
||||||
|
in1 = _SIMD32_OFFSET(pSrc);
|
||||||
|
in2 = _SIMD32_OFFSET(pSrc + 2);
|
||||||
|
|
||||||
|
/* negate two samples at a time */
|
||||||
|
in1 = __QSUB16(0, in1);
|
||||||
|
|
||||||
|
/* negate two samples at a time */
|
||||||
|
in2 = __QSUB16(0, in2);
|
||||||
|
|
||||||
|
/* store the result to destination 2 samples at a time */
|
||||||
|
_SIMD32_OFFSET(pDst) = in1;
|
||||||
|
/* store the result to destination 2 samples at a time */
|
||||||
|
_SIMD32_OFFSET(pDst + 2) = in2;
|
||||||
|
|
||||||
|
|
||||||
|
/* update pointers to process next samples */
|
||||||
|
pSrc += 4u;
|
||||||
|
pDst += 4u;
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* If the blockSize is not a multiple of 4, compute any remaining output samples here.
|
||||||
|
** No loop unrolling is used. */
|
||||||
|
blkCnt = blockSize % 0x4u;
|
||||||
|
|
||||||
|
#else
|
||||||
|
|
||||||
|
/* Run the below code for Cortex-M0 */
|
||||||
|
|
||||||
|
/* Initialize blkCnt with number of samples */
|
||||||
|
blkCnt = blockSize;
|
||||||
|
|
||||||
|
#endif /* #ifndef ARM_MATH_CM0_FAMILY */
|
||||||
|
|
||||||
|
while(blkCnt > 0u)
|
||||||
|
{
|
||||||
|
/* C = -A */
|
||||||
|
/* Negate and then store the result in the destination buffer. */
|
||||||
|
in = *pSrc++;
|
||||||
|
*pDst++ = (in == (q15_t) 0x8000) ? 0x7fff : -in;
|
||||||
|
|
||||||
|
/* Decrement the loop counter */
|
||||||
|
blkCnt--;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @} end of negate group
|
||||||
|
*/
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user