Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2787 | decky | 1 | /** @addtogroup ia32 |
2 | * @{ |
||
3 | */ |
||
4 | /** @file |
||
5 | */ |
||
6 | |||
7 | #include <proc/thread.h> |
||
8 | #include <console/klog.h> |
||
9 | #include <arch/tdebug.h> |
||
10 | |||
11 | /* trap flag */ |
||
12 | #define EFLAGS_TF 0x100 |
||
13 | |||
14 | /** |
||
15 | * Called when the IAFTER event setting is (potentially) changed. |
||
16 | * |
||
17 | * On this arch the TRAP flag in userspace state is set |
||
18 | * according to the setting of TDEBUG_EVMASK_IAFTER |
||
19 | * in order to stop after the execution of each instruction. |
||
20 | * |
||
21 | * The calling thread must have already locked t. |
||
22 | * |
||
23 | * Returns 0 on success, non-zero on failure. (Mainly if IAFTER is set, but |
||
24 | * architecture does not support it.) |
||
25 | */ |
||
26 | int tdebug_iafter_update(thread_t *t) |
||
27 | { |
||
28 | uint32_t eflags; |
||
29 | |||
30 | if (t->tdebug.uspace_state == NULL) { |
||
31 | /* userspace state is not available */ |
||
32 | /* FIXME: this should not happen when properly imlemented */ |
||
33 | klog_printf("fail: uspace_state not available\n"); |
||
34 | return -1; |
||
35 | } |
||
36 | |||
37 | eflags = t->tdebug.uspace_state->eflags; |
||
38 | |||
39 | if ((t->tdebug.event_mask & TDEBUG_EVMASK_IAFTER) != 0) { |
||
40 | eflags = eflags | EFLAGS_TF; |
||
41 | } else { |
||
42 | eflags = eflags & ~EFLAGS_TF; |
||
43 | } |
||
44 | |||
45 | t->tdebug.uspace_state->eflags = eflags; |
||
46 | return 0; |
||
47 | } |
||
48 | |||
49 | |||
50 | /** @} |
||
51 | */ |