From a53a9cf1ebb8ca797843bf71e4dc6d9ebf6f8a1f Mon Sep 17 00:00:00 2001 From: Philipp Oppermann Date: Wed, 20 May 2020 09:35:43 +0200 Subject: [PATCH] Update x86_64 dependency to version 0.11.0 --- Cargo.toml | 2 +- example-kernel/Cargo.lock | 43 +++------------------------------------ example-kernel/Cargo.toml | 2 +- src/frame_allocator.rs | 17 ++++++---------- src/main.rs | 4 ++-- src/page_table.rs | 29 +++++++++----------------- test-kernel/Cargo.lock | 43 +++------------------------------------ test-kernel/Cargo.toml | 2 +- 8 files changed, 27 insertions(+), 115 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 420553b6..71fb65cb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -14,7 +14,7 @@ required-features = ["binary"] [dependencies] xmas-elf = { version = "0.6.2", optional = true } -x86_64 = { version = "0.8.3", optional = true } +x86_64 = { version = "0.11.0", optional = true } usize_conversions = { version = "0.2.0", optional = true } fixedvec = { version = "0.2.4", optional = true } bit_field = { version = "0.10.0", optional = true } diff --git a/example-kernel/Cargo.lock b/example-kernel/Cargo.lock index 6cf76349..c659370f 100644 --- a/example-kernel/Cargo.lock +++ b/example-kernel/Cargo.lock @@ -1,13 +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" -dependencies = [ - "nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "bit_field" version = "0.9.0" @@ -22,48 +14,19 @@ source = "registry+https://github.com/rust-lang/crates.io-index" name = "example-kernel" version = "0.1.0" dependencies = [ - "x86_64 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "x86_64 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "nodrop" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "os_bootinfo" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "usize_conversions" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "ux" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "x86_64" -version = "0.3.6" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "array-init 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "bit_field 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "os_bootinfo 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "usize_conversions 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ux 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [metadata] -"checksum array-init 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "23589ecb866b460d3a0f1278834750268c607e8e28a1b982c907219f3178cd72" "checksum bit_field 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed8765909f9009617974ab6b7d332625b320b33c326b1e9321382ef1999b5d56" "checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd" -"checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" -"checksum os_bootinfo 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "66481dbeb5e773e7bd85b63cd6042c30786f834338288c5ec4f3742673db360a" -"checksum usize_conversions 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f70329e2cbe45d6c97a5112daad40c34cd9a4e18edb5a2a18fefeb584d8d25e5" -"checksum ux 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "88dfeb711b61ce620c0cb6fd9f8e3e678622f0c971da2a63c4b3e25e88ed012f" -"checksum x86_64 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f9258d7e2dd25008d69e8c9e9ee37865887a5e1e3d06a62f1cb3f6c209e6f177" +"checksum x86_64 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "365de37eb7c6da582cbb510dd0f3f1235d24ff6309a8a96e8a9909cc9bfd608f" diff --git a/example-kernel/Cargo.toml b/example-kernel/Cargo.toml index a9c76f70..c3e50263 100644 --- a/example-kernel/Cargo.toml +++ b/example-kernel/Cargo.toml @@ -5,4 +5,4 @@ authors = ["Philipp Oppermann "] edition = "2018" [dependencies] -x86_64 = "0.3.4" +x86_64 = "0.11.0" diff --git a/src/frame_allocator.rs b/src/frame_allocator.rs index 5630702f..5b77cdb2 100644 --- a/src/frame_allocator.rs +++ b/src/frame_allocator.rs @@ -1,16 +1,13 @@ use super::{frame_range, phys_frame_range}; use bootloader::bootinfo::{MemoryMap, MemoryRegion, MemoryRegionType}; -use x86_64::structures::paging::{frame::PhysFrameRange, PhysFrame, UnusedPhysFrame}; +use x86_64::structures::paging::{frame::PhysFrameRange, PhysFrame}; pub(crate) struct FrameAllocator<'a> { pub memory_map: &'a mut MemoryMap, } impl<'a> FrameAllocator<'a> { - pub(crate) fn allocate_frame( - &mut self, - region_type: MemoryRegionType, - ) -> Option { + pub(crate) fn allocate_frame(&mut self, region_type: MemoryRegionType) -> Option { // try to find an existing region of same type that can be enlarged let mut iter = self.memory_map.iter_mut().peekable(); while let Some(region) = iter.next() { @@ -20,8 +17,7 @@ impl<'a> FrameAllocator<'a> { && next.region_type == MemoryRegionType::Usable && !next.range.is_empty() { - let frame = - unsafe { UnusedPhysFrame::new(phys_frame_range(region.range).end) }; + let frame = phys_frame_range(region.range).end; region.range.end_frame_number += 1; iter.next().unwrap().range.start_frame_number += 1; return Some(frame); @@ -30,7 +26,7 @@ impl<'a> FrameAllocator<'a> { } } - fn split_usable_region<'a, I>(iter: &mut I) -> Option<(UnusedPhysFrame, PhysFrameRange)> + fn split_usable_region<'a, I>(iter: &mut I) -> Option<(PhysFrame, PhysFrameRange)> where I: Iterator, { @@ -42,10 +38,9 @@ impl<'a> FrameAllocator<'a> { continue; } - let physframe = phys_frame_range(region.range).start; - let unused_frame = unsafe { UnusedPhysFrame::new(physframe) }; + let frame = phys_frame_range(region.range).start; region.range.start_frame_number += 1; - return Some((unused_frame, PhysFrame::range(physframe, physframe + 1))); + return Some((frame, PhysFrame::range(frame, frame + 1))); } None } diff --git a/src/main.rs b/src/main.rs index ce7bcc50..7fa7fc06 100644 --- a/src/main.rs +++ b/src/main.rs @@ -19,7 +19,7 @@ use usize_conversions::usize_from; use x86_64::instructions::tlb; use x86_64::structures::paging::{ frame::PhysFrameRange, page_table::PageTableEntry, Mapper, Page, PageTable, PageTableFlags, - PageTableIndex, PhysFrame, RecursivePageTable, Size2MiB, Size4KiB, UnusedPhysFrame, + PageTableIndex, PhysFrame, RecursivePageTable, Size2MiB, Size4KiB, }; use x86_64::{PhysAddr, VirtAddr}; @@ -309,7 +309,7 @@ fn bootloader_main( unsafe { page_table::map_page( page, - UnusedPhysFrame::new(frame), + frame, flags, &mut rec_page_table, &mut frame_allocator, diff --git a/src/page_table.rs b/src/page_table.rs index 8f943afb..ed2ac136 100644 --- a/src/page_table.rs +++ b/src/page_table.rs @@ -5,7 +5,6 @@ use fixedvec::FixedVec; use x86_64::structures::paging::mapper::{MapToError, MapperFlush, UnmapError}; use x86_64::structures::paging::{ self, Mapper, Page, PageSize, PageTableFlags, PhysFrame, RecursivePageTable, Size4KiB, - UnusedPhysFrame, }; use x86_64::{align_up, PhysAddr, VirtAddr}; use xmas_elf::program::{self, ProgramHeader64}; @@ -18,12 +17,12 @@ pub struct MemoryInfo { #[derive(Debug)] pub enum MapKernelError { - Mapping(MapToError), + Mapping(MapToError), MultipleTlsSegments, } -impl From for MapKernelError { - fn from(e: MapToError) -> Self { +impl From> for MapKernelError { + fn from(e: MapToError) -> Self { MapKernelError::Mapping(e) } } @@ -71,7 +70,7 @@ pub(crate) fn map_segment( kernel_start: PhysAddr, page_table: &mut RecursivePageTable, frame_allocator: &mut FrameAllocator, -) -> Result, MapToError> { +) -> Result, MapToError> { let typ = segment.get_type().unwrap(); match typ { program::Type::Load => { @@ -97,16 +96,8 @@ pub(crate) fn map_segment( for frame in PhysFrame::range_inclusive(start_frame, end_frame) { let offset = frame - start_frame; let page = start_page + offset; - unsafe { - map_page( - page, - UnusedPhysFrame::new(frame), - page_table_flags, - page_table, - frame_allocator, - )? - } - .flush(); + unsafe { map_page(page, frame, page_table_flags, page_table, frame_allocator)? } + .flush(); } if mem_size > file_size { @@ -126,7 +117,7 @@ pub(crate) fn map_segment( unsafe { map_page( temp_page.clone(), - UnusedPhysFrame::new(new_frame.clone()), + new_frame.clone(), page_table_flags, page_table, frame_allocator, @@ -202,11 +193,11 @@ pub(crate) fn map_segment( pub(crate) unsafe fn map_page<'a, S>( page: Page, - phys_frame: UnusedPhysFrame, + phys_frame: PhysFrame, flags: PageTableFlags, page_table: &mut RecursivePageTable<'a>, frame_allocator: &mut FrameAllocator, -) -> Result, MapToError> +) -> Result, MapToError> where S: PageSize, RecursivePageTable<'a>: Mapper, @@ -214,7 +205,7 @@ where struct PageTableAllocator<'a, 'b: 'a>(&'a mut FrameAllocator<'b>); unsafe impl<'a, 'b> paging::FrameAllocator for PageTableAllocator<'a, 'b> { - fn allocate_frame(&mut self) -> Option> { + fn allocate_frame(&mut self) -> Option> { self.0.allocate_frame(MemoryRegionType::PageTable) } } diff --git a/test-kernel/Cargo.lock b/test-kernel/Cargo.lock index 19970e08..da989002 100644 --- a/test-kernel/Cargo.lock +++ b/test-kernel/Cargo.lock @@ -1,13 +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" -dependencies = [ - "nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "bit_field" version = "0.9.0" @@ -18,52 +10,23 @@ name = "bitflags" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -[[package]] -name = "nodrop" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "os_bootinfo" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "test-kernel" version = "0.1.0" dependencies = [ - "x86_64 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)", + "x86_64 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "usize_conversions" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" - -[[package]] -name = "ux" -version = "0.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" - [[package]] name = "x86_64" -version = "0.3.6" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "array-init 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)", "bit_field 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", - "os_bootinfo 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "usize_conversions 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "ux 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [metadata] -"checksum array-init 0.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "23589ecb866b460d3a0f1278834750268c607e8e28a1b982c907219f3178cd72" "checksum bit_field 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ed8765909f9009617974ab6b7d332625b320b33c326b1e9321382ef1999b5d56" "checksum bitflags 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3d155346769a6855b86399e9bc3814ab343cd3d62c7e985113d46a0ec3c281fd" -"checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" -"checksum os_bootinfo 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "66481dbeb5e773e7bd85b63cd6042c30786f834338288c5ec4f3742673db360a" -"checksum usize_conversions 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f70329e2cbe45d6c97a5112daad40c34cd9a4e18edb5a2a18fefeb584d8d25e5" -"checksum ux 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)" = "88dfeb711b61ce620c0cb6fd9f8e3e678622f0c971da2a63c4b3e25e88ed012f" -"checksum x86_64 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "f9258d7e2dd25008d69e8c9e9ee37865887a5e1e3d06a62f1cb3f6c209e6f177" +"checksum x86_64 0.11.0 (registry+https://github.com/rust-lang/crates.io-index)" = "365de37eb7c6da582cbb510dd0f3f1235d24ff6309a8a96e8a9909cc9bfd608f" diff --git a/test-kernel/Cargo.toml b/test-kernel/Cargo.toml index 85bcf7a9..3c2be212 100644 --- a/test-kernel/Cargo.toml +++ b/test-kernel/Cargo.toml @@ -5,4 +5,4 @@ authors = ["Philipp Oppermann "] edition = "2018" [dependencies] -x86_64 = "0.3.4" +x86_64 = "0.11.0"