mirror of
https://github.com/panpaul/tiny_os
synced 2024-09-20 09:45:19 +08:00
feat: move vspace into lib
This commit is contained in:
parent
774cabc513
commit
6267f8449d
@ -1,9 +0,0 @@
|
|||||||
mod entry;
|
|
||||||
mod table;
|
|
||||||
|
|
||||||
pub use crate::arch::vspace::{Entry, Table};
|
|
||||||
pub use entry::*;
|
|
||||||
pub use table::*;
|
|
||||||
|
|
||||||
assert_impl_all!(Entry: EntryOps);
|
|
||||||
assert_impl_all!(Table: TableOps);
|
|
79
lib/vspace/Cargo.lock
generated
Normal file
79
lib/vspace/Cargo.lock
generated
Normal file
@ -0,0 +1,79 @@
|
|||||||
|
# This file is automatically @generated by Cargo.
|
||||||
|
# It is not intended for manual editing.
|
||||||
|
version = 3
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "autocfg"
|
||||||
|
version = "1.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "f1fdabc7756949593fe60f30ec81974b613357de856987752631dea1e3394c80"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bitflags"
|
||||||
|
version = "2.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cf4b9d6a944f767f8e5e0db018570623c85f3d925ac718db4e06d0187adb21c1"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-derive"
|
||||||
|
version = "0.4.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ed3955f1a9c7c0c15e092f9c887db08b1fc683305fdf6eb6684f22555355e202"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num-traits"
|
||||||
|
version = "0.2.18"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a"
|
||||||
|
dependencies = [
|
||||||
|
"autocfg",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "proc-macro2"
|
||||||
|
version = "1.0.79"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e835ff2298f5721608eb1a980ecaee1aef2c132bf95ecc026a11b7bf3c01c02e"
|
||||||
|
dependencies = [
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "quote"
|
||||||
|
version = "1.0.35"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "291ec9ab5efd934aaf503a6466c5d5251535d108ee747472c3977cc5acc868ef"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "syn"
|
||||||
|
version = "2.0.58"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "44cfb93f38070beee36b3fef7d4f5a16f27751d94b187b666a5cc5e9b0d30687"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"unicode-ident",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "unicode-ident"
|
||||||
|
version = "1.0.12"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "vspace"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"num-derive",
|
||||||
|
"num-traits",
|
||||||
|
]
|
13
lib/vspace/Cargo.toml
Normal file
13
lib/vspace/Cargo.toml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
[package]
|
||||||
|
name = "vspace"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2021"
|
||||||
|
|
||||||
|
[features]
|
||||||
|
default = []
|
||||||
|
legacy = []
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
bitflags = "2.4"
|
||||||
|
num-derive = "0.4"
|
||||||
|
num-traits = { version = "0.2", default-features = false }
|
@ -1,6 +1,6 @@
|
|||||||
use core::fmt::*;
|
use core::fmt::*;
|
||||||
use core::hash::*;
|
use core::hash::*;
|
||||||
use core::iter::Step;
|
use core::iter::*;
|
||||||
use core::num::*;
|
use core::num::*;
|
||||||
use core::ops::*;
|
use core::ops::*;
|
||||||
|
|
9
lib/vspace/src/lib.rs
Normal file
9
lib/vspace/src/lib.rs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
#![cfg_attr(not(test), no_std)]
|
||||||
|
#![feature(const_mut_refs)]
|
||||||
|
#![feature(step_trait)]
|
||||||
|
|
||||||
|
#[macro_use]
|
||||||
|
extern crate num_derive;
|
||||||
|
|
||||||
|
pub mod addr;
|
||||||
|
pub mod paging;
|
@ -1,4 +1,4 @@
|
|||||||
use crate::vspace::addr::PhysAddr;
|
use crate::addr::PhysAddr;
|
||||||
use bitflags::bitflags;
|
use bitflags::bitflags;
|
||||||
use core::fmt::Debug;
|
use core::fmt::Debug;
|
||||||
|
|
5
lib/vspace/src/paging/mod.rs
Normal file
5
lib/vspace/src/paging/mod.rs
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
mod entry;
|
||||||
|
mod table;
|
||||||
|
|
||||||
|
pub use entry::*;
|
||||||
|
pub use table::*;
|
@ -1,5 +1,5 @@
|
|||||||
use super::{EntryOps, MapAttr};
|
use super::{EntryOps, MapAttr};
|
||||||
use crate::vspace::addr::{PhysAddr, VirtAddr};
|
use crate::addr::{PhysAddr, VirtAddr};
|
||||||
use core::fmt::Debug;
|
use core::fmt::Debug;
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd, Eq, FromPrimitive, ToPrimitive)]
|
#[derive(Debug, Clone, Copy, PartialEq, PartialOrd, Eq, FromPrimitive, ToPrimitive)]
|
||||||
@ -51,6 +51,8 @@ pub trait TableOps: Debug {
|
|||||||
type Entry: EntryOps;
|
type Entry: EntryOps;
|
||||||
const MAX_PAGE_SIZE: TableLevel;
|
const MAX_PAGE_SIZE: TableLevel;
|
||||||
|
|
||||||
|
/// # Safety
|
||||||
|
/// `location` must be a page-aligned virtual address and will not be dropped.
|
||||||
unsafe fn new(location: VirtAddr) -> &'static mut Self;
|
unsafe fn new(location: VirtAddr) -> &'static mut Self;
|
||||||
|
|
||||||
fn map(&mut self, from: VirtAddr, to: PhysAddr, attr: MapAttr, level: TableLevel)
|
fn map(&mut self, from: VirtAddr, to: PhysAddr, attr: MapAttr, level: TableLevel)
|
Loading…
Reference in New Issue
Block a user