Changeset 4fb6bf36 in mainline


Ignore:
Timestamp:
2008-01-11T17:49:35Z (16 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0ee4322
Parents:
eb27ce5a
Message:

move cpuid tests from amd64.c to boot.S

Location:
kernel/arch/amd64
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • kernel/arch/amd64/include/cpuid.h

    reb27ce5a r4fb6bf36  
    3838#define AMD_CPUID_EXTENDED   0x80000001
    3939#define AMD_EXT_NOEXECUTE    20
     40#define AMD_EXT_LONG_MODE    29
    4041
    41 #define INTEL_CPUID_STANDARD 0x1
     42#define INTEL_CPUID_STANDARD 0x00000001
     43#define INTEL_CPUID_EXTENDED 0x80000000
    4244#define INTEL_SSE2           26
    4345#define INTEL_FXSAVE         24
  • kernel/arch/amd64/src/amd64.c

    reb27ce5a r4fb6bf36  
    104104void arch_pre_mm_init(void)
    105105{
    106         cpu_info_t cpuid_s;
    107 
    108         cpuid(AMD_CPUID_EXTENDED,&cpuid_s);
    109         if (! (cpuid_s.cpuid_edx & (1<<AMD_EXT_NOEXECUTE)))
    110                 panic("Processor does not support No-execute pages.\n");
    111 
    112         cpuid(INTEL_CPUID_STANDARD,&cpuid_s);
    113         if (! (cpuid_s.cpuid_edx & (1<<INTEL_FXSAVE)))
    114                 panic("Processor does not support FXSAVE/FXRESTORE.\n");
    115        
    116         if (! (cpuid_s.cpuid_edx & (1<<INTEL_SSE2)))
    117                 panic("Processor does not support SSE2 instructions.\n");
    118 
    119         /* Enable No-execute pages */
     106        /* Enable no-execute pages */
    120107        set_efer_flag(AMD_NXE_FLAG);
    121108        /* Enable FPU */
     
    124111        /* Initialize segmentation */
    125112        pm_init();
    126 
    127         /* Disable I/O on nonprivileged levels
    128          * clear the NT(nested-thread) flag
     113       
     114        /* Disable I/O on nonprivileged levels
     115         * clear the NT (nested-thread) flag
    129116         */
    130117        clean_IOPL_NT_flags();
  • kernel/arch/amd64/src/boot/boot.S

    reb27ce5a r4fb6bf36  
    1 #
     1
    22# Copyright (c) 2005 Ondrej Palkovsky
    33# Copyright (c) 2006 Martin Decky
     
    7676        # the Default operand size must not be 1 when entering long mode
    7777       
    78         movl $0x80000000, %eax 
     78        movl $(INTEL_CPUID_EXTENDED), %eax 
    7979        cpuid
    80         cmp $0x80000000, %eax                                           # any function > 80000000h?
    81         jbe long_mode_unsupported
    82         movl $(AMD_CPUID_EXTENDED), %eax                        # Extended function code 80000001
     80        cmp $(INTEL_CPUID_EXTENDED), %eax
     81        ja extended_cpuid_supported
     82               
     83                movl $extended_cpuid_msg, %esi
     84                jmp error_halt
     85       
     86        extended_cpuid_supported:
     87       
     88        movl $(AMD_CPUID_EXTENDED), %eax
    8389        cpuid
    84         bt $29, %edx                                                            # Test if long mode is supported.
     90        bt $(AMD_EXT_LONG_MODE), %edx
    8591        jc long_mode_supported
    86 
    87         long_mode_unsupported:
     92               
    8893                movl $long_mode_msg, %esi
    8994                jmp error_halt
    90        
     95
    9196        long_mode_supported:
     97       
     98        bt $(AMD_EXT_NOEXECUTE), %edx
     99        jc noexecute_supported
     100       
     101                movl $noexecute_msg, %esi
     102                jmp error_halt
     103       
     104        noexecute_supported:
     105       
     106        movl $(INTEL_CPUID_STANDARD), %eax
     107        cpuid
     108        bt $(INTEL_FXSAVE), %edx
     109        jc fx_supported
     110       
     111                movl $fx_msg, %esi
     112                jmp error_halt
     113       
     114        fx_supported:
     115       
     116        bt $(INTEL_SSE2), %edx
     117        jc sse2_supported
     118       
     119                movl $sse2_msg, %esi
     120                jmp error_halt
     121       
     122        sse2_supported:
    92123       
    93124#ifdef CONFIG_FB
     
    112143#endif 
    113144       
    114         # Enable 64-bit page transaltion entries - CR4.PAE = 1.
     145        # Enable 64-bit page translation entries - CR4.PAE = 1.
    115146        # Paging is not enabled until after long mode is enabled
    116147       
     
    128159        movl $EFER_MSR_NUM, %ecx        # EFER MSR number
    129160        rdmsr                                           # Read EFER
    130         btsl $AMD_LME_FLAG, %eax        # Set LME=1
     161        btsl $AMD_LME_FLAG, %eax        # Set LME = 1
    131162        wrmsr                                           # Write EFER
    132163       
    133         # Enable paging to activate long mode (set CR0.PG=1)
     164        # Enable paging to activate long mode (set CR0.PG = 1)
    134165       
    135166        movl %cr0, %eax
     
    636667        .long 0
    637668
     669extended_cpuid_msg:
     670        .asciz "Extended CPUID not supported. System halted."
    638671long_mode_msg:
    639672        .asciz "64 bit long mode not supported. System halted."
     673noexecute_msg:
     674        .asciz "No-execute pages not supported. System halted."
     675fx_msg:
     676        .asciz "FXSAVE/FXRESTORE instructions not supported. System halted."
     677sse2_msg:
     678        .asciz "SSE2 instructions not supported. System halted."
Note: See TracChangeset for help on using the changeset viewer.