Make .data empty.

This commit is contained in:
Alexander Myltsev 2022-11-20 23:40:45 +03:00
parent 38d384175c
commit e4fcd27e31
3 changed files with 18 additions and 6 deletions

View File

@ -30,7 +30,7 @@ void set_idt_gate(int n, uint32_t handler) {
} }
// defined in vectors.S // defined in vectors.S
extern uint32_t default_handlers[]; extern const uint32_t default_handlers[];
void init_idt() { void init_idt() {
if (default_handlers[0] == 0) { if (default_handlers[0] == 0) {
@ -41,7 +41,7 @@ void init_idt() {
} }
} }
const char *exception_messages[] = { const char * const exception_messages[] = {
"Division By Zero", "Division By Zero",
"Debug", "Debug",
"Non Maskable Interrupt", "Non Maskable Interrupt",

View File

@ -37,11 +37,11 @@ vector\i :
.section .text .section .text
handler \number handler \number
.section .data .section .rodata
.long vector\number .long vector\number
.endm .endm
.section .data .section .rodata
.global default_handlers .global default_handlers
default_handlers: default_handlers:
.set i,0 .set i,0

16
mbr.S
View File

@ -16,7 +16,11 @@ get_drive_geometry:
mov $8, %ah mov $8, %ah
mov boot_drive, %dl mov boot_drive, %dl
int $0x13 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 .equ ELF32_ENTRY_OFFSET, 0x18
@ -42,13 +46,17 @@ load_kernel:
mov KERNEL_OFFSET + ELF32_ENTRY_OFFSET, %si mov KERNEL_OFFSET + ELF32_ENTRY_OFFSET, %si
mov %si, entry // store entry point mov %si, entry // store entry point
#if 0
mov KERNEL_OFFSET + ELF32_PHNUM_OFFSET, %ax mov KERNEL_OFFSET + ELF32_PHNUM_OFFSET, %ax
dec %ax // no offset to the first entry dec %ax // no offset to the first entry
mulb KERNEL_OFFSET + ELF32_PHENTSIZE_OFFSET mulb KERNEL_OFFSET + ELF32_PHENTSIZE_OFFSET
mov %ax, %di mov %ax, %di
add KERNEL_OFFSET + ELF32_PHDR_OFFSET, %di add KERNEL_OFFSET + ELF32_PHDR_OFFSET, %di
// now di holds offset to the last phentry // 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 mov KERNEL_OFFSET + ELF32_PHDR_FILESZ_OFFSET(%di), %ax
add KERNEL_OFFSET + ELF32_PHDR_P_OFFSET(%di), %ax add KERNEL_OFFSET + ELF32_PHDR_P_OFFSET(%di), %ax
sub $0x1000, %ax // we won't load the header sub $0x1000, %ax // we won't load the header
@ -140,6 +148,10 @@ read_error:
.balign 2 .balign 2
entry: entry:
.word 0 .word 0
disk_heads:
.byte 0
sectors_per_track:
.byte 0
.balign 4 .balign 4
gdt_start: gdt_start: