annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
168
04a5e0aa7f01 add kernel_error.cbc
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 #include "../context.h"
04a5e0aa7f01 add kernel_error.cbc
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 #interface "ErrorGear.h"
04a5e0aa7f01 add kernel_error.cbc
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3
04a5e0aa7f01 add kernel_error.cbc
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 // ----
04a5e0aa7f01 add kernel_error.cbc
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5 // typedef struct KernelError <Type, Isa> impl ErrorGear {
310
ba8687746ff6 impl kernel_error codes
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 168
diff changeset
6 // __code infinity_loop(Type* error_gear,__code next(...));
168
04a5e0aa7f01 add kernel_error.cbc
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7 // } KernelError;
04a5e0aa7f01 add kernel_error.cbc
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 // ----
04a5e0aa7f01 add kernel_error.cbc
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9
04a5e0aa7f01 add kernel_error.cbc
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 ErrorGear* createKernelError(struct Context* cbc_context) {
04a5e0aa7f01 add kernel_error.cbc
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 struct ErrorGear* error_gear = new ErrorGear();
04a5e0aa7f01 add kernel_error.cbc
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 struct KernelError* kernel_error = new KernelError();
04a5e0aa7f01 add kernel_error.cbc
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 error_gear->error_gear = (union Data*)kernel_error;
310
ba8687746ff6 impl kernel_error codes
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 168
diff changeset
14 kernel_error->error_gear = NULL;
ba8687746ff6 impl kernel_error codes
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 168
diff changeset
15 kernel_error->infinity_loop = C_infinity_loopKernelError;
168
04a5e0aa7f01 add kernel_error.cbc
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 error_gear->error = C_errorKernelError;
04a5e0aa7f01 add kernel_error.cbc
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 error_gear->panic = C_panicKernelError;
310
ba8687746ff6 impl kernel_error codes
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 168
diff changeset
18 error_gear->next = C_nextKernelError;
168
04a5e0aa7f01 add kernel_error.cbc
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 return error_gear;
04a5e0aa7f01 add kernel_error.cbc
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
20 }
04a5e0aa7f01 add kernel_error.cbc
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
21
310
ba8687746ff6 impl kernel_error codes
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 168
diff changeset
22 __code infinity_loopKernelError(struct KernelError* error_gear,__code next(...)) {
ba8687746ff6 impl kernel_error codes
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 168
diff changeset
23 goto next(...);
ba8687746ff6 impl kernel_error codes
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 168
diff changeset
24 }
ba8687746ff6 impl kernel_error codes
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 168
diff changeset
25
ba8687746ff6 impl kernel_error codes
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 168
diff changeset
26 __code errorKernelError(struct KernelError* error_gear, int err_code, __code next(...)) {
ba8687746ff6 impl kernel_error codes
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 168
diff changeset
27
ba8687746ff6 impl kernel_error codes
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 168
diff changeset
28 goto next(...);
168
04a5e0aa7f01 add kernel_error.cbc
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
29 }
04a5e0aa7f01 add kernel_error.cbc
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
30
310
ba8687746ff6 impl kernel_error codes
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 168
diff changeset
31 __code panicKernelError(struct KernelError* error_gear, char* msg) {
ba8687746ff6 impl kernel_error codes
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 168
diff changeset
32 cli();
ba8687746ff6 impl kernel_error codes
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 168
diff changeset
33 cons.locking = 0;
168
04a5e0aa7f01 add kernel_error.cbc
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
34
310
ba8687746ff6 impl kernel_error codes
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 168
diff changeset
35 cprintf("cpu%d: panic: ", cpu->id);
ba8687746ff6 impl kernel_error codes
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 168
diff changeset
36
ba8687746ff6 impl kernel_error codes
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 168
diff changeset
37 show_callstk(s);
ba8687746ff6 impl kernel_error codes
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 168
diff changeset
38 panicked = 1; // freeze other CPU
ba8687746ff6 impl kernel_error codes
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 168
diff changeset
39
ba8687746ff6 impl kernel_error codes
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 168
diff changeset
40 goto infinity_loopKernelError(error_gear, error_gear->inifinity_loop);
168
04a5e0aa7f01 add kernel_error.cbc
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
41 }
04a5e0aa7f01 add kernel_error.cbc
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
42
310
ba8687746ff6 impl kernel_error codes
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 168
diff changeset
43