Code cleanup - make clippy happier
This commit is contained in:
parent
0a4fb34d32
commit
45f4ac5ef9
@ -8,15 +8,17 @@ extern crate alloc;
|
||||
|
||||
use alloc::vec::Vec;
|
||||
use core::arch::x86_64 as arch_x86;
|
||||
use polling_serial::serial_println;
|
||||
use vga_buffer::println;
|
||||
|
||||
pub mod prefetcher;
|
||||
|
||||
const CACHE_INFO_CPUID_LEAF: u32 = 0x4;
|
||||
|
||||
pub fn get_cache_info() -> Vec<CacheInfo> {
|
||||
let mut ret = Vec::new();
|
||||
let mut i = 0;
|
||||
|
||||
while let Some(cache_info) =
|
||||
CacheInfo::fromCpuidResult(&unsafe { arch_x86::__cpuid_count(0x04, i) })
|
||||
CacheInfo::from_cpuid_result(&unsafe { arch_x86::__cpuid_count(CACHE_INFO_CPUID_LEAF, i) })
|
||||
{
|
||||
ret.push(cache_info);
|
||||
i += 1;
|
||||
@ -51,7 +53,7 @@ pub struct CacheInfo {
|
||||
}
|
||||
|
||||
impl CacheInfo {
|
||||
pub fn fromCpuidResult(cr: &arch_x86::CpuidResult) -> Option<CacheInfo> {
|
||||
pub fn from_cpuid_result(cr: &arch_x86::CpuidResult) -> Option<CacheInfo> {
|
||||
let ctype = cr.eax & 0x1f;
|
||||
let cache_type = match ctype {
|
||||
0 => {
|
||||
@ -77,11 +79,6 @@ impl CacheInfo {
|
||||
let inclusive = (cr.edx & 0x2) != 0;
|
||||
let complex_cache_indexing = (cr.edx & 0x4) != 0;
|
||||
|
||||
println!(
|
||||
"CR(eax{:x},ebx{:x},ecx{:x},edx{:x})",
|
||||
cr.eax, cr.ebx, cr.ecx, cr.edx
|
||||
);
|
||||
|
||||
Some(CacheInfo {
|
||||
cache_type,
|
||||
level,
|
||||
|
1
cache_info/src/prefetcher.rs
Normal file
1
cache_info/src/prefetcher.rs
Normal file
@ -0,0 +1 @@
|
||||
|
@ -1,8 +1,6 @@
|
||||
use alloc::alloc::{GlobalAlloc, Layout};
|
||||
use core::ptr::null_mut;
|
||||
use polling_serial::serial_println;
|
||||
use x86_64::instructions::bochs_breakpoint;
|
||||
use x86_64::structures::paging::mapper::MapToError::PageAlreadyMapped;
|
||||
use x86_64::{
|
||||
structures::paging::{
|
||||
mapper::MapToError, FrameAllocator, Mapper, Page, PageTableFlags, Size4KiB,
|
||||
@ -37,8 +35,7 @@ pub fn init_heap(
|
||||
Page::range_inclusive(heap_start_page, heap_end_page)
|
||||
};
|
||||
|
||||
let mut i = 0;
|
||||
for page in page_range {
|
||||
for (i, page) in page_range.enumerate() {
|
||||
let frame = frame_allocator
|
||||
.allocate_frame()
|
||||
.ok_or(MapToError::FrameAllocationFailed)?;
|
||||
@ -47,7 +44,6 @@ pub fn init_heap(
|
||||
if i == 0 {
|
||||
serial_println!("Mapped {:?} at {:?}", page, frame);
|
||||
}
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
unsafe {
|
||||
|
10
src/main.rs
10
src/main.rs
@ -8,7 +8,6 @@
|
||||
#![reexport_test_harness_main = "test_main"]
|
||||
extern crate alloc;
|
||||
|
||||
use alloc::boxed::Box;
|
||||
use bootloader::{entry_point, BootInfo};
|
||||
use cache_info;
|
||||
use core::panic::PanicInfo;
|
||||
@ -22,7 +21,6 @@ use x86_64;
|
||||
#[cfg(not(test))]
|
||||
use dendrobates_tinctoreus_azureus::hlt_loop;
|
||||
|
||||
use dendrobates_tinctoreus_azureus::memory::create_example_mapping;
|
||||
#[cfg(not(test))]
|
||||
use vga_buffer::{set_colors, Color, ForegroundColor};
|
||||
|
||||
@ -53,8 +51,8 @@ fn kernel_main(boot_info: &'static BootInfo) -> ! {
|
||||
x86_64::instructions::interrupts::int3();
|
||||
|
||||
use dendrobates_tinctoreus_azureus::memory;
|
||||
use x86_64::structures::paging::{MapperAllSizes, PageTable};
|
||||
use x86_64::{structures::paging::Page, VirtAddr};
|
||||
use x86_64::structures::paging::MapperAllSizes;
|
||||
use x86_64::VirtAddr;
|
||||
|
||||
let phys_mem_offset = VirtAddr::new(boot_info.physical_memory_offset);
|
||||
// new: initialize a mapper
|
||||
@ -67,7 +65,7 @@ fn kernel_main(boot_info: &'static BootInfo) -> ! {
|
||||
// the identity-mapped vga buffer page
|
||||
0xb8000,
|
||||
// some code page
|
||||
0x201008,
|
||||
0x20_1008,
|
||||
// some stack page
|
||||
0x0100_0020_1a10,
|
||||
// virtual address mapped to physical address 0
|
||||
@ -83,8 +81,6 @@ fn kernel_main(boot_info: &'static BootInfo) -> ! {
|
||||
|
||||
allocator::init_heap(&mut mapper, &mut frame_allocator).expect("heap initialization failed");
|
||||
|
||||
let x = Box::new(41);
|
||||
|
||||
let caches = cache_info::get_cache_info();
|
||||
serial_println!("Caches:");
|
||||
serial_println!("{:#?}", caches);
|
||||
|
Loading…
Reference in New Issue
Block a user