Mercurial > hg > Members > menikon > CbC_xv6
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 |
rev | line source |
---|---|
312 | 1 #include "param.h" |
2 #include "proc.h" | |
168 | 3 #interface "ErrorGear.h" |
4 | |
5 // ---- | |
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 | 8 // } KernelError; |
9 // ---- | |
10 | |
11 ErrorGear* createKernelError(struct Context* cbc_context) { | |
12 struct ErrorGear* error_gear = new ErrorGear(); | |
13 struct KernelError* kernel_error = new KernelError(); | |
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 | 17 error_gear->error = C_errorKernelError; |
18 error_gear->panic = C_panicKernelError; | |
19 return error_gear; | |
20 } | |
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 | 29 } |
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 | 32 extern struct cpu* cpu; |
313 | 33 extern struct { struct spinlock lock; int locking; } cons; |
34 extern int panicked; | |
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 | 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 | 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 | 45 } |
46 | |
310
ba8687746ff6
impl kernel_error codes
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
168
diff
changeset
|
47 |