forked from AbleOS/ableos_userland
work on driver layout and STD lib
This commit is contained in:
parent
bd4241209a
commit
9523507f1b
8
Cargo.lock
generated
8
Cargo.lock
generated
|
@ -37,6 +37,10 @@ version = "1.0.66"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "216261ddc8289130e551ddcd5ce8a064710c0d064a4d2895c67151c92b5443f6"
|
||||
|
||||
[[package]]
|
||||
name = "audio_interface"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "base64"
|
||||
version = "0.13.1"
|
||||
|
@ -224,6 +228,10 @@ version = "1.16.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "86f0b0d4bf799edbc74508c1e8bf170ff5f41238e5f8225603ca7caaae2b7860"
|
||||
|
||||
[[package]]
|
||||
name = "pc_beeper_driver"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.47"
|
||||
|
|
|
@ -4,6 +4,8 @@ members = [
|
|||
"drivers/basic_driver",
|
||||
"drivers/randomness_handler",
|
||||
|
||||
"drivers/audio/pc_beeper_driver",
|
||||
|
||||
"drivers/graphics/derelict_microarchitecture",
|
||||
"drivers/graphics/ground",
|
||||
"drivers/graphics/novideo",
|
||||
|
@ -13,6 +15,7 @@ members = [
|
|||
"drivers/mice/ps2_mouse",
|
||||
|
||||
"libraries/able_graphics_library",
|
||||
"libraries/audio_interface",
|
||||
"libraries/clparse",
|
||||
"libraries/cryptography",
|
||||
"libraries/locale-maxima",
|
||||
|
|
2
drivers/audio/pc_beeper_driver/.cargo/config.toml
Normal file
2
drivers/audio/pc_beeper_driver/.cargo/config.toml
Normal file
|
@ -0,0 +1,2 @@
|
|||
[build]
|
||||
target = "wasm32-unknown-unknown"
|
8
drivers/audio/pc_beeper_driver/Cargo.toml
Normal file
8
drivers/audio/pc_beeper_driver/Cargo.toml
Normal file
|
@ -0,0 +1,8 @@
|
|||
[package]
|
||||
name = "pc_beeper_driver"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
7
drivers/audio/pc_beeper_driver/src/main.rs
Normal file
7
drivers/audio/pc_beeper_driver/src/main.rs
Normal file
|
@ -0,0 +1,7 @@
|
|||
#![no_std]
|
||||
#![no_main]
|
||||
|
||||
#[no_mangle]
|
||||
fn start() {
|
||||
// Simple driver
|
||||
}
|
|
@ -9,6 +9,7 @@ pub mod color;
|
|||
pub mod cursor;
|
||||
pub mod engine3d;
|
||||
pub mod ptmode;
|
||||
pub mod raw_pixel;
|
||||
|
||||
pub const VERSION: versioning::Version = versioning::Version {
|
||||
major: 0,
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
|
18
libraries/able_graphics_library/src/raw_pixel/mod.rs
Normal file
18
libraries/able_graphics_library/src/raw_pixel/mod.rs
Normal file
|
@ -0,0 +1,18 @@
|
|||
use alloc::vec::Vec;
|
||||
|
||||
pub struct Color {
|
||||
r: u8,
|
||||
g: u8,
|
||||
b: u8,
|
||||
a: u8,
|
||||
}
|
||||
|
||||
pub struct PixelBuffer {
|
||||
width: usize,
|
||||
height: usize,
|
||||
data: Vec<Color>,
|
||||
}
|
||||
impl PixelBuffer {
|
||||
pub fn xy_calc(x: usize, y: isize) {}
|
||||
pub fn blit(&mut self, x: isize, y: isize, buff: PixelBuffer) {}
|
||||
}
|
8
libraries/audio_interface/Cargo.toml
Normal file
8
libraries/audio_interface/Cargo.toml
Normal file
|
@ -0,0 +1,8 @@
|
|||
[package]
|
||||
name = "audio_interface"
|
||||
version = "0.1.0"
|
||||
edition = "2021"
|
||||
|
||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||
|
||||
[dependencies]
|
38
libraries/audio_interface/src/lib.rs
Normal file
38
libraries/audio_interface/src/lib.rs
Normal file
|
@ -0,0 +1,38 @@
|
|||
pub struct AudioObject {
|
||||
// Play one bit per this interval
|
||||
playback_speed: u64,
|
||||
playback_ring: [u8; 2048],
|
||||
paused: bool,
|
||||
}
|
||||
impl AudioInterface for AudioObject {
|
||||
fn pause(&mut self) -> Result<(), AudioErrors> {
|
||||
self.paused = true;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn play() -> Result<(), AudioErrors> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn stop() -> Result<(), AudioErrors> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn fill_playback_buffer(&mut self, playback_slice: [u8; 128]) -> Result<(), AudioErrors> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
pub enum AudioErrors {
|
||||
EmptyPlaybackBuffer,
|
||||
}
|
||||
|
||||
pub trait AudioInterface {
|
||||
fn pause(&mut self) -> Result<(), AudioErrors>;
|
||||
fn play() -> Result<(), AudioErrors>;
|
||||
|
||||
// Stop will clear the buffer and stop playback
|
||||
fn stop() -> Result<(), AudioErrors>;
|
||||
|
||||
fn fill_playback_buffer(&mut self, playback_slice: [u8; 128]) -> Result<(), AudioErrors>;
|
||||
}
|
|
@ -10,12 +10,12 @@ unsafe extern "C" fn _start() -> ! {
|
|||
|
||||
main(0, core::ptr::null());
|
||||
|
||||
asm!(
|
||||
"syscall",
|
||||
in("rax") 60,
|
||||
in("rdi") 0,
|
||||
options(noreturn)
|
||||
);
|
||||
// asm!(
|
||||
// "syscall",
|
||||
// in("rax") 60,
|
||||
// in("rdi") 0,
|
||||
// options(noreturn)
|
||||
// );
|
||||
}
|
||||
|
||||
#[lang = "start"]
|
||||
|
|
9
libraries/std/src/env.rs
Normal file
9
libraries/std/src/env.rs
Normal file
|
@ -0,0 +1,9 @@
|
|||
pub struct Args {
|
||||
pub inner: [u8; 10],
|
||||
}
|
||||
|
||||
pub fn args() -> Args {
|
||||
Args {
|
||||
inner: [65, 66, 65, 66, 65, 65, 66, 65, 66, 65],
|
||||
}
|
||||
}
|
12
libraries/std/src/io.rs
Normal file
12
libraries/std/src/io.rs
Normal file
|
@ -0,0 +1,12 @@
|
|||
pub enum IOErrors {
|
||||
UnknownError,
|
||||
}
|
||||
|
||||
pub struct Port<T> {
|
||||
inner: T,
|
||||
}
|
||||
impl<T> Port<T> {
|
||||
pub fn read(&self) -> Result<T, IOErrors> {
|
||||
Ok(self.inner)
|
||||
}
|
||||
}
|
|
@ -3,6 +3,8 @@
|
|||
#![no_std]
|
||||
|
||||
mod entry;
|
||||
pub mod env;
|
||||
pub mod io;
|
||||
pub mod panic;
|
||||
|
||||
use core::arch::asm;
|
||||
|
@ -31,3 +33,19 @@ pub fn print(s: &str) {
|
|||
);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn print_char(c: char) {
|
||||
let array = [c];
|
||||
|
||||
unsafe {
|
||||
asm!(
|
||||
"syscall",
|
||||
in("rax") 1,
|
||||
in("rdi") 1,
|
||||
in("rsi") array.as_ptr(),
|
||||
in("rdx") 1,
|
||||
out("rcx") _,
|
||||
out("r11") _,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,18 @@
|
|||
use core::arch::asm;
|
||||
|
||||
#[panic_handler]
|
||||
fn panic_handler(pinfo: &core::panic::PanicInfo) -> ! {
|
||||
print("PANIC!");
|
||||
print("PANIC!\n");
|
||||
|
||||
// #[cfg(unix)]
|
||||
unsafe {
|
||||
asm!(
|
||||
"syscall",
|
||||
in("rax") 231,
|
||||
in("rdi") 1,
|
||||
options(noreturn)
|
||||
);
|
||||
}
|
||||
|
||||
loop {}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
pub use core::prelude::v1::*;
|
||||
|
||||
pub use crate::print;
|
||||
pub use crate::print_char;
|
||||
|
||||
pub use core::panic;
|
||||
|
||||
|
|
|
@ -1,2 +1,2 @@
|
|||
cargo +nightly xbuild -p std_test --target std_test/bare-x86_64.json;
|
||||
cargo +nightly xbuild -p std_test --target std_test/bare-x86_64.json && \
|
||||
../target/bare-x86_64/debug/std_test
|
|
@ -1,4 +1,14 @@
|
|||
use std::{
|
||||
env::{self, args},
|
||||
print_char,
|
||||
};
|
||||
|
||||
fn main() {
|
||||
for x in args().inner {
|
||||
print_char(x as char);
|
||||
}
|
||||
print_char(b'\n' as char);
|
||||
|
||||
print("Hello, world!\n");
|
||||
|
||||
panic!("Broken");
|
||||
|
|
Loading…
Reference in a new issue