]> pd.if.org Git - zos/blob - cpu.s
add a readme with a public domain note
[zos] / cpu.s
1 global readtsc:function
2 global readmsr:function
3 global writemsr:function
4 global enable_syscall:function
5 global disable_syscall:function
6 global setdr0:function
7 global setdr1:function
8 global setdr2:function
9 global setdr3:function
10 global nextrip:function
11
12 setdr0:
13         mov rax, dr0
14         mov dr0, rdi
15         ret
16
17 setdr1:
18         mov rax, dr1
19         mov dr1, rdi
20         ret
21 setdr2:
22         mov rax, dr2
23         mov dr2, rdi
24         ret
25 setdr3:
26         mov rax, dr3
27         mov dr3, rdi
28         ret
29
30 nextrip:
31         pop rax
32         push rax
33         ret
34         
35 readtsc:
36         rdtsc
37         shl rdx, 32
38         or rax, rdx
39         ret
40
41 writemsr:
42         ; rdi is msr, rsi is value to write
43         mov ecx, edi
44         ; edx is high order bits, eax is low order bits to write
45         mov eax, esi
46         shr rsi, 32
47         mov edx, esi
48         wrmsr
49         ret
50
51 readmsr:
52         mov ecx, edi
53         rdmsr
54         shl rdx, 32
55         or rax, rdx
56
57 %define EFER 0xc0000080
58 enable_syscall:
59         mov ecx, EFER
60         rdmsr
61         or eax, 0x1
62         wrmsr
63         ret
64
65 disable_syscall:
66         mov ecx, EFER
67         rdmsr
68         and eax, DWORD ~0x1
69         wrmsr
70         ret