X-Git-Url: https://pd.if.org/git/?p=zos;a=blobdiff_plain;f=cpu.s;fp=cpu.s;h=30ca25e010420fc6ee6ee3ff8863f7cbc49846bd;hp=0000000000000000000000000000000000000000;hb=5a6d8336c11140500330da69cd74490a07876fe1;hpb=5c0e560e481e2e97b793f7574e849a5882781df9 diff --git a/cpu.s b/cpu.s new file mode 100644 index 0000000..30ca25e --- /dev/null +++ b/cpu.s @@ -0,0 +1,70 @@ +global readtsc:function +global readmsr:function +global writemsr:function +global enable_syscall:function +global disable_syscall:function +global setdr0:function +global setdr1:function +global setdr2:function +global setdr3:function +global nextrip:function + +setdr0: + mov rax, dr0 + mov dr0, rdi + ret + +setdr1: + mov rax, dr1 + mov dr1, rdi + ret +setdr2: + mov rax, dr2 + mov dr2, rdi + ret +setdr3: + mov rax, dr3 + mov dr3, rdi + ret + +nextrip: + pop rax + push rax + ret + +readtsc: + rdtsc + shl rdx, 32 + or rax, rdx + ret + +writemsr: + ; rdi is msr, rsi is value to write + mov ecx, edi + ; edx is high order bits, eax is low order bits to write + mov eax, esi + shr rsi, 32 + mov edx, esi + wrmsr + ret + +readmsr: + mov ecx, edi + rdmsr + shl rdx, 32 + or rax, rdx + +%define EFER 0xc0000080 +enable_syscall: + mov ecx, EFER + rdmsr + or eax, 0x1 + wrmsr + ret + +disable_syscall: + mov ecx, EFER + rdmsr + and eax, DWORD ~0x1 + wrmsr + ret