forked from AbleOS/ableos
redux
This commit is contained in:
parent
ac8f047643
commit
46e30e7297
|
@ -1,13 +1,5 @@
|
|||
#![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::{
|
||||
arch::{init, sloop},
|
||||
|
@ -18,15 +10,22 @@ use {
|
|||
info::master,
|
||||
systeminfo::{KERNEL_VERSION, RELEASE_TYPE},
|
||||
},
|
||||
file::{File, PathRep},
|
||||
relib::network::socket::SimpleSock,
|
||||
relib::network::socket::Socket,
|
||||
file::PathRep,
|
||||
relib::network::socket::{SimpleSock, Socket},
|
||||
scheduler::SCHEDULER,
|
||||
VgaBuffer, SCREEN_BUFFER,
|
||||
},
|
||||
alloc::{
|
||||
format,
|
||||
string::{String, ToString},
|
||||
vec,
|
||||
},
|
||||
alloc::{string::ToString, vec},
|
||||
core::sync::atomic::{AtomicU64, Ordering::*},
|
||||
facepalm::start_facepalm,
|
||||
lazy_static::lazy_static,
|
||||
log::*,
|
||||
shadeable::pixel_format::from_vga_16,
|
||||
vga::colors::Color16,
|
||||
};
|
||||
|
||||
lazy_static! {
|
||||
|
@ -40,54 +39,41 @@ pub fn kernel_main() -> ! {
|
|||
init::init();
|
||||
log::set_max_level(BOOT_CONF.log_level());
|
||||
|
||||
use crate::scheduler::Priority;
|
||||
let mut scheduler = SCHEDULER.lock();
|
||||
{
|
||||
{
|
||||
let mut scheduler = SCHEDULER.lock();
|
||||
|
||||
use Priority::*;
|
||||
|
||||
let mut process_1 = scheduler.new_process(High);
|
||||
process_1.capabilities.files = FileAccess::Some(vec![PathRep {
|
||||
location: FileLocations::Home,
|
||||
file_name: "test".to_string(),
|
||||
}]);
|
||||
scheduler.add_process(process_1);
|
||||
for ref_process in &scheduler.list {
|
||||
trace!("{:?}", ref_process);
|
||||
}
|
||||
drop(scheduler);
|
||||
|
||||
use crate::proto_filetable::contain::FILE_TABLE;
|
||||
use crate::proto_filetable::file::FileLocations;
|
||||
|
||||
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(&[0x00, 0x61, 0x73, 0x6d, 0x01, 0x00, 0x00, 0x00]);
|
||||
file_table.add_file("wasm_test", new_file);
|
||||
|
||||
let file = file_table.get_file("wasm_test");
|
||||
|
||||
match file {
|
||||
Some(file) => {
|
||||
let file_bytes = &file.data_pointer;
|
||||
|
||||
use crate::wasm::WasmProgram;
|
||||
let ret = WasmProgram::new_from_bytes(file_bytes);
|
||||
trace!("Binary Valid: {:?}", ret.validate_header());
|
||||
use crate::scheduler::Priority::*;
|
||||
let mut process_1 = scheduler.new_process(High);
|
||||
process_1.capabilities.files = FileAccess::Some(vec![PathRep {
|
||||
location: FileLocations::Home,
|
||||
file_name: "test".to_string(),
|
||||
}]);
|
||||
scheduler.add_process(process_1);
|
||||
for ref_process in &scheduler.list {
|
||||
trace!("{:?}", ref_process);
|
||||
}
|
||||
drop(scheduler);
|
||||
}
|
||||
None => {
|
||||
info!("File not found");
|
||||
|
||||
use crate::proto_filetable::file::FileLocations;
|
||||
|
||||
{
|
||||
let mut sock_print_id = SimpleSock::new();
|
||||
sock_print_id.register_protocol("Screen Printer".to_string());
|
||||
sock_print_id.write(format!("🐑").into());
|
||||
|
||||
let mut mode = SCREEN_BUFFER.lock();
|
||||
|
||||
mode.force_redraw();
|
||||
for current in (*String::from_utf8_lossy(&sock_print_id.peek().unwrap())).chars() {
|
||||
mode.draw_char(0, 0, current, from_vga_16(Color16::Red));
|
||||
}
|
||||
mode.copy_to_buffer();
|
||||
}
|
||||
}
|
||||
|
||||
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();
|
||||
start_facepalm();
|
||||
|
||||
sloop()
|
||||
}
|
||||
|
|
|
@ -16,4 +16,6 @@ pub fn start_facepalm() {
|
|||
info!("facepalm 🤦 launched!");
|
||||
info!("facepalm 🤦 version: {}", VERSION);
|
||||
info!("facepalm 🤦 {} mode", RELEASE_TYPE);
|
||||
|
||||
// Drop into a debug shell
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue