diff --git a/arch/x86_64/src/acpi/mod.rs b/arch/x86_64/src/acpi/mod.rs index 245450d..8162723 100644 --- a/arch/x86_64/src/acpi/mod.rs +++ b/arch/x86_64/src/acpi/mod.rs @@ -22,7 +22,7 @@ pub mod sdt; pub mod xsdt; 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) { print!(" "); diff --git a/bootloader/x86_64/bootsector.asm b/bootloader/x86_64/bootsector.asm index 86032ab..1273e86 100644 --- a/bootloader/x86_64/bootsector.asm +++ b/bootloader/x86_64/bootsector.asm @@ -96,6 +96,69 @@ load: jc error 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: mov si, errored call print diff --git a/bootloader/x86_64/config.asm b/bootloader/x86_64/config.asm new file mode 100644 index 0000000..8e3b220 --- /dev/null +++ b/bootloader/x86_64/config.asm @@ -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 diff --git a/bootloader/x86_64/startup-common.asm b/bootloader/x86_64/startup-common.asm index 518410d..70b9f96 100644 --- a/bootloader/x86_64/startup-common.asm +++ b/bootloader/x86_64/startup-common.asm @@ -83,6 +83,7 @@ finished_loading: jmp startup_arch +%include "config.asm" %include "descriptor_flags.inc" %include "gdt_entry.inc" %include "unreal.asm" diff --git a/bootloader/x86_64/vesa.asm b/bootloader/x86_64/vesa.asm index 943e4eb..b649e4b 100644 --- a/bootloader/x86_64/vesa.asm +++ b/bootloader/x86_64/vesa.asm @@ -15,17 +15,13 @@ vesa: xor cx, cx mov [.minx], cx mov [.miny], cx - mov [.requiredx], cx - mov [.requiredy], cx - mov [.requiredmode], cx + mov [config.xres], cx + mov [config.yres], cx .findmode: mov si, [VBECardInfo.videomodeptr] mov ax, [VBECardInfo.videomodeptr+2] mov fs, ax sub si, 2 - mov cx, [.requiredmode] - test cx, cx - jnz .getmodeinfo .searchmodes: add si, 2 mov cx, [fs:si] @@ -51,9 +47,9 @@ vesa: jb .searchmodes .testx: mov cx, [VBEModeInfo.xresolution] - cmp word [.requiredx], 0 + cmp word [config.xres], 0 je .notrequiredx - cmp cx, [.requiredx] + cmp cx, [config.xres] je .testy jmp .searchmodes .notrequiredx: @@ -61,11 +57,11 @@ vesa: jb .searchmodes .testy: mov cx, [VBEModeInfo.yresolution] - cmp word [.requiredy], 0 + cmp word [config.yres], 0 je .notrequiredy - cmp cx, [.requiredy] + cmp cx, [config.yres] jne .searchmodes ;as if there weren't enough warnings, USE WITH CAUTION - cmp word [.requiredx], 0 + cmp word [config.xres], 0 jnz .setmode jmp .testgood .notrequiredy: @@ -95,7 +91,16 @@ vesa: int 0x16 pop esi 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: mov bx, [.currentmode] cmp bx, 0 @@ -114,12 +119,8 @@ vesa: .minx dw 640 .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 .currentmode dw 0