From 9eee6999d9d27301b73f604c9978677c9794d717 Mon Sep 17 00:00:00 2001 From: Christoffer Bubach Date: Sun, 11 Jan 2015 06:41:33 +0100 Subject: [PATCH] Now bootable --- kernel/16bit/init16bit.asm | 4 +- kernel/int/idt.asm | 201 +++++++++++++++++++------------------ kernel/shell/commands.asm | 3 +- 3 files changed, 105 insertions(+), 103 deletions(-) diff --git a/kernel/16bit/init16bit.asm b/kernel/16bit/init16bit.asm index 4815455..ac37936 100755 --- a/kernel/16bit/init16bit.asm +++ b/kernel/16bit/init16bit.asm @@ -15,7 +15,7 @@ init16bit: xor eax, eax ; clear mem for IDT and GDT mov edi, [idtr.address] ; IDT address - mov ecx, ([idtr.size] + [idtr.size])/4 + mov ecx, (0x800 + 0x800)/4 rep stosd mov eax, cs @@ -29,7 +29,7 @@ init16bit: mov [gdt.BOS_16data + 7], ah lea esi, [gdt] - mov edi, [gdtr.address] ; GDT address + mov edi, 0x7400 ; GDT address mov ecx, (gdt_end - gdt)/4 rep movsd ; Move it to final pos. diff --git a/kernel/int/idt.asm b/kernel/int/idt.asm index cafbc63..5b4a8d8 100644 --- a/kernel/int/idt.asm +++ b/kernel/int/idt.asm @@ -1,148 +1,149 @@ ;----------------------------------------------------------; -; BOS kernel Christoffer Bubach, 2003-2005. ; +; BOS kernel Christoffer Bubach, 2003-2005. ; ;----------------------------------------------------------; -; ; -; set/modify IDT entries ; -; ; +; ; +; set/modify IDT entries ; +; ; ;----------------------------------------------------------; ;--------------------------------------------------; -; set up IDT ; -; in: edi = pointer to "unhandled int"-function. ; +; set up IDT ; +; in: esi = pointer to "unhandled int"-function. ; ;--------------------------------------------------; init_idt: - push eax - push ecx + push eax + push ecx - mov ecx, 0 - .loop: ; loop - mov eax, edi ; and - mov [(0x6c00+ecx)], ax ; set whole IDT - add ecx, 2 ; to one ISR + xor ecx, ecx + .l1: + mov eax, esi ; loop full IDT and + mov [(0x6c00+ecx)], ax ; set to one ISR + add ecx, 2 - mov dword [(0x6c00+ecx)], 0x8E000008 ; 0x6c00 is where - add ecx, 4 ; we put the IDT + mov dword [(0x6c00+ecx)], 0x8E000008 ; 0x6c00 is where + add ecx, 4 ; we put the IDT - mov eax, edi - shr eax, 16 - mov [(0x6c00+ecx)], ax - add ecx, 2 + mov eax, esi + shr eax, 16 + mov [(0x6c00+ecx)], ax + add ecx, 2 - cmp ecx, 0x800 ; 256 ints - jb .loop ; * 8 bytes each + cmp ecx, 0x800 ; 256 ints + jb .l1 ; * 8 bytes each - pop ecx - pop eax - ret + pop ecx + pop eax + ret ;--------------------------------------; -; modify IDT, set any int ; -; in: cl = int number ; -; edi = int function pointer ; +; modify IDT, set any int ; +; in: cl = int number ; +; edi = int function pointer ; ;--------------------------------------; set_int: - push eax - push ecx + push eax + push ecx - mov al, 8 ; 8 bytes for each int - mul cl ; cl * al = ax - movzx ecx, ax ; ecx = offset in IDT (1/2 for dword list) - ;;mov [(idt_list+ecx/2)], edi ; add new int to idt entry list - mov dword [(idt_list+ecx)], edi ; add new int to idt entry list + mov al, 8 ; 8 bytes for each int + mul cl ; cl * al = ax + movzx ecx, ax ; ecx = IDT offset + shr ecx, 1 ; 1/2 for dword list + mov dword [(idt_list+ecx)], edi ; add to dword int list + movzx ecx, ax ; ecx = IDT offset - mov eax, edi - mov [(0x6c00+ecx)], ax - add ecx, 2 + mov eax, edi + mov [(0x6c00+ecx)], ax + add ecx, 2 - mov dword [(0x6c00+ecx)], 0x8E000008 - add ecx, 4 + mov dword [(0x6c00+ecx)], 0x8E000008 + add ecx, 4 - mov eax, edi - shr eax, 16 - mov [(0x6c00+ecx)], ax + mov eax, edi + shr eax, 16 + mov [(0x6c00+ecx)], ax - pop ecx - pop eax - ret + pop ecx + pop eax + ret ;------------------------------------------------; -; get int address ; -; in: cl = int number ; -; out: esi = address or 0 if none present ; +; get int address ; +; in: cl = int number ; +; out: esi = address or 0 if none present ; ;------------------------------------------------; get_int: - push eax + push eax - mov eax, 4 ; 4 bytes for each address - mul cl ; cl * al = ax - mov esi, idt_list - add esi, eax + mov eax, 4 ; 4 bytes for each address + mul cl ; cl * al = ax + mov esi, idt_list + add esi, eax - pop eax - ret + pop eax + ret ;----------------------------------------; -; sets ints from list ; -; in: esi = pointer to int list ; +; sets ints from list ; +; in: esi = pointer to int list ; ;----------------------------------------; set_idt_list: - push eax - push edi + push eax + push edi - mov ecx, 0 - .loop: - lodsd - or eax, eax - jz .next - mov edi, eax - call set_int - .next: - inc ecx - cmp ecx, 0x100 - jb .loop + xor ecx, ecx + .l1: + lodsd + or eax, eax + jz .next + mov edi, eax + call set_int + .next: + inc ecx + cmp ecx, 0x100 + jb .l1 - pop edi - pop eax - ret + pop edi + pop eax + ret ;------------------------------; ; list of idt entries. ; -; 0 = not handled ; +; 0 = not handled ; ;------------------------------; -idt_list: dd isr00 - dd isr01 - dd isr02 - dd isr03 - dd isr04 - dd isr05 - dd isr06 - dd isr07 - dd isr08 - dd isr09 - dd isr0A - dd isr0B - dd isr0C - dd isr0D - dd isr0E - dd 0 - dd isr10 - dd isr11 - dd isr12 - dd isr13 - times 12 dd 0 ; 12 unused ints - dd isr20 - dd isr21 - times 16 dd 0 ; 16 unused ints - dd isr32 ; First free and BOS system interrupt. - times 205 dd 0 ; 205 unused ints \ No newline at end of file +idt_list: dd isr00 + dd isr01 + dd isr02 + dd isr03 + dd isr04 + dd isr05 + dd isr06 + dd isr07 + dd isr08 + dd isr09 + dd isr0A + dd isr0B + dd isr0C + dd isr0D + dd isr0E + dd 0 + dd isr10 + dd isr11 + dd isr12 + dd isr13 + times 12 dd 0 ; 12 unused ints + dd isr20 + dd isr21 + times 16 dd 0 ; 16 unused ints + dd isr32 ; First free and BOS system interrupt. + times 205 dd 0 ; 205 unused ints \ No newline at end of file diff --git a/kernel/shell/commands.asm b/kernel/shell/commands.asm index 1c66dc7..3314e01 100755 --- a/kernel/shell/commands.asm +++ b/kernel/shell/commands.asm @@ -311,7 +311,8 @@ call print_char call fdd_reset - call fdd_recalibrate ; do somthing about the error.. :P + mov al, 1 + call fdd_recal_seek ; do somthing about the error.. :P .end: ret -- 2.52.0