8000 Update to new x86_64 version · rust-osdev/bootloader@4cb3645 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4cb3645

Browse files
committed
Update to new x86_64 version
1 parent 646f746 commit 4cb3645

File tree

3 files changed

+13
-18
lines changed

3 files changed

+13
-18
lines changed

Cargo.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/main.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ extern crate fixedvec;
2121
use core::slice;
2222
use os_bootinfo::BootInfo;
2323
use usize_conversions::usize_from;
24-
use x86_64::instructions::tlb;
2524
use x86_64::structures::paging::{Mapper, RecursivePageTable};
2625
use x86_64::structures::paging::{Page, PageTableFlags, PhysFrame, Size2MB};
2726
use x86_64::ux::u9;
@@ -159,10 +158,8 @@ pub extern "C" fn load_elf(
159158
for page in Page::range_inclusive(kernel_start_page, kernel_end_page) {
160159
rec_page_table
161160
.unmap(page, &mut |_| {})
162-
.expect("dealloc error");
161+
.expect("dealloc error").flush();
163162
}
164-
// Flush the translation lookaside buffer since we changed the active mapping.
165-
tlb::flush_all();
166163

167164
// Map kernel segments.
168165
let stack_end = page_table::map_kernel(
@@ -185,7 +182,7 @@ pub extern "C" fn load_elf(
185182
flags,
186183
&mut rec_page_table,
187184
&mut frame_allocator,
188-
).expect("Mapping of bootinfo page failed");
185+
).expect("Mapping of bootinfo page failed").flush();
189186
page
190187
};
191188

src/page_table.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
use fixedvec::FixedVec;
22
use frame_allocator::FrameAllocator;
33
use os_bootinfo::MemoryRegionType;
4-
use x86_64::instructions::tlb;
54
use x86_64::structures::paging::{MapToError, RecursivePageTable, UnmapError};
6-
use x86_64::structures::paging::{Mapper, Page, PageSize, PageTableFlags, PhysFrame, Size4KB};
5+
use x86_64::structures::paging::{Mapper, MapperFlush, Page, PageSize, PageTableFlags, PhysFrame, Size4KB};
76
use x86_64::{align_up, PhysAddr, VirtAddr};
87
use xmas_elf::program::{self, ProgramHeader64};
98

@@ -30,7 +29,7 @@ pub(crate) fn map_kernel(
3029
let frame = frame_allocator
3130
.allocate_frame(region_type)
3231
.ok_or(MapToError::FrameAllocationFailed)?;
33-
map_page(page, frame, flags, page_table, frame_allocator)?;
32+
map_page(page, frame, flags, page_table, frame_allocator)?.flush();
3433
}
3534

3635
Ok(stack_end.start_address())
@@ -67,7 +66,7 @@ pub(crate) fn map_segment(
6766
for frame in PhysFrame::range_inclusive(start_frame, end_frame) {
6867
let offset = frame - start_frame;
6968
let page = start_page + offset;
70-
map_page(page, frame, page_table_flags, page_table, frame_allocator)?;
69+
map_page(page, frame, page_table_flags, page_table, frame_allocator)?.flush();
7170
}
7271

7372
if mem_size > file_size {
@@ -90,7 +89,7 @@ pub(crate) fn map_segment(
9089
page_table_flags,
9190
page_table,
9291
frame_allocator,
93-
)?;
92+
)?.flush();
9493

9594
type PageArray = [u64; Size4KB::SIZE as usize / 8];
9695

@@ -113,15 +112,14 @@ pub(crate) fn map_segment(
113112
UnmapError::InvalidFrameAddressInPageTable => unreachable!(),
114113
});
115114
}
116-
tlb::flush(last_page.start_address());
117115

118116
map_page(
119117
last_page,
120118
new_frame,
121119
page_table_flags,
122120
page_table,
123121
frame_allocator,
124-
)?;
122+
)?.flush();
125123
}
126124

127125
// Map additional frames.
@@ -134,7 +132,7 @@ pub(crate) fn map_segment(
134132
let frame = frame_allocator
135133
.allocate_frame(MemoryRegionType::Kernel)
136134
.ok_or(MapToError::FrameAllocationFailed)?;
137-
map_page(page, frame, page_table_flags, page_table, frame_allocator)?;
135+
map_page(page, frame, page_table_flags, page_table, frame_allocator)?.flush();
138136
}
139137

140138
// zero
@@ -155,7 +153,7 @@ pub(crate) fn map_page<'a, S>(
155153
flags: PageTableFlags,
156154
page_table: &mut RecursivePageTable<'a>,
157155
frame_allocator: &mut FrameAllocator,
158-
) -> Result<(), MapToError>
156+
) -> Result<MapperFlush<S>, MapToError>
159157
where
160158
S: PageSize,
161159
RecursivePageTable<'a>: Mapper<S>,

0 commit comments

Comments
 (0)
0