forked from AbleOS/ableos
framebuffer + smp work
This commit is contained in:
parent
65bb92e02b
commit
e8712d7c39
|
@ -24,9 +24,17 @@ pub struct KernelConfig {
|
||||||
|
|
||||||
impl KernelConfig {
|
impl KernelConfig {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
toml::from_str(include_str!("../assets/kernel.toml")).unwrap()
|
KernelConfig::default()
|
||||||
|
}
|
||||||
|
pub fn load_from_string(toml_string: &str) -> Self {
|
||||||
|
match toml::from_str(toml_string) {
|
||||||
|
Ok(kernel_conf) => kernel_conf,
|
||||||
|
Err(err) => {
|
||||||
|
error!("Error {}", err);
|
||||||
|
KernelConfig::new()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn log_level(&self) -> LevelFilter {
|
pub fn log_level(&self) -> LevelFilter {
|
||||||
use LevelFilter::*;
|
use LevelFilter::*;
|
||||||
match self.logging.level {
|
match self.logging.level {
|
||||||
|
@ -42,7 +50,15 @@ impl KernelConfig {
|
||||||
|
|
||||||
impl Default for KernelConfig {
|
impl Default for KernelConfig {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self::new()
|
Self {
|
||||||
|
logging: LoggingConfig {
|
||||||
|
enabled: true,
|
||||||
|
log_to_serial: true,
|
||||||
|
log_to_vterm: false,
|
||||||
|
level: LogLevel::Trace,
|
||||||
|
filter: Vec::new(),
|
||||||
|
},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,9 @@ use crate::{boot_conf::KernelConfig, scratchpad, systeminfo::RELEASE_TYPE};
|
||||||
// use crate::{boot_conf::KernelConfig, scratchpad, systeminfo::RELEASE_TYPE, TERM};
|
// use crate::{boot_conf::KernelConfig, scratchpad, systeminfo::RELEASE_TYPE, TERM};
|
||||||
use crate::{filesystem, hardware};
|
use crate::{filesystem, hardware};
|
||||||
use kernel::KERNEL_VERSION;
|
use kernel::KERNEL_VERSION;
|
||||||
|
use limine::LimineSmpInfo;
|
||||||
|
use limine::{LimineFramebufferRequest, LimineSmpRequest};
|
||||||
|
|
||||||
use spin::Lazy;
|
use spin::Lazy;
|
||||||
|
|
||||||
// FIXME: platform agnostic paging stuff
|
// FIXME: platform agnostic paging stuff
|
||||||
|
@ -23,6 +26,8 @@ use x86_64::structures::paging::{Mapper, Size4KiB};
|
||||||
|
|
||||||
// TODO: Change this structure to allow for multiple cores loaded
|
// TODO: Change this structure to allow for multiple cores loaded
|
||||||
pub static KERNEL_CONF: Lazy<KernelConfig> = Lazy::new(KernelConfig::new);
|
pub static KERNEL_CONF: Lazy<KernelConfig> = Lazy::new(KernelConfig::new);
|
||||||
|
pub static FRAMEBUFFER: LimineFramebufferRequest = LimineFramebufferRequest::new(0);
|
||||||
|
pub static SMP: LimineSmpRequest = LimineSmpRequest::new(0);
|
||||||
|
|
||||||
/// The main entry point of the kernel
|
/// The main entry point of the kernel
|
||||||
pub fn kernel_main(
|
pub fn kernel_main(
|
||||||
|
@ -31,14 +36,20 @@ pub fn kernel_main(
|
||||||
) -> ! {
|
) -> ! {
|
||||||
init::init();
|
init::init();
|
||||||
|
|
||||||
// /*
|
{
|
||||||
|
// TODO: Setup config loaded from disk
|
||||||
|
let mut kptr = KERNEL_CONF.as_mut_ptr();
|
||||||
|
unsafe {
|
||||||
|
*kptr = KernelConfig::new();
|
||||||
|
}
|
||||||
|
}
|
||||||
if KERNEL_CONF.logging.enabled {
|
if KERNEL_CONF.logging.enabled {
|
||||||
log::set_max_level(KERNEL_CONF.log_level());
|
log::set_max_level(KERNEL_CONF.log_level());
|
||||||
// println!("{:#?}", *KERNEL_CONF);
|
// println!("{:#?}", *KERNEL_CONF);
|
||||||
} else {
|
} else {
|
||||||
log::set_max_level(log::LevelFilter::Off);
|
log::set_max_level(log::LevelFilter::Off);
|
||||||
}
|
}
|
||||||
// */
|
|
||||||
// let mut term = TERM.lock();
|
// let mut term = TERM.lock();
|
||||||
// term.initialize();
|
// term.initialize();
|
||||||
// term.set_dirty(true);
|
// term.set_dirty(true);
|
||||||
|
@ -83,46 +94,50 @@ pub fn kernel_main(
|
||||||
/*
|
/*
|
||||||
log_version_data();
|
log_version_data();
|
||||||
// */
|
// */
|
||||||
|
|
||||||
|
{
|
||||||
|
// TODO: setup a proper framebuffer handler
|
||||||
|
let fb_response = FRAMEBUFFER.get_response().get().unwrap();
|
||||||
|
for fb in fb_response.framebuffers().unwrap() {
|
||||||
|
trace!("Framebuffer {}x{}", fb.width, fb.height);
|
||||||
|
trace!("{}", fb.memory_model);
|
||||||
|
trace!("{}", fb.bpp);
|
||||||
|
let mut count = 0;
|
||||||
|
let total = fb.width * fb.height * 3;
|
||||||
|
while count != total {
|
||||||
|
unsafe {
|
||||||
|
let fb_ptr = fb.address.as_mut_ptr().unwrap();
|
||||||
|
*fb_ptr.offset((count).try_into().unwrap()) = 0xff;
|
||||||
|
*fb_ptr.offset((count + 1).try_into().unwrap()) = 0xff;
|
||||||
|
*fb_ptr.offset((count + 2).try_into().unwrap()) = 0xff;
|
||||||
|
*fb_ptr.offset((count + 3).try_into().unwrap()) = 0x00;
|
||||||
|
|
||||||
|
*fb_ptr.offset((count + 4).try_into().unwrap()) = 0x00;
|
||||||
|
*fb_ptr.offset((count + 5).try_into().unwrap()) = 0x00;
|
||||||
|
// *fb_ptr.offset((count + 6).try_into().unwrap()) = 0x00;
|
||||||
|
}
|
||||||
|
count += 6;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// SMP
|
||||||
|
{
|
||||||
|
let smp = SMP.get_response().get().unwrap();
|
||||||
|
for cpu in smp.cpus().unwrap() {
|
||||||
|
// unsafe {
|
||||||
|
// cpu.goto_address = *(trace_hcf as *const u64);
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
scratchpad();
|
scratchpad();
|
||||||
sloop()
|
sloop()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn traceloop() {
|
extern "C" fn trace_hcf(info: *const LimineSmpInfo) -> ! {
|
||||||
// TODO: Having an empty function double faults
|
trace!("CPU BOOT");
|
||||||
|
loop {}
|
||||||
// let mut last_time = 0.0;
|
|
||||||
/*
|
|
||||||
loop {
|
|
||||||
// FIXME: the following double faults
|
|
||||||
/*
|
|
||||||
let time = fetch_time();
|
|
||||||
if time > last_time {
|
|
||||||
last_time = time;
|
|
||||||
trace!("Timer");
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* TODO: This also double faults
|
|
||||||
let fs = &*crate::filesystem::FILE_SYSTEM.lock();
|
|
||||||
let path = format!("/home/able/bins/aos_test.wasm");
|
|
||||||
|
|
||||||
let home_exec_file = fs.open(&path.as_bytes(), OpenOptions::new().read(true));
|
|
||||||
|
|
||||||
drop(fs);
|
|
||||||
let mut binary_prog: Vec<u8> = vec![];
|
|
||||||
|
|
||||||
match home_exec_file {
|
|
||||||
Ok(file) => {
|
|
||||||
let ret = file.read_to_end(&mut binary_prog).unwrap();
|
|
||||||
}
|
|
||||||
_ => {}
|
|
||||||
}
|
|
||||||
|
|
||||||
wasm_jumploader::run_program(&binary_prog);
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn cpu_socket_startup() {
|
pub fn cpu_socket_startup() {
|
||||||
|
|
|
@ -5,7 +5,7 @@ ${ABLEOS_KERNEL}=boot:///boot/kernel
|
||||||
DEFAULT_ENTRY=1
|
DEFAULT_ENTRY=1
|
||||||
TIMEOUT=3
|
TIMEOUT=3
|
||||||
VERBOSE=yes
|
VERBOSE=yes
|
||||||
|
INTERFACE_RESOLUTION=800x600
|
||||||
# Terminal related settings
|
# Terminal related settings
|
||||||
# TERM_WALLPAPER=${WALLPAPER_PATH}
|
# TERM_WALLPAPER=${WALLPAPER_PATH}
|
||||||
TERM_BACKDROP=008080
|
TERM_BACKDROP=008080
|
||||||
|
@ -15,3 +15,5 @@ TERM_BACKDROP=008080
|
||||||
PROTOCOL=limine
|
PROTOCOL=limine
|
||||||
KERNEL_PATH=${ABLEOS_KERNEL}
|
KERNEL_PATH=${ABLEOS_KERNEL}
|
||||||
KERNEL_CMDLINE=
|
KERNEL_CMDLINE=
|
||||||
|
# Setting a default resolution for the framebuffer
|
||||||
|
RESOLUTION=800x600x24
|
||||||
|
|
Loading…
Reference in a new issue