Unverified Commit 7322a58e authored by bors[bot]'s avatar bors[bot] Committed by GitHub
Browse files

Merge #33

33: fmt: Replace hex prefix with alternate flag r=stlankes a=mkroening

See https://github.com/hermitcore/libhermit-rs/pull/282

.
Co-authored-by: Martin Kröning's avatarMartin Kröning <mkroening@posteo.net>
parents 6605efce 67e00601
Pipeline #567345 passed with stages
in 2 minutes and 32 seconds
......@@ -72,34 +72,30 @@ impl BootInfo {
impl fmt::Debug for BootInfo {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!(f, "magic_number 0x{:x}", self.magic_number)?;
writeln!(f, "version 0x{:x}", self.version)?;
writeln!(f, "base 0x{:x}", self.base)?;
writeln!(f, "limit 0x{:x}", self.limit)?;
writeln!(f, "tls_start 0x{:x}", self.tls_start)?;
writeln!(f, "tls_filesz 0x{:x}", self.tls_filesz)?;
writeln!(f, "tls_memsz 0x{:x}", self.tls_memsz)?;
writeln!(f, "image_size 0x{:x}", self.image_size)?;
writeln!(f, "magic_number {:#x}", self.magic_number)?;
writeln!(f, "version {:#x}", self.version)?;
writeln!(f, "base {:#x}", self.base)?;
writeln!(f, "limit {:#x}", self.limit)?;
writeln!(f, "tls_start {:#x}", self.tls_start)?;
writeln!(f, "tls_filesz {:#x}", self.tls_filesz)?;
writeln!(f, "tls_memsz {:#x}", self.tls_memsz)?;
writeln!(f, "image_size {:#x}", self.image_size)?;
writeln!(f, "current_stack_address {:#x}", self.current_stack_address)?;
writeln!(
f,
"current_stack_address 0x{:x}",
self.current_stack_address
)?;
writeln!(
f,
"current_percore_address 0x{:x}",
"current_percore_address {:#x}",
self.current_percore_address
)?;
writeln!(f, "host_logical_addr 0x{:x}", self.host_logical_addr)?;
writeln!(f, "boot_gtod 0x{:x}", self.boot_gtod)?;
writeln!(f, "cmdline 0x{:x}", self.cmdline)?;
writeln!(f, "cmdsize 0x{:x}", self.cmdsize)?;
writeln!(f, "host_logical_addr {:#x}", self.host_logical_addr)?;
writeln!(f, "boot_gtod {:#x}", self.boot_gtod)?;
writeln!(f, "cmdline {:#x}", self.cmdline)?;
writeln!(f, "cmdsize {:#x}", self.cmdsize)?;
writeln!(f, "cpu_freq {}", self.cpu_freq)?;
writeln!(f, "boot_processor {}", self.boot_processor)?;
writeln!(f, "cpu_online {}", self.cpu_online)?;
writeln!(f, "possible_cpus {}", self.possible_cpus)?;
writeln!(f, "current_boot_id {}", self.current_boot_id)?;
writeln!(f, "uartport 0x{:x}", self.uartport)?;
writeln!(f, "uartport {:#x}", self.uartport)?;
writeln!(f, "single_kernel {}", self.single_kernel)?;
writeln!(f, "uhyve {}", self.uhyve)
}
......
......@@ -40,7 +40,7 @@ pub fn find_kernel() -> &'static [u8] {
pub unsafe fn boot_kernel(virtual_address: u64, mem_size: u64, entry_point: u64) -> ! {
// Jump to the kernel entry point and provide the Multiboot information to it.
loaderlog!(
"Jumping to HermitCore Application Entry Point at 0x{:x}",
"Jumping to HermitCore Application Entry Point at {:#x}",
entry_point
);
......
......@@ -74,35 +74,31 @@ impl BootInfo {
impl fmt::Debug for BootInfo {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
writeln!(f, "magic_number 0x{:x}", self.magic_number)?;
writeln!(f, "version 0x{:x}", self.version)?;
writeln!(f, "base 0x{:x}", self.base)?;
writeln!(f, "limit 0x{:x}", self.limit)?;
writeln!(f, "tls_start 0x{:x}", self.tls_start)?;
writeln!(f, "tls_filesz 0x{:x}", self.tls_filesz)?;
writeln!(f, "tls_memsz 0x{:x}", self.tls_memsz)?;
writeln!(f, "image_size 0x{:x}", self.image_size)?;
writeln!(f, "magic_number {:#x}", self.magic_number)?;
writeln!(f, "version {:#x}", self.version)?;
writeln!(f, "base {:#x}", self.base)?;
writeln!(f, "limit {:#x}", self.limit)?;
writeln!(f, "tls_start {:#x}", self.tls_start)?;
writeln!(f, "tls_filesz {:#x}", self.tls_filesz)?;
writeln!(f, "tls_memsz {:#x}", self.tls_memsz)?;
writeln!(f, "image_size {:#x}", self.image_size)?;
writeln!(f, "current_stack_address {:#x}", self.current_stack_address)?;
writeln!(
f,
"current_stack_address 0x{:x}",
self.current_stack_address
)?;
writeln!(
f,
"current_percore_address 0x{:x}",
"current_percore_address {:#x}",
self.current_percore_address
)?;
writeln!(f, "host_logical_addr 0x{:x}", self.host_logical_addr)?;
writeln!(f, "boot_gtod 0x{:x}", self.boot_gtod)?;
writeln!(f, "mb_info 0x{:x}", self.mb_info)?;
writeln!(f, "cmdline 0x{:x}", self.cmdline)?;
writeln!(f, "cmdsize 0x{:x}", self.cmdsize)?;
writeln!(f, "host_logical_addr {:#x}", self.host_logical_addr)?;
writeln!(f, "boot_gtod {:#x}", self.boot_gtod)?;
writeln!(f, "mb_info {:#x}", self.mb_info)?;
writeln!(f, "cmdline {:#x}", self.cmdline)?;
writeln!(f, "cmdsize {:#x}", self.cmdsize)?;
writeln!(f, "cpu_freq {}", self.cpu_freq)?;
writeln!(f, "boot_processor {}", self.boot_processor)?;
writeln!(f, "cpu_online {}", self.cpu_online)?;
writeln!(f, "possible_cpus {}", self.possible_cpus)?;
writeln!(f, "current_boot_id {}", self.current_boot_id)?;
writeln!(f, "uartport 0x{:x}", self.uartport)?;
writeln!(f, "uartport {:#x}", self.uartport)?;
writeln!(f, "single_kernel {}", self.single_kernel)?;
writeln!(f, "uhyve {}", self.uhyve)
}
......
......@@ -68,7 +68,7 @@ pub fn output_message_byte(byte: u8) {
pub unsafe fn find_kernel() -> &'static [u8] {
// Identity-map the Multiboot information.
assert!(mb_info > 0, "Could not find Multiboot information");
loaderlog!("Found Multiboot information at 0x{:x}", mb_info);
loaderlog!("Found Multiboot information at {:#x}", mb_info);
let page_address = align_down!(mb_info, BasePageSize::SIZE);
paging::map::<BasePageSize>(page_address, page_address, 1, PageTableEntryFlags::WRITABLE);
......@@ -102,14 +102,10 @@ pub unsafe fn find_kernel() -> &'static [u8] {
}
}
loaderlog!(
"Found module: [0x{:x} - 0x{:x}]",
start_address,
end_address
);
loaderlog!("Found module: [{:#x} - {:#x}]", start_address, end_address);
let elf_start = start_address;
let elf_len = end_address - start_address;
loaderlog!("Module length: 0x{:x}", elf_len);
loaderlog!("Module length: {:#x}", elf_len);
// Memory after the highest end address is unused and available for the physical memory manager.
physicalmem::init(align_up!(end_address, LargePageSize::SIZE));
......@@ -120,12 +116,12 @@ pub unsafe fn find_kernel() -> &'static [u8] {
"Could not find a single module in the Multiboot information"
);
assert!(start_address > 0);
loaderlog!("Found an ELF module at 0x{:x}", start_address);
loaderlog!("Found an ELF module at {:#x}", start_address);
let page_address = align_down!(start_address, BasePageSize::SIZE);
let counter =
(align_up!(start_address, LargePageSize::SIZE) - page_address) / BasePageSize::SIZE;
loaderlog!(
"Map {} pages at 0x{:x} (page size {} KByte)",
"Map {} pages at {:#x} (page size {} KByte)",
counter,
page_address,
BasePageSize::SIZE / 1024
......@@ -142,7 +138,7 @@ pub unsafe fn find_kernel() -> &'static [u8] {
let counter = (align_up!(end_address, LargePageSize::SIZE) - address) / LargePageSize::SIZE;
if counter > 0 {
loaderlog!(
"Map {} pages at 0x{:x} (page size {} KByte)",
"Map {} pages at {:#x} (page size {} KByte)",
counter,
address,
LargePageSize::SIZE / 1024
......@@ -177,8 +173,8 @@ pub unsafe fn boot_kernel(virtual_address: u64, mem_size: u64, entry_point: u64)
PageTableEntryFlags::WRITABLE,
);
loaderlog!("BootInfo located at 0x{:x}", &BOOT_INFO as *const _ as u64);
loaderlog!("Use stack address 0x{:x}", BOOT_INFO.current_stack_address);
loaderlog!("BootInfo located at {:#x}", &BOOT_INFO as *const _ as u64);
loaderlog!("Use stack address {:#x}", BOOT_INFO.current_stack_address);
let multiboot = Multiboot::from_ptr(mb_info as u64, &mut MEM).unwrap();
if let Some(cmdline) = multiboot.command_line() {
......@@ -196,7 +192,7 @@ pub unsafe fn boot_kernel(virtual_address: u64, mem_size: u64, entry_point: u64)
// Jump to the kernel entry point and provide the Multiboot information to it.
let entry_point = entry_point - virtual_address + new_addr;
loaderlog!(
"Jumping to HermitCore Application Entry Point at 0x{:x}",
"Jumping to HermitCore Application Entry Point at {:#x}",
entry_point
);
let func: extern "C" fn(boot_info: &'static mut BootInfo) -> ! =
......
......@@ -92,7 +92,7 @@ impl PageTableEntry {
assert_eq!(
physical_address % LargePageSize::SIZE,
0,
"Physical address is not on a 2 MiB page boundary (physical_address = 0x{:x})",
"Physical address is not on a 2 MiB page boundary (physical_address = {:#x})",
physical_address
);
} else {
......@@ -100,7 +100,7 @@ impl PageTableEntry {
assert_eq!(
physical_address % BasePageSize::SIZE,
0,
"Physical address is not on a 4 KiB page boundary (physical_address = 0x{:x})",
"Physical address is not on a 4 KiB page boundary (physical_address = {:#x})",
physical_address
);
}
......
......@@ -20,7 +20,7 @@ pub fn allocate(size: usize) -> usize {
assert_eq!(
size % BasePageSize::SIZE,
0,
"Size 0x{:x} is a multiple of 0x{:x}",
"Size {:#x} is a multiple of {:#x}",
size,
BasePageSize::SIZE
);
......
......@@ -59,7 +59,7 @@ pub unsafe fn sections_init() {
}
pub unsafe fn load_kernel(elf: &elf::Elf<'_>, elf_start: u64, mem_size: u64) -> (u64, u64) {
loaderlog!("start 0x{:x}, size 0x{:x}", elf_start, mem_size);
loaderlog!("start {:#x}, size {:#x}", elf_start, mem_size);
if !elf.libraries.is_empty() {
panic!(
"Error: file depends on following libraries: {:?}",
......@@ -72,11 +72,11 @@ pub unsafe fn load_kernel(elf: &elf::Elf<'_>, elf_start: u64, mem_size: u64) ->
assert!(elf.header.e_machine == ELF_ARCH);
if elf.header.e_ident[7] != 0xFF {
loaderlog!("Unsupported OS ABI 0x{:x}", elf.header.e_ident[7]);
loaderlog!("Unsupported OS ABI {:#x}", elf.header.e_ident[7]);
}
let address = get_memory(mem_size);
loaderlog!("Load HermitCore Application at 0x{:x}", address);
loaderlog!("Load HermitCore Application at {:#x}", address);
// load application
for program_header in &elf.program_headers {
......@@ -101,7 +101,7 @@ pub unsafe fn load_kernel(elf: &elf::Elf<'_>, elf_start: u64, mem_size: u64) ->
BOOT_INFO.tls_memsz = program_header.p_memsz as u64;
loaderlog!(
"Found TLS starts at 0x{:x} (size {} Bytes)",
"Found TLS starts at {:#x} (size {} Bytes)",
BOOT_INFO.tls_start,
BOOT_INFO.tls_memsz
);
......@@ -164,7 +164,7 @@ pub fn check_kernel_elf_file(elf: &elf::Elf<'_>) -> u64 {
// Verify the information.
assert!(file_size > 0);
assert!(mem_size > 0);
loaderlog!("Found entry point: 0x{:x}", elf.entry);
loaderlog!("Found entry point: {:#x}", elf.entry);
loaderlog!("File Size: {} Bytes", file_size);
loaderlog!("Mem Size: {} Bytes", mem_size);
......
......@@ -29,7 +29,7 @@ pub unsafe extern "C" fn loader_main() -> ! {
arch::message_output_init();
loaderlog!(
"Loader: [0x{:x} - 0x{:x}]",
"Loader: [{:#x} - {:#x}]",
&kernel_start as *const u8 as usize,
&kernel_end as *const u8 as usize
);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment