Allow x and y resolution to be saved
This commit is contained in:
parent
03db207100
commit
64cfe68046
|
@ -22,7 +22,7 @@ pub mod sdt;
|
||||||
pub mod xsdt;
|
pub mod xsdt;
|
||||||
|
|
||||||
const TRAMPOLINE: usize = 0x7E00;
|
const TRAMPOLINE: usize = 0x7E00;
|
||||||
const AP_STARTUP: usize = 0x8000;
|
const AP_STARTUP: usize = TRAMPOLINE + 512;
|
||||||
|
|
||||||
pub fn init_sdt(sdt: &'static Sdt, active_table: &mut ActivePageTable) {
|
pub fn init_sdt(sdt: &'static Sdt, active_table: &mut ActivePageTable) {
|
||||||
print!(" ");
|
print!(" ");
|
||||||
|
|
|
@ -96,6 +96,69 @@ load:
|
||||||
jc error
|
jc error
|
||||||
ret
|
ret
|
||||||
|
|
||||||
|
; store some sectors to disk from a buffer in memory
|
||||||
|
; buffer has to be below 1MiB
|
||||||
|
; IN
|
||||||
|
; ax: start sector
|
||||||
|
; bx: offset of buffer
|
||||||
|
; cx: number of sectors (512 Bytes each)
|
||||||
|
; dx: segment of buffer
|
||||||
|
; CLOBBER
|
||||||
|
; ax, bx, cx, dx, si
|
||||||
|
; TODO rewrite to (eventually) move larger parts at once
|
||||||
|
; if that is done increase buffer_size_sectors in startup-common to that (max 0x80000 - startup_end)
|
||||||
|
store:
|
||||||
|
cmp cx, 128
|
||||||
|
jbe .good_size
|
||||||
|
|
||||||
|
pusha
|
||||||
|
mov cx, 128
|
||||||
|
call store
|
||||||
|
popa
|
||||||
|
add ax, 128
|
||||||
|
add dx, 128 * 512 / 16
|
||||||
|
sub cx, 128
|
||||||
|
|
||||||
|
jmp store
|
||||||
|
.good_size:
|
||||||
|
mov [DAPACK.addr], eax
|
||||||
|
mov [DAPACK.buf], bx
|
||||||
|
mov [DAPACK.count], cx
|
||||||
|
mov [DAPACK.seg], dx
|
||||||
|
|
||||||
|
mov bx, [DAPACK.addr + 2]
|
||||||
|
call print_num
|
||||||
|
|
||||||
|
mov bx, [DAPACK.addr]
|
||||||
|
call print_num
|
||||||
|
|
||||||
|
mov al, '#'
|
||||||
|
call print_char
|
||||||
|
|
||||||
|
mov bx, [DAPACK.count]
|
||||||
|
call print_num
|
||||||
|
|
||||||
|
mov al, ' '
|
||||||
|
call print_char
|
||||||
|
|
||||||
|
mov bx, [DAPACK.seg]
|
||||||
|
call print_num
|
||||||
|
|
||||||
|
mov al, ':'
|
||||||
|
call print_char
|
||||||
|
|
||||||
|
mov bx, [DAPACK.buf]
|
||||||
|
call print_num
|
||||||
|
|
||||||
|
call print_line
|
||||||
|
|
||||||
|
mov dl, [disk]
|
||||||
|
mov si, DAPACK
|
||||||
|
mov ah, 0x43
|
||||||
|
int 0x13
|
||||||
|
jc error
|
||||||
|
ret
|
||||||
|
|
||||||
error:
|
error:
|
||||||
mov si, errored
|
mov si, errored
|
||||||
call print
|
call print
|
||||||
|
|
18
bootloader/x86_64/config.asm
Normal file
18
bootloader/x86_64/config.asm
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
SECTION .text
|
||||||
|
USE16
|
||||||
|
|
||||||
|
align 512, db 0
|
||||||
|
|
||||||
|
config:
|
||||||
|
.xres: dw 0
|
||||||
|
.yres: dw 0
|
||||||
|
|
||||||
|
times 512 - ($ - config) db 0
|
||||||
|
|
||||||
|
save_config:
|
||||||
|
mov eax, (config - boot) / 512
|
||||||
|
mov bx, config
|
||||||
|
mov cx, 1
|
||||||
|
xor dx, dx
|
||||||
|
call store
|
||||||
|
ret
|
|
@ -83,6 +83,7 @@ finished_loading:
|
||||||
|
|
||||||
jmp startup_arch
|
jmp startup_arch
|
||||||
|
|
||||||
|
%include "config.asm"
|
||||||
%include "descriptor_flags.inc"
|
%include "descriptor_flags.inc"
|
||||||
%include "gdt_entry.inc"
|
%include "gdt_entry.inc"
|
||||||
%include "unreal.asm"
|
%include "unreal.asm"
|
||||||
|
|
|
@ -15,17 +15,13 @@ vesa:
|
||||||
xor cx, cx
|
xor cx, cx
|
||||||
mov [.minx], cx
|
mov [.minx], cx
|
||||||
mov [.miny], cx
|
mov [.miny], cx
|
||||||
mov [.requiredx], cx
|
mov [config.xres], cx
|
||||||
mov [.requiredy], cx
|
mov [config.yres], cx
|
||||||
mov [.requiredmode], cx
|
|
||||||
.findmode:
|
.findmode:
|
||||||
mov si, [VBECardInfo.videomodeptr]
|
mov si, [VBECardInfo.videomodeptr]
|
||||||
mov ax, [VBECardInfo.videomodeptr+2]
|
mov ax, [VBECardInfo.videomodeptr+2]
|
||||||
mov fs, ax
|
mov fs, ax
|
||||||
sub si, 2
|
sub si, 2
|
||||||
mov cx, [.requiredmode]
|
|
||||||
test cx, cx
|
|
||||||
jnz .getmodeinfo
|
|
||||||
.searchmodes:
|
.searchmodes:
|
||||||
add si, 2
|
add si, 2
|
||||||
mov cx, [fs:si]
|
mov cx, [fs:si]
|
||||||
|
@ -51,9 +47,9 @@ vesa:
|
||||||
jb .searchmodes
|
jb .searchmodes
|
||||||
.testx:
|
.testx:
|
||||||
mov cx, [VBEModeInfo.xresolution]
|
mov cx, [VBEModeInfo.xresolution]
|
||||||
cmp word [.requiredx], 0
|
cmp word [config.xres], 0
|
||||||
je .notrequiredx
|
je .notrequiredx
|
||||||
cmp cx, [.requiredx]
|
cmp cx, [config.xres]
|
||||||
je .testy
|
je .testy
|
||||||
jmp .searchmodes
|
jmp .searchmodes
|
||||||
.notrequiredx:
|
.notrequiredx:
|
||||||
|
@ -61,11 +57,11 @@ vesa:
|
||||||
jb .searchmodes
|
jb .searchmodes
|
||||||
.testy:
|
.testy:
|
||||||
mov cx, [VBEModeInfo.yresolution]
|
mov cx, [VBEModeInfo.yresolution]
|
||||||
cmp word [.requiredy], 0
|
cmp word [config.yres], 0
|
||||||
je .notrequiredy
|
je .notrequiredy
|
||||||
cmp cx, [.requiredy]
|
cmp cx, [config.yres]
|
||||||
jne .searchmodes ;as if there weren't enough warnings, USE WITH CAUTION
|
jne .searchmodes ;as if there weren't enough warnings, USE WITH CAUTION
|
||||||
cmp word [.requiredx], 0
|
cmp word [config.xres], 0
|
||||||
jnz .setmode
|
jnz .setmode
|
||||||
jmp .testgood
|
jmp .testgood
|
||||||
.notrequiredy:
|
.notrequiredy:
|
||||||
|
@ -95,7 +91,16 @@ vesa:
|
||||||
int 0x16
|
int 0x16
|
||||||
pop esi
|
pop esi
|
||||||
cmp al, 'y'
|
cmp al, 'y'
|
||||||
jne .searchmodes
|
je .setmode
|
||||||
|
cmp al, 's'
|
||||||
|
je .savemode
|
||||||
|
jmp .searchmodes
|
||||||
|
.savemode:
|
||||||
|
mov cx, [VBEModeInfo.xresolution]
|
||||||
|
mov [config.xres], cx
|
||||||
|
mov cx, [VBEModeInfo.yresolution]
|
||||||
|
mov [config.yres], cx
|
||||||
|
call save_config
|
||||||
.setmode:
|
.setmode:
|
||||||
mov bx, [.currentmode]
|
mov bx, [.currentmode]
|
||||||
cmp bx, 0
|
cmp bx, 0
|
||||||
|
@ -114,12 +119,8 @@ vesa:
|
||||||
|
|
||||||
.minx dw 640
|
.minx dw 640
|
||||||
.miny dw 480
|
.miny dw 480
|
||||||
.required:
|
|
||||||
.requiredx dw 1024 ;USE THESE WITH CAUTION
|
|
||||||
.requiredy dw 768
|
|
||||||
.requiredmode dw 0
|
|
||||||
|
|
||||||
.modeok db ": Is this OK?(y/n)",10,13,0
|
.modeok db ": Is this OK? (s)ave/(y)es/(n)o",10,13,0
|
||||||
|
|
||||||
.goodmode dw 0
|
.goodmode dw 0
|
||||||
.currentmode dw 0
|
.currentmode dw 0
|
||||||
|
|
Loading…
Reference in a new issue