Skip to content

Commit 16edea6

Browse files
authored
Merge pull request #791 from mkroening/fmt-ptr
Format pointer types using Pointer trait
2 parents e522eb1 + 53d845f commit 16edea6

File tree

16 files changed

+55
-55
lines changed

16 files changed

+55
-55
lines changed

src/arch/aarch64/kernel/interrupts.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -245,11 +245,11 @@ pub(crate) fn init() {
245245
let gicc_size = u64::from_be_bytes(slice.try_into().unwrap());
246246

247247
info!(
248-
"Found GIC Distributor interface at {:#X} (size {:#X})",
248+
"Found GIC Distributor interface at {:p} (size {:#X})",
249249
gicd_start, gicd_size
250250
);
251251
info!(
252-
"Found generic interrupt controller at {:#X} (size {:#X})",
252+
"Found generic interrupt controller at {:p} (size {:#X})",
253253
gicc_start, gicc_size
254254
);
255255

src/arch/aarch64/kernel/pci.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ pub fn init() {
250250

251251
let pci_address =
252252
virtualmem::allocate_aligned(size.try_into().unwrap(), 0x10000000).unwrap();
253-
info!("Mapping PCI Enhanced Configuration Space interface to virtual address {:#X} (size {:#X})", pci_address, size);
253+
info!("Mapping PCI Enhanced Configuration Space interface to virtual address {:p} (size {:#X})", pci_address, size);
254254

255255
let mut flags = PageTableEntryFlags::empty();
256256
flags.device().writable().execute_disable();

src/arch/aarch64/kernel/scheduler.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ impl TaskStacks {
131131
.expect("Failed to allocate Physical Memory for TaskStacks");
132132

133133
debug!(
134-
"Create stacks at {:#X} with a size of {} KB",
134+
"Create stacks at {:p} with a size of {} KB",
135135
virt_addr,
136136
total_size >> 10
137137
);
@@ -174,7 +174,7 @@ impl TaskStacks {
174174

175175
pub fn from_boot_stacks() -> TaskStacks {
176176
let stack = VirtAddr::from_u64(CURRENT_STACK_ADDRESS.load(Ordering::Relaxed));
177-
debug!("Using boot stack {:#X}", stack);
177+
debug!("Using boot stack {:p}", stack);
178178

179179
TaskStacks::Boot(BootStack { stack })
180180
}
@@ -217,7 +217,7 @@ impl Drop for TaskStacks {
217217
TaskStacks::Boot(_) => {}
218218
TaskStacks::Common(stacks) => {
219219
debug!(
220-
"Deallocating stacks at {:#X} with a size of {} KB",
220+
"Deallocating stacks at {:p} with a size of {} KB",
221221
stacks.virt_addr,
222222
stacks.total_size >> 10,
223223
);

src/arch/aarch64/kernel/systemtime.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ pub fn init() {
6565
let (slice, _residual_slice) = residual_slice.split_at(core::mem::size_of::<u64>());
6666
let size = u64::from_be_bytes(slice.try_into().unwrap());
6767

68-
debug!("Found RTC at {:#X} (size {:#X})", addr, size);
68+
debug!("Found RTC at {:p} (size {:#X})", addr, size);
6969

7070
let pl031_address = virtualmem::allocate_aligned(
7171
size.try_into().unwrap(),

src/arch/aarch64/mm/paging.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ impl PageTableEntry {
152152
assert_eq!(
153153
physical_address % BasePageSize::SIZE,
154154
0,
155-
"Physical address is not on a 4 KiB page boundary (physical_address = {:#X})",
155+
"Physical address is not on a 4 KiB page boundary (physical_address = {:p})",
156156
physical_address
157157
);
158158

@@ -256,7 +256,7 @@ impl<S: PageSize> Page<S> {
256256
fn including_address(virtual_address: VirtAddr) -> Self {
257257
assert!(
258258
Self::is_valid_address(virtual_address),
259-
"Virtual address {:#X} is invalid",
259+
"Virtual address {:p} is invalid",
260260
virtual_address
261261
);
262262

@@ -556,15 +556,15 @@ fn get_page_range<S: PageSize>(virtual_address: VirtAddr, count: usize) -> PageI
556556
}
557557

558558
pub fn get_page_table_entry<S: PageSize>(virtual_address: VirtAddr) -> Option<PageTableEntry> {
559-
trace!("Looking up Page Table Entry for {:#X}", virtual_address);
559+
trace!("Looking up Page Table Entry for {:p}", virtual_address);
560560

561561
let page = Page::<S>::including_address(virtual_address);
562562
let root_pagetable = unsafe { &mut *(L0TABLE_ADDRESS.as_mut_ptr() as *mut PageTable<L0Table>) };
563563
root_pagetable.get_page_table_entry(page)
564564
}
565565

566566
pub fn get_physical_address<S: PageSize>(virtual_address: VirtAddr) -> Option<PhysAddr> {
567-
trace!("Getting physical address for {:#X}", virtual_address);
567+
trace!("Getting physical address for {:p}", virtual_address);
568568

569569
let page = Page::<S>::including_address(virtual_address);
570570
let root_pagetable = unsafe { &mut *(L0TABLE_ADDRESS.as_mut_ptr() as *mut PageTable<L0Table>) };
@@ -592,7 +592,7 @@ pub fn map<S: PageSize>(
592592
flags: PageTableEntryFlags,
593593
) {
594594
trace!(
595-
"Mapping virtual address {:#X} to physical address {:#X} ({} pages)",
595+
"Mapping virtual address {:p} to physical address {:p} ({} pages)",
596596
virtual_address,
597597
physical_address,
598598
count
@@ -620,7 +620,7 @@ pub fn map_heap<S: PageSize>(virt_addr: VirtAddr, count: usize) {
620620

621621
pub fn unmap<S: PageSize>(virtual_address: VirtAddr, count: usize) {
622622
trace!(
623-
"Unmapping virtual address {:#X} ({} pages)",
623+
"Unmapping virtual address {:p} ({} pages)",
624624
virtual_address,
625625
count
626626
);
@@ -639,7 +639,7 @@ pub unsafe fn init() {
639639
let aa64mmfr0: u64;
640640

641641
let ram_start = get_ram_address();
642-
info!("RAM starts at physical address 0x{:x}", ram_start);
642+
info!("RAM starts at physical address {:p}", ram_start);
643643

644644
// determine physical address size
645645
unsafe {

src/arch/aarch64/mm/physicalmem.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ pub fn allocate_aligned(size: usize, alignment: usize) -> Result<PhysAddr, Alloc
9393
pub fn deallocate(physical_address: PhysAddr, size: usize) {
9494
assert!(
9595
physical_address >= PhysAddr(mm::kernel_end_address().as_u64()),
96-
"Physical address {:#X} is not >= KERNEL_END_ADDRESS",
96+
"Physical address {:p} is not >= KERNEL_END_ADDRESS",
9797
physical_address
9898
);
9999
assert!(size > 0);

src/arch/aarch64/mm/virtualmem.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,18 +81,18 @@ pub fn allocate_aligned(size: usize, alignment: usize) -> Result<VirtAddr, Alloc
8181
pub fn deallocate(virtual_address: VirtAddr, size: usize) {
8282
assert!(
8383
virtual_address >= mm::kernel_end_address() || virtual_address < mm::kernel_start_address(),
84-
"Virtual address {:#X} belongs to the kernel",
84+
"Virtual address {:p} belongs to the kernel",
8585
virtual_address
8686
);
8787
assert!(
8888
virtual_address < KERNEL_VIRTUAL_MEMORY_END,
89-
"Virtual address {:#X} is not < KERNEL_VIRTUAL_MEMORY_END",
89+
"Virtual address {:p} is not < KERNEL_VIRTUAL_MEMORY_END",
9090
virtual_address
9191
);
9292
assert_eq!(
9393
virtual_address % BasePageSize::SIZE,
9494
0,
95-
"Virtual address {:#X} is not a multiple of {:#X}",
95+
"Virtual address {:p} is not a multiple of {:#X}",
9696
virtual_address,
9797
BasePageSize::SIZE
9898
);

src/arch/x86_64/kernel/acpi.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -417,13 +417,13 @@ fn parse_fadt(fadt: AcpiTable<'_>) {
417417
// Check it.
418418
assert!(
419419
dsdt.header.signature() == "DSDT",
420-
"DSDT at {:#X} has invalid signature \"{}\"",
420+
"DSDT at {:p} has invalid signature \"{}\"",
421421
dsdt_address,
422422
dsdt.header.signature()
423423
);
424424
assert!(
425425
verify_checksum(dsdt.header_start_address(), dsdt.header.length as usize).is_ok(),
426-
"DSDT at {dsdt_address:#X} has invalid checksum"
426+
"DSDT at {dsdt_address:p} has invalid checksum"
427427
);
428428

429429
// Try to find the "_S5_" object for SLP_TYPA in the DSDT AML bytecode.
@@ -503,21 +503,21 @@ pub fn init() {
503503
// Check and save the entire APIC table for the get_apic_table() call.
504504
assert!(
505505
verify_checksum(table.header_start_address(), table.header.length as usize).is_ok(),
506-
"MADT at {table_physical_address:#X} has invalid checksum"
506+
"MADT at {table_physical_address:p} has invalid checksum"
507507
);
508508
MADT.set(table).unwrap();
509509
} else if table.header.signature() == "FACP" {
510510
// The "Fixed ACPI Description Table" (FADT) aka "Fixed ACPI Control Pointer" (FACP)
511511
// Check and parse this table for the poweroff() call.
512512
assert!(
513513
verify_checksum(table.header_start_address(), table.header.length as usize).is_ok(),
514-
"FADT at {table_physical_address:#X} has invalid checksum"
514+
"FADT at {table_physical_address:p} has invalid checksum"
515515
);
516516
parse_fadt(table);
517517
} else if table.header.signature() == "SSDT" {
518518
assert!(
519519
verify_checksum(table.header_start_address(), table.header.length as usize).is_ok(),
520-
"SSDT at {table_physical_address:#X} has invalid checksum"
520+
"SSDT at {table_physical_address:p} has invalid checksum"
521521
);
522522
parse_ssdt(table);
523523
}

src/arch/x86_64/kernel/apic.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ fn detect_from_mp() -> Result<PhysAddr, ()> {
408408
2 => {
409409
let io_entry: &ApicIoEntry = unsafe { &*(addr as *const ApicIoEntry) };
410410
let ioapic = PhysAddr(io_entry.addr.into());
411-
info!("Found IOAPIC at 0x{:x}", ioapic);
411+
info!("Found IOAPIC at 0x{:p}", ioapic);
412412

413413
init_ioapic_address(ioapic);
414414

@@ -456,7 +456,7 @@ pub fn init() {
456456
let local_apic_address = virtualmem::allocate(BasePageSize::SIZE as usize).unwrap();
457457
LOCAL_APIC_ADDRESS.set(local_apic_address).unwrap();
458458
debug!(
459-
"Mapping Local APIC at {:#X} to virtual address {:#X}",
459+
"Mapping Local APIC at {:p} to virtual address {:p}",
460460
local_apic_physical_address, local_apic_address
461461
);
462462

@@ -696,7 +696,7 @@ pub fn boot_application_processors() {
696696

697697
// Identity-map the boot code page and copy over the code.
698698
debug!(
699-
"Mapping SMP boot code to physical and virtual address {:#X}",
699+
"Mapping SMP boot code to physical and virtual address {:p}",
700700
SMP_BOOT_CODE_ADDRESS
701701
);
702702
let mut flags = PageTableEntryFlags::empty();

src/arch/x86_64/kernel/scheduler.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ impl TaskStacks {
9999
.expect("Failed to allocate Physical Memory for TaskStacks");
100100

101101
debug!(
102-
"Create stacks at {:#X} with a size of {} KB",
102+
"Create stacks at {:p} with a size of {} KB",
103103
virt_addr,
104104
total_size >> 10
105105
);
@@ -153,11 +153,11 @@ impl TaskStacks {
153153
let stack = VirtAddr::from_usize(
154154
tss.privilege_stack_table[0].as_u64() as usize + Self::MARKER_SIZE - KERNEL_STACK_SIZE,
155155
);
156-
debug!("Using boot stack {:#X}", stack);
156+
debug!("Using boot stack {:p}", stack);
157157
let ist1 = VirtAddr::from_usize(
158158
tss.interrupt_stack_table[0].as_u64() as usize + Self::MARKER_SIZE - IST_SIZE,
159159
);
160-
debug!("IST1 is located at {:#X}", ist1);
160+
debug!("IST1 is located at {:p}", ist1);
161161

162162
TaskStacks::Boot(BootStack { stack, ist1 })
163163
}
@@ -211,7 +211,7 @@ impl Drop for TaskStacks {
211211
TaskStacks::Boot(_) => {}
212212
TaskStacks::Common(stacks) => {
213213
debug!(
214-
"Deallocating stacks at {:#X} with a size of {} KB",
214+
"Deallocating stacks at {:p} with a size of {} KB",
215215
stacks.virt_addr,
216216
stacks.total_size >> 10,
217217
);

src/arch/x86_64/mm/paging.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ where
165165
{
166166
assert!(
167167
frame.start_address().as_u64() < mm::kernel_start_address().0,
168-
"Address {:#X} to be identity-mapped is not below Kernel start address",
168+
"Address {:p} to be identity-mapped is not below Kernel start address",
169169
frame.start_address()
170170
);
171171

@@ -187,7 +187,7 @@ where
187187
RecursivePageTable<'static>: Mapper<S>,
188188
{
189189
trace!(
190-
"Unmapping virtual address {:#X} ({} pages)",
190+
"Unmapping virtual address {:p} ({} pages)",
191191
virtual_address,
192192
count
193193
);

src/arch/x86_64/mm/physicalmem.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ pub fn allocate_aligned(size: usize, alignment: usize) -> Result<PhysAddr, Alloc
158158
pub fn deallocate(physical_address: PhysAddr, size: usize) {
159159
assert!(
160160
physical_address >= PhysAddr(mm::kernel_end_address().as_u64()),
161-
"Physical address {physical_address:#X} is not >= KERNEL_END_ADDRESS"
161+
"Physical address {physical_address:p} is not >= KERNEL_END_ADDRESS"
162162
);
163163
assert!(size > 0);
164164
assert_eq!(
@@ -179,7 +179,7 @@ pub fn reserve(physical_address: PhysAddr, size: usize) {
179179
assert_eq!(
180180
physical_address % BasePageSize::SIZE as usize,
181181
0,
182-
"Physical address {:#X} is not a multiple of {:#X}",
182+
"Physical address {:p} is not a multiple of {:#X}",
183183
physical_address,
184184
BasePageSize::SIZE
185185
);

src/arch/x86_64/mm/virtualmem.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,16 +66,16 @@ pub fn allocate_aligned(size: usize, alignment: usize) -> Result<VirtAddr, Alloc
6666
pub fn deallocate(virtual_address: VirtAddr, size: usize) {
6767
assert!(
6868
virtual_address >= VirtAddr(mm::kernel_end_address().as_u64()),
69-
"Virtual address {virtual_address:#X} is not >= KERNEL_END_ADDRESS"
69+
"Virtual address {virtual_address:p} is not >= KERNEL_END_ADDRESS"
7070
);
7171
assert!(
7272
virtual_address < kernel_heap_end(),
73-
"Virtual address {virtual_address:#X} is not < kernel_heap_end()"
73+
"Virtual address {virtual_address:p} is not < kernel_heap_end()"
7474
);
7575
assert_eq!(
7676
virtual_address % BasePageSize::SIZE,
7777
0,
78-
"Virtual address {:#X} is not a multiple of {:#X}",
78+
"Virtual address {:p} is not a multiple of {:#X}",
7979
virtual_address,
8080
BasePageSize::SIZE
8181
);

src/lib.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ pub(crate) extern "C" fn __sys_malloc(size: usize, align: usize) -> *mut u8 {
136136
let ptr = unsafe { ALLOCATOR.alloc(layout) };
137137

138138
trace!(
139-
"__sys_malloc: allocate memory at {:#x} (size {:#x}, align {:#x})",
140-
ptr as usize,
139+
"__sys_malloc: allocate memory at {:p} (size {:#x}, align {:#x})",
140+
ptr,
141141
size,
142142
align
143143
);
@@ -175,8 +175,8 @@ pub(crate) extern "C" fn __sys_realloc(
175175
let layout_res = Layout::from_size_align(size, align);
176176
if layout_res.is_err() || size == 0 || new_size == 0 {
177177
warn!(
178-
"__sys_realloc called with ptr {:#x}, size {:#x}, align {:#x}, new_size {:#x} is an invalid layout!",
179-
ptr as usize, size, align, new_size
178+
"__sys_realloc called with ptr {:p}, size {:#x}, align {:#x}, new_size {:#x} is an invalid layout!",
179+
ptr, size, align, new_size
180180
);
181181
return core::ptr::null::<*mut u8>() as *mut u8;
182182
}
@@ -185,14 +185,14 @@ pub(crate) extern "C" fn __sys_realloc(
185185

186186
if new_ptr.is_null() {
187187
debug!(
188-
"__sys_realloc failed to resize ptr {:#x} with size {:#x}, align {:#x}, new_size {:#x} !",
189-
ptr as usize, size, align, new_size
188+
"__sys_realloc failed to resize ptr {:p} with size {:#x}, align {:#x}, new_size {:#x} !",
189+
ptr, size, align, new_size
190190
);
191191
} else {
192192
trace!(
193-
"__sys_realloc: resized memory at {:#x}, new address {:#x}",
194-
ptr as usize,
195-
new_ptr as usize
193+
"__sys_realloc: resized memory at {:p}, new address {:p}",
194+
ptr,
195+
new_ptr
196196
);
197197
}
198198
new_ptr
@@ -222,8 +222,8 @@ pub(crate) extern "C" fn __sys_free(ptr: *mut u8, size: usize, align: usize) {
222222
debug_assert_ne!(size, 0, "__sys_free error: size cannot be 0");
223223
} else {
224224
trace!(
225-
"sys_free: deallocate memory at {:#x} (size {:#x})",
226-
ptr as usize,
225+
"sys_free: deallocate memory at {:p} (size {:#x})",
226+
ptr,
227227
size
228228
);
229229
}
@@ -303,7 +303,7 @@ fn boot_processor_main() -> ! {
303303
}
304304

305305
info!("Welcome to HermitCore-rs {}", env!("CARGO_PKG_VERSION"));
306-
info!("Kernel starts at {:#x}", env::get_base_address());
306+
info!("Kernel starts at {:p}", env::get_base_address());
307307

308308
extern "C" {
309309
static mut __bss_start: u8;
@@ -312,7 +312,7 @@ fn boot_processor_main() -> ! {
312312
core::ptr::addr_of_mut!(__bss_start)
313313
});
314314
info!(
315-
"TLS starts at {:#x} (size {} Bytes)",
315+
"TLS starts at {:p} (size {} Bytes)",
316316
env::get_tls_start(),
317317
env::get_tls_memsz()
318318
);

0 commit comments

Comments
 (0)