broken cbfa to fix for a while

This commit is contained in:
FantasyPvP
2023-11-26 13:34:53 +00:00
parent b28b53418a
commit b16ce4a6f2
21 changed files with 86 additions and 601 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
use x86_64::structures::idt::{InterruptDescriptorTable, InterruptStackFrame};
use crate::{print, println};
use crate::kernel::gdt;
use super::gdt;
use lazy_static::lazy_static;
use spin;
use pic8259::ChainedPics;
@@ -42,7 +42,7 @@ extern "x86-interrupt" fn keyboard_interrupt_handler(_stack_frame: InterruptStac
let mut port = Port::new(0x60);
let scancode: u8 = unsafe { port.read() };
crate::kernel::tasks::keyboard::add_scancode(scancode);
super::tasks::keyboard::add_scancode(scancode);
unsafe {
PICS.lock().notify_end_of_interrupt(InterruptIndex::Keyboard.as_u8());
+1 -1
View File
@@ -6,7 +6,7 @@ use volatile::Volatile;
use alloc::borrow::ToOwned;
use alloc::vec;
use alloc::vec::Vec;
use crate::kernel::render::RenderError::InvalidRenderMode;
use crate::system::kernel::render::RenderError::InvalidRenderMode;
use crate::serial_println;
use crate::std::io::Screen;
+1 -20
View File
@@ -15,7 +15,7 @@ lazy_static! {
}
#[doc(hidden)]
pub fn _print(args: core::fmt::Arguments) {
pub fn _serial_print(args: core::fmt::Arguments) {
use core::fmt::Write;
use x86_64::instructions::interrupts;
@@ -38,22 +38,3 @@ pub fn serial_reply(chr: char) -> char {
chr_return
}
#[macro_export]
macro_rules! serial_print {
($($arg:tt)*) => {
$crate::kernel::serial::_print(format_args!($($arg)*));
};
}
#[macro_export]
macro_rules! serial_println {
() => (serial_print!("\n"));
($fmt:expr) => ($crate::serial_print!(concat!($fmt, "\n")));
($fmt:expr, $($arg:tt)*) => (
$crate::serial_print!(
concat!($fmt, "\n"), $($arg)*
)
);
}
+1 -1
View File
@@ -13,7 +13,7 @@ use futures_util::task::AtomicWaker;
use futures_util::stream::StreamExt;
use pc_keyboard::{layouts, DecodedKey, HandleControl, Keyboard, ScancodeSet1, KeyCode};
use crate::print;
use crate::kernel::render::RENDERER;
use crate::system::kernel::render::RENDERER;
use alloc::{string::String};
static WAKER: AtomicWaker = AtomicWaker::new();
+15 -3
View File
@@ -1,10 +1,22 @@
pub mod std;
pub mod kernel;
use bootloader::BootInfo;
use x86_64::VirtAddr;
use crate::system::kernel::{allocator, memory};
use crate::system::kernel::memory::BootInfoFrameAllocator;
pub fn init() {
pub mod std;
mod kernel;
pub fn init(boot_info : &'static BootInfo) {
kernel::gdt::init();
kernel::interrupts::init_idt();
unsafe { kernel::interrupts::PICS.lock().initialize() };
x86_64::instructions::interrupts::enable();
kernel::sysinit::init().unwrap();
let physical_memory_offset = VirtAddr::new(boot_info.physical_memory_offset);
let mut mapper = unsafe { memory::init(physical_memory_offset) };
let mut frame_allocator = unsafe { BootInfoFrameAllocator::init(&boot_info.memory_map) };
allocator::init_heap(&mut mapper, &mut frame_allocator).expect("heap initialisation failed");
}
+3 -8
View File
@@ -1,10 +1,7 @@
use alloc::string::String;
use alloc::vec;
use alloc::vec::Vec;
use lazy_static::lazy_static;
use crate::kernel::render::{BUFFER_HEIGHT, BUFFER_WIDTH, ColorCode, RENDERER, ScreenChar};
use crate::{println, serial_println};
use spin::Mutex;
use crate::system::kernel::render::{BUFFER_HEIGHT, BUFFER_WIDTH, RENDERER, ScreenChar};
use crate::std::io::{Color, Screen};
/// TODO: get a working implementation for CLI apps
@@ -13,11 +10,9 @@ use crate::std::io::{Color, Screen};
/// the position of the element by passing a tuple (x,y) to render()
///
/// nothing will appear on the screen until the frame is actually rendered by
/// the render_frame method on the renderer
pub use crate::system::kernel::render::{special_char, RenderError};
/// the write_to_screen() method on the renderer
pub use crate::system::kernel::render::{special_char, RenderError, ColorCode};
#[derive(Clone, Copy, Debug, PartialEq)]
+29 -13
View File
@@ -1,20 +1,17 @@
use crate::{
kernel::render::{RENDERER, self},
kernel::tasks::keyboard::{KEYBOARD},
use crate::system::kernel::{
render::{RENDERER, self, RenderError},
tasks::keyboard::{KEYBOARD},
serial::{serial_reply},
};
pub use crate::system::kernel::{
tasks::keyboard::KeyStroke,
serial::{_serial_print},
render::{Color, ColorCode},
};
pub use crate::kernel::tasks::keyboard::KeyStroke;
use alloc::string::String;
use alloc::vec::Vec;
pub use crate::{print, println, serial_print, serial_println};
pub use crate::kernel::render::Color;
use crate::kernel::serial::serial_reply;
use lazy_static::lazy_static;
use spin::Mutex;
use crate::kernel::render::Renderer;
use crate::std::frame::RenderError;
pub struct Stdin {}
impl Stdin {
@@ -109,6 +106,25 @@ macro_rules! printerr {
($($arg:tt)*) => ($crate::std::io::_printerr(format_args!($($arg)*)));
}
#[macro_export]
macro_rules! serial_print {
($($arg:tt)*) => {
$crate::std::io::_serial_print(format_args!($($arg)*));
};
}
#[macro_export]
macro_rules! serial_println {
() => (serial_print!("\n"));
($fmt:expr) => ($crate::serial_print!(concat!($fmt, "\n")));
($fmt:expr, $($arg:tt)*) => (
$crate::serial_print!(
concat!($fmt, "\n"), $($arg)*
)
);
}
#[doc(hidden)]
pub fn _print(args: core::fmt::Arguments) {
render::write(args, (Color::White, Color::Black));
+1
View File
@@ -5,6 +5,7 @@ pub mod tasks;
pub mod os;
pub mod frame;
pub mod time;
pub mod syscall;
// this is where the standard library for the operating system will be defined
+7
View File
@@ -0,0 +1,7 @@
/// THIS FILE IS ONLY FOR SPECIFIC CASES WHERE THE MAIN FUNCTION NEEDS DIRECT KERNEL INTERACTION
use crate::system::kernel::render::RENDERER;
pub fn terminal_mode_force() {
RENDERER.lock().terminal_mode_force();
}
+1 -1
View File
@@ -1,4 +1,4 @@
pub use crate::kernel::tasks::{Task, executor::Executor};
pub use crate::system::kernel::tasks::{Task, executor::Executor};
pub fn stop() -> ! {
loop {