1
0
mirror of https://github.com/rcore-os/rCore.git synced 2024-11-23 00:16:17 +04:00

Fix SMP. Move cpu::init to asm.

This commit is contained in:
WangRunji 2018-06-17 01:41:43 +08:00
parent 4817f69acb
commit 60ed3a2ed4
4 changed files with 9 additions and 29 deletions

View File

@ -128,15 +128,15 @@ enable_paging:
or eax, 1 << 5
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
rdmsr
or eax, 1 << 8
or eax, 1 << 8 | 1 << 11
wrmsr
; enable paging in the cr0 register
; enable paging & write protect in the cr0 register
mov eax, cr0
or eax, 1 << 31
or eax, 1 << 31 | 1 << 16
mov cr0, eax
ret

View File

@ -85,15 +85,15 @@ enable_paging:
or eax, 1 << 5
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
rdmsr
or eax, 1 << 8
or eax, 1 << 8 | 1 << 11
wrmsr
; enable paging in the cr0 register
; enable paging & write protect in the cr0 register
mov eax, cr0
or eax, 1 << 31
or eax, 1 << 31 | 1 << 16
mov cr0, eax
ret

View File

@ -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
/// See: https://wiki.osdev.org/Shutdown
/// Must run qemu with `-device isa-debug-exit`

View File

@ -64,7 +64,6 @@ mod arch;
/// The entry point of Rust kernel
#[no_mangle]
pub extern "C" fn rust_main(multiboot_information_address: usize) -> ! {
arch::cpu::init();
arch::idt::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"))
});
// 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);
fs::load_sfs();
@ -123,7 +121,6 @@ pub extern "C" fn rust_main(multiboot_information_address: usize) -> ! {
/// The entry point for another processors
#[no_mangle]
pub extern "C" fn other_main() -> ! {
arch::cpu::init();
arch::gdt::init();
arch::idt::init();
arch::driver::apic::other_init();