update `memory` crate to 2018 edition

master
WangRunji 6 years ago
parent c4935a1477
commit 12457f10cb

@ -2,6 +2,7 @@
name = "ucore-memory" name = "ucore-memory"
version = "0.1.0" version = "0.1.0"
authors = ["WangRunji <wangrunji0408@163.com>"] authors = ["WangRunji <wangrunji0408@163.com>"]
edition = "2018"
[dependencies] [dependencies]
log = "0.4" log = "0.4"

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

@ -206,7 +206,6 @@ impl FrameRcMap {
pub mod test { pub mod test {
use super::*; use super::*;
use alloc::boxed::Box;
#[test] #[test]
fn test() { fn test() {

@ -1,15 +1,11 @@
#![no_std] #![cfg_attr(not(test), no_std)]
#![feature(alloc)] #![feature(alloc)]
#![feature(nll)] #![feature(nll)]
#![feature(extern_crate_item_prelude)]
// import macros from log
use log::*;
extern crate alloc; extern crate alloc;
#[macro_use]
extern crate log;
// To use `println!` in test
#[cfg(test)]
#[macro_use]
extern crate std;
pub mod paging; pub mod paging;
pub mod cow; pub mod cow;
@ -17,4 +13,4 @@ pub mod swap;
pub mod memory_set; pub mod memory_set;
mod addr; mod addr;
pub use addr::*; pub use crate::addr::*;

@ -4,7 +4,7 @@
use alloc::vec::Vec; use alloc::vec::Vec;
use core::fmt::{Debug, Error, Formatter}; use core::fmt::{Debug, Error, Formatter};
use super::*; use super::*;
use paging::*; use crate::paging::*;
/// an inactive page table /// an inactive page table
/// Note: InactivePageTable is not a PageTable /// Note: InactivePageTable is not a PageTable

@ -2,7 +2,7 @@
use alloc::collections::VecDeque; use alloc::collections::VecDeque;
use super::*; use super::*;
use paging::Entry; use crate::paging::Entry;
#[derive(Default)] #[derive(Default)]
pub struct EnhancedClockSwapManager { pub struct EnhancedClockSwapManager {

@ -10,7 +10,6 @@ use super::*;
use super::paging::*; use super::paging::*;
use super::memory_set::InactivePageTable; use super::memory_set::InactivePageTable;
use super::addr::Frame; use super::addr::Frame;
use alloc::rc::Rc;
use core::ops::{Deref, DerefMut}; use core::ops::{Deref, DerefMut};
//pub use self::fifo::FifoSwapManager; //pub use self::fifo::FifoSwapManager;

Loading…
Cancel
Save