changeset 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 14845ce8254b
children 356e7f4c70a2
files src/impl/kernel_error.cbc src/impl/kernel_error.h src/interface/ErrorGear.h
diffstat 3 files changed, 25 insertions(+), 10 deletions(-) [+]
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);
 }
 
+
--- a/src/impl/kernel_error.h	Wed Feb 05 16:50:00 2020 +0900
+++ b/src/impl/kernel_error.h	Thu Feb 06 12:25:34 2020 +0900
@@ -1,2 +1,3 @@
 typedef struct KernelError <Type, Isa> impl ErrorGear {
+  __code infinity_loop(Type* error_gear,__code next(...));
 } KernelError;
--- a/src/interface/ErrorGear.h	Wed Feb 05 16:50:00 2020 +0900
+++ b/src/interface/ErrorGear.h	Thu Feb 06 12:25:34 2020 +0900
@@ -1,8 +1,5 @@
 typedef struct ErrorGear <Type, Impl> {
-  union Data* error_gear;
-  int err_code;
-  char* msg;
-
-  __code error(int err_code,...);
-  __code panic(char* msg);
+  __code error(Impl* error_gear, int err_code, __code next(...));
+  __code panic(Impl* error_gear, char* msg);
+  __code next(...);
 } ErrorGear;