Commit ad5e9360 authored by Martin Kröning's avatar Martin Kröning 🦀
Browse files

fmt: Replace hex prefix with alternate flag

parent a5a5744b
......@@ -71,34 +71,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)
}
......
......@@ -230,7 +230,7 @@ impl TaskTLS {
impl Drop for TaskTLS {
fn drop(&mut self) {
/*debug!(
"Deallocate TLS at 0x{:x} (layout {:?})",
"Deallocate TLS at {:#x} (layout {:?})",
self.address, self.layout,
);
......
......@@ -541,7 +541,7 @@ pub fn init_next_processor_variables(core_id: CoreId) {
);
trace!(
"Initialize per core data at 0x{:x} (size {} bytes)",
"Initialize per core data at {:#x} (size {} bytes)",
core::ptr::read_volatile(&(*BOOT_INFO).current_percore_address),
mem::size_of::<PerCoreVariables>()
);
......@@ -592,7 +592,7 @@ pub fn boot_application_processors() {
cr3().try_into().unwrap();
// Set entry point
debug!(
"Set entry point for application processor to 0x{:x}",
"Set entry point for application processor to {:#x}",
_start as usize
);
*((SMP_BOOT_CODE_ADDRESS + SMP_BOOT_CODE_OFFSET_ENTRY).as_mut_ptr()) = _start as usize;
......
......@@ -122,7 +122,7 @@ pub fn install() {
let is_init = IDT_INIT.swap(true, Ordering::SeqCst);
if !is_init {
debug!("IDT address: 0x{:x}", &IDT.entries as *const _ as usize);
debug!("IDT address: {:#x}", &IDT.entries as *const _ as usize);
// TODO: As soon as https://github.com/rust-lang/rust/issues/44580 is implemented, it should be possible to
// implement "new" as "const fn" and do this call already in the initialization of IDTP.
......
......@@ -379,7 +379,7 @@ pub fn boot_processor_init() {
processor::detect_frequency();
processor::print_information();
unsafe {
trace!("Cr0: 0x{:x}, Cr4: 0x{:x}", cr0(), cr4());
trace!("Cr0: {:#x}, Cr4: {:#x}", cr0(), cr4());
}
systemtime::init();
......@@ -421,7 +421,7 @@ pub fn application_processor_init() {
apic::init_x2apic();
apic::init_local_apic();
unsafe {
trace!("Cr0: 0x{:x}, Cr4: 0x{:x}", cr0(), cr4());
trace!("Cr0: {:#x}, Cr4: {:#x}", cr0(), cr4());
}
irq::enable();
finish_processor_init();
......
......@@ -173,7 +173,7 @@ fn parse_bars(bus: u8, device: u8, vendor_id: u16, device_id: u16) -> Vec<PciBar
let register = PCI_BAR0_REGISTER + ((i as u32) << 2);
let barword = read_config(bus, device, register);
debug!(
"Found bar{} @{:x}:{:x} as 0x{:x}",
"Found bar{} @{:x}:{:x} as {:#x}",
i, vendor_id, device_id, barword
);
......@@ -214,7 +214,7 @@ fn parse_bars(bus: u8, device: u8, vendor_id: u16, device_id: u16) -> Vec<PciBar
let base_addr = ((barword_high as usize) << 32) + (barword & 0xFFFF_FFF0) as usize;
debug!(
"64-bit memory bar, merged next barword. Addr: 0x{:x}",
"64-bit memory bar, merged next barword. Addr: {:#x}",
base_addr
);
......@@ -345,7 +345,7 @@ impl PciAdapter {
};
debug!(
"Mapping bar {} at 0x{:x} with length 0x{:x}",
"Mapping bar {} at {:#x} with length {:#x}",
index, pci_bar.addr, pci_bar.size
);
......@@ -379,7 +379,7 @@ impl fmt::Display for PciBar {
PciBar::IO(io_bar) => ("IOBar", io_bar.addr as usize, io_bar.size as usize),
PciBar::Memory(mem_bar) => ("MemoryBar", mem_bar.addr, mem_bar.size),
};
write!(f, "{}: 0x{:x} (size 0x{:x})", typ, addr, size)?;
write!(f, "{}: {:#x} (size {:#x})", typ, addr, size)?;
Ok(())
}
......@@ -512,7 +512,7 @@ pub fn init_drivers() {
.filter(|x| x.vendor_id == 0x1AF4 && x.device_id >= 0x1000 && x.device_id <= 0x107F)
} {
info!(
"Found virtio network device with device id 0x{:x}",
"Found virtio network device with device id {:#x}",
adapter.device_id
);
......@@ -531,7 +531,7 @@ pub fn init_drivers() {
})
} {
info!(
"Found Realtek network device with device id 0x{:x}",
"Found Realtek network device with device id {:#x}",
adapter.device_id
);
......
......@@ -763,7 +763,7 @@ pub fn configure() {
// Prevent writes to read-only pages in Ring 0.
cr0.insert(Cr0::CR0_WRITE_PROTECT);
debug!("Set CR0 to 0x{:x}", cr0);
debug!("Set CR0 to {:#x}", cr0);
unsafe {
cr0_write(cr0);
}
......@@ -803,7 +803,7 @@ pub fn configure() {
crate::__sys_shutdown(1);
}
debug!("Set CR4 to 0x{:x}", cr4);
debug!("Set CR4 to {:#x}", cr4);
unsafe {
cr4_write(cr4);
}
......@@ -821,7 +821,7 @@ pub fn configure() {
xcr0.insert(Xcr0::XCR0_AVX_STATE);
}
debug!("Set XCR0 to 0x{:x}", xcr0);
debug!("Set XCR0 to {:#x}", xcr0);
unsafe {
xcr0_write(xcr0);
}
......
......@@ -292,7 +292,7 @@ impl TaskTLS {
}
debug!(
"Set up TLS at 0x{:x}, tdata_size 0x{:x}, tls_size 0x{:x}",
"Set up TLS at {:#x}, tdata_size {:#x}, tls_size {:#x}",
tls_pointer, tdata_size, tls_size
);
......@@ -317,7 +317,7 @@ impl TaskTLS {
impl Drop for TaskTLS {
fn drop(&mut self) {
debug!(
"Deallocate TLS at 0x{:x} (layout {:?})",
"Deallocate TLS at {:#x} (layout {:?})",
self.address, self.layout,
);
......
......@@ -744,7 +744,7 @@ pub fn init_page_tables() {
let pml4 = controlregs::cr3();
let pde = pml4 + 2 * BasePageSize::SIZE as u64;
debug!("Found PML4 at 0x{:x}", pml4);
debug!("Found PML4 at {:#x}", pml4);
// make sure that only the required areas are mapped
let start = pde
......@@ -763,7 +763,7 @@ pub fn init_page_tables() {
// Identity-map the supplied Multiboot information and command line.
let mb_info = get_mbinfo();
if !mb_info.is_zero() {
info!("Found Multiboot info at 0x{:x}", mb_info);
info!("Found Multiboot info at {:#x}", mb_info);
identity_map(PhysAddr(mb_info.as_u64()), PhysAddr(mb_info.as_u64()));
// Map the "Memory Map" information too.
......@@ -780,7 +780,7 @@ pub fn init_page_tables() {
let cmdsize = environment::get_cmdsize();
if cmdsize > 0 {
let cmdline = environment::get_cmdline();
info!("Found cmdline at 0x{:x} (size {})", cmdline, cmdsize);
info!("Found cmdline at {:#x} (size {})", cmdline, cmdsize);
identity_map(
PhysAddr(cmdline.as_u64()),
PhysAddr(cmdline.as_u64()) + cmdsize - 1u64,
......
......@@ -294,7 +294,7 @@ impl NetworkInterface for RTL8139Driver {
))
} else {
error!(
"RTL8192: invalid header 0x{:x}, rx_pos {}\n",
"RTL8192: invalid header {:#x}, rx_pos {}\n",
header, self.rxpos
);
......@@ -423,7 +423,7 @@ pub fn init_device(adapter: &pci::PciAdapter) -> Result<RTL8139Driver, DriverErr
.unwrap();
debug!(
"Found RTL8139 at iobase 0x{:x} (irq {})",
"Found RTL8139 at iobase {:#x} (irq {})",
iobase, adapter.irq
);
......@@ -511,7 +511,7 @@ pub fn init_device(adapter: &pci::PciAdapter) -> Result<RTL8139Driver, DriverErr
}
debug!(
"Allocate TxBuffer at 0x{:x} and RxBuffer at 0x{:x}",
"Allocate TxBuffer at {:#x} and RxBuffer at {:#x}",
txbuffer, rxbuffer
);
......@@ -567,7 +567,7 @@ pub fn init_device(adapter: &pci::PciAdapter) -> Result<RTL8139Driver, DriverErr
outb(iobase + CR, CR_TE | CR_RE); // Sets the RE and TE bits high
info!(
"RTL8139: CR = 0x{:x}, ISR = 0x{:x}, speed = {} mbps",
"RTL8139: CR = {:#x}, ISR = {:#x}, speed = {} mbps",
inb(iobase + CR),
inw(iobase + ISR),
speed
......
......@@ -172,7 +172,7 @@ impl<'a> Virtq<'a> {
common_cfg.queue_enable = 1;
debug!(
"desc 0x{:x}, avail 0x{:x}, used 0x{:x}",
"desc {:#x}, avail {:#x}, used {:#x}",
common_cfg.queue_desc, common_cfg.queue_avail, common_cfg.queue_used
);
......@@ -747,7 +747,7 @@ pub fn map_virtiocap(
let mut nextcaplist = caplist;
if nextcaplist < 0x40 {
error!(
"Caplist inside header! Offset: 0x{:x}, Aborting",
"Caplist inside header! Offset: {:#x}, Aborting",
nextcaplist
);
return None;
......@@ -766,7 +766,7 @@ pub fn map_virtiocap(
}
let captypeword = pci::read_config(bus, device, nextcaplist);
debug!(
"Read cap at offset 0x{:x}: captype 0x{:x}",
"Read cap at offset {:#x}: captype {:#x}",
nextcaplist, captypeword
);
let captype = captypeword & 0xFF; // pci cap type
......@@ -785,7 +785,7 @@ pub fn map_virtiocap(
let offset: usize = pci::read_config(bus, device, virtiocapoffset + 8) as usize; // get offset_of!(virtio_pci_cap, offset)
let length: usize = pci::read_config(bus, device, virtiocapoffset + 12) as usize; // get offset_of!(virtio_pci_cap, length)
debug!(
"Found virtio config bar as 0x{:x}, offset 0x{:x}, length 0x{:x}",
"Found virtio config bar as {:#x}, offset {:#x}, length {:#x}",
baridx, offset, length
);
......@@ -795,7 +795,7 @@ pub fn map_virtiocap(
if size < offset + length {
error!(
"virtio config struct does not fit in bar! Aborting! 0x{:x} < 0x{:x}",
"virtio config struct does not fit in bar! Aborting! {:#x} < {:#x}",
size,
offset + length
);
......
......@@ -236,7 +236,7 @@ impl<'a> fmt::Debug for VirtioNetDriver<'a> {
write!(f, "VirtioNetDriver {{ ")?;
write!(f, "common_cfg: {:?}, ", self.common_cfg)?;
write!(f, "device_cfg: {:?}, ", self.device_cfg)?;
write!(f, "isr_cfg: 0x{:x}, ", self.isr_cfg)?;
write!(f, "isr_cfg: {:#x}, ", self.isr_cfg)?;
write!(f, "nofity_cfg: {:?}, ", self.notify_cfg)?;
match &self.vqueues {
None => write!(f, "Uninitialized VQs")?,
......@@ -309,15 +309,12 @@ impl<'a> VirtioNetDriver<'a> {
common_cfg.driver_feature_select = 1;
common_cfg.driver_feature |= required as u32;
info!(
"Virtio features: device 0x{:x} vs required 0x{:x}",
"Virtio features: device {:#x} vs required {:#x}",
device_features, required
);
} else {
error!("Device doesn't offer required feature to support Virtio-Net");
error!(
"Virtio features: 0x{:x} vs 0x{:x}",
device_features, required
);
error!("Virtio features: {:#x} vs {:#x}", device_features, required);
}
}
......@@ -533,7 +530,7 @@ pub fn create_virtionet_driver(adapter: &pci::PciAdapter) -> Option<VirtioNetDri
} else {
info!("Virtio-Net link is down");
}
info!("Virtio-Net status: 0x{:x}", drv.common_cfg.device_status);
info!("Virtio-Net status: {:#x}", drv.common_cfg.device_status);
Some(drv)
}
......@@ -31,14 +31,14 @@ pub mod error {
match self {
VirtioError::Unknown =>write!(f, "Driver failed to initialize virtio device due to unknown reasosn!"),
VirtioError::FromPci(pci_error) => match pci_error {
PciError::General(id) => write!(f, "Driver failed to initialize device with id: 0x{:x}. Due to unknown reasosn!", id),
PciError::NoBar(id ) => write!(f, "Driver failed to initialize device with id: 0x{:x}. Reason: No BAR's found.", id),
PciError::NoCapPtr(id) => write!(f, "Driver failed to initialize device with id: 0x{:x}. Reason: No Capabilities pointer found.", id),
PciError::BadCapPtr(id) => write!(f, "Driver failed to initialize device with id: 0x{:x}. Reason: Malformed Capabilities pointer.", id),
PciError::NoBarForCap(id) => write!(f, "Driver failed to initialize device with id: 0x{:x}. Reason: Bar indicated by capability not found.", id),
PciError::NoVirtioCaps(id) => write!(f, "Driver failed to initialize device with id: 0x{:x}. Reason: No Virtio capabilities were found.", id),
PciError::General(id) => write!(f, "Driver failed to initialize device with id: {:#x}. Due to unknown reasosn!", id),
PciError::NoBar(id ) => write!(f, "Driver failed to initialize device with id: {:#x}. Reason: No BAR's found.", id),
PciError::NoCapPtr(id) => write!(f, "Driver failed to initialize device with id: {:#x}. Reason: No Capabilities pointer found.", id),
PciError::BadCapPtr(id) => write!(f, "Driver failed to initialize device with id: {:#x}. Reason: Malformed Capabilities pointer.", id),
PciError::NoBarForCap(id) => write!(f, "Driver failed to initialize device with id: {:#x}. Reason: Bar indicated by capability not found.", id),
PciError::NoVirtioCaps(id) => write!(f, "Driver failed to initialize device with id: {:#x}. Reason: No Virtio capabilities were found.", id),
},
VirtioError::DevNotSupported(id) => write!(f, "Device with id 0x{:x} not supported.", id),
VirtioError::DevNotSupported(id) => write!(f, "Device with id {:#x} not supported.", id),
VirtioError::NetDriver(net_error) => match net_error {
VirtioNetError::General => write!(f, "Virtio network driver failed due to unknown reasons!"),
VirtioNetError::NoDevCfg(id) => write!(f, "Network driver failed, for device {:x}, due to a missing or malformed device config!", id),
......
......@@ -1238,7 +1238,7 @@ pub fn init_device(adapter: &PciAdapter) -> Result<VirtioDriver, DriverError> {
| DevId::VIRTIO_TRANS_DEV_ID_ENTROPY
| DevId::VIRTIO_TRANS_DEV_ID_9P => {
warn!(
"Legacy/transitional Virtio device, with id: 0x{:x} is NOT supported, skipping!",
"Legacy/transitional Virtio device, with id: {:#x} is NOT supported, skipping!",
adapter.device_id
);
......@@ -1278,7 +1278,7 @@ pub fn init_device(adapter: &PciAdapter) -> Result<VirtioDriver, DriverError> {
}
_ => {
warn!(
"Virtio device with id: 0x{:x} is NOT supported, skipping!",
"Virtio device with id: {:#x} is NOT supported, skipping!",
adapter.device_id
);
......
......@@ -148,7 +148,7 @@ pub extern "C" fn __sys_malloc(size: usize, align: usize) -> *mut u8 {
let layout_res = Layout::from_size_align(size, align);
if layout_res.is_err() || size == 0 {
warn!(
"__sys_malloc called with size 0x{:x}, align 0x{:x} is an invalid layout!",
"__sys_malloc called with size {:#x}, align {:#x} is an invalid layout!",
size, align
);
return core::ptr::null::<*mut u8>() as *mut u8;
......@@ -157,7 +157,7 @@ pub extern "C" fn __sys_malloc(size: usize, align: usize) -> *mut u8 {
let ptr = unsafe { ALLOCATOR.alloc(layout) };
trace!(
"__sys_malloc: allocate memory at 0x{:x} (size 0x{:x}, align 0x{:x})",
"__sys_malloc: allocate memory at {:#x} (size {:#x}, align {:#x})",
ptr as usize,
size,
align
......@@ -196,7 +196,7 @@ pub extern "C" fn __sys_realloc(
let layout_res = Layout::from_size_align(size, align);
if layout_res.is_err() || size == 0 || new_size == 0 {
warn!(
"__sys_realloc called with ptr 0x{:x}, size 0x{:x}, align 0x{:x}, new_size 0x{:x} is an invalid layout!",
"__sys_realloc called with ptr {:#x}, size {:#x}, align {:#x}, new_size {:#x} is an invalid layout!",
ptr as usize, size, align, new_size
);
return core::ptr::null::<*mut u8>() as *mut u8;
......@@ -206,12 +206,12 @@ pub extern "C" fn __sys_realloc(
if new_ptr.is_null() {
debug!(
"__sys_realloc failed to resize ptr 0x{:x} with size 0x{:x}, align 0x{:x}, new_size 0x{:x} !",
"__sys_realloc failed to resize ptr {:#x} with size {:#x}, align {:#x}, new_size {:#x} !",
ptr as usize, size, align, new_size
);
} else {
trace!(
"__sys_realloc: resized memory at 0x{:x}, new address 0x{:x}",
"__sys_realloc: resized memory at {:#x}, new address {:#x}",
ptr as usize,
new_ptr as usize
);
......@@ -236,14 +236,14 @@ pub extern "C" fn __sys_free(ptr: *mut u8, size: usize, align: usize) {
let layout_res = Layout::from_size_align(size, align);
if layout_res.is_err() || size == 0 {
warn!(
"__sys_free called with size 0x{:x}, align 0x{:x} is an invalid layout!",
"__sys_free called with size {:#x}, align {:#x} is an invalid layout!",
size, align
);
debug_assert!(layout_res.is_err(), "__sys_free error: Invalid layout");
debug_assert_ne!(size, 0, "__sys_free error: size cannot be 0");
} else {
trace!(
"sys_free: deallocate memory at 0x{:x} (size 0x{:x})",
"sys_free: deallocate memory at {:#x} (size {:#x})",
ptr as usize,
size
);
......@@ -333,12 +333,12 @@ fn boot_processor_main() -> ! {
logging::init();
info!("Welcome to HermitCore-rs {}", env!("CARGO_PKG_VERSION"));
info!("Kernel starts at 0x{:x}", environment::get_base_address());
info!("BSS starts at 0x{:x}", unsafe {
info!("Kernel starts at {:#x}", environment::get_base_address());
info!("BSS starts at {:#x}", unsafe {
&__bss_start as *const usize as usize
});
info!(
"TLS starts at 0x{:x} (size {} Bytes)",
"TLS starts at {:#x} (size {} Bytes)",
environment::get_tls_start(),
environment::get_tls_memsz()
);
......
......@@ -67,7 +67,7 @@ fn map_heap<S: PageSize>(virt_addr: VirtAddr, size: usize) -> usize {
i += S::SIZE;
}
Err(_) => {
error!("Unable to allocate page frame of size 0x{:x}", S::SIZE);
error!("Unable to allocate page frame of size {:#x}", S::SIZE);
return i;
}
}
......@@ -90,7 +90,7 @@ pub fn init() {
info!("Total memory size: {} MB", total_memory_size() >> 20);
info!(
"Kernel region: [0x{:x} - 0x{:x}]",
"Kernel region: [{:#x} - {:#x}]",
kernel_start_address(),
kernel_end_address()
);
......@@ -134,7 +134,7 @@ pub fn init() {
.lock()
.init(start.as_usize(), kernel_heap_size);
info!("Kernel heap starts at 0x{:x}", start);
info!("Kernel heap starts at {:#x}", start);
}
info!("Kernel heap size: {} MB", kernel_heap_size >> 20);
......@@ -172,7 +172,7 @@ pub fn init() {
};
info!(
"Heap: size {} MB, start address 0x{:x}",
"Heap: size {} MB, start address {:#x}",
virt_size >> 20,
virt_addr
);
......@@ -219,7 +219,7 @@ pub fn init() {
HEAP_END_ADDRESS = map_addr;
info!(
"Heap is located at 0x{:x} -- 0x{:x} ({} Bytes unmapped)",
"Heap is located at {:#x} -- {:#x} ({} Bytes unmapped)",
HEAP_START_ADDRESS, HEAP_END_ADDRESS, map_size
);
}
......
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