aboutsummaryrefslogtreecommitdiff
path: root/mirai/crimson/context/debug.zig
blob: 13b4fc0c197afd2c0153e4ff8748e40502164422 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
//! Capture Debug Registers

const asm_debug = @import("../../asm/debug/debug.zig");
const types = @import("../types/types.zig");
const DebugState = types.DebugState;

pub fn capture(state: *DebugState) void {
    state.dr0 = asm_debug.read_dr0();
    state.dr1 = asm_debug.read_dr1();
    state.dr2 = asm_debug.read_dr2();
    state.dr3 = asm_debug.read_dr3();
    state.dr6 = asm_debug.read_dr6();
    state.dr7 = asm_debug.read_dr7();
    state.dr4 = 0;
    state.dr5 = 0;
}

pub fn restore(state: *const DebugState) void {
    asm_debug.write_dr0(state.dr0);
    asm_debug.write_dr1(state.dr1);
    asm_debug.write_dr2(state.dr2);
    asm_debug.write_dr3(state.dr3);
    asm_debug.write_dr6(state.dr6);
    asm_debug.write_dr7(state.dr7);
}