diff --git a/MANIFESTO.md b/MANIFESTO.md new file mode 100644 index 0000000..05cd16c --- /dev/null +++ b/MANIFESTO.md @@ -0,0 +1,67 @@ +# The Design of AbleOS +## The unix philosophy and why it shouldn't exist +small is only beautiful if its complete. + grep for example supports the `-r` flag which should instead be `grep`+`find` +Everything is not a stream of bytes. + +programs can do multiple things well + `cat`, `head` and `tail` could all be one program with a flag + `which head` `which tail` `which cat` should all return the same binary with different flags + ``` + which head == /bin/cat range=0-10 + + which tail == /bin/cat reverse_index=true range=0-10 + + which cat == /bin/cat + ``` + +build a prototype quickly only applies if you are being pressured. do thing quickly then refine +'choose portability over effeciency' this is a flawed idealogy choose modularity over pure portability +'store data in flat text files' this leads to a psuedostandardization on KVPair configuration languages that all sit in a flat text file. Instead pick a configuration format that gets loaded into a tree structure + +## File Systems +### The amount of files inside of a folder +32765. Why you might ask? +### Dot files +`dotfiles` were a mistake given to us by bad programmers mocking better programmers. [link](https://web.archive.org/web/20230413171520/http://xahlee.info/UnixResource_dir/writ/unix_origin_of_dot_filename.html) + +### File name case sensitivity +Case sensitivity seems like a great idea! But in practice leads to the following filetree +``` +/kernel +/Kernel +/kErnEl +/KeRnEl +``` +which is a nightmare and you should be erradicated if you think this is a positive +provide a display name for files that allows case and save the file as caseless + +### File name character limits +unix is a plauge upon this earth. name a file `:(){ :|:& };:` and try listing it. You have lost access to your terminal. +if you defined a sane method of listing files and allowing programs to provide the OS a standard method of providing argument suggestions and being aware you would never run into this issue + +## CLI vs GUI +Graphics are not your enemy unix lovers. You mustn't be stuck in 1981. Times have changed! You can have a graphical shell enviroment. SGI Irix was aware of this in 1988, not perfect of course but 7 years after dos is an impressive leap. +FFMPEG??? Why no gui? Give me a good git ui + + +### Emails plain text +Unix believes in plain text emails. Quotes are `>` + +### Unix Wizards and Instability +[Do not meddle in the affairs of Unix, for it is subtle and quick to anger.] + +### Unix why are your mouse a file? +This list is incomplete +`/dev/input/event1` The PS2 Mouse +`/dev/input/psaux` The PS2 Mouse +`/dev/input/psmouse` The PS2 Mouse +`/dev/input/mice` The Not(?) PS2 Mouse I think? +`/dev/input/mouse0` The not Not(?) ps2 mouse? First usb mouse I think? +`/dev/input/usbhid` USB mice (should be autodetected) +`/dev/input/sermouse` Most serial mice +`/dev/input/logibm` Bus mouse connected to Logitech adapter card +`/dev/input/inport` Bus mouse connected to ATI or Microsoft InPort card +`/dev/input/by-id/usb-` A usb mouse via its id + +I propose a unified system for input via a Device Tree of sorts \ No newline at end of file diff --git a/design.dot b/design.dot new file mode 100644 index 0000000..4ec166d --- /dev/null +++ b/design.dot @@ -0,0 +1,50 @@ +strict graph OS { + layout=dot; + ModelingSoftware -- GraphicsAPI; + ModelingSoftware -- HID; + ModelingSoftware -- VFS; + + GameEngine3D -- GraphicsAPI; + GameEngine3D -- VFS; + GameEngine3D -- AudioSubsystem; + GameEngine3D -- HID; + GameEngine3D -- Networking; + + Git -- VFS; + Git -- Networking; + + ListFile -- VFS; + MakeFile -- VFS; + + AudioSubsystem -- AbleOSInterface; + GraphicsAPI -- AbleOSInterface; + HID -- AbleOSInterface; + Networking -- AbleOSInterface; + + FatFileSystemProc -- VFS; + NTFSFileSystemProc -- VFS; + EXT2 -- VFS; + + FatFileSystemProc -- DriveSystemProc; + NTFSFileSystemProc -- DriveSystemProc; + EXT2 -- DriveSystemProc; + + + DriveSystemProc -- AbleOSInterface; + + AbleOSInterface -- DriveSystemProc; + AbleOSInterface -- Kernel; + + + Kernel -- x86HAL; + Kernel -- riscvHAL; + Kernel -- aarch64HAL; + + x86HAL -- GPU; + riscvHAL -- GPU; + aarch64HAL -- GPU; + + x86HAL -- SoundCard; + riscvHAL -- SoundCard; + aarch64HAL -- SoundCard; +} \ No newline at end of file diff --git a/kernel/src/arch/x86_64/graphics.rs b/kernel/src/arch/x86_64/graphics.rs index 3ad4346..3a4fccf 100644 --- a/kernel/src/arch/x86_64/graphics.rs +++ b/kernel/src/arch/x86_64/graphics.rs @@ -14,6 +14,7 @@ use { pub static DISPLAY: Lazy> = Lazy::new(|| { static FB_REQ: FramebufferRequest = FramebufferRequest::new(0); let fb1 = &FB_REQ.get_response().get().unwrap().framebuffers()[0]; + let m = Mutex::new(Display { fb: fb1.address.as_ptr().unwrap().cast(), size: Size::new(fb1.width as u32, fb1.height as u32), @@ -26,31 +27,31 @@ pub static DISPLAY: Lazy> = Lazy::new(|| { pub fn init() { Lazy::force(&DISPLAY); } -pub fn virtio_gpu(transport: T) { - let mut gpu = VirtIOGpu::::new(transport).expect("failed to create gpu driver"); - let (width, height) = gpu.resolution().expect("failed to get resolution"); - let width = width as usize; - let height = height as usize; - log::info!("GPU resolution is {}x{}", width, height); - let fb = gpu.setup_framebuffer().expect("failed to get fb"); - for y in 0..height { - for x in 0..width { - let idx = (y * width + x) * 4; - fb[idx] = x as u8; - fb[idx + 1] = y as u8; - fb[idx + 2] = (x + y) as u8; - } - } - gpu.flush().expect("failed to flush"); - //delay some time - log::info!("virtio-gpu show graphics...."); - for _ in 0..100000 { - for _ in 0..100000 { - unsafe { - core::arch::asm!("nop"); - } - } - } +// pub fn virtio_gpu(transport: T) { +// let mut gpu = VirtIOGpu::::new(transport).expect("failed to create gpu driver"); +// let (width, height) = gpu.resolution().expect("failed to get resolution"); +// let width = width as usize; +// let height = height as usize; +// log::info!("GPU resolution is {}x{}", width, height); +// let fb = gpu.setup_framebuffer().expect("failed to get fb"); +// for y in 0..height { +// for x in 0..width { +// let idx = (y * width + x) * 4; +// fb[idx] = x as u8; +// fb[idx + 1] = y as u8; +// fb[idx + 2] = (x + y) as u8; +// } +// } +// gpu.flush().expect("failed to flush"); +// //delay some time +// log::info!("virtio-gpu show graphics...."); +// for _ in 0..100000 { +// for _ in 0..100000 { +// unsafe { +// core::arch::asm!("nop"); +// } +// } +// } - log::info!("virtio-gpu test finished"); -} +// log::info!("virtio-gpu test finished"); +// } diff --git a/kernel/src/arch/x86_64/logging.rs b/kernel/src/arch/x86_64/logging.rs index e01a506..457fb07 100644 --- a/kernel/src/arch/x86_64/logging.rs +++ b/kernel/src/arch/x86_64/logging.rs @@ -8,41 +8,41 @@ use { }; static SERIAL_CONSOLE: Mutex = Mutex::new(unsafe { SerialPort::new(0x3F8) }); -// static TERMINAL_LOGGER: Lazy> = Lazy::new(|| Mutex::new(TermLogger::new())); +static TERMINAL_LOGGER: Lazy> = Lazy::new(|| Mutex::new(TermLogger::new())); pub fn init() { SERIAL_CONSOLE.lock().init(); - // Lazy::force(&TERMINAL_LOGGER); + Lazy::force(&TERMINAL_LOGGER); } pub fn log(args: core::fmt::Arguments<'_>) -> core::fmt::Result { x86_64::instructions::interrupts::without_interrupts(|| { - // TERMINAL_LOGGER.lock().write_fmt(args)?; + TERMINAL_LOGGER.lock().write_fmt(args)?; SERIAL_CONSOLE.lock().write_fmt(args) }) } -// struct TermLogger(&'static TerminalResponse); -// unsafe impl Send for TermLogger {} -// impl TermLogger { -// pub fn new() -> Self { -// static TERM_REQ: TerminalRequest = TerminalRequest::new(0); -// Self( -// TERM_REQ -// .get_response() -// .get() -// .expect("failed to get terminal response"), -// ) -// } -// } +struct TermLogger(&'static TerminalResponse); +unsafe impl Send for TermLogger {} +impl TermLogger { + pub fn new() -> Self { + static TERM_REQ: TerminalRequest = TerminalRequest::new(0); + Self( + TERM_REQ + .get_response() + .get() + .expect("failed to get terminal response"), + ) + } +} -// impl Write for TermLogger { -// fn write_str(&mut self, s: &str) -> core::fmt::Result { -// if let (Some(w), ts) = (self.0.write(), self.0.terminals()) { -// for term in ts { -// w(term, s); -// } -// } -// Ok(()) -// } -// } +impl Write for TermLogger { + fn write_str(&mut self, s: &str) -> core::fmt::Result { + if let (Some(w), ts) = (self.0.write(), self.0.terminals()) { + for term in ts { + w(term, s); + } + } + Ok(()) + } +} diff --git a/kernel/src/arch/x86_64/mod.rs b/kernel/src/arch/x86_64/mod.rs index f12f8fd..b0549f1 100644 --- a/kernel/src/arch/x86_64/mod.rs +++ b/kernel/src/arch/x86_64/mod.rs @@ -111,14 +111,15 @@ unsafe extern "C" fn _kernel_start() -> ! { // Graphics test { + graphics::init(); let mut dis = DISPLAY.lock(); use {able_graphics_library::raw_pixel, embedded_graphics::prelude::RgbColor}; dis.set_color(Rgb888::GREEN); dis.line(1, 1, 10, 10, 4); - dis.line(1, 200, 100, 10, 1); - dis.line(1, 1, 200, 10, 1); + // dis.line(1, 200, 100, 10, 1); + // dis.line(1, 1, 200, 10, 1); } crate::kmain::kmain( diff --git a/test.wasm b/test.wasm new file mode 100644 index 0000000..da05794 Binary files /dev/null and b/test.wasm differ