did a bit of cleanup
Some checks failed
Continuous Integration / ci (push) Failing after 4m46s
Format code / Format the kernel (push) Has been cancelled

This commit is contained in:
Arthur Beck 2025-03-31 16:28:47 -05:00
parent 32e1eb6c28
commit fc11d393ff
Signed by: ArthurB
GPG key ID: CA200B389F0F6BC9
7 changed files with 50 additions and 18 deletions

View file

@ -1,6 +1,5 @@
#!/bin/bash
(
flags=$-
set -o pipefail -o noclobber
@ -120,9 +119,9 @@
cargo clippy --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"
echo "[INFO] Checking target with clippy"
cargo clippy --target "$real_target" --release -Zbuild-std=core,alloc --bin entrypoint_$target
echo "[INFO] Building"
echo "[INFO] Building target"
cargo build --target "$real_target" --release -Zbuild-std=core,alloc --bin entrypoint_$target 2>/dev/null
cp "target/$(echo $target_json | sed 's/\.json//')/release/entrypoint_$target" kernel-$target

View file

@ -1,14 +1,23 @@
#!/bin/bash
if [[ $# -ne 1 ]]; then
echo "Error: expected target to be passed to $0"
echo ""
echo "Run in the format: $0 target"
echo "[ERROR] Expected target to be passed"
echo -e "[TIP] Run in the format: \"$0 \x1b[3mtarget\x1b[0m\""
exit 1
fi
set -e
# -f makes it so it won't error out if the file doesn't exist
rm -f targets.tmp
envsubst < "targets" > "targets.tmp"
export $(grep -Ev '^#' config.aphro.tmp | xargs)
pushd . 2>&1 > /dev/null
trap 'popd -0 2>&1 > /dev/null' EXIT
cd ../emulation
if [[ "$1" = "x86" ]]; then
@ -19,4 +28,12 @@ if [[ "$1" = "x86" ]]; then
sed -i "s@%{BUILT_FILE}@aphrodite-$1.iso@g" bochsrc
bochs -q
else
if [[ "$TARGETS" =~ "$1" ]]; then
echo "[ERROR] Cannot emulate specified architecture \"$1\"."
else
echo "[ERROR] Unknown architecture \"$1\"."
echo "[TIP] Check your spelling."
fi
exit 1
fi

View file

@ -1,5 +1,5 @@
//! The entrypoint to the kernel; placed before all other code.
#![cfg(any(target_arch = "x86"))]
#![cfg(target_arch = "x86")]
#![no_std]
#![no_main]
#![warn(missing_docs)]
@ -179,13 +179,13 @@ extern "C" fn _start() -> ! {
// rawmemorymap's sections into a pointer to those sections.
for ele in &mut *memorysections {
(*ele) = core::mem::transmute(Into::<MemoryMapping>::into(*ele))
(*ele) = core::mem::transmute::<aphrodite::boot::MemoryMapping, aphrodite::multiboot2::MemorySection>(Into::<MemoryMapping>::into(*ele))
}
MM = MemoryMap {
version: (*rawmemorymap).entry_version,
entry_size: (*rawmemorymap).entry_size,
sections: core::mem::transmute(memorysections),
sections: core::mem::transmute::<&mut [aphrodite::multiboot2::MemorySection], &[aphrodite::boot::MemoryMapping]>(memorysections),
};
let mm2 = aphrodite::boot::MemoryMap {
len: MM.sections.len() as u64,
@ -215,7 +215,7 @@ extern "C" fn _start() -> ! {
panic!("size of framebuffer info tag < 32");
}
let framebufferinfo: *const FramebufferInfo =
(ptr as usize + size_of::<Tag>()) as *const FramebufferInfo;
(ptr + size_of::<Tag>()) as *const FramebufferInfo;
match (*framebufferinfo).fb_type {
0 => {
// Indexed

View file

@ -49,10 +49,10 @@ impl crate::display::TextDisplay for FramebufferInfo {
}
}
let color = clr;
if pos.0 > self.width {
if pos.0 >= self.width {
return Err(crate::Error::new("Invalid X position", ERR_INVALID_X));
}
if pos.1 > self.height {
if pos.1 >= self.height {
return Err(crate::Error::new("Invalid Y position", ERR_INVALID_Y));
}
unsafe {
@ -68,7 +68,18 @@ impl crate::display::TextDisplay for FramebufferInfo {
}
Ok(())
}
fn get_size(&self) -> (u32, u32) { (self.width, self.height) }
fn scroll(&self) {
let mut addr = self.address as usize;
addr += self.pitch as usize;
unsafe { core::ptr::copy(addr as *const u8, self.address as usize as *mut u8, (self.pitch*(self.height-1)) as usize); }
for x in 0..self.width {
self.write_char((x, self.height-1), b' ', crate::display::COLOR_DEFAULT);
}
}
}
impl FramebufferInfo {

View file

@ -27,6 +27,8 @@ pub trait TextDisplay: core::fmt::Write {
) -> Result<(), crate::Error<'static>>;
/// Gets the size of the screen.
fn get_size(&self) -> (u32, u32);
/// Scroll the screen up one character. Clear the bottom row.
fn scroll(&self);
}
impl dyn TextDisplay + '_ {
@ -47,9 +49,13 @@ impl dyn TextDisplay + '_ {
str: &str,
color: Color,
) -> Result<(u32, u32), crate::Error<'static>> {
let (width, _) = self.get_size();
let (width, height) = self.get_size();
let (mut x, mut y) = pos;
for char in str.as_bytes() {
if y >= height {
self.scroll();
y -= 1;
}
self.write_char((x, y), *char, color)?;
if *char == 0 {
continue;
@ -96,6 +102,7 @@ impl TextDisplay for NoneTextDisplay {
fn write_char(&self, _: (u32, u32), _: u8, _: Color) -> Result<(), crate::Error<'static>> {
Ok(())
}
fn scroll(&self) {}
}
impl Write for NoneTextDisplay {

View file

@ -172,8 +172,6 @@ impl<'a> MemoryMapAlloc<'a> {
};
out.memory_map.reset_iter();
for mapping in &mut *out.memory_map {
mapping.output();
crate::arch::output::sdebugsnpln("");
if mapping.len < (size_of::<Allocation>() * 32) as u64 {
continue;
}
@ -527,7 +525,8 @@ 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) };
// removed 2024-03-31 due to performance concerns and rust doesn't require this
// unsafe { core::ptr::write_bytes(addr as *mut u8, 0, alloc.len as usize) };
// Mark as free
alloc.used = false;

View file

@ -7,7 +7,7 @@
#![deny(rustdoc::invalid_html_tags)]
#![deny(rustdoc::invalid_rust_codeblocks)]
#![deny(unsafe_op_in_unsafe_fn)]
// tidy-alphabetical-start
#![feature(ptr_metadata)]
#![feature(const_trait_impl)]
#![feature(f128)]
@ -20,7 +20,6 @@
#![feature(ptr_as_uninit)]
#![allow(internal_features)]
#![feature(core_intrinsics)]
// tidy-alphabetical-end
extern crate alloc;