Skip to content

Commit eb3ba7e

Browse files
committed
Halt on panic or assert rather than loop
1 parent dc34018 commit eb3ba7e

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/system.c

+9-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
#include "monitor.h"
33
#include "isr.h"
44

5+
static void halt(void)
6+
{
7+
asm volatile("hlt");
8+
}
9+
510
void memcpy(void *dest, const void *src, uint32_t length)
611
{
712
const byte_t *srcPtr = (const byte_t *)src;
@@ -49,7 +54,8 @@ void panic(char *msg, char *file, uint32_t line)
4954
monitor_put(':');
5055
monitor_writei(line, 'd');
5156
monitor_writeline(")");
52-
for (;;);
57+
58+
halt();
5359
}
5460

5561
void panic_assert(char *msg, char *file, uint32_t line)
@@ -66,5 +72,6 @@ void panic_assert(char *msg, char *file, uint32_t line)
6672
monitor_put(':');
6773
monitor_writei(line, 'd');
6874
monitor_writeline(")");
69-
for (;;);
75+
76+
halt();
7077
}

0 commit comments

Comments
 (0)