Clippy, format, docs
This commit is contained in:
parent
d95ac44304
commit
27e643426a
@ -52,3 +52,21 @@ Lastly, I want to figure out a way to make the kernel's capability
|
||||
representation a little more... *robust*, I guess. More idiomatic Rust. Using
|
||||
raw pointers everywhere feels sloppy. Maybe this is a good application of
|
||||
`PhantomData<T>`?
|
||||
|
||||
## 2026-11-09: Capability management refinement
|
||||
|
||||
I decided to use `Pin<&mut Capability>` for the derivation tree pointers. This
|
||||
makes a lot of sense, considering the capabilities aren't supposed to move
|
||||
around in memory.
|
||||
|
||||
For capabilities representing memory ranges, we can use a "buddy" system:
|
||||
52 bits of a 64-bit pointer are used to refer to the base address of the range.
|
||||
6 of the remaining 12 bits can be used to represent the number of pages in the
|
||||
range. If we call this 6-bit value n, then the number of pages represented by
|
||||
the capability can be defined as 2^n. Access rights can be encoded in the final
|
||||
6 bits. We can represent any number of pages using binary partitioning.
|
||||
|
||||
For page type capabilities, we can do something similar, except we use all 12
|
||||
low bits for access rights. Keeping all capability types the same size allows
|
||||
for convenient storage of capabilities in an array, as enum variants with
|
||||
associated types. Boom!!!
|
||||
|
||||
@ -4,11 +4,11 @@
|
||||
use core::arch::asm;
|
||||
use core::ptr::{addr_of, addr_of_mut};
|
||||
|
||||
use intbits::Bits;
|
||||
use lazy_static::lazy_static;
|
||||
use x86_64::structures::gdt;
|
||||
use x86_64::structures::gdt::*;
|
||||
use x86_64::structures::tss::TaskStateSegment;
|
||||
use intbits::Bits;
|
||||
|
||||
use crate::log::*;
|
||||
use crate::memory::alloc::format;
|
||||
@ -23,12 +23,15 @@ trait ModifyFlags {
|
||||
impl ModifyFlags for Descriptor {
|
||||
fn set_flags(self, flags: DescriptorFlags) -> Descriptor {
|
||||
match self {
|
||||
Descriptor::UserSegment(a) => {
|
||||
Descriptor::UserSegment(intbits::Bits::with_bits(a, 52..=55, intbits::Bits::bits(flags.bits(), 0..=3)))
|
||||
}
|
||||
Descriptor::SystemSegment(a, b) => {
|
||||
Descriptor::SystemSegment(intbits::Bits::with_bits(a, 52..=55, intbits::Bits::bits(flags.bits(), 0..=3)), b)
|
||||
}
|
||||
Descriptor::UserSegment(a) => Descriptor::UserSegment(intbits::Bits::with_bits(
|
||||
a,
|
||||
52..=55,
|
||||
intbits::Bits::bits(flags.bits(), 0..=3),
|
||||
)),
|
||||
Descriptor::SystemSegment(a, b) => Descriptor::SystemSegment(
|
||||
intbits::Bits::with_bits(a, 52..=55, intbits::Bits::bits(flags.bits(), 0..=3)),
|
||||
b,
|
||||
),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -23,8 +23,8 @@ use log::*;
|
||||
use memory::alloc::format;
|
||||
use params::*;
|
||||
|
||||
use x86_64::VirtAddr;
|
||||
use crate::boot::modules::MODULE_RESPONSE;
|
||||
use x86_64::VirtAddr;
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
unsafe extern "C" fn main() -> ! {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user