/SPARTAN/trunk/arch/ia32/include/boot/boot.h |
---|
29,7 → 29,9 |
#ifndef __ia32_BOOT_H__ |
#define __ia32_BOOT_H__ |
#define BOOTSTRAP_OFFSET 0x8000 |
#define BOOT_OFFSET 0x100000 |
#define MULTIBOOT_HEADER_MAGIC 0x1BADB002 |
#define MULTIBOOT_HEADER_FLAGS 0x00010003 |
/SPARTAN/trunk/arch/ia32/src/ia32.c |
---|
57,7 → 57,7 |
if (config.cpu_active == 1) { |
bios_init(); |
i8042_init(); /* a20 bit */ |
i8042_init(); /* keyboard controller */ |
i8259_init(); /* PIC */ |
i8254_init(); /* hard clock */ |
/SPARTAN/trunk/arch/ia32/src/pm.c |
---|
70,7 → 70,9 |
struct tss *tss_p = NULL; |
/* gdtr is changed by kmp before next CPU is initialized */ |
struct ptr_16_32 gdtr __attribute__ ((section ("K_DATA_START"))) = { .limit = sizeof(gdt), .base = KA2PA((__address) gdt - BOOT_OFFSET) }; |
struct ptr_16_32 bsp_bootstrap_gdtr __attribute__ ((section ("K_DATA_START"))) = { .limit = sizeof(gdt), .base = KA2PA((__address) gdt - BOOT_OFFSET) }; |
struct ptr_16_32 ap_bootstrap_gdtr __attribute__ ((section ("K_DATA_START"))) = { .limit = sizeof(gdt), .base = KA2PA((__address) gdt) }; |
struct ptr_16_32 gdtr = { .limit = sizeof(gdt), .base = KA2PA((__address) gdt) }; |
struct ptr_16_32 idtr __attribute__ ((section ("K_DATA_START"))) = { .limit = sizeof(idt), .base = KA2PA((__address) idt) }; |
void gdt_setbase(struct descriptor *d, __address base) |
170,7 → 172,7 |
/* |
* Update addresses in GDT and IDT to their virtual counterparts. |
*/ |
gdtr.base = KA2PA(gdtr.base); |
gdtr.base = (__address) gdt; |
idtr.base = (__address) idt; |
__asm__ volatile ("lgdt %0\n" : : "m" (gdtr)); |
__asm__ volatile ("lidt %0\n" : : "m" (idtr)); |
/SPARTAN/trunk/arch/ia32/src/smp/ap.S |
---|
50,12 → 50,13 |
xorw %ax,%ax |
movw %ax,%ds |
lgdt gdtr # initialize Global Descriptor Table register |
lgdt ap_bootstrap_gdtr # initialize Global Descriptor Table register |
movl %cr0,%eax |
orl $1,%eax |
movl %eax,%cr0 # switch to protected mode |
jmpl $KTEXT,$jump_to_kernel |
jump_to_kernel: |
.code32 |
movw $KDATA,%ax |
68,6 → 69,11 |
call map_kernel # map kernel and turn paging on |
movb $0xd1, %al # enable A20 using the keyboard controller |
outb %al, $0x64 |
movb $0xdf, %al |
outb %al, $0x60 |
jmpl $KTEXT,$main_ap |
#endif /* __SMP__ */ |
/SPARTAN/trunk/arch/ia32/src/boot/boot.S |
---|
31,6 → 31,9 |
.section K_TEXT_START |
.global kernel_image_start |
KTEXT=8 |
KDATA=16 |
.code16 |
# |
# This is where we require any SPARTAN-kernel-compatible boot loader |
45,17 → 48,17 |
xorw %ax, %ax |
movw %ax, %ds |
movw %ax, %ss # initialize stack segment register |
movl $0x7c00, %esp # initialize stack pointer |
movl $BOOTSTRAP_OFFSET - 0x400, %esp # initialize stack pointer |
call memmap_arch_init |
lgdt gdtr # initialize Global Descriptor Table register |
lgdt bsp_bootstrap_gdtr # initialize Global Descriptor Table register |
movl %cr0, %eax |
orl $0x1, %eax |
movl %eax, %cr0 # switch to protected mode |
jmpl $8, $boot_image_start |
jmpl $KTEXT, $boot_image_start |
.code32 |
.align 4 |
70,7 → 73,7 |
.long multiboot_image_start + BOOT_OFFSET |
boot_image_start: |
movw $16, %ax |
movw $KDATA, %ax |
movw %ax, %es |
movw %ax, %gs |
movw %ax, %fs |
84,8 → 87,8 |
movb $0xdf, %al |
outb %al, $0x60 |
movl $0x8000, %esi |
movl $0x8000 + BOOT_OFFSET, %edi |
movl $BOOTSTRAP_OFFSET, %esi |
movl $BOOTSTRAP_OFFSET + BOOT_OFFSET, %edi |
movl $_hardcoded_kernel_size, %ecx |
cld |
rep movsb |
93,11 → 96,11 |
jmp protected |
multiboot_image_start: |
movl $0x7c00, %esp # initialize stack pointer |
movl BOOTSTRAP_OFFSET - 0x400, %esp # initialize stack pointer |
lgdt gdtr |
lgdt gdtr # initialize Global Descriptor Table register |
movw $16, %ax |
movw $KDATA, %ax |
movw %ax, %es |
movw %ax, %gs |
movw %ax, %fs |
/SPARTAN/trunk/arch/ia32/src/mm/frame.c |
---|
30,9 → 30,11 |
#include <arch/mm/frame.h> |
#include <mm/vm.h> |
#include <config.h> |
#include <arch/boot/boot.h> |
#include <arch/boot/memmap.h> |
#include <print.h> |
size_t hardcoded_unmapped_ktext_size = 0; |
size_t hardcoded_unmapped_kdata_size = 0; |
void frame_arch_init(void) |
{ |
39,13 → 41,15 |
__u8 i; |
if (config.cpu_active == 1) { |
/* Reserve the NULL frame */ |
frame_not_free(0x0); |
/* Reserve well-known memory regions */ |
frame_region_not_free(0xa0000,0xff000); |
frame_region_not_free(0xfec00000,0xffffffff); |
/* This is a nasty hack, which should be fixed soon */ |
frame_region_not_free(0x0, 0xfffff); |
/* Reserve real mode bootstrap memory */ |
frame_region_not_free(BOOTSTRAP_OFFSET, BOOTSTRAP_OFFSET + hardcoded_unmapped_ktext_size + hardcoded_unmapped_kdata_size); |
for (i=e820counter;i>0;i--) { |
if (e820table[i-1].type!=MEMMAP_MEMORY_AVAILABLE) { |
/SPARTAN/trunk/arch/ia32/_link.ld |
---|
17,12 → 17,13 |
*(K_TEXT_START); |
*(K_TEXT_START_2); |
unmapped_ktext_end = .; |
unmapped_kdata_start = .; |
*(K_DATA_START); |
unmapped_kdata_end = .; |
} |
.mapped (0x80100000+SIZEOF(.unmapped)+0x8000) : AT (0x8000+SIZEOF(.unmapped)) { |
.mapped (0x80100000+0x8000+SIZEOF(.unmapped)): AT (0x8000+SIZEOF(.unmapped)) { |
ktext_start = .; |
*(BOOT_DATA) |
*(.text); |
38,6 → 39,10 |
LONG(ktext_end - ktext_start + (unmapped_ktext_end - unmapped_ktext_start)); |
hardcoded_kdata_size = .; |
LONG(kdata_end - kdata_start + (unmapped_kdata_end - unmapped_kdata_start)); |
hardcoded_unmapped_ktext_size = .; |
LONG(unmapped_ktext_end - unmapped_ktext_start); |
hardcoded_unmapped_kdata_size = .; |
LONG(unmapped_kdata_end - unmapped_kdata_start); |
*(.bss); /* uninitialized static variables */ |
*(K_DATA_END); |
kdata_end = .; |