Skip to content

Commit

Permalink
Merge pull request #289 from Freax13/higher-half-pic
Browse files Browse the repository at this point in the history
support higher half position independent kernels
  • Loading branch information
phil-opp authored Jan 9, 2023
2 parents e2477a0 + 329de3f commit bf4fcea
Show file tree
Hide file tree
Showing 4 changed files with 261 additions and 65 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,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
5 changes: 5 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ fn build_uefi_bootloader(out_dir: &Path) -> PathBuf {
// local build
cmd.arg("--path").arg("uefi");
println!("cargo:rerun-if-changed=uefi");
println!("cargo:rerun-if-changed=common");
} else {
cmd.arg("--version").arg(BOOTLOADER_VERSION);
}
Expand Down Expand Up @@ -135,6 +136,10 @@ fn build_bios_stage_2(out_dir: &Path) -> PathBuf {
// local build
cmd.arg("--path").arg(&local_path);
println!("cargo:rerun-if-changed={}", local_path.display());
println!(
"cargo:rerun-if-changed={}",
local_path.with_file_name("common").display()
);
} else {
cmd.arg("--version").arg(BOOTLOADER_VERSION);
}
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 bf4fcea

Please sign in to comment.