@micro-os-plus/architecture-riscv 4.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +152 -0
- package/CMakeLists.txt +87 -0
- package/LICENSE +21 -0
- package/README.md +317 -0
- package/include/micro-os-plus/architecture-riscv/core-functions-inlines.h +86 -0
- package/include/micro-os-plus/architecture-riscv/core-functions.h +105 -0
- package/include/micro-os-plus/architecture-riscv/csr-functions-inlines.h +466 -0
- package/include/micro-os-plus/architecture-riscv/csr-functions.h +241 -0
- package/include/micro-os-plus/architecture-riscv/declarations.h +58 -0
- package/include/micro-os-plus/architecture-riscv/defines.h +185 -0
- package/include/micro-os-plus/architecture-riscv/device-functions-inlines.h +235 -0
- package/include/micro-os-plus/architecture-riscv/device-functions.h +166 -0
- package/include/micro-os-plus/architecture-riscv/instructions-inlines.h +172 -0
- package/include/micro-os-plus/architecture-riscv/instructions.h +153 -0
- package/include/micro-os-plus/architecture-riscv/platform-functions-inlines.h +81 -0
- package/include/micro-os-plus/architecture-riscv/platform-functions.h +75 -0
- package/include/micro-os-plus/architecture-riscv/plic-functions.h +278 -0
- package/include/micro-os-plus/architecture-riscv/semihosting-inlines.h +79 -0
- package/include/micro-os-plus/architecture-riscv/types.h +135 -0
- package/include/micro-os-plus/architecture.h +38 -0
- package/linker-scripts/README.md +7 -0
- package/linker-scripts/sections-flash.ld +425 -0
- package/linker-scripts/sections-ram.ld +425 -0
- package/linker-scripts/sections.ld +377 -0
- package/meson.build +46 -0
- package/package.json +37 -0
- package/src/.gitkeep +0 -0
- package/xpack.json +23 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# Change & release log
|
|
2
|
+
|
|
3
|
+
Releases in reverse chronological order.
|
|
4
|
+
|
|
5
|
+
Please check
|
|
6
|
+
[GitHub](https://github.com/micro-os-plus/architecture-riscv-xpack/issues/)
|
|
7
|
+
and close existing issues and pull requests.
|
|
8
|
+
|
|
9
|
+
## 2022-07-28
|
|
10
|
+
|
|
11
|
+
* v4.1.0
|
|
12
|
+
* e19aa16 #5: remove linker script ARM sections
|
|
13
|
+
* 5f43150 #7: add sections-flash.ld
|
|
14
|
+
* 963be52 #6: rework semihosting_call_host() to avoid asm() registers
|
|
15
|
+
* 31ebece #4: add signed_register_t for semihosting result
|
|
16
|
+
|
|
17
|
+
## 2022-07-25
|
|
18
|
+
|
|
19
|
+
* 0f03dd3 add preliminary xpack.json
|
|
20
|
+
|
|
21
|
+
## 2022-07-24
|
|
22
|
+
|
|
23
|
+
* v4.0.0
|
|
24
|
+
|
|
25
|
+
## 2022-07-21
|
|
26
|
+
|
|
27
|
+
* move rtos out
|
|
28
|
+
|
|
29
|
+
## 2021-03-10
|
|
30
|
+
|
|
31
|
+
* v3.0.2
|
|
32
|
+
* gitkeep device/include
|
|
33
|
+
* v3.0.1
|
|
34
|
+
* fix/silence warnings
|
|
35
|
+
|
|
36
|
+
## 2021-03-09
|
|
37
|
+
|
|
38
|
+
* v3.0.0
|
|
39
|
+
* separate rtos-port folder
|
|
40
|
+
* fix/silence warnings
|
|
41
|
+
|
|
42
|
+
## 2021-03-01
|
|
43
|
+
|
|
44
|
+
* v2.0.0
|
|
45
|
+
|
|
46
|
+
## 2021-02-28
|
|
47
|
+
|
|
48
|
+
* rename micro_os_plus
|
|
49
|
+
|
|
50
|
+
## 2021-02-04
|
|
51
|
+
|
|
52
|
+
* v1.1.0
|
|
53
|
+
* first restructured release
|
|
54
|
+
|
|
55
|
+
## 2020-09-19
|
|
56
|
+
|
|
57
|
+
* v1.0.3
|
|
58
|
+
* bump startup to 1.0.8
|
|
59
|
+
|
|
60
|
+
## 2018-04-16
|
|
61
|
+
|
|
62
|
+
* v1.0.2
|
|
63
|
+
* bump deps & move back to npm
|
|
64
|
+
* update README developer info
|
|
65
|
+
|
|
66
|
+
## 2018-01-24
|
|
67
|
+
|
|
68
|
+
* v1.0.1
|
|
69
|
+
* update dependencies
|
|
70
|
+
|
|
71
|
+
## 2018-01-24
|
|
72
|
+
|
|
73
|
+
* v1.0.0
|
|
74
|
+
|
|
75
|
+
### 2018-01-20
|
|
76
|
+
|
|
77
|
+
* [#271] Reimplement RISC-V semihosting
|
|
78
|
+
* semihosting asm: remove "cc"
|
|
79
|
+
|
|
80
|
+
### 2018-01-15
|
|
81
|
+
|
|
82
|
+
* [#2] Use wfi() in infinite loops
|
|
83
|
+
* [#3] Add semihosting call_host() implementation
|
|
84
|
+
|
|
85
|
+
## (2018-01-09)
|
|
86
|
+
|
|
87
|
+
* v0.2.0
|
|
88
|
+
|
|
89
|
+
## 2017-11-10
|
|
90
|
+
|
|
91
|
+
* README: reformat prerequisites
|
|
92
|
+
* arch-functions.cpp: fix typo
|
|
93
|
+
* README: explain xpm install
|
|
94
|
+
* README: refer to CHANGELOG in message
|
|
95
|
+
* README: update license with links
|
|
96
|
+
* do not ignore package-lock
|
|
97
|
+
|
|
98
|
+
## 2017-11-07
|
|
99
|
+
|
|
100
|
+
* traps.cpp: add `handle_machine_ext()` declaration
|
|
101
|
+
* ignore package-lock for now
|
|
102
|
+
* rework interrupts to use namespaces
|
|
103
|
+
|
|
104
|
+
## 2017-10-30
|
|
105
|
+
|
|
106
|
+
* arch-defines: fix `MCAUSE_CAUSE` for 32-bits
|
|
107
|
+
* traps.cpp: fix section `.traps_handlers`
|
|
108
|
+
* reset-entry.S: cosmetise comments
|
|
109
|
+
|
|
110
|
+
## 2017-10-29
|
|
111
|
+
|
|
112
|
+
* include/\*: rename csr set/clear_\*_bits
|
|
113
|
+
* include/\*/defines.h: simplify & prefix
|
|
114
|
+
* include/\*/types.h: add exc & irq enums
|
|
115
|
+
* include/platform-functions-inlines.h added
|
|
116
|
+
* src/traps.cpp: rename `riscv_interrupts_local_handlers`
|
|
117
|
+
* include/core-functions.h: move `riscv_trap_entry()` here
|
|
118
|
+
* include/\*: update guard macros
|
|
119
|
+
|
|
120
|
+
## 2017-10-28
|
|
121
|
+
|
|
122
|
+
* src/traps.cpp: move local handlers to device
|
|
123
|
+
* include/architecture-riscv/defines.h: number of exc
|
|
124
|
+
* update for device-peripherals.h
|
|
125
|
+
|
|
126
|
+
## 2017-10-26
|
|
127
|
+
|
|
128
|
+
* v1.1.0
|
|
129
|
+
* update for new GitHub names
|
|
130
|
+
|
|
131
|
+
## 2017-10-04
|
|
132
|
+
|
|
133
|
+
* v0.0.4
|
|
134
|
+
* package.json clean-ups
|
|
135
|
+
* add CHANGELOG.md
|
|
136
|
+
|
|
137
|
+
## 2017-09-18
|
|
138
|
+
|
|
139
|
+
* v0.0.3
|
|
140
|
+
* add enable/disable M external interrupts
|
|
141
|
+
* add plic-functions.h
|
|
142
|
+
* traps.cpp: use new plic api
|
|
143
|
+
* csr-functions*.h: add `mhartid()`
|
|
144
|
+
* `*_exception_`, `*_interrupt_local_`
|
|
145
|
+
- for improved readability, use full names
|
|
146
|
+
- use local_device array, if needed
|
|
147
|
+
|
|
148
|
+
## 2017-09-04
|
|
149
|
+
|
|
150
|
+
* v0.0.2
|
|
151
|
+
* v0.0.1
|
|
152
|
+
* initial version, copied from µOS++.
|
package/CMakeLists.txt
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
# -----------------------------------------------------------------------------
|
|
2
|
+
#
|
|
3
|
+
# This file is part of the µOS++ distribution.
|
|
4
|
+
# (https://github.com/micro-os-plus/)
|
|
5
|
+
# Copyright (c) 2021 Liviu Ionescu
|
|
6
|
+
#
|
|
7
|
+
# Permission to use, copy, modify, and/or distribute this software
|
|
8
|
+
# for any purpose is hereby granted, under the terms of the MIT license.
|
|
9
|
+
#
|
|
10
|
+
# If a copy of the license was not distributed with this file, it can
|
|
11
|
+
# be obtained from https://opensource.org/licenses/MIT/.
|
|
12
|
+
#
|
|
13
|
+
# -----------------------------------------------------------------------------
|
|
14
|
+
|
|
15
|
+
# This file is intended to be consumed by applications with:
|
|
16
|
+
#
|
|
17
|
+
# `add_subdirectory("xpacks/micro-os-plus-architecture-riscv")`
|
|
18
|
+
#
|
|
19
|
+
# The result is an interface library that can be added to the linker with:
|
|
20
|
+
#
|
|
21
|
+
# `target_link_libraries(your-target PUBLIC micro-os-plus::architecture-riscv)`
|
|
22
|
+
|
|
23
|
+
# -----------------------------------------------------------------------------
|
|
24
|
+
## Preamble ##
|
|
25
|
+
|
|
26
|
+
# https://cmake.org/cmake/help/v3.20/
|
|
27
|
+
cmake_minimum_required(VERSION 3.20)
|
|
28
|
+
|
|
29
|
+
project(
|
|
30
|
+
micro-os-plus-architecture-riscv
|
|
31
|
+
DESCRIPTION "µOS++ RISC-V architecture"
|
|
32
|
+
)
|
|
33
|
+
|
|
34
|
+
if(COMMAND xpack_get_package_name_and_version)
|
|
35
|
+
xpack_get_package_name_and_version("${CMAKE_CURRENT_SOURCE_DIR}/package.json")
|
|
36
|
+
message(VERBOSE "Processing xPack ${PACKAGE_JSON_NAME}@${PACKAGE_JSON_VERSION}...")
|
|
37
|
+
endif()
|
|
38
|
+
|
|
39
|
+
# -----------------------------------------------------------------------------
|
|
40
|
+
## The project library definitions ##
|
|
41
|
+
|
|
42
|
+
# https://cmake.org/cmake/help/v3.20/command/add_library.html?highlight=interface#normal-libraries
|
|
43
|
+
# PRIVATE: build definitions, used internally
|
|
44
|
+
# INTERFACE: usage definitions, passed up to targets linking to it
|
|
45
|
+
# PUBLIC: both
|
|
46
|
+
|
|
47
|
+
add_library(micro-os-plus-architecture-riscv-interface INTERFACE EXCLUDE_FROM_ALL)
|
|
48
|
+
|
|
49
|
+
# -----------------------------------------------------------------------------
|
|
50
|
+
# Target settings.
|
|
51
|
+
|
|
52
|
+
target_include_directories(micro-os-plus-architecture-riscv-interface INTERFACE
|
|
53
|
+
"include"
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
target_sources(micro-os-plus-architecture-riscv-interface INTERFACE
|
|
57
|
+
# None.
|
|
58
|
+
)
|
|
59
|
+
|
|
60
|
+
target_compile_definitions(micro-os-plus-architecture-riscv-interface INTERFACE
|
|
61
|
+
# None.
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
target_compile_options(micro-os-plus-architecture-riscv-interface INTERFACE
|
|
65
|
+
# None.
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
target_link_libraries(micro-os-plus-architecture-riscv-interface INTERFACE
|
|
69
|
+
# Dependencies
|
|
70
|
+
# None.
|
|
71
|
+
)
|
|
72
|
+
|
|
73
|
+
if (COMMAND xpack_display_target_lists)
|
|
74
|
+
xpack_display_target_lists(micro-os-plus-architecture-riscv-interface)
|
|
75
|
+
endif()
|
|
76
|
+
|
|
77
|
+
# -----------------------------------------------------------------------------
|
|
78
|
+
# Aliases.
|
|
79
|
+
|
|
80
|
+
# https://cmake.org/cmake/help/v3.20/command/add_library.html#alias-libraries
|
|
81
|
+
add_library(micro-os-plus::architecture-riscv ALIAS micro-os-plus-architecture-riscv-interface)
|
|
82
|
+
message(VERBOSE "> micro-os-plus::architecture-riscv -> micro-os-plus-architecture-riscv-interface")
|
|
83
|
+
|
|
84
|
+
add_library(micro-os-plus::architecture ALIAS micro-os-plus-architecture-riscv-interface)
|
|
85
|
+
message(VERBOSE "> micro-os-plus::architecture -> micro-os-plus-architecture-riscv-interface")
|
|
86
|
+
|
|
87
|
+
# -----------------------------------------------------------------------------
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017 Liviu Ionescu
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
[](https://github.com/micro-os-plus/architecture-riscv-xpack/blob/xpack/LICENSE)
|
|
2
|
+
[](https://github.com/micro-os-plus/architecture-riscv-xpack/actions/workflows/CI.yml)
|
|
3
|
+
|
|
4
|
+
# A source library xPack with the µOS++ RISC-V architecture definitions
|
|
5
|
+
|
|
6
|
+
This project provides the **architecture-riscv** source library as an xPack
|
|
7
|
+
dependency and includes architecture definitions for RISC-V embedded projects.
|
|
8
|
+
|
|
9
|
+
The project is hosted on GitHub as
|
|
10
|
+
[micro-os-plus/architecture-riscv-xpack](https://github.com/micro-os-plus/architecture-riscv-xpack).
|
|
11
|
+
|
|
12
|
+
## Maintainer info
|
|
13
|
+
|
|
14
|
+
This page is addressed to developers who plan to include this source
|
|
15
|
+
library into their own projects.
|
|
16
|
+
|
|
17
|
+
For maintainer info, please see the
|
|
18
|
+
[README-MAINTAINER](README-MAINTAINER.md) file.
|
|
19
|
+
|
|
20
|
+
## Install
|
|
21
|
+
|
|
22
|
+
As a source library xPack, the easiest way to add it to a project is via
|
|
23
|
+
**xpm**, but it can also be used as any Git project, for example as a submodule.
|
|
24
|
+
|
|
25
|
+
### Prerequisites
|
|
26
|
+
|
|
27
|
+
A recent [xpm](https://xpack.github.io/xpm/),
|
|
28
|
+
which is a portable [Node.js](https://nodejs.org/) command line application.
|
|
29
|
+
|
|
30
|
+
For details please follow the instructions in the
|
|
31
|
+
[xPack install](https://xpack.github.io/install/) page.
|
|
32
|
+
|
|
33
|
+
### xpm
|
|
34
|
+
|
|
35
|
+
This package is available from npmjs.com as
|
|
36
|
+
[`@micro-os-plus/architecture-riscv`](https://www.npmjs.com/package/@micro-os-plus/architecture-riscv)
|
|
37
|
+
from the `npmjs.com` registry:
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
cd my-project
|
|
41
|
+
xpm init # Unless a package.json is already present
|
|
42
|
+
|
|
43
|
+
xpm install @micro-os-plus/architecture-riscv@latest
|
|
44
|
+
|
|
45
|
+
ls -l xpacks/micro-os-plus-architecture-riscv
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Git submodule
|
|
49
|
+
|
|
50
|
+
If, for any reason, **xpm** is not available, the next recommended
|
|
51
|
+
solution is to link it as a Git submodule below an `xpacks` folder.
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
cd my-project
|
|
55
|
+
git init # Unless already a Git project
|
|
56
|
+
mkdir -p xpacks
|
|
57
|
+
|
|
58
|
+
git submodule add https://github.com/micro-os-plus/architecture-riscv-xpack.git \
|
|
59
|
+
xpacks/micro-os-plus-architecture-riscv
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Branches
|
|
63
|
+
|
|
64
|
+
Apart from the unused `master` branch, there are two active branches:
|
|
65
|
+
|
|
66
|
+
- `xpack`, with the latest stable version (default)
|
|
67
|
+
- `xpack-develop`, with the current development version
|
|
68
|
+
|
|
69
|
+
All development is done in the `xpack-develop` branch, and contributions via
|
|
70
|
+
Pull Requests should be directed to this branch.
|
|
71
|
+
|
|
72
|
+
When new releases are published, the `xpack-develop` branch is merged
|
|
73
|
+
into `xpack`.
|
|
74
|
+
|
|
75
|
+
## Developer info
|
|
76
|
+
|
|
77
|
+
### Overview
|
|
78
|
+
|
|
79
|
+
This source xPack provides general RISC-V definitions and will eventually
|
|
80
|
+
include the implementation for a hardware abstraction layer, which,
|
|
81
|
+
for RISC-V is not yet standardized.
|
|
82
|
+
|
|
83
|
+
### Status
|
|
84
|
+
|
|
85
|
+
The **architecture-riscv** source library is fully functional,
|
|
86
|
+
but minimalistic, for running semihosted tests.
|
|
87
|
+
|
|
88
|
+
### Design details
|
|
89
|
+
|
|
90
|
+
From a top down approach, in µOS++, the RISC-V definitions are
|
|
91
|
+
grouped by several criteria:
|
|
92
|
+
|
|
93
|
+
- platform (board)
|
|
94
|
+
- device
|
|
95
|
+
- core
|
|
96
|
+
- hart (hardware thread)
|
|
97
|
+
|
|
98
|
+
#### Platform
|
|
99
|
+
|
|
100
|
+
The platform level refers to a device and adds platform specific definitions,
|
|
101
|
+
like what GPIO pins are used for various LEDs, buttons, etc.
|
|
102
|
+
|
|
103
|
+
The portable way to include platform specific definitions in an application is:
|
|
104
|
+
|
|
105
|
+
```c
|
|
106
|
+
#include <micro-os-plus/platform.h>
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
In µOS++, the platform specific definitions are grouped in the
|
|
110
|
+
`riscv::platform` namespace.
|
|
111
|
+
|
|
112
|
+
An example of a platform package is **sifive/platform-sifive-hifive1** with the
|
|
113
|
+
SiFive HiFive1 small development board.
|
|
114
|
+
|
|
115
|
+
#### Device
|
|
116
|
+
|
|
117
|
+
The RISC-V documentation introduces the term _platform_ as:
|
|
118
|
+
|
|
119
|
+
> A RISC-V hardware _platform_ can contain one or more RISC-V-compatible
|
|
120
|
+
processing cores together with other non-RISC-V-compatible cores,
|
|
121
|
+
fixed-function accelerators, various physical memory structures,
|
|
122
|
+
I/O devices, and an interconnect structure to allow the components
|
|
123
|
+
to communicate.
|
|
124
|
+
|
|
125
|
+
In modern implementations, this is generally either a physical chip
|
|
126
|
+
or a synthesised one.
|
|
127
|
+
|
|
128
|
+
In other contexts, _platform_ has a broader meaning and may refer to
|
|
129
|
+
the environment in which a piece of software is executed; it may be
|
|
130
|
+
the hardware or the operating system (OS); to avoid confusions, in
|
|
131
|
+
µOS++ the term **device** is used to identify the vendor specific
|
|
132
|
+
RISC-V details (with _platform_ being used for the machine, or the board).
|
|
133
|
+
|
|
134
|
+
Please note that RISC-V defines some common MMIO registers (like
|
|
135
|
+
`mtime` and `mtimecmp`), but, for more flexibility, leaves the
|
|
136
|
+
implementation to define the actual address. Unfortunately this
|
|
137
|
+
increases the software complexity, since the device specific headers
|
|
138
|
+
must define some fixed symbols and the header files must be included
|
|
139
|
+
in a careful order, to avoid circular references.
|
|
140
|
+
|
|
141
|
+
In µOS++, the device specific definitions are grouped in the
|
|
142
|
+
`riscv::device` namespace.
|
|
143
|
+
|
|
144
|
+
The portable way to include device specific definitions in an application is:
|
|
145
|
+
|
|
146
|
+
```c
|
|
147
|
+
#include <micro-os-plus/device.h>
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
Example of device packages are **sifive/devices** with the SiFive
|
|
151
|
+
Freedom E310 and E31/E51 Arty devices.
|
|
152
|
+
|
|
153
|
+
#### Core
|
|
154
|
+
|
|
155
|
+
The RISC-V documentation introduces the term _core_ as:
|
|
156
|
+
|
|
157
|
+
> A component is termed a core if it contains an independent
|
|
158
|
+
instruction fetch unit. A RISC-V-compatible core might support
|
|
159
|
+
multiple RISC-V-compatible hardware threads, or harts, through
|
|
160
|
+
multi-threading.
|
|
161
|
+
|
|
162
|
+
In µOS++, the core specific definitions are grouped in the
|
|
163
|
+
`riscv::core` namespace.
|
|
164
|
+
|
|
165
|
+
The portable way to include architecture specific definitions
|
|
166
|
+
in an application is:
|
|
167
|
+
|
|
168
|
+
```c
|
|
169
|
+
#include <micro-os-plus/architecture.h>
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
#### Hart
|
|
173
|
+
|
|
174
|
+
Hardware threads are the working horses of the software threads;
|
|
175
|
+
each hardware thread has its own set of general registers and
|
|
176
|
+
Control and Status Registers (CSRs); the OS may schedule a
|
|
177
|
+
maximum number of software threads equal with the number of
|
|
178
|
+
hardware threads, possibly with some grouping constrains.
|
|
179
|
+
|
|
180
|
+
In RISC-V, **Control and Status Registers** (**CSR**s) are
|
|
181
|
+
a special group of registers, available via specific `csr`
|
|
182
|
+
instructions from a separate addressing space not visible in
|
|
183
|
+
the memory space.
|
|
184
|
+
|
|
185
|
+
The `hart` specific definitions are grouped under the `riscv::csr` namespace.
|
|
186
|
+
|
|
187
|
+
#### Other namespaces
|
|
188
|
+
|
|
189
|
+
Interrupts and exceptions are grouped under `riscv::irq` and `riscv::exc`.
|
|
190
|
+
|
|
191
|
+
### Build & integration info
|
|
192
|
+
|
|
193
|
+
The project is written in C++ and assembly and it is expected
|
|
194
|
+
to be used in C and C++ projects.
|
|
195
|
+
|
|
196
|
+
The source code was compiled with riscv-none-elf-gcc 12,
|
|
197
|
+
and should be warning free.
|
|
198
|
+
|
|
199
|
+
To ease the integration of this package into user projects, there
|
|
200
|
+
are already made CMake and meson configuration files (see below).
|
|
201
|
+
|
|
202
|
+
For other build systems, consider the following details:
|
|
203
|
+
|
|
204
|
+
#### Include folders
|
|
205
|
+
|
|
206
|
+
The following folders should be passed to the compiler during the build:
|
|
207
|
+
|
|
208
|
+
- `include`
|
|
209
|
+
|
|
210
|
+
The header files to be included in user projects are:
|
|
211
|
+
|
|
212
|
+
```c++
|
|
213
|
+
#include <micro-os-plus/architecture.h>
|
|
214
|
+
```
|
|
215
|
+
|
|
216
|
+
#### Source files
|
|
217
|
+
|
|
218
|
+
The source files to be added to user projects are:
|
|
219
|
+
|
|
220
|
+
- none
|
|
221
|
+
|
|
222
|
+
#### Preprocessor definitions
|
|
223
|
+
|
|
224
|
+
- none
|
|
225
|
+
|
|
226
|
+
#### Compiler options
|
|
227
|
+
|
|
228
|
+
- `-std=c++20` or higher for C++ sources
|
|
229
|
+
- `-std=c11` for C sources
|
|
230
|
+
|
|
231
|
+
#### C++ Namespaces
|
|
232
|
+
|
|
233
|
+
- `micro_os_plus::architecture`
|
|
234
|
+
|
|
235
|
+
#### C++ Classes
|
|
236
|
+
|
|
237
|
+
TBD
|
|
238
|
+
|
|
239
|
+
#### Dependencies
|
|
240
|
+
|
|
241
|
+
- none
|
|
242
|
+
|
|
243
|
+
#### CMake
|
|
244
|
+
|
|
245
|
+
To integrate the architecture-riscv source library into a CMake application,
|
|
246
|
+
add this folder to the build:
|
|
247
|
+
|
|
248
|
+
```cmake
|
|
249
|
+
add_subdirectory("xpacks/micro-os-plus-architecture-riscv")`
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
The result is an interface library that can be added as an application
|
|
253
|
+
dependency with:
|
|
254
|
+
|
|
255
|
+
```cmake
|
|
256
|
+
target_link_libraries(your-target PRIVATE
|
|
257
|
+
|
|
258
|
+
micro-os-plus::architecture-riscv
|
|
259
|
+
)
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
#### meson
|
|
263
|
+
|
|
264
|
+
To integrate the architecture-riscv source library into a meson application,
|
|
265
|
+
add this folder to the build:
|
|
266
|
+
|
|
267
|
+
```meson
|
|
268
|
+
subdir('xpacks/micro-os-plus-architecture-riscv')
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
The result is a dependency object that can be added
|
|
272
|
+
to an application with:
|
|
273
|
+
|
|
274
|
+
```meson
|
|
275
|
+
exe = executable(
|
|
276
|
+
your-target,
|
|
277
|
+
link_with: [
|
|
278
|
+
# Nothing, not static.
|
|
279
|
+
],
|
|
280
|
+
dependencies: [
|
|
281
|
+
micro_os_plus_architecture_riscv_dependency,
|
|
282
|
+
]
|
|
283
|
+
)
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
### Examples
|
|
287
|
+
|
|
288
|
+
TBD
|
|
289
|
+
|
|
290
|
+
### Known problems
|
|
291
|
+
|
|
292
|
+
- none
|
|
293
|
+
|
|
294
|
+
### Tests
|
|
295
|
+
|
|
296
|
+
TBD
|
|
297
|
+
|
|
298
|
+
## Change log - incompatible changes
|
|
299
|
+
|
|
300
|
+
According to [semver](https://semver.org) rules:
|
|
301
|
+
|
|
302
|
+
> Major version X (X.y.z | X > 0) MUST be incremented if any
|
|
303
|
+
backwards incompatible changes are introduced to the public API.
|
|
304
|
+
|
|
305
|
+
The incompatible changes, in reverse chronological order,
|
|
306
|
+
are:
|
|
307
|
+
|
|
308
|
+
- v4.x: move rtos-port outside
|
|
309
|
+
- v3.x: move rtos-port to separate folder
|
|
310
|
+
- v2.x: rename micro_os_plus
|
|
311
|
+
|
|
312
|
+
## License
|
|
313
|
+
|
|
314
|
+
The original content is released under the
|
|
315
|
+
[MIT License](https://opensource.org/licenses/MIT/),
|
|
316
|
+
with all rights reserved to
|
|
317
|
+
[Liviu Ionescu](https://github.com/ilg-ul/).
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* This file is part of the µOS++ distribution.
|
|
3
|
+
* (https://github.com/micro-os-plus/)
|
|
4
|
+
* Copyright (c) 2017 Liviu Ionescu.
|
|
5
|
+
*
|
|
6
|
+
* Permission to use, copy, modify, and/or distribute this software
|
|
7
|
+
* for any purpose is hereby granted, under the terms of the MIT license.
|
|
8
|
+
*
|
|
9
|
+
* If a copy of the license was not distributed with this file, it can
|
|
10
|
+
* be obtained from https://opensource.org/licenses/MIT/.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
#ifndef MICRO_OS_PLUS_ARCHITECTURE_RISCV_CORE_FUNCTIONS_INLINES_H_
|
|
14
|
+
#define MICRO_OS_PLUS_ARCHITECTURE_RISCV_CORE_FUNCTIONS_INLINES_H_
|
|
15
|
+
|
|
16
|
+
// ----------------------------------------------------------------------------
|
|
17
|
+
|
|
18
|
+
#include <stdint.h>
|
|
19
|
+
|
|
20
|
+
// ----------------------------------------------------------------------------
|
|
21
|
+
// Inline implementations for the RISC-V core support functions.
|
|
22
|
+
|
|
23
|
+
#if defined(__cplusplus)
|
|
24
|
+
extern "C"
|
|
25
|
+
{
|
|
26
|
+
#endif // defined(__cplusplus)
|
|
27
|
+
|
|
28
|
+
// --------------------------------------------------------------------------
|
|
29
|
+
|
|
30
|
+
static inline __attribute__ ((always_inline)) void
|
|
31
|
+
riscv_core_enable_machine_external_interrupts (void)
|
|
32
|
+
{
|
|
33
|
+
riscv_csr_set_mie_bits (RISCV_CSR_MIP_MEIP);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* @brief Disable external interrupts (used by PLIC).
|
|
38
|
+
*/
|
|
39
|
+
static inline __attribute__ ((always_inline)) void
|
|
40
|
+
riscv_core_disable_machine_external_interrupts (void)
|
|
41
|
+
{
|
|
42
|
+
riscv_csr_clear_mie_bits (RISCV_CSR_MIP_MEIP);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// --------------------------------------------------------------------------
|
|
46
|
+
|
|
47
|
+
#if defined(__cplusplus)
|
|
48
|
+
}
|
|
49
|
+
#endif // defined(__cplusplus)
|
|
50
|
+
|
|
51
|
+
// ============================================================================
|
|
52
|
+
|
|
53
|
+
#if defined(__cplusplus)
|
|
54
|
+
|
|
55
|
+
// ----------------------------------------------------------------------------
|
|
56
|
+
|
|
57
|
+
namespace riscv
|
|
58
|
+
{
|
|
59
|
+
namespace core
|
|
60
|
+
{
|
|
61
|
+
|
|
62
|
+
inline __attribute__ ((always_inline)) void
|
|
63
|
+
enable_machine_external_interrupts (void)
|
|
64
|
+
{
|
|
65
|
+
riscv_core_enable_machine_external_interrupts ();
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
inline __attribute__ ((always_inline)) void
|
|
69
|
+
disable_machine_external_interrupts (void)
|
|
70
|
+
{
|
|
71
|
+
riscv_core_disable_machine_external_interrupts ();
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// ------------------------------------------------------------------------
|
|
75
|
+
} // namespace core
|
|
76
|
+
} // namespace riscv
|
|
77
|
+
|
|
78
|
+
// ----------------------------------------------------------------------------
|
|
79
|
+
|
|
80
|
+
#endif // defined(__cplusplus)
|
|
81
|
+
|
|
82
|
+
// ----------------------------------------------------------------------------
|
|
83
|
+
|
|
84
|
+
#endif // MICRO_OS_PLUS_ARCHITECTURE_RISCV_CORE_FUNCTIONS_INLINES_H_
|
|
85
|
+
|
|
86
|
+
// ----------------------------------------------------------------------------
|