Compare commits
2 Commits
86509e39c1
...
65b8c0ee67
Author | SHA1 | Date | |
---|---|---|---|
65b8c0ee67 | |||
2f942e1721 |
15
Cargo.toml
15
Cargo.toml
@ -91,17 +91,14 @@ unexpected_cfgs = { level = "allow", check-cfg = ['cfg(rust_analyzer)'] }
|
|||||||
[workspace.lints.clippy]
|
[workspace.lints.clippy]
|
||||||
derivable_impls = { level = "allow" }
|
derivable_impls = { level = "allow" }
|
||||||
|
|
||||||
# [profile.dev]
|
[profile.dev]
|
||||||
# opt-level = 1
|
opt-level = 1
|
||||||
# split-debuginfo = "packed"
|
# split-debuginfo = "packed"
|
||||||
# lto = "thin"
|
lto = "thin"
|
||||||
# panic = "abort"
|
panic = "abort"
|
||||||
|
|
||||||
[profile.test]
|
[profile.test]
|
||||||
split-debuginfo = "none"
|
split-debuginfo = "none"
|
||||||
|
|
||||||
# [profile.dev.package."*"]
|
[profile.dev.package."*"]
|
||||||
# opt-level = 3
|
opt-level = 3
|
||||||
|
|
||||||
# [profile.dev]
|
|
||||||
# opt-level = "s"
|
|
||||||
|
@ -208,10 +208,12 @@ impl<K: KernelTableManager, PA: PhysicalMemoryAllocator<Address = PhysicalAddres
|
|||||||
stack.push(mdscr_el1);
|
stack.push(mdscr_el1);
|
||||||
stack.push(context.stack_pointer);
|
stack.push(context.stack_pointer);
|
||||||
|
|
||||||
|
let ttbr0 = context.address_space | (context.asid << 48) | 1;
|
||||||
|
|
||||||
setup_common_context(
|
setup_common_context(
|
||||||
&mut stack,
|
&mut stack,
|
||||||
__aarch64_task_enter_user as _,
|
__aarch64_task_enter_user as _,
|
||||||
context.address_space,
|
ttbr0,
|
||||||
context.thread_pointer as _,
|
context.thread_pointer as _,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ use aarch64_cpu::registers::{DAIF, MPIDR_EL1, TPIDR_EL1};
|
|||||||
use alloc::{boxed::Box, sync::Arc, vec::Vec};
|
use alloc::{boxed::Box, sync::Arc, vec::Vec};
|
||||||
use device_api::interrupt::{LocalInterruptController, MessageInterruptController};
|
use device_api::interrupt::{LocalInterruptController, MessageInterruptController};
|
||||||
use kernel_arch_interface::{
|
use kernel_arch_interface::{
|
||||||
cpu::{CpuImpl, IpiQueue},
|
cpu::{CpuData, CpuImpl, IpiQueue},
|
||||||
guard::IrqGuard,
|
guard::IrqGuard,
|
||||||
task::Scheduler,
|
task::Scheduler,
|
||||||
util::OneTimeInit,
|
util::OneTimeInit,
|
||||||
@ -32,6 +32,8 @@ pub struct PerCpuData {
|
|||||||
pub gic: OneTimeInit<Arc<dyn GicInterface>>,
|
pub gic: OneTimeInit<Arc<dyn GicInterface>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl CpuData for PerCpuData {}
|
||||||
|
|
||||||
static IPI_QUEUES: OneTimeInit<Vec<IpiQueue<ArchitectureImpl>>> = OneTimeInit::new();
|
static IPI_QUEUES: OneTimeInit<Vec<IpiQueue<ArchitectureImpl>>> = OneTimeInit::new();
|
||||||
pub static CPU_COUNT: AtomicUsize = AtomicUsize::new(1);
|
pub static CPU_COUNT: AtomicUsize = AtomicUsize::new(1);
|
||||||
|
|
||||||
|
@ -83,8 +83,9 @@ impl<TA: TableAllocator> ProcessAddressSpaceManager<TA> for ProcessAddressSpaceI
|
|||||||
self.pop_l3_entry(address)
|
self.pop_l3_entry(address)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_address_with_asid(&self) -> u64 {
|
fn as_address_with_asid(&self) -> (u64, u64) {
|
||||||
unsafe { u64::from(self.l1.as_physical_address()) | ((self.asid as u64) << 48) | 1 }
|
let physical = unsafe { u64::from(self.l1.as_physical_address()) };
|
||||||
|
(physical, self.asid as u64)
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn clear(&mut self) {
|
unsafe fn clear(&mut self) {
|
||||||
|
@ -8,7 +8,7 @@ use core::ptr::null_mut;
|
|||||||
use alloc::vec::Vec;
|
use alloc::vec::Vec;
|
||||||
use device_api::interrupt::{LocalInterruptController, MessageInterruptController};
|
use device_api::interrupt::{LocalInterruptController, MessageInterruptController};
|
||||||
use kernel_arch_interface::{
|
use kernel_arch_interface::{
|
||||||
cpu::{CpuImpl, IpiQueue},
|
cpu::{CpuData, CpuImpl, IpiQueue},
|
||||||
task::Scheduler,
|
task::Scheduler,
|
||||||
Architecture,
|
Architecture,
|
||||||
};
|
};
|
||||||
@ -29,6 +29,8 @@ pub struct PerCpuData {
|
|||||||
pub enabled_features: CpuFeatures,
|
pub enabled_features: CpuFeatures,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl CpuData for PerCpuData {}
|
||||||
|
|
||||||
static mut CPU: *mut () = null_mut();
|
static mut CPU: *mut () = null_mut();
|
||||||
|
|
||||||
#[naked]
|
#[naked]
|
||||||
|
@ -68,8 +68,8 @@ impl<TA: TableAllocator> ProcessAddressSpaceManager<TA> for ProcessAddressSpaceI
|
|||||||
self.pop_l3_entry(address)
|
self.pop_l3_entry(address)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_address_with_asid(&self) -> u64 {
|
fn as_address_with_asid(&self) -> (u64, u64) {
|
||||||
unsafe { self.l0.as_physical_address().into_u64() }
|
(unsafe { self.l0.as_physical_address().into_u64() }, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,7 +12,7 @@ use core::{
|
|||||||
use alloc::{boxed::Box, vec::Vec};
|
use alloc::{boxed::Box, vec::Vec};
|
||||||
use device_api::interrupt::{LocalInterruptController, MessageInterruptController};
|
use device_api::interrupt::{LocalInterruptController, MessageInterruptController};
|
||||||
use kernel_arch_interface::{
|
use kernel_arch_interface::{
|
||||||
cpu::{CpuImpl, IpiQueue},
|
cpu::{CpuData, CpuImpl, IpiQueue},
|
||||||
task::Scheduler,
|
task::Scheduler,
|
||||||
util::OneTimeInit,
|
util::OneTimeInit,
|
||||||
Architecture,
|
Architecture,
|
||||||
@ -58,6 +58,8 @@ pub struct PerCpuData {
|
|||||||
pub enabled_features: CpuFeatures,
|
pub enabled_features: CpuFeatures,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl CpuData for PerCpuData {}
|
||||||
|
|
||||||
impl PerCpuData {
|
impl PerCpuData {
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn local_apic(&self) -> &dyn LocalApicInterface {
|
pub fn local_apic(&self) -> &dyn LocalApicInterface {
|
||||||
|
@ -71,9 +71,9 @@ impl<TA: TableAllocator> ProcessAddressSpaceManager<TA> for ProcessAddressSpaceI
|
|||||||
.ok_or(Error::InvalidMemoryOperation)
|
.ok_or(Error::InvalidMemoryOperation)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn as_address_with_asid(&self) -> u64 {
|
fn as_address_with_asid(&self) -> (u64, u64) {
|
||||||
// TODO x86-64 PCID/ASID?
|
// TODO x86-64 PCID/ASID?
|
||||||
unsafe { self.l0.as_physical_address().into_u64() }
|
(unsafe { self.l0.as_physical_address().into_u64() }, 0)
|
||||||
}
|
}
|
||||||
|
|
||||||
unsafe fn clear(&mut self) {
|
unsafe fn clear(&mut self) {
|
||||||
|
@ -10,7 +10,7 @@ use device_api::{
|
|||||||
};
|
};
|
||||||
use kernel_arch::{Architecture, ArchitectureImpl};
|
use kernel_arch::{Architecture, ArchitectureImpl};
|
||||||
use kernel_arch_i686::{gdt, mem::table::L3, PerCpuData};
|
use kernel_arch_i686::{gdt, mem::table::L3, PerCpuData};
|
||||||
use kernel_arch_x86::cpuid::{self, CpuFeatures, EcxFeatures, EdxFeatures};
|
use kernel_arch_x86::cpuid::{self, CpuFeatures, EcxFeatures, EdxFeatures, ExtEdxFeatures};
|
||||||
use libk::{
|
use libk::{
|
||||||
arch::Cpu,
|
arch::Cpu,
|
||||||
config, debug,
|
config, debug,
|
||||||
@ -95,10 +95,12 @@ impl I686 {
|
|||||||
CpuFeatures {
|
CpuFeatures {
|
||||||
ecx: EcxFeatures::SSE3 | EcxFeatures::XSAVE | EcxFeatures::OSXSAVE,
|
ecx: EcxFeatures::SSE3 | EcxFeatures::XSAVE | EcxFeatures::OSXSAVE,
|
||||||
edx: EdxFeatures::SSE2 | EdxFeatures::FXSR,
|
edx: EdxFeatures::SSE2 | EdxFeatures::FXSR,
|
||||||
|
ext_edx: ExtEdxFeatures::empty(),
|
||||||
},
|
},
|
||||||
CpuFeatures {
|
CpuFeatures {
|
||||||
ecx: EcxFeatures::empty(),
|
ecx: EcxFeatures::empty(),
|
||||||
edx: EdxFeatures::FPU | EdxFeatures::SSE | EdxFeatures::PSE,
|
edx: EdxFeatures::FPU | EdxFeatures::SSE | EdxFeatures::PSE,
|
||||||
|
ext_edx: ExtEdxFeatures::empty(),
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
let will_features = will_features.expect("Could not enable needed CPU features");
|
let will_features = will_features.expect("Could not enable needed CPU features");
|
||||||
|
@ -21,7 +21,6 @@ pub fn handle_interrupt() {
|
|||||||
sbi::sbi_set_timer(now.wrapping_add(frequency / TICK_RATE));
|
sbi::sbi_set_timer(now.wrapping_add(frequency / TICK_RATE));
|
||||||
|
|
||||||
if Cpu::local().is_bootstrap() {
|
if Cpu::local().is_bootstrap() {
|
||||||
let frequency = frequency * 1000;
|
|
||||||
let last = LAST_TICK.swap(now, Ordering::Release);
|
let last = LAST_TICK.swap(now, Ordering::Release);
|
||||||
if frequency != 0 {
|
if frequency != 0 {
|
||||||
if let Some(delta) = now.checked_sub(last) {
|
if let Some(delta) = now.checked_sub(last) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user