Changeset f6297e0 in mainline for arch/ia32/src


Ignore:
Timestamp:
2005-09-03T15:45:14Z (20 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ab08b42
Parents:
2f08a55d
Message:

proper way of initializing GDT during boot on IA-32, fixes the nasty hack
SMP might be still broken

Location:
arch/ia32/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • arch/ia32/src/boot/boot.S

    r2f08a55d rf6297e0  
    3232.global kernel_image_start
    3333
     34KTEXT=8
     35KDATA=16
     36
    3437.code16
    3538#
     
    4548        xorw %ax, %ax
    4649        movw %ax, %ds
    47         movw %ax, %ss                   # initialize stack segment register
    48         movl $0x7c00, %esp              # initialize stack pointer
     50        movw %ax, %ss                                                   # initialize stack segment register
     51        movl $BOOTSTRAP_OFFSET - 0x400, %esp    # initialize stack pointer
    4952       
    5053        call memmap_arch_init
    5154       
    52         lgdt gdtr                       # initialize Global Descriptor Table register
     55        lgdt bsp_bootstrap_gdtr                                 # initialize Global Descriptor Table register
    5356       
    5457        movl %cr0, %eax
    5558        orl $0x1, %eax
    56         movl %eax, %cr0                 # switch to protected mode
     59        movl %eax, %cr0                                                 # switch to protected mode
    5760       
    58         jmpl $8, $boot_image_start
     61        jmpl $KTEXT, $boot_image_start
    5962       
    6063.code32
     
    7174       
    7275boot_image_start:
    73         movw $16, %ax
     76        movw $KDATA, %ax
    7477        movw %ax, %es
    7578        movw %ax, %gs
     
    8588        outb %al, $0x60
    8689       
    87         movl $0x8000, %esi
    88         movl $0x8000 + BOOT_OFFSET, %edi
     90        movl $BOOTSTRAP_OFFSET, %esi
     91        movl $BOOTSTRAP_OFFSET + BOOT_OFFSET, %edi
    8992        movl $_hardcoded_kernel_size, %ecx
    9093        cld
     
    9497       
    9598multiboot_image_start:
    96         movl $0x7c00, %esp              # initialize stack pointer
     99        movl BOOTSTRAP_OFFSET - 0x400, %esp             # initialize stack pointer
    97100       
    98         lgdt gdtr
     101        lgdt gdtr                                                               # initialize Global Descriptor Table register
    99102
    100         movw $16, %ax
     103        movw $KDATA, %ax
    101104        movw %ax, %es
    102105        movw %ax, %gs
    103106        movw %ax, %fs
    104         movw %ax, %ds                   # kernel data + stack
     107        movw %ax, %ds                                                   # kernel data + stack
    105108        movw %ax, %ss
    106109       
    107         call map_kernel                 # map kernel and turn paging on
     110        call map_kernel                                                 # map kernel and turn paging on
    108111       
    109112protected:
    110         call main_bsp                   # never returns
     113        call main_bsp           # never returns
    111114
    112115        cli
  • arch/ia32/src/ia32.c

    r2f08a55d rf6297e0  
    5858        if (config.cpu_active == 1) {
    5959                bios_init();
    60                 i8042_init();   /* a20 bit */
     60                i8042_init();   /* keyboard controller */
    6161                i8259_init();   /* PIC */
    6262                i8254_init();   /* hard clock */
  • arch/ia32/src/mm/frame.c

    r2f08a55d rf6297e0  
    3131#include <mm/vm.h>
    3232#include <config.h>
     33#include <arch/boot/boot.h>
    3334#include <arch/boot/memmap.h>
    3435
    35 #include <print.h>
     36size_t hardcoded_unmapped_ktext_size = 0;
     37size_t hardcoded_unmapped_kdata_size = 0;
    3638
    3739void frame_arch_init(void)
     
    4042       
    4143        if (config.cpu_active == 1) {
     44                /* Reserve the NULL frame */
    4245                frame_not_free(0x0);
    43 
     46               
     47                /* Reserve well-known memory regions */
    4448                frame_region_not_free(0xa0000,0xff000);
    4549                frame_region_not_free(0xfec00000,0xffffffff);
    4650               
    47                 /* This is a nasty hack, which should be fixed soon */
    48                 frame_region_not_free(0x0, 0xfffff);
     51                /* Reserve real mode bootstrap memory */
     52                frame_region_not_free(BOOTSTRAP_OFFSET, BOOTSTRAP_OFFSET + hardcoded_unmapped_ktext_size + hardcoded_unmapped_kdata_size);
    4953               
    5054                for (i=e820counter;i>0;i--) {
  • arch/ia32/src/pm.c

    r2f08a55d rf6297e0  
    7171
    7272/* gdtr is changed by kmp before next CPU is initialized */
    73 struct ptr_16_32 gdtr __attribute__ ((section ("K_DATA_START"))) = { .limit = sizeof(gdt), .base = KA2PA((__address) gdt - BOOT_OFFSET) };
     73struct ptr_16_32 bsp_bootstrap_gdtr __attribute__ ((section ("K_DATA_START"))) = { .limit = sizeof(gdt), .base = KA2PA((__address) gdt - BOOT_OFFSET) };
     74struct ptr_16_32 ap_bootstrap_gdtr __attribute__ ((section ("K_DATA_START"))) = { .limit = sizeof(gdt), .base = KA2PA((__address) gdt) };
     75struct ptr_16_32 gdtr = { .limit = sizeof(gdt), .base = KA2PA((__address) gdt) };
    7476struct ptr_16_32 idtr __attribute__ ((section ("K_DATA_START"))) = { .limit = sizeof(idt), .base = KA2PA((__address) idt) };
    7577
     
    171173         * Update addresses in GDT and IDT to their virtual counterparts.
    172174         */
    173         gdtr.base = KA2PA(gdtr.base);
     175        gdtr.base = (__address) gdt;
    174176        idtr.base = (__address) idt;
    175177        __asm__ volatile ("lgdt %0\n" : : "m" (gdtr));
  • arch/ia32/src/smp/ap.S

    r2f08a55d rf6297e0  
    4848.code16
    4949        cli
    50         xorw %ax,%ax
    51         movw %ax,%ds
     50        xorw %ax, %ax
     51        movw %ax, %ds
    5252
    53         lgdt gdtr                       # initialize Global Descriptor Table register
     53        lgdt ap_bootstrap_gdtr  # initialize Global Descriptor Table register
    5454       
    55         movl %cr0,%eax
    56         orl $1,%eax
    57         movl %eax,%cr0                  # switch to protected mode
    58         jmpl $KTEXT,$jump_to_kernel
     55        movl %cr0, %eax
     56        orl $1, %eax
     57        movl %eax, %cr0                 # switch to protected mode
     58        jmpl $KTEXT, $jump_to_kernel
     59       
    5960jump_to_kernel:
    6061.code32
    61         movw $KDATA,%ax
    62         movw %ax,%ds
    63         movw %ax,%es
    64         movw %ax,%ss
    65         movl $(ctx-0x80000000),%eax     # KA2PA((__address) &ctx)
    66         movl (%eax),%esp
    67         subl $0x80000000,%esp           # KA2PA(ctx.sp)
     62        movw $KDATA, %ax
     63        movw %ax, %ds
     64        movw %ax, %es
     65        movw %ax, %ss
     66        movl $(ctx-0x80000000), %eax    # KA2PA((__address) &ctx)
     67        movl (%eax), %esp
     68        subl $0x80000000, %esp                  # KA2PA(ctx.sp)
    6869
    69         call map_kernel                 # map kernel and turn paging on
     70        call map_kernel                                 # map kernel and turn paging on
     71       
     72        movb $0xd1, %al                                 # enable A20 using the keyboard controller
     73        outb %al, $0x64
     74        movb $0xdf, %al
     75        outb %al, $0x60
    7076
    71         jmpl $KTEXT,$main_ap
     77        jmpl $KTEXT, $main_ap
    7278
    7379#endif /* __SMP__ */
Note: See TracChangeset for help on using the changeset viewer.