#include <stdbool.h>
#include <stdint.h>
#include <sys/kconfig.h>
#include <sys/kassert.h>
#include <sys/kdebug.h>
#include <sys/kmem.h>
#include <sys/ktime.h>
#include <sys/spinlock.h>
#include <sys/irq.h>
#include <sys/syscall.h>
#include <sys/mp.h>
#include <machine/amd64.h>
#include <machine/lapic.h>
#include <machine/trap.h>
#include <machine/mp.h>
#include <sys/thread.h>
Go to the source code of this file.
◆ copy_unsafe()
int copy_unsafe |
( |
void * |
to, |
|
|
void * |
from, |
|
|
uintptr_t |
len |
|
) |
| |
◆ copy_unsafe_done()
void copy_unsafe_done |
( |
void |
| ) |
|
◆ copy_unsafe_fault()
void copy_unsafe_fault |
( |
void |
| ) |
|
◆ copystr_unsafe()
int copystr_unsafe |
( |
void * |
to, |
|
|
void * |
from, |
|
|
uintptr_t |
len |
|
) |
| |
◆ copystr_unsafe_done()
void copystr_unsafe_done |
( |
void |
| ) |
|
◆ copystr_unsafe_fault()
void copystr_unsafe_fault |
( |
void |
| ) |
|
◆ Debug_Breakpoint()
Definition at line 67 of file debug.c.
68{
70
71
73
74 }
75
76
78
79
81
82
85}
TrapFrame * frames[MAX_CPUS]
static volatile uint64_t debugLock
static INLINE uint64_t atomic_swap_uint64(volatile uint64_t *dst, uint64_t newval)
static void atomic_set_uint64(volatile uint64_t *dst, uint64_t newval)
◆ Debug_HaltIPI()
Definition at line 51 of file debug.c.
52{
55
57
60 }
61
64}
static volatile uint64_t debugCmd
static volatile uint64_t debugHalted
void MP_SetState(int state)
static INLINE void pause()
◆ Debug_Traps()
static void Debug_Traps |
( |
int |
argc, |
|
|
const char * |
argv[] |
|
) |
| |
|
static |
Definition at line 278 of file trap.c.
279{
280 int i;
281
282 kprintf(
"Trap Interrupts Trap Interrupts\n");
283 for (i = 0; i <
T_MAX / 2; i++)
284 {
285 kprintf(
"%-4d %-12d %-4d %-12d\n",
288 }
289}
int kprintf(const char *fmt,...)
static uint64_t intStats[256]
◆ KTimer_Process()
Definition at line 88 of file ktimer.c.
89{
91
93 return;
94 }
95
97
99
102
103
109 }
110 }
111
112
115 }
116
118}
UnixEpoch KTime_GetEpoch()
void KTimer_Release(KTimerEvent *evt)
#define TIMER_WHEEL_LENGTH
#define LIST_FOREACH_SAFE(var, head, field, tvar)
#define LIST_REMOVE(elm, field)
void Spinlock_Unlock(Spinlock *lock) __UNLOCK_EX(*lock)
void Spinlock_Lock(Spinlock *lock) __LOCK_EX(*lock)
◆ REGISTER_DBGCMD()
REGISTER_DBGCMD |
( |
traps |
, |
|
|
"Print trap statistics" |
, |
|
|
Debug_Traps |
|
|
) |
| |
◆ Trap_Dump()
Definition at line 95 of file trap.c.
96{
98 kprintf(
"Interrupt %d Error Code: %016llx\n",
100 kprintf(
"cr0: %016llx cr2: %016llx\n",
102 kprintf(
"cr3: %016llx cr4: %016llx\n",
104 kprintf(
"dr0: %016llx dr1: %016llx dr2: %016llx\n",
106 kprintf(
"dr3: %016llx dr6: %016llx dr7: %016llx\n",
108 kprintf(
"rip: %04x:%016llx rsp: %04x:%016llx\n",
110 kprintf(
"rflags: %016llx ds: %04x es: %04x fs: %04x gs: %04x\n",
112 kprintf(
"rax: %016llx rbx: %016llx rcx: %016llx\n",
114 kprintf(
"rdx: %016llx rsi: %016llx rdi: %016llx\n",
116 kprintf(
"rbp: %016llx r8: %016llx r9: %016llx\n",
118 kprintf(
"r10: %016llx r11: %016llx r12: %016llx\n",
120 kprintf(
"r13: %016llx r14: %016llx r15: %016llx\n",
122}
static INLINE uint64_t read_dr1()
static INLINE uint16_t read_es()
static INLINE uint16_t read_ds()
static INLINE uint64_t read_cr2()
static INLINE uint16_t read_fs()
static INLINE uint64_t read_cr3()
static INLINE uint64_t read_dr3()
static INLINE uint64_t read_dr7()
static INLINE uint64_t read_dr6()
static INLINE uint16_t read_gs()
static INLINE uint64_t read_cr4()
static INLINE uint64_t read_cr0()
static INLINE uint64_t read_dr0()
static INLINE uint64_t read_dr2()
◆ trap_entry()
Definition at line 146 of file trap.c.
147{
148
150
151
157 return;
158 }
159
160
162 {
163
166 return;
167 }
168
169
173 kprintf(
"Faulted in copy_unsafe\n");
175 return;
176 }
177
178
182 kprintf(
"Faulted in copystr_unsafe\n");
184 return;
185 }
186
187
189 {
194 while (1)
196 }
197 }
198
199
201 {
204 return;
208 kprintf(
"Userlevel breakpoint\n");
210 return;
211 }
216 }
221 return;
222 }
223 }
224
225
227 {
233 }
234
235 return;
236 }
237
238
242 }
243
244
246 {
249 return;
250 }
251
252
254 {
255 kprintf(
"Spurious Interrupt!\n");
256 return;
257 }
259 {
261 while (1)
263 }
265 {
267 while (1)
269 }
270
273 while (1)
275}
void IRQ_Handler(int irq)
#define VLOG(_module, _format,...)
uint64_t Syscall_Entry(uint64_t syscall, uint64_t a1, uint64_t a2, uint64_t a3, uint64_t a4, uint64_t a5)
void copy_unsafe_done(void)
int copystr_unsafe(void *to, void *from, uintptr_t len)
void copy_unsafe_fault(void)
void Debug_HaltIPI(TrapFrame *tf)
int copy_unsafe(void *to, void *from, uintptr_t len)
void Trap_StackDump(TrapFrame *tf)
void Debug_Breakpoint(TrapFrame *tf)
void copystr_unsafe_done(void)
void Trap_Dump(TrapFrame *tf)
void copystr_unsafe_fault(void)
int syscall(int number,...)
◆ Trap_Init()
Definition at line 33 of file trap.c.
34{
35 int i;
36
37 kprintf(
"Initializing IDT... ");
38
39 for (i = 0; i <
T_MAX; i++) {
43
46
49 }
50
51 for (; i < 256; i++) {
55
58
61 }
62
63
69
70
74
77
79
80
81 for (i = 0; i < 256; i++) {
83 }
84
86}
static INLINE void lidt(PseudoDescriptor *idt)
static InteruptGate64 idt[256]
static PseudoDescriptor idtdesc
uint64_t trap_table[T_MAX]
◆ Trap_InitAP()
◆ trap_pop()
◆ Trap_StackDump()
Definition at line 125 of file trap.c.
126{
129
130
131 for (rsp = tf->
rsp; (rsp & 0xFFF) != 0; rsp += 8) {
133 kprintf(
"%016llx: %016llx\n", rsp, *data);
134 }
135}
◆ idt
◆ idtdesc
◆ intStats
◆ trap_table