Skip to content

Commit e03c8e0

Browse files
committed
Debug box: Do not reboot by default
The `debug_halt_error` handler should not implicitly infer a reboot of the system. The debug box handler can reboot, if it thinks it's necessary. The newly introduced vIRQ_SystemReset API can be used for this purpose. By default, the debug handler will trigger a call to `uvisor_error`, a user-level API to trigger a halt. The halt will have the newly introduced reason `DEBUG_BOX_HALT`.
1 parent 06fb938 commit e03c8e0

File tree

2 files changed

+9
-14
lines changed

2 files changed

+9
-14
lines changed

api/inc/halt_exports.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
typedef enum {
3131
USER_NOT_ALLOWED = 1,
32+
DEBUG_BOX_HALT,
3233
} THaltUserError;
3334

3435
typedef enum {

core/debug/src/debug.c

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -156,20 +156,15 @@ void debug_fault(THaltError reason, uint32_t lr, uint32_t sp)
156156
DEBUG_PRINT_END();
157157
}
158158

159-
static void __debug_reboot(void)
159+
static void debug_die(void)
160160
{
161-
UVISOR_SVC(UVISOR_SVC_ID_DEBUG_REBOOT, "");
161+
UVISOR_SVC(UVISOR_SVC_ID_HALT_USER_ERR, "", DEBUG_BOX_HALT);
162162
}
163163

164-
/* This function must be called as an SVCall handler.
165-
* All debug handlers that are required to reboot upon exit should use the
166-
* __debug_reboot function as return value, which triggers the SVCall. This note
167-
* applies to uVisor internally, as the actual debug box does not need to care
168-
* about this. */
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. */
169166
void debug_reboot(void)
170167
{
171-
/* FIXME: The halt will be replaced with a proper return code. An ACL will
172-
* be created to allow single boxes to reset the device. */
173168
if (!g_debug_box.initialized || g_active_box != g_debug_box.box_id) {
174169
HALT_ERROR(NOT_ALLOWED, "This function can only be called from the context of an initialized debug box.\n\r");
175170
}
@@ -180,8 +175,7 @@ void debug_reboot(void)
180175
}
181176

182177
/* FIXME: Currently it is not possible to return to a regular execution flow
183-
* after the execution of the debug box handler. It is possible to
184-
* reboot, though. */
178+
* after the execution of the debug box handler. */
185179
static void debug_deprivilege_and_return(void * debug_handler, void * return_handler,
186180
uint32_t a0, uint32_t a1, uint32_t a2, uint32_t a3)
187181
{
@@ -230,7 +224,7 @@ void debug_halt_error(THaltError reason)
230224
/* If the debug box does not exist (or it has not been initialized yet), or
231225
* the debug box was already called once, just loop forever. */
232226
if (!g_debug_box.initialized || debugged_once_before) {
233-
while(1);
227+
while (1);
234228
} else {
235229
/* Remember that debug_deprivilege_and_return() has been called once.
236230
* We'll reboot after the debug handler is run, so this will go back to
@@ -239,8 +233,8 @@ void debug_halt_error(THaltError reason)
239233

240234
/* The following arguments are passed to the destination function:
241235
* 1. reason
242-
* Upon return from the debug handler, the system will reboot. */
243-
debug_deprivilege_and_return(g_debug_box.driver->halt_error, __debug_reboot, reason, 0, 0, 0);
236+
* Upon return from the debug handler, we will die. */
237+
debug_deprivilege_and_return(g_debug_box.driver->halt_error, debug_die, reason, 0, 0, 0);
244238
}
245239
}
246240

0 commit comments

Comments
 (0)