clippy stuff
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
|
||||
//use x86_64::align_up;
|
||||
|
||||
pub const HEAP_START: usize = 0o_000_001_000_000_0000; // 0x40000000 - 0x40019000
|
||||
pub const HEAP_START: usize = 0x40000000; // 0x40000000 - 0x40019000
|
||||
pub const HEAP_SIZE: usize = 100 * 1024; // 100 KiB
|
||||
|
||||
// A simple allocator that allocates memory linearly and ignores freed memory.
|
||||
|
||||
@@ -20,7 +20,9 @@ static GLOBAL_ALLOCATOR: Talck<spin::Mutex<()>, ErrOnOom> = Talc::new(ErrOnOom).
|
||||
|
||||
pub struct DummyAlloc;
|
||||
unsafe impl GlobalAlloc for DummyAlloc {
|
||||
unsafe fn alloc(&self, _: Layout) -> *mut u8 { 0 as *mut u8 }
|
||||
unsafe fn alloc(&self, _: Layout) -> *mut u8 {
|
||||
core::ptr::null_mut::<u8>()
|
||||
}
|
||||
unsafe fn dealloc(&self, _ptr: *mut u8, _: Layout) {}
|
||||
}
|
||||
|
||||
@@ -125,9 +127,9 @@ pub struct MemInfo<'a>{
|
||||
}
|
||||
|
||||
impl MemInfo<'_> {
|
||||
pub fn load(mb_ptr: usize) -> Self {
|
||||
pub fn load(mb_ptr: *const BootInformationHeader) -> Self {
|
||||
let boot_info = unsafe {
|
||||
multiboot2::BootInformation::load(mb_ptr as *const BootInformationHeader).unwrap()
|
||||
multiboot2::BootInformation::load(mb_ptr).unwrap()
|
||||
};
|
||||
let mmap_tag = boot_info.memory_map_tag().unwrap();
|
||||
|
||||
@@ -151,7 +153,7 @@ impl MemInfo<'_> {
|
||||
//log::debug!("Multiboot: start: 0x{:x} sz: 0x{:x}", mi.mb_start, mi.mb_end - mi.mb_start);
|
||||
|
||||
Self {
|
||||
boot_info:unsafe { multiboot2::BootInformation::load(mb_ptr as *const BootInformationHeader).unwrap()},
|
||||
boot_info: unsafe { multiboot2::BootInformation::load(mb_ptr).unwrap()},
|
||||
mem_area_iter: MemoryAreaIter::new(mmap_tag),
|
||||
kernel_start,
|
||||
kernel_end,
|
||||
@@ -161,7 +163,7 @@ impl MemInfo<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn init(mb_ptr: usize) -> paging::ActivePageTable {
|
||||
pub fn init(mb_ptr: *const BootInformationHeader) -> paging::ActivePageTable {
|
||||
once::assert_has_not_been_called!("mem::init must be called only once");
|
||||
let mem_info = MemInfo::load(mb_ptr);
|
||||
let mut frame_alloc = area_frame_alloc::AreaFrameAllocator::new(&mem_info);
|
||||
|
||||
@@ -28,13 +28,13 @@ impl EntryFlags {
|
||||
|
||||
if section.flags().contains(ElfSectionFlags::ALLOCATED) {
|
||||
// section is loaded to memory
|
||||
flags = flags | EntryFlags::PRESENT;
|
||||
flags |= EntryFlags::PRESENT;
|
||||
}
|
||||
if section.flags().contains(ElfSectionFlags::WRITABLE) {
|
||||
flags = flags | EntryFlags::WRITABLE;
|
||||
flags |= EntryFlags::WRITABLE;
|
||||
}
|
||||
if !section.flags().contains(ElfSectionFlags::EXECUTABLE) {
|
||||
flags = flags | EntryFlags::NO_EXECUTE;
|
||||
flags |= EntryFlags::NO_EXECUTE;
|
||||
}
|
||||
|
||||
flags
|
||||
|
||||
@@ -7,7 +7,7 @@ use super::{
|
||||
Frame, FrameAllocator,
|
||||
PAGE_SIZE, PhysicalAddress,
|
||||
VirtualAddress, Page,
|
||||
ENTRY_COUNT, InactivePageTable
|
||||
ENTRY_COUNT,
|
||||
};
|
||||
use core::ptr::Unique;
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#![allow(unexpected_cfgs)]
|
||||
use core::ops::{Deref, DerefMut};
|
||||
use self::{entry::*, mapper::Mapper, temporary::TemporaryPage};
|
||||
use super::{Frame, FrameAllocator, MemInfo, PAGE_SIZE};
|
||||
@@ -119,8 +120,8 @@ impl InactivePageTable {
|
||||
|
||||
impl Page {
|
||||
pub fn containing_address(address: VirtualAddress) -> Page {
|
||||
assert!(address < 0x0000_8000_0000_0000 ||
|
||||
address >= 0xffff_8000_0000_0000,
|
||||
assert!(
|
||||
!(0x0000_8000_0000_0000..0xffff_8000_0000_0000).contains(&address),
|
||||
"invalid address: 0x{:x}", address);
|
||||
Page { number: address / PAGE_SIZE }
|
||||
}
|
||||
@@ -137,7 +138,7 @@ impl Page {
|
||||
(self.number >> 9) & 0o777
|
||||
}
|
||||
fn p1_index(&self) -> usize {
|
||||
(self.number >> 0) & 0o777
|
||||
self.number & 0o777
|
||||
}
|
||||
pub fn range_inclusive(start: Page, end: Page) -> PageIter {
|
||||
PageIter {
|
||||
@@ -225,8 +226,7 @@ pub fn remap_the_kernel<A>(allocator: &mut A, mem_info: &MemInfo) -> ActivePageT
|
||||
active_table
|
||||
}
|
||||
|
||||
|
||||
|
||||
#[cfg(disabled)]
|
||||
pub fn test_paging<A>(allocator: &mut A)
|
||||
where A: FrameAllocator
|
||||
{
|
||||
|
||||
@@ -44,12 +44,12 @@ impl<L> Table<L> where L: HierarchicalLevel {
|
||||
self.next_table_mut(index).unwrap()
|
||||
}
|
||||
|
||||
pub fn next_table<'a>(&'a self, index: usize) -> Option<&'a Table<L::NextLevel>> {
|
||||
pub fn next_table(&self, index: usize) -> Option<&Table<L::NextLevel>> {
|
||||
self.next_table_address(index)
|
||||
.map(|address| unsafe { &*(address as *const _) })
|
||||
}
|
||||
|
||||
pub fn next_table_mut<'a>(&'a mut self, index: usize) -> Option<&'a mut Table<L::NextLevel>> {
|
||||
pub fn next_table_mut(&mut self, index: usize) -> Option<&mut Table<L::NextLevel>> {
|
||||
self.next_table_address(index)
|
||||
.map(|address| unsafe { &mut *(address as *mut _) })
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ impl TemporaryPage {
|
||||
where A: FrameAllocator
|
||||
{
|
||||
TemporaryPage {
|
||||
page: page,
|
||||
page,
|
||||
allocator: TinyAllocator::new(allocator),
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user