From 8d8a1c819a81127729e2a8a5e58e82ceaef3bf05 Mon Sep 17 00:00:00 2001 From: Berkus Decker Date: Tue, 29 Dec 2020 16:18:20 +0200 Subject: [PATCH] [sq] add Page caps implementations --- .../arch/aarch64/caps/page_directory_cap.rs | 18 ++++++++++++++++++ .../aarch64/caps/page_global_directory_cap.rs | 18 ++++++++++++++++++ .../src/arch/aarch64/caps/page_table_cap.rs | 18 ++++++++++++++++++ .../aarch64/objects/page_global_directory.rs | 2 ++ 4 files changed, 56 insertions(+) diff --git a/nucleus/src/arch/aarch64/caps/page_directory_cap.rs b/nucleus/src/arch/aarch64/caps/page_directory_cap.rs index e3ad7bf..c34550a 100644 --- a/nucleus/src/arch/aarch64/caps/page_directory_cap.rs +++ b/nucleus/src/arch/aarch64/caps/page_directory_cap.rs @@ -35,3 +35,21 @@ capdef! { PageDirectory } //===================== // Cap implementation //===================== + +impl PageDirectoryCapability { + pub(crate) fn base_address() -> PhysAddr { + PhysAddr::new(self.0.read(PageDirectoryCap::BasePtr)) + } + + pub(crate) fn is_mapped() -> bool { + self.0.read(PageDirectoryCap::IsMapped) == 1 + } + + pub(crate) fn mapped_address() -> VirtAddr { + VirtAddr::new(self.0.read(PageDirectoryCap::MappedAddress)) + } + + pub(crate) fn mapped_asid() -> ASID { + self.0.read(PageDirectoryCap::MappedASID) + } +} diff --git a/nucleus/src/arch/aarch64/caps/page_global_directory_cap.rs b/nucleus/src/arch/aarch64/caps/page_global_directory_cap.rs index 74732fd..665cd03 100644 --- a/nucleus/src/arch/aarch64/caps/page_global_directory_cap.rs +++ b/nucleus/src/arch/aarch64/caps/page_global_directory_cap.rs @@ -34,3 +34,21 @@ capdef! { PageGlobalDirectory } //===================== // Cap implementation //===================== + +impl PageGlobalDirectoryCapability { + pub(crate) fn base_address() -> PhysAddr { + PhysAddr::new(self.0.read(PageGlobalDirectoryCap::BasePtr)) + } + + pub(crate) fn is_mapped() -> bool { + self.0.read(PageGlobalDirectoryCap::IsMapped) == 1 + } + + pub(crate) fn mapped_address() -> VirtAddr { + VirtAddr::new(self.0.read(PageGlobalDirectoryCap::MappedAddress)) + } + + pub(crate) fn mapped_asid() -> ASID { + self.0.read(PageGlobalDirectoryCap::MappedASID) + } +} diff --git a/nucleus/src/arch/aarch64/caps/page_table_cap.rs b/nucleus/src/arch/aarch64/caps/page_table_cap.rs index 56bcc80..1bece2b 100644 --- a/nucleus/src/arch/aarch64/caps/page_table_cap.rs +++ b/nucleus/src/arch/aarch64/caps/page_table_cap.rs @@ -35,3 +35,21 @@ capdef! { PageTable } //===================== // Cap implementation //===================== + +impl PageTableCapability { + pub(crate) fn base_address() -> PhysAddr { + PhysAddr::new(self.0.read(PageTableCap::BasePtr)) + } + + pub(crate) fn is_mapped() -> bool { + self.0.read(PageTableCap::IsMapped) == 1 + } + + pub(crate) fn mapped_address() -> VirtAddr { + VirtAddr::new(self.0.read(PageTableCap::MappedAddress)) + } + + pub(crate) fn mapped_asid() -> ASID { + self.0.read(PageTableCap::MappedASID) + } +} diff --git a/nucleus/src/arch/aarch64/objects/page_global_directory.rs b/nucleus/src/arch/aarch64/objects/page_global_directory.rs index f1775be..8a2b1ef 100644 --- a/nucleus/src/arch/aarch64/objects/page_global_directory.rs +++ b/nucleus/src/arch/aarch64/objects/page_global_directory.rs @@ -26,3 +26,5 @@ impl PageCacheManagement for PageGlobalDirectory { todo!() } } + +impl From for PageGlobalDirectory {}