Automated format

This commit is contained in:
Formatter 2025-04-19 14:45:41 +00:00
parent 123a289a32
commit ec1b08c08e
6 changed files with 59 additions and 31 deletions

View file

@ -76,12 +76,19 @@ fn main() -> Result<(), std::io::Error> {
.arg("-o")
.arg(format!("{}/x86_asm.o", std::env::var("OUT_DIR").unwrap()))
.spawn()?
.wait()?.success() {
return Err(std::io::Error::new(std::io::ErrorKind::InvalidInput, "Assembler failed to run"));
} else {
println!("cargo::rustc-link-arg={}/x86_asm.o", std::env::var("OUT_DIR").unwrap());
}
.wait()?
.success()
{
return Err(std::io::Error::new(
std::io::ErrorKind::InvalidInput,
"Assembler failed to run",
));
} else {
println!(
"cargo::rustc-link-arg={}/x86_asm.o",
std::env::var("OUT_DIR").unwrap()
);
}
Ok(())
}

View file

@ -310,7 +310,7 @@ extern "C" fn _start() -> ! {
sdebugsln("Bootloader information has been successfully loaded");
sdebugunp(b'\n');
//aphrodite::arch::initalize_rtc();
// aphrodite::arch::initalize_rtc();
unsafe {
if BI.output.clone().is_some() {
@ -329,7 +329,6 @@ extern "C" fn _start() -> ! {
sdebugs("Framebuffer bpp: ");
sdebugbnpln(&aphrodite::u8_as_u8_slice(framebuffer_info.bpp));
let ega: &dyn aphrodite::display::TextDisplay = &framebuffer_info;
aphrodite::indep_boot_entry::indep_boot_entry(Some(ega), &BI);

View file

@ -74,10 +74,7 @@ unsafe fn load_idt(base: *const u8, size: usize) {
size: 0,
};
unsafe {
IDTR = Idtr {
base,
size,
};
IDTR = Idtr { base, size };
}
unsafe { asm!("lidt {}", sym IDTR) }
}
@ -117,7 +114,13 @@ impl From<IdtEntry> for RawIdtEntry {
/// # Panics
/// Panics if the global allocator has not been setup
pub unsafe fn activate_idt(idt: Idt) {
let mut entries = [IdtEntry {offset_high: 0, data: 0, segment: 0, offset_low: 0, vector: 0}; 256];
let mut entries = [IdtEntry {
offset_high: 0,
data: 0,
segment: 0,
offset_low: 0,
vector: 0,
}; 256];
let mut f = 0;
for i in 0..idt.len {
if idt.using_raw[i] {
@ -153,7 +156,13 @@ pub unsafe fn activate_idt(idt: Idt) {
let mut last_vector = 0u16;
let mut start = true;
let mut entries2 = [IdtEntry {offset_high: 0, data: 0, segment: 0, offset_low: 0, vector: 0}; 256];
let mut entries2 = [IdtEntry {
offset_high: 0,
data: 0,
segment: 0,
offset_low: 0,
vector: 0,
}; 256];
f = 0;
for entry in &entries {
@ -195,7 +204,12 @@ pub unsafe fn activate_idt(idt: Idt) {
f += 1;
}
let mut raw_entries = [RawIdtEntry { offset_high: 0, data: 0, segment: 0, offset_low: 0}; 256];
let mut raw_entries = [RawIdtEntry {
offset_high: 0,
data: 0,
segment: 0,
offset_low: 0,
}; 256];
f = 0;
for entry in &entries2 {
raw_entries[f] = RawIdtEntry::from(*entry);
@ -203,7 +217,10 @@ pub unsafe fn activate_idt(idt: Idt) {
}
unsafe {
load_idt((&raw_entries) as *const [RawIdtEntry; 256] as *const u8, (idt.len * 8) - 1);
load_idt(
(&raw_entries) as *const [RawIdtEntry; 256] as *const u8,
(idt.len * 8) - 1,
);
}
}

View file

@ -16,8 +16,8 @@ mod constants;
use constants::*;
use gdt::GDTEntry;
use interrupts::{disable_interrupts, enable_interrupts, pop_irq, restore_irq};
use ports::{inb, outb};
use output::*;
use ports::{inb, outb};
/// Returns the most specific architecture available.
pub const fn get_arch() -> super::Architecture { super::Architecture::X86 }
@ -100,36 +100,41 @@ pub fn alloc_available_boot() {
let entries = gdt::serialize_gdt_entries([
gdt::GDT_NULL_ENTRY,
GDTEntry { // kernel code segment, segment 0x08
GDTEntry {
// kernel code segment, segment 0x08
limit: 0xFFFFF,
base: 0,
access: 0x9A,
flags: 0xC,
},
GDTEntry { // kernel data segment, segment 0x10
GDTEntry {
// kernel data segment, segment 0x10
limit: 0xFFFFF,
base: 0,
access: 0x92,
flags: 0xC,
},
GDTEntry { // user code segment, segment 0x18
GDTEntry {
// user code segment, segment 0x18
limit: 0xFFFFF,
base: 0,
access: 0xFA,
flags: 0xC,
},
GDTEntry { // user data segment, segment 0x20
GDTEntry {
// user data segment, segment 0x20
limit: 0xFFFFF,
base: 0,
access: 0xF2,
flags: 0xC,
},
GDTEntry { // Video RAM segment, segment 0x28
GDTEntry {
// Video RAM segment, segment 0x28
limit: 0xFFFFF,
base: 0,
access: 0x92,
flags: 0xC,
}
},
]);
sdebugsln("GDT prepared");

View file

@ -3,22 +3,22 @@
not(CONFIG_POWERON_TEST_DISPLAY = "false")
))]
use crate::display::{TextDisplay, COLOR_BLACK, COLOR_DEFAULT};
use crate::output::{toutputsln, sreset};
use crate::arch::output::*;
use crate::display::{COLOR_BLACK, COLOR_DEFAULT, TextDisplay};
use crate::output::{sreset, toutputsln};
pub fn run(display: &dyn TextDisplay) {
sinfosln("Running display power-on test...");
display.clear_screen(COLOR_DEFAULT).unwrap();
sreset();
sinfosln("Screen cleared; attempting to write text to display");
toutputsln("Testing display...", display).unwrap();
toutputsln("Testing display...", display).unwrap();
toutputsln("Testing display...", display).unwrap();
sinfosln("Success! Clearing display with COLOR_BLACK.");
display.clear_screen(COLOR_BLACK).unwrap();
@ -28,6 +28,6 @@ pub fn run(display: &dyn TextDisplay) {
display.clear_screen(COLOR_DEFAULT).unwrap();
sreset();
sinfosln("Done running display power-on test");
}
}

View file

@ -2,13 +2,13 @@
use crate::display::TextDisplay;
mod memmapalloc;
mod display;
mod memmapalloc;
pub fn run(display: &dyn TextDisplay) {
#[cfg(not(CONFIG_POWERON_TEST_DISPLAY = "false"))]
display::run(display);
#[cfg(not(CONFIG_POWERON_TEST_ALLOC = "false"))]
memmapalloc::run(display);
}