refactor: fix warnings/fix incorrect EarlyMapping::map

This commit is contained in:
Mark Poliakov 2023-11-06 18:30:41 +02:00
parent fbb804f14f
commit a530a34a09
6 changed files with 29 additions and 36 deletions

View File

@ -28,7 +28,6 @@ use crate::{
PhysicalAddress,
},
sync::IrqSafeSpinlock,
util,
};
use super::intrinsics;
@ -180,8 +179,10 @@ impl acpi_system::Handler for AcpiHandlerImpl {
Ok(())
}
fn stall(duration: Duration) {
util::polling_sleep(duration).ok();
fn stall(_duration: Duration) {
// 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 sleep(&self, duration: Duration) {
util::polling_sleep(duration).unwrap();
fn sleep(&self, _duration: Duration) {
todo!()
// util::polling_sleep(duration).unwrap();
}
}
@ -335,7 +337,9 @@ impl AcpiHandler for AcpiHandlerImpl {
}
/// Initializes ACPI management
#[allow(unused)]
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();
system.initialize(AcpiInterruptMethod::Apic).unwrap();

View File

@ -1,24 +1,21 @@
//! x86-64 boot and entry functions
use core::{arch::global_asm, sync::atomic::Ordering};
use tock_registers::interfaces::{ReadWriteable, Writeable};
use tock_registers::interfaces::Writeable;
use yboot_proto::{
v1::{FramebufferOption, MemoryMap},
LoadProtocolHeader, LoadProtocolV1, KERNEL_MAGIC, LOADER_MAGIC, PROTOCOL_VERSION_1,
};
use crate::{
arch::x86_64::{
registers::{CR0, MSR_IA32_KERNEL_GS_BASE},
smp::CPU_COUNT,
},
arch::x86_64::{registers::MSR_IA32_KERNEL_GS_BASE, smp::CPU_COUNT},
fs::devfs,
kernel_main, kernel_secondary_main,
mem::KERNEL_VIRT_OFFSET,
task::runtime,
};
use super::{cpuid::init_cpuid, exception, registers::CR4, ARCHITECTURE};
use super::{cpuid::init_cpuid, exception, ARCHITECTURE};
pub enum BootData {
YBoot(&'static LoadProtocolV1),

View File

@ -5,7 +5,7 @@ use core::{
use abi::error::Error;
use kernel_util::util::OneTimeInit;
use memtables::{FixedTables, KERNEL_L3_COUNT};
use memtables::FixedTables;
use static_assertions::{const_assert_eq, const_assert_ne};
pub mod process;
@ -13,7 +13,6 @@ pub mod table;
use crate::{
arch::x86_64::{intrinsics, mem::table::PageAttributes, registers::CR3},
device::display::font::PcScreenFont,
mem::{
address::{FromRaw, IntoRaw, KernelImageObject},
device::RawDeviceMemoryMapping,
@ -249,7 +248,7 @@ impl<'a, T: Sized> EarlyMapping<'a, T> {
let offset = physical.page_offset::<L3>();
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);
Ok(EarlyMapping { value, page_count })

View File

@ -1,4 +1,5 @@
//! Helper types for interfacing with x86-64 registers
#![allow(unused)]
macro_rules! impl_read {
($t:ident, $register:ty, $body:expr) => {
@ -259,10 +260,7 @@ mod cr0 {
}
mod cr3 {
use tock_registers::{
interfaces::{ReadWriteable, Readable},
register_bitfields,
};
use tock_registers::{interfaces::ReadWriteable, register_bitfields};
register_bitfields! {
u64,
@ -282,10 +280,6 @@ mod cr3 {
assert_eq!(address & 0xFFF, 0);
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

View File

@ -18,7 +18,11 @@
trait_alias,
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)]
#![allow(missing_docs)]
#![no_std]

View File

@ -1,9 +1,4 @@
//! Various kernel utility functions
use core::time::Duration;
use yggdrasil_abi::error::Error;
// use crate::arch::{Architecture, ARCHITECTURE};
pub mod queue;
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
pub fn polling_sleep(duration: Duration) -> Result<(), Error> {
// TODO no non-IRQ mode timestamp provider
for i in 0..1000000 {
core::hint::spin_loop();
}
Ok(())
}
// /// Performs a busy-loop sleep until the specified duration has passed
// pub fn polling_sleep(duration: Duration) -> Result<(), Error> {
// // TODO no non-IRQ mode timestamp provider
// for i in 0..1000000 {
// core::hint::spin_loop();
// }
// Ok(())
// }