diff src/impl/kernel_error.cbc @ 310:ba8687746ff6

impl kernel_error codes
author anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Thu, 06 Feb 2020 12:25:34 +0900
parents 04a5e0aa7f01
children cd9092628a63
line wrap: on
line diff
--- a/src/impl/kernel_error.cbc	Wed Feb 05 16:50:00 2020 +0900
+++ b/src/impl/kernel_error.cbc	Thu Feb 06 12:25:34 2020 +0900
@@ -3,6 +3,7 @@
 
 // ----
 // typedef struct KernelError <Type, Isa> impl ErrorGear {
+//   __code infinity_loop(Type* error_gear,__code next(...));
 // } KernelError;
 // ----
 
@@ -10,17 +11,33 @@
     struct ErrorGear* error_gear  = new ErrorGear();
     struct KernelError* kernel_error = new KernelError();
     error_gear->error_gear = (union Data*)kernel_error;
-    error_gear->err_code  = 0;
-    error_gear->msg = NULL;
+    kernel_error->error_gear = NULL;
+    kernel_error->infinity_loop = C_infinity_loopKernelError;
     error_gear->error = C_errorKernelError;
     error_gear->panic = C_panicKernelError;
+    error_gear->next = C_nextKernelError;
     return error_gear;
 }
-__code errorKernelError(int err_code,...) {
 
+__code infinity_loopKernelError(struct KernelError* error_gear,__code next(...)) {
+    goto next(...);
+}
+
+__code errorKernelError(struct KernelError* error_gear, int err_code, __code next(...)) {
+
+    goto next(...);
 }
 
-__code panicKernelError(char* msg) {
+__code panicKernelError(struct KernelError* error_gear, char* msg) {
+    cli();
+    cons.locking = 0;
 
+    cprintf("cpu%d: panic: ", cpu->id);
+
+    show_callstk(s);
+    panicked = 1; // freeze other CPU
+
+    goto infinity_loopKernelError(error_gear, error_gear->inifinity_loop);
 }
 
+