yggdrasil/src/main.rs

114 lines
3.1 KiB
Rust
Raw Normal View History

2023-07-18 18:03:45 +03:00
//! osdev-x kernel crate
#![feature(
naked_functions,
asm_const,
panic_info_message,
optimize_attribute,
const_trait_impl,
maybe_uninit_slice,
2023-07-25 16:47:00 +03:00
arbitrary_self_types,
2023-07-28 14:26:39 +03:00
const_mut_refs,
let_chains
2023-07-18 18:03:45 +03:00
)]
#![allow(clippy::new_without_default)]
#![warn(missing_docs)]
#![no_std]
#![no_main]
2023-07-29 19:31:56 +03:00
extern crate yggdrasil_abi as abi;
2023-07-28 14:26:39 +03:00
//
// use abi::{
// error::Error,
// io::{FileMode, OpenOptions, RawFd},
// process::ExitCode,
// };
// use fs::{devfs, FileBlockAllocator, INITRD_DATA};
// use memfs::MemoryFilesystem;
// use task::process::Process;
// use vfs::{Filesystem, IoContext, VnodeRef};
//
// extern crate alloc;
//
2023-07-29 19:31:56 +03:00
#[macro_use]
pub mod debug;
2023-07-18 18:03:45 +03:00
#[macro_use]
pub mod arch;
2023-07-28 14:26:39 +03:00
#[panic_handler]
fn panic_handler(_pi: &core::panic::PanicInfo) -> ! {
loop {}
2023-07-18 18:03:45 +03:00
}
2023-07-28 14:26:39 +03:00
//
2023-07-29 21:11:15 +03:00
pub mod device;
2023-07-28 14:26:39 +03:00
// pub mod fs;
2023-07-29 19:31:56 +03:00
pub mod mem;
2023-07-28 14:26:39 +03:00
// pub mod panic;
// pub mod proc;
2023-07-29 19:31:56 +03:00
pub mod sync;
2023-07-28 14:26:39 +03:00
// pub mod syscall;
// pub mod task;
2023-07-29 19:31:56 +03:00
pub mod util;
2023-07-28 14:26:39 +03:00
//
// fn setup_root() -> Result<VnodeRef, Error> {
// let initrd_data = INITRD_DATA.get();
// let fs = MemoryFilesystem::<FileBlockAllocator>::from_slice(initrd_data.data).unwrap();
// fs.root()
// }
//
// /// Entry point for common kernel code.
// ///
// /// # Note
// ///
// /// This function is meant to be used as a kernel-space process after all the platform-specific
// /// initialization has finished.
// pub fn kernel_main() {
// // use crate::{debug::LogLevel, mem::phys};
// // use crate::task::tasklet::{self, TaskFlow};
// // use core::time::Duration;
//
// // Schedule a tasklet to print memory usage stats every 10 seconds
// // tasklet::add_periodic("mem-stats", Duration::from_secs(3), || {
// // let phys_mem = phys::PHYSICAL_MEMORY.get().lock();
// // let stats = phys_mem.stats();
// // stats.dump(LogLevel::Debug);
//
// // TaskFlow::Continue
// // });
//
// let root = match setup_root() {
// Ok(root) => root,
// Err(err) => {
// warnln!("Could not setup root from initrd: {:?}", err);
// return;
// }
// };
//
// let ioctx = IoContext::new(root);
// let node = ioctx.find(None, "/init", true, true).unwrap();
// let file = node.open(OpenOptions::READ, FileMode::empty()).unwrap();
//
// let devfs = devfs::root();
// let console = ioctx
// .find(Some(devfs.clone()), "ttyS0", true, true)
// .unwrap();
// let stdin = console.open(OpenOptions::READ, FileMode::empty()).unwrap();
// let stdout = console.open(OpenOptions::WRITE, FileMode::empty()).unwrap();
// let stderr = stdout.clone();
//
// {
// let user_init = proc::exec::load_elf(file, &["/init", "xxx"]).unwrap();
// let mut io = user_init.io.lock();
// io.set_ioctx(ioctx);
// io.set_file(RawFd::STDIN, stdin).unwrap();
// io.set_file(RawFd::STDOUT, stdout).unwrap();
// io.set_file(RawFd::STDERR, stderr).unwrap();
// drop(io);
//
// user_init.set_session_terminal(console);
//
// user_init.enqueue_somewhere();
// }
//
// Process::current().exit(ExitCode::SUCCESS);
// }