refactor: fix warnings/fix incorrect EarlyMapping::map
This commit is contained in:
parent
fbb804f14f
commit
a530a34a09
@ -28,7 +28,6 @@ use crate::{
|
|||||||
PhysicalAddress,
|
PhysicalAddress,
|
||||||
},
|
},
|
||||||
sync::IrqSafeSpinlock,
|
sync::IrqSafeSpinlock,
|
||||||
util,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::intrinsics;
|
use super::intrinsics;
|
||||||
@ -180,8 +179,10 @@ impl acpi_system::Handler for AcpiHandlerImpl {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn stall(duration: Duration) {
|
fn stall(_duration: Duration) {
|
||||||
util::polling_sleep(duration).ok();
|
// TODO polling_sleep is not yet implemented properly
|
||||||
|
todo!()
|
||||||
|
// util::polling_sleep(duration).ok();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -307,8 +308,9 @@ impl aml::Handler for AcpiHandlerImpl {
|
|||||||
|
|
||||||
fn write_ec_u8(&self, _address: u64, _value: u8) {}
|
fn write_ec_u8(&self, _address: u64, _value: u8) {}
|
||||||
|
|
||||||
fn sleep(&self, duration: Duration) {
|
fn sleep(&self, _duration: Duration) {
|
||||||
util::polling_sleep(duration).unwrap();
|
todo!()
|
||||||
|
// util::polling_sleep(duration).unwrap();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -335,7 +337,9 @@ impl AcpiHandler for AcpiHandlerImpl {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Initializes ACPI management
|
/// Initializes ACPI management
|
||||||
|
#[allow(unused)]
|
||||||
pub fn init_acpi(tables: &'static AcpiTables<AcpiHandlerImpl>) -> Result<(), Error> {
|
pub fn init_acpi(tables: &'static AcpiTables<AcpiHandlerImpl>) -> Result<(), Error> {
|
||||||
|
// TODO currently broken for real HW
|
||||||
let mut system = AcpiSystem::new(tables, Box::new(AcpiHandlerImpl)).unwrap();
|
let mut system = AcpiSystem::new(tables, Box::new(AcpiHandlerImpl)).unwrap();
|
||||||
|
|
||||||
system.initialize(AcpiInterruptMethod::Apic).unwrap();
|
system.initialize(AcpiInterruptMethod::Apic).unwrap();
|
||||||
|
@ -1,24 +1,21 @@
|
|||||||
//! x86-64 boot and entry functions
|
//! x86-64 boot and entry functions
|
||||||
use core::{arch::global_asm, sync::atomic::Ordering};
|
use core::{arch::global_asm, sync::atomic::Ordering};
|
||||||
|
|
||||||
use tock_registers::interfaces::{ReadWriteable, Writeable};
|
use tock_registers::interfaces::Writeable;
|
||||||
use yboot_proto::{
|
use yboot_proto::{
|
||||||
v1::{FramebufferOption, MemoryMap},
|
v1::{FramebufferOption, MemoryMap},
|
||||||
LoadProtocolHeader, LoadProtocolV1, KERNEL_MAGIC, LOADER_MAGIC, PROTOCOL_VERSION_1,
|
LoadProtocolHeader, LoadProtocolV1, KERNEL_MAGIC, LOADER_MAGIC, PROTOCOL_VERSION_1,
|
||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
arch::x86_64::{
|
arch::x86_64::{registers::MSR_IA32_KERNEL_GS_BASE, smp::CPU_COUNT},
|
||||||
registers::{CR0, MSR_IA32_KERNEL_GS_BASE},
|
|
||||||
smp::CPU_COUNT,
|
|
||||||
},
|
|
||||||
fs::devfs,
|
fs::devfs,
|
||||||
kernel_main, kernel_secondary_main,
|
kernel_main, kernel_secondary_main,
|
||||||
mem::KERNEL_VIRT_OFFSET,
|
mem::KERNEL_VIRT_OFFSET,
|
||||||
task::runtime,
|
task::runtime,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{cpuid::init_cpuid, exception, registers::CR4, ARCHITECTURE};
|
use super::{cpuid::init_cpuid, exception, ARCHITECTURE};
|
||||||
|
|
||||||
pub enum BootData {
|
pub enum BootData {
|
||||||
YBoot(&'static LoadProtocolV1),
|
YBoot(&'static LoadProtocolV1),
|
||||||
|
@ -5,7 +5,7 @@ use core::{
|
|||||||
|
|
||||||
use abi::error::Error;
|
use abi::error::Error;
|
||||||
use kernel_util::util::OneTimeInit;
|
use kernel_util::util::OneTimeInit;
|
||||||
use memtables::{FixedTables, KERNEL_L3_COUNT};
|
use memtables::FixedTables;
|
||||||
use static_assertions::{const_assert_eq, const_assert_ne};
|
use static_assertions::{const_assert_eq, const_assert_ne};
|
||||||
|
|
||||||
pub mod process;
|
pub mod process;
|
||||||
@ -13,7 +13,6 @@ pub mod table;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
arch::x86_64::{intrinsics, mem::table::PageAttributes, registers::CR3},
|
arch::x86_64::{intrinsics, mem::table::PageAttributes, registers::CR3},
|
||||||
device::display::font::PcScreenFont,
|
|
||||||
mem::{
|
mem::{
|
||||||
address::{FromRaw, IntoRaw, KernelImageObject},
|
address::{FromRaw, IntoRaw, KernelImageObject},
|
||||||
device::RawDeviceMemoryMapping,
|
device::RawDeviceMemoryMapping,
|
||||||
@ -249,7 +248,7 @@ impl<'a, T: Sized> EarlyMapping<'a, T> {
|
|||||||
let offset = physical.page_offset::<L3>();
|
let offset = physical.page_offset::<L3>();
|
||||||
let page_count = (offset + layout.size() + L3::SIZE - 1) / L3::SIZE;
|
let page_count = (offset + layout.size() + L3::SIZE - 1) / L3::SIZE;
|
||||||
|
|
||||||
let virt = map_early_pages(physical, page_count)?;
|
let virt = map_early_pages(aligned, page_count)?;
|
||||||
let value = &mut *((virt + offset) as *mut T);
|
let value = &mut *((virt + offset) as *mut T);
|
||||||
|
|
||||||
Ok(EarlyMapping { value, page_count })
|
Ok(EarlyMapping { value, page_count })
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
//! Helper types for interfacing with x86-64 registers
|
//! Helper types for interfacing with x86-64 registers
|
||||||
|
#![allow(unused)]
|
||||||
|
|
||||||
macro_rules! impl_read {
|
macro_rules! impl_read {
|
||||||
($t:ident, $register:ty, $body:expr) => {
|
($t:ident, $register:ty, $body:expr) => {
|
||||||
@ -259,10 +260,7 @@ mod cr0 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
mod cr3 {
|
mod cr3 {
|
||||||
use tock_registers::{
|
use tock_registers::{interfaces::ReadWriteable, register_bitfields};
|
||||||
interfaces::{ReadWriteable, Readable},
|
|
||||||
register_bitfields,
|
|
||||||
};
|
|
||||||
|
|
||||||
register_bitfields! {
|
register_bitfields! {
|
||||||
u64,
|
u64,
|
||||||
@ -282,10 +280,6 @@ mod cr3 {
|
|||||||
assert_eq!(address & 0xFFF, 0);
|
assert_eq!(address & 0xFFF, 0);
|
||||||
self.modify(CR3::ADDR.val((address as u64) >> 12))
|
self.modify(CR3::ADDR.val((address as u64) >> 12))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn address(&self) -> usize {
|
|
||||||
(self.read(CR3::ADDR) as usize) << 12
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// x86-64 control register 3
|
/// x86-64 control register 3
|
||||||
|
@ -18,7 +18,11 @@
|
|||||||
trait_alias,
|
trait_alias,
|
||||||
strict_provenance
|
strict_provenance
|
||||||
)]
|
)]
|
||||||
#![allow(clippy::new_without_default, clippy::fn_to_numeric_cast)]
|
#![allow(
|
||||||
|
clippy::new_without_default,
|
||||||
|
clippy::fn_to_numeric_cast,
|
||||||
|
async_fn_in_trait
|
||||||
|
)]
|
||||||
// #![warn(missing_docs)]
|
// #![warn(missing_docs)]
|
||||||
#![allow(missing_docs)]
|
#![allow(missing_docs)]
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
@ -1,9 +1,4 @@
|
|||||||
//! Various kernel utility functions
|
//! Various kernel utility functions
|
||||||
use core::time::Duration;
|
|
||||||
|
|
||||||
use yggdrasil_abi::error::Error;
|
|
||||||
|
|
||||||
// use crate::arch::{Architecture, ARCHITECTURE};
|
|
||||||
|
|
||||||
pub mod queue;
|
pub mod queue;
|
||||||
pub mod ring;
|
pub mod ring;
|
||||||
@ -24,11 +19,11 @@ impl<T, E, I: Iterator<Item = Result<T, E>>> ResultIterator<T, E> for I {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Performs a busy-loop sleep until the specified duration has passed
|
// /// Performs a busy-loop sleep until the specified duration has passed
|
||||||
pub fn polling_sleep(duration: Duration) -> Result<(), Error> {
|
// pub fn polling_sleep(duration: Duration) -> Result<(), Error> {
|
||||||
// TODO no non-IRQ mode timestamp provider
|
// // TODO no non-IRQ mode timestamp provider
|
||||||
for i in 0..1000000 {
|
// for i in 0..1000000 {
|
||||||
core::hint::spin_loop();
|
// core::hint::spin_loop();
|
||||||
}
|
// }
|
||||||
Ok(())
|
// Ok(())
|
||||||
}
|
// }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user