parent
5b91db9d76
commit
77703442e7
@ -1,9 +0,0 @@
|
|||||||
use x86_64;
|
|
||||||
|
|
||||||
pub fn enable() {
|
|
||||||
unsafe{ x86_64::instructions::interrupts::enable(); }
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn disable() {
|
|
||||||
unsafe{ x86_64::instructions::interrupts::disable(); }
|
|
||||||
}
|
|
@ -0,0 +1,11 @@
|
|||||||
|
use x86_64;
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
pub unsafe fn enable() {
|
||||||
|
x86_64::instructions::interrupts::enable();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline(always)]
|
||||||
|
pub unsafe fn disable() {
|
||||||
|
x86_64::instructions::interrupts::disable();
|
||||||
|
}
|
@ -1,8 +1,8 @@
|
|||||||
use core::marker::PhantomData;
|
use core::marker::PhantomData;
|
||||||
use core::ops::{Index, IndexMut};
|
use core::ops::{Index, IndexMut};
|
||||||
use memory::FrameAllocator;
|
use memory::FrameAllocator;
|
||||||
use memory::paging::entry::*;
|
use super::entry::*;
|
||||||
use memory::paging::ENTRY_COUNT;
|
use super::ENTRY_COUNT;
|
||||||
|
|
||||||
pub const P4: *mut Table<Level4> = 0xffffffff_fffff000 as *mut _;
|
pub const P4: *mut Table<Level4> = 0xffffffff_fffff000 as *mut _;
|
||||||
|
|
@ -0,0 +1,53 @@
|
|||||||
|
use super::address::PhysicalAddress;
|
||||||
|
|
||||||
|
pub const PAGE_SIZE: usize = 4096;
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord)]
|
||||||
|
pub struct Frame {
|
||||||
|
pub(super) number: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Frame {
|
||||||
|
pub fn containing_address(address: usize) -> Frame {
|
||||||
|
Frame{ number: address / PAGE_SIZE }
|
||||||
|
}
|
||||||
|
//TODO: Set private
|
||||||
|
pub fn start_address(&self) -> PhysicalAddress {
|
||||||
|
PhysicalAddress((self.number * PAGE_SIZE) as u64)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn clone(&self) -> Frame {
|
||||||
|
Frame { number: self.number }
|
||||||
|
}
|
||||||
|
//TODO: Set private
|
||||||
|
pub fn range_inclusive(start: Frame, end: Frame) -> FrameIter {
|
||||||
|
FrameIter {
|
||||||
|
start: start,
|
||||||
|
end: end,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct FrameIter {
|
||||||
|
start: Frame,
|
||||||
|
end: Frame,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Iterator for FrameIter {
|
||||||
|
type Item = Frame;
|
||||||
|
|
||||||
|
fn next(&mut self) -> Option<Frame> {
|
||||||
|
if self.start <= self.end {
|
||||||
|
let frame = self.start.clone();
|
||||||
|
self.start.number += 1;
|
||||||
|
Some(frame)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub trait FrameAllocator {
|
||||||
|
fn allocate_frame(&mut self) -> Option<Frame>;
|
||||||
|
fn deallocate_frame(&mut self, frame: Frame);
|
||||||
|
}
|
Loading…
Reference in new issue