/SPARTAN/trunk/arch/ia32/src/pm.c |
---|
66,17 → 66,17 |
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 = (__address) gdt }; |
struct ptr_16_32 idtr __attribute__ ((section ("K_DATA_START")))= { .limit = sizeof(idt), .base = (__address) idt }; |
struct ptr_16_32 gdtr __attribute__ ((section ("K_DATA_START"))) = { .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) |
{ |
d->base_0_15 = base & 0xffff; |
d->base_16_23 = (base >> 16) & 0xff; |
d->base_24_31 = (base >> 24) & 0xff; |
d->base_0_15 = KA2PA(base) & 0xffff; |
d->base_16_23 = (KA2PA(base) >> 16) & 0xff; |
d->base_24_31 = (KA2PA(base) >> 24) & 0xff; |
} |
void gdt_setlimit(struct descriptor *d, __address limit) |
void gdt_setlimit(struct descriptor *d, __u32 limit) |
{ |
d->limit_0_15 = limit & 0xffff; |
d->limit_16_19 = (limit >> 16) & 0xf; |
84,8 → 84,8 |
void idt_setoffset(struct idescriptor *d, __address offset) |
{ |
d->offset_0_15 = offset & 0xffff; |
d->offset_16_31 = offset >> 16; |
d->offset_0_15 = KA2PA(offset) & 0xffff; |
d->offset_16_31 = KA2PA(offset) >> 16; |
} |
void tss_initialize(struct tss *t) |
/SPARTAN/trunk/arch/ia32/src/boot/boot.S |
---|
39,8 → 39,8 |
# switch to protected mode. |
# |
kernel_image_start: |
cli |
call memmap_arch_init |
cli |
xorw %ax,%ax |
movw %ax,%ds |
lgdt gdtr |
62,8 → 62,39 |
lidt idtr |
call main_bsp # never returns |
# |
# Here we setup mapping for both the unmapped and mapped sections of the kernel. |
# For simplicity, we set only one 4M page for 0x00000000 and one for 0x80000000. |
# |
movl %cr4, %ecx |
orl $(1<<4), %ecx |
movl %ecx, %cr4 # turn PSE on |
movl $((1<<7)|(1<<0)), %eax |
movl %eax, page_directory # mapping 0x00000000 => 0x00000000 |
movl $(page_directory+(4096/2)), %edx |
movl %eax, (%edx) # mapping 0x80000000 => 0x00000000 |
leal page_directory, %eax |
movl %eax, %cr3 |
# turn on paging |
movl %cr0, %ebx |
orl $(1<<31), %ebx |
movl %ebx, %cr0 |
movl $_hardcoded_ktext_size, hardcoded_ktext_size |
movl $_hardcoded_kdata_size, hardcoded_kdata_size |
movl $_hardcoded_load_address, hardcoded_load_address |
call main_bsp # never returns |
cli |
hlt |
.section K_DATA_START |
.align 4096 |
page_directory: |
.space 4096, 0 |
/SPARTAN/trunk/arch/ia32/src/boot/memmap.S |
---|
29,12 → 29,6 |
#include <arch/boot/memmap.h> |
.global memmap_arch_init |
.code16 |
.section K_TEXT_START |
E820_RECORD_SIZE = MEMMAP_E820_RECORD_SIZE |
E820_MAX_RECORDS = MEMMAP_E820_MAX_RECORDS |
E820_SMAP = 0x534d4150 |
/SPARTAN/trunk/arch/ia32/src/mm/frame.c |
---|
37,11 → 37,8 |
void frame_arch_init(void) |
{ |
if (config.cpu_active == 1) { |
__u32 kernel_frames_max; |
kernel_frames_max = ((KERNEL_ADDRESS_SPACE_END+1)/FRAME_SIZE); |
kernel_frames_free = kernel_frames = frames < kernel_frames_max ? frames : kernel_frames_max; |
kernel_frames = frames; |
kernel_frames_free = frames_free; |
frame_kernel_bitmap = frame_bitmap; |
frame_not_free(0x0); |
/SPARTAN/trunk/arch/ia32/src/mm/page.c |
---|
53,19 → 53,22 |
__u32 i; |
if (config.cpu_active == 1) { |
dba = frame_alloc(FRAME_KA | FRAME_PANIC); |
dba = KA2PA(frame_alloc(FRAME_KA | FRAME_PANIC)); |
memsetb(dba, PAGE_SIZE, 0); |
cpu_write_dba(dba); |
bootstrap_dba = dba; |
/* |
* Identity mapping for all but 0th page. |
* PA2KA(identity) mapping for all but 0th page. |
*/ |
for (i = 1; i < frames; i++) |
for (i = 1; i < frames; i++) { |
map_page_to_frame(i * PAGE_SIZE, i * PAGE_SIZE, PAGE_CACHEABLE, 0); |
map_page_to_frame(PA2KA(i * PAGE_SIZE), i * PAGE_SIZE, PAGE_CACHEABLE, 0); |
} |
trap_register(14, page_fault); |
cpu_write_dba(dba); |
} |
else { |
104,7 → 107,9 |
__address dba, newpt; |
int pde, pte; |
dba = cpu_read_dba(); |
// TODO: map_page_to_frame should take dba as a parameter |
// dba = cpu_read_dba(); |
dba = bootstrap_dba; |
pde = page >> 22; /* page directory entry */ |
pte = (page >> 12) & 0x3ff; /* page table entry */ |
116,7 → 121,7 |
* There is currently no page table for this address. Allocate |
* frame for the page table and clean it. |
*/ |
newpt = frame_alloc(FRAME_KA); |
newpt = KA2PA(frame_alloc(FRAME_KA)); |
pd[pde].frame_address = newpt >> 12; |
memsetb(newpt, PAGE_SIZE, 0); |
pd[pde].present = 1; |
123,7 → 128,7 |
pd[pde].uaccessible = 1; |
} |
if (copy) { |
newpt = frame_alloc(FRAME_KA); |
newpt = KA2PA(frame_alloc(FRAME_KA)); |
memcopy(pd[pde].frame_address << 12, newpt, PAGE_SIZE); |
pd[pde].frame_address = newpt >> 12; |
} |