Changeset 42edee68 in mainline


Ignore:
Timestamp:
2006-01-08T19:33:17Z (19 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0c0410b
Parents:
46d26ee
Message:

AMD64 SMP boots again

Location:
arch/amd64
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • arch/amd64/_link.ld.in

    r46d26ee r42edee68  
    5353                kdata_end = .;
    5454        }
     55       
     56#ifdef CONFIG_SMP       
     57       
     58        _hardcoded_unmapped_size = (unmapped_ktext_end - unmapped_ktext_start) + (unmapped_kdata_end - unmapped_kdata_start);
     59        ap_boot = unmapped_ap_boot - BOOT_OFFSET + AP_BOOT_OFFSET;
     60        ap_gdtr = unmapped_ap_gdtr - BOOT_OFFSET + AP_BOOT_OFFSET;
     61        protected_ap_gdtr = PA2KA(ap_gdtr);
     62
     63#endif /* CONFIG_SMP */
     64
    5565}
  • arch/amd64/include/pm.h

    r46d26ee r42edee68  
    146146
    147147extern struct ptr_16_64 gdtr;
    148 extern struct ptr_16_32 real_bootstrap_gdtr;
    149 extern struct ptr_16_32 protected_bootstrap_gdtr;
     148extern struct ptr_16_32 bootstrap_gdtr;
     149extern struct ptr_16_32 protected_ap_gdtr;
    150150
    151151extern void pm_init(void);
  • arch/amd64/src/boot/boot.S

    r46d26ee r42edee68  
    11#
    22# Copyright (C) 2005 Ondrej Palkovsky
     3# Copyright (C) 2006 Martin Decky
    34# All rights reserved.
    45#
     
    3839       
    3940.section K_TEXT_START, "ax"
    40 # .code16
    41 # .global kernel_image_start
    42 # .global multiboot_image_start
    43 # kernel_image_start:
    44 
    45 #       movl $0x80000000, %eax 
    46 #       cpuid
    47 #       cmp $0x80000000, %eax   # any function > 80000000h?
    48 #       jbe no_long_mode
    49 #       movl $(AMD_CPUID_EXTENDED), %eax # Extended function code 80000001
    50 #       cpuid
    51 #       bt $29, %edx            # Test if long mode is supported.
    52 #       jnc no_long_mode
    53 #
    54 #
    55 # no_long_mode:
    56 # 1:
    57 #       jmp 1b
    58 #       
     41
    5942.code32
    6043.align 4
     
    9073        # the Default operand size must not be 1 when entering long mode
    9174       
     75        movl $0x80000000, %eax 
     76        cpuid
     77        cmp $0x80000000, %eax                                           # any function > 80000000h?
     78        jbe long_mode_unsupported
     79        movl $(AMD_CPUID_EXTENDED), %eax                        # Extended function code 80000001
     80        cpuid
     81        bt $29, %edx                                                            # Test if long mode is supported.
     82        jc long_mode_supported
     83
     84        long_mode_unsupported:
     85                cli
     86                hlt
     87       
     88        long_mode_supported:
     89       
    9290        # Enable 64-bit page transaltion entries - CR4.PAE = 1.
    9391        # Paging is not enabled until after long mode is enabled
     
    218216               
    219217        invalid_boot:
     218       
     219#ifdef CONFIG_SMP
     220       
     221        # copy AP bootstrap routines below 1 MB
     222       
     223        movq $BOOT_OFFSET, %rsi
     224        movq $AP_BOOT_OFFSET, %rdi
     225        movq $_hardcoded_unmapped_size, %rcx
     226        cld
     227        rep movsb
     228       
     229#endif
    220230       
    221231        call main_bsp   # never returns
  • arch/amd64/src/smp/ap.S

    r46d26ee r42edee68  
    11#
    22# Copyright (C) 2001-2004 Jakub Jermar
     3# Copyright (C) 2005-2006 Martin Decky
    34# All rights reserved.
    45#
     
    3233
    3334#include <arch/boot/boot.h>
     35#include <arch/boot/memmap.h>
     36#include <arch/mm/page.h>
    3437#include <arch/pm.h>
    3538#include <arch/cpu.h>
    3639#include <arch/cpuid.h>
    37 #include <arch/mm/page.h>
    38        
    39 .section K_TEXT_START_2, "ax"
     40
     41.section K_TEXT_START, "ax"
    4042
    4143#ifdef CONFIG_SMP
    4244
    43 .global ap_boot
     45.global unmapped_ap_boot
    4446
    4547# This piece of code is real-mode and is meant to be alligned at 4K boundary.
     
    4850
    4951.align 4096
    50 ap_boot:
     52unmapped_ap_boot:
    5153.code16
    5254        cli
     
    5456        movw %ax, %ds
    5557
    56         lgdt real_bootstrap_gdtr_boot   # initialize Global Descriptor Table register
     58        lgdt ap_gdtr            # initialize Global Descriptor Table register
    5759       
    5860        movl %cr0, %eax
    5961        orl $1, %eax
    60         movl %eax, %cr0                 # switch to protected mode
     62        movl %eax, %cr0                         # switch to protected mode
     63        jmpl $gdtselector(KTEXT32_DES), $jump_to_kernel - BOOT_OFFSET + AP_BOOT_OFFSET
    6164       
    62         jmpl $gdtselector(KTEXT32_DES), $now_in_prot
    63 
    64 .code32
    65 now_in_prot:
     65jump_to_kernel:
     66.code32
    6667        movw $gdtselector(KDATA_DES), %ax
    6768        movw %ax, %ds
     69        movw %ax, %es
    6870        movw %ax, %ss
    6971       
    70 
    7172        # Enable 64-bit page transaltion entries - CR4.PAE = 1.
    7273        # Paging is not enabled until after long mode is enabled
     74       
    7375        movl %cr4, %eax
    7476        btsl $5, %eax
    7577        movl %eax, %cr4
    7678
    77         # Set up NEW paging tables, that are
    78         # already moved BOOT_OFFSET up
    79         leal ptl_0+BOOT_OFFSET, %eax
     79        leal ptl_0, %eax
    8080        movl %eax, %cr3
    8181       
     
    9292       
    9393        # At this point we are in compatibility mode
    94         jmpl $gdtselector(KTEXT_DES), $start64
     94        jmpl $gdtselector(KTEXT_DES), $start64 - BOOT_OFFSET + AP_BOOT_OFFSET
    9595
    9696.code64
    9797start64:
    9898        movq (ctx), %rsp
    99         call main_ap   # never returns
    100        
    101        
     99        call main_ap - AP_BOOT_OFFSET + BOOT_OFFSET   # never returns
     100
    102101#endif /* CONFIG_SMP */
     102
     103.section K_DATA_START, "ax"
     104
     105#ifdef CONFIG_SMP
     106
     107.global unmapped_ap_gdtr
     108
     109unmapped_ap_gdtr:
     110        .word 0
     111        .long 0
     112
     113#endif /* CONFIG_SMP */
Note: See TracChangeset for help on using the changeset viewer.