mirror of
https://github.com/phil-opp/blog_os.git
synced 2025-12-16 14:27:49 +00:00
Update bitflags to 0.9.1 (#347)
Signed-off-by: Tim Crawford <crawfxrd@gmail.com>
This commit is contained in:
committed by
Philipp Oppermann
parent
7b04934cab
commit
e54cfa4378
@@ -5,7 +5,7 @@ version = "0.1.0"
|
||||
|
||||
[dependencies]
|
||||
bit_field = "0.7.0"
|
||||
bitflags = "0.7.0"
|
||||
bitflags = "0.9.1"
|
||||
multiboot2 = "0.1.0"
|
||||
once = "0.3.2"
|
||||
rlibc = "1.0"
|
||||
|
||||
@@ -614,12 +614,12 @@ We get the following output:
|
||||
// in src/interrupts/mod.rs
|
||||
|
||||
bitflags! {
|
||||
flags PageFaultErrorCode: u64 {
|
||||
const PROTECTION_VIOLATION = 1 << 0,
|
||||
const CAUSED_BY_WRITE = 1 << 1,
|
||||
const USER_MODE = 1 << 2,
|
||||
const MALFORMED_TABLE = 1 << 3,
|
||||
const INSTRUCTION_FETCH = 1 << 4,
|
||||
struct PageFaultErrorCode: u64 {
|
||||
const PROTECTION_VIOLATION = 1 << 0;
|
||||
const CAUSED_BY_WRITE = 1 << 1;
|
||||
const USER_MODE = 1 << 2;
|
||||
const MALFORMED_TABLE = 1 << 3;
|
||||
const INSTRUCTION_FETCH = 1 << 4;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -633,7 +633,7 @@ Let's try `make run` again:
|
||||
Compiling spin v0.4.5
|
||||
Compiling once v0.3.2
|
||||
Compiling x86 v0.8.0
|
||||
Compiling bitflags v0.7.0
|
||||
Compiling bitflags v0.9.1
|
||||
Compiling raw-cpuid v2.0.1
|
||||
Compiling rlibc v0.1.5
|
||||
Compiling linked_list_allocator v0.2.3
|
||||
|
||||
@@ -97,7 +97,7 @@ To model the various flags, we will use the [bitflags] crate. To add it as a dep
|
||||
```toml
|
||||
[dependencies]
|
||||
...
|
||||
bitflags = "0.7.0"
|
||||
bitflags = "0.9.1"
|
||||
```
|
||||
|
||||
To import the macro, we need to use `#[macro_use]` above the `extern crate` definition:
|
||||
@@ -112,23 +112,23 @@ Now we can model the various flags:
|
||||
|
||||
```rust
|
||||
bitflags! {
|
||||
pub flags EntryFlags: u64 {
|
||||
const PRESENT = 1 << 0,
|
||||
const WRITABLE = 1 << 1,
|
||||
const USER_ACCESSIBLE = 1 << 2,
|
||||
const WRITE_THROUGH = 1 << 3,
|
||||
const NO_CACHE = 1 << 4,
|
||||
const ACCESSED = 1 << 5,
|
||||
const DIRTY = 1 << 6,
|
||||
const HUGE_PAGE = 1 << 7,
|
||||
const GLOBAL = 1 << 8,
|
||||
const NO_EXECUTE = 1 << 63,
|
||||
pub struct EntryFlags: u64 {
|
||||
const PRESENT = 1 << 0;
|
||||
const WRITABLE = 1 << 1;
|
||||
const USER_ACCESSIBLE = 1 << 2;
|
||||
const WRITE_THROUGH = 1 << 3;
|
||||
const NO_CACHE = 1 << 4;
|
||||
const ACCESSED = 1 << 5;
|
||||
const DIRTY = 1 << 6;
|
||||
const HUGE_PAGE = 1 << 7;
|
||||
const GLOBAL = 1 << 8;
|
||||
const NO_EXECUTE = 1 << 63;
|
||||
}
|
||||
}
|
||||
```
|
||||
To extract the flags from the entry we create an `Entry::flags` method that uses [from_bits_truncate]:
|
||||
|
||||
[from_bits_truncate]: https://doc.rust-lang.org/bitflags/bitflags/macro.bitflags!.html#methods
|
||||
[from_bits_truncate]: https://doc.rust-lang.org/bitflags/bitflags/index.html#methods-1
|
||||
|
||||
```rust
|
||||
pub fn flags(&self) -> EntryFlags {
|
||||
|
||||
@@ -558,12 +558,12 @@ The flag bits are common between all descriptor types, so we create a general `D
|
||||
// in src/interrupts/gdt.rs
|
||||
|
||||
bitflags! {
|
||||
flags DescriptorFlags: u64 {
|
||||
const CONFORMING = 1 << 42,
|
||||
const EXECUTABLE = 1 << 43,
|
||||
const USER_SEGMENT = 1 << 44,
|
||||
const PRESENT = 1 << 47,
|
||||
const LONG_MODE = 1 << 53,
|
||||
struct DescriptorFlags: u64 {
|
||||
const CONFORMING = 1 << 42;
|
||||
const EXECUTABLE = 1 << 43;
|
||||
const USER_SEGMENT = 1 << 44;
|
||||
const PRESENT = 1 << 47;
|
||||
const LONG_MODE = 1 << 53;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
@@ -85,11 +85,11 @@ impl Descriptor {
|
||||
}
|
||||
|
||||
bitflags! {
|
||||
flags DescriptorFlags: u64 {
|
||||
const CONFORMING = 1 << 42,
|
||||
const EXECUTABLE = 1 << 43,
|
||||
const USER_SEGMENT = 1 << 44,
|
||||
const PRESENT = 1 << 47,
|
||||
const LONG_MODE = 1 << 53,
|
||||
struct DescriptorFlags: u64 {
|
||||
const CONFORMING = 1 << 42;
|
||||
const EXECUTABLE = 1 << 43;
|
||||
const USER_SEGMENT = 1 << 44;
|
||||
const PRESENT = 1 << 47;
|
||||
const LONG_MODE = 1 << 53;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,17 +42,17 @@ impl Entry {
|
||||
}
|
||||
|
||||
bitflags! {
|
||||
pub flags EntryFlags: u64 {
|
||||
const PRESENT = 1 << 0,
|
||||
const WRITABLE = 1 << 1,
|
||||
const USER_ACCESSIBLE = 1 << 2,
|
||||
const WRITE_THROUGH = 1 << 3,
|
||||
const NO_CACHE = 1 << 4,
|
||||
const ACCESSED = 1 << 5,
|
||||
const DIRTY = 1 << 6,
|
||||
const HUGE_PAGE = 1 << 7,
|
||||
const GLOBAL = 1 << 8,
|
||||
const NO_EXECUTE = 1 << 63,
|
||||
pub struct EntryFlags: u64 {
|
||||
const PRESENT = 1 << 0;
|
||||
const WRITABLE = 1 << 1;
|
||||
const USER_ACCESSIBLE = 1 << 2;
|
||||
const WRITE_THROUGH = 1 << 3;
|
||||
const NO_CACHE = 1 << 4;
|
||||
const ACCESSED = 1 << 5;
|
||||
const DIRTY = 1 << 6;
|
||||
const HUGE_PAGE = 1 << 7;
|
||||
const GLOBAL = 1 << 8;
|
||||
const NO_EXECUTE = 1 << 63;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user