aboutsummaryrefslogtreecommitdiff
path: root/src/shared/segmentation.rs
diff options
context:
space:
mode:
authorGravatar Gerd Zellweger <mail@gerdzellweger.com> 2017-10-17 10:15:12 +0200
committerGravatar GitHub <noreply@github.com> 2017-10-17 10:15:12 +0200
commit9cba8c9b18c24c549999f687aed1d3e5cbf90f6e (patch)
treef6ea88f2be9b169520c1bb534013560b6726fc95 /src/shared/segmentation.rs
parent6b18a71119bdb3c16bd5c6f85208597711785df9 (diff)
parent31183183e4dd295b8f48c21873a8cdfa60ba3c7d (diff)
downloadrust-x86-9cba8c9b18c24c549999f687aed1d3e5cbf90f6e.tar.gz
rust-x86-9cba8c9b18c24c549999f687aed1d3e5cbf90f6e.tar.zst
rust-x86-9cba8c9b18c24c549999f687aed1d3e5cbf90f6e.zip
Merge pull request #29 from sergey-v-galtsev/segmentation-fixes
Several small fixes for shared/descriptor.rs and shared/segmentation.rs.
Diffstat (limited to 'src/shared/segmentation.rs')
-rw-r--r--src/shared/segmentation.rs13
1 files changed, 7 insertions, 6 deletions
diff --git a/src/shared/segmentation.rs b/src/shared/segmentation.rs
index e836d42..fbbaf34 100644
--- a/src/shared/segmentation.rs
+++ b/src/shared/segmentation.rs
@@ -174,8 +174,8 @@ pub enum Type {
impl Type {
pub fn pack(self) -> u8 {
match self {
- Type::Data(d) => d.bits | 0b0_000,
- Type::Code(c) => c.bits | 0b1_000,
+ Type::Data(d) => d.bits | 0b10_000,
+ Type::Code(c) => c.bits | 0b11_000,
}
}
}
@@ -229,10 +229,11 @@ impl SegmentDescriptor {
base2: ((base as usize & 0xFF0000) >> 16) as u8,
base3: ((base as usize & 0xFF000000) >> 24) as u8,
access: descriptor::Flags::from_type(ty1)
- | descriptor::Flags::from_priv(dpl),
+ | descriptor::Flags::from_priv(dpl)
+ | descriptor::FLAGS_PRESENT,
limit1: limit1,
limit2_flags: FLAGS_DB
- | if fine_grained { FLAGS_G } else { Flags::empty() }
+ | if fine_grained { Flags::empty() } else { FLAGS_G }
| Flags::from_limit2(limit2),
}
}
@@ -246,7 +247,7 @@ bitflags! {
const FLAGS_L = 1 << 5,
/// Default operation size (0 = 16-bit segment, 1 = 32-bit segment).
const FLAGS_DB = 1 << 6,
- /// Granularity (0 = limit in bytes, 1 = limt in 4 KiB Pages).
+ /// Granularity (0 = limit in bytes, 1 = limit in 4 KiB Pages).
const FLAGS_G = 1 << 7,
}
@@ -256,7 +257,7 @@ impl Flags {
pub const BLANK: Flags = Flags { bits: 0 };
pub fn from_limit2(limit2: u8) -> Flags {
- assert_eq!(limit2 & !0b111, 0);
+ assert_eq!(limit2 & !0b1111, 0);
Flags { bits: limit2 }
}
}