Skip to content

Commit

Permalink
support higher half position independent kernels
Browse files Browse the repository at this point in the history
Co-Authored-By: Philipp Oppermann <dev@phil-opp.com>
  • Loading branch information
Freax13 and phil-opp committed Nov 28, 2022
1 parent 0dd33b0 commit 69c9246
Show file tree
Hide file tree
Showing 3 changed files with 256 additions and 65 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ rustflags = [
"-C",
"link-args=--image-base 0xFFFF800000000000",
"-C",
"relocation-model=static", # pic in higher half not supported yet
"relocation-model=pic",
"-C",
"code-model=large",
]
Expand Down
8 changes: 4 additions & 4 deletions common/src/level_4_entries.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{entropy, BootInfo, RawFrameBufferInfo};
use crate::{entropy, load_kernel::VirtualAddressOffset, BootInfo, RawFrameBufferInfo};
use bootloader_api::{config, info::MemoryRegion, BootloaderConfig};
use core::{alloc::Layout, iter::Step};
use rand::{
Expand Down Expand Up @@ -126,11 +126,11 @@ impl UsedLevel4Entries {
pub fn mark_segments<'a>(
&mut self,
segments: impl Iterator<Item = ProgramHeader<'a>>,
virtual_address_offset: u64,
virtual_address_offset: VirtualAddressOffset,
) {
for segment in segments.filter(|s| s.mem_size() > 0) {
self.mark_range_as_used(
segment.virtual_addr() + virtual_address_offset,
virtual_address_offset + segment.virtual_addr(),
segment.mem_size(),
);
}
Expand Down Expand Up @@ -158,7 +158,7 @@ impl UsedLevel4Entries {
// Choose the first index.
free_entries.next()
};
let idx = idx_opt.expect("no usable level 4 entries found");
let Some(idx) = idx_opt else { panic!("no usable level 4 entries found ({num} entries requested)"); };

// Mark the entries as used.
for i in 0..num.into_usize() {
Expand Down
Loading

0 comments on commit 69c9246

Please sign in to comment.