diff --git a/cpu/idt.c b/cpu/idt.c index 218c88d..da94d89 100644 --- a/cpu/idt.c +++ b/cpu/idt.c @@ -30,7 +30,7 @@ void set_idt_gate(int n, uint32_t handler) { } // defined in vectors.S -extern uint32_t default_handlers[]; +extern const uint32_t default_handlers[]; void init_idt() { if (default_handlers[0] == 0) { @@ -41,7 +41,7 @@ void init_idt() { } } -const char *exception_messages[] = { +const char * const exception_messages[] = { "Division By Zero", "Debug", "Non Maskable Interrupt", diff --git a/cpu/vectors.S b/cpu/vectors.S index 9fd80ed..5c9f42e 100644 --- a/cpu/vectors.S +++ b/cpu/vectors.S @@ -37,11 +37,11 @@ vector\i : .section .text handler \number - .section .data + .section .rodata .long vector\number .endm -.section .data +.section .rodata .global default_handlers default_handlers: .set i,0 diff --git a/mbr.S b/mbr.S index 2451313..dac62bb 100644 --- a/mbr.S +++ b/mbr.S @@ -16,7 +16,11 @@ get_drive_geometry: mov $8, %ah mov boot_drive, %dl int $0x13 - // TODO + inc %dh // number of heads + mov %dh, disk_heads + and 0x3f, %cl + mov %cl, sectors_per_track + ret .equ ELF32_ENTRY_OFFSET, 0x18 @@ -42,13 +46,17 @@ load_kernel: mov KERNEL_OFFSET + ELF32_ENTRY_OFFSET, %si mov %si, entry // store entry point + #if 0 mov KERNEL_OFFSET + ELF32_PHNUM_OFFSET, %ax dec %ax // no offset to the first entry mulb KERNEL_OFFSET + ELF32_PHENTSIZE_OFFSET mov %ax, %di - add KERNEL_OFFSET + ELF32_PHDR_OFFSET, %di // now di holds offset to the last phentry + #else + mov KERNEL_OFFSET + ELF32_PHDR_OFFSET, %di + // now di holds offset to the first phentry + #endif mov KERNEL_OFFSET + ELF32_PHDR_FILESZ_OFFSET(%di), %ax add KERNEL_OFFSET + ELF32_PHDR_P_OFFSET(%di), %ax sub $0x1000, %ax // we won't load the header @@ -140,6 +148,10 @@ read_error: .balign 2 entry: .word 0 +disk_heads: + .byte 0 +sectors_per_track: + .byte 0 .balign 4 gdt_start: