GDT Entries:
Code: Select all
code64_descriptor GDT_STR 0ffffh,0,0,9ah,0afh,0 ;
data64_descriptor GDT_STR 0ffffh,0,0,92h,0afh,0 ;
Code: Select all
lidt_PM_start dw lidt_size
lidt_PM_ptr dq 0
linterruptsall db 4096 dup (0)
lidt_size=$-(linterruptsall)
Code: Select all
xor edx,edx
mov edx,CODE64
shl edx,4
add edx,f0lm ; the handler
mov eax,edx
mov di,linterruptsall
add di,0xf0*16
mov word [di],ax ; lower
add di,2
mov word [di],pm_sel_rcode64; sel
add di,2
mov byte [di],0
add di,1
mov byte [di],08Eh;
add di,1
mov eax,edx
shr eax,16
mov word [di],ax ; upper
add di,2
mov dword [di],0;
; Set idt ptr
xor eax,eax
mov ax,DATA16
shl eax,4
add ax,linterruptsall
mov dword [lidt_PM_ptr],eax
mov dword [lidt_PM_ptr + 4],0
ret
Code: Select all
f0lm:
iretq
Code: Select all
xor rbx,rbx
mov bx,DATA16
shl rbx,4
add rbx,lidt_PM_start
lidt tbyte [rbx]
mov ax,pm_sel_rdata64
mov ss,ax
mov es,ax
mov ds,ax
mov fs,ax
mov gs,ax
xor rsp,rsp
mov sp,RUNDATA64 ; segment for the stack
shl rsp,4
add rsp,256
sti
int 0xf0; boom in VMWare, but not in bochs.
Thanks