@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
|
@@ -0,0 +1,166 @@
|
|
|
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_DEVICE_FUNCTIONS_H_
|
|
14
|
+
#define MICRO_OS_PLUS_ARCHITECTURE_RISCV_DEVICE_FUNCTIONS_H_
|
|
15
|
+
|
|
16
|
+
// ----------------------------------------------------------------------------
|
|
17
|
+
|
|
18
|
+
#include <micro-os-plus/architecture-riscv/types.h>
|
|
19
|
+
|
|
20
|
+
// ----------------------------------------------------------------------------
|
|
21
|
+
|
|
22
|
+
/*
|
|
23
|
+
* RISC-V device support functions.
|
|
24
|
+
*
|
|
25
|
+
* The declarations are part of the common design, but each device
|
|
26
|
+
* must define the actual address and include the file
|
|
27
|
+
* <micro-os-plus/architecture-riscv/device-functions-inlines.h>.
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
// ----------------------------------------------------------------------------
|
|
31
|
+
#if defined(__cplusplus)
|
|
32
|
+
extern "C"
|
|
33
|
+
{
|
|
34
|
+
#endif // defined(__cplusplus)
|
|
35
|
+
|
|
36
|
+
// --------------------------------------------------------------------------
|
|
37
|
+
// `mtime` functions.
|
|
38
|
+
|
|
39
|
+
#if __riscv_xlen == 64
|
|
40
|
+
static
|
|
41
|
+
#endif // __riscv_xlen == 64
|
|
42
|
+
uint64_t
|
|
43
|
+
riscv_device_read_mtime (void);
|
|
44
|
+
|
|
45
|
+
static uint32_t
|
|
46
|
+
riscv_device_read_mtime_low (void);
|
|
47
|
+
|
|
48
|
+
static uint32_t
|
|
49
|
+
riscv_device_read_mtime_high (void);
|
|
50
|
+
|
|
51
|
+
#if __riscv_xlen == 64
|
|
52
|
+
static
|
|
53
|
+
#endif // __riscv_xlen == 64
|
|
54
|
+
void
|
|
55
|
+
riscv_device_write_mtime (uint64_t value);
|
|
56
|
+
|
|
57
|
+
static void
|
|
58
|
+
riscv_device_write_mtime_low (uint32_t value);
|
|
59
|
+
|
|
60
|
+
static void
|
|
61
|
+
riscv_device_write_mtime_high (uint32_t value);
|
|
62
|
+
|
|
63
|
+
// --------------------------------------------------------------------------
|
|
64
|
+
// `mtimecmp` functions.
|
|
65
|
+
|
|
66
|
+
static uint64_t
|
|
67
|
+
riscv_device_read_mtimecmp (void);
|
|
68
|
+
|
|
69
|
+
static uint32_t
|
|
70
|
+
riscv_device_read_mtimecmp_low (void);
|
|
71
|
+
|
|
72
|
+
static uint32_t
|
|
73
|
+
riscv_device_read_mtimecmp_high (void);
|
|
74
|
+
|
|
75
|
+
#if __riscv_xlen == 64
|
|
76
|
+
static
|
|
77
|
+
#endif // __riscv_xlen == 64
|
|
78
|
+
void
|
|
79
|
+
riscv_device_write_mtimecmp (uint64_t value);
|
|
80
|
+
|
|
81
|
+
static void
|
|
82
|
+
riscv_device_write_mtimecmp_low (uint32_t value);
|
|
83
|
+
|
|
84
|
+
static void
|
|
85
|
+
riscv_device_write_mtimecmp_high (uint32_t value);
|
|
86
|
+
|
|
87
|
+
// --------------------------------------------------------------------------
|
|
88
|
+
|
|
89
|
+
#if defined(__cplusplus)
|
|
90
|
+
}
|
|
91
|
+
#endif // defined(__cplusplus)
|
|
92
|
+
|
|
93
|
+
// ============================================================================
|
|
94
|
+
|
|
95
|
+
#if defined(__cplusplus)
|
|
96
|
+
|
|
97
|
+
// ----------------------------------------------------------------------------
|
|
98
|
+
|
|
99
|
+
namespace riscv
|
|
100
|
+
{
|
|
101
|
+
namespace device
|
|
102
|
+
{
|
|
103
|
+
// ----------------------------------------------------------------------------
|
|
104
|
+
// `mtime` functions.
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* Read the RTC current counter.
|
|
108
|
+
*/
|
|
109
|
+
uint64_t
|
|
110
|
+
mtime (void);
|
|
111
|
+
|
|
112
|
+
uint32_t
|
|
113
|
+
mtime_low (void);
|
|
114
|
+
|
|
115
|
+
uint32_t
|
|
116
|
+
mtime_high (void);
|
|
117
|
+
|
|
118
|
+
void
|
|
119
|
+
mtime (uint64_t value);
|
|
120
|
+
|
|
121
|
+
void
|
|
122
|
+
mtime_low (uint32_t value);
|
|
123
|
+
|
|
124
|
+
void
|
|
125
|
+
mtime_high (uint32_t value);
|
|
126
|
+
|
|
127
|
+
// ------------------------------------------------------------------------
|
|
128
|
+
// `mtimecmp` functions.
|
|
129
|
+
|
|
130
|
+
/**
|
|
131
|
+
* Read the RTC comparator.
|
|
132
|
+
*/
|
|
133
|
+
uint64_t
|
|
134
|
+
mtimecmp (void);
|
|
135
|
+
|
|
136
|
+
uint32_t
|
|
137
|
+
mtimecmp_low (void);
|
|
138
|
+
|
|
139
|
+
uint32_t
|
|
140
|
+
mtimecmp_high (void);
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Write the RTC comparator.
|
|
144
|
+
*/
|
|
145
|
+
void
|
|
146
|
+
mtimecmp (uint64_t value);
|
|
147
|
+
|
|
148
|
+
void
|
|
149
|
+
mtimecmp_low (uint32_t value);
|
|
150
|
+
|
|
151
|
+
void
|
|
152
|
+
mtimecmp_high (uint32_t value);
|
|
153
|
+
|
|
154
|
+
// ------------------------------------------------------------------------
|
|
155
|
+
} // namespace device
|
|
156
|
+
} // namespace riscv
|
|
157
|
+
|
|
158
|
+
// ----------------------------------------------------------------------------
|
|
159
|
+
|
|
160
|
+
#endif // defined(__cplusplus)
|
|
161
|
+
|
|
162
|
+
// ----------------------------------------------------------------------------
|
|
163
|
+
|
|
164
|
+
#endif // MICRO_OS_PLUS_ARCHITECTURE_RISCV_DEVICE_FUNCTIONS_H_
|
|
165
|
+
|
|
166
|
+
// ----------------------------------------------------------------------------
|
|
@@ -0,0 +1,172 @@
|
|
|
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_ARCH_INSTRUCTIONS_INLINES_H_
|
|
14
|
+
#define MICRO_OS_PLUS_ARCHITECTURE_RISCV_ARCH_INSTRUCTIONS_INLINES_H_
|
|
15
|
+
|
|
16
|
+
// ----------------------------------------------------------------------------
|
|
17
|
+
|
|
18
|
+
#include <stdint.h>
|
|
19
|
+
|
|
20
|
+
// ----------------------------------------------------------------------------
|
|
21
|
+
|
|
22
|
+
// Inline implementations for the RISC-V architecture instructions.
|
|
23
|
+
|
|
24
|
+
#if defined(__cplusplus)
|
|
25
|
+
extern "C"
|
|
26
|
+
{
|
|
27
|
+
#endif // defined(__cplusplus)
|
|
28
|
+
|
|
29
|
+
// --------------------------------------------------------------------------
|
|
30
|
+
|
|
31
|
+
static inline __attribute__ ((always_inline)) void
|
|
32
|
+
riscv_architecture_nop (void)
|
|
33
|
+
{
|
|
34
|
+
__asm__ volatile(
|
|
35
|
+
|
|
36
|
+
" nop "
|
|
37
|
+
|
|
38
|
+
: /* Outputs */
|
|
39
|
+
: /* Inputs */
|
|
40
|
+
: /* Clobbers */
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
static inline __attribute__ ((always_inline)) void
|
|
45
|
+
riscv_architecture_ebreak (void)
|
|
46
|
+
{
|
|
47
|
+
__asm__ volatile(
|
|
48
|
+
|
|
49
|
+
" ebreak "
|
|
50
|
+
|
|
51
|
+
: /* Outputs */
|
|
52
|
+
: /* Inputs */
|
|
53
|
+
: /* Clobbers */
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static inline __attribute__ ((always_inline)) void
|
|
58
|
+
riscv_architecture_wfi (void)
|
|
59
|
+
{
|
|
60
|
+
__asm__ volatile(
|
|
61
|
+
|
|
62
|
+
" wfi "
|
|
63
|
+
|
|
64
|
+
: /* Outputs */
|
|
65
|
+
: /* Inputs */
|
|
66
|
+
: /* Clobbers */
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
static inline __attribute__ ((always_inline)) void
|
|
71
|
+
micro_os_plus_architecture_nop (void)
|
|
72
|
+
{
|
|
73
|
+
riscv_architecture_nop ();
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* `break` instruction.
|
|
78
|
+
*/
|
|
79
|
+
static inline __attribute__ ((always_inline)) void
|
|
80
|
+
micro_os_plus_architecture_brk (void)
|
|
81
|
+
{
|
|
82
|
+
riscv_architecture_ebreak ();
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* `wfi` instruction.
|
|
87
|
+
*/
|
|
88
|
+
static inline __attribute__ ((always_inline)) void
|
|
89
|
+
micro_os_plus_architecture_wfi (void)
|
|
90
|
+
{
|
|
91
|
+
riscv_architecture_wfi ();
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
// --------------------------------------------------------------------------
|
|
95
|
+
|
|
96
|
+
#if defined(__cplusplus)
|
|
97
|
+
}
|
|
98
|
+
#endif // defined(__cplusplus)
|
|
99
|
+
|
|
100
|
+
// ============================================================================
|
|
101
|
+
|
|
102
|
+
#if defined(__cplusplus)
|
|
103
|
+
|
|
104
|
+
// ----------------------------------------------------------------------------
|
|
105
|
+
|
|
106
|
+
namespace riscv
|
|
107
|
+
{
|
|
108
|
+
namespace architecture
|
|
109
|
+
{
|
|
110
|
+
// ------------------------------------------------------------------------
|
|
111
|
+
|
|
112
|
+
inline __attribute__ ((always_inline)) void
|
|
113
|
+
nop (void)
|
|
114
|
+
{
|
|
115
|
+
riscv_architecture_nop ();
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
inline __attribute__ ((always_inline)) void
|
|
119
|
+
ebreak (void)
|
|
120
|
+
{
|
|
121
|
+
riscv_architecture_ebreak ();
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
inline __attribute__ ((always_inline)) void
|
|
125
|
+
wfi (void)
|
|
126
|
+
{
|
|
127
|
+
riscv_architecture_wfi ();
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// ------------------------------------------------------------------------
|
|
131
|
+
} // namespace architecture
|
|
132
|
+
} // namespace riscv
|
|
133
|
+
|
|
134
|
+
// ----------------------------------------------------------------------------
|
|
135
|
+
// Inline functions.
|
|
136
|
+
namespace micro_os_plus
|
|
137
|
+
{
|
|
138
|
+
namespace architecture
|
|
139
|
+
{
|
|
140
|
+
// ------------------------------------------------------------------------
|
|
141
|
+
|
|
142
|
+
inline __attribute__ ((always_inline)) void
|
|
143
|
+
nop (void)
|
|
144
|
+
{
|
|
145
|
+
riscv::architecture::nop ();
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
inline __attribute__ ((always_inline)) void
|
|
149
|
+
brk (void)
|
|
150
|
+
{
|
|
151
|
+
riscv::architecture::ebreak ();
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
inline __attribute__ ((always_inline)) void
|
|
155
|
+
wfi (void)
|
|
156
|
+
{
|
|
157
|
+
riscv::architecture::wfi ();
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
// ------------------------------------------------------------------------
|
|
161
|
+
} // namespace architecture
|
|
162
|
+
} // namespace micro_os_plus
|
|
163
|
+
|
|
164
|
+
// ----------------------------------------------------------------------------
|
|
165
|
+
|
|
166
|
+
#endif // defined(__cplusplus)
|
|
167
|
+
|
|
168
|
+
// ----------------------------------------------------------------------------
|
|
169
|
+
|
|
170
|
+
#endif // MICRO_OS_PLUS_ARCHITECTURE_RISCV_ARCH_INSTRUCTIONS_INLINES_H_
|
|
171
|
+
|
|
172
|
+
// ----------------------------------------------------------------------------
|
|
@@ -0,0 +1,153 @@
|
|
|
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_ARCH_INSTRUCTIONS_H_
|
|
14
|
+
#define MICRO_OS_PLUS_ARCHITECTURE_RISCV_ARCH_INSTRUCTIONS_H_
|
|
15
|
+
|
|
16
|
+
// ----------------------------------------------------------------------------
|
|
17
|
+
|
|
18
|
+
#include <micro-os-plus/architecture-riscv/defines.h>
|
|
19
|
+
|
|
20
|
+
#include <stdint.h>
|
|
21
|
+
|
|
22
|
+
// ----------------------------------------------------------------------------
|
|
23
|
+
|
|
24
|
+
// Declarations of RISC-V functions to wrap architecture instructions.
|
|
25
|
+
|
|
26
|
+
#if defined(__cplusplus)
|
|
27
|
+
extern "C"
|
|
28
|
+
{
|
|
29
|
+
#endif // defined(__cplusplus)
|
|
30
|
+
|
|
31
|
+
// --------------------------------------------------------------------------
|
|
32
|
+
// Architecture assembly instructions in C.
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* `nop` instruction.
|
|
36
|
+
*/
|
|
37
|
+
static void
|
|
38
|
+
riscv_architecture_nop (void);
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* `ebreak` instruction.
|
|
42
|
+
*/
|
|
43
|
+
static void
|
|
44
|
+
riscv_architecture_ebreak (void);
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* `wfi` instruction.
|
|
48
|
+
*/
|
|
49
|
+
static void
|
|
50
|
+
riscv_architecture_wfi (void);
|
|
51
|
+
|
|
52
|
+
// --------------------------------------------------------------------------
|
|
53
|
+
// Portable architecture assembly instructions in C.
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* `nop` instruction.
|
|
57
|
+
*/
|
|
58
|
+
static void
|
|
59
|
+
micro_os_plus_architecture_nop (void);
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* `break` instruction.
|
|
63
|
+
*/
|
|
64
|
+
static void
|
|
65
|
+
micro_os_plus_architecture_brk (void);
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* `wfi` instruction.
|
|
69
|
+
*/
|
|
70
|
+
static void
|
|
71
|
+
micro_os_plus_architecture_wfi (void);
|
|
72
|
+
|
|
73
|
+
// --------------------------------------------------------------------------
|
|
74
|
+
|
|
75
|
+
#if defined(__cplusplus)
|
|
76
|
+
}
|
|
77
|
+
#endif // defined(__cplusplus)
|
|
78
|
+
|
|
79
|
+
// ============================================================================
|
|
80
|
+
|
|
81
|
+
#if defined(__cplusplus)
|
|
82
|
+
|
|
83
|
+
// ----------------------------------------------------------------------------
|
|
84
|
+
|
|
85
|
+
namespace riscv
|
|
86
|
+
{
|
|
87
|
+
namespace architecture
|
|
88
|
+
{
|
|
89
|
+
// ------------------------------------------------------------------------
|
|
90
|
+
// Architecture assembly instructions in C++.
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* The assembler `nop` instruction.
|
|
94
|
+
*/
|
|
95
|
+
void
|
|
96
|
+
nop (void);
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* The assembler `ebreak` instruction.
|
|
100
|
+
*/
|
|
101
|
+
void
|
|
102
|
+
ebreak (void);
|
|
103
|
+
|
|
104
|
+
/**
|
|
105
|
+
* The assembler `wfi` instruction.
|
|
106
|
+
*/
|
|
107
|
+
void
|
|
108
|
+
wfi (void);
|
|
109
|
+
|
|
110
|
+
// ------------------------------------------------------------------------
|
|
111
|
+
} // namespace architecture
|
|
112
|
+
} // namespace riscv
|
|
113
|
+
|
|
114
|
+
// ----------------------------------------------------------------------------
|
|
115
|
+
// Inline functions.
|
|
116
|
+
namespace micro_os_plus
|
|
117
|
+
{
|
|
118
|
+
namespace architecture
|
|
119
|
+
{
|
|
120
|
+
// ------------------------------------------------------------------------
|
|
121
|
+
// Portable architecture assembly instructions in C++.
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* The assembler `nop` instruction.
|
|
125
|
+
*/
|
|
126
|
+
void
|
|
127
|
+
nop (void);
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* The assembler `break` instruction.
|
|
131
|
+
*/
|
|
132
|
+
void
|
|
133
|
+
brk (void);
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* The assembler `wfi` instruction.
|
|
137
|
+
*/
|
|
138
|
+
void
|
|
139
|
+
wfi (void);
|
|
140
|
+
|
|
141
|
+
// ------------------------------------------------------------------------
|
|
142
|
+
} // namespace architecture
|
|
143
|
+
} // namespace micro_os_plus
|
|
144
|
+
|
|
145
|
+
// ----------------------------------------------------------------------------
|
|
146
|
+
|
|
147
|
+
#endif // defined(__cplusplus)
|
|
148
|
+
|
|
149
|
+
// ----------------------------------------------------------------------------
|
|
150
|
+
|
|
151
|
+
#endif // MICRO_OS_PLUS_ARCHITECTURE_RISCV_ARCH_INSTRUCTIONS_H_
|
|
152
|
+
|
|
153
|
+
// ----------------------------------------------------------------------------
|
|
@@ -0,0 +1,81 @@
|
|
|
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_PLATFORM_FUNCTIONS_INLINES_H_
|
|
14
|
+
#define MICRO_OS_PLUS_ARCHITECTURE_RISCV_PLATFORM_FUNCTIONS_INLINES_H_
|
|
15
|
+
|
|
16
|
+
// ----------------------------------------------------------------------------
|
|
17
|
+
|
|
18
|
+
#include <stdint.h>
|
|
19
|
+
|
|
20
|
+
// ----------------------------------------------------------------------------
|
|
21
|
+
|
|
22
|
+
/*
|
|
23
|
+
* Board support functions.
|
|
24
|
+
*
|
|
25
|
+
* Inline functions are first defined in C (prefixed with `riscv_board_`),
|
|
26
|
+
* then, for convenience, are redefined in C++ in the `riscv::board::`
|
|
27
|
+
* namespace.
|
|
28
|
+
*
|
|
29
|
+
* Regular functions are first defined in C++ then aliased to C.
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
// ----------------------------------------------------------------------------
|
|
33
|
+
#if defined(__cplusplus)
|
|
34
|
+
extern "C"
|
|
35
|
+
{
|
|
36
|
+
#endif // defined(__cplusplus)
|
|
37
|
+
|
|
38
|
+
static inline __attribute__ ((always_inline)) uint32_t
|
|
39
|
+
riscv_board_get_rtc_frequency_hz (void)
|
|
40
|
+
{
|
|
41
|
+
return RISCV_PLATFORM_RTC_FREQUENCY_HZ;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
#if defined(__cplusplus)
|
|
45
|
+
}
|
|
46
|
+
#endif // defined(__cplusplus)
|
|
47
|
+
|
|
48
|
+
// ----------------------------------------------------------------------------
|
|
49
|
+
|
|
50
|
+
#if defined(__cplusplus)
|
|
51
|
+
|
|
52
|
+
// ----------------------------------------------------------------------------
|
|
53
|
+
|
|
54
|
+
namespace riscv
|
|
55
|
+
{
|
|
56
|
+
namespace board
|
|
57
|
+
{
|
|
58
|
+
// ------------------------------------------------------------------------
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* Get the board RTC frequency.
|
|
62
|
+
*/
|
|
63
|
+
inline __attribute__ ((always_inline)) uint32_t
|
|
64
|
+
rtc_frequency_hz (void)
|
|
65
|
+
{
|
|
66
|
+
return riscv_board_get_rtc_frequency_hz ();
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// ------------------------------------------------------------------------
|
|
70
|
+
} // namespace board
|
|
71
|
+
} // namespace riscv
|
|
72
|
+
|
|
73
|
+
// ----------------------------------------------------------------------------
|
|
74
|
+
|
|
75
|
+
#endif // defined(__cplusplus)
|
|
76
|
+
|
|
77
|
+
// ----------------------------------------------------------------------------
|
|
78
|
+
|
|
79
|
+
#endif // MICRO_OS_PLUS_ARCHITECTURE_RISCV_PLATFORM_FUNCTIONS_INLINES_H_
|
|
80
|
+
|
|
81
|
+
// ----------------------------------------------------------------------------
|
|
@@ -0,0 +1,75 @@
|
|
|
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_PLATFORM_FUNCTIONS_H_
|
|
14
|
+
#define MICRO_OS_PLUS_ARCHITECTURE_RISCV_PLATFORM_FUNCTIONS_H_
|
|
15
|
+
|
|
16
|
+
// ----------------------------------------------------------------------------
|
|
17
|
+
|
|
18
|
+
#include <stdint.h>
|
|
19
|
+
|
|
20
|
+
// ----------------------------------------------------------------------------
|
|
21
|
+
|
|
22
|
+
// RISC-V core support functions.
|
|
23
|
+
|
|
24
|
+
#if defined(__cplusplus)
|
|
25
|
+
extern "C"
|
|
26
|
+
{
|
|
27
|
+
#endif // defined(__cplusplus)
|
|
28
|
+
|
|
29
|
+
// --------------------------------------------------------------------------
|
|
30
|
+
|
|
31
|
+
// The declarations are part of the common design, but each board
|
|
32
|
+
// must implement them in the <xxx/platform-functions.h> file.
|
|
33
|
+
|
|
34
|
+
// Redundant, see the inline definitions.
|
|
35
|
+
|
|
36
|
+
// static uint32_t
|
|
37
|
+
// riscv_board_get_rtc_frequency_hz (void);
|
|
38
|
+
|
|
39
|
+
// --------------------------------------------------------------------------
|
|
40
|
+
|
|
41
|
+
#if defined(__cplusplus)
|
|
42
|
+
}
|
|
43
|
+
#endif // defined(__cplusplus)
|
|
44
|
+
|
|
45
|
+
// ============================================================================
|
|
46
|
+
|
|
47
|
+
#if defined(__cplusplus)
|
|
48
|
+
|
|
49
|
+
// ----------------------------------------------------------------------------
|
|
50
|
+
|
|
51
|
+
namespace riscv
|
|
52
|
+
{
|
|
53
|
+
namespace board
|
|
54
|
+
{
|
|
55
|
+
// The declarations are part of the common design, but each board
|
|
56
|
+
// must implement them in the <xxx/platform-functions.h> file.
|
|
57
|
+
|
|
58
|
+
// Redundant, see the inline definitions.
|
|
59
|
+
|
|
60
|
+
// uint32_t
|
|
61
|
+
// rtc_frequency_hz (void);
|
|
62
|
+
|
|
63
|
+
// ------------------------------------------------------------------------
|
|
64
|
+
} // namespace board
|
|
65
|
+
} // namespace riscv
|
|
66
|
+
|
|
67
|
+
// ----------------------------------------------------------------------------
|
|
68
|
+
|
|
69
|
+
#endif // defined(__cplusplus)
|
|
70
|
+
|
|
71
|
+
// ----------------------------------------------------------------------------
|
|
72
|
+
|
|
73
|
+
#endif // MICRO_OS_PLUS_ARCHITECTURE_RISCV_PLATFORM_FUNCTIONS_H_
|
|
74
|
+
|
|
75
|
+
// ----------------------------------------------------------------------------
|