Code: Select all
align 16
tss:
dd 0
dq 9fc00h ; rsp 0 = rsp
dq 0 ; rsp 1
dq 0 ; rsp 2
dq 0
dq 0 ; ist 1
dq 0 ; ist 2
dq 0 ; ist 3
dq 0 ; ist 4
dq 0 ; ist 5
dq 0 ; ist 6
dq 0 ; ist 7
dq 0
dw 0
dw $-tss ; i/o map offset
tsse equ $-tss-1
gdtr: ; ## type offs size DPL attr
dq 0 ;
dw 0ffffh,0,09b00h,0afh ; 08 code 00000000-0009FC00 0 R
dw 0ffffh,0,09300h,0afh ; 10 data 00000000-FFFFFFFF 0 RW
dw 0ffffh,0,0fa00h,0afh ; 18 code 00000000-FFFFFFFF 3 R
dw 0ffffh,0,0f200h,0afh ; 20 data 00000000-FFFFFFFF 3 RW
DEFINE_TSS tss,tsse-1 ; 28 TSS 00000000-FFFFFFFF 0 R
use64
align 16
longmode:
mov ax,10h
mov ds,ax
mov es,ax
mov fs,ax
mov gs,ax
mov ss,ax
mov rsp,9fc00h
; enable SYSCALL/SYSRET
mov ecx,0c0000081h ; MSR_STAR
xor eax,eax
mov edx,(8+16)*65536 or 18h ; (syscode+16)*65536 or appcode
wrmsr
mov ecx,0c0000082h ; MSR_LSTAR
mov eax,sys ; RIP
xor edx,edx
wrmsr
mov ecx,0c0000084h ; MSR_FMASK
mov eax,202h ; RFLAGS
xor edx,edx
wrmsr
; enable NMI and int's
in al,70h
and al,7fh
out 70h,al
sti
; goto to ring3
mov ax,28h ; tss
ltr ax
mov rcx,idle
sysretq
align 16
idle:
mov rsi,100*1024*1024
mov ax,[rsi] ;!! TRIPLE FAULT HERE !!
jmp $
; IDT table
exc_table:
dd exc00 or 80000h, 8e00h
dd exc01 or 80000h, 8e00h
dd exc02 or 80000h, 8e00h
; ....
dd exc31 or 80000h, 8e00h
exc00:
jmp $
Code: Select all
00015424046i[CPU0 ] CPU is in long mode (active)
00015424046i[CPU0 ] CS.d_b = 16 bit
00015424046i[CPU0 ] SS.d_b = 16 bit
00015424046i[CPU0 ] EFER = 0x00000501
00015424046i[CPU0 ] | RAX=0000000000000028 RBX=0000000000201027
00015424046i[CPU0 ] | RCX=0000000000001310 RDX=0000000000000000
00015424046i[CPU0 ] | RSP=000000000009fc00 RBP=0000000000000005
00015424046i[CPU0 ] | RSI=0000000006400000 RDI=0000000000001000
00015424046i[CPU0 ] | R8=0000000000000000 R9=0000000000000000
00015424046i[CPU0 ] | R10=0000000000000000 R11=0000000000000000
00015424046i[CPU0 ] | R12=0000000000000000 R13=0000000000000000
00015424046i[CPU0 ] | R14=0000000000000000 R15=0000000000000000
00015424046i[CPU0 ] | IOPL=0 id vip vif ac vm RF nt of df if tf sf zf af pf cf
00015424046i[CPU0 ] | SEG selector base limit G D
00015424046i[CPU0 ] | SEG sltr(index|ti|rpl) base limit G D
00015424046i[CPU0 ] | CS:002b( 0005| 0| 3) 00000000 ffffffff 1 0
00015424046i[CPU0 ] | DS:0010( 0002| 0| 0) 00000000 ffffffff 1 0
00015424046i[CPU0 ] | SS:0023( 0004| 0| 3) 00000000 ffffffff 1 0
00015424046i[CPU0 ] | ES:0010( 0002| 0| 0) 00000000 ffffffff 1 0
00015424046i[CPU0 ] | FS:0010( 0002| 0| 0) 00000000 ffffffff 1 0
00015424046i[CPU0 ] | GS:0010( 0002| 0| 0) 00000000 ffffffff 1 0
00015424046i[CPU0 ] | MSR_FS_BASE:0000000000000000
00015424046i[CPU0 ] | MSR_GS_BASE:0000000000000000
00015424046i[CPU0 ] | RIP=0000000000001317 (0000000000001317)
00015424046i[CPU0 ] | CR0=0x80000011 CR2=0x00000000009b1204
00015424046i[CPU0 ] | CR3=0x00100000 CR4=0x00000020
00015424046i[CPU0 ] 0x0000000000001317>> mov ax, word ptr ds:[rsi] : 668B06
00015424046e[CPU0 ] exception(): 3rd (14) exception with no resolution, shutdown status is 00h, resetting
00015424046i[SYS ] bx_pc_system_c::Reset(HARDWARE) called
00015424046i[CPU0 ] cpu hardware reset
Sorry for my English.