Skip to content

Commit bf4fcea

Browse files
authored
Merge pull request #289 from Freax13/higher-half-pic
support higher half position independent kernels
2 parents e2477a0 + 329de3f commit bf4fcea

File tree

4 files changed

+261
-65
lines changed

4 files changed

+261
-65
lines changed

Diff for: Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ rustflags = [
103103
"-C",
104104
"link-args=--image-base 0xFFFF800000000000",
105105
"-C",
106-
"relocation-model=static", # pic in higher half not supported yet
106+
"relocation-model=pic",
107107
"-C",
108108
"code-model=large",
109109
]

Diff for: build.rs

+5
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ fn build_uefi_bootloader(out_dir: &Path) -> PathBuf {
5454
// local build
5555
cmd.arg("--path").arg("uefi");
5656
println!("cargo:rerun-if-changed=uefi");
57+
println!("cargo:rerun-if-changed=common");
5758
} else {
5859
cmd.arg("--version").arg(BOOTLOADER_VERSION);
5960
}
@@ -135,6 +136,10 @@ fn build_bios_stage_2(out_dir: &Path) -> PathBuf {
135136
// local build
136137
cmd.arg("--path").arg(&local_path);
137138
println!("cargo:rerun-if-changed={}", local_path.display());
139+
println!(
140+
"cargo:rerun-if-changed={}",
141+
local_path.with_file_name("common").display()
142+
);
138143
} else {
139144
cmd.arg("--version").arg(BOOTLOADER_VERSION);
140145
}

Diff for: common/src/level_4_entries.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{entropy, BootInfo, RawFrameBufferInfo};
1+
use crate::{entropy, load_kernel::VirtualAddressOffset, BootInfo, RawFrameBufferInfo};
22
use bootloader_api::{config, info::MemoryRegion, BootloaderConfig};
33
use core::{alloc::Layout, iter::Step};
44
use rand::{
@@ -126,11 +126,11 @@ impl UsedLevel4Entries {
126126
pub fn mark_segments<'a>(
127127
&mut self,
128128
segments: impl Iterator<Item = ProgramHeader<'a>>,
129-
virtual_address_offset: u64,
129+
virtual_address_offset: VirtualAddressOffset,
130130
) {
131131
for segment in segments.filter(|s| s.mem_size() > 0) {
132132
self.mark_range_as_used(
133-
segment.virtual_addr() + virtual_address_offset,
133+
virtual_address_offset + segment.virtual_addr(),
134134
segment.mem_size(),
135135
);
136136
}
@@ -158,7 +158,7 @@ impl UsedLevel4Entries {
158158
// Choose the first index.
159159
free_entries.next()
160160
};
161-
let idx = idx_opt.expect("no usable level 4 entries found");
161+
let Some(idx) = idx_opt else { panic!("no usable level 4 entries found ({num} entries requested)"); };
162162

163163
// Mark the entries as used.
164164
for i in 0..num.into_usize() {

0 commit comments

Comments
 (0)