mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
cleanup swap top mod now that most of the implementation is done
This commit is contained in:
parent
30b5be7a79
commit
379d4e81c5
1 changed files with 15 additions and 44 deletions
|
|
@ -1,4 +1,17 @@
|
||||||
use crate::{bootconfig::BootConfig, PageTable};
|
/// Virtual address fields:
|
||||||
|
/// 31 22 21 12 11 0
|
||||||
|
/// | L1 index | L2 index | LSB of addr |
|
||||||
|
///
|
||||||
|
/// L1 PTE thus consists of 1024 entries, each resolving to a 22-bit number.
|
||||||
|
/// - The bottom 10 bits are flags
|
||||||
|
/// - The top 2 bits are 0
|
||||||
|
/// - The middle 20 bits are the MSB of the address to the PA of the L2 PTE
|
||||||
|
///
|
||||||
|
/// L2 PTE thus consists of 1024 entries, each resolving to a 22-bit number. It is
|
||||||
|
/// indexed by the "L2 index" bits.
|
||||||
|
/// - The bottom 10 bits are flags
|
||||||
|
/// - The top 2 bits are 0
|
||||||
|
/// - The middle 20 bits are the MSB of the address to the PA of the target page
|
||||||
|
|
||||||
#[repr(C)]
|
#[repr(C)]
|
||||||
pub struct SwapDescriptor {
|
pub struct SwapDescriptor {
|
||||||
|
|
@ -26,46 +39,4 @@ pub struct RawPage {
|
||||||
pub data: [u8; 4096],
|
pub data: [u8; 4096],
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Mapping pages to swap.
|
pub const SWAP_PT_VADDR: usize = 0xE000_0000;
|
||||||
///
|
|
||||||
/// Given a virtual address and PID, map to a physical offset in swap.
|
|
||||||
/*
|
|
||||||
bitfield! {
|
|
||||||
#[derive(Copy, Clone, Eq)]
|
|
||||||
impl Debug;
|
|
||||||
pub u32,
|
|
||||||
}
|
|
||||||
pub struct SwapPte {}
|
|
||||||
*/
|
|
||||||
|
|
||||||
const FLG_VALID: usize = 0x1;
|
|
||||||
|
|
||||||
/// Virtual address fields:
|
|
||||||
/// 31 22 21 12 11 0
|
|
||||||
/// | L1 index | L2 index | LSB of addr |
|
|
||||||
///
|
|
||||||
/// L1 PTE thus consists of 1024 entries, each resolving to a 22-bit number.
|
|
||||||
/// - The bottom 10 bits are flags
|
|
||||||
/// - The top 2 bits are 0
|
|
||||||
/// - The middle 20 bits are the MSB of the address to the PA of the L2 PTE
|
|
||||||
pub fn set_l1_pte(from_va: usize, to_pa: usize, root_pt: &mut PageTable) {
|
|
||||||
let index = from_va >> 22;
|
|
||||||
root_pt.entries[index] = ((to_pa & 0xFFFF_FC00) >> 2) // top 2 bits of PA are not used, we don't do 34-bit PA featured by Sv32
|
|
||||||
| FLG_VALID;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Virtual address fields:
|
|
||||||
/// 31 22 21 12 11 0
|
|
||||||
/// | L1 index | L2 index | LSB of addr |
|
|
||||||
///
|
|
||||||
/// L2 PTE thus consists of 1024 entries, each resolving to a 22-bit number. It is
|
|
||||||
/// indexed by the "L2 index" bits.
|
|
||||||
/// - The bottom 10 bits are flags
|
|
||||||
/// - The top 2 bits are 0
|
|
||||||
/// - The middle 20 bits are the MSB of the address to the PA of the target page
|
|
||||||
pub fn set_l2_pte(from_va: usize, to_pa: usize, l2_pt: &mut PageTable, flags: usize) {
|
|
||||||
let index = (from_va >> 12) & 0x3_FF;
|
|
||||||
l2_pt.entries[index] = ((to_pa & 0xFFFF_FC00) >> 2) // top 2 bits of PA are not used, we don't do 34-bit PA featured by Sv32
|
|
||||||
| flags
|
|
||||||
| FLG_VALID;
|
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue