aboutsummaryrefslogtreecommitdiff
path: root/src/shared/paging.rs
diff options
context:
space:
mode:
authorGravatar Gerd Zellweger <mail@gerdzellweger.com> 2016-07-04 14:08:17 +0200
committerGravatar GitHub <noreply@github.com> 2016-07-04 14:08:17 +0200
commitc12e050a69dd1a9b04f07ab78a166c6371d35a6f (patch)
treefea35bcf5b507efdd4c1c0f5dab146360c70478a /src/shared/paging.rs
parent32257991aaa3700620f1d6c180cfec3e2d65a360 (diff)
parentbd2950de1a48d72cbb718cc9a367142e0eb97b72 (diff)
downloadrust-x86-c12e050a69dd1a9b04f07ab78a166c6371d35a6f.tar.gz
rust-x86-c12e050a69dd1a9b04f07ab78a166c6371d35a6f.tar.zst
rust-x86-c12e050a69dd1a9b04f07ab78a166c6371d35a6f.zip
Merge pull request #16 from QuiltOS/master
Fix #15: Combine with https://github.com/Tobba/libcpu
Diffstat (limited to 'src/shared/paging.rs')
-rw-r--r--src/shared/paging.rs48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/shared/paging.rs b/src/shared/paging.rs
new file mode 100644
index 0000000..41705a9
--- /dev/null
+++ b/src/shared/paging.rs
@@ -0,0 +1,48 @@
+//! Description of the data-structures for IA-32e paging mode.
+
+use core::fmt;
+
+/// Represent a virtual (linear) memory address
+#[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)]
+pub struct VAddr(usize);
+
+impl VAddr {
+ /// Convert to `usize`
+ pub const fn as_usize(&self) -> usize {
+ self.0
+ }
+ /// Convert from `usize`
+ pub const fn from_usize(v: usize) -> Self {
+ VAddr(v)
+ }
+}
+
+impl fmt::Binary for VAddr {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ self.0.fmt(f)
+ }
+}
+
+impl fmt::Display for VAddr {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ self.0.fmt(f)
+ }
+}
+
+impl fmt::LowerHex for VAddr {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ self.0.fmt(f)
+ }
+}
+
+impl fmt::Octal for VAddr {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ self.0.fmt(f)
+ }
+}
+
+impl fmt::UpperHex for VAddr {
+ fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
+ self.0.fmt(f)
+ }
+}