1
0
Fork 0
forked from koniifer/ableos
This commit is contained in:
Elfein Landers 2022-02-03 20:03:28 -08:00
commit 8fea0bd6b8
8 changed files with 324 additions and 276 deletions

View file

@ -77,7 +77,14 @@ impl ScreenBuffer {
} }
} }
} }
pub fn draw_unfilled_rect(&mut self, x1: usize, y1: usize, x2: usize, y2: usize, color: Rgba64) { pub fn draw_unfilled_rect(
&mut self,
x1: usize,
y1: usize,
x2: usize,
y2: usize,
color: Rgba64,
) {
// x1 y1 => x2 y1 => x2 y2 => x1 y2 => x1 y1 // x1 y1 => x2 y1 => x2 y2 => x1 y2 => x1 y1
self.draw_line(x1, y1, x2, y1, color); self.draw_line(x1, y1, x2, y1, color);
self.draw_line(x2, y1, x2, y2, color); self.draw_line(x2, y1, x2, y2, color);
@ -203,8 +210,6 @@ impl VgaBuffer for ScreenBuffer {
for y in 0..self.size.y { for y in 0..self.size.y {
for x in 0..self.size.x { for x in 0..self.size.x {
use shadeable::pixel_format::into_vga_16; use shadeable::pixel_format::into_vga_16;
// let vga_color = get_color16(self.buff[y * self.size.x + x]);
let vga_color = into_vga_16(self.buff[y * self.size.x + x]); let vga_color = into_vga_16(self.buff[y * self.size.x + x]);
if into_vga_16(self.clear_color) != vga_color { if into_vga_16(self.clear_color) != vga_color {

View file

@ -1,5 +1,11 @@
#![allow(clippy::empty_loop)] #![allow(clippy::empty_loop)]
use alloc::{format, string::String};
use shadeable::pixel_format::from_vga_16;
use vga::colors::Color16;
use crate::{ScreenBuffer, VgaBuffer, SCREEN_BUFFER};
// use crate::scheduler; // use crate::scheduler;
use { use {
@ -17,10 +23,7 @@ use {
relib::network::socket::Socket, relib::network::socket::Socket,
scheduler::SCHEDULER, scheduler::SCHEDULER,
}, },
alloc::{ alloc::{string::ToString, vec},
string::{String, ToString},
vec,
},
core::sync::atomic::{AtomicU64, Ordering::*}, core::sync::atomic::{AtomicU64, Ordering::*},
lazy_static::lazy_static, lazy_static::lazy_static,
log::*, log::*,
@ -57,30 +60,6 @@ pub fn kernel_main() -> ! {
use crate::proto_filetable::file::FileLocations; use crate::proto_filetable::file::FileLocations;
let mut file_table = FILE_TABLE.lock(); let mut file_table = FILE_TABLE.lock();
/*
let mut new_file = File::new(FileLocations::Bin, "test".to_string(), "txt".to_string());
new_file.write_bytes(b"Hello, world!");
file_table.add_file("test", new_file);
let file = file_table.get_file("test");
match file {
Some(file) => {
let file_bytes = &file.data_pointer;
let file_string = String::from_utf8(file_bytes.to_vec()).unwrap();
info!("{}", file_string);
}
None => {
info!("File not found");
}
}
*/
let mut new_file = File::new(FileLocations::Bin, "test".to_string(), "txt".to_string()); let mut new_file = File::new(FileLocations::Bin, "test".to_string(), "txt".to_string());
new_file.write_bytes(&[0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00]); new_file.write_bytes(&[0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00]);
@ -101,7 +80,15 @@ pub fn kernel_main() -> ! {
} }
} }
log_version_data(); let mut abcde = SCREEN_BUFFER.lock();
abcde.force_redraw();
abcde.draw_filled_circle(100, 100, 300, 0x0000ffff);
abcde.draw_unfilled_rect(100, 100, 400, 200, 0xff0000ff);
abcde.draw_filled_rect(300, 300, 400, 400, 0xff0000ff);
abcde.draw_line(100, 100, 400, 200, 0xff0000ff);
abcde.copy_to_buffer();
sloop() sloop()
} }

View file

@ -1,37 +0,0 @@
use crate::proc::PID;
#[repr(C)]
/// Signals that can be sent to a process
pub enum Signals {
/// Terminate the process
Terminate,
/// Shutdown the process and allow it to shutdown cleanly
Quit,
}
#[repr(C)]
pub enum SystemCall {
/// Sleep the calling process for the given number of milliseconds
///
/// # Arguments
///
/// * `ticks` - The number of ticks to sleep for
Sleep(u64),
/// Send a signal to a process
///
/// # Arguments
///
/// * `pid` - The PID of the process to send the signal to
/// * `signal` - The signal to send
SendSignal(PID, Signals),
}
#[no_mangle]
pub extern "C" fn syscall(call: SystemCall) {
// Handle the system call
match call {
SystemCall::Sleep(ms) => todo!("Sleep for {} ms", ms),
SystemCall::SendSignal(process_id, signal) => todo!(),
}
}

View file

@ -0,0 +1,40 @@
//! File system related system calls.
/// Temporary representation of a file path
pub type Path = *const u8;
/// Remove a Directory from the filesystem
///
/// # Arguments
/// * `full_path` - The full path of the directory to remove
/// * `force` - Whether to remove the directory even if it is not empty
#[no_mangle]
pub extern "C" fn remove_directory(path: Path, force_delete: bool) {
unimplemented!();
}
/// Create a new directory at the given path
///
/// # Arguments
/// * `full_path` - The full path of the directory to create
#[no_mangle]
pub extern "C" fn create_directory(path: Path) -> Result<(), FileErrors> {
unimplemented!();
}
#[repr(C)]
/// Errors that can occur when messing with files
pub enum FileErrors {
/// The directory can not be created
DirectoryCouldNotBeCreated,
/// The directory could not be removed
DirectoryCouldNotBeRemoved,
///
FileCouldNotBeCreated,
///
FileCouldNotBeRemoved,
/// The file could not be opened
FileCouldNotBeOpened,
///
FileCouldNotBeClosed,
}

View file

@ -0,0 +1,25 @@
#![deny(missing_docs)]
//! The module of syscalls.
use crate::proc::PID;
pub mod file_calls;
pub mod time_calls;
#[repr(C)]
/// Signals that can be sent to a process
pub enum Signals {
/// Terminate the process
Terminate,
/// Shutdown the process and allow it to shutdown cleanly
Quit,
}
/// Send a signal to a process
///
/// # Arguments
///
/// * `pid` - The PID of the process to send the signal to
/// * `signal` - The signal to send
#[no_mangle]
pub extern "C" fn send_signal(pid: PID, signal: Signals) {}

View file

@ -0,0 +1,28 @@
//! Time related system calls.
use core::panic;
/// Seconds and milliseconds since the Unix epoch.
#[repr(C)]
pub struct SecondsTime {
seconds: u64,
milliseconds: u64,
}
/// Sleep the calling process for the given number of milliseconds
#[no_mangle]
pub extern "C" fn sleep(time: SecondsTime) {
panic!("sleep is not implemented yet");
}
#[no_mangle]
/// Get the current time in seconds, milliseconds
pub extern "C" fn get_time() -> SecondsTime {
panic!("get_time not implemented");
}
#[no_mangle]
/// Set the current time in seconds, milliseconds
pub extern "C" fn set_time(time: SecondsTime) {
panic!("set_time not implemented");
}

View file

@ -3,7 +3,7 @@
//! This module contains the virtio device structural code. //! This module contains the virtio device structural code.
//! //!
//! # Notes //! # Notes
//! https://docs.oasis-open.org/virtio/virtio/v1.1/csprd01/virtio-v1.1-csprd01.html#x1-20001 //! <https://docs.oasis-open.org/virtio/virtio/v1.1/csprd01/virtio-v1.1-csprd01.html#x1-20001>
pub struct VirtioDevice { pub struct VirtioDevice {
status: VirtioDeviceStatus, status: VirtioDeviceStatus,

View file

@ -92,7 +92,7 @@ impl WasmProgram {
/// # Examples /// # Examples
/// ``` /// ```
/// use wasm_loader::wasm::WasmProgram; /// use wasm_loader::wasm::WasmProgram;
/// let wasm_program = WasmProgram::new_from_bytes(b"\0\0\0\0\1\0\0\0"); /// let wasm_program = WasmProgram::new_from_bytes(b"\0\0\0\01\0\0\0");
/// assert_eq!(wasm_program.is_valid(), (true, false)); /// assert_eq!(wasm_program.is_valid(), (true, false));
/// ``` /// ```
pub fn validate_header(self) -> (bool, bool) { pub fn validate_header(self) -> (bool, bool) {