Skip to content

Commit

Permalink
Update dependencies (#42)
Browse files Browse the repository at this point in the history
* Reorder dependencies

* Update x86 dependencies
  • Loading branch information
vinc authored Apr 13, 2020
1 parent 8b33c39 commit 090466b
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 68 deletions.
88 changes: 39 additions & 49 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 12 additions & 12 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,20 @@ qwerty = []
dvorak = []

[dependencies]
bootloader = { version = "0.8.3", features = ["map_physical_memory"]}
linked_list_allocator = "0.6.4"
volatile = "0.2.6"
spin = "0.5.2"
x86_64 = "0.8.1"
pic8259_simple = "0.1.1"
pc-keyboard = { git = "https://github.com/thejpster/pc-keyboard" }
base64 = { version = "0.11", default-features = false }
bit_field = "0.10.0"
raw-cpuid = "7.0.3"
uart_16550 = "0.2.1"
bootloader = { version = "0.9.0", features = ["map_physical_memory"]}
hmac = { version = "0.7", default-features = false }
lazy_static = { version = "1.0", features = ["spin_no_std"] }
base64 = { version = "0.11", default-features = false }
libm = "0.2.1"
linked_list_allocator = "0.8.2"
pbkdf2 = { version = "0.3", default-features = false }
pc-keyboard = { git = "https://github.com/thejpster/pc-keyboard" }
pic8259_simple = "0.1.1"
raw-cpuid = "7.0.3"
sha2 = { version = "0.8", default-features = false }
hmac = { version = "0.7", default-features = false }
smoltcp = { version = "0.6", default-features = false, features = ["alloc", "ethernet", "socket-tcp", "socket-udp", "proto-ipv4", "proto-dhcpv4"] }
libm = "0.2.1"
spin = "0.5.2"
uart_16550 = "0.2.4"
volatile = "0.2.6"
x86_64 = "0.10.0"
6 changes: 4 additions & 2 deletions src/kernel/allocator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub const HEAP_SIZE: usize = 100 * 1024; // 100 KiB
#[global_allocator]
static ALLOCATOR: LockedHeap = LockedHeap::empty();

pub fn init_heap(mapper: &mut impl Mapper<Size4KiB>, frame_allocator: &mut impl FrameAllocator<Size4KiB>) -> Result<(), MapToError> {
pub fn init_heap(mapper: &mut impl Mapper<Size4KiB>, frame_allocator: &mut impl FrameAllocator<Size4KiB>) -> Result<(), MapToError<Size4KiB>> {
let page_range = {
let heap_start = VirtAddr::new(HEAP_START as u64);
let heap_end = heap_start + HEAP_SIZE - 1u64;
Expand All @@ -25,7 +25,9 @@ pub fn init_heap(mapper: &mut impl Mapper<Size4KiB>, frame_allocator: &mut impl
for page in page_range {
let frame = frame_allocator.allocate_frame().ok_or(MapToError::FrameAllocationFailed)?;
let flags = PageTableFlags::PRESENT | PageTableFlags::WRITABLE;
mapper.map_to(page, frame, flags, frame_allocator)?.flush();
unsafe {
mapper.map_to(page, frame, flags, frame_allocator)?.flush();
}
}

unsafe {
Expand Down
9 changes: 4 additions & 5 deletions src/kernel/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::{log, kernel};
use lazy_static::lazy_static;
use spin::Mutex;
use x86_64::structures::paging::mapper::MapperAllSizes;
use x86_64::structures::paging::{FrameAllocator, OffsetPageTable, PageTable, PhysFrame, Size4KiB, UnusedPhysFrame};
use x86_64::structures::paging::{FrameAllocator, OffsetPageTable, PageTable, PhysFrame, Size4KiB};
use x86_64::{PhysAddr, VirtAddr};

lazy_static! {
Expand Down Expand Up @@ -64,18 +64,17 @@ impl BootInfoFrameAllocator {
}
}

fn usable_frames(&self) -> impl Iterator<Item = UnusedPhysFrame> {
fn usable_frames(&self) -> impl Iterator<Item = PhysFrame> {
let regions = self.memory_map.iter();
let usable_regions = regions.filter(|r| r.region_type == MemoryRegionType::Usable);
let addr_ranges = usable_regions.map(|r| r.range.start_addr()..r.range.end_addr());
let frame_addresses = addr_ranges.flat_map(|r| r.step_by(4096));
let frames = frame_addresses.map(|addr| PhysFrame::containing_address(PhysAddr::new(addr)));
frames.map(|f| unsafe { UnusedPhysFrame::new(f) })
frame_addresses.map(|addr| PhysFrame::containing_address(PhysAddr::new(addr)))
}
}

unsafe impl FrameAllocator<Size4KiB> for BootInfoFrameAllocator {
fn allocate_frame(&mut self) -> Option<UnusedPhysFrame> {
fn allocate_frame(&mut self) -> Option<PhysFrame> {
let frame = self.usable_frames().nth(self.next);
self.next += 1;
frame
Expand Down

0 comments on commit 090466b

Please sign in to comment.