Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- org 7c00h
- use16
- cli
- lgdt[gdt]
- mov eax,cr4
- or al,1
- mov cr4,eax
- mov eax,cr0
- or al,1
- mov cr0,eax
- jmp gdt_code-gdt_table:pmode
- vm86:
- mov ax,0e41h
- mov bx,7
- int 10h
- ;which interrupt trigger to end the virtual 8086 mode?
- jmp $
- use32
- pmode:
- mov ax,gdt_data-gdt_table
- mov gs,ax
- mov fs,ax
- mov ds,ax
- mov es,ax
- mov ss,ax
- mov esp,9fffch
- mov ax,18h
- ltr ax
- mov al,11h
- out 20h,al
- mov al,20h
- out 21h,al
- mov al,4
- out 21h,al
- mov al,1
- out 21h,al
- mov al,255-1 shl 6
- out 21h,al
- mov edi,idt_table
- mov edx,8e00h
- mov eax,(gdt_code-gdt_table) shl 16
- mov ecx,20h
- interrupts1:
- mov [edi],eax
- mov [edi+4],edx
- add edi,8
- loop interrupts1
- mov edx,8f00h
- mov eax,(gdt_code-gdt_table) shl 16
- add ecx,8
- interrupts2:
- mov [edi],eax
- mov [edi+4],edx
- add edi,8
- loop interrupts2
- mov edx,8f00h
- mov eax,(gdt_code-gdt_table) shl 16
- mov ecx,256-8-32
- interrupts3:
- mov [edi],eax
- mov [edi+4],edx
- add edi,8
- loop interrupts3
- mov word[idt_table+20h*8+6*8],second_sector
- mov word[idt_table+49*8],function_floppy
- lidt[idt]
- sti
- push 0
- push 0
- push 0
- push 0
- push 0
- push 0fffeh
- push 23000h
- push 0
- push vm86
- iretd
- int 49
- jmp $
- function_floppy:
- mov dx,3f2h
- mov al,1ch
- out dx,al
- mov al,6
- out 0ah,al
- mov al,0ffh
- out 0ch,al
- mov al,0
- out 4,al
- mov ax,second_sector
- out 81h,al
- mov al,ah
- out 4,al
- mov al,0ffh
- out 5,al
- mov al,1
- out 5,al
- mov al,2
- out 0ah,al
- call readmsr
- mov dx,3f5h
- mov al,66h
- out dx,al
- mov al,0
- out dx,al
- mov al,0
- out dx,al
- mov al,0
- out dx,al
- mov al,2
- out dx,al
- mov al,2
- out dx,al
- mov al,18
- out dx,al
- mov al,27
- out dx,al
- mov al,0ffh
- out dx,al
- iret
- readmsr:
- mov dx,3f4h
- in al,dx
- and al,0c0h
- cmp al,80h
- jne readmsr
- ret
- gdt:
- dw gdt_end-gdt_table-1
- dd gdt_table
- gdt_table:
- dq 0
- gdt_code:
- dw 0ffffh
- dw 0
- db 0
- db 9ah
- db 0cfh
- db 0
- gdt_data:
- dw 0ffffh
- dw 0
- db 0
- db 92h
- db 0cfh
- db 0
- gdt_tss:
- dw 0ffffh
- dw 0
- db 0
- db 89h
- db 8fh
- db 0
- gdt_end:
- idt:
- dw idt_end-256*8-1
- dd idt_table
- idt_table=256*4
- idt_end:
- times 510-($-$$) db 0
- dw 0aa55h
- second_sector:
- mov byte[0b8000h],43h
- mov byte[0b8000h+1],0ch
- mov byte[0b8000h+2],69h
- mov byte[0b8000h+3],0ch
- mov byte[0b8000h+4],61h
- mov byte[0b8000h+5],0ch
- mov byte[0b8000h+6],6fh
- mov byte[0b8000h+7],0ch
- mov byte[0b8000h+8],21h
- mov byte[0b8000h+9],0ch
- mov byte[0b8000h+10],20h
- mov byte[0b8000h+11],0ch
- mov byte[0b8000h+12],3ah
- mov byte[0b8000h+13],0ch
- mov byte[0b8000h+14],29h
- mov byte[0b8000h+15],0ch
- jmp $
- times 512-($-second_sector) db 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement