diff --git a/Cargo.lock b/Cargo.lock index 5898ca55..c4225ccf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,14 +1,5 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -[[package]] -name = "array-init" -version = "0.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "23589ecb866b460d3a0f1278834750268c607e8e28a1b982c907219f3178cd72" -dependencies = [ - "nodrop", -] - [[package]] name = "autocfg" version = "1.0.0" @@ -42,23 +33,14 @@ dependencies = [ "spin", "uart_16550", "volatile", - "x86_64 0.8.1", + "x86_64", ] [[package]] name = "bootloader" -version = "0.8.3" +version = "0.8.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d596849a47f28abdea62d7a6a25c4f6e69c3d9b09b0a2877db6e9cda004ca993" - -[[package]] -name = "cast" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4b9434b9a5aa1450faa3f9cb14ea0e8c53bb5d2b3c1bfd1ab4fc03e9f33fbfb0" -dependencies = [ - "rustc_version", -] +checksum = "c3ed4f735c4e455ba86a3d2939b1c0729414153642106c9d035693355630a42c" [[package]] name = "cfg-if" @@ -141,24 +123,27 @@ dependencies = [ [[package]] name = "linked_list_allocator" -version = "0.6.6" +version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "47de1a43fad0250ee197e9e124e5b5deab3d7b39d4428ae8a6d741ceb340c362" +checksum = "18c618c431dfe4419afbe22852f6aceffbc17bd82ba0a18b982def291000824c" dependencies = [ - "spin", + "spinning_top", ] [[package]] -name = "nodrop" -version = "0.1.14" +name = "lock_api" +version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb" +checksum = "79b2de95ecb4691949fea4716ca53cdbcfccb2c612e19644a8bad05edcf9f47b" +dependencies = [ + "scopeguard", +] [[package]] name = "pc-keyboard" -version = "0.3.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fff50ab09ba31bcebc0669f4e64c0952fae1acdca9e6e0587e68e4e8443808ac" +checksum = "c48392db76c4e9a69e0b3be356c5f97ebb7b14413c5e4fd0af4755dbf86e2fce" [[package]] name = "pic8259_simple" @@ -176,28 +161,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "5894c618ce612a3fa23881b152b608bafb8c56cfc22f434a3ba3120b40f7b587" [[package]] -name = "rustc_version" -version = "0.2.3" +name = "scopeguard" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver", -] - -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" +checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "spin" @@ -206,20 +173,23 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" [[package]] -name = "uart_16550" -version = "0.2.1" +name = "spinning_top" +version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "803ea8cb602dbb32c1a657a866d2dd79fe7dbeab0fb2ac667cb4dcc7de12a58b" +checksum = "32d801a3a53bcf5071f85fef8d5cab9e5f638fc5580a37e6eb7aba4b37438d24" dependencies = [ - "bitflags", - "x86_64 0.7.7", + "lock_api", ] [[package]] -name = "ux" -version = "0.1.3" +name = "uart_16550" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "88dfeb711b61ce620c0cb6fd9f8e3e678622f0c971da2a63c4b3e25e88ed012f" +checksum = "d44b0f30cb82b0fbc15b78ade1064226529ad52028bc8cb8accb98ff6f3d7131" +dependencies = [ + "bitflags", + "x86_64", +] [[package]] name = "volatile" @@ -229,25 +199,10 @@ checksum = "6af0edf5b4faacc31fc51159244d78d65ec580f021afcef7bd53c04aeabc7f29" [[package]] name = "x86_64" -version = "0.7.7" +version = "0.9.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1f27d9168654aee1b0c1b73746caeb4aa33248f8b8c8f6e100e697fcc2a794b2" +checksum = "4206b60c9f99766329b66962aa8ddc01df6c7edd02edc046b7a69d5df9fcdbcf" dependencies = [ - "array-init", "bit_field", "bitflags", - "cast", - "ux", -] - -[[package]] -name = "x86_64" -version = "0.8.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f21672dcbed52bc09eea030d189600c0189c66c97bc5b31779eb780e064a201f" -dependencies = [ - "array-init", - "bit_field", - "bitflags", - "cast", ] diff --git a/Cargo.toml b/Cargo.toml index 950db65a..5acca0b2 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -16,11 +16,11 @@ harness = false bootloader = { version = "0.8.0", features = ["map_physical_memory"]} volatile = "0.2.6" spin = "0.5.2" -x86_64 = "0.8.1" +x86_64 = "0.9.6" uart_16550 = "0.2.0" pic8259_simple = "0.1.1" -pc-keyboard = "0.3.1" -linked_list_allocator = "0.6.4" +pc-keyboard = "0.5.0" +linked_list_allocator = "0.8.0" [dependencies.lazy_static] version = "1.0" diff --git a/src/allocator.rs b/src/allocator.rs index 11ebeb52..dce05a62 100644 --- a/src/allocator.rs +++ b/src/allocator.rs @@ -21,7 +21,7 @@ static ALLOCATOR: Locked = Locked::new(FixedSizeBlockAl pub fn init_heap( mapper: &mut impl Mapper, frame_allocator: &mut impl FrameAllocator, -) -> Result<(), MapToError> { +) -> Result<(), MapToError> { let page_range = { let heap_start = VirtAddr::new(HEAP_START as u64); let heap_end = heap_start + HEAP_SIZE - 1u64; diff --git a/src/allocator/bump.rs b/src/allocator/bump.rs index 7d104eff..37031254 100644 --- a/src/allocator/bump.rs +++ b/src/allocator/bump.rs @@ -36,7 +36,10 @@ unsafe impl GlobalAlloc for Locked { let mut bump = self.lock(); // get a mutable reference let alloc_start = align_up(bump.next, layout.align()); - let alloc_end = alloc_start.checked_add(layout.size()).expect("overflow"); + let alloc_end = match alloc_start.checked_add(layout.size()) { + Some(end) => end, + None => return ptr::null_mut(), + }; if alloc_end > bump.heap_end { ptr::null_mut() // out of memory diff --git a/src/allocator/linked_list.rs b/src/allocator/linked_list.rs index a03b6f34..c2d1958d 100644 --- a/src/allocator/linked_list.rs +++ b/src/allocator/linked_list.rs @@ -86,7 +86,7 @@ impl LinkedListAllocator { /// Returns the allocation start address on success. fn alloc_from_region(region: &ListNode, size: usize, align: usize) -> Result { let alloc_start = align_up(region.start_addr(), align); - let alloc_end = alloc_start.checked_add(size).expect("overflow"); + let alloc_end = alloc_start.checked_add(size).ok_or(())?; if alloc_end > region.end_addr() { // region too small diff --git a/src/driver/keyboard.rs b/src/driver/keyboard.rs index 316eb238..967c51cf 100644 --- a/src/driver/keyboard.rs +++ b/src/driver/keyboard.rs @@ -4,7 +4,7 @@ use core::{ pin::Pin, task::{Context, Poll}, }; -use pc_keyboard::{layouts, DecodedKey, Keyboard, ScancodeSet1}; +use pc_keyboard::{layouts, DecodedKey, HandleControl, Keyboard, ScancodeSet1}; fn next_scancode() -> impl Future { NextScancode @@ -33,7 +33,7 @@ impl Future for NextScancode { } pub async fn print_keypresses() { - let mut keyboard = Keyboard::new(layouts::Us104Key, ScancodeSet1); + let mut keyboard = Keyboard::new(layouts::Us104Key, ScancodeSet1, HandleControl::Ignore); loop { if let Ok(Some(key_event)) = keyboard.add_byte(next_scancode().await) { diff --git a/src/interrupts.rs b/src/interrupts.rs index 6ba1eed8..2beccdc2 100644 --- a/src/interrupts.rs +++ b/src/interrupts.rs @@ -116,7 +116,6 @@ pub(crate) static KEYBOARD_INTERRUPT_WAKER: AtomicWaker = AtomicWaker::new(); extern "x86-interrupt" fn keyboard_interrupt_handler(_stack_frame: &mut InterruptStackFrame) { use x86_64::instructions::port::Port; - let mut port = Port::new(0x60); let scancode: u8 = unsafe { port.read() };