mirror of
https://github.com/XunilGroup/XunilOS.git
synced 2026-06-02 12:44:24 +02:00
Remove unneccessary debug, increase kernel heap to 64mb, add a global
build_and_run script, fix build.rs sometimes using the wrong architecture, add badapple ELF and change default font size to 1 for it to work, improve framebuffer errors, remove unnecessary commands from make and improve debug filtering
This commit is contained in:
+20
-4
@@ -3,15 +3,25 @@ use std::fs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn main() {
|
||||
let arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap();
|
||||
let arch = std::env::var("TARGET")
|
||||
.unwrap_or_else(|_| {
|
||||
std::env::var("CARGO_CFG_TARGET_ARCH").unwrap_or_else(|_| "x86_64".to_string())
|
||||
})
|
||||
.split('-')
|
||||
.next()
|
||||
.unwrap()
|
||||
.to_string();
|
||||
|
||||
let timer_frequency_hz = env::var("TIMER_FREQUENCY_HZ").unwrap_or_else(|_| "1000".to_string());
|
||||
let karch = env::var("KARCH").unwrap_or_else(|_| "x86_64".to_string());
|
||||
let karch = env::var("KARCH").unwrap_or_else(|_| arch.clone());
|
||||
|
||||
let out_dir = PathBuf::from("src");
|
||||
fs::write(
|
||||
out_dir.join("config.rs"),
|
||||
format!("pub const TIMER_FREQUENCY_HZ: usize = {timer_frequency_hz};\npub const KARCH: &str = \"{karch}\";"),
|
||||
format!(
|
||||
"pub const TIMER_FREQUENCY_HZ: usize = {timer_frequency_hz};\n\
|
||||
pub const KARCH: &str = \"{karch}\";"
|
||||
),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
@@ -19,7 +29,13 @@ fn main() {
|
||||
|
||||
fs::write(
|
||||
out_dir.join("assets.rs"),
|
||||
format!("pub static INIT_ELF: &[u8] = include_bytes!(\"../../../../../assets/{karch}/init\");\npub static DOOM_WAD: &[u8] = include_bytes!(\"../../../../../assets/doom1.wad\");\npub static DOOM_ELF: &[u8] = include_bytes!(\"../../../../../assets/{karch}/doomgeneric\");\npub static HELLOWORLD_ELF: &[u8] = include_bytes!(\"../../../../../assets/{karch}/helloworld.elf\");"),
|
||||
format!(
|
||||
"pub static INIT_ELF: &[u8] = include_bytes!(\"../../../../../assets/{karch}/init\");\n\
|
||||
pub static DOOM_WAD: &[u8] = include_bytes!(\"../../../../../assets/doom1.wad\");\n\
|
||||
pub static DOOM_ELF: &[u8] = include_bytes!(\"../../../../../assets/{karch}/doomgeneric\");\n\
|
||||
pub static HELLOWORLD_ELF: &[u8] = include_bytes!(\"../../../../../assets/{karch}/helloworld.elf\");\n\
|
||||
pub static BADAPPLE_ELF: &[u8] = include_bytes!(\"../../../../../assets/{karch}/badapple\");"
|
||||
),
|
||||
)
|
||||
.unwrap();
|
||||
|
||||
|
||||
@@ -1,12 +1,8 @@
|
||||
use core::sync::atomic::Ordering;
|
||||
|
||||
use crate::{
|
||||
arch::{
|
||||
aarch64::init::KERNEL_STACK,
|
||||
arch::{HHDM_OFFSET, XunilFrameAllocator, safe_lock, serial_print},
|
||||
},
|
||||
driver::graphics::framebuffer::USER_FB_BASE,
|
||||
util::U64Buf,
|
||||
use crate::arch::{
|
||||
aarch64::init::KERNEL_STACK,
|
||||
arch::{HHDM_OFFSET, XunilFrameAllocator, safe_lock},
|
||||
};
|
||||
use limine::{
|
||||
memory_map::EntryType,
|
||||
|
||||
@@ -455,11 +455,6 @@ pub unsafe extern "C" fn syscall_dispatch(
|
||||
) -> isize {
|
||||
#[cfg(target_arch = "x86_64")]
|
||||
interrupts::enable();
|
||||
// if num != 1 {
|
||||
// serial_print("syscall num=");
|
||||
// serial_print(U64Buf::new(num as u64).as_str());
|
||||
// serial_print("\n");
|
||||
// }
|
||||
|
||||
set_reschedule(match num {
|
||||
BRK => false,
|
||||
|
||||
@@ -9,7 +9,7 @@ use x86_64::structures::paging::{
|
||||
pub static ALLOCATOR: Locked<LinkedListAllocator> = Locked::new(LinkedListAllocator::new());
|
||||
|
||||
pub const HEAP_START: usize = 0xffffffff90000000;
|
||||
pub const HEAP_SIZE: usize = 4 * 1024 * 1024; // 64 MiB
|
||||
pub const HEAP_SIZE: usize = 64 * 1024 * 1024; // 64 MiB
|
||||
|
||||
pub fn init_heap(mapper: &mut OffsetPageTable) -> Result<(), MapToError<Size4KiB>> {
|
||||
let page_count = HEAP_SIZE / 4096;
|
||||
|
||||
@@ -8,7 +8,10 @@ use x86_64::{
|
||||
},
|
||||
};
|
||||
|
||||
use crate::arch::arch::{HHDM_OFFSET, XunilFrameAllocator};
|
||||
use crate::{
|
||||
arch::arch::{HHDM_OFFSET, XunilFrameAllocator, serial_print},
|
||||
println,
|
||||
};
|
||||
|
||||
unsafe fn active_level_4_table(mem_offset: VirtAddr) -> &'static mut PageTable {
|
||||
let (level_4_table, _) = Cr3::read();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
pub static INIT_ELF: &[u8] = include_bytes!("../../../../../assets/aarch64/init");
|
||||
pub static INIT_ELF: &[u8] = include_bytes!("../../../../../assets/x86_64/init");
|
||||
pub static DOOM_WAD: &[u8] = include_bytes!("../../../../../assets/doom1.wad");
|
||||
pub static DOOM_ELF: &[u8] = include_bytes!("../../../../../assets/aarch64/doomgeneric");
|
||||
pub static HELLOWORLD_ELF: &[u8] = include_bytes!("../../../../../assets/aarch64/helloworld.elf");
|
||||
pub static DOOM_ELF: &[u8] = include_bytes!("../../../../../assets/x86_64/doomgeneric");
|
||||
pub static HELLOWORLD_ELF: &[u8] = include_bytes!("../../../../../assets/x86_64/helloworld.elf");
|
||||
pub static BADAPPLE_ELF: &[u8] = include_bytes!("../../../../../assets/x86_64/badapple");
|
||||
@@ -48,6 +48,10 @@ static FILES: &[FakeFileEntry] = &[
|
||||
name: "helloworld.elf",
|
||||
data: HELLOWORLD_ELF,
|
||||
},
|
||||
FakeFileEntry {
|
||||
name: "badapple",
|
||||
data: BADAPPLE_ELF,
|
||||
},
|
||||
FakeFileEntry {
|
||||
name: "doomgeneric",
|
||||
data: DOOM_ELF,
|
||||
|
||||
@@ -15,7 +15,6 @@ pub struct ConsoleWriter<'a> {
|
||||
|
||||
impl Write for ConsoleWriter<'_> {
|
||||
fn write_str(&mut self, s: &str) -> fmt::Result {
|
||||
serial_print(s);
|
||||
self.console.print(s, self.fb);
|
||||
Ok(())
|
||||
}
|
||||
@@ -31,12 +30,17 @@ impl SerialConsole {
|
||||
pub fn new() -> SerialConsole {
|
||||
SerialConsole {
|
||||
text: String::new(),
|
||||
font_size: 2,
|
||||
font_size: 1,
|
||||
dirty: false,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print(&mut self, text: &str, fb: &mut Framebuffer) {
|
||||
if text == "\x1b[2J" {
|
||||
self.text.clear();
|
||||
return;
|
||||
}
|
||||
|
||||
let max_height = fb.height / (12 * self.font_size);
|
||||
let max_width = fb.width / (8 * self.font_size);
|
||||
|
||||
|
||||
+3
-3
@@ -180,10 +180,11 @@ pub unsafe extern "C" fn kernel_main_aarch64(mapper: &mut AArchPageTable) -> ! {
|
||||
init_framebuffer(&limine_framebuffer);
|
||||
with_framebuffer(|fb| fb.setup_aarch64());
|
||||
} else {
|
||||
serial_print("no framebuffers found");
|
||||
panic!("no framebuffers found");
|
||||
}
|
||||
} else {
|
||||
panic!("no framebuffers found");
|
||||
}
|
||||
|
||||
init_serial_console();
|
||||
|
||||
init_keyboard();
|
||||
@@ -193,7 +194,6 @@ pub unsafe extern "C" fn kernel_main_aarch64(mapper: &mut AArchPageTable) -> ! {
|
||||
} else {
|
||||
println!("Could not get date at boot. Will default to 0.")
|
||||
}
|
||||
|
||||
DAIF.write(DAIF::D::Masked + DAIF::A::Masked + DAIF::I::Unmasked + DAIF::F::Masked);
|
||||
|
||||
run_elf(INIT_ELF, false, true);
|
||||
|
||||
Reference in New Issue
Block a user