diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 1 | ||||
-rw-r--r-- | src/shared/descriptor.rs | 26 | ||||
-rw-r--r-- | src/shared/segmentation.rs | 13 |
3 files changed, 20 insertions, 20 deletions
@@ -8,7 +8,6 @@ #[macro_use] extern crate bitflags; -#[macro_use] extern crate raw_cpuid; #[cfg(feature = "performance-counter")] diff --git a/src/shared/descriptor.rs b/src/shared/descriptor.rs index 32abb79..7fdf098 100644 --- a/src/shared/descriptor.rs +++ b/src/shared/descriptor.rs @@ -107,7 +107,7 @@ bitflags!{ // Code => permissions const FLAGS_TYPE_SEG_C_READ = 0b1_0010, - const FLAGS_TYPE_SEG_D_CONFORMING = 0b1_0100, + const FLAGS_TYPE_SEG_C_CONFORMING = 0b1_0100, /// Data Read-Only const FLAGS_TYPE_SEG_D_RO = FLAGS_TYPE_DATA.bits, @@ -139,32 +139,32 @@ bitflags!{ | FLAGS_TYPE_SEG_ACCESSED.bits, /// Code Execute-Only - const FLAGS_TYPE_SEG_C_EO = FLAGS_TYPE_DATA.bits, + const FLAGS_TYPE_SEG_C_EO = FLAGS_TYPE_CODE.bits, /// Code Execute-Only, accessed - const FLAGS_TYPE_SEG_C_EOA = FLAGS_TYPE_DATA.bits + const FLAGS_TYPE_SEG_C_EOA = FLAGS_TYPE_CODE.bits | FLAGS_TYPE_SEG_ACCESSED.bits, /// Code Execute/Read - const FLAGS_TYPE_SEG_C_ER = FLAGS_TYPE_DATA.bits + const FLAGS_TYPE_SEG_C_ER = FLAGS_TYPE_CODE.bits | FLAGS_TYPE_SEG_C_READ.bits, /// Code Execute/Read, accessed - const FLAGS_TYPE_SEG_C_ERA = FLAGS_TYPE_DATA.bits + const FLAGS_TYPE_SEG_C_ERA = FLAGS_TYPE_CODE.bits | FLAGS_TYPE_SEG_C_READ.bits | FLAGS_TYPE_SEG_ACCESSED.bits, /// Code Execute-Only, conforming - const FLAGS_TYPE_SEG_C_EOC = FLAGS_TYPE_DATA.bits - | FLAGS_TYPE_SEG_D_CONFORMING.bits, + const FLAGS_TYPE_SEG_C_EOC = FLAGS_TYPE_CODE.bits + | FLAGS_TYPE_SEG_C_CONFORMING.bits, /// Code Execute-Only, conforming, accessed - const FLAGS_TYPE_SEG_C_EOCA = FLAGS_TYPE_DATA.bits - | FLAGS_TYPE_SEG_D_CONFORMING.bits + const FLAGS_TYPE_SEG_C_EOCA = FLAGS_TYPE_CODE.bits + | FLAGS_TYPE_SEG_C_CONFORMING.bits | FLAGS_TYPE_SEG_ACCESSED.bits, /// Code Execute/Read, conforming - const FLAGS_TYPE_SEG_C_ERC = FLAGS_TYPE_DATA.bits + const FLAGS_TYPE_SEG_C_ERC = FLAGS_TYPE_CODE.bits | FLAGS_TYPE_SEG_C_READ.bits - | FLAGS_TYPE_SEG_D_CONFORMING.bits, + | FLAGS_TYPE_SEG_C_CONFORMING.bits, /// Code Execute/Read, conforming, accessed - const FLAGS_TYPE_SEG_C_ERCA = FLAGS_TYPE_DATA.bits + const FLAGS_TYPE_SEG_C_ERCA = FLAGS_TYPE_CODE.bits | FLAGS_TYPE_SEG_C_READ.bits - | FLAGS_TYPE_SEG_D_CONFORMING.bits + | FLAGS_TYPE_SEG_C_CONFORMING.bits | FLAGS_TYPE_SEG_ACCESSED.bits, } } 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 } } } |