Compare commits

..

No commits in common. "8d10160ea1d644ece884f5a6522776ba8e376a8b" and "3c13ffe6ae1e6fd5e2b328d15484f85b741719f6" have entirely different histories.

16 changed files with 22 additions and 50 deletions

View file

@ -7,5 +7,4 @@
"kernel/aphrodite_common/Cargo.toml",
"user/Cargo.toml"
],
"rust-analyzer.check.command": "clippy",
}

View file

@ -96,13 +96,10 @@
real_target=$(basename $real_target)
if [[ $check = "true" ]]; then
echo "[INFO] Checking target $target(with rust target of $real_target)"
cargo clippy --target "$real_target" --release -Zbuild-std=core,alloc --bin entrypoint_$target
cargo check --target "$real_target" --release -Zbuild-std=core,alloc --bin entrypoint_$target
else
echo "[INFO] Compiling target $target(with rust target of $real_target)"
echo "[INFO] Running clippy"
cargo clippy --target "$real_target" --release -Zbuild-std=core,alloc --bin entrypoint_$target
echo "[INFO] Building"
cargo build --target "$real_target" --release -Zbuild-std=core,alloc --bin entrypoint_$target 2>/dev/null
cargo build --target "$real_target" --release -Zbuild-std=core,alloc --bin entrypoint_$target
cp "target/$(echo $real_target | sed 's/\.json//')/release/entrypoint_$target" kernel-$target
if [[ "$CONFIG_BUILD_GRUB" = "true" ]]; then

View file

@ -95,16 +95,6 @@ pub mod interrupts {
}
}
}
impl Default for IdtBuilder {
fn default() -> Self {
IdtBuilder {
vectors: [0; 256],
funcs: [MaybeUninit::uninit(); 256],
idx: 0,
}
}
}
}
pub mod output {

View file

@ -1,5 +1,5 @@
//! Constants used throughout kernel code.
#![cfg(target_arch = "x86")]
#![cfg(any(target_arch = "x86"))]
/// The assembly port number to output debug messages to.
pub(super) const DEBUG_PORT: u16 = 0xE9;

View file

@ -1,5 +1,5 @@
//! Stuff for writing and reading to the EGA text buffer.
#![cfg(target_arch = "x86")]
#![cfg(any(target_arch = "x86"))]
use crate::display::Color;
@ -109,6 +109,6 @@ impl FramebufferInfo {
super::ports::outb(0x3D4, 0x0E);
addr |= (super::ports::inb(0x3D5) as u32) << 8;
(addr % self.width, addr / self.width)
return (addr % self.width, addr / self.width);
}
}

View file

@ -1,5 +1,4 @@
//! GDT initalization.
#![cfg(target_arch = "x86")]
use core::alloc::Layout;

View file

@ -1,5 +1,5 @@
//! Provides interrupt-related functions
#![cfg(target_arch = "x86")]
#![cfg(any(target_arch = "x86"))]
#![allow(static_mut_refs)]
use core::{
@ -69,20 +69,21 @@ pub fn restore_irq(flags: PoppedInterrupts) {
}
/// The IDTR. Used internally in [load_idt].
#[repr(C, packed)]
struct Idtr {
#[repr(packed)]
#[repr(C)]
struct IDTR {
base: *const u8,
size: usize,
}
unsafe impl Send for Idtr {}
unsafe impl Sync for Idtr {}
unsafe impl Send for IDTR {}
unsafe impl Sync for IDTR {}
/// Loads an interrupt descriptor table.
fn load_idt(base: *const u8, size: usize) {
static mut IDTR: MaybeUninit<Idtr> = MaybeUninit::uninit();
static mut IDTR: MaybeUninit<IDTR> = MaybeUninit::uninit();
unsafe {
IDTR.write(Idtr { base, size });
IDTR.write(IDTR { base, size });
}
unsafe { asm!("lidt {}", in(reg) IDTR.as_ptr() as usize) }
}
@ -147,14 +148,3 @@ impl IdtBuilder {
}
}
}
impl Default for IdtBuilder {
fn default() -> Self {
IdtBuilder {
vectors: [0; 256],
funcs: [MaybeUninit::uninit(); 256],
user_callable: [false; 256],
idx: 0,
}
}
}

View file

@ -1,5 +1,4 @@
//! Hardware-level memory sections. Unimplemented for certain hardware, x86 implements with GDT.
#![cfg(target_arch = "x86")]
use core::arch::asm;

View file

@ -1,5 +1,5 @@
//! General x86 functions
#![cfg(target_arch = "x86")]
#![cfg(any(target_arch = "x86"))]
use core::arch::asm;
@ -13,7 +13,7 @@ pub mod ports;
mod constants;
use constants::*;
pub(self) use constants::*;
use interrupts::{pop_irq, restore_irq};
use ports::{inb, outb};

View file

@ -1,5 +1,5 @@
//! Functions to output to various things
#![cfg(target_arch = "x86")]
#![cfg(any(target_arch = "x86"))]
use super::ports;
use paste::paste;

View file

@ -1,5 +1,4 @@
//! Functions and types related to paging.
#![cfg(target_arch = "x86")]
use core::arch::asm;

View file

@ -1,5 +1,5 @@
//! Provides utilities for interacting with assembly ports
#![cfg(target_arch = "x86")]
#![cfg(any(target_arch = "x86"))]
use core::arch::asm;

View file

@ -126,7 +126,7 @@ impl core::iter::Iterator for MemoryMap {
type Item = MemoryMapping;
fn next(&mut self) -> Option<Self::Item> {
self.idx += 1;
if self.sections.len() < self.idx {
if self.sections.len() <= self.idx - 1 {
self.reset_iter();
return None;
}

View file

@ -7,7 +7,7 @@ macro_rules! cfg_int {
paste::paste! {
{
let cfg = env!($cfg).as_bytes();
$crate::[< str_as_ $type >](cfg)
crate::[< str_as_ $type >](cfg)
}
}
};

View file

@ -303,7 +303,7 @@ impl<'a> MemoryMapAlloc<'a> {
let mut i = 0;
while i < num_allocs {
let current = unsafe {
&mut *((self.allocations as usize + size_of::<Allocation>() * (i as usize))
&mut *((self.allocations as usize + size_of::<Allocation>() * (i as usize))
as *mut Allocation)
};
@ -524,7 +524,7 @@ unsafe impl<'a> Allocator for MemoryMapAlloc<'a> {
if alloc.used && alloc.addr == addr {
// Zero the memory
unsafe { core::ptr::write_bytes(addr as *mut u8, 0, alloc.len as usize) };
// Mark as free
alloc.used = false;
found = true;
@ -664,4 +664,4 @@ unsafe impl<'a> GlobalAlloc for MemoryMapAlloc<'a> {
/// The last status of memory allocation or deallocation for a [MemoryMapAlloc].
/// This can be used for more insight to why an allocation or deallocation failed.
pub static mut LAST_MEMMAP_ERR: Result<(), crate::Error<'static>> = Ok(());
pub static mut LAST_MEMMAP_ERR: Result<(), crate::Error<'static>> = Ok(());

View file

@ -1,7 +1,6 @@
//! This provides raw methods for internal kernel usage for the Aphrodite kernel. See aphrodite_user for userspace.
#![no_std]
#![warn(missing_docs)]
#![warn(clippy::missing_docs_in_private_items)]
#![warn(rustdoc::missing_crate_level_docs)]
#![deny(rustdoc::invalid_html_tags)]
#![deny(rustdoc::invalid_rust_codeblocks)]