The Pedigree Project 0.1
IrqTime.inc
1; Latency accounting may run only with IRQs masked and kernel GS active.
2%ifdef PEDIGREE_LATENCY_ACCOUNTING
3extern pedigree_irq_time_state
4%endif
5
6; Preserve the surrounding assembly ABI when no public register frame exists.
7; "rflags" reads the target flags at the original RSP plus the optional offset.
8%macro IRQ_TIME_STATE 1-2 0
9%ifdef PEDIGREE_LATENCY_ACCOUNTING
10 pushfq
11 push rax
12 push rcx
13 push rdx
14 push rsi
15 push rdi
16 push r8
17 push r9
18 push r10
19 push r11
20 mov r11, rsp
21 and rsp, -16
22 sub rsp, 16
23 mov [rsp], r11
24%ifidni %1, rflags
25 mov rdi, [r11+80+%2]
26 shr edi, 9
27 and edi, 1
28%else
29 mov edi, %1
30%endif
31 call pedigree_irq_time_state wrt ..plt
32 mov rsp, [rsp]
33 pop r11
34 pop r10
35 pop r9
36 pop r8
37 pop rdi
38 pop rsi
39 pop rdx
40 pop rcx
41 pop rax
42 popfq
43%endif
44%endmacro