Commit 70ec83a4 authored by Stefan Lankes's avatar Stefan Lankes Committed by Stefan Lankes
Browse files

increase the readability, fix typos

parent 5b232d8d
......@@ -71,8 +71,8 @@ const SMP_BOOT_CODE_OFFSET_BOOTINFO: usize = 0x10;
const X2APIC_ENABLE: u64 = 1 << 10;
static mut LOCAL_APIC_ADDRESS: VirtAddr = VirtAddr(0);
static mut IOAPIC_ADDRESS: VirtAddr = VirtAddr(0);
static mut LOCAL_APIC_ADDRESS: VirtAddr = VirtAddr::zero();
static mut IOAPIC_ADDRESS: VirtAddr = VirtAddr::zero();
/// Stores the Local APIC IDs of all CPUs. The index equals the Core ID.
/// Both numbers often match, but don't need to (e.g. when a core has been disabled).
......
......@@ -513,7 +513,7 @@ where
// Mark all entries as unused in the newly created table.
let subtable = self.subtable::<S>(page);
for entry in subtable.entries.iter_mut() {
entry.physical_address_and_flags = PhysAddr(0u64);
entry.physical_address_and_flags = PhysAddr::zero();
}
}
......@@ -653,7 +653,7 @@ pub fn virtual_to_physical(virtual_address: VirtAddr) -> PhysAddr {
let off = virtual_address.as_u64()
& !(((!0u64) << page_bits) & !PageTableEntryFlags::EXECUTE_DISABLE.bits());
let phys =
entry & (((!064) << page_bits) & !PageTableEntryFlags::EXECUTE_DISABLE.bits());
entry & (((!0u64) << page_bits) & !PageTableEntryFlags::EXECUTE_DISABLE.bits());
return PhysAddr(off | phys);
}
......@@ -701,7 +701,7 @@ pub fn identity_map(start_address: PhysAddr, end_address: PhysAddr) {
let first_page = Page::<BasePageSize>::including_address(VirtAddr(start_address.as_u64()));
let last_page = Page::<BasePageSize>::including_address(VirtAddr(end_address.as_u64()));
assert!(
last_page.address() < VirtAddr(mm::kernel_start_address().as_u64()),
last_page.address() < mm::kernel_start_address(),
"Address {:#X} to be identity-mapped is not below Kernel start address",
last_page.address()
);
......
......@@ -24,17 +24,17 @@ use core::mem;
/// Physical and virtual address of the first 2 MiB page that maps the kernel.
/// Can be easily accessed through kernel_start_address()
static mut KERNEL_START_ADDRESS: VirtAddr = VirtAddr(0u64);
static mut KERNEL_START_ADDRESS: VirtAddr = VirtAddr::zero();
/// Physical and virtual address of the first page after the kernel.
/// Can be easily accessed through kernel_end_address()
static mut KERNEL_END_ADDRESS: VirtAddr = VirtAddr(0u64);
static mut KERNEL_END_ADDRESS: VirtAddr = VirtAddr::zero();
/// Start address of the user heap
static mut HEAP_START_ADDRESS: VirtAddr = VirtAddr(0u64);
static mut HEAP_START_ADDRESS: VirtAddr = VirtAddr::zero();
/// End address of the user heap
static mut HEAP_END_ADDRESS: VirtAddr = VirtAddr(0u64);
static mut HEAP_END_ADDRESS: VirtAddr = VirtAddr::zero();
pub fn kernel_start_address() -> VirtAddr {
unsafe { KERNEL_START_ADDRESS }
......@@ -80,7 +80,7 @@ fn map_heap<S: PageSize>(virt_addr: VirtAddr, size: usize) -> usize {
pub fn init() {
// Calculate the start and end addresses of the 2 MiB page(s) that map the kernel.
unsafe {
KERNEL_START_ADDRESS = environment::get_base_address().align_up_to_large_page();
KERNEL_START_ADDRESS = environment::get_base_address().align_down_to_large_page();
KERNEL_END_ADDRESS = (environment::get_base_address() + environment::get_image_size())
.align_up_to_large_page();
}
......
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