Multiuser, Capabilities and Access Controls (#54)
[lunaix-os.git] / lunaix-os / arch / x86 / trace.c
1 #include <lunaix/trace.h>
2
3 void
4 trace_print_transistion_short(struct hart_state* hstate)
5 {
6     trace_log("  trigger: iv=%d, ecause=%p, frame=%p",
7                 hart_vector_stamp(hstate),
8                 hart_ecause(hstate),
9                 hart_stack_frame(hstate));
10 }
11
12 #ifdef CONFIG_ARCH_X86_64
13
14 void
15 trace_print_transition_full(struct hart_state* hstate)
16 {
17     trace_log("hart state transition");
18     trace_log("  vector=%d, ecause=0x%x", 
19                 hart_vector_stamp(hstate),
20                 hart_ecause(hstate));
21
22     trace_log("  rflags=0x%016lx", hstate->execp->rflags);
23     trace_log("  sp=0x%016lx, seg_sel=0x%04x", 
24                 hstate->execp->rsp, 
25                 hstate->execp->ss);
26     trace_log("  ip=0x%016lx, seg_sel=0x%04x",
27                 hstate->execp->rip,
28                 hstate->execp->cs);
29 }
30
31 void
32 trace_dump_state(struct hart_state* hstate)
33 {
34     struct regcontext* rh = &hstate->registers;
35     struct exec_param* ep = hstate->execp;
36     trace_log("hart state dump (depth=%d)", hstate->depth);
37     trace_log("  rax=0x%016lx, rbx=0x%016lx",
38                 rh->rax, rh->rbx);
39     trace_log("  rcx=0x%016lx, rdx=0x%016lx",
40                 rh->rcx, rh->rdx);
41     trace_log("  rdi=0x%016lx, rsi=0x%016lx",
42                 rh->rdi, rh->rsi);
43
44     trace_log("  r08=0x%016lx, r09=0x%016lx",
45                 rh->r8, rh->r9);
46     trace_log("  r10=0x%016lx, r11=0x%016lx",
47                 rh->r10, rh->r11);
48     trace_log("  r12=0x%016lx, r13=0x%016lx",
49                 rh->r12, rh->r13);
50     trace_log("  r14=0x%016lx, r15=0x%016lx",
51                 rh->r14, rh->r15);
52
53     trace_log("   cs=0x%04x, rip=0x%016lx",
54                 ep->cs, ep->rip);
55     trace_log("   ss=0x%04x, rsp=0x%016lx",
56                 ep->ss, ep->rsp);
57     trace_log("  rflags=0x%016lx",
58                 ep->rflags);
59 }
60
61 #else
62
63 void
64 trace_print_transition_full(struct hart_state* hstate)
65 {
66     trace_log("hart state transition");
67     trace_log("  vector=%d, ecause=0x%x", 
68                 hart_vector_stamp(hstate),
69                 hart_ecause(hstate));
70     trace_log("  eflags=0x%x", hstate->execp->eflags);
71     trace_log("  sp=%p, [seg_sel=0x%04x]", 
72                 hstate->execp->esp, 
73                 hstate->execp->ss);
74     trace_log("  ip=%p, seg_sel=0x%04x",
75                 hstate->execp->eip,
76                 hstate->execp->cs);
77 }
78
79 void
80 trace_dump_state(struct hart_state* hstate)
81 {
82     struct regcontext* rh = &hstate->registers;
83     struct exec_param* ep = hstate->execp;
84     trace_log("hart state dump (depth=%d)", hstate->depth);
85     trace_log("  eax=0x%08x, ebx=0x%08x, ecx=0x%08x",
86                 rh->eax, rh->ebx, rh->ecx);
87     trace_log("  edx=0x%08x, ebp=0x%08x",
88                 rh->edx, rh->ebp);
89     trace_log("   ds=0x%04x, edi=0x%08x",
90                 rh->ds, rh->edi);
91     trace_log("   es=0x%04x, esi=0x%08x",
92                 rh->es, rh->esi);
93     trace_log("   fs=0x%04x, gs=0x%x",
94                 rh->fs, rh->gs);
95     trace_log("   cs=0x%04x, ip=0x%08x",
96                 ep->cs, ep->eip);
97     trace_log("  [ss=0x%04x],sp=0x%08x",
98                 ep->ss, ep->esp);
99     trace_log("  eflags=0x%08x",
100                 ep->eflags);
101 }
102
103 #endif