@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.
Files changed (28) hide show
  1. package/CHANGELOG.md +152 -0
  2. package/CMakeLists.txt +87 -0
  3. package/LICENSE +21 -0
  4. package/README.md +317 -0
  5. package/include/micro-os-plus/architecture-riscv/core-functions-inlines.h +86 -0
  6. package/include/micro-os-plus/architecture-riscv/core-functions.h +105 -0
  7. package/include/micro-os-plus/architecture-riscv/csr-functions-inlines.h +466 -0
  8. package/include/micro-os-plus/architecture-riscv/csr-functions.h +241 -0
  9. package/include/micro-os-plus/architecture-riscv/declarations.h +58 -0
  10. package/include/micro-os-plus/architecture-riscv/defines.h +185 -0
  11. package/include/micro-os-plus/architecture-riscv/device-functions-inlines.h +235 -0
  12. package/include/micro-os-plus/architecture-riscv/device-functions.h +166 -0
  13. package/include/micro-os-plus/architecture-riscv/instructions-inlines.h +172 -0
  14. package/include/micro-os-plus/architecture-riscv/instructions.h +153 -0
  15. package/include/micro-os-plus/architecture-riscv/platform-functions-inlines.h +81 -0
  16. package/include/micro-os-plus/architecture-riscv/platform-functions.h +75 -0
  17. package/include/micro-os-plus/architecture-riscv/plic-functions.h +278 -0
  18. package/include/micro-os-plus/architecture-riscv/semihosting-inlines.h +79 -0
  19. package/include/micro-os-plus/architecture-riscv/types.h +135 -0
  20. package/include/micro-os-plus/architecture.h +38 -0
  21. package/linker-scripts/README.md +7 -0
  22. package/linker-scripts/sections-flash.ld +425 -0
  23. package/linker-scripts/sections-ram.ld +425 -0
  24. package/linker-scripts/sections.ld +377 -0
  25. package/meson.build +46 -0
  26. package/package.json +37 -0
  27. package/src/.gitkeep +0 -0
  28. package/xpack.json +23 -0
@@ -0,0 +1,377 @@
1
+ /*
2
+ * Default linker script.
3
+ *
4
+ * Static constructors/destructors use the new .init_array/.fini_array
5
+ * definitions; the old .init/.fini are no longer used.
6
+ *
7
+ * The heap starts immediately after the last statically allocated
8
+ * .bss/.noinit section (the _end symbol), and extends up to the stack.
9
+ *
10
+ * To make use of the multi-region initialisations, define
11
+ * MICRO_OS_PLUS_INCLUDE_STARTUP_INIT_MULTIPLE_RAM_SECTIONS for the _startup.cpp file.
12
+ */
13
+
14
+ /*
15
+ * Explicitly define the RISC-V architecture.
16
+ */
17
+ OUTPUT_ARCH( "riscv" )
18
+
19
+ /*
20
+ * The entry point is important for debuggers and simulators, the
21
+ * hardware has its own notion of the startup address.
22
+ */
23
+ ENTRY(riscv_reset_entry)
24
+
25
+ /*
26
+ * The '__stack' definition is required by newlib crt0; do not remove it.
27
+ * The stack is located at the very end of the RAM region.
28
+ */
29
+ __stack = ORIGIN(RAM) + LENGTH(RAM);
30
+ __stack_size = DEFINED(__stack_size) ? __stack_size : 2K;
31
+
32
+ /*
33
+ * The ELF object file format uses program headers, also knows as segments.
34
+ * The program headers describe how the program should be loaded into memory.
35
+ * You can print them out by using the objdump program with the ‘-p’ option.
36
+ */
37
+ PHDRS
38
+ {
39
+ phdr_flash PT_LOAD;
40
+ phdr_ram_init PT_LOAD;
41
+ phdr_ram PT_NULL;
42
+ }
43
+
44
+ SECTIONS
45
+ {
46
+ /*
47
+ * On RISC-V devices the startup address is a regular address, so this
48
+ * must be the very first section.
49
+ * Apart from the assembly code used to initialise the stack,
50
+ * do not place anything else into this section.
51
+ */
52
+ .reset_entry : ALIGN(4)
53
+ {
54
+ KEEP(*(SORT_NONE(.reset_entry) SORT_NONE(.reset_entry.*)))
55
+ } >FLASH AT>FLASH :phdr_flash
56
+
57
+ /*
58
+ * Dynamic Run Time Metadata.
59
+ * Normally the debugger reaches this section by resolving a symbol,
60
+ * but in case it should scan memory for the magic, better place this
61
+ * section as early as possible.
62
+ */
63
+ .drtm : ALIGN(4)
64
+ {
65
+ KEEP(*(.drtm .drtm.*))
66
+ } >FLASH AT>FLASH :phdr_flash
67
+
68
+ /*
69
+ * For convenience, place the trap code early.
70
+ */
71
+ .trap_entry : ALIGN(4)
72
+ {
73
+ *(.exceptions_array .exceptions_array.*)
74
+ *(.interrupts_local_array .interrupts_local_array.*)
75
+ *(.interrupts_global_array .interrupts_global_array.*)
76
+ *(.trap_entry .trap_entry.*)
77
+ *(.traps_handlers .traps_handlers.*)
78
+ } >FLASH AT>FLASH :phdr_flash
79
+
80
+ /*
81
+ * Memory regions initialization arrays.
82
+ *
83
+ * There are two kinds of arrays for each RAM region, one for
84
+ * data and one for bss. Each is iterated at startup and the
85
+ * region initialization is performed.
86
+ *
87
+ * The data array includes:
88
+ * - from (LOADADDR())
89
+ * - region_begin (ADDR())
90
+ * - region_end (ADDR()+SIZEOF())
91
+ *
92
+ * The bss array includes:
93
+ * - region_begin (ADDR())
94
+ * - region_end (ADDR()+SIZEOF())
95
+ *
96
+ * WARNING: It is mandatory that the regions are word aligned,
97
+ * since the initialization code works only on words.
98
+ */
99
+ .mem_inits : ALIGN(4)
100
+ {
101
+ PROVIDE_HIDDEN(__data_regions_array_begin__ = .); /* µOS++ specific. */
102
+
103
+ LONG(LOADADDR(.data));
104
+ LONG(ADDR(.data));
105
+ LONG(ADDR(.data)+SIZEOF(.data));
106
+
107
+ /* If more DATA regions are needed, add more such records. */
108
+
109
+ PROVIDE_HIDDEN(__data_regions_array_end__ = .); /* µOS++ specific. */
110
+
111
+ PROVIDE_HIDDEN(__bss_regions_array_begin__ = .); /* µOS++ specific. */
112
+
113
+ LONG(ADDR(.bss));
114
+ LONG(ADDR(.bss)+SIZEOF(.bss));
115
+
116
+ /* If more BSS regions are needed, add more such records. */
117
+
118
+ PROVIDE_HIDDEN(__bss_regions_array_end__ = .); /* µOS++ specific. */
119
+ } >FLASH AT>FLASH :phdr_flash
120
+
121
+ /*
122
+ * The preinit code, i.e. an array of pointers to initialization
123
+ * functions to be performed before constructors.
124
+ */
125
+ .preinit_array : ALIGN(4)
126
+ {
127
+ /*
128
+ * PROVIDE not used intentionally,
129
+ * this symbol must not be used for other purposes.
130
+ */
131
+ __preinit_array_start = .; /* µOS++ specific. */
132
+ __preinit_array_begin__ = .; /* µOS++ specific. */
133
+
134
+ /*
135
+ * Used to run the system inits before anything else.
136
+ */
137
+ KEEP(*(.preinit_array_sysinit .preinit_array_sysinit.*))
138
+
139
+ /*
140
+ * Used for other platform inits.
141
+ */
142
+ KEEP(*(.preinit_array_platform .preinit_array_platform.*))
143
+
144
+ /*
145
+ * The application inits. If you need to enforce some order in
146
+ * execution, create new sections, as before.
147
+ */
148
+ KEEP(*(.preinit_array .preinit_array.*))
149
+
150
+ __preinit_array_end = .; /* µOS++ specific. */
151
+ __preinit_array_end__ = .; /* µOS++ specific. */
152
+ } >FLASH AT>FLASH :phdr_flash
153
+
154
+ /*
155
+ * The init code, i.e. an array of pointers to static constructors.
156
+ */
157
+ .init_array : ALIGN(4)
158
+ {
159
+ /* PROVIDE not used intentionally, this symbol must not be used. */
160
+ __init_array_start = .; /* Standard newlib definition. */
161
+
162
+ KEEP(*(SORT_BY_INIT_PRIORITY(.init_array.*) SORT_BY_INIT_PRIORITY(.ctors.*)))
163
+ KEEP(*(.init_array EXCLUDE_FILE(*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .ctors))
164
+
165
+ __init_array_end = .; /* Standard newlib definition. */
166
+ } >FLASH AT>FLASH :phdr_flash
167
+
168
+ /*
169
+ * The fini code, i.e. an array of pointers to static destructors.
170
+ */
171
+ .fini_array : ALIGN(4)
172
+ {
173
+ /* PROVIDE not used intentionally, this symbol must not be used. */
174
+ __fini_array_start = .; /* Standard newlib definition. */
175
+
176
+ KEEP(*(SORT_BY_INIT_PRIORITY(.fini_array.*) SORT_BY_INIT_PRIORITY(.dtors.*)))
177
+ KEEP(*(.fini_array EXCLUDE_FILE(*crtbegin.o *crtbegin?.o *crtend.o *crtend?.o ) .dtors))
178
+
179
+ __fini_array_end = .; /* Standard newlib definition. */
180
+ } >FLASH AT>FLASH :phdr_flash
181
+
182
+ /*
183
+ * The program code.
184
+ */
185
+ .text : ALIGN(4)
186
+ {
187
+ *(.text.unlikely .text.unlikely.*)
188
+ *(.text.startup .text.startup.*)
189
+ *(.text .text.*)
190
+ *(.gnu.linkonce.t.*)
191
+ } >FLASH AT>FLASH :phdr_flash
192
+
193
+ . = ALIGN(4);
194
+ PROVIDE(__etext = .);
195
+ PROVIDE(_etext = .);
196
+ PROVIDE(etext = .);
197
+
198
+ /*
199
+ * C++ virtual tables.
200
+ */
201
+ .vtable : ALIGN(4)
202
+ {
203
+ KEEP(*(vtable))
204
+ } >FLASH AT>FLASH :phdr_flash
205
+
206
+ /*
207
+ * Exception frames.
208
+ */
209
+ .exceptions : ALIGN(4)
210
+ {
211
+ KEEP(*(.eh_frame*))
212
+ *(.gcc_except_table)
213
+ } >FLASH AT>FLASH :phdr_flash
214
+
215
+ /*
216
+ * Read-only data (constants)
217
+ */
218
+ .rodata : ALIGN(4)
219
+ {
220
+ *(.rodata .rodata.*)
221
+ *(.constdata .constdata.*)
222
+ *(.gnu.linkonce.r.*)
223
+ } >FLASH AT>FLASH :phdr_flash
224
+
225
+ . = ALIGN(4);
226
+ PROVIDE( _data = . );
227
+
228
+ /*
229
+ * The initialised data section.
230
+ *
231
+ * The program executes knowing that the data is in RAM
232
+ * but the loader puts the initial values in FLASH.
233
+ * The startup will copy the initial values from FLASH to RAM.
234
+ */
235
+ .data : ALIGN(4)
236
+ {
237
+ FILL(0xFF)
238
+
239
+ __data_start__ = . ; /* Standard newlib definition. */
240
+ __data_begin__ = . ; /* µOS++ specific */
241
+ *(.data_begin .data_begin.*) /* µOS++ __data_begin_guard */
242
+
243
+ *(.data .data.*)
244
+ *(.gnu.linkonce.d.*)
245
+
246
+ . = ALIGN(8);
247
+ /*
248
+ * RISC-V specific; the compiler optimises memory accesses
249
+ * in the +/- 2K range around __global_pointer$ to GP relative.
250
+ * For this to work, GP must be loaded during startup with the
251
+ * address of __global_pointer$.
252
+ * This optimisation favours a 4K range. Newlib places
253
+ * several impure and malloc pointers in the .sdata section.
254
+ */
255
+ PROVIDE( __global_pointer$ = . + (4K / 2) );
256
+
257
+ *(.sdata .sdata.*)
258
+ *(.gnu.linkonce.s.*)
259
+
260
+ /* RISC-V specific; not sure if needed. */
261
+ . = ALIGN(8);
262
+ *(.srodata.cst16)
263
+ *(.srodata.cst8)
264
+ *(.srodata.cst4)
265
+ *(.srodata.cst2)
266
+ *(.srodata .srodata.*)
267
+
268
+ *(.data_end .data_end.*) /* µOS++ __data_end_guard; must be last */
269
+ . = ALIGN(4);
270
+ __data_end__ = . ; /* Standard newlib definition. */
271
+ } >RAM AT>FLASH :phdr_ram_init
272
+
273
+ /*
274
+ * This address is used by the µOS++ startup code to
275
+ * initialise the .data section.
276
+ */
277
+ __data_load_addr__ = LOADADDR(.data);
278
+
279
+ . = ALIGN(4);
280
+ PROVIDE( __edata = . );
281
+ PROVIDE( _edata = . );
282
+ PROVIDE( edata = . );
283
+
284
+ /*
285
+ * The uninitialised data sections. NOLOAD is used to avoid
286
+ * the "section `.bss' type changed to PROGBITS" warning
287
+ */
288
+
289
+ /* The primary uninitialised data section. */
290
+ .bss (NOLOAD) : ALIGN(4)
291
+ {
292
+ __bss_start = .; /* Standard newlib definition. */
293
+ __bss_start__ = .; /* Standard newlib definition. */
294
+ __bss_begin__ = .; /* µOS++ specific */
295
+ *(.bss_begin .bss_begin.*) /* µOS++ __bss_begin_guard */
296
+
297
+ *(.sbss .sbss.*)
298
+ *(.gnu.linkonce.sb.*)
299
+
300
+ *(.bss .bss.*)
301
+ *(.gnu.linkonce.b.*)
302
+ *(COMMON)
303
+
304
+ *(.bss_end .bss_end.*) /* µOS++ __bss_end_guard; must be last */
305
+ . = ALIGN(4);
306
+ __bss_end__ = .; /* Standard newlib definition. */
307
+ __bss_end = .; /* Standard newlib definition. */
308
+ } >RAM AT>RAM :phdr_ram
309
+
310
+ /*
311
+ * Similar to .bss, but not initialised to zero. µOS++ extension.
312
+ */
313
+ .noinit (NOLOAD) : ALIGN(4)
314
+ {
315
+ __noinit_begin__ = .; /* µOS++ extension. */
316
+
317
+ *(.noinit .noinit.*)
318
+
319
+ . = ALIGN(4) ;
320
+ __noinit_end__ = .; /* µOS++ extension. */
321
+ } >RAM AT>RAM :phdr_ram
322
+
323
+ /* _sbrk() expects at least word alignment. */
324
+ . = ALIGN(8);
325
+ PROVIDE( __end = . );
326
+ PROVIDE( _end = . );
327
+ PROVIDE( end = . );
328
+
329
+ PROVIDE( __heap_begin__ = . ); /* µOS++ extension. */
330
+
331
+ .stack __stack - __stack_size :
332
+ {
333
+ PROVIDE( _heap_end = . ); /* Standard newlib definition. */
334
+ PROVIDE( __heap_end__ = . ); /* µOS++ extension. */
335
+ . += __stack_size;
336
+ } >RAM AT>RAM :phdr_ram
337
+
338
+
339
+ /*
340
+ * Stabs debugging sections.
341
+ */
342
+ .stab 0 : { *(.stab) }
343
+ .stabstr 0 : { *(.stabstr) }
344
+ .stab.excl 0 : { *(.stab.excl) }
345
+ .stab.exclstr 0 : { *(.stab.exclstr) }
346
+ .stab.index 0 : { *(.stab.index) }
347
+ .stab.indexstr 0 : { *(.stab.indexstr) }
348
+ .comment 0 : { *(.comment) }
349
+
350
+ /*
351
+ * DWARF debug sections.
352
+ * Symbols in the DWARF debugging sections are relative to the beginning
353
+ * of the section so we begin them at 0.
354
+ */
355
+ /* DWARF 1 */
356
+ .debug 0 : { *(.debug) }
357
+ .line 0 : { *(.line) }
358
+ /* GNU DWARF 1 extensions */
359
+ .debug_srcinfo 0 : { *(.debug_srcinfo) }
360
+ .debug_sfnames 0 : { *(.debug_sfnames) }
361
+ /* DWARF 1.1 and DWARF 2 */
362
+ .debug_aranges 0 : { *(.debug_aranges) }
363
+ .debug_pubnames 0 : { *(.debug_pubnames) }
364
+ /* DWARF 2 */
365
+ .debug_info 0 : { *(.debug_info .gnu.linkonce.wi.*) }
366
+ .debug_abbrev 0 : { *(.debug_abbrev) }
367
+ .debug_line 0 : { *(.debug_line) }
368
+ .debug_frame 0 : { *(.debug_frame) }
369
+ .debug_str 0 : { *(.debug_str) }
370
+ .debug_loc 0 : { *(.debug_loc) }
371
+ .debug_macinfo 0 : { *(.debug_macinfo) }
372
+ /* SGI/MIPS DWARF 2 extensions */
373
+ .debug_weaknames 0 : { *(.debug_weaknames) }
374
+ .debug_funcnames 0 : { *(.debug_funcnames) }
375
+ .debug_typenames 0 : { *(.debug_typenames) }
376
+ .debug_varnames 0 : { *(.debug_varnames) }
377
+ }
package/meson.build ADDED
@@ -0,0 +1,46 @@
1
+ # -----------------------------------------------------------------------------
2
+ #
3
+ # This file is part of the µOS++ distribution.
4
+ # (https://github.com/micro-os-plus/)
5
+ # Copyright (c) 2022 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
+ # `subdir('xpacks/micro-os-plus-architecture-riscv')`
18
+ #
19
+ # The result is a dependency that can be referred as:
20
+ #
21
+ # `dependencies: [micro_os_plus_architecture_dependency],`
22
+
23
+ # Note: the meson configuration is provided only as a proof of concept,
24
+ # for production it might need some refinements.
25
+
26
+ # -----------------------------------------------------------------------------
27
+
28
+ message('Processing xPack @micro-os-plus/architecture-riscv...')
29
+
30
+ # https://mesonbuild.com/Reference-manual_functions.html#declare_dependency
31
+ 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
+ ]
41
+ )
42
+
43
+ message('+ -I include')
44
+ message('> micro_os_plus_architecture_dependency')
45
+
46
+ # -----------------------------------------------------------------------------
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
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
+ },
18
+ "keywords": [
19
+ "xpack",
20
+ "c++",
21
+ "micro-os-plus",
22
+ "risc-v",
23
+ "architecture"
24
+ ],
25
+ "homepage": "https://github.com/micro-os-plus/architecture-riscv-xpack/",
26
+ "author": {
27
+ "name": "Liviu Ionescu",
28
+ "email": "ilg@livius.net",
29
+ "url": "https://github.com/ilg-ul/"
30
+ },
31
+ "license": "MIT",
32
+ "bugs": {
33
+ "url": "https://github.com/micro-os-plus/architecture-riscv-xpack/issues/"
34
+ },
35
+ "config": {},
36
+ "xpack": {}
37
+ }
package/src/.gitkeep ADDED
File without changes
package/xpack.json ADDED
@@ -0,0 +1,23 @@
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
+ }