X-Git-Url: https://git.wirehaze.ovh/BOS.git/blobdiff_plain/9eee6999d9d27301b73f604c9978677c9794d717..359bb65a0ed9dbb75a208db4675db689877a85b9:/kernel/init/bios.asm diff --git a/kernel/init/bios.asm b/kernel/init/bios.asm index ed5716d..8ecad9f 100755 --- a/kernel/init/bios.asm +++ b/kernel/init/bios.asm @@ -8,100 +8,99 @@ rmode_int: - pushad - push eax - shr eax, 16 ; move high bits to ax - mov word [realmode_ax], ax ; save new ax value - pop eax ; restore - - push ebx - shr ebx, 16 ; move high bits to bx - mov byte [int_number], bl ; save int number to call - pop ebx - - mov byte [realmode_error], 0 ; all variables is in the - mov word [realmode_bx], bx ; realmode/variables.inc file - mov word [realmode_cx], cx - mov word [realmode_dx], dx - call disable_irqs - jmp pword 0x18:do_16pmode ; must substract 0x10000 from - ; data addresses becasue of - ; fasm strict "org" behavior + pushad + push eax + shr eax, 16 ; move high bits to ax + mov word [realmode_ax], ax ; save new ax value + pop eax ; restore + + push ebx + shr ebx, 16 ; move high bits to bx + mov byte [int_number], bl ; save int number to call + pop ebx + + mov byte [realmode_error], 0 ; all variables is in the + mov word [realmode_bx], bx ; realmode/variables.inc file + mov word [realmode_cx], cx + mov word [realmode_dx], dx + call disable_irqs + jmp pword 0x18:do_16pmode ; begin our dark journey into 16bit-land + use16 do_16pmode: - mov ax, 0x20 - mov ds, ax - mov es, ax - mov fs, ax - mov gs, ax - mov ss, ax + mov ax, 0x20 + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + mov ss, ax - cli - mov eax, cr0 - and al, 0xFE - mov cr0, eax + cli + mov eax, cr0 + and al, 0xFE + mov cr0, eax - jmp 0x1000:(do_realm) + jmp 0x0000:(do_realm) ; this should be triple checked! do_realm: - mov ax, cs - mov ds, ax + mov ax, cs + mov ds, ax - xor ax, ax - mov es, ax - mov fs, ax - mov gs, ax - mov ss, ax + xor ax, ax + mov es, ax + mov fs, ax + mov gs, ax + mov ss, ax - lidt [ridtr] ; realmode/variables.inc - sti + lidt [ridtr] ; realmode/variables.inc + sti - mov ax, word [realmode_ax] - mov bx, word [realmode_bx] - mov cx, word [realmode_cx] - mov dx, word [realmode_dx] + mov ax, word [realmode_ax] + mov bx, word [realmode_bx] + mov cx, word [realmode_cx] + mov dx, word [realmode_dx] - push ax ; this is some cool shit.. ;) - mov al, [int_number] ; interrupt to preform - mov [$+5], al ; move it to right pos. - pop ax - db 0xCD ; opcode for int. - db 0x00 ; move int_number here + push ax ; this is some cool shit.. ;) + mov al, [int_number] ; interrupt to preform + mov [$+5], al ; move it to right pos. + pop ax + db 0xCD ; opcode for int. + db 0x00 ; move int_number here - jnc .no_error - mov byte [realmode_error], 1 + jnc .no_error + mov byte [realmode_error], 1 - .no_error: - mov word [realmode_ax], ax - mov word [realmode_bx], bx - mov word [realmode_cx], cx - mov word [realmode_dx], dx + .no_error: + mov word [realmode_ax], ax + mov word [realmode_bx], bx + mov word [realmode_cx], cx + mov word [realmode_dx], dx - cli + cli - lgdt [gdtr] - lidt [idtr] - mov eax, cr0 - or al, 1 - mov cr0, eax + lgdt [gdtr] + lidt [idtr] + mov eax, cr0 + or al, 1 + mov cr0, eax - jmp pword 0x08:gobackto_pm + jmp pword 0x08:gobackto_pm use32 gobackto_pm: - mov ax, 0x10 ; refresh all segment registers - mov ds, ax - mov es, ax - mov fs, ax - mov gs, ax - mov ss, ax - call enable_irqs - sti - popad - clc ; clear carry. - cmp [realmode_error], 1 ; if error, then - jne .end - stc ; set carry. - .end: - ret \ No newline at end of file + mov ax, 0x10 ; refresh all segment registers + mov ds, ax + mov es, ax + mov fs, ax + mov gs, ax + mov ss, ax + call enable_irqs + sti + popad + clc ; clear carry. + cmp [realmode_error], 1 ; if error, then + jne .end + stc ; set carry. + .end: + ret \ No newline at end of file