Mercurial > hg > Members > menikon > CbC_xv6
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 |
rev | line source |
---|---|
168 | 1 #include "../context.h" |
2 #interface "ErrorGear.h" | |
3 | |
4 // ---- | |
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 | 7 // } KernelError; |
8 // ---- | |
9 | |
10 ErrorGear* createKernelError(struct Context* cbc_context) { | |
11 struct ErrorGear* error_gear = new ErrorGear(); | |
12 struct KernelError* kernel_error = new KernelError(); | |
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 | 16 error_gear->error = C_errorKernelError; |
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 | 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) { |
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 | 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 | 41 } |
42 | |
310
ba8687746ff6
impl kernel_error codes
anatofuz <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
168
diff
changeset
|
43 |