maint: remove memtables crate

This commit is contained in:
2025-07-17 17:53:53 +03:00
parent 0672d55e8e
commit a5526f8001
14 changed files with 63 additions and 241 deletions
Generated
-12
View File
@@ -1116,7 +1116,6 @@ dependencies = [
"device-api",
"kernel-arch-interface",
"libk-mm-interface",
"memtables",
"static_assertions",
"tock-registers",
"yggdrasil-abi",
@@ -1150,7 +1149,6 @@ dependencies = [
"kernel-arch-interface",
"libk-mm-interface",
"log",
"memtables",
"static_assertions",
"tock-registers",
"yggdrasil-abi",
@@ -1178,7 +1176,6 @@ dependencies = [
"kernel-arch-x86",
"libk-mm-interface",
"log",
"memtables",
"static_assertions",
"tock-registers",
"yggdrasil-abi",
@@ -1431,14 +1428,6 @@ dependencies = [
"autocfg",
]
[[package]]
name = "memtables"
version = "0.1.0"
dependencies = [
"bitflags 2.8.0",
"bytemuck",
]
[[package]]
name = "miniz_oxide"
version = "0.8.4"
@@ -2955,7 +2944,6 @@ dependencies = [
"libk-util",
"log",
"memfs",
"memtables",
"prettyplease",
"static_assertions",
"tock-registers",
-1
View File
@@ -66,7 +66,6 @@ libk-util.path = "kernel/libk/libk-util"
libk-mm.path = "kernel/libk/libk-mm"
libk-mm-interface.path = "kernel/libk/libk-mm/interface"
libk-device.path = "kernel/libk/libk-device"
memtables.path = "kernel/lib/memtables"
vmalloc.path = "kernel/lib/vmalloc"
device-api-macros.path = "kernel/lib/device-api/macros"
device-tree.path = "kernel/lib/device-tree"
-1
View File
@@ -19,7 +19,6 @@ chrono.workspace = true
device-api = { workspace = true, features = ["derive"] }
device-api-macros.workspace = true
memtables.workspace = true
vmalloc.workspace = true
kernel-arch.workspace = true
-1
View File
@@ -7,7 +7,6 @@ edition = "2021"
yggdrasil-abi.workspace = true
kernel-arch-interface.workspace = true
libk-mm-interface.workspace = true
memtables.workspace = true
device-api = { workspace = true, features = ["derive"] }
bitflags.workspace = true
-1
View File
@@ -7,7 +7,6 @@ edition = "2024"
yggdrasil-abi.workspace = true
kernel-arch-interface.workspace = true
libk-mm-interface.workspace = true
memtables.workspace = true
device-api = { workspace = true, features = ["derive"] }
tock-registers.workspace = true
+4 -2
View File
@@ -11,10 +11,12 @@ use libk_mm_interface::{
EntryLevel, EntryLevelDrop, EntryLevelExt, MapAttributes, NextPageTable, TableAllocator,
},
};
use memtables::riscv64::PageAttributes;
use yggdrasil_abi::error::Error;
use crate::mem::{clone_kernel_tables, table::PageEntry};
use crate::mem::{
clone_kernel_tables,
table::{PageAttributes, PageEntry},
};
use super::{
table::{DroppableRange, PageTable, L1, L2, L3},
+59 -1
View File
@@ -1,8 +1,10 @@
use core::{
fmt,
marker::PhantomData,
ops::{Index, IndexMut, Range},
};
use bitflags::bitflags;
use libk_mm_interface::{
address::{AsPhysicalAddress, PhysicalAddress},
pointer::{PhysicalRef, PhysicalRefMut},
@@ -16,7 +18,40 @@ use yggdrasil_abi::error::Error;
use super::{KernelTableManagerImpl, USER_BOUNDARY};
pub use memtables::riscv64::PageAttributes;
bitflags! {
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub struct PageAttributes: u64 {
const N = 1 << 63;
/// Software-tracked dirty bit (RSW[0])
const SW_DIRTY = 1 << 9;
/// Dirty bit
const D = 1 << 7;
/// Access bit
const A = 1 << 6;
/// Global mapping bit, implies all lower levels are also global
const G = 1 << 5;
/// U-mode access permission
const U = 1 << 4;
/// Execute permission
const X = 1 << 3;
/// Write permission
const W = 1 << 2;
/// Read-permission
const R = 1 << 1;
/// Valid bit
const V = 1 << 0;
}
// X W R Meaning
// 0 0 0 Pointer to next level of page table
// 0 0 1 Read-only page
// 0 1 0 ---
// 0 1 1 Read-write page
// 1 0 0 Execute only
// 1 0 1 Read-execute page
// 1 1 0 ---
// 1 1 1 Read-write-execute page
}
/// L3 - entry is 4KiB
#[derive(Debug, Clone, Copy)]
@@ -283,3 +318,26 @@ impl<L: EntryLevel> IndexMut<usize> for PageTable<L> {
&mut self.entries[index]
}
}
impl fmt::Display for PageAttributes {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
use fmt::Write;
macro_rules! bit {
($self:ident, $field:expr, $letter:literal) => {
if $self.contains($field) {
f.write_char($letter)
} else {
f.write_char('-')
}
};
}
bit!(self, Self::R, 'r')?;
bit!(self, Self::W, 'w')?;
bit!(self, Self::X, 'x')?;
bit!(self, Self::U, 'u')?;
Ok(())
}
}
-1
View File
@@ -7,7 +7,6 @@ edition = "2021"
yggdrasil-abi.workspace = true
kernel-arch-interface.workspace = true
libk-mm-interface.workspace = true
memtables.workspace = true
device-api = { workspace = true, features = ["derive"] }
kernel-arch-x86.workspace = true
-13
View File
@@ -1,13 +0,0 @@
[package]
name = "memtables"
version = "0.1.0"
edition = "2021"
authors = ["Mark Poliakov <mark@alnyan.me>"]
[dependencies]
bitflags.workspace = true
bytemuck.workspace = true
[features]
default = []
all = []
-26
View File
@@ -1,26 +0,0 @@
use bytemuck::{Pod, Zeroable};
use crate::RawTable;
pub const KERNEL_L3_COUNT: usize = 8;
#[derive(Clone, Copy, Pod, Zeroable)]
#[repr(C)]
pub struct FixedTables {
// 1GiB entries
pub l1: RawTable,
// 2MiB entries
pub l2: RawTable,
pub l3s: [RawTable; KERNEL_L3_COUNT],
}
impl FixedTables {
pub const fn zeroed() -> Self {
Self {
l1: RawTable::zeroed(),
l2: RawTable::zeroed(),
l3s: [RawTable::zeroed(); KERNEL_L3_COUNT],
}
}
}
-35
View File
@@ -1,35 +0,0 @@
use crate::{aarch64, riscv64, x86_64};
pub enum AnyTables {
X86_64(x86_64::FixedTables),
AArch64(aarch64::FixedTables),
Riscv64(riscv64::FixedTables),
}
impl AnyTables {
pub fn as_bytes(&self) -> &[u8] {
match self {
Self::X86_64(tables) => bytemuck::bytes_of(tables),
Self::AArch64(tables) => bytemuck::bytes_of(tables),
Self::Riscv64(tables) => bytemuck::bytes_of(tables),
}
}
}
impl From<x86_64::FixedTables> for AnyTables {
fn from(value: x86_64::FixedTables) -> Self {
Self::X86_64(value)
}
}
impl From<aarch64::FixedTables> for AnyTables {
fn from(value: aarch64::FixedTables) -> Self {
Self::AArch64(value)
}
}
impl From<riscv64::FixedTables> for AnyTables {
fn from(value: riscv64::FixedTables) -> Self {
Self::Riscv64(value)
}
}
-36
View File
@@ -1,36 +0,0 @@
#![no_std]
use bytemuck::{Pod, Zeroable};
// AArch64
#[cfg(any(feature = "all", target_arch = "aarch64"))]
pub mod aarch64;
#[cfg(all(not(feature = "all"), target_arch = "aarch64"))]
pub use aarch64::FixedTables;
// x86-64
#[cfg(any(feature = "all", target_arch = "x86_64"))]
pub mod x86_64;
#[cfg(all(not(feature = "all"), target_arch = "x86_64"))]
pub use x86_64::FixedTables;
// RISC-V 64-bit
#[cfg(any(feature = "all", target_arch = "riscv64"))]
pub mod riscv64;
#[cfg(all(not(feature = "all"), target_arch = "riscv64"))]
pub use riscv64::FixedTables;
#[cfg(feature = "all")]
pub mod any;
#[derive(Clone, Copy, Pod, Zeroable)]
#[repr(C, align(0x1000))]
pub struct RawTable {
pub data: [u64; 512],
}
impl RawTable {
pub const fn zeroed() -> Self {
Self { data: [0; 512] }
}
}
-84
View File
@@ -1,84 +0,0 @@
use core::fmt;
use bitflags::bitflags;
use bytemuck::{Pod, Zeroable};
use crate::RawTable;
pub const KERNEL_L3_COUNT: usize = 8;
bitflags! {
#[derive(Clone, Copy, PartialEq, Eq, Debug)]
pub struct PageAttributes: u64 {
const N = 1 << 63;
/// Software-tracked dirty bit (RSW[0])
const SW_DIRTY = 1 << 9;
/// Dirty bit
const D = 1 << 7;
/// Access bit
const A = 1 << 6;
/// Global mapping bit, implies all lower levels are also global
const G = 1 << 5;
/// U-mode access permission
const U = 1 << 4;
/// Execute permission
const X = 1 << 3;
/// Write permission
const W = 1 << 2;
/// Read-permission
const R = 1 << 1;
/// Valid bit
const V = 1 << 0;
}
// X W R Meaning
// 0 0 0 Pointer to next level of page table
// 0 0 1 Read-only page
// 0 1 0 ---
// 0 1 1 Read-write page
// 1 0 0 Execute only
// 1 0 1 Read-execute page
// 1 1 0 ---
// 1 1 1 Read-write-execute page
}
#[derive(Clone, Copy, Pod, Zeroable)]
#[repr(C)]
pub struct FixedTables {
pub l1: RawTable,
pub kernel_l2: RawTable,
pub kernel_l3s: [RawTable; KERNEL_L3_COUNT],
}
impl FixedTables {
pub const fn zeroed() -> Self {
Self {
l1: RawTable::zeroed(),
kernel_l2: RawTable::zeroed(),
kernel_l3s: [RawTable::zeroed(); KERNEL_L3_COUNT],
}
}
}
impl fmt::Display for PageAttributes {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
use fmt::Write;
macro_rules! bit {
($self:ident, $field:expr, $letter:literal) => {
if $self.contains($field) {
f.write_char($letter)
} else {
f.write_char('-')
}
};
}
bit!(self, Self::R, 'r')?;
bit!(self, Self::W, 'w')?;
bit!(self, Self::X, 'x')?;
bit!(self, Self::U, 'u')?;
Ok(())
}
}
-27
View File
@@ -1,27 +0,0 @@
use bytemuck::{Pod, Zeroable};
use crate::RawTable;
pub const KERNEL_L3_COUNT: usize = 16;
#[derive(Clone, Copy, Pod, Zeroable)]
#[repr(C)]
pub struct FixedTables {
pub l0: RawTable,
pub kernel_l1: RawTable,
pub kernel_l2: RawTable,
pub kernel_l3s: [RawTable; KERNEL_L3_COUNT],
}
impl FixedTables {
pub const fn zeroed() -> Self {
Self {
l0: RawTable::zeroed(),
kernel_l1: RawTable::zeroed(),
kernel_l2: RawTable::zeroed(),
kernel_l3s: [RawTable::zeroed(); KERNEL_L3_COUNT],
}
}
}