Handle panic through kvprintf instead
This commit is contained in:
parent
e30cc4c3d0
commit
5596841482
3 changed files with 13 additions and 6 deletions
|
@ -7,12 +7,11 @@
|
|||
|
||||
volatile int panicked = false;
|
||||
|
||||
__attribute__((visibility("hidden")))
|
||||
void __panic(const char *restrict fmt, ...) {
|
||||
__attribute__((visibility("hidden"))) void __panic(const char *restrict fmt, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
(void)mini_vpprintf(stdout_puts, NULL, fmt, ap);
|
||||
kvprintf(fmt, ap);
|
||||
va_end(ap);
|
||||
panicked = true;
|
||||
while (true) asm volatile("wfi");
|
||||
for (;;) asm volatile("wfi");
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <mini-printf.h>
|
||||
#include <stddef.h>
|
||||
#include <stdio.h>
|
||||
#include <uart.h>
|
||||
|
||||
/** Helper routine to put characters into our uart device */
|
||||
|
@ -21,7 +22,12 @@ static int stdout_puts(char *s, int len, void *unused) {
|
|||
int kprintf(const char *restrict fmt, ...) {
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
int ret = mini_vpprintf(stdout_puts, NULL, fmt, ap);
|
||||
int ret = kvprintf(fmt, &ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int kvprintf(const char *fmt, va_list ap) {
|
||||
int ret = mini_vpprintf(stdout_puts, NULL, fmt, ap);
|
||||
return ret;
|
||||
}
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
#ifndef STDIO_H
|
||||
#define STDIO_H
|
||||
|
||||
int stdout_puts(char *s, int len, void *unused);
|
||||
#include <stdarg.h>
|
||||
|
||||
int kprintf(const char *restrict format, ...);
|
||||
int kvprintf(const char *fmt, va_list ap);
|
||||
|
||||
// int fprintf(FILE *restrict stream, const char *restrict format, ...);
|
||||
// int dprintf(int fd, const char *restrict format, ...);
|
||||
|
|
Loading…
Add table
Reference in a new issue