Subversion Repositories HelenOS-historic

Compare Revisions

Ignore whitespace Rev 693 → Rev 692

/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)
/kernel/trunk/arch/ia32/_link.ld.in
13,9 → 13,10
#include <arch/mm/page.h>
 
SECTIONS {
.unmapped BOOT_OFFSET: AT (0) {
.unmapped BOOTSTRAP_OFFSET: AT (BOOTSTRAP_OFFSET) {
unmapped_ktext_start = .;
*(K_TEXT_START);
*(K_TEXT_START_2);
unmapped_ktext_end = .;
unmapped_kdata_start = .;
23,7 → 24,7
unmapped_kdata_end = .;
}
.mapped (PA2KA(BOOT_OFFSET)+SIZEOF(.unmapped)): AT (SIZEOF(.unmapped)) {
.mapped (PA2KA(BOOT_OFFSET+BOOTSTRAP_OFFSET)+SIZEOF(.unmapped)): AT (BOOTSTRAP_OFFSET+SIZEOF(.unmapped)) {
ktext_start = .;
*(.text);
ktext_end = .;
33,7 → 34,7
*(.rodata*); /* string literals */
*(COMMON); /* global variables */
hardcoded_load_address = .;
LONG(PA2KA(BOOT_OFFSET));
LONG(PA2KA(BOOT_OFFSET+BOOTSTRAP_OFFSET));
hardcoded_ktext_size = .;
LONG((ktext_end - ktext_start) + (unmapped_ktext_end - unmapped_ktext_start));
hardcoded_kdata_size = .;
52,14 → 53,12
*(.note.GNU-stack);
*(.comment);
}
 
#ifdef CONFIG_SMP
_hardcoded_kernel_size = (ktext_end - ktext_start) + (unmapped_ktext_end - unmapped_ktext_start) + (kdata_end - kdata_start) + (unmapped_kdata_end - unmapped_kdata_start);
_hardcoded_unmapped_size = (unmapped_ktext_end - unmapped_ktext_start) + (unmapped_kdata_end - unmapped_kdata_start);
_hardcoded_unmapped_size = (unmapped_ktext_end - unmapped_ktext_start) + (unmapped_kdata_end - unmapped_kdata_start);
ap_boot = unmapped_ap_boot - BOOT_OFFSET + AP_BOOT_OFFSET;
ap_gdtr = unmapped_ap_gdtr - BOOT_OFFSET + AP_BOOT_OFFSET;
protected_ap_gdtr = PA2KA(ap_gdtr);
 
#endif /* CONFIG_SMP */
 
e820table_boot = KA2PA(e820table) - BOOT_OFFSET;
e820counter_boot = KA2PA(e820counter) - BOOT_OFFSET;
real_bootstrap_gdtr = PA2KA(real_bootstrap_gdtr_boot);
}
/kernel/trunk/arch/ia32/include/boot/boot.h
29,9 → 29,8
#ifndef __ia32_BOOT_H__
#define __ia32_BOOT_H__
 
#define BOOT_OFFSET 0x108000
#define AP_BOOT_OFFSET 0x8000
#define BOOT_STACK_SIZE 0x400
#define BOOTSTRAP_OFFSET 0x8000
#define BOOT_OFFSET 0x100000
 
#define MULTIBOOT_HEADER_MAGIC 0x1BADB002
#define MULTIBOOT_HEADER_FLAGS 0x00010003
/kernel/trunk/arch/ia32/include/pm.h
131,8 → 131,8
} __attribute__ ((packed));
 
extern struct ptr_16_32 gdtr;
extern struct ptr_16_32 bootstrap_gdtr;
extern struct ptr_16_32 protected_ap_gdtr;
extern struct ptr_16_32 real_bootstrap_gdtr;
extern struct ptr_16_32 protected_bootstrap_gdtr;
extern struct tss *tss_p;
 
extern struct descriptor gdt[];