Fix SMP. Move cpu::init to asm.

master
WangRunji 7 years ago
parent 4817f69acb
commit 60ed3a2ed4

@ -128,15 +128,15 @@ enable_paging:
or eax, 1 << 5 or eax, 1 << 5
mov cr4, eax mov cr4, eax
; set the long mode bit in the EFER MSR (model specific register) ; set the long mode bit & no execute bit in the EFER MSR (model specific register)
mov ecx, 0xC0000080 mov ecx, 0xC0000080
rdmsr rdmsr
or eax, 1 << 8 or eax, 1 << 8 | 1 << 11
wrmsr wrmsr
; enable paging in the cr0 register ; enable paging & write protect in the cr0 register
mov eax, cr0 mov eax, cr0
or eax, 1 << 31 or eax, 1 << 31 | 1 << 16
mov cr0, eax mov cr0, eax
ret ret

@ -85,15 +85,15 @@ enable_paging:
or eax, 1 << 5 or eax, 1 << 5
mov cr4, eax mov cr4, eax
; set the long mode bit in the EFER MSR (model specific register) ; set the long mode bit & no execute bit in the EFER MSR (model specific register)
mov ecx, 0xC0000080 mov ecx, 0xC0000080
rdmsr rdmsr
or eax, 1 << 8 or eax, 1 << 8 | 1 << 11
wrmsr wrmsr
; enable paging in the cr0 register ; enable paging & write protect in the cr0 register
mov eax, cr0 mov eax, cr0
or eax, 1 << 31 or eax, 1 << 31 | 1 << 16
mov cr0, eax mov cr0, eax
ret ret

@ -1,20 +1,3 @@
pub fn init() {
enable_nxe_bit();
enable_write_protect_bit();
}
/// Enable 'No-Execute' bit in page entry
pub fn enable_nxe_bit() {
use x86_64::registers::model_specific::*;
unsafe { Efer::update(|flags| flags.insert(EferFlags::NO_EXECUTE_ENABLE)); }
}
/// Enable write protection in kernel mode
pub fn enable_write_protect_bit() {
use x86_64::registers::control::*;
unsafe { Cr0::update(|flags| flags.insert(Cr0Flags::WRITE_PROTECT)); }
}
/// Exit qemu /// Exit qemu
/// See: https://wiki.osdev.org/Shutdown /// See: https://wiki.osdev.org/Shutdown
/// Must run qemu with `-device isa-debug-exit` /// Must run qemu with `-device isa-debug-exit`

@ -64,7 +64,6 @@ mod arch;
/// The entry point of Rust kernel /// The entry point of Rust kernel
#[no_mangle] #[no_mangle]
pub extern "C" fn rust_main(multiboot_information_address: usize) -> ! { pub extern "C" fn rust_main(multiboot_information_address: usize) -> ! {
arch::cpu::init();
arch::idt::init(); arch::idt::init();
io::init(); io::init();
@ -88,8 +87,7 @@ pub extern "C" fn rust_main(multiboot_information_address: usize) -> ! {
kernel_memory.push(MemoryArea::new_identity(addr, addr + count * 0x1000, MemoryAttr::default(), "acpi")) kernel_memory.push(MemoryArea::new_identity(addr, addr + count * 0x1000, MemoryAttr::default(), "acpi"))
}); });
// FIXME: page fault in SMP arch::smp::start_other_cores(&acpi, &mut kernel_memory);
// arch::smp::start_other_cores(&acpi, &mut kernel_memory);
process::init(kernel_memory); process::init(kernel_memory);
fs::load_sfs(); fs::load_sfs();
@ -123,7 +121,6 @@ pub extern "C" fn rust_main(multiboot_information_address: usize) -> ! {
/// The entry point for another processors /// The entry point for another processors
#[no_mangle] #[no_mangle]
pub extern "C" fn other_main() -> ! { pub extern "C" fn other_main() -> ! {
arch::cpu::init();
arch::gdt::init(); arch::gdt::init();
arch::idt::init(); arch::idt::init();
arch::driver::apic::other_init(); arch::driver::apic::other_init();

Loading…
Cancel
Save