1
0
Fork 0
forked from koniifer/ableos

colorify function added

This commit is contained in:
Able 2021-12-24 13:00:20 -06:00
parent cddecccb4c
commit 914085fdf5
15 changed files with 182 additions and 109 deletions

View file

@ -1,2 +0,0 @@
cargo bootimage --target json_targets/x86_64-ableos.json && \
qemu-system-x86_64 -S -gdb tcp::9000 -drive format=raw,file=target/x86_64-ableos/debug/bootimage-ableos.bin

View file

@ -1,2 +0,0 @@
cargo bootimage --target json_targets/x86_64-ableos.json && \
qemu-system-x86_64 -drive format=raw,file=target/x86_64-ableos/debug/bootimage-ableos.bin

View file

@ -1,2 +0,0 @@
cargo bootimage --target json_targets/x86_64-ableos.json && \
qemu-system-x86_64 -drive format=raw,file=target/x86_64-ableos/debug/bootimage-ableos.bin

View file

@ -1,2 +0,0 @@
cargo bootimage --release --target json_targets/x86_64-ableos.json && \
qemu-system-x86_64 -drive format=raw,file=target/x86_64-ableos/release/bootimage-ableos.bin

View file

@ -1,5 +1,5 @@
pub mod allocator; pub mod allocator;
pub mod graphics; pub mod graphics;
pub mod serial; pub mod serial;
#[deprecated(note = "The use of hardware specific drivers for VGA is discouraged")] // #[deprecated(note = "The use of hardware specific drivers for VGA is discouraged")]
pub mod vga; pub mod vga;

View file

@ -106,10 +106,7 @@ lazy_static! {
buffer: unsafe { &mut *(0xb8000 as *mut Buffer) }, buffer: unsafe { &mut *(0xb8000 as *mut Buffer) },
}); });
} }
#[allow(dead_code)]
pub fn set_vga_color() {
WRITER.lock().color_code = ColorCode::new(Color::White, Color::Yellow);
}
use core::fmt; use core::fmt;
use lazy_static::lazy_static; use lazy_static::lazy_static;
use spin::Mutex; use spin::Mutex;
@ -131,3 +128,7 @@ pub fn _kprint(args: fmt::Arguments) {
WRITER.lock().write_fmt(args).unwrap(); WRITER.lock().write_fmt(args).unwrap();
}); });
} }
pub fn set_vga_color(fg: Color, bg: Color) {
WRITER.lock().color_code = ColorCode::new(fg, bg);
}

View file

@ -23,8 +23,8 @@ pub fn start(boot_info: &'static BootInfo) -> ! {
let page = Page::containing_address(VirtAddr::new(0xdeadbeaf000)); let page = Page::containing_address(VirtAddr::new(0xdeadbeaf000));
memory::create_example_mapping(page, &mut mapper, &mut frame_allocator); memory::create_example_mapping(page, &mut mapper, &mut frame_allocator);
let page_ptr: *mut u64 = page.start_address().as_mut_ptr(); // let page_ptr: *mut u64 = page.start_address().as_mut_ptr();
unsafe { page_ptr.offset(400).write_volatile(0xf021_f077_f065_804e) }; // unsafe { page_ptr.offset(400).write_volatile(0xf021_f077_f065_804e) };
allocator::init_heap(&mut mapper, &mut frame_allocator).expect("heap initialization failed"); allocator::init_heap(&mut mapper, &mut frame_allocator).expect("heap initialization failed");

View file

@ -0,0 +1,63 @@
use crate::arch::drivers::vga::{set_vga_color, Color};
pub fn colorify(eval: &str) {
let y = eval.split("$");
for z in y {
match z {
"BLACK" => {
set_vga_color(Color::Black, Color::Black);
}
"RED" => {
set_vga_color(Color::Red, Color::Black);
}
"GREEN" => {
set_vga_color(Color::Green, Color::Black);
}
"BLUE" => {
set_vga_color(Color::Blue, Color::Black);
}
"CYAN" => {
set_vga_color(Color::Cyan, Color::Black);
}
"MAGENTA" => {
set_vga_color(Color::Magenta, Color::Black);
}
"BROWN" => {
set_vga_color(Color::Brown, Color::Black);
}
"LIGHTGRAY" => {
set_vga_color(Color::LightGray, Color::Black);
}
"DARKGRAY" => {
set_vga_color(Color::DarkGray, Color::Black);
}
"LIGHTBLUE" => {
set_vga_color(Color::LightBlue, Color::Black);
}
"LIGHTGREEN" => {
set_vga_color(Color::LightGreen, Color::Black);
}
"LIGHTCYAN" => {
set_vga_color(Color::LightCyan, Color::Black);
}
"LIGHTRED" => {
set_vga_color(Color::LightRed, Color::Black);
}
"PINK" => {
set_vga_color(Color::Pink, Color::Black);
}
"YELLOW" => {
set_vga_color(Color::Yellow, Color::Black);
}
"WHITE" => {
set_vga_color(Color::White, Color::Black);
}
"RESET" => {
set_vga_color(Color::White, Color::Black);
}
elk => {
print!("{}", elk);
}
}
}
}

View file

@ -1,5 +1,6 @@
#![allow(dead_code)] #![allow(dead_code)]
use crate::trace; use crate::trace;
// TODO: Evaluate variable sized mailboxes
pub struct MailBoxes { pub struct MailBoxes {
flags: u8, flags: u8,

View file

@ -1,5 +1,6 @@
#![allow(dead_code)] #![allow(dead_code)]
pub mod absi;
pub mod clip; pub mod clip;
pub mod server; pub mod server;
pub mod systeminfo; pub mod systeminfo;

View file

@ -1,5 +1,6 @@
#![allow(clippy::empty_loop)] #![allow(clippy::empty_loop)]
use crate::experiments::absi::colorify;
use { use {
crate::{ crate::{
arch::{drivers::graphics::GraphicsBuffer, init, sloop}, arch::{drivers::graphics::GraphicsBuffer, init, sloop},
@ -12,7 +13,6 @@ use {
alloc::vec, alloc::vec,
lazy_static::lazy_static, lazy_static::lazy_static,
}; };
#[no_mangle] #[no_mangle]
#[allow(unconditional_recursion)] #[allow(unconditional_recursion)]
pub extern "C" fn stack_overflow() -> u8 { pub extern "C" fn stack_overflow() -> u8 {
@ -31,6 +31,7 @@ lazy_static! {
#[no_mangle] #[no_mangle]
pub fn kernel_main() -> ! { pub fn kernel_main() -> ! {
init::init(); init::init();
let mut a_thread = Thread::new(); let mut a_thread = Thread::new();
a_thread.new_task(test_fn); a_thread.new_task(test_fn);
@ -46,6 +47,8 @@ pub fn kernel_main() -> ! {
println!("{} v{}", RELEASE_TYPE, KERNEL_VERSION); println!("{} v{}", RELEASE_TYPE, KERNEL_VERSION);
info!("{} v{}", RELEASE_TYPE, KERNEL_VERSION); info!("{} v{}", RELEASE_TYPE, KERNEL_VERSION);
colorify("$PINK$Hi$RED$ from$GREEN$ able");
// stack_overflow(); // stack_overflow();
// crate::arch::shutdown(); // crate::arch::shutdown();
sloop() sloop()

View file

@ -39,7 +39,6 @@ pub mod kmain;
pub mod panic; pub mod panic;
pub mod relib; pub mod relib;
pub mod scheduler; pub mod scheduler;
pub mod test;
pub mod wasm; pub mod wasm;
extern crate alloc; extern crate alloc;

View file

@ -72,7 +72,7 @@ impl ModuleImportResolver for HostFunctions {
} }
pub fn evaluate() { pub fn evaluate() {
let wasm_binary = include_bytes!("rust.wasm"); let wasm_binary = include_bytes!("zig.wasm");
// Load wasm binary and prepare it for instantiation. // Load wasm binary and prepare it for instantiation.
let module = wasmi::Module::from_buffer(&wasm_binary).expect("failed to load wasm"); let module = wasmi::Module::from_buffer(&wasm_binary).expect("failed to load wasm");

View file

@ -37,11 +37,22 @@ syscall_enum! {
GET_PID=6, // Get the proccess ID GET_PID=6, // Get the proccess ID
PROCESS_INFO=7, // Get information about the process PROCESS_INFO=7, // Get information about the process
//scheduler Related Syscals //scheduler Related Syscals
GET_PRIORITY=10, // Get scheduler priority GET_PRIORITY=8, // Get scheduler priority
SET_PRIORITY=11, // Set scheduler priority SET_PRIORITY=9, // Set scheduler priority
// //
GET_HOSTNAME=12, GET_HOSTNAME=10,
SET_HOSTNAME=13, SET_HOSTNAME=11,
NEW_THREAD=12,
NEW_TASK=13,
KILL_THREAD=14,
KILL_TASK=15,
GET_THREAD=16,
GET_TASK=17,
SEND= 18,
RECEIVE = 19,
RESPOND = 20,
//File Related syscalls //File Related syscalls
// //
@ -65,7 +76,6 @@ syscall_enum! {
GET_TIME=36, // Gets the system time (some derivitive of seconds) GET_TIME=36, // Gets the system time (some derivitive of seconds)
SET_TIME=37, // Sets the system time (some derivitive of seconds) SET_TIME=37, // Sets the system time (some derivitive of seconds)
// Socket SysCall // Socket SysCall
SOCKET_BIND=39, // Used by servers to lock a port SOCKET_BIND=39, // Used by servers to lock a port
SOCKET_CONNECT=40, SOCKET_CONNECT=40,
@ -73,6 +83,9 @@ syscall_enum! {
SOCKET_SEND=42, SOCKET_SEND=42,
SOCKET_RECEIVE=43, SOCKET_RECEIVE=43,
EXIT=50, EXIT=50,
EMPTY=0xFFFF, EMPTY=0xFFFF,
} }

BIN
ableos/src/wasm/zig.wasm Normal file

Binary file not shown.