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

Resolve clippy warnings

parent 66e2e326
......@@ -45,7 +45,7 @@ const TCR_FLAGS: u64 = TCR_IRGN_WBWA | TCR_ORGN_WBWA | TCR_SHARED;
const VA_BITS: u64 = 48;
fn tcr_size(x: u64) -> u64 {
(((64) - (x)) << 16) | (((64) - (x)) << 0)
((64 - x) << 16) | (64 - x)
}
global_asm!(include_str!("entry.s"));
......@@ -158,43 +158,42 @@ unsafe fn pre_init() -> ! {
- Fill in the missing Documentation for some of the bits and verify if we care about them
or if loading ond not setting them would be the appropriate action.
*/
let sctrl_el1: u64 = 0
| (1 << 26) /* UCI Enables EL0 access in AArch64 for DC CVAU, DC CIVAC,
DC CVAC and IC IVAU instructions */
| (0 << 25) /* EE Explicit data accesses at EL1 and Stage 1 translation
table walks at EL1 & EL0 are little-endian*/
| (0 << 24) /* EOE Explicit data accesses at EL0 are little-endian*/
| (1 << 23)
| (1 << 22)
| (1 << 20)
| (0 << 19) /* WXN Regions with write permission are not forced to XN */
| (1 << 18) /* nTWE WFE instructions are executed as normal*/
| (0 << 17)
| (1 << 16) /* nTWI WFI instructions are executed as normal*/
| (1 << 15) /* UCT Enables EL0 access in AArch64 to the CTR_EL0 register*/
| (1 << 14) /* DZE Execution of the DC ZVA instruction is allowed at EL0*/
| (0 << 13)
| (1 << 12) /* I Instruction caches enabled at EL0 and EL1*/
| (1 << 11)
| (0 << 10)
| (0 << 9) /* UMA Disable access to the interrupt masks from EL0*/
| (1 << 8) /* SED The SETEND instruction is available*/
| (0 << 7) /* ITD The IT instruction functionality is available*/
| (0 << 6) /* THEE ThumbEE is disabled*/
| (0 << 5) /* CP15BEN CP15 barrier operations disabled*/
| (1 << 4) /* SA0 Stack Alignment check for EL0 enabled*/
| (1 << 3) /* SA Stack Alignment check enabled*/
| (1 << 2) /* C Data and unified enabled*/
| (0 << 1) /* A Alignment fault checking disabled*/
| (0 << 0) /* M MMU enable*/
;
let sctrl_el1: u64 = 0;
// | (1 << 26) /* UCI Enables EL0 access in AArch64 for DC CVAU, DC CIVAC,
// DC CVAC and IC IVAU instructions */
// | (0 << 25) /* EE Explicit data accesses at EL1 and Stage 1 translation
// table walks at EL1 & EL0 are little-endian*/
// | (0 << 24) /* EOE Explicit data accesses at EL0 are little-endian*/
// | (1 << 23)
// | (1 << 22)
// | (1 << 20)
// | (0 << 19) /* WXN Regions with write permission are not forced to XN */
// | (1 << 18) /* nTWE WFE instructions are executed as normal*/
// | (0 << 17)
// | (1 << 16) /* nTWI WFI instructions are executed as normal*/
// | (1 << 15) /* UCT Enables EL0 access in AArch64 to the CTR_EL0 register*/
// | (1 << 14) /* DZE Execution of the DC ZVA instruction is allowed at EL0*/
// | (0 << 13)
// | (1 << 12) /* I Instruction caches enabled at EL0 and EL1*/
// | (1 << 11)
// | (0 << 10)
// | (0 << 9) /* UMA Disable access to the interrupt masks from EL0*/
// | (1 << 8) /* SED The SETEND instruction is available*/
// | (0 << 7) /* ITD The IT instruction functionality is available*/
// | (0 << 6) /* THEE ThumbEE is disabled*/
// | (0 << 5) /* CP15BEN CP15 barrier operations disabled*/
// | (1 << 4) /* SA0 Stack Alignment check for EL0 enabled*/
// | (1 << 3) /* SA Stack Alignment check enabled*/
// | (1 << 2) /* C Data and unified enabled*/
// | (0 << 1) /* A Alignment fault checking disabled*/
// | (0 << 0) /* M MMU enable*/
// ;
asm!("msr sctlr_el1, {0}", in(reg) sctrl_el1, options(nostack));
// Enter loader
loader_main();
// we should never reach this point
loop {}
unreachable!()
}
pub unsafe fn wait_forever() -> ! {
......
......@@ -4,9 +4,7 @@ pub struct SerialPort {
impl SerialPort {
pub const fn new(port_address: u32) -> Self {
Self {
port_address: port_address,
}
Self { port_address }
}
pub fn write_byte(&self, byte: u8) {
......
......@@ -174,7 +174,7 @@ impl<S: PageSize> Page<S> {
/// Although we could make this check depend on the actual linear address width from the CPU,
/// any extension above 48-bit would require a new page table level, which we don't implement.
fn is_valid_address(virtual_address: usize) -> bool {
virtual_address < 0x8000_0000_0000 || virtual_address >= 0xFFFF_8000_0000_0000
!(0x8000_0000_0000..0xFFFF_8000_0000_0000).contains(&virtual_address)
}
/// Returns a Page including the given virtual address.
......@@ -193,14 +193,14 @@ impl<S: PageSize> Page<S> {
assert!(first.virtual_address <= last.virtual_address);
PageIter {
current: first,
last: last,
last,
}
}
/// Returns the index of this page in the table given by L.
fn table_index<L: PageTableLevel>(&self) -> usize {
assert!(L::LEVEL >= S::MAP_LEVEL);
self.virtual_address >> PAGE_BITS >> L::LEVEL * PAGE_MAP_BITS & PAGE_MAP_MASK
self.virtual_address >> PAGE_BITS >> (L::LEVEL * PAGE_MAP_BITS) & PAGE_MAP_MASK
}
}
......@@ -396,7 +396,7 @@ where
/// Returns the next subtable for the given page in the page table hierarchy.
///
/// Must only be called if a page of this size is mapped in a subtable!
fn subtable<S: PageSize>(&self, page: Page<S>) -> &mut PageTable<L::SubtableLevel> {
fn subtable<S: PageSize>(&mut self, page: Page<S>) -> &mut PageTable<L::SubtableLevel> {
assert!(L::LEVEL > S::MAP_LEVEL);
// Calculate the address of the subtable.
......
......@@ -32,9 +32,7 @@ pub struct SerialPort {
impl SerialPort {
pub const fn new(port_address: u16) -> Self {
Self {
port_address: port_address,
}
Self { port_address }
}
fn read_from_register(&self, register: u16) -> u8 {
......
......@@ -18,8 +18,10 @@
#![feature(const_raw_ptr_deref)]
#![feature(core_intrinsics)]
#![no_std]
#![allow(clippy::missing_safety_doc)]
// EXTERNAL CRATES
#[cfg(target_arch = "x86_64")]
#[macro_use]
extern crate bitflags;
extern crate goblin;
......@@ -55,7 +57,7 @@ extern "C" {
}
#[global_allocator]
static ALLOCATOR: &'static mm::allocator::Allocator = &mm::allocator::Allocator;
static ALLOCATOR: &mm::allocator::Allocator = &mm::allocator::Allocator;
// FUNCTIONS
pub unsafe fn sections_init() {
......@@ -69,7 +71,7 @@ pub unsafe fn sections_init() {
pub unsafe fn load_kernel(elf: &elf::Elf, elf_start: u64, mem_size: u64) -> (u64, u64) {
loaderlog!("start 0x{:x}, size 0x{:x}", elf_start, mem_size);
if elf.libraries.len() > 0 {
if !elf.libraries.is_empty() {
panic!(
"Error: file depends on following libraries: {:?}",
elf.libraries
......@@ -147,7 +149,7 @@ pub unsafe fn load_kernel(elf: &elf::Elf, elf_start: u64, mem_size: u64) -> (u64
}
pub fn check_kernel_elf_file(elf: &elf::Elf) -> u64 {
if elf.libraries.len() > 0 {
if !elf.libraries.is_empty() {
panic!(
"Error: file depends on following libraries: {:?}",
elf.libraries
......
......@@ -9,6 +9,7 @@
#![no_std] // don't link the Rust standard library
#![cfg_attr(not(test), no_main)] // disable all Rust-level entry points
#![cfg_attr(test, allow(dead_code, unused_macros, unused_imports))]
#![allow(clippy::missing_safety_doc)]
extern crate goblin;
extern crate rusty_loader;
......
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