Skip to content

Commit

Permalink
fix: rename kernel_{start,end} to loader_{start,end}
Browse files Browse the repository at this point in the history
Signed-off-by: Martin Kröning <[email protected]>
  • Loading branch information
mkroening committed Apr 9, 2024
1 parent e8c3b52 commit 0c3a2d8
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 26 deletions.
4 changes: 2 additions & 2 deletions src/arch/aarch64/link.ld
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ PHDRS
SECTIONS
{
. = phys;
kernel_start = .;
loader_start = .;
.text : {
KEEP(*(.text._start))
*(.text)
Expand Down Expand Up @@ -48,5 +48,5 @@ SECTIONS
. += 16K; /* | growth */
/* | direction */
__boot_core_stack_end_exclusive = .; /* | */
kernel_end = .;
loader_end = .;
}
6 changes: 3 additions & 3 deletions src/arch/aarch64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use crate::arch::paging::*;
use crate::arch::serial::SerialPort;

extern "C" {
static kernel_end: u8;
static loader_end: u8;
static mut l0_pgtable: u64;
static mut l1_pgtable: u64;
static mut l2_pgtable: u64;
Expand Down Expand Up @@ -81,7 +81,7 @@ pub fn output_message_byte(byte: u8) {
}

pub unsafe fn get_memory(_memory_size: u64) -> u64 {
(unsafe { ptr::addr_of!(kernel_end) }.addr() as u64).align_up(LargePageSize::SIZE as u64)
(unsafe { ptr::addr_of!(loader_end) }.addr() as u64).align_up(LargePageSize::SIZE as u64)
}

pub fn find_kernel() -> &'static [u8] {
Expand Down Expand Up @@ -181,7 +181,7 @@ pub unsafe fn boot_kernel(kernel_info: LoadedKernel) -> ! {
}
pgt_slice[1] = uart_address as u64 + PT_MEM_CD;

// map kernel to KERNEL_START and stack below the kernel
// map kernel to loader_start and stack below the kernel
let pgt_slice = unsafe { core::slice::from_raw_parts_mut(ptr::addr_of_mut!(l2k_pgtable), 512) };
for i in pgt_slice.iter_mut() {
*i = 0;
Expand Down
4 changes: 2 additions & 2 deletions src/arch/riscv64/link.ld
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
SECTIONS {
kernel_start = ADDR (.text.start);
loader_start = ADDR (.text.start);

.text.start 0x80200000 : { *(.text._start) }
.text : { *(.text.*) }
.rodata : { *(.rodata.*) }
.data : { *(.data.*) }
.bss : { *(.bss.*) }

kernel_end = .;
loader_end = .;
}
8 changes: 4 additions & 4 deletions src/arch/x86_64/entry.s
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

.set BOOT_STACK_SIZE, 4096

.extern kernel_start # defined in linker script
.extern kernel_end
.extern loader_start # defined in linker script
.extern loader_end

# We use a special name to map this section at the begin of our kernel
# => Multiboot expects its magic number at the beginning of the kernel.
Expand Down Expand Up @@ -82,8 +82,8 @@ cpu_init:
push edi
push ebx
push ecx
mov ecx, OFFSET kernel_start
mov ebx, OFFSET kernel_end
mov ecx, OFFSET loader_start
mov ebx, OFFSET loader_end
add ebx, 0x1000
L0: cmp ecx, ebx
jae L1
Expand Down
8 changes: 4 additions & 4 deletions src/arch/x86_64/entry_fc.s
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@

.set BOOT_STACK_SIZE, 4096

.extern kernel_start # defined in linker script
.extern kernel_end
.extern loader_start # defined in linker script
.extern loader_end

# Move entry point at the beginning of the elf file
.section .mboot, "a"
Expand All @@ -26,8 +26,8 @@ _start:
push rdi
push rbx
push rcx
movabs rcx, OFFSET kernel_start
movabs rbx, OFFSET kernel_end
movabs rcx, OFFSET loader_start
movabs rbx, OFFSET loader_end
add rbx, 0x1000
L0: cmp rcx, rbx
jae L1
Expand Down
4 changes: 2 additions & 2 deletions src/arch/x86_64/link.ld
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ phys = 0x000000100000;

SECTIONS
{
kernel_start = phys;
loader_start = phys;
.mboot phys : AT(ADDR(.mboot)) {
*(.mboot)
}
Expand All @@ -25,5 +25,5 @@ SECTIONS
*(.bss)
*(.bss.*)
}
kernel_end = .;
loader_end = .;
}
4 changes: 2 additions & 2 deletions src/arch/x86_64/link_fc.ld
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ phys = 0x000000100000;

SECTIONS
{
kernel_start = phys;
loader_start = phys;
.mboot phys : AT(ADDR(.mboot)) {
*(.mboot)
}
Expand All @@ -24,5 +24,5 @@ SECTIONS
*(.bss)
*(.bss.*)
}
kernel_end = .;
loader_end = .;
}
8 changes: 4 additions & 4 deletions src/arch/x86_64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ use self::physicalmem::PhysAlloc;

#[cfg(target_os = "none")]
extern "C" {
static kernel_end: u8;
static loader_end: u8;
#[cfg(not(feature = "fc"))]
static mb_info: usize;
#[cfg(feature = "fc")]
Expand Down Expand Up @@ -171,7 +171,7 @@ pub fn find_kernel() -> &'static [u8] {
let elf_start = ramdisk_address as usize;
let elf_len = ramdisk_size as usize;

let free_memory_address = unsafe { ptr::addr_of!(kernel_end) }
let free_memory_address = unsafe { ptr::addr_of!(loader_end) }
.addr()
.align_up(Size2MiB::SIZE as usize);
// TODO: Workaround for https://github.com/hermitcore/loader/issues/96
Expand Down Expand Up @@ -285,7 +285,7 @@ pub unsafe fn boot_kernel(kernel_info: LoadedKernel) -> ! {

// determine boot stack address
let new_stack =
(unsafe { ptr::addr_of!(kernel_end) }.addr() + 0x1000).align_up(Size4KiB::SIZE as usize);
(unsafe { ptr::addr_of!(loader_end) }.addr() + 0x1000).align_up(Size4KiB::SIZE as usize);

let cmdline_ptr = unsafe {
*(sptr::from_exposed_addr(boot_params + LINUX_SETUP_HEADER_OFFSET + CMD_LINE_PTR_OFFSET))
Expand Down Expand Up @@ -445,7 +445,7 @@ pub unsafe fn boot_kernel(kernel_info: LoadedKernel) -> ! {
let multiboot = unsafe { Multiboot::from_ptr(mb_info as u64, &mut mem).unwrap() };

// determine boot stack address
let mut new_stack = unsafe { ptr::addr_of!(kernel_end) }
let mut new_stack = unsafe { ptr::addr_of!(loader_end) }
.addr()
.align_up(Size4KiB::SIZE as usize);

Expand Down
6 changes: 3 additions & 3 deletions src/none.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ use log::info;
use crate::{arch, console};

extern "C" {
static kernel_end: u8;
static kernel_start: u8;
static loader_end: u8;
static loader_start: u8;
}

/// Entry Point of the BIOS Loader
Expand All @@ -20,7 +20,7 @@ pub(crate) unsafe extern "C" fn loader_main() -> ! {
crate::log::init();

unsafe {
info!("Loader: [{:p} - {:p}]", &kernel_start, &kernel_end);
info!("Loader: [{:p} - {:p}]", &loader_start, &loader_end);
}

let kernel = arch::find_kernel();
Expand Down

0 comments on commit 0c3a2d8

Please sign in to comment.