diff --git a/Cargo.toml b/Cargo.toml index 72b36acf..2ad01f9f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -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" diff --git a/blog/content/extra/naked-exceptions/02-better-exception-messages/index.md b/blog/content/extra/naked-exceptions/02-better-exception-messages/index.md index 8df26af4..404d4bce 100644 --- a/blog/content/extra/naked-exceptions/02-better-exception-messages/index.md +++ b/blog/content/extra/naked-exceptions/02-better-exception-messages/index.md @@ -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; } } ``` diff --git a/blog/content/extra/naked-exceptions/03-returning-from-exceptions/index.md b/blog/content/extra/naked-exceptions/03-returning-from-exceptions/index.md index 79d9eee7..e31509ee 100644 --- a/blog/content/extra/naked-exceptions/03-returning-from-exceptions/index.md +++ b/blog/content/extra/naked-exceptions/03-returning-from-exceptions/index.md @@ -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 diff --git a/blog/content/posts/06-page-tables/index.md b/blog/content/posts/06-page-tables/index.md index 7cba5095..8c2e8187 100644 --- a/blog/content/posts/06-page-tables/index.md +++ b/blog/content/posts/06-page-tables/index.md @@ -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 { diff --git a/blog/content/posts/10-double-faults/index.md b/blog/content/posts/10-double-faults/index.md index 148ae397..b375b418 100644 --- a/blog/content/posts/10-double-faults/index.md +++ b/blog/content/posts/10-double-faults/index.md @@ -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; } } ``` diff --git a/src/interrupts/gdt.rs b/src/interrupts/gdt.rs index 23400821..5ea28e31 100644 --- a/src/interrupts/gdt.rs +++ b/src/interrupts/gdt.rs @@ -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; } } diff --git a/src/memory/paging/entry.rs b/src/memory/paging/entry.rs index 9e3ba4e2..5afbcd75 100644 --- a/src/memory/paging/entry.rs +++ b/src/memory/paging/entry.rs @@ -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; } }