Skip to content

Commit a53a9cf

Browse files
committed
Update x86_64 dependency to version 0.11.0
1 parent 70d9d07 commit a53a9cf

File tree

8 files changed

+27
-115
lines changed

8 files changed

+27
-115
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ required-features = ["binary"]
1414

1515
[dependencies]
1616
xmas-elf = { version = "0.6.2", optional = true }
17-
x86_64 = { version = "0.8.3", optional = true }
17+
x86_64 = { version = "0.11.0", optional = true }
1818
usize_conversions = { version = "0.2.0", optional = true }
1919
fixedvec = { version = "0.2.4", optional = true }
2020
bit_field = { version = "0.10.0", optional = true }

example-kernel/Cargo.lock

+3-40
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example-kernel/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ authors = ["Philipp Oppermann <[email protected]>"]
55
edition = "2018"
66

77
[dependencies]
8-
x86_64 = "0.3.4"
8+
x86_64 = "0.11.0"

src/frame_allocator.rs

+6-11
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
use super::{frame_range, phys_frame_range};
22
use bootloader::bootinfo::{MemoryMap, MemoryRegion, MemoryRegionType};
3-
use x86_64::structures::paging::{frame::PhysFrameRange, PhysFrame, UnusedPhysFrame};
3+
use x86_64::structures::paging::{frame::PhysFrameRange, PhysFrame};
44

55
pub(crate) struct FrameAllocator<'a> {
66
pub memory_map: &'a mut MemoryMap,
77
}
88

99
impl<'a> FrameAllocator<'a> {
10-
pub(crate) fn allocate_frame(
11-
&mut self,
12-
region_type: MemoryRegionType,
13-
) -> Option<UnusedPhysFrame> {
10+
pub(crate) fn allocate_frame(&mut self, region_type: MemoryRegionType) -> Option<PhysFrame> {
1411
// try to find an existing region of same type that can be enlarged
1512
let mut iter = self.memory_map.iter_mut().peekable();
1613
while let Some(region) = iter.next() {
@@ -20,8 +17,7 @@ impl<'a> FrameAllocator<'a> {
2017
&& next.region_type == MemoryRegionType::Usable
2118
&& !next.range.is_empty()
2219
{
23-
let frame =
24-
unsafe { UnusedPhysFrame::new(phys_frame_range(region.range).end) };
20+
let frame = phys_frame_range(region.range).end;
2521
region.range.end_frame_number += 1;
2622
iter.next().unwrap().range.start_frame_number += 1;
2723
return Some(frame);
@@ -30,7 +26,7 @@ impl<'a> FrameAllocator<'a> {
3026
}
3127
}
3228

33-
fn split_usable_region<'a, I>(iter: &mut I) -> Option<(UnusedPhysFrame, PhysFrameRange)>
29+
fn split_usable_region<'a, I>(iter: &mut I) -> Option<(PhysFrame, PhysFrameRange)>
3430
where
3531
I: Iterator<Item = &'a mut MemoryRegion>,
3632
{
@@ -42,10 +38,9 @@ impl<'a> FrameAllocator<'a> {
4238
continue;
4339
}
4440

45-
let physframe = phys_frame_range(region.range).start;
46-
let unused_frame = unsafe { UnusedPhysFrame::new(physframe) };
41+
let frame = phys_frame_range(region.range).start;
4742
region.range.start_frame_number += 1;
48-
return Some((unused_frame, PhysFrame::range(physframe, physframe + 1)));
43+
return Some((frame, PhysFrame::range(frame, frame + 1)));
4944
}
5045
None
5146
}

src/main.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use usize_conversions::usize_from;
1919
use x86_64::instructions::tlb;
2020
use x86_64::structures::paging::{
2121
frame::PhysFrameRange, page_table::PageTableEntry, Mapper, Page, PageTable, PageTableFlags,
22-
PageTableIndex, PhysFrame, RecursivePageTable, Size2MiB, Size4KiB, UnusedPhysFrame,
22+
PageTableIndex, PhysFrame, RecursivePageTable, Size2MiB, Size4KiB,
2323
};
2424
use x86_64::{PhysAddr, VirtAddr};
2525

@@ -309,7 +309,7 @@ fn bootloader_main(
309309
unsafe {
310310
page_table::map_page(
311311
page,
312-
UnusedPhysFrame::new(frame),
312+
frame,
313313
flags,
314314
&mut rec_page_table,
315315
&mut frame_allocator,

src/page_table.rs

+10-19
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ use fixedvec::FixedVec;
55
use x86_64::structures::paging::mapper::{MapToError, MapperFlush, UnmapError};
66
use x86_64::structures::paging::{
77
self, Mapper, Page, PageSize, PageTableFlags, PhysFrame, RecursivePageTable, Size4KiB,
8-
UnusedPhysFrame,
98
};
109
use x86_64::{align_up, PhysAddr, VirtAddr};
1110
use xmas_elf::program::{self, ProgramHeader64};
@@ -18,12 +17,12 @@ pub struct MemoryInfo {
1817

1918
#[derive(Debug)]
2019
pub enum MapKernelError {
21-
Mapping(MapToError),
20+
Mapping(MapToError<Size4KiB>),
2221
MultipleTlsSegments,
2322
}
2423

25-
impl From<MapToError> for MapKernelError {
26-
fn from(e: MapToError) -> Self {
24+
impl From<MapToError<Size4KiB>> for MapKernelError {
25+
fn from(e: MapToError<Size4KiB>) -> Self {
2726
MapKernelError::Mapping(e)
2827
}
2928
}
@@ -71,7 +70,7 @@ pub(crate) fn map_segment(
7170
kernel_start: PhysAddr,
7271
page_table: &mut RecursivePageTable,
7372
frame_allocator: &mut FrameAllocator,
74-
) -> Result<Option<TlsTemplate>, MapToError> {
73+
) -> Result<Option<TlsTemplate>, MapToError<Size4KiB>> {
7574
let typ = segment.get_type().unwrap();
7675
match typ {
7776
program::Type::Load => {
@@ -97,16 +96,8 @@ pub(crate) fn map_segment(
9796
for frame in PhysFrame::range_inclusive(start_frame, end_frame) {
9897
let offset = frame - start_frame;
9998
let page = start_page + offset;
100-
unsafe {
101-
map_page(
102-
page,
103-
UnusedPhysFrame::new(frame),
104-
page_table_flags,
105-
page_table,
106-
frame_allocator,
107-
)?
108-
}
109-
.flush();
99+
unsafe { map_page(page, frame, page_table_flags, page_table, frame_allocator)? }
100+
.flush();
110101
}
111102

112103
if mem_size > file_size {
@@ -126,7 +117,7 @@ pub(crate) fn map_segment(
126117
unsafe {
127118
map_page(
128119
temp_page.clone(),
129-
UnusedPhysFrame::new(new_frame.clone()),
120+
new_frame.clone(),
130121
page_table_flags,
131122
page_table,
132123
frame_allocator,
@@ -202,19 +193,19 @@ pub(crate) fn map_segment(
202193

203194
pub(crate) unsafe fn map_page<'a, S>(
204195
page: Page<S>,
205-
phys_frame: UnusedPhysFrame<S>,
196+
phys_frame: PhysFrame<S>,
206197
flags: PageTableFlags,
207198
page_table: &mut RecursivePageTable<'a>,
208199
frame_allocator: &mut FrameAllocator,
209-
) -> Result<MapperFlush<S>, MapToError>
200+
) -> Result<MapperFlush<S>, MapToError<S>>
210201
where
211202
S: PageSize,
212203
RecursivePageTable<'a>: Mapper<S>,
213204
{
214205
struct PageTableAllocator<'a, 'b: 'a>(&'a mut FrameAllocator<'b>);
215206

216207
unsafe impl<'a, 'b> paging::FrameAllocator<Size4KiB> for PageTableAllocator<'a, 'b> {
217-
fn allocate_frame(&mut self) -> Option<UnusedPhysFrame<Size4KiB>> {
208+
fn allocate_frame(&mut self) -> Option<PhysFrame<Size4KiB>> {
218209
self.0.allocate_frame(MemoryRegionType::PageTable)
219210
}
220211
}

test-kernel/Cargo.lock

+3-40
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test-kernel/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ authors = ["Philipp Oppermann <[email protected]>"]
55
edition = "2018"
66

77
[dependencies]
8-
x86_64 = "0.3.4"
8+
x86_64 = "0.11.0"

0 commit comments

Comments
 (0)