|
|
|
@ -1,9 +1,8 @@
|
|
|
|
|
use core::ops::{Add, AddAssign};
|
|
|
|
|
use super::paging::*;
|
|
|
|
|
use super::memory_set::*;
|
|
|
|
|
|
|
|
|
|
pub type VirtAddr = usize;
|
|
|
|
|
pub type PhysAddr = usize;
|
|
|
|
|
|
|
|
|
|
pub const PAGE_SIZE: usize = 1 << 12;
|
|
|
|
|
|
|
|
|
|
#[derive(Debug, Copy, Clone, PartialEq, Eq, PartialOrd, Ord)]
|
|
|
|
@ -80,13 +79,16 @@ impl Iterator for PageRange {
|
|
|
|
|
/// frame for the swapmanager
|
|
|
|
|
#[derive(Debug, Copy, Clone, PartialOrd, Ord)]
|
|
|
|
|
#[repr(C)]
|
|
|
|
|
pub struct Frame {
|
|
|
|
|
page_table: usize, // the raw pointer for the frame's memory set's inactive page table
|
|
|
|
|
virtaddr: VirtAddr, // the virtual addr for the frame
|
|
|
|
|
token: usize, // the token for frame
|
|
|
|
|
pub struct Frame {
|
|
|
|
|
/// the raw pointer for the frame's memory set's inactive page table
|
|
|
|
|
page_table: usize,
|
|
|
|
|
/// the virtual addr for the frame
|
|
|
|
|
virtaddr: VirtAddr,
|
|
|
|
|
/// the token for frame
|
|
|
|
|
token: usize,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Frame{
|
|
|
|
|
impl Frame {
|
|
|
|
|
pub fn get_page_table(&self) -> usize {
|
|
|
|
|
self.page_table
|
|
|
|
|
}
|
|
|
|
@ -95,11 +97,11 @@ impl Frame{
|
|
|
|
|
self.virtaddr
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn get_token(&self) -> usize{
|
|
|
|
|
pub fn get_token(&self) -> usize {
|
|
|
|
|
self.token
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
pub fn new(pt: usize, addr: VirtAddr, pttoken: usize) -> Self{
|
|
|
|
|
pub fn new(pt: usize, addr: VirtAddr, pttoken: usize) -> Self {
|
|
|
|
|
Frame {
|
|
|
|
|
page_table: pt,
|
|
|
|
|
virtaddr: addr,
|
|
|
|
@ -108,12 +110,10 @@ impl Frame{
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl PartialEq for Frame{
|
|
|
|
|
impl PartialEq for Frame {
|
|
|
|
|
fn eq(&self, other: &Frame) -> bool {
|
|
|
|
|
self.token == other.token && self.virtaddr == other.virtaddr
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Eq for Frame{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
impl Eq for Frame {}
|