Subversion Repositories HelenOS

Rev

Rev 576 | Rev 803 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 576 Rev 799
Line 44... Line 44...
44
#include <arch/cpuid.h>
44
#include <arch/cpuid.h>
45
#include <genarch/acpi/acpi.h>
45
#include <genarch/acpi/acpi.h>
46
#include <panic.h>
46
#include <panic.h>
47
#include <interrupt.h>
47
#include <interrupt.h>
48
 
48
 
-
 
49
/** Disable I/O on non-privileged levels
-
 
50
 *
-
 
51
 * Clean IOPL(12,13) and NT(14) flags in EFLAGS register
-
 
52
 */
-
 
53
static void clean_IOPL_NT_flags(void)
-
 
54
{
-
 
55
    asm
-
 
56
    (
-
 
57
        "pushfq;"
-
 
58
        "pop %%rax;"
-
 
59
        "and $~(0x7000),%%rax;"
-
 
60
        "pushq %%rax;"
-
 
61
        "popfq;"
-
 
62
        :
-
 
63
        :
-
 
64
        :"%rax"
-
 
65
    );
-
 
66
}
-
 
67
 
-
 
68
/** Disable alignment check
-
 
69
 *
-
 
70
 * Clean AM(18) flag in CR0 register
-
 
71
 */
-
 
72
static void clean_AM_flag(void)
-
 
73
{
-
 
74
    asm
-
 
75
    (
-
 
76
        "mov %%cr0,%%rax;"
-
 
77
        "and $~(0x40000),%%rax;"
-
 
78
        "mov %%rax,%%cr0;"
-
 
79
        :
-
 
80
        :
-
 
81
        :"%rax"
-
 
82
    );
-
 
83
}
-
 
84
 
49
void arch_pre_mm_init(void)
85
void arch_pre_mm_init(void)
50
{
86
{
51
    struct cpu_info cpuid_s;
87
    struct cpu_info cpuid_s;
52
 
88
 
53
    cpuid(AMD_CPUID_EXTENDED,&cpuid_s);
89
    cpuid(AMD_CPUID_EXTENDED,&cpuid_s);
Line 61... Line 97...
61
    if (! (cpuid_s.cpuid_edx & (1<<INTEL_SSE2)))
97
    if (! (cpuid_s.cpuid_edx & (1<<INTEL_SSE2)))
62
        panic("Processor does not support SSE2 instructions.\n");
98
        panic("Processor does not support SSE2 instructions.\n");
63
 
99
 
64
    /* Enable No-execute pages */
100
    /* Enable No-execute pages */
65
    set_efer_flag(AMD_NXE_FLAG);
101
    set_efer_flag(AMD_NXE_FLAG);
-
 
102
    /* Enable SYSCALL/SYSRET */
-
 
103
    set_efer_flag(AMD_SCE_FLAG);
66
    /* Enable FPU */
104
    /* Enable FPU */
67
    cpu_setup_fpu();
105
    cpu_setup_fpu();
68
 
-
 
-
 
106
    /* Initialize segmentation */
69
    pm_init();
107
    pm_init();
70
 
108
 
-
 
109
        /* Disable I/O on nonprivileged levels
-
 
110
     * clear the NT(nested-thread) flag
-
 
111
     */
-
 
112
    clean_IOPL_NT_flags();
-
 
113
    /* Disable alignment check */
-
 
114
    clean_AM_flag();
-
 
115
   
-
 
116
 
71
    if (config.cpu_active == 1) {
117
    if (config.cpu_active == 1) {
72
        bios_init();
118
        bios_init();
73
        i8259_init();   /* PIC */
119
        i8259_init();   /* PIC */
74
        i8254_init();   /* hard clock */
120
        i8254_init();   /* hard clock */
75
 
121
 
76
        exc_register(VECTOR_SYSCALL, "syscall", syscall);
-
 
77
       
-
 
78
        #ifdef CONFIG_SMP
122
        #ifdef CONFIG_SMP
79
        exc_register(VECTOR_TLB_SHOOTDOWN_IPI, "tlb_shootdown",
123
        exc_register(VECTOR_TLB_SHOOTDOWN_IPI, "tlb_shootdown",
80
                 tlb_shootdown_ipi);
124
                 tlb_shootdown_ipi);
81
        exc_register(VECTOR_WAKEUP_IPI, "wakeup_ipi", wakeup_ipi);
125
        exc_register(VECTOR_WAKEUP_IPI, "wakeup_ipi", wakeup_ipi);
82
        #endif /* CONFIG_SMP */
126
        #endif /* CONFIG_SMP */