Skip to content

Commit d88de47

Browse files
committed
style: format hex literals as lowercase
1 parent af3fc95 commit d88de47

27 files changed

+73
-72
lines changed

rustfmt.toml

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
group_imports = "StdExternalCrate"
22
hard_tabs = true
3+
hex_literal_case = "Lower"
34
imports_granularity = "Module"

src/arch/aarch64/kernel/interrupts.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ pub(crate) extern "C" fn do_sync(state: &State) {
175175
let irqid = GicV3::get_and_acknowledge_interrupt().unwrap();
176176
let esr = ESR_EL1.get();
177177
let ec = esr >> 26;
178-
let iss = esr & 0x00FF_FFFF;
178+
let iss = esr & 0x00ff_ffff;
179179
let pc = ELR_EL1.get();
180180

181181
/* data abort from lower or current level */

src/arch/aarch64/kernel/pci.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -25,19 +25,19 @@ pub(crate) struct PciConfigRegion(VirtAddr);
2525
impl PciConfigRegion {
2626
pub const fn new(addr: VirtAddr) -> Self {
2727
assert!(
28-
addr.as_u64() & 0x0FFF_FFFF == 0,
28+
addr.as_u64() & 0x0fff_ffff == 0,
2929
"Unaligned PCI Config Space"
3030
);
3131
Self(addr)
3232
}
3333

3434
#[inline]
3535
fn addr_from_offset(&self, pci_addr: PciAddress, offset: u16) -> usize {
36-
assert!(offset & 0xF000 == 0, "Invalid offset");
36+
assert!(offset & 0xf000 == 0, "Invalid offset");
3737
(u64::from(pci_addr.bus()) << 20
3838
| u64::from(pci_addr.device()) << 15
3939
| u64::from(pci_addr.function()) << 12
40-
| (u64::from(offset) & 0xFFF)
40+
| (u64::from(offset) & 0xfff)
4141
| self.0.as_u64()) as usize
4242
}
4343
}

src/arch/aarch64/kernel/processor.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ impl CpuFrequency {
7272
}
7373

7474
unsafe fn detect_from_register(&mut self) -> Result<(), ()> {
75-
let hz = CNTFRQ_EL0.get() & 0xFFFF_FFFF;
75+
let hz = CNTFRQ_EL0.get() & 0xffff_ffff;
7676
self.set_detected_cpu_frequency(hz.try_into().unwrap(), CpuFrequencySources::Register)
7777
}
7878

src/arch/aarch64/kernel/scheduler.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ impl TaskFrame for Task {
354354
// Set a marker for debugging at the very top.
355355
let mut stack = self.stacks.get_kernel_stack() + self.stacks.get_kernel_stack_size()
356356
- TaskStacks::MARKER_SIZE;
357-
*stack.as_mut_ptr::<u64>() = 0xDEAD_BEEFu64;
357+
*stack.as_mut_ptr::<u64>() = 0xdead_beefu64;
358358

359359
// Put the State structure expected by the ASM switch() function on the stack.
360360
stack -= mem::size_of::<State>();
@@ -374,7 +374,7 @@ impl TaskFrame for Task {
374374
(*state).spsel = 1;
375375

376376
/* Zero the condition flags. */
377-
(*state).spsr_el1 = 0x3E5;
377+
(*state).spsr_el1 = 0x3e5;
378378

379379
// Set the task's stack pointer entry to the stack we have just crafted.
380380
self.last_stack_pointer = stack;
@@ -383,7 +383,7 @@ impl TaskFrame for Task {
383383
self.user_stack_pointer = self.stacks.get_user_stack()
384384
+ self.stacks.get_user_stack_size()
385385
- TaskStacks::MARKER_SIZE;
386-
*self.user_stack_pointer.as_mut_ptr::<u64>() = 0xDEAD_BEEFu64;
386+
*self.user_stack_pointer.as_mut_ptr::<u64>() = 0xdead_beefu64;
387387
(*state).sp_el0 = self.user_stack_pointer.as_u64();
388388
}
389389
}

src/arch/aarch64/mm/paging.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use crate::{mm, scheduler, KERNEL_STACK_SIZE};
1616
/// Setting the upper bits to zero tells the MMU to use TTBR0 for the base address for the first table.
1717
///
1818
/// See entry.S and ARM Cortex-A Series Programmer's Guide for ARMv8-A, Version 1.0, PDF page 172
19-
const L0TABLE_ADDRESS: VirtAddr = VirtAddr::new(0x0000_FFFF_FFFF_F000u64);
19+
const L0TABLE_ADDRESS: VirtAddr = VirtAddr::new(0x0000_ffff_ffff_f000u64);
2020

2121
/// Number of Offset bits of a virtual address for a 4 KiB page, which are shifted away to get its Page Frame Number (PFN).
2222
const PAGE_BITS: usize = 12;
@@ -25,7 +25,7 @@ const PAGE_BITS: usize = 12;
2525
const PAGE_MAP_BITS: usize = 9;
2626

2727
/// A mask where PAGE_MAP_BITS are set to calculate a table index.
28-
const PAGE_MAP_MASK: usize = 0x1FF;
28+
const PAGE_MAP_MASK: usize = 0x1ff;
2929

3030
bitflags! {
3131
/// Useful flags for an entry in either table (L0Table, L1Table, L2Table, L3Table).

src/arch/riscv64/kernel/scheduler.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -385,7 +385,7 @@ impl TaskFrame for Task {
385385
// Set a marker for debugging at the very top.
386386
let mut stack =
387387
self.stacks.get_kernel_stack() + self.stacks.get_kernel_stack_size() - 0x10u64;
388-
*stack.as_mut_ptr::<u64>() = 0xDEAD_BEEFu64;
388+
*stack.as_mut_ptr::<u64>() = 0xdead_beefu64;
389389

390390
// Put the State structure expected by the ASM switch() function on the stack.
391391
stack -= mem::size_of::<State>();

src/arch/riscv64/mm/paging.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ const PAGE_BITS: usize = 12;
1919
const PAGE_MAP_BITS: usize = 9;
2020

2121
/// A mask where PAGE_MAP_BITS are set to calculate a table index.
22-
const PAGE_MAP_MASK: usize = 0x1FF;
22+
const PAGE_MAP_MASK: usize = 0x1ff;
2323

2424
/// Number of page levels
2525
const PAGE_LEVELS: usize = 3;
@@ -104,7 +104,7 @@ impl PageTableEntry {
104104
pub fn address(&self) -> PhysAddr {
105105
PhysAddr::new(
106106
(
107-
self.physical_address_and_flags.as_u64() & !(0x3FFu64)
107+
self.physical_address_and_flags.as_u64() & !(0x3ffu64)
108108
//& !(0x3FFu64 << 54)
109109
) << 2,
110110
)

src/arch/x86_64/kernel/acpi.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ use crate::arch::x86_64::mm::{paging, virtualmem};
1313
use crate::env;
1414

1515
/// Memory at this physical address is supposed to contain a pointer to the Extended BIOS Data Area (EBDA).
16-
const EBDA_PTR_LOCATION: PhysAddr = PhysAddr::new(0x0000_040E);
16+
const EBDA_PTR_LOCATION: PhysAddr = PhysAddr::new(0x0000_040e);
1717
/// Minimum physical address where a valid EBDA must be located.
1818
const EBDA_MINIMUM_ADDRESS: PhysAddr = PhysAddr::new(0x400);
1919
/// The size of the EBDA window that is searched for an ACPI RSDP.
2020
const EBDA_WINDOW_SIZE: usize = 1024;
2121
/// The lower bound of the other address range, where the ACPI RSDP could be located.
22-
const RSDP_SEARCH_ADDRESS_LOW: PhysAddr = PhysAddr::new(0xE_0000);
22+
const RSDP_SEARCH_ADDRESS_LOW: PhysAddr = PhysAddr::new(0xe_0000);
2323
/// The upper bound of the other address range, where the ACPI RSDP could be located.
24-
const RSDP_SEARCH_ADDRESS_HIGH: PhysAddr = PhysAddr::new(0xF_FFFF);
24+
const RSDP_SEARCH_ADDRESS_HIGH: PhysAddr = PhysAddr::new(0xf_ffff);
2525
/// Length in bytes of the structure, over which the basic (ACPI 1.0) checksum is calculated.
2626
const RSDP_CHECKSUM_LENGTH: usize = 20;
2727
/// Length in byte sof the structure, over which the extended (ACPI 2.0+) checksum is calculated.
@@ -36,7 +36,7 @@ const AML_ZEROOP: u8 = 0x00;
3636
/// ACPI AML opcode indicating a single one byte as the data.
3737
const AML_ONEOP: u8 = 0x01;
3838
/// ACPI AML opcode indicating that a single byte with the data follows.
39-
const AML_BYTEPREFIX: u8 = 0x0A;
39+
const AML_BYTEPREFIX: u8 = 0x0a;
4040

4141
/// Bit to enable an ACPI Sleep State.
4242
const SLP_EN: u16 = 1 << 13;

src/arch/x86_64/kernel/apic.rs

+8-8
Original file line numberDiff line numberDiff line change
@@ -369,11 +369,11 @@ fn search_mp_floating(memory_range: AddrRange<PhysAddr>) -> Result<&'static Apic
369369
/// Helper function to detect APIC by the Multiprocessor Specification
370370
fn detect_from_mp() -> Result<PhysAddr, ()> {
371371
let mp_float = if let Ok(mpf) = search_mp_floating(
372-
AddrRange::new(PhysAddr::new(0x9F000u64), PhysAddr::new(0xA0000u64)).unwrap(),
372+
AddrRange::new(PhysAddr::new(0x9f000u64), PhysAddr::new(0xa0000u64)).unwrap(),
373373
) {
374374
Ok(mpf)
375375
} else if let Ok(mpf) = search_mp_floating(
376-
AddrRange::new(PhysAddr::new(0xF0000u64), PhysAddr::new(0x10_0000u64)).unwrap(),
376+
AddrRange::new(PhysAddr::new(0xf0000u64), PhysAddr::new(0x10_0000u64)).unwrap(),
377377
) {
378378
Ok(mpf)
379379
} else {
@@ -415,7 +415,7 @@ fn detect_from_mp() -> Result<PhysAddr, ()> {
415415

416416
if mp_config.entry_count == 0 {
417417
warn!("No MP table entries! Guess IO-APIC!");
418-
let default_address = PhysAddr::new(0xFEC0_0000);
418+
let default_address = PhysAddr::new(0xfec0_0000);
419419

420420
init_ioapic_address(default_address);
421421
} else {
@@ -455,7 +455,7 @@ fn detect_from_mp() -> Result<PhysAddr, ()> {
455455
fn default_apic() -> PhysAddr {
456456
warn!("Try to use default APIC address");
457457

458-
let default_address = PhysAddr::new(0xFEE0_0000);
458+
let default_address = PhysAddr::new(0xfee0_0000);
459459

460460
// currently, uhyve doesn't support an IO-APIC
461461
if !env::is_uhyve() {
@@ -866,7 +866,7 @@ pub fn wakeup_core(core_id_to_wakeup: CoreId) {
866866
/// Translate the x2APIC MSR into an xAPIC memory address.
867867
#[inline]
868868
fn translate_x2apic_msr_to_xapic_address(x2apic_msr: u32) -> VirtAddr {
869-
*LOCAL_APIC_ADDRESS.get().unwrap() + ((u64::from(x2apic_msr) & 0xFF) << 4)
869+
*LOCAL_APIC_ADDRESS.get().unwrap() + ((u64::from(x2apic_msr) & 0xff) << 4)
870870
}
871871

872872
fn local_apic_read(x2apic_msr: u32) -> u32 {
@@ -902,11 +902,11 @@ fn ioapic_read(reg: u32) -> u32 {
902902
}
903903

904904
fn ioapic_version() -> u32 {
905-
ioapic_read(IOAPIC_REG_VER) & 0xFF
905+
ioapic_read(IOAPIC_REG_VER) & 0xff
906906
}
907907

908908
fn ioapic_max_redirection_entry() -> u8 {
909-
((ioapic_read(IOAPIC_REG_VER) >> 16) & 0xFF) as u8
909+
((ioapic_read(IOAPIC_REG_VER) >> 16) & 0xff) as u8
910910
}
911911

912912
fn local_apic_write(x2apic_msr: u32, value: u64) {
@@ -934,7 +934,7 @@ fn local_apic_write(x2apic_msr: u32, value: u64) {
934934

935935
// Instead of a single 64-bit ICR register, xAPIC has two 32-bit registers (ICR1 and ICR2).
936936
// There is a gap between them and the destination field in ICR2 is also 8 bits instead of 32 bits.
937-
let destination = ((value >> 8) & 0xFF00_0000) as u32;
937+
let destination = ((value >> 8) & 0xff00_0000) as u32;
938938
let icr2 = unsafe {
939939
&mut *((*LOCAL_APIC_ADDRESS.get().unwrap() + APIC_ICR2).as_mut_ptr::<u32>())
940940
};

src/arch/x86_64/kernel/pci.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ use crate::drivers::pci::{PciDevice, PCI_DEVICES};
66
const PCI_MAX_BUS_NUMBER: u8 = 32;
77
const PCI_MAX_DEVICE_NUMBER: u8 = 32;
88

9-
const PCI_CONFIG_ADDRESS_PORT: u16 = 0xCF8;
9+
const PCI_CONFIG_ADDRESS_PORT: u16 = 0xcf8;
1010
const PCI_CONFIG_ADDRESS_ENABLE: u32 = 1 << 31;
1111

12-
const PCI_CONFIG_DATA_PORT: u16 = 0xCFC;
12+
const PCI_CONFIG_DATA_PORT: u16 = 0xcfc;
1313

1414
#[derive(Debug, Copy, Clone)]
1515
pub(crate) struct PciConfigRegion;

src/arch/x86_64/kernel/pic.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ use crate::scheduler;
77

88
const PIC1_COMMAND_PORT: u16 = 0x20;
99
const PIC1_DATA_PORT: u16 = 0x21;
10-
const PIC2_COMMAND_PORT: u16 = 0xA0;
11-
const PIC2_DATA_PORT: u16 = 0xA1;
10+
const PIC2_COMMAND_PORT: u16 = 0xa0;
11+
const PIC2_DATA_PORT: u16 = 0xa1;
1212

1313
pub const PIC1_INTERRUPT_OFFSET: u8 = 32;
1414
const PIC2_INTERRUPT_OFFSET: u8 = 40;
@@ -69,8 +69,8 @@ pub fn init() {
6969
outb(PIC2_DATA_PORT, 0x01);
7070

7171
// Mask all interrupts on both PICs.
72-
outb(PIC1_DATA_PORT, 0xFF);
73-
outb(PIC2_DATA_PORT, 0xFF);
72+
outb(PIC1_DATA_PORT, 0xff);
73+
outb(PIC2_DATA_PORT, 0xff);
7474
}
7575
}
7676

src/arch/x86_64/kernel/processor.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -178,15 +178,15 @@ impl FPUState {
178178
// Set FPU-related values to their default values after initialization.
179179
// Refer to Intel Vol. 3A, Table 9-1. IA-32 and Intel 64 Processor States Following Power-up, Reset, or INIT
180180
legacy_region: XSaveLegacyRegion {
181-
fpu_control_word: 0x37F,
181+
fpu_control_word: 0x37f,
182182
fpu_status_word: 0,
183-
fpu_tag_word: 0xFFFF,
183+
fpu_tag_word: 0xffff,
184184
fpu_opcode: 0,
185185
fpu_instruction_pointer: 0,
186186
fpu_instruction_pointer_high_or_cs: 0,
187187
fpu_data_pointer: 0,
188188
fpu_data_pointer_high_or_ds: 0,
189-
mxcsr: 0x1F80,
189+
mxcsr: 0x1f80,
190190
mxcsr_mask: 0,
191191
st_space: [0; 8 * 16],
192192
xmm_space: [0; 16 * 16],
@@ -891,7 +891,7 @@ pub fn configure() {
891891
} else {
892892
panic!("Syscall support is missing");
893893
}
894-
wrmsr(IA32_STAR, (0x1Bu64 << 48) | (0x08u64 << 32));
894+
wrmsr(IA32_STAR, (0x1bu64 << 48) | (0x08u64 << 32));
895895
wrmsr(
896896
IA32_LSTAR,
897897
crate::arch::x86_64::kernel::syscall::syscall_handler as u64,

src/arch/x86_64/kernel/scheduler.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -352,7 +352,7 @@ impl TaskFrame for Task {
352352
// Set a marker for debugging at the very top.
353353
let mut stack = self.stacks.get_kernel_stack() + self.stacks.get_kernel_stack_size()
354354
- TaskStacks::MARKER_SIZE;
355-
*stack.as_mut_ptr::<u64>() = 0xDEAD_BEEFu64;
355+
*stack.as_mut_ptr::<u64>() = 0xdead_beefu64;
356356

357357
// Put the State structure expected by the ASM switch() function on the stack.
358358
stack -= mem::size_of::<State>();

src/arch/x86_64/kernel/systemtime.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ const CMOS_HOUR_REGISTER: u8 = 0x04;
1919
const CMOS_DAY_REGISTER: u8 = 0x07;
2020
const CMOS_MONTH_REGISTER: u8 = 0x08;
2121
const CMOS_YEAR_REGISTER: u8 = 0x09;
22-
const CMOS_STATUS_REGISTER_A: u8 = 0x0A;
23-
const CMOS_STATUS_REGISTER_B: u8 = 0x0B;
22+
const CMOS_STATUS_REGISTER_A: u8 = 0x0a;
23+
const CMOS_STATUS_REGISTER_B: u8 = 0x0b;
2424

2525
const CMOS_UPDATE_IN_PROGRESS_FLAG: u8 = 1 << 7;
2626
const CMOS_24_HOUR_FORMAT_FLAG: u8 = 1 << 1;
@@ -52,7 +52,7 @@ impl Rtc {
5252

5353
/// Returns the binary value for a given value in BCD (Binary-Coded Decimal).
5454
const fn convert_bcd_value(value: u8) -> u8 {
55-
((value / 16) * 10) + (value & 0xF)
55+
((value / 16) * 10) + (value & 0xf)
5656
}
5757

5858
/// Returns the number of microseconds since the epoch from a given date.

src/arch/x86_64/kernel/vga.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,16 @@ use x86::io::*;
55
use crate::arch::x86_64::mm::paging;
66
use crate::arch::x86_64::mm::paging::{BasePageSize, PageTableEntryFlags, PageTableEntryFlagsExt};
77

8-
const CRT_CONTROLLER_ADDRESS_PORT: u16 = 0x3D4;
9-
const CRT_CONTROLLER_DATA_PORT: u16 = 0x3D5;
10-
const CURSOR_START_REGISTER: u8 = 0x0A;
8+
const CRT_CONTROLLER_ADDRESS_PORT: u16 = 0x3d4;
9+
const CRT_CONTROLLER_DATA_PORT: u16 = 0x3d5;
10+
const CURSOR_START_REGISTER: u8 = 0x0a;
1111
const CURSOR_DISABLE: u8 = 0x20;
1212

1313
const ATTRIBUTE_BLACK: u8 = 0x00;
1414
const ATTRIBUTE_LIGHTGREY: u8 = 0x07;
1515
const COLS: usize = 80;
1616
const ROWS: usize = 25;
17-
const VGA_BUFFER_ADDRESS: PhysAddr = PhysAddr::new(0xB8000);
17+
const VGA_BUFFER_ADDRESS: PhysAddr = PhysAddr::new(0xb8000);
1818

1919
static VGA_SCREEN: SpinMutex<VgaScreen> = SpinMutex::new(VgaScreen::new());
2020

src/arch/x86_64/mm/paging.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ pub use x86_64::structures::paging::{
9494

9595
/// Returns a recursive page table mapping, its last entry is mapped to the table itself
9696
unsafe fn recursive_page_table() -> RecursivePageTable<'static> {
97-
let level_4_table_addr = 0xFFFF_FFFF_FFFF_F000;
97+
let level_4_table_addr = 0xffff_ffff_ffff_f000;
9898
let level_4_table_ptr = ptr::with_exposed_provenance_mut(level_4_table_addr);
9999
unsafe {
100100
let level_4_table = &mut *(level_4_table_ptr);

src/arch/x86_64/mm/virtualmem.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ pub fn print_information() {
162162
#[cfg(not(feature = "common-os"))]
163163
#[inline]
164164
pub const fn kernel_heap_end() -> VirtAddr {
165-
VirtAddr::new(0x7FFF_FFFF_FFFFu64)
165+
VirtAddr::new(0x7fff_ffff_ffffu64)
166166
}
167167

168168
#[cfg(feature = "common-os")]

src/drivers/net/gem.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ impl NetworkDriver for GEMDriver {
321321
let word1_addr = self.rxbuffer_list + u64::from(index * 8 + 4);
322322
let word1_entry =
323323
unsafe { core::ptr::read_volatile(word1_addr.as_mut_ptr::<u32>()) };
324-
let length = word1_entry & 0x1FFF;
324+
let length = word1_entry & 0x1fff;
325325
debug!("Received frame in buffer {}, length: {}", index, length);
326326

327327
// Starting point to search for next frame
@@ -347,7 +347,7 @@ impl NetworkDriver for GEMDriver {
347347
if value {
348348
// disable interrupts from the NIC
349349
unsafe {
350-
(*self.gem).int_disable.set(0x7FF_FEFF);
350+
(*self.gem).int_disable.set(0x7ff_feff);
351351
}
352352
} else {
353353
// Enable all known interrupts by setting the interrupt mask.
@@ -427,7 +427,7 @@ impl GEMDriver {
427427
core::ptr::write_volatile(word1_addr.as_mut_ptr::<u32>(), 0);
428428
// Give back ownership to GEM
429429
let word0_entry = core::ptr::read_volatile(word0_addr.as_mut_ptr::<u32>());
430-
core::ptr::write_volatile(word0_addr.as_mut_ptr::<u32>(), word0_entry & 0xFFFF_FFFE);
430+
core::ptr::write_volatile(word0_addr.as_mut_ptr::<u32>(), word0_entry & 0xffff_fffe);
431431
}
432432
}
433433

@@ -485,10 +485,10 @@ pub fn init_device(
485485
// Clear the Statistics registers
486486
(*gem).network_control.modify(NetworkControl::STATCLR::SET);
487487
// Clear the status registers
488-
(*gem).receive_status.set(0x0F);
489-
(*gem).transmit_status.set(0x0F);
488+
(*gem).receive_status.set(0x0f);
489+
(*gem).transmit_status.set(0x0f);
490490
// Disable all interrupts
491-
(*gem).int_disable.set(0x7FF_FEFF);
491+
(*gem).int_disable.set(0x7ff_feff);
492492
// Clear the buffer queues
493493
(*gem).rx_qbar.set(0x0);
494494
(*gem).tx_qbar.set(0x0);
@@ -560,7 +560,7 @@ pub fn init_device(
560560
warn! {"No PHY address provided. Trying to find PHY ..."}
561561
for i in 0..32 {
562562
match phy_read(gem, i, PhyReg::Control) {
563-
0xFFFF => (), //Invalid
563+
0xffff => (), //Invalid
564564
0x0 => (), //Invalid
565565
_ => {
566566
phy_addr = i;

0 commit comments

Comments
 (0)