Merge branch 'stable' into 'master'
Remove all nighly feature gates See merge request redox-os/rmm!17
This commit is contained in:
@@ -25,7 +25,7 @@ impl<A: Arch> BumpAllocator<A> {
|
||||
}
|
||||
}
|
||||
pub fn areas(&self) -> &'static [MemoryArea] {
|
||||
todo!()
|
||||
self.orig_areas.0
|
||||
}
|
||||
/// Returns one semifree and the fully free areas. The offset is the number of bytes after
|
||||
/// which the first area is free.
|
||||
|
||||
+25
-17
@@ -1,5 +1,4 @@
|
||||
use core::{marker::PhantomData, mem, ptr};
|
||||
use std::collections::BTreeMap;
|
||||
use std::{collections::BTreeMap, marker::PhantomData, mem, ptr, sync::Mutex};
|
||||
|
||||
use crate::{
|
||||
arch::x86_64::X8664Arch, page::PageFlags, Arch, MemoryArea, PageEntry, PhysicalAddress,
|
||||
@@ -64,7 +63,7 @@ impl Arch for EmulateArch {
|
||||
);
|
||||
}
|
||||
|
||||
MACHINE = Some(machine);
|
||||
*MACHINE.lock().unwrap() = Some(machine);
|
||||
|
||||
// Set table to pml4
|
||||
EmulateArch::set_table(TableKind::Kernel, PhysicalAddress::new(pml4));
|
||||
@@ -75,43 +74,52 @@ impl Arch for EmulateArch {
|
||||
|
||||
#[inline(always)]
|
||||
unsafe fn read<T>(address: VirtualAddress) -> T {
|
||||
unsafe { MACHINE.as_ref().unwrap().read(address) }
|
||||
MACHINE.lock().unwrap().as_ref().unwrap().read(address)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
unsafe fn write<T>(address: VirtualAddress, value: T) {
|
||||
unsafe { MACHINE.as_mut().unwrap().write(address, value) }
|
||||
MACHINE
|
||||
.lock()
|
||||
.unwrap()
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.write(address, value)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
unsafe fn write_bytes(address: VirtualAddress, value: u8, count: usize) {
|
||||
unsafe { MACHINE.as_mut().unwrap().write_bytes(address, value, count) }
|
||||
MACHINE
|
||||
.lock()
|
||||
.unwrap()
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.write_bytes(address, value, count)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
unsafe fn invalidate(address: VirtualAddress) {
|
||||
unsafe {
|
||||
MACHINE.as_mut().unwrap().invalidate(address);
|
||||
}
|
||||
MACHINE
|
||||
.lock()
|
||||
.unwrap()
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.invalidate(address);
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
unsafe fn invalidate_all() {
|
||||
unsafe {
|
||||
MACHINE.as_mut().unwrap().invalidate_all();
|
||||
}
|
||||
MACHINE.lock().unwrap().as_mut().unwrap().invalidate_all();
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
unsafe fn table(_table_kind: TableKind) -> PhysicalAddress {
|
||||
unsafe { MACHINE.as_mut().unwrap().get_table() }
|
||||
MACHINE.lock().unwrap().as_mut().unwrap().get_table()
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
unsafe fn set_table(_table_kind: TableKind, address: PhysicalAddress) {
|
||||
unsafe {
|
||||
MACHINE.as_mut().unwrap().set_table(address);
|
||||
}
|
||||
MACHINE.lock().unwrap().as_mut().unwrap().set_table(address);
|
||||
}
|
||||
fn virt_is_valid(_address: VirtualAddress) -> bool {
|
||||
// TODO: Don't see why an emulated arch would have any problems with canonicalness...
|
||||
@@ -132,7 +140,7 @@ static MEMORY_AREAS: [MemoryArea; 2] = [
|
||||
},
|
||||
];
|
||||
|
||||
static mut MACHINE: Option<Machine<EmulateArch>> = None;
|
||||
static MACHINE: Mutex<Option<Machine<EmulateArch>>> = Mutex::new(None);
|
||||
|
||||
struct Machine<A> {
|
||||
memory: Box<[u8]>,
|
||||
|
||||
+3
-10
@@ -57,14 +57,7 @@ impl Arch for X8664Arch {
|
||||
// On x86_64, an address is valid if and only if it is canonical. It may still point to
|
||||
// unmapped memory, but will always be valid once translated via the page table has
|
||||
// suceeded.
|
||||
address.is_canonical()
|
||||
}
|
||||
}
|
||||
|
||||
impl VirtualAddress {
|
||||
#[doc(cfg(target_arch = "x86_64"))]
|
||||
pub fn is_canonical(self) -> bool {
|
||||
let masked = self.data() & 0xFFFF_8000_0000_0000;
|
||||
let masked = address.data() & 0xFFFF_8000_0000_0000;
|
||||
// TODO: 5-level paging
|
||||
masked == 0xFFFF_8000_0000_0000 || masked == 0
|
||||
}
|
||||
@@ -96,10 +89,10 @@ mod tests {
|
||||
#[test]
|
||||
fn is_canonical() {
|
||||
fn yes(address: usize) {
|
||||
assert!(VirtualAddress::new(address).is_canonical());
|
||||
assert!(X8664Arch::virt_is_valid(VirtualAddress::new(address)));
|
||||
}
|
||||
fn no(address: usize) {
|
||||
assert!(!VirtualAddress::new(address).is_canonical());
|
||||
assert!(!X8664Arch::virt_is_valid(VirtualAddress::new(address)));
|
||||
}
|
||||
|
||||
yes(0xFFFF_8000_1337_1337);
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
#![feature(doc_cfg)]
|
||||
#![feature(let_chains)]
|
||||
|
||||
pub use crate::{allocator::*, arch::*, page::*};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user