Fix a number of warnings
This commit is contained in:
@@ -10,8 +10,6 @@ use x86::dtables::{self, DescriptorTablePointer};
|
||||
use x86::segmentation::{self, Descriptor as SegmentDescriptor, SegmentSelector};
|
||||
use x86::task;
|
||||
|
||||
use crate::paging::PAGE_SIZE;
|
||||
|
||||
pub const GDT_NULL: usize = 0;
|
||||
pub const GDT_KERNEL_CODE: usize = 1;
|
||||
pub const GDT_KERNEL_DATA: usize = 2;
|
||||
|
||||
@@ -45,7 +45,7 @@ impl Idt {
|
||||
let byte_index = index / 64;
|
||||
let bit = index % 64;
|
||||
|
||||
unsafe { &self.reservations[usize::from(byte_index)] }.load(Ordering::Acquire) & (1 << bit) != 0
|
||||
{ &self.reservations[usize::from(byte_index)] }.load(Ordering::Acquire) & (1 << bit) != 0
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@@ -53,14 +53,14 @@ impl Idt {
|
||||
let byte_index = index / 64;
|
||||
let bit = index % 64;
|
||||
|
||||
unsafe { &self.reservations[usize::from(byte_index)] }.fetch_or(u64::from(reserved) << bit, Ordering::AcqRel);
|
||||
{ &self.reservations[usize::from(byte_index)] }.fetch_or(u64::from(reserved) << bit, Ordering::AcqRel);
|
||||
}
|
||||
#[inline]
|
||||
pub fn is_reserved_mut(&mut self, index: u8) -> bool {
|
||||
let byte_index = index / 64;
|
||||
let bit = index % 64;
|
||||
|
||||
*unsafe { &mut self.reservations[usize::from(byte_index)] }.get_mut() & (1 << bit) != 0
|
||||
*{ &mut self.reservations[usize::from(byte_index)] }.get_mut() & (1 << bit) != 0
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@@ -68,7 +68,7 @@ impl Idt {
|
||||
let byte_index = index / 64;
|
||||
let bit = index % 64;
|
||||
|
||||
*unsafe { &mut self.reservations[usize::from(byte_index)] }.get_mut() |= u64::from(reserved) << bit;
|
||||
*{ &mut self.reservations[usize::from(byte_index)] }.get_mut() |= u64::from(reserved) << bit;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ pub fn is_reserved(cpu_id: usize, index: u8) -> bool {
|
||||
let byte_index = index / 64;
|
||||
let bit = index % 64;
|
||||
|
||||
unsafe { &IDTS.read().as_ref().unwrap().get(&cpu_id).unwrap().reservations[usize::from(byte_index)] }.load(Ordering::Acquire) & (1 << bit) != 0
|
||||
{ &IDTS.read().as_ref().unwrap().get(&cpu_id).unwrap().reservations[usize::from(byte_index)] }.load(Ordering::Acquire) & (1 << bit) != 0
|
||||
}
|
||||
|
||||
#[inline]
|
||||
@@ -90,7 +90,7 @@ pub fn set_reserved(cpu_id: usize, index: u8, reserved: bool) {
|
||||
let byte_index = index / 64;
|
||||
let bit = index % 64;
|
||||
|
||||
unsafe { &IDTS.read().as_ref().unwrap().get(&cpu_id).unwrap().reservations[usize::from(byte_index)] }.fetch_or(u64::from(reserved) << bit, Ordering::AcqRel);
|
||||
{ &IDTS.read().as_ref().unwrap().get(&cpu_id).unwrap().reservations[usize::from(byte_index)] }.fetch_or(u64::from(reserved) << bit, Ordering::AcqRel);
|
||||
}
|
||||
|
||||
pub fn allocate_interrupt() -> Option<NonZeroU8> {
|
||||
|
||||
@@ -54,7 +54,7 @@ impl<L> Table<L> where L: TableLevel {
|
||||
}
|
||||
|
||||
pub fn zero(&mut self) {
|
||||
for entry in unsafe { &mut self.entries }.iter_mut() {
|
||||
for entry in self.entries.iter_mut() {
|
||||
entry.set_zero();
|
||||
}
|
||||
}
|
||||
@@ -62,12 +62,12 @@ impl<L> Table<L> where L: TableLevel {
|
||||
/// Set number of entries in first table entry
|
||||
fn set_entry_count(&mut self, count: u64) {
|
||||
debug_assert!(count <= ENTRY_COUNT as u64, "count can't be greater than ENTRY_COUNT");
|
||||
unsafe { &mut self.entries[0] }.set_counter_bits(count)
|
||||
self.entries[0].set_counter_bits(count)
|
||||
}
|
||||
|
||||
/// Get number of entries in first table entry
|
||||
fn entry_count(&self) -> u64 {
|
||||
unsafe { &self.entries[0] }.counter_bits()
|
||||
self.entries[0].counter_bits()
|
||||
}
|
||||
|
||||
pub fn increment_entry_count(&mut self) {
|
||||
@@ -124,12 +124,12 @@ impl<L> Index<usize> for Table<L> where L: TableLevel {
|
||||
type Output = Entry;
|
||||
|
||||
fn index(&self, index: usize) -> &Entry {
|
||||
unsafe { &self.entries[index] }
|
||||
&self.entries[index]
|
||||
}
|
||||
}
|
||||
|
||||
impl<L> IndexMut<usize> for Table<L> where L: TableLevel {
|
||||
fn index_mut(&mut self, index: usize) -> &mut Entry {
|
||||
unsafe { &mut self.entries[index] }
|
||||
&mut self.entries[index]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,10 +6,9 @@ use alloc::{
|
||||
vec::Vec,
|
||||
};
|
||||
use core::{
|
||||
alloc::{GlobalAlloc, Layout},
|
||||
alloc::GlobalAlloc,
|
||||
cmp::Ordering,
|
||||
mem,
|
||||
ptr::NonNull,
|
||||
};
|
||||
use spin::RwLock;
|
||||
|
||||
|
||||
@@ -68,21 +68,19 @@ where
|
||||
{
|
||||
pub fn init(&mut self) {
|
||||
//TODO: Cleanup
|
||||
unsafe {
|
||||
self.int_en.write(0x00.into());
|
||||
self.line_ctrl.write(0x80.into());
|
||||
self.data.write(0x01.into());
|
||||
self.int_en.write(0x00.into());
|
||||
self.line_ctrl.write(0x03.into());
|
||||
self.fifo_ctrl.write(0xC7.into());
|
||||
self.modem_ctrl.write(0x0B.into());
|
||||
self.int_en.write(0x01.into());
|
||||
}
|
||||
self.int_en.write(0x00.into());
|
||||
self.line_ctrl.write(0x80.into());
|
||||
self.data.write(0x01.into());
|
||||
self.int_en.write(0x00.into());
|
||||
self.line_ctrl.write(0x03.into());
|
||||
self.fifo_ctrl.write(0xC7.into());
|
||||
self.modem_ctrl.write(0x0B.into());
|
||||
self.int_en.write(0x01.into());
|
||||
}
|
||||
|
||||
fn line_sts(&self) -> LineStsFlags {
|
||||
LineStsFlags::from_bits_truncate(
|
||||
(unsafe { self.line_sts.read() } & 0xFF.into())
|
||||
(self.line_sts.read() & 0xFF.into())
|
||||
.try_into()
|
||||
.unwrap_or(0),
|
||||
)
|
||||
@@ -91,7 +89,7 @@ where
|
||||
pub fn receive(&mut self) -> Option<u8> {
|
||||
if self.line_sts().contains(LineStsFlags::INPUT_FULL) {
|
||||
Some(
|
||||
(unsafe { self.data.read() } & 0xFF.into())
|
||||
(self.data.read() & 0xFF.into())
|
||||
.try_into()
|
||||
.unwrap_or(0),
|
||||
)
|
||||
@@ -102,7 +100,7 @@ where
|
||||
|
||||
pub fn send(&mut self, data: u8) {
|
||||
while !self.line_sts().contains(LineStsFlags::OUTPUT_EMPTY) {}
|
||||
unsafe { self.data.write(data.into()) }
|
||||
self.data.write(data.into())
|
||||
}
|
||||
|
||||
pub fn write(&mut self, buf: &[u8]) {
|
||||
|
||||
@@ -68,7 +68,6 @@ extern crate alloc;
|
||||
|
||||
#[macro_use]
|
||||
extern crate bitflags;
|
||||
#[macro_use]
|
||||
extern crate bitfield;
|
||||
extern crate goblin;
|
||||
extern crate linked_list_allocator;
|
||||
|
||||
@@ -40,6 +40,7 @@ pub extern "C" fn rust_begin_unwind(info: &PanicInfo) -> ! {
|
||||
|
||||
#[lang = "oom"]
|
||||
#[no_mangle]
|
||||
#[allow(improper_ctypes_definitions)] // Layout is not repr(C)
|
||||
pub extern fn rust_oom(_layout: Layout) -> ! {
|
||||
panic!("kernel memory allocation failed");
|
||||
}
|
||||
|
||||
@@ -483,7 +483,7 @@ impl Scheme for UserScheme {
|
||||
let context_lock = contexts.current().ok_or(Error::new(ESRCH))?;
|
||||
let context = context_lock.read();
|
||||
let mut grants = context.grants.write();
|
||||
let mut funmap = &mut grants.funmap;
|
||||
let funmap = &mut grants.funmap;
|
||||
let entry = funmap.range(..=Region::byte(VirtualAddress::new(grant_address))).next_back();
|
||||
|
||||
let grant_address = VirtualAddress::new(grant_address);
|
||||
@@ -513,7 +513,7 @@ impl Scheme for UserScheme {
|
||||
let context_lock = contexts.current().ok_or(Error::new(ESRCH))?;
|
||||
let context = context_lock.read();
|
||||
let mut grants = context.grants.write();
|
||||
let mut funmap = &mut grants.funmap;
|
||||
let funmap = &mut grants.funmap;
|
||||
let entry = funmap.range(..=Region::byte(VirtualAddress::new(grant_address))).next_back();
|
||||
|
||||
let grant_address = VirtualAddress::new(grant_address);
|
||||
|
||||
@@ -16,7 +16,7 @@ use crate::paging::{ActivePageTable, TableKind, VirtualAddress};
|
||||
use crate::syscall::data::TimeSpec;
|
||||
use crate::syscall::error::{Error, Result, ESRCH, EAGAIN, EFAULT, EINVAL};
|
||||
use crate::syscall::flag::{FUTEX_WAIT, FUTEX_WAIT64, FUTEX_WAKE, FUTEX_REQUEUE};
|
||||
use crate::syscall::validate::{validate_array, validate_slice, validate_slice_mut};
|
||||
use crate::syscall::validate::validate_array;
|
||||
|
||||
type FutexList = VecDeque<FutexEntry>;
|
||||
|
||||
|
||||
@@ -87,7 +87,7 @@ pub fn clone(flags: CloneFlags, stack_base: usize) -> Result<ContextId> {
|
||||
arch = context.arch.clone();
|
||||
|
||||
if let Some(ref fx) = context.kfx {
|
||||
let mut new_fx = unsafe {
|
||||
let new_fx = unsafe {
|
||||
let new_fx_ptr = crate::ALLOCATOR.alloc(Layout::from_size_align_unchecked(1024, 16));
|
||||
if new_fx_ptr.is_null() {
|
||||
// FIXME: It's mildly ironic that the only place where clone can fail with
|
||||
@@ -339,7 +339,7 @@ pub fn clone(flags: CloneFlags, stack_base: usize) -> Result<ContextId> {
|
||||
}
|
||||
|
||||
let mut active_utable = unsafe { ActivePageTable::new(TableKind::User) };
|
||||
let mut active_ktable = unsafe { ActivePageTable::new(TableKind::Kernel) };
|
||||
let active_ktable = unsafe { ActivePageTable::new(TableKind::Kernel) };
|
||||
|
||||
let mut new_utable = unsafe {
|
||||
let frame = allocate_frames(1).ok_or(Error::new(ENOMEM))?;
|
||||
@@ -916,7 +916,7 @@ pub fn fexec_kernel(fd: FileHandle, args: Box<[Box<[u8]>]>, vars: Box<[Box<[u8]>
|
||||
(auxv, phdr_grant)
|
||||
} else {
|
||||
let phdr_grant = match context::contexts().current().ok_or(Error::new(ESRCH))?.read().grants.write() {
|
||||
mut grants => {
|
||||
grants => {
|
||||
let size = elf.program_headers_size() * elf.program_header_count();
|
||||
let aligned_size = (size + PAGE_SIZE - 1) / PAGE_SIZE * PAGE_SIZE;
|
||||
|
||||
@@ -934,7 +934,6 @@ pub fn fexec_kernel(fd: FileHandle, args: Box<[Box<[u8]>]>, vars: Box<[Box<[u8]>
|
||||
|
||||
grant
|
||||
}
|
||||
|
||||
};
|
||||
let mut auxv = Vec::with_capacity(3);
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ fn validate(address: usize, size: usize, writable: bool) -> Result<()> {
|
||||
pub unsafe fn validate_ref<T>(ptr: *const T, size: usize) -> Result<&'static T> {
|
||||
if size == mem::size_of::<T>() {
|
||||
validate(ptr as usize, mem::size_of::<T>(), false)?;
|
||||
Ok(unsafe { &*ptr })
|
||||
Ok(&*ptr)
|
||||
} else {
|
||||
Err(Error::new(EINVAL))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user