X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Floader.asm;h=f1ef6595f009002341869f9824ce88c7996d8eb1;hb=HEAD;hp=0ef217774b45332e97f0f84d3cc4239c38fc5fe1;hpb=d47314873cf54024672cabe3746c80c7d4e6e6fa;p=metatoy diff --git a/src/loader.asm b/src/loader.asm index 0ef2177..f1ef659 100644 --- a/src/loader.asm +++ b/src/loader.asm @@ -17,11 +17,13 @@ _start: mov ds, ax mov es, ax mov fs, ax ; this will store the original real mode segment - mov ss, ax ; modify the return to real mode jump segment mov [.jmpcs16 + 3], ax - xor ax, ax + ; put the stack on the next segment, should be free + add ax, 1000h + mov ss, ax + mov ax, 0xfffe mov sp, ax %ifdef BUG_WARNING @@ -111,6 +113,7 @@ _start: mov ax, 13h int 10h + cli ; paranoid lgdt [gdt_lim] mov eax, cr0 @@ -165,7 +168,7 @@ _start: mov ss, ax ; restore real-mode IVT - lidt [rmidt] + o32 lidt [rmidt] ; switch back to text mode mov ax, 3 @@ -177,8 +180,14 @@ _start: mov ax, 1 call far [vmswitch] ; broadcast windows exit + xor ax, ax + mov bx, ax + mov si, ax + mov es, ax + mov ds, ax + mov cx, ax + mov dx, ax mov ax, 1606h - xor dx, dx int 2fh exit: mov ax, 4c00h @@ -188,6 +197,7 @@ str_gemmis db 'Memory manager detected, trying to take control...',0 str_errvm86 db 'Error: memory manager running. Stop it and try again (e.g. emm386 off)',10,0 str_enterpm db 'Entering 32bit protected mode ...',10,0 + align 4 vmswitch: vmswitch_off dw 0 vmswitch_seg dw 0 @@ -350,7 +360,7 @@ detect_memory: str_ok db 'OK',10,0 str_fail db 'failed',10,0 memdet_fail_msg db 'Failed to detect available memory!',10,0 -memdet_detram db 'Detecting RAM ' +memdet_detram db 'Detecting RAM ',0 memdet_e820_msg db '(BIOS 15h/0xe820)... ',0 memdet_e801_msg db '(BIOS 15h/0xe801)... ',0 memdet_88_msg db '(BIOS 15h/0x88, max 64mb)... ',0 @@ -623,4 +633,40 @@ gdt: ; 0: null segment rmidt: dw 3ffh ; IVT limit (1kb / 256 entries) dd 0 ; IVT base 0 + +; --- debug --- +newline: + push ax + mov al, 13 + call ser_putchar + mov al, 10 + call ser_putchar + pop ax + ret + +printhex: + rol ax, 4 + call print_hexdigit + rol ax, 4 + call print_hexdigit + rol ax, 4 + call print_hexdigit + rol ax, 4 + call print_hexdigit + ret + +print_hexdigit: + push ax + and ax, 0xf + cmp al, 0xa + jae .hexdig + add al, '0' + call ser_putchar + pop ax + ret +.hexdig:add al, 'a' - 10 + call ser_putchar + pop ax + ret + ; vi:set ts=8 sts=8 sw=8 ft=nasm: