Code: Select all
.section .bss
.align 16
stack_bottom:
.skip 16384 # 16 KiB
stack_top:
.section .text
.global _start
.type _start, @function
_start:
mov $stack_top, %esp
call kernel_main
.global _gdt_flush
.extern _gp
.type _gdt_flush, @function
_gdt_flush:
lgdt (_gp)
mov %ax, 0x10
mov %ds, %ax
mov %es, %ax
mov %fs, %ax
mov %gs, %ax
mov %ss, %ax
jmp $0x08, $flush2
flush2:
ret
.global _idt_load
.extern _idtp
.type _idt_load, @function
_idt_load:
lidt (_idtp)
ret
.global _isr0
/* _isr1, isr2 etc... */
.type _isr0, @function
_isr0:
cli
push 0
push 0
jmp isr_common_stub
.type _isr1, @function
_isr1:
cli
push 0
push 1
jmp isr_common_stub
/* _isr2, isr3 etc... */
.global isr_common_stub
.extern _fault_handler
.type isr_common_stub, @function
isr_common_stub:
pusha
push %ds
push %es
push %fs
push %gs
mov %ax, 0x10
mov %ds, %ax
mov %es, %ax
mov %fs, %ax
mov %gs, %ax
mov %eax, %esp
push %eax
mov %eax, _fault_handler
call *%eax
pop %eax
pop %gs
pop %fs
pop %es
pop %ds
popa
add %esp, 8
iret
.size _start, . - _start
Code: Select all
struct regs{
unsigned int gs, fs, es, ds;
unsigned int edi, esi, ebp, esp, ebx, edx, ecx, eax;
unsigned int int_no, err_code;
unsigned int eip, cs, eflags, useresp, ss;
};
extern void _isr0();
/* _isr1, isr2 etc... */
void isrs_install(){
idt_set_gate(0, (unsigned)_isr0, 0x08, 0x8E);
/* _isr1, isr2 etc... */
}
void _fault_handler(struct regs *r){
printf("Exception!\n");
}
Code: Select all
asm("int $0x10");
I have read the wiki page on this issue but I'm not sure if any of the listed potential problems apply to me. Can anyone point me in the right direction? Thanks.
[/size]