/kernel/trunk/arch/ia32/src/mm/frame.c |
---|
50,10 → 50,8 |
/* Reserve frame 0 (BIOS data) */ |
frame_region_not_free(0, FRAME_SIZE); |
#ifdef CONFIG_SMP |
/* Reserve AP real mode bootstrap memory */ |
frame_region_not_free(AP_BOOT_OFFSET, hardcoded_unmapped_ktext_size + hardcoded_unmapped_kdata_size); |
#endif |
/* Reserve real mode bootstrap memory */ |
frame_region_not_free(BOOTSTRAP_OFFSET, hardcoded_unmapped_ktext_size + hardcoded_unmapped_kdata_size); |
for (i = 0; i < e820counter; i++) { |
if (e820table[i].type == MEMMAP_MEMORY_AVAILABLE) { |
/kernel/trunk/arch/ia32/src/smp/smp.c |
---|
30,7 → 30,6 |
#include <arch/smp/smp.h> |
#include <arch/smp/mps.h> |
#include <arch/smp/ap.h> |
#include <arch/boot/boot.h> |
#include <genarch/acpi/acpi.h> |
#include <genarch/acpi/madt.h> |
#include <config.h> |
142,10 → 141,9 |
if (!(gdt_new = (struct descriptor *) malloc(GDT_ITEMS*sizeof(struct descriptor)))) |
panic("couldn't allocate memory for GDT\n"); |
memcpy(gdt_new, gdt, GDT_ITEMS * sizeof(struct descriptor)); |
memcpy(gdt_new, gdt, GDT_ITEMS*sizeof(struct descriptor)); |
memsetb((__address)(&gdt_new[TSS_DES]), sizeof(struct descriptor), 0); |
protected_ap_gdtr.limit = GDT_ITEMS * sizeof(struct descriptor); |
protected_ap_gdtr.base = KA2PA((__address) gdt_new); |
real_bootstrap_gdtr.base = KA2PA((__address) gdt_new); |
gdtr.base = (__address) gdt_new; |
if (l_apic_send_init_ipi(ops->cpu_apic_id(i))) { |
/kernel/trunk/arch/ia32/src/smp/apic.c |
---|
30,7 → 30,6 |
#include <arch/smp/apic.h> |
#include <arch/smp/ap.h> |
#include <arch/smp/mps.h> |
#include <arch/boot/boot.h> |
#include <mm/page.h> |
#include <time/delay.h> |
#include <interrupt.h> |
/kernel/trunk/arch/ia32/src/smp/ap.S |
---|
1,6 → 1,5 |
# |
# Copyright (C) 2001-2004 Jakub Jermar |
# Copyright (C) 2005-2006 Martin Decky |
# All rights reserved. |
# |
# Redistribution and use in source and binary forms, with or without |
31,16 → 30,11 |
# Init code for application processors. |
# |
#include <arch/boot/boot.h> |
#include <arch/boot/memmap.h> |
#include <arch/mm/page.h> |
#include <arch/pm.h> |
.section K_TEXT_START_2, "ax" |
.section K_TEXT_START, "ax" |
#ifdef CONFIG_SMP |
.global unmapped_ap_boot |
.global ap_boot |
KTEXT=8 |
KDATA=16 |
50,18 → 44,18 |
# requirements. |
.align 4096 |
unmapped_ap_boot: |
ap_boot: |
.code16 |
cli |
xorw %ax, %ax |
movw %ax, %ds |
lgdt ap_gdtr # initialize Global Descriptor Table register |
lgdt real_bootstrap_gdtr_boot # initialize Global Descriptor Table register |
movl %cr0, %eax |
orl $1, %eax |
movl %eax, %cr0 # switch to protected mode |
jmpl $KTEXT, $jump_to_kernel - BOOT_OFFSET + AP_BOOT_OFFSET |
jmpl $KTEXT, $jump_to_kernel |
jump_to_kernel: |
.code32 |
69,7 → 63,7 |
movw %ax, %ds |
movw %ax, %es |
movw %ax, %ss |
movl $KA2PA(ctx), %eax # KA2PA((__address) &ctx) |
movl $(ctx-0x80000000), %eax # KA2PA((__address) &ctx) |
movl (%eax), %esp |
subl $0x80000000, %esp # KA2PA(ctx.sp) |
80,16 → 74,3 |
jmpl $KTEXT, $main_ap |
#endif /* CONFIG_SMP */ |
.section K_DATA_START, "ax" |
#ifdef CONFIG_SMP |
.global unmapped_ap_gdtr |
unmapped_ap_gdtr: |
.word 0 |
.long 0 |
#endif /* CONFIG_SMP */ |
/kernel/trunk/arch/ia32/src/boot/boot.S |
---|
1,6 → 1,5 |
# |
# Copyright (C) 2001-2004 Jakub Jermar |
# Copyright (C) 2005-2006 Martin Decky |
# All rights reserved. |
# |
# Redistribution and use in source and binary forms, with or without |
32,8 → 31,6 |
#include <arch/mm/page.h> |
#include <arch/pm.h> |
#define START_STACK (BOOT_OFFSET - BOOT_STACK_SIZE) |
.section K_TEXT_START, "ax" |
KTEXT=8 |
41,34 → 38,40 |
.code32 |
.align 4 |
.global multiboot_image_start |
multiboot_header: |
.long MULTIBOOT_HEADER_MAGIC |
.long MULTIBOOT_HEADER_FLAGS |
.long -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS) # checksum |
.long multiboot_header |
.long unmapped_ktext_start |
.long multiboot_header + BOOT_OFFSET |
.long unmapped_ktext_start + BOOT_OFFSET |
.long 0 |
.long 0 |
.long multiboot_image_start |
.long multiboot_image_start + BOOT_OFFSET |
multiboot_image_start: |
movl $START_STACK, %esp # initialize stack pointer |
lgdt KA2PA(bootstrap_gdtr) # initialize Global Descriptor Table register |
movl $BOOTSTRAP_OFFSET - 0x400, %esp # initialize stack pointer |
lgdt protected_bootstrap_gdtr - 0x80000000 # initialize Global Descriptor Table register |
movw $KDATA, %cx |
movw %cx, %es |
movw %cx, %gs |
movw %cx, %fs |
movw %cx, %ds # kernel data + stack |
movw %cx, %ds # kernel data + stack |
movw %cx, %ss |
jmpl $KTEXT, $multiboot_meeting_point |
jmpl $KTEXT, $multiboot_meeting_point + BOOT_OFFSET |
multiboot_meeting_point: |
pushl %ebx # save parameters from GRUB |
pushl %eax |
movl $BOOTSTRAP_OFFSET + BOOT_OFFSET, %esi |
movl $BOOTSTRAP_OFFSET, %edi |
movl $_hardcoded_unmapped_size, %ecx |
cld |
rep movsb |
call map_kernel # map kernel and turn paging on |
popl %eax |
167,19 → 170,7 |
invalid_boot: |
#ifdef CONFIG_SMP |
# copy AP bootstrap routines below 1 MB |
movl $BOOT_OFFSET, %esi |
movl $AP_BOOT_OFFSET, %edi |
movl $_hardcoded_unmapped_size, %ecx |
cld |
rep movsb |
#endif |
call main_bsp # never returns |
call main_bsp - BOOT_OFFSET # never returns |
cli |
hlt |
223,3 → 214,9 |
.align 4096 |
page_directory: |
.space 4096, 0 |
.global real_bootstrap_gdtr_boot |
real_bootstrap_gdtr_boot: |
.word selector(GDT_ITEMS) |
.long KA2PA(gdt)-BOOT_OFFSET |
/kernel/trunk/arch/ia32/src/pm.c |
---|
71,7 → 71,7 |
struct tss *tss_p = NULL; |
/* gdtr is changed by kmp before next CPU is initialized */ |
struct ptr_16_32 bootstrap_gdtr = { .limit = sizeof(gdt), .base = KA2PA((__address) gdt) }; |
struct ptr_16_32 protected_bootstrap_gdtr = { .limit = sizeof(gdt), .base = KA2PA((__address) gdt) }; |
struct ptr_16_32 gdtr = { .limit = sizeof(gdt), .base = (__address) gdt }; |
void gdt_setbase(struct descriptor *d, __address base) |