Fixed some bugs. Now 64 bits kernel can do it.

This commit is contained in:
hyperassembler 2015-09-03 21:49:37 -04:00
parent 454be49390
commit a4411ce9a6
5 changed files with 9 additions and 13 deletions

View File

@ -63,7 +63,6 @@ GDT64: ; Global Descriptor Table (64-bit).
dq GDT64 ; Base.
entry_32:
xchg bx,bx
; close interrupt
cli
@ -76,6 +75,9 @@ hlt
; set stack pointer
mov esp, KERNEL_STACK
; save multiboot_info*
mov esi,ebx
; check x64 support
call ensure_support_x64
cmp eax,1
@ -181,6 +183,7 @@ mov ss,ax
; align 16 bytes like this for now
mov rsp,KERNEL_STACK
mov rdi,rsi ; multiboot_info*
call kmain
hlt

View File

@ -73,7 +73,6 @@ pushaq
cld
call hal_interrupt_handler_dummy
popaq
xchg bx,bx
iretq
hal_halt_cpu:

View File

@ -8,7 +8,7 @@
boot_info_t* NATIVE64 hal_init(multiboot_info_t* m_info)
{
text_pos = get_pos(3, 0);
text_pos = get_pos(0, 0);
// get gdt ready
hal_write_segment_descriptor((void *) &g_gdt[0], 0, 0, 0);
@ -30,8 +30,8 @@ boot_info_t* NATIVE64 hal_init(multiboot_info_t* m_info)
g_idt_ptr.limit = 21*16-1;
hal_flush_idt(&g_idt_ptr);
boot_info_t* boot_info = (boot_info_t*)hal_halloc(sizeof(boot_info_t));
BOCHS_MAGIC_BREAKPOINT();
hal_assert(boot_info != NULL, "Unable to allocate memory for boot_info.");
// obtain boot information
// memory info
@ -95,12 +95,6 @@ boot_info_t* NATIVE64 hal_init(multiboot_info_t* m_info)
linked_list_add(boot_info->module_info->module_list, &each_module->list_node);
}
}
else
{
// halt machine
hal_printf("HAL: Cannot detect kernel modules.");
hal_halt_cpu();
}
// detect APIC
cpuid_t cpuid_info;

View File

@ -40,7 +40,7 @@ void NATIVE64 hal_assert(int64_t expression, char* message)
if(!expression)
{
hal_printf("HAL: Assertion failed. Detail: %s", message == NULL ? "NULL" : message);
hal_halt_cpu();
}
hal_halt_cpu();
return;
}

View File

@ -4,8 +4,8 @@
#include "../hal/io.h"
#include "../common/util/util.h"
extern uint64_t kernel_start;
extern uint64_t kernel_end;
extern char kernel_start[];
extern char kernel_end[];
void NATIVE64 kmain(multiboot_info_t *multiboot_info)
{
boot_info_t* boot_info = hal_init(multiboot_info);