#include "param.h" #include "proc.h" #interface "ErrorGear.h" // ---- // typedef struct KernelError impl ErrorGear { // __code infinity_loop(Type* error_gear,__code next(...)); // } KernelError; // ---- ErrorGear* createKernelError(struct Context* cbc_context) { struct ErrorGear* error_gear = new ErrorGear(); struct KernelError* kernel_error = new KernelError(); error_gear->error_gear = (union Data*)kernel_error; kernel_error->error_gear = NULL; kernel_error->infinity_loop = C_infinity_loopKernelError; error_gear->error = C_errorKernelError; error_gear->panic = C_panicKernelError; return error_gear; } __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(struct KernelError* error_gear, char* msg) { extern struct cpu* cpu; 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); }