Subversion Repositories HelenOS

Rev

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

Rev 4344 Rev 4345
Line 37... Line 37...
37
#include <arch/types.h>
37
#include <arch/types.h>
38
 
38
 
39
#include <config.h>
39
#include <config.h>
40
 
40
 
41
#include <proc/thread.h>
41
#include <proc/thread.h>
-
 
42
#include <genarch/multiboot/multiboot.h>
42
#include <genarch/drivers/legacy/ia32/io.h>
43
#include <genarch/drivers/legacy/ia32/io.h>
43
#include <genarch/drivers/ega/ega.h>
44
#include <genarch/drivers/ega/ega.h>
44
#include <arch/drivers/vesa.h>
45
#include <arch/drivers/vesa.h>
45
#include <genarch/kbd/i8042.h>
46
#include <genarch/kbd/i8042.h>
46
#include <arch/drivers/i8254.h>
47
#include <arch/drivers/i8254.h>
47
#include <arch/drivers/i8259.h>
48
#include <arch/drivers/i8259.h>
-
 
49
#include <arch/boot/boot.h>
48
 
50
 
49
#ifdef CONFIG_SMP
51
#ifdef CONFIG_SMP
50
#include <arch/smp/apic.h>
52
#include <arch/smp/apic.h>
51
#endif
53
#endif
52
 
54
 
Line 63... Line 65...
63
#include <console/console.h>
65
#include <console/console.h>
64
#include <ddi/irq.h>
66
#include <ddi/irq.h>
65
#include <ddi/device.h>
67
#include <ddi/device.h>
66
#include <sysinfo/sysinfo.h>
68
#include <sysinfo/sysinfo.h>
67
 
69
 
68
 
-
 
69
/** Disable I/O on non-privileged levels
70
/** Disable I/O on non-privileged levels
70
 *
71
 *
71
 * Clean IOPL(12,13) and NT(14) flags in EFLAGS register
72
 * Clean IOPL(12,13) and NT(14) flags in EFLAGS register
72
 */
73
 */
73
static void clean_IOPL_NT_flags(void)
74
static void clean_IOPL_NT_flags(void)
74
{
75
{
75
    asm (
76
    asm volatile (
76
        "pushfq\n"
77
        "pushfq\n"
77
        "pop %%rax\n"
78
        "pop %%rax\n"
78
        "and $~(0x7000), %%rax\n"
79
        "and $~(0x7000), %%rax\n"
79
        "pushq %%rax\n"
80
        "pushq %%rax\n"
80
        "popfq\n"
81
        "popfq\n"
81
        :
-
 
82
        :
-
 
83
        : "%rax"
82
        ::: "%rax"
84
    );
83
    );
85
}
84
}
86
 
85
 
87
/** Disable alignment check
86
/** Disable alignment check
88
 *
87
 *
89
 * Clean AM(18) flag in CR0 register
88
 * Clean AM(18) flag in CR0 register
90
 */
89
 */
91
static void clean_AM_flag(void)
90
static void clean_AM_flag(void)
92
{
91
{
93
    asm (
92
    asm volatile (
94
        "mov %%cr0, %%rax\n"
93
        "mov %%cr0, %%rax\n"
95
        "and $~(0x40000), %%rax\n"
94
        "and $~(0x40000), %%rax\n"
96
        "mov %%rax, %%cr0\n"
95
        "mov %%rax, %%cr0\n"
97
        :
-
 
98
        :
-
 
99
        : "%rax"
96
        ::: "%rax"
100
    );
97
    );
101
}
98
}
102
 
99
 
-
 
100
/** Perform amd64-specific initialization before main_bsp() is called.
-
 
101
 *
-
 
102
 * @param signature Should contain the multiboot signature.
-
 
103
 * @param mi        Pointer to the multiboot information structure.
-
 
104
 */
-
 
105
void arch_pre_main(uint32_t signature, const multiboot_info_t *mi)
-
 
106
{
-
 
107
    /* Parse multiboot information obtained from the bootloader. */
-
 
108
    multiboot_info_parse(signature, mi);
-
 
109
   
-
 
110
#ifdef CONFIG_SMP
-
 
111
    /* Copy AP bootstrap routines below 1 MB. */
-
 
112
    memcpy((void *) AP_BOOT_OFFSET, (void *) BOOT_OFFSET,
-
 
113
        (size_t) &_hardcoded_unmapped_size);
-
 
114
#endif
-
 
115
}
-
 
116
 
103
void arch_pre_mm_init(void)
117
void arch_pre_mm_init(void)
104
{
118
{
105
    /* Enable no-execute pages */
119
    /* Enable no-execute pages */
106
    set_efer_flag(AMD_NXE_FLAG);
120
    set_efer_flag(AMD_NXE_FLAG);
107
    /* Enable FPU */
121
    /* Enable FPU */
Line 183... Line 197...
183
     * self-sufficient.
197
     * self-sufficient.
184
     */
198
     */
185
    sysinfo_set_item_val("kbd", NULL, true);
199
    sysinfo_set_item_val("kbd", NULL, true);
186
    sysinfo_set_item_val("kbd.devno", NULL, devno);
200
    sysinfo_set_item_val("kbd.devno", NULL, devno);
187
    sysinfo_set_item_val("kbd.inr", NULL, IRQ_KBD);
201
    sysinfo_set_item_val("kbd.inr", NULL, IRQ_KBD);
-
 
202
    sysinfo_set_item_val("kbd.address.physical", NULL,
-
 
203
        (uintptr_t) I8042_BASE);
-
 
204
    sysinfo_set_item_val("kbd.address.kernel", NULL,
-
 
205
        (uintptr_t) I8042_BASE);
188
}
206
}
189
 
207
 
190
void calibrate_delay_loop(void)
208
void calibrate_delay_loop(void)
191
{
209
{
192
    i8254_calibrate_delay_loop();
210
    i8254_calibrate_delay_loop();