annotate src/impl/kernel_error.cbc @ 313:561eedeb9a99

ommit static variable at console
author anatofuz
date Thu, 06 Feb 2020 16:56:50 +0900
parents cd9092628a63
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
312
cd9092628a63 mv kernel_error KernelError.h
anatofuz
parents: 310
diff changeset
1 #include "param.h"
cd9092628a63 mv kernel_error KernelError.h
anatofuz
parents: 310
diff changeset
2 #include "proc.h"
168
04a5e0aa7f01 add kernel_error.cbc
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 #interface "ErrorGear.h"
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 // ----
04a5e0aa7f01 add kernel_error.cbc
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 // 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
7 // __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
8 // } KernelError;
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
04a5e0aa7f01 add kernel_error.cbc
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 ErrorGear* createKernelError(struct Context* cbc_context) {
04a5e0aa7f01 add kernel_error.cbc
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 struct ErrorGear* error_gear = new ErrorGear();
04a5e0aa7f01 add kernel_error.cbc
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
13 struct KernelError* kernel_error = new KernelError();
04a5e0aa7f01 add kernel_error.cbc
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
14 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
15 kernel_error->error_gear = NULL;
ba8687746ff6 impl kernel_error codes
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 168
diff changeset
16 kernel_error->infinity_loop = C_infinity_loopKernelError;
168
04a5e0aa7f01 add kernel_error.cbc
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
17 error_gear->error = C_errorKernelError;
04a5e0aa7f01 add kernel_error.cbc
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 error_gear->panic = C_panicKernelError;
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) {
312
cd9092628a63 mv kernel_error KernelError.h
anatofuz
parents: 310
diff changeset
32 extern struct cpu* cpu;
313
561eedeb9a99 ommit static variable at console
anatofuz
parents: 312
diff changeset
33 extern struct { struct spinlock lock; int locking; } cons;
561eedeb9a99 ommit static variable at console
anatofuz
parents: 312
diff changeset
34 extern int panicked;
561eedeb9a99 ommit static variable at console
anatofuz
parents: 312
diff changeset
35
310
ba8687746ff6 impl kernel_error codes
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 168
diff changeset
36 cli();
ba8687746ff6 impl kernel_error codes
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 168
diff changeset
37 cons.locking = 0;
168
04a5e0aa7f01 add kernel_error.cbc
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
38
310
ba8687746ff6 impl kernel_error codes
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 168
diff changeset
39 cprintf("cpu%d: panic: ", cpu->id);
ba8687746ff6 impl kernel_error codes
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 168
diff changeset
40
313
561eedeb9a99 ommit static variable at console
anatofuz
parents: 312
diff changeset
41 show_callstk(msg);
310
ba8687746ff6 impl kernel_error codes
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 168
diff changeset
42 panicked = 1; // freeze other CPU
ba8687746ff6 impl kernel_error codes
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 168
diff changeset
43
ba8687746ff6 impl kernel_error codes
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 168
diff changeset
44 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
45 }
04a5e0aa7f01 add kernel_error.cbc
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
46
310
ba8687746ff6 impl kernel_error codes
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 168
diff changeset
47