From 53d845f4c37d5f2ae3bc3a2deddbc1f60042dce7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Kr=C3=B6ning?= Date: Wed, 12 Jul 2023 14:14:00 +0200 Subject: [PATCH] Format address types using Pointer trait MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Martin Kröning --- src/arch/aarch64/kernel/interrupts.rs | 4 ++-- src/arch/aarch64/kernel/pci.rs | 2 +- src/arch/aarch64/kernel/scheduler.rs | 6 +++--- src/arch/aarch64/kernel/systemtime.rs | 2 +- src/arch/aarch64/mm/paging.rs | 14 +++++++------- src/arch/aarch64/mm/physicalmem.rs | 2 +- src/arch/aarch64/mm/virtualmem.rs | 6 +++--- src/arch/x86_64/kernel/acpi.rs | 10 +++++----- src/arch/x86_64/kernel/apic.rs | 6 +++--- src/arch/x86_64/kernel/scheduler.rs | 8 ++++---- src/arch/x86_64/mm/paging.rs | 4 ++-- src/arch/x86_64/mm/physicalmem.rs | 4 ++-- src/arch/x86_64/mm/virtualmem.rs | 6 +++--- src/lib.rs | 4 ++-- src/mm/mod.rs | 8 ++++---- src/scheduler/mod.rs | 2 +- 16 files changed, 44 insertions(+), 44 deletions(-) diff --git a/src/arch/aarch64/kernel/interrupts.rs b/src/arch/aarch64/kernel/interrupts.rs index 906f7bb2ad..14a1fc602d 100644 --- a/src/arch/aarch64/kernel/interrupts.rs +++ b/src/arch/aarch64/kernel/interrupts.rs @@ -245,11 +245,11 @@ pub(crate) fn init() { let gicc_size = u64::from_be_bytes(slice.try_into().unwrap()); info!( - "Found GIC Distributor interface at {:#X} (size {:#X})", + "Found GIC Distributor interface at {:p} (size {:#X})", gicd_start, gicd_size ); info!( - "Found generic interrupt controller at {:#X} (size {:#X})", + "Found generic interrupt controller at {:p} (size {:#X})", gicc_start, gicc_size ); diff --git a/src/arch/aarch64/kernel/pci.rs b/src/arch/aarch64/kernel/pci.rs index 204d5a7cee..20835cd1ba 100644 --- a/src/arch/aarch64/kernel/pci.rs +++ b/src/arch/aarch64/kernel/pci.rs @@ -250,7 +250,7 @@ pub fn init() { let pci_address = virtualmem::allocate_aligned(size.try_into().unwrap(), 0x10000000).unwrap(); - info!("Mapping PCI Enhanced Configuration Space interface to virtual address {:#X} (size {:#X})", pci_address, size); + info!("Mapping PCI Enhanced Configuration Space interface to virtual address {:p} (size {:#X})", pci_address, size); let mut flags = PageTableEntryFlags::empty(); flags.device().writable().execute_disable(); diff --git a/src/arch/aarch64/kernel/scheduler.rs b/src/arch/aarch64/kernel/scheduler.rs index 3400dff9b8..1517e23a5e 100644 --- a/src/arch/aarch64/kernel/scheduler.rs +++ b/src/arch/aarch64/kernel/scheduler.rs @@ -131,7 +131,7 @@ impl TaskStacks { .expect("Failed to allocate Physical Memory for TaskStacks"); debug!( - "Create stacks at {:#X} with a size of {} KB", + "Create stacks at {:p} with a size of {} KB", virt_addr, total_size >> 10 ); @@ -174,7 +174,7 @@ impl TaskStacks { pub fn from_boot_stacks() -> TaskStacks { let stack = VirtAddr::from_u64(CURRENT_STACK_ADDRESS.load(Ordering::Relaxed)); - debug!("Using boot stack {:#X}", stack); + debug!("Using boot stack {:p}", stack); TaskStacks::Boot(BootStack { stack }) } @@ -217,7 +217,7 @@ impl Drop for TaskStacks { TaskStacks::Boot(_) => {} TaskStacks::Common(stacks) => { debug!( - "Deallocating stacks at {:#X} with a size of {} KB", + "Deallocating stacks at {:p} with a size of {} KB", stacks.virt_addr, stacks.total_size >> 10, ); diff --git a/src/arch/aarch64/kernel/systemtime.rs b/src/arch/aarch64/kernel/systemtime.rs index d3e46a9795..182345c62c 100644 --- a/src/arch/aarch64/kernel/systemtime.rs +++ b/src/arch/aarch64/kernel/systemtime.rs @@ -65,7 +65,7 @@ pub fn init() { let (slice, _residual_slice) = residual_slice.split_at(core::mem::size_of::()); let size = u64::from_be_bytes(slice.try_into().unwrap()); - debug!("Found RTC at {:#X} (size {:#X})", addr, size); + debug!("Found RTC at {:p} (size {:#X})", addr, size); let pl031_address = virtualmem::allocate_aligned( size.try_into().unwrap(), diff --git a/src/arch/aarch64/mm/paging.rs b/src/arch/aarch64/mm/paging.rs index 12966b14d8..63cf1a9406 100644 --- a/src/arch/aarch64/mm/paging.rs +++ b/src/arch/aarch64/mm/paging.rs @@ -152,7 +152,7 @@ impl PageTableEntry { assert_eq!( physical_address % BasePageSize::SIZE, 0, - "Physical address is not on a 4 KiB page boundary (physical_address = {:#X})", + "Physical address is not on a 4 KiB page boundary (physical_address = {:p})", physical_address ); @@ -256,7 +256,7 @@ impl Page { fn including_address(virtual_address: VirtAddr) -> Self { assert!( Self::is_valid_address(virtual_address), - "Virtual address {:#X} is invalid", + "Virtual address {:p} is invalid", virtual_address ); @@ -556,7 +556,7 @@ fn get_page_range(virtual_address: VirtAddr, count: usize) -> PageI } pub fn get_page_table_entry(virtual_address: VirtAddr) -> Option { - trace!("Looking up Page Table Entry for {:#X}", virtual_address); + trace!("Looking up Page Table Entry for {:p}", virtual_address); let page = Page::::including_address(virtual_address); let root_pagetable = unsafe { &mut *(L0TABLE_ADDRESS.as_mut_ptr() as *mut PageTable) }; @@ -564,7 +564,7 @@ pub fn get_page_table_entry(virtual_address: VirtAddr) -> Option(virtual_address: VirtAddr) -> Option { - trace!("Getting physical address for {:#X}", virtual_address); + trace!("Getting physical address for {:p}", virtual_address); let page = Page::::including_address(virtual_address); let root_pagetable = unsafe { &mut *(L0TABLE_ADDRESS.as_mut_ptr() as *mut PageTable) }; @@ -592,7 +592,7 @@ pub fn map( flags: PageTableEntryFlags, ) { trace!( - "Mapping virtual address {:#X} to physical address {:#X} ({} pages)", + "Mapping virtual address {:p} to physical address {:p} ({} pages)", virtual_address, physical_address, count @@ -620,7 +620,7 @@ pub fn map_heap(virt_addr: VirtAddr, count: usize) { pub fn unmap(virtual_address: VirtAddr, count: usize) { trace!( - "Unmapping virtual address {:#X} ({} pages)", + "Unmapping virtual address {:p} ({} pages)", virtual_address, count ); @@ -639,7 +639,7 @@ pub unsafe fn init() { let aa64mmfr0: u64; let ram_start = get_ram_address(); - info!("RAM starts at physical address 0x{:x}", ram_start); + info!("RAM starts at physical address {:p}", ram_start); // determine physical address size unsafe { diff --git a/src/arch/aarch64/mm/physicalmem.rs b/src/arch/aarch64/mm/physicalmem.rs index 14587a4774..9c5469597c 100644 --- a/src/arch/aarch64/mm/physicalmem.rs +++ b/src/arch/aarch64/mm/physicalmem.rs @@ -93,7 +93,7 @@ pub fn allocate_aligned(size: usize, alignment: usize) -> Result= PhysAddr(mm::kernel_end_address().as_u64()), - "Physical address {:#X} is not >= KERNEL_END_ADDRESS", + "Physical address {:p} is not >= KERNEL_END_ADDRESS", physical_address ); assert!(size > 0); diff --git a/src/arch/aarch64/mm/virtualmem.rs b/src/arch/aarch64/mm/virtualmem.rs index ca8eb6b4c1..d93c193710 100644 --- a/src/arch/aarch64/mm/virtualmem.rs +++ b/src/arch/aarch64/mm/virtualmem.rs @@ -81,18 +81,18 @@ pub fn allocate_aligned(size: usize, alignment: usize) -> Result= mm::kernel_end_address() || virtual_address < mm::kernel_start_address(), - "Virtual address {:#X} belongs to the kernel", + "Virtual address {:p} belongs to the kernel", virtual_address ); assert!( virtual_address < KERNEL_VIRTUAL_MEMORY_END, - "Virtual address {:#X} is not < KERNEL_VIRTUAL_MEMORY_END", + "Virtual address {:p} is not < KERNEL_VIRTUAL_MEMORY_END", virtual_address ); assert_eq!( virtual_address % BasePageSize::SIZE, 0, - "Virtual address {:#X} is not a multiple of {:#X}", + "Virtual address {:p} is not a multiple of {:#X}", virtual_address, BasePageSize::SIZE ); diff --git a/src/arch/x86_64/kernel/acpi.rs b/src/arch/x86_64/kernel/acpi.rs index 0aae16a043..91cfb935b9 100644 --- a/src/arch/x86_64/kernel/acpi.rs +++ b/src/arch/x86_64/kernel/acpi.rs @@ -417,13 +417,13 @@ fn parse_fadt(fadt: AcpiTable<'_>) { // Check it. assert!( dsdt.header.signature() == "DSDT", - "DSDT at {:#X} has invalid signature \"{}\"", + "DSDT at {:p} has invalid signature \"{}\"", dsdt_address, dsdt.header.signature() ); assert!( verify_checksum(dsdt.header_start_address(), dsdt.header.length as usize).is_ok(), - "DSDT at {dsdt_address:#X} has invalid checksum" + "DSDT at {dsdt_address:p} has invalid checksum" ); // Try to find the "_S5_" object for SLP_TYPA in the DSDT AML bytecode. @@ -503,7 +503,7 @@ pub fn init() { // Check and save the entire APIC table for the get_apic_table() call. assert!( verify_checksum(table.header_start_address(), table.header.length as usize).is_ok(), - "MADT at {table_physical_address:#X} has invalid checksum" + "MADT at {table_physical_address:p} has invalid checksum" ); MADT.set(table).unwrap(); } else if table.header.signature() == "FACP" { @@ -511,13 +511,13 @@ pub fn init() { // Check and parse this table for the poweroff() call. assert!( verify_checksum(table.header_start_address(), table.header.length as usize).is_ok(), - "FADT at {table_physical_address:#X} has invalid checksum" + "FADT at {table_physical_address:p} has invalid checksum" ); parse_fadt(table); } else if table.header.signature() == "SSDT" { assert!( verify_checksum(table.header_start_address(), table.header.length as usize).is_ok(), - "SSDT at {table_physical_address:#X} has invalid checksum" + "SSDT at {table_physical_address:p} has invalid checksum" ); parse_ssdt(table); } diff --git a/src/arch/x86_64/kernel/apic.rs b/src/arch/x86_64/kernel/apic.rs index 8b647135d7..f262adfff6 100644 --- a/src/arch/x86_64/kernel/apic.rs +++ b/src/arch/x86_64/kernel/apic.rs @@ -408,7 +408,7 @@ fn detect_from_mp() -> Result { 2 => { let io_entry: &ApicIoEntry = unsafe { &*(addr as *const ApicIoEntry) }; let ioapic = PhysAddr(io_entry.addr.into()); - info!("Found IOAPIC at 0x{:x}", ioapic); + info!("Found IOAPIC at 0x{:p}", ioapic); init_ioapic_address(ioapic); @@ -456,7 +456,7 @@ pub fn init() { let local_apic_address = virtualmem::allocate(BasePageSize::SIZE as usize).unwrap(); LOCAL_APIC_ADDRESS.set(local_apic_address).unwrap(); debug!( - "Mapping Local APIC at {:#X} to virtual address {:#X}", + "Mapping Local APIC at {:p} to virtual address {:p}", local_apic_physical_address, local_apic_address ); @@ -696,7 +696,7 @@ pub fn boot_application_processors() { // Identity-map the boot code page and copy over the code. debug!( - "Mapping SMP boot code to physical and virtual address {:#X}", + "Mapping SMP boot code to physical and virtual address {:p}", SMP_BOOT_CODE_ADDRESS ); let mut flags = PageTableEntryFlags::empty(); diff --git a/src/arch/x86_64/kernel/scheduler.rs b/src/arch/x86_64/kernel/scheduler.rs index 985c189929..4aaf5512ff 100644 --- a/src/arch/x86_64/kernel/scheduler.rs +++ b/src/arch/x86_64/kernel/scheduler.rs @@ -99,7 +99,7 @@ impl TaskStacks { .expect("Failed to allocate Physical Memory for TaskStacks"); debug!( - "Create stacks at {:#X} with a size of {} KB", + "Create stacks at {:p} with a size of {} KB", virt_addr, total_size >> 10 ); @@ -153,11 +153,11 @@ impl TaskStacks { let stack = VirtAddr::from_usize( tss.privilege_stack_table[0].as_u64() as usize + Self::MARKER_SIZE - KERNEL_STACK_SIZE, ); - debug!("Using boot stack {:#X}", stack); + debug!("Using boot stack {:p}", stack); let ist1 = VirtAddr::from_usize( tss.interrupt_stack_table[0].as_u64() as usize + Self::MARKER_SIZE - IST_SIZE, ); - debug!("IST1 is located at {:#X}", ist1); + debug!("IST1 is located at {:p}", ist1); TaskStacks::Boot(BootStack { stack, ist1 }) } @@ -211,7 +211,7 @@ impl Drop for TaskStacks { TaskStacks::Boot(_) => {} TaskStacks::Common(stacks) => { debug!( - "Deallocating stacks at {:#X} with a size of {} KB", + "Deallocating stacks at {:p} with a size of {} KB", stacks.virt_addr, stacks.total_size >> 10, ); diff --git a/src/arch/x86_64/mm/paging.rs b/src/arch/x86_64/mm/paging.rs index 67584556a3..f6ae7d6881 100644 --- a/src/arch/x86_64/mm/paging.rs +++ b/src/arch/x86_64/mm/paging.rs @@ -165,7 +165,7 @@ where { assert!( frame.start_address().as_u64() < mm::kernel_start_address().0, - "Address {:#X} to be identity-mapped is not below Kernel start address", + "Address {:p} to be identity-mapped is not below Kernel start address", frame.start_address() ); @@ -187,7 +187,7 @@ where RecursivePageTable<'static>: Mapper, { trace!( - "Unmapping virtual address {:#X} ({} pages)", + "Unmapping virtual address {:p} ({} pages)", virtual_address, count ); diff --git a/src/arch/x86_64/mm/physicalmem.rs b/src/arch/x86_64/mm/physicalmem.rs index 39afbf8aba..b6293b11c7 100644 --- a/src/arch/x86_64/mm/physicalmem.rs +++ b/src/arch/x86_64/mm/physicalmem.rs @@ -158,7 +158,7 @@ pub fn allocate_aligned(size: usize, alignment: usize) -> Result= PhysAddr(mm::kernel_end_address().as_u64()), - "Physical address {physical_address:#X} is not >= KERNEL_END_ADDRESS" + "Physical address {physical_address:p} is not >= KERNEL_END_ADDRESS" ); assert!(size > 0); assert_eq!( @@ -179,7 +179,7 @@ pub fn reserve(physical_address: PhysAddr, size: usize) { assert_eq!( physical_address % BasePageSize::SIZE as usize, 0, - "Physical address {:#X} is not a multiple of {:#X}", + "Physical address {:p} is not a multiple of {:#X}", physical_address, BasePageSize::SIZE ); diff --git a/src/arch/x86_64/mm/virtualmem.rs b/src/arch/x86_64/mm/virtualmem.rs index 56db39b164..bd2a6dff2b 100644 --- a/src/arch/x86_64/mm/virtualmem.rs +++ b/src/arch/x86_64/mm/virtualmem.rs @@ -66,16 +66,16 @@ pub fn allocate_aligned(size: usize, alignment: usize) -> Result= VirtAddr(mm::kernel_end_address().as_u64()), - "Virtual address {virtual_address:#X} is not >= KERNEL_END_ADDRESS" + "Virtual address {virtual_address:p} is not >= KERNEL_END_ADDRESS" ); assert!( virtual_address < kernel_heap_end(), - "Virtual address {virtual_address:#X} is not < kernel_heap_end()" + "Virtual address {virtual_address:p} is not < kernel_heap_end()" ); assert_eq!( virtual_address % BasePageSize::SIZE, 0, - "Virtual address {:#X} is not a multiple of {:#X}", + "Virtual address {:p} is not a multiple of {:#X}", virtual_address, BasePageSize::SIZE ); diff --git a/src/lib.rs b/src/lib.rs index 42f8fc6e33..ea9a1e287f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -303,7 +303,7 @@ fn boot_processor_main() -> ! { } info!("Welcome to HermitCore-rs {}", env!("CARGO_PKG_VERSION")); - info!("Kernel starts at {:#x}", env::get_base_address()); + info!("Kernel starts at {:p}", env::get_base_address()); extern "C" { static mut __bss_start: u8; @@ -312,7 +312,7 @@ fn boot_processor_main() -> ! { core::ptr::addr_of_mut!(__bss_start) }); info!( - "TLS starts at {:#x} (size {} Bytes)", + "TLS starts at {:p} (size {} Bytes)", env::get_tls_start(), env::get_tls_memsz() ); diff --git a/src/mm/mod.rs b/src/mm/mod.rs index 67594ad155..771ead996d 100644 --- a/src/mm/mod.rs +++ b/src/mm/mod.rs @@ -66,7 +66,7 @@ pub fn init() { info!("Total memory size: {} MB", total_memory_size() >> 20); info!( - "Kernel region: [{:#x} - {:#x}]", + "Kernel region: [{:p} - {:p}]", kernel_start_address(), kernel_end_address() ); @@ -152,7 +152,7 @@ pub fn init() { }; info!( - "Heap: size {} MB, start address {:#x}", + "Heap: size {} MB, start address {:p}", virt_size >> 20, virt_addr ); @@ -254,7 +254,7 @@ pub fn deallocate(virtual_address: VirtAddr, sz: usize) { arch::mm::physicalmem::deallocate(phys_addr, size); } else { panic!( - "No page table entry for virtual address {:#X}", + "No page table entry for virtual address {:p}", virtual_address ); } @@ -303,7 +303,7 @@ pub fn unmap(virtual_address: VirtAddr, sz: usize) { arch::mm::virtualmem::deallocate(virtual_address, size); } else { panic!( - "No page table entry for virtual address {:#X}", + "No page table entry for virtual address {:p}", virtual_address ); } diff --git a/src/scheduler/mod.rs b/src/scheduler/mod.rs index a93ec3b0c9..094e080640 100644 --- a/src/scheduler/mod.rs +++ b/src/scheduler/mod.rs @@ -658,7 +658,7 @@ impl PerCoreScheduler { if id != new_id { // Tell the scheduler about the new task. debug!( - "Switching task from {} to {} (stack {:#X} => {:#X})", + "Switching task from {} to {} (stack {:#X} => {:p})", id, new_id, unsafe { *last_stack_pointer },