Move serial driver to arch::x86_64::dev::serial
This commit is contained in:
@@ -12,6 +12,13 @@ spin = "0.9.8"
|
||||
pic8259 = "0.11.0"
|
||||
pc-keyboard = "0.8.0"
|
||||
libm = { version = "0.1.0", path = "../libm" }
|
||||
crossbeam = { version = "0.8.4", default-features = false, features = [
|
||||
# "alloc",
|
||||
"crossbeam-queue",
|
||||
] }
|
||||
futures-util = { version = "0.3.31", default-features = false, features = [
|
||||
# "alloc",
|
||||
] }
|
||||
|
||||
[build-dependencies]
|
||||
cc = "1.2.14"
|
||||
|
||||
@@ -1 +1,2 @@
|
||||
pub mod pic;
|
||||
pub mod serial;
|
||||
|
||||
@@ -8,7 +8,7 @@ use x86_64::instructions::interrupts;
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! serial_print {
|
||||
($($arg:tt)*) => ($crate::io::serial::_serial_write(format_args!($($arg)*)));
|
||||
($($arg:tt)*) => ($crate::arch::x86_64::dev::serial::_serial_write(format_args!($($arg)*)));
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
@@ -1,5 +1,4 @@
|
||||
//! Sets up a memory map using Limine.
|
||||
|
||||
use limine::{
|
||||
request::{HhdmRequest, KernelAddressRequest, MemoryMapRequest},
|
||||
response::MemoryMapResponse,
|
||||
|
||||
+20
-14
@@ -1,32 +1,36 @@
|
||||
/* use core::{
|
||||
use core::{
|
||||
pin::Pin,
|
||||
task::{Context, Poll},
|
||||
};
|
||||
|
||||
use crossbeam::queue::ArrayQueue;
|
||||
use futures_util::{Stream, StreamExt, task::AtomicWaker};
|
||||
use pc_keyboard::{
|
||||
DecodedKey, HandleControl, KeyCode, Keyboard, ScancodeSet1,
|
||||
layouts::{self, Uk105Key},
|
||||
};
|
||||
use spin::{Lazy, Mutex, Once};
|
||||
|
||||
// static KBD_QUEUE: Once<ArrayQueue<u8>> = Once::new();
|
||||
// static WAKER: AtomicWaker = AtomicWaker::new();
|
||||
static KBD_QUEUE: Once<ArrayQueue<u8>> = Once::new();
|
||||
static WAKER: AtomicWaker = AtomicWaker::new();
|
||||
|
||||
pub static KEYBOARD: Lazy<Mutex<Keyboard<Uk105Key, ScancodeSet1>>> = Lazy::new(|| {
|
||||
Mutex::new(Keyboard::new(
|
||||
ScancodeSet1::new(),
|
||||
// TODO: Expose an API to change the default KB layout.
|
||||
layouts::Uk105Key,
|
||||
HandleControl::Ignore,
|
||||
))
|
||||
});
|
||||
pub static KEYBOARD: Lazy<Mutex<Keyboard<Uk105Key, ScancodeSet1>>> =
|
||||
Lazy::new(|| {
|
||||
Mutex::new(Keyboard::new(
|
||||
ScancodeSet1::new(),
|
||||
// TODO: Expose an API to change the default KB layout.
|
||||
layouts::Uk105Key,
|
||||
HandleControl::Ignore,
|
||||
))
|
||||
});
|
||||
pub static SCANCODE_STREAM: Lazy<Mutex<ScancodeStream>> =
|
||||
Lazy::new(|| Mutex::new(ScancodeStream::new()));
|
||||
|
||||
pub fn add_scancode(scancode: u8) {
|
||||
if let Some(queue) = KBD_QUEUE.get() {
|
||||
if queue.push(scancode).is_err() {
|
||||
// println!("WARNING: scancode queue full; dropping keyboard input");
|
||||
// println!("WARNING: scancode queue full; dropping keyboard
|
||||
// input");
|
||||
} else {
|
||||
WAKER.wake();
|
||||
}
|
||||
@@ -59,7 +63,10 @@ impl Default for ScancodeStream {
|
||||
impl Stream for ScancodeStream {
|
||||
type Item = u8;
|
||||
|
||||
fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
|
||||
fn poll_next(
|
||||
self: Pin<&mut Self>,
|
||||
cx: &mut Context<'_>,
|
||||
) -> Poll<Option<Self::Item>> {
|
||||
let queue = KBD_QUEUE.get().unwrap();
|
||||
|
||||
if let Some(scancode) = queue.pop() {
|
||||
@@ -200,4 +207,3 @@ impl core::fmt::Display for KeyStroke {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
+1
-14
@@ -1,14 +1 @@
|
||||
pub mod keyboard;
|
||||
pub mod serial;
|
||||
|
||||
// Re-exported macro definitions.
|
||||
|
||||
/* pub use crate::print;
|
||||
pub use crate::print_log;
|
||||
pub use crate::printerr;
|
||||
pub use crate::println;
|
||||
pub use crate::println_log;
|
||||
pub use crate::printlnerr;
|
||||
pub use crate::serial_print;
|
||||
pub use crate::serial_println;
|
||||
*/
|
||||
// pub mod keyboard;
|
||||
|
||||
+1
-1
@@ -11,10 +11,10 @@
|
||||
rustdoc::missing_panics_doc
|
||||
)]
|
||||
|
||||
use arch::x86_64::dev::serial;
|
||||
use arch::x86_64::{gdt, interrupts};
|
||||
use core::arch::asm;
|
||||
use graphics::font::{FONT_SPLEEN_8X16, Font};
|
||||
use io::serial;
|
||||
use limine::BaseRevision;
|
||||
|
||||
pub mod arch;
|
||||
|
||||
Reference in New Issue
Block a user