Move serial driver to arch::x86_64::dev::serial
This commit is contained in:
Generated
+63
@@ -29,6 +29,31 @@ dependencies = [
|
||||
"shlex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam"
|
||||
version = "0.8.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1137cd7e7fc0fb5d3c5a8678be38ec56e819125d8d7907411fe24ccb943faca8"
|
||||
dependencies = [
|
||||
"crossbeam-queue",
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-queue"
|
||||
version = "0.3.12"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0f58bbc28f91df819d0aa2a2c00cd19754769c2fad90579b3592b1c9ba7a3115"
|
||||
dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "crossbeam-utils"
|
||||
version = "0.8.21"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d0a5c400df2834b80a4c3327b3aad3a4c4cd4de0629063962b03235697506a28"
|
||||
|
||||
[[package]]
|
||||
name = "darling"
|
||||
version = "0.20.10"
|
||||
@@ -75,6 +100,8 @@ name = "foundry_os"
|
||||
version = "0.1.0"
|
||||
dependencies = [
|
||||
"cc",
|
||||
"crossbeam",
|
||||
"futures-util",
|
||||
"libm",
|
||||
"limine",
|
||||
"pc-keyboard",
|
||||
@@ -83,6 +110,30 @@ dependencies = [
|
||||
"x86_64",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "futures-core"
|
||||
version = "0.3.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "05f29059c0c2090612e8d742178b0580d2dc940c837851ad723096f87af6663e"
|
||||
|
||||
[[package]]
|
||||
name = "futures-task"
|
||||
version = "0.3.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f90f7dce0722e95104fcb095585910c0977252f286e354b5e3bd38902cd99988"
|
||||
|
||||
[[package]]
|
||||
name = "futures-util"
|
||||
version = "0.3.31"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9fa08315bb612088cc391249efdc3bc77536f16c91f6cf495e6fbe85b20a4a81"
|
||||
dependencies = [
|
||||
"futures-core",
|
||||
"futures-task",
|
||||
"pin-project-lite",
|
||||
"pin-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ident_case"
|
||||
version = "1.0.1"
|
||||
@@ -133,6 +184,18 @@ dependencies = [
|
||||
"x86_64",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pin-project-lite"
|
||||
version = "0.2.16"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "3b3cff922bd51709b605d9ead9aa71031d81447142d828eb4a6eba76fe619f9b"
|
||||
|
||||
[[package]]
|
||||
name = "pin-utils"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.93"
|
||||
|
||||
@@ -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