@micro-os-plus/architecture-riscv 4.1.0 → 5.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.
Files changed (31) hide show
  1. package/CHANGELOG.md +104 -2
  2. package/CMakeLists.txt +70 -52
  3. package/LICENSE +1 -1
  4. package/README.md +34 -25
  5. package/include/micro-os-plus/architecture-riscv/core-functions.h +11 -7
  6. package/include/micro-os-plus/architecture-riscv/csr-functions.h +12 -8
  7. package/include/micro-os-plus/architecture-riscv/declarations.h +7 -8
  8. package/include/micro-os-plus/architecture-riscv/defines.h +13 -14
  9. package/include/micro-os-plus/architecture-riscv/device-functions.h +9 -10
  10. package/include/micro-os-plus/architecture-riscv/functions.h +35 -0
  11. package/include/micro-os-plus/architecture-riscv/{core-functions-inlines.h → inlines/core-functions-inlines.h} +9 -10
  12. package/include/micro-os-plus/architecture-riscv/{csr-functions-inlines.h → inlines/csr-functions-inlines.h} +25 -26
  13. package/include/micro-os-plus/architecture-riscv/{device-functions-inlines.h → inlines/device-functions-inlines.h} +9 -10
  14. package/include/micro-os-plus/architecture-riscv/{instructions-inlines.h → inlines/instructions-inlines.h} +12 -13
  15. package/include/micro-os-plus/architecture-riscv/{platform-functions-inlines.h → inlines/platform-functions-inlines.h} +9 -10
  16. package/include/micro-os-plus/architecture-riscv/inlines/semihosting-inlines.h +51 -0
  17. package/include/micro-os-plus/architecture-riscv/instructions.h +15 -11
  18. package/include/micro-os-plus/architecture-riscv/platform-functions.h +6 -7
  19. package/include/micro-os-plus/architecture-riscv/plic-functions.h +7 -8
  20. package/include/micro-os-plus/architecture-riscv/types.h +6 -7
  21. package/include/micro-os-plus/architecture.h +40 -17
  22. package/linker-scripts/sections-flash.ld +6 -7
  23. package/linker-scripts/sections-ram.ld +6 -7
  24. package/meson.build +83 -23
  25. package/package.json +56 -21
  26. package/src/semihosting.cpp +58 -0
  27. package/src/show-cpuid.cpp +28 -0
  28. package/xcdl-package.jsonc +33 -0
  29. package/include/micro-os-plus/architecture-riscv/semihosting-inlines.h +0 -79
  30. package/src/.gitkeep +0 -0
  31. package/xpack.json +0 -23
package/meson.build CHANGED
@@ -1,46 +1,106 @@
1
1
  # -----------------------------------------------------------------------------
2
+ # DO NOT EDIT! Automatically generated from template file:
3
+ # xcdl-package.jsonc
2
4
  #
3
- # This file is part of the µOS++ distribution.
4
- # (https://github.com/micro-os-plus/)
5
- # Copyright (c) 2022 Liviu Ionescu
5
+ # This file is part of the µOS++ project (https://micro-os-plus.github.io/).
6
+ # Copyright (c) 2022-2026 Liviu Ionescu. All rights reserved.
6
7
  #
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.
8
+ # Permission to use, copy, modify, and/or distribute this software for any
9
+ # purpose is hereby granted, under the terms of the MIT license.
9
10
  #
10
- # If a copy of the license was not distributed with this file, it can
11
- # be obtained from https://opensource.org/licenses/MIT/.
11
+ # If a copy of the license was not distributed with this file, it can be
12
+ # obtained from https://opensource.org/licenses/mit.
12
13
  #
13
14
  # -----------------------------------------------------------------------------
14
15
 
15
- # This file is intended to be consumed by applications with:
16
+ # This file is intended to be used by applications via:
16
17
  #
17
- # `subdir('xpacks/micro-os-plus-architecture-riscv')`
18
+ # `subdir('xpacks/@micro-os-plus/architecture-riscv')`
18
19
  #
19
- # The result is a dependency that can be referred as:
20
+ # This creates dependencies that can be linked to a target with:
20
21
  #
21
- # `dependencies: [micro_os_plus_architecture_dependency],`
22
+ # `dependencies: [micro_os_plus_architectures_riscv_dependency],`
22
23
 
23
- # Note: the meson configuration is provided only as a proof of concept,
24
+ # Note: the Meson configuration is provided only as a proof of concept;
24
25
  # for production it might need some refinements.
25
26
 
26
27
  # -----------------------------------------------------------------------------
27
28
 
28
- message('Processing xPack @micro-os-plus/architecture-riscv...')
29
+ # A source code library with the µOS++ RISC-V architecture port.
30
+ message('Processing xpm package @micro-os-plus/architecture-riscv...')
31
+
32
+ # -----------------------------------------------------------------------------
33
+
34
+ # Meson's DSL does not provide introspection methods on dependency objects
35
+ # to retrieve their properties after creation. The `_local_*` variables
36
+ # therefore serve a dual purpose: populating the dependency object and
37
+ # iterating over its components for the `message()` calls at the end.
38
+
39
+ _local_compile_args = [] # Common C/C++ args.
40
+ _local_compile_c_args = [] # C only args.
41
+ _local_compile_cpp_args = [] # C++ only args.
42
+ _local_include_directories = []
43
+ _local_sources = []
44
+ _local_compile_definitions = []
45
+ _local_dependencies = []
46
+ _local_link_args = []
47
+ _local_link_with = []
48
+
49
+ _local_include_directories += [
50
+ 'include',
51
+ ]
52
+
53
+ _local_sources += [
54
+ 'src/semihosting.cpp',
55
+ 'src/show-cpuid.cpp',
56
+ ]
29
57
 
30
58
  # https://mesonbuild.com/Reference-manual_functions.html#declare_dependency
59
+ micro_os_plus_architectures_riscv_dependency = declare_dependency(
60
+ include_directories: include_directories(_local_include_directories),
61
+ compile_args: _local_compile_args,
62
+ sources: files(_local_sources),
63
+ dependencies: _local_dependencies,
64
+ link_args: _local_link_args,
65
+ link_with: _local_link_with,
66
+ )
67
+
68
+ # Meson dependencies cannot differentiate between C and C++ compile args;
69
+ # they are therefore exposed as separate variables alongside the dependency.
70
+ micro_os_plus_architectures_riscv_dependency_compile_c_args = _local_compile_c_args
71
+ micro_os_plus_architectures_riscv_dependency_compile_cpp_args = _local_compile_cpp_args
72
+
73
+ foreach name : _local_include_directories
74
+ message('+ -I ' + name)
75
+ endforeach
76
+ foreach name : _local_sources + _local_compile_definitions + _local_compile_args + _local_compile_c_args + _local_compile_cpp_args
77
+ message('+ ' + name)
78
+ endforeach
79
+ message('> micro_os_plus_architectures_riscv_dependency')
80
+
81
+ # -----------------------------------------------------------------------------
82
+ # Alias.
83
+
31
84
  micro_os_plus_architecture_dependency = declare_dependency(
32
- include_directories: include_directories(
33
- 'include',
34
- ),
35
- sources: files(
36
- ),
37
- compile_args: [
38
- ],
39
- dependencies: [
40
- ]
85
+ include_directories: include_directories(_local_include_directories),
86
+ compile_args: _local_compile_args,
87
+ sources: files(_local_sources),
88
+ dependencies: _local_dependencies,
89
+ link_args: _local_link_args,
90
+ link_with: _local_link_with,
41
91
  )
42
92
 
43
- message('+ -I include')
93
+ # Meson dependencies cannot differentiate between C and C++ compile args;
94
+ # they are therefore exposed as separate variables alongside the dependency.
95
+ micro_os_plus_architecture_dependency_compile_c_args = _local_compile_c_args
96
+ micro_os_plus_architecture_dependency_compile_cpp_args = _local_compile_cpp_args
97
+
98
+ foreach name : _local_include_directories
99
+ message('+ -I ' + name)
100
+ endforeach
101
+ foreach name : _local_sources + _local_compile_definitions + _local_compile_args + _local_compile_c_args + _local_compile_cpp_args
102
+ message('+ ' + name)
103
+ endforeach
44
104
  message('> micro_os_plus_architecture_dependency')
45
105
 
46
106
  # -----------------------------------------------------------------------------
package/package.json CHANGED
@@ -1,20 +1,7 @@
1
1
  {
2
2
  "name": "@micro-os-plus/architecture-riscv",
3
- "version": "4.1.0",
4
- "description": "A source library xPack with the µOS++ RISC-V architecture port",
5
- "main": "",
6
- "scripts": {
7
- "npm-install": "npm install",
8
- "pack": "npm pack",
9
- "version-patch": "npm version patch",
10
- "version-minor": "npm version minor",
11
- "postversion": "git push origin --all && git push origin --tags",
12
- "git-log": "git log --pretty='%cd * %h %s' --date=short"
13
- },
14
- "repository": {
15
- "type": "git",
16
- "url": "https://github.com/micro-os-plus/architecture-riscv-xpack.git/"
17
- },
3
+ "version": "5.1.0",
4
+ "description": "A source code library with the µOS++ RISC-V architecture port",
18
5
  "keywords": [
19
6
  "xpack",
20
7
  "c++",
@@ -22,16 +9,64 @@
22
9
  "risc-v",
23
10
  "architecture"
24
11
  ],
25
- "homepage": "https://github.com/micro-os-plus/architecture-riscv-xpack/",
12
+ "license": "MIT",
26
13
  "author": {
27
14
  "name": "Liviu Ionescu",
28
15
  "email": "ilg@livius.net",
29
- "url": "https://github.com/ilg-ul/"
16
+ "url": "https://github.com/ilg-ul"
30
17
  },
31
- "license": "MIT",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/micro-os-plus/architecture-riscv-xpack.git"
21
+ },
22
+ "homepage": "https://micro-os-plus.github.io/architecture-riscv-xpack/",
32
23
  "bugs": {
33
- "url": "https://github.com/micro-os-plus/architecture-riscv-xpack/issues/"
24
+ "url": "https://github.com/micro-os-plus/architecture-riscv-xpack/issues"
25
+ },
26
+ "$dependenciesUrls": {
27
+ "del-cli": "https://www.npmjs.com/package/del-cli",
28
+ "json": "https://www.npmjs.com/package/json",
29
+ "liquidjs": "https://www.npmjs.com/package/liquidjs",
30
+ "glob": "https://www.npmjs.com/package/glob",
31
+ "json5": "https://www.npmjs.com/package/json5",
32
+ "jsonc-parser": "https://www.npmjs.com/package/jsonc-parser"
33
+ },
34
+ "dependencies": {},
35
+ "devDependencies": {
36
+ "@xpack/npm-packages-helper": "github:xpack/npm-packages-helper",
37
+ "del-cli": "^7.0.0",
38
+ "json": "^11.0.0",
39
+ "liquidjs": "^10.25.0",
40
+ "glob": "^13.0.6",
41
+ "json5": "^2.2.3",
42
+ "jsonc-parser": "^3.3.1"
43
+ },
44
+ "scripts": {
45
+ "generate-top-commons": "node node_modules/@xpack/npm-packages-helper/maintenance-scripts/generate-top-commons.mjs --micro-os-plus",
46
+ "npm-install": "npm install",
47
+ "npm-link-helpers": "npm link @xpack/npm-packages-helper",
48
+ "npm-outdated": "npm outdated",
49
+ "npm-ci": "npm ci",
50
+ "npm-pack": "npm pack",
51
+ "npm-link": "npm link",
52
+ "git-log": "git log --pretty='%cd * %h %s' --date=short",
53
+ "git-pull-helper": "git -C ${HOME}/Work/micro-os-plus/build-helper-xpack.git pull",
54
+ "deep-clean": "del-cli node_modules package-lock.json *.tgz",
55
+ "postversion": "git push origin --all && git push origin --tags"
56
+ },
57
+ "xpack": {
58
+ "minimumXpmRequired": "0.20.8",
59
+ "devDependencies": {
60
+ "@xpack-dev-tools/clang": "21.1.8-1.1"
61
+ },
62
+ "actions": {
63
+ "clang-format": "node scripts/clang-format.mjs",
64
+ "cmake-format": "node scripts/cmake-format.mjs",
65
+ "jsonc-format": "node scripts/jsonc-format.mjs",
66
+ "xcdl-export": "node scripts/xcdl-export.mjs xcdl-package.json*"
67
+ }
34
68
  },
35
- "config": {},
36
- "xpack": {}
69
+ "engines": {
70
+ "node": ">=20.0"
71
+ }
37
72
  }
@@ -0,0 +1,58 @@
1
+ /*
2
+ * This file is part of the µOS++ project (https://micro-os-plus.github.io/).
3
+ * Copyright (c) 2023-2026 Liviu Ionescu. All rights reserved.
4
+ *
5
+ * Permission to use, copy, modify, and/or distribute this software for any
6
+ * purpose is hereby granted, under the terms of the MIT license.
7
+ *
8
+ * If a copy of the license was not distributed with this file, it can be
9
+ * obtained from https://opensource.org/licenses/mit.
10
+ */
11
+
12
+ // ----------------------------------------------------------------------------
13
+
14
+ #include "micro-os-plus/architecture.h"
15
+ #include "micro-os-plus/semihosting.h"
16
+
17
+ // ----------------------------------------------------------------------------
18
+
19
+ #if defined(MICRO_OS_PLUS_SEMIHOSTING_ENABLED)
20
+
21
+ // ----------------------------------------------------------------------------
22
+
23
+ micro_os_plus_semihosting_response_t
24
+ micro_os_plus_semihosting_call_host (
25
+ int reason, micro_os_plus_semihosting_param_block_t* arg)
26
+ {
27
+ micro_os_plus_semihosting_response_t value;
28
+
29
+ __asm__ volatile (
30
+
31
+ " mv a0, %[rsn] \n"
32
+ " mv a1, %[arg] \n"
33
+
34
+ " .balign 16 \n"
35
+ // Workaround for RISC-V lack of multiple EBREAKs.
36
+ " .option push \n"
37
+ " .option norvc \n"
38
+ " slli x0, x0, 0x1f \n"
39
+ " ebreak \n"
40
+ " srai x0, x0, %[swi] \n"
41
+ " .option pop \n"
42
+
43
+ " mv %[val], a0"
44
+
45
+ : [val] "=r"(value) /* Outputs */
46
+ : [rsn] "r"(reason), [arg] "r"(arg),
47
+ [swi] "i"(RISCV_SEMIHOSTING_CALL_NUMBER) /* Inputs */
48
+ : "a0", "a1", "a2", "a3", "a4", "a5", "memory" /* Clobbers */
49
+ );
50
+
51
+ return value;
52
+ }
53
+
54
+ // ----------------------------------------------------------------------------
55
+
56
+ #endif // defined(MICRO_OS_PLUS_SEMIHOSTING_ENABLED)
57
+
58
+ // ----------------------------------------------------------------------------
@@ -0,0 +1,28 @@
1
+ /*
2
+ * This file is part of the µOS++ project (https://micro-os-plus.github.io/).
3
+ * Copyright (c) 2023-2026 Liviu Ionescu. All rights reserved.
4
+ *
5
+ * Permission to use, copy, modify, and/or distribute this software for any
6
+ * purpose is hereby granted, under the terms of the MIT license.
7
+ *
8
+ * If a copy of the license was not distributed with this file, it can be
9
+ * obtained from https://opensource.org/licenses/mit.
10
+ */
11
+
12
+ // ----------------------------------------------------------------------------
13
+
14
+ #include "micro-os-plus/architecture.h"
15
+ // #include "micro-os-plus/diag/trace.h"
16
+
17
+ // ----------------------------------------------------------------------------
18
+
19
+ using namespace micro_os_plus;
20
+
21
+ // ----------------------------------------------------------------------------
22
+
23
+ void
24
+ micro_os_plus_architecture_show_cpuid (void)
25
+ {
26
+ }
27
+
28
+ // ----------------------------------------------------------------------------
@@ -0,0 +1,33 @@
1
+ {
2
+ "$schema": "https://xpack.github.io/xcdl/schemas/xcdl-2.0.0.json",
3
+ "minimumXcdlRequired": "2.0.0",
4
+ "license": "MIT",
5
+ "copyright": "Copyright (c) 2022-2026 Liviu Ionescu. All rights reserved.",
6
+ "cdlComponents": [
7
+ {
8
+ "id": "micro-os-plus.architectures.riscv",
9
+ "alias": "micro-os-plus.architecture",
10
+ "display": "RISC-V architecture",
11
+ "description": "The RISC-V architecture definitions",
12
+ "publicIncludeFolders": [
13
+ "include"
14
+ ],
15
+ "sourceFiles": [
16
+ "src/semihosting.cpp",
17
+ "src/show-cpuid.cpp"
18
+ ],
19
+ "dependencies": [
20
+ // This introduces a circular dependency.
21
+ // "micro-os-plus.semihosting"
22
+ ],
23
+ "implementedInterfaces": [
24
+ "micro-os-plus.architecture"
25
+ ],
26
+ "generatedFile": {
27
+ "type": "c-header",
28
+ "filePath": "{{buildFolderPath}}/generated/include/micro-os-plus/architecture-defines.h"
29
+ },
30
+ // "defaultDefine": "MICRO_OS_PLUS_INCLUDE_ARCHITECTURES_RISCV_ENABLED"
31
+ }
32
+ ]
33
+ }
@@ -1,79 +0,0 @@
1
- /*
2
- * This file is part of the µOS++ distribution.
3
- * (https://github.com/micro-os-plus/)
4
- * Copyright (c) 2015 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_ARCH_SEMIHOSTING_INLINES_H_
14
- #define MICRO_OS_PLUS_ARCHITECTURE_RISCV_ARCH_SEMIHOSTING_INLINES_H_
15
-
16
- // ----------------------------------------------------------------------------
17
-
18
- #if defined(__cplusplus)
19
- extern "C"
20
- {
21
- #endif // defined(__cplusplus)
22
-
23
- // --------------------------------------------------------------------------
24
-
25
- // The hint that differentiates the semihosting call.
26
- #define RISCV_SEMIHOSTING_CALL_NUMBER 7
27
-
28
- // --------------------------------------------------------------------------
29
-
30
- // Type of each entry in a parameter block.
31
- typedef micro_os_plus_architecture_register_t
32
- micro_os_plus_semihosting_param_block_t;
33
- // Type of result.
34
- typedef micro_os_plus_architecture_signed_register_t
35
- micro_os_plus_semihosting_response_t;
36
-
37
- // --------------------------------------------------------------------------
38
-
39
- static inline __attribute__ ((always_inline))
40
- micro_os_plus_semihosting_response_t
41
- micro_os_plus_semihosting_call_host (int reason, void* arg)
42
- {
43
- micro_os_plus_semihosting_response_t value;
44
-
45
- __asm__ volatile(
46
-
47
- " mv a0, %[rsn] \n"
48
- " mv a1, %[arg] \n"
49
-
50
- " .balign 16 \n"
51
- // Workaround for RISC-V lack of multiple EBREAKs.
52
- " .option push \n"
53
- " .option norvc \n"
54
- " slli x0, x0, 0x1f \n"
55
- " ebreak \n"
56
- " srai x0, x0, %[swi] \n"
57
- " .option pop \n"
58
-
59
- " mv %[val], a0"
60
-
61
- : [val] "=r"(value) /* Outputs */
62
- : [rsn] "r"(reason), [arg] "r"(arg), [swi] "i"(RISCV_SEMIHOSTING_CALL_NUMBER) /* Inputs */
63
- : "a0", "a1", "a2", "a3", "a4", "a5", "memory" /* Clobbers */
64
- );
65
-
66
- return value;
67
- }
68
-
69
- // --------------------------------------------------------------------------
70
-
71
- #if defined(__cplusplus)
72
- }
73
- #endif // defined(__cplusplus)
74
-
75
- // ----------------------------------------------------------------------------
76
-
77
- #endif // MICRO_OS_PLUS_ARCHITECTURE_RISCV_ARCH_SEMIHOSTING_INLINES_H_
78
-
79
- // ----------------------------------------------------------------------------
package/src/.gitkeep DELETED
File without changes
package/xpack.json DELETED
@@ -1,23 +0,0 @@
1
- {
2
- "minimumXpmakeRequired": "0.0.0",
3
- "license": "MIT",
4
- "copyright": "Copyright (c) 2022 Liviu Ionescu",
5
- "description": "Top architecture RISC-V components",
6
- "cdlComponents": {
7
- "architecture-riscv": {
8
- "description": "The RISC-V architecture definitions.",
9
- "parent": "micro-os-plus",
10
- "compilerIncludeFolders": [
11
- "include"
12
- ],
13
- "compilerSourceFiles": [],
14
- "compilerDefinitions": [],
15
- "compilerOptions": [],
16
- "dependencies": [],
17
- "generatedDefinition": "MICRO_OS_PLUS_INCLUDE_ARCHITECTURE_RISCV",
18
- "implementedInterfaces": [
19
- "architecture"
20
- ]
21
- }
22
- }
23
- }