📄 bootcode.inc
字号:
pop es
; GRAPHICS ACCELERATION
movzx eax,byte [es:preboot_mtrr-0x10000]
cmp eax,0
jne pre_mtrr
mov si,gr_acc-0x10000
call printplain
mov ebx,0x0201
call getkey
pre_mtrr:
push word 0x0000
pop es
mov [es:0x901C],al
push word 0x1000
pop es
mov si,linef-0x10000
call printplain
; GET MOUSE PORT
movzx eax,byte [es:preboot_mouse-0x10000]
cmp eax,0
jne pre_mouse
;mov si,linef-0x10000
;call print
mov si,askmouse-0x10000
call print
mov ebx,0x0301
call getkey
pre_mouse:
push word 0x0000
pop es
mov [es:0x9010],al
push word 0x1000
pop es
mov si,linef-0x10000
call printplain
; MEMORY MODEL
movzx eax,byte [es:preboot_memory-0x10000]
cmp eax,0
jne pre_mem
mov si,mem_model-0x10000
call printplain
mov ebx,0x0501
call getkey
pre_mem:
push word 0x0000
pop es
mov [es:0x9030],al
push word 0x1000
pop es
mov si,linef-0x10000
call printplain
; DIRECT WRITE TO LFB, PAGING DISABLED
movzx eax,byte [es:preboot_lfb-0x10000]
mov eax,1 ; paging disabled
cmp eax,0
jne pre_lfb
mov si,gr_direct-0x10000
call printplain
mov ebx,0x0201
call getkey
pre_lfb:
push word 0x0000
pop es
mov [es:0x901E],al
mov ax,0x1000
mov es,ax
mov si,linef-0x10000
; call printplain
; DISPLAY BOOTLOG
movzx eax,byte [es:preboot_bootlog-0x10000]
mov eax,2 ; pause
cmp eax,0
jne pre_bootlog
mov si,bootlog-0x10000
call printplain
mov ebx,0x0201
call getkey
pre_bootlog:
push word 0x0000
pop es
mov [es:0x901D],al
push word 0x1000
pop es
mov si,linef-0x10000
call printplain
; BOOT DEVICE
movzx eax,byte [es:preboot_device-0x10000]
cmp eax,0
jne pre_device
mov si,bdev-0x10000
call printplain
mov ebx,0x0301
call getkey
pre_device:
dec al
mov [es:boot_dev-0x10000],al
mov si,linef-0x10000
call printplain
; READ DISKETTE TO MEMORY
cmp [boot_dev-0x10000],0
jne no_sys_on_floppy
mov si,diskload-0x10000
call print
mov ax,0x0000 ; reset drive
mov dx,0x0000
int 0x13
mov cx,0x0001 ; startcyl,startsector
mov dx,0x0000 ; starthead,drive
push word 80*2 ; read no of sect
reads:
pusha
xor si,si
newread:
push word 0x0
pop es
mov bx,0xa000 ; es:bx -> data area
mov ax,0x0200+18 ; read, no of sectors to read
int 0x13
cmp ah,0
jz goodread
add si,1
cmp si,10
jnz newread
mov si,badsect-0x10000
call printplain
jmp $
goodread:
; move -> 1mb
mov si,movedesc-0x10000
push word 0x1000
pop es
mov cx,256*18
mov ah,0x87
int 0x15
mov eax,[es:movedesc-0x10000+0x18+2]
add eax,512*18
mov [es:movedesc-0x10000+0x18+2],eax
popa
inc dh
cmp dh,2
jnz bb2
mov dh,0
inc ch
pusha ; print prosentage
push word 0x1000
pop es
xor eax,eax ; 5
mov al,ch
shr eax,2
and eax,1
mov ebx,5
mul bx
add al,48
mov [es:pros+1-0x10000],al
xor eax,eax ; 10
mov al,ch
shr eax,3
add al,48
mov [es:pros-0x10000],al
mov si,pros-0x10000
call printplain
popa
bb2:
pop ax
dec ax
push ax
cmp ax,0
jnz rs
jmp readdone
rs:
jmp reads
movedesc:
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0xff,0xff,0x0,0xa0,0x00,0x93,0x0,0x0
db 0xff,0xff,0x0,0x00,0x10,0x93,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
db 0x00,0x00,0x0,0x00,0x00,0x00,0x0,0x0
readdone:
pop ax
mov dx,0x3f2 ; floppy motor off
mov al,0
out dx,al
mov si,backspace-0x10000
call printplain
call printplain
mov si,okt-0x10000
call printplain
no_sys_on_floppy:
; PAGE TABLE
map_mem equ 63 ; amount of memory to map
mov bx,0x6000
mov es,bx ; [es:di] = 6000:0
xor edi,edi
mov ecx,256*map_mem ; Map (mapmem) M
mov eax,7
cld
pt2:
cmp ecx,256*(map_mem-8) ; 8 M map to LFB
jnz pt3
pop eax
add eax,7
pt3:
cmp ecx,256*(map_mem-12) ; 12 M back to linear = physical
jnz pt4
mov eax,12*0x100000 + 7
pt4:
stosd
add eax,4096
loop pt2
; 4 M PAGE DIRECTORY (comment page table)
;mov edi, 0x68000
;mov eax, 0x00000000 +110000111b ; 0 M - global page
;stosd
;mov eax, 0x00400000 + 10000111b ; 4 M
;stosd
;mov eax, 0x00800000 + 10000111b ; 8 M
;stosd
;mov eax, 0x00C00000 + 10000111b ; 12 M
;stosd
;mov eax, 0x01000000 + 10000111b ; 16 M
;stosd
;mov eax, 0x01400000 + 10000111b ; 20 M
;stosd
;mov eax, 0x01800000 + 10000111b ; 24 M
;stosd
;pop eax
;add eax, 110000111b ; 28 M - global page
;stosd
;mov eax, 0x68000 + 10000111b ; Self pointer
;stosd
;mov eax,CR4
;and eax,0xffffffff-32 ; set PAE to 0 \
;or eax,00010000b ; set PSE to 1 / -> 4 M pages
;or eax,10000000b ; PGE -> global paging allowed
;mov cr4,eax
; 4 KB PAGE DIRECTORY
mov bx , 0x7000
mov es , bx ; [es:di] = 7000:0
xor edi, edi
mov ecx, 64 / 4
mov eax, 0x60007 ; for 0 M
cld
pd4k:
stosd
add eax, 0x01000
loop pd4k
mov eax, 0x70000 +8+16 ; Page directory and enable caches
mov cr3, eax
; SET GRAPHICS
mov dx,0x0000
mov es,dx
mov bx,[es:0x9008]
mov ax,bx ; vga & 320x200
cmp ax,0x13
je setgr
cmp ax,0x12
je setgr
mov ax,0x4f02 ; Vesa
setgr:
int 0x10
cmp ah,0
jz gmok
mov si,fatalsel-0x10000
call print
jmp $
gmok:
mov dx,0x1000
mov es,dx
; set mode 0x12 graphics registers:
cmp bx,0x12
jne gmok2
mov al,0x05
mov dx,0x03ce
out dx,al ; select GDC mode register
mov al,0x02
mov dx,0x03cf
out dx,al ; set write mode 2
mov al,0x02
mov dx,0x03c4
out dx,al ; select VGA sequencer map mask register
mov al,0x0f
mov dx,0x03c5
out dx,al ; set mask for all planes 0-3
mov al,0x08
mov dx,0x03ce
out dx,al ; select GDC bit mask register
; for writes to 0x03cf
gmok2:
mov dx,0x1000
mov es,dx
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -