File tree Expand file tree Collapse file tree 6 files changed +21
-8
lines changed Expand file tree Collapse file tree 6 files changed +21
-8
lines changed Original file line number Diff line number Diff line change 18
18
#define __UVISOR_API_NVIC_VIRTUAL_H__
19
19
20
20
#include "api/inc/interrupts.h"
21
+ #include "api/inc/unvic_exports.h"
21
22
22
23
#define NVIC_SetPriorityGrouping __NVIC_SetPriorityGrouping
23
24
#define NVIC_GetPriorityGrouping __NVIC_GetPriorityGrouping
29
30
#define NVIC_GetActive __NVIC_GetActive
30
31
#define NVIC_SetPriority vIRQ_SetPriority
31
32
#define NVIC_GetPriority vIRQ_GetPriority
32
- #define NVIC_SystemReset vIRQ_SystemReset
33
+ #define NVIC_SystemReset () vIRQ_SystemReset(RESET_REASON_NO_REASON)
33
34
34
35
#endif /* __UVISOR_API_NVIC_VIRTUAL_H__ */
Original file line number Diff line number Diff line change 17
17
#ifndef __UVISOR_API_INTERRUPTS_H__
18
18
#define __UVISOR_API_INTERRUPTS_H__
19
19
20
+ #include "api/inc/unvic_exports.h"
20
21
#include "api/inc/uvisor_exports.h"
21
22
#include <stdint.h>
22
23
@@ -62,7 +63,8 @@ UVISOR_EXTERN void vIRQ_EnableAll(void);
62
63
63
64
/** Reset the device.
64
65
* @warning Currently only the debug box can reset the device.
66
+ * @param reason[in] Reason for rebooting. Currently not used.
65
67
*/
66
- UVISOR_EXTERN void vIRQ_SystemReset (void );
68
+ UVISOR_EXTERN void vIRQ_SystemReset (TResetReason reason );
67
69
68
70
#endif /* __UVISOR_API_INTERRUPTS_H__ */
Original file line number Diff line number Diff line change 28
28
* priorities available to them */
29
29
#define UVISOR_VIRQ_MAX_PRIORITY ((uint32_t) (1 << __NVIC_PRIO_BITS) - 1 - __UVISOR_NVIC_MIN_PRIORITY)
30
30
31
+ /* Reasons for rebooting */
32
+ typedef enum {
33
+ RESET_REASON_NO_REASON = 0 ,
34
+ RESET_REASON_HALT ,
35
+ __TRESETREASON_MAX /* Always keep the last element of the enum. */
36
+ } TResetReason ;
37
+
31
38
/* Offset of NVIC interrupts with respect to handler 0 */
32
39
#define NVIC_OFFSET 16
33
40
Original file line number Diff line number Diff line change @@ -166,12 +166,12 @@ int vIRQ_GetLevel(void)
166
166
}
167
167
}
168
168
169
- void vIRQ_SystemReset (void )
169
+ void vIRQ_SystemReset (TResetReason reason )
170
170
{
171
171
if (__uvisor_mode == 0 ) {
172
172
NVIC_SystemReset ();
173
173
}
174
174
else {
175
- UVISOR_SVC (UVISOR_SVC_ID_DEBUG_REBOOT , "" );
175
+ UVISOR_SVC (UVISOR_SVC_ID_DEBUG_REBOOT , "" , reason );
176
176
}
177
177
}
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ void debug_map_addr_to_periph(uint32_t address);
47
47
void debug_register_driver (const TUvisorDebugDriver * const driver );
48
48
uint32_t debug_get_version (void );
49
49
void debug_halt_error (THaltError reason );
50
- void debug_reboot (void );
50
+ void debug_reboot (TResetReason reason );
51
51
52
52
#define DEBUG_PRINT_HEAD (x ) {\
53
53
DPRINTF("\n***********************************************************\n");\
Original file line number Diff line number Diff line change @@ -161,14 +161,17 @@ static void debug_die(void)
161
161
UVISOR_SVC (UVISOR_SVC_ID_HALT_USER_ERR , "" , DEBUG_BOX_HALT );
162
162
}
163
163
164
- /* FIXME: The halt will be replaced with a proper return code. An ACL will be
165
- * created to allow single boxes to reset the device. */
166
- void debug_reboot (void )
164
+ void debug_reboot (TResetReason reason )
167
165
{
168
166
if (!g_debug_box .initialized || g_active_box != g_debug_box .box_id ) {
169
167
HALT_ERROR (NOT_ALLOWED , "This function can only be called from the context of an initialized debug box.\n\r" );
170
168
}
171
169
170
+ /* Note: Currently we do not act differently based on the reset reason. */
171
+ if (reason >= __TRESETREASON_MAX ) {
172
+ HALT_ERROR (NOT_ALLOWED , "Invalid reset reason: %d.\r\n" , reason );
173
+ }
174
+
172
175
/* Reboot.
173
176
* If called from unprivileged code, NVIC_SystemReset causes a fault. */
174
177
NVIC_SystemReset ();
You can’t perform that action at this time.
0 commit comments