mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
move platform-specific locations into the xous-rs crates
This enables a couple of things that have been long wanting, including: - the ability to know what PAGE_SIZE is from a single central define - the ability to determine where certain virtual memory ranges are located (useful for the userspace swapper). Previously these were "hidden" from crates because they were embedded directly in the kernel implementation module, which is not accessible as a dependency, thus causing us to e.g. create redundant copies of the PAGE_SIZE variable. This hopefully makes migrating to a larger page size in some future version of the OS a bit simpler.
This commit is contained in:
parent
5945634f5e
commit
f8978d7511
4 changed files with 77 additions and 46 deletions
|
|
@ -10,6 +10,8 @@ pub use syscall::*;
|
|||
pub mod process;
|
||||
pub use process::*;
|
||||
|
||||
pub const PAGE_SIZE: usize = 4096;
|
||||
|
||||
pub struct ProcessHandle {
|
||||
pub pid: crate::PID,
|
||||
pub cid: crate::CID,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,41 @@
|
|||
use crate::{Error, MemoryAddress, MemoryFlags, MemoryRange};
|
||||
const PAGE_SIZE: usize = 4096;
|
||||
|
||||
pub const PAGE_SIZE: usize = 4096;
|
||||
pub const DEFAULT_HEAP_BASE: usize = 0x2000_0000;
|
||||
pub const DEFAULT_MESSAGE_BASE: usize = 0x4000_0000;
|
||||
pub const DEFAULT_BASE: usize = 0x6000_0000;
|
||||
|
||||
// open a large aperture from A000-E000 for a potential RAM-mapped swap area: this gives us up to 1GiB swap
|
||||
// space. Please don't actually use all of it: performance will be unimaginably bad. Note that the
|
||||
// A000-E000 range is also shared with the MMAP virtual region.
|
||||
pub const SWAP_HAL_VADDR: usize = 0xa000_0000;
|
||||
pub const MMAP_VIRT_BASE: usize = 0xb000_0000;
|
||||
|
||||
pub const USER_AREA_END: usize = 0xff00_0000;
|
||||
pub const EXCEPTION_STACK_TOP: usize = 0xffff_0000;
|
||||
pub const PAGE_TABLE_OFFSET: usize = 0xff40_0000;
|
||||
pub const PAGE_TABLE_ROOT_OFFSET: usize = 0xff80_0000;
|
||||
pub const THREAD_CONTEXT_AREA: usize = 0xff80_1000;
|
||||
|
||||
pub const FLG_VALID: usize = 0x1;
|
||||
pub const FLG_R: usize = 0x2;
|
||||
pub const FLG_W: usize = 0x4;
|
||||
pub const FLG_X: usize = 0x8;
|
||||
pub const FLG_U: usize = 0x10; // User
|
||||
pub const FLG_A: usize = 0x40;
|
||||
pub const FLG_D: usize = 0x80; // Dirty (explicitly managed, not automatic)
|
||||
pub const FLG_S: usize = 0x100; // Shared
|
||||
pub const FLG_P: usize = 0x200; // swaP
|
||||
|
||||
/// swap-specific flags
|
||||
pub const SWAP_FLG_WIRED: u32 = 0x1_00;
|
||||
pub const SWAP_PT_VADDR: usize = 0xE000_0000;
|
||||
// E000_0000 - E100_0000 => 16 MiB of vaddr space for page tables; should be more than enough
|
||||
pub const SWAP_CFG_VADDR: usize = 0xE100_0000;
|
||||
pub const SWAP_RPT_VADDR: usize = 0xE100_1000;
|
||||
pub const SWAP_COUNT_VADDR: usize = 0xE110_0000;
|
||||
pub const SWAP_APP_UART_VADDR: usize = 0xE180_0000;
|
||||
pub const SWAP_APP_UART_IFRAM_VADDR: usize = 0xE180_1000;
|
||||
|
||||
extern crate alloc;
|
||||
use alloc::alloc::{Layout, alloc, dealloc};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,43 @@
|
|||
use crate::{Error, MemoryAddress, MemoryFlags, MemoryRange};
|
||||
|
||||
// pub const DEFAULT_STACK_TOP: usize = 0x8000_0000;
|
||||
pub const DEFAULT_HEAP_BASE: usize = 0x2000_0000;
|
||||
pub const DEFAULT_MESSAGE_BASE: usize = 0x4000_0000;
|
||||
pub const DEFAULT_BASE: usize = 0x6000_0000;
|
||||
|
||||
// open a large aperture from A000-E000 for a potential RAM-mapped swap area: this gives us up to 1GiB swap
|
||||
// space. Please don't actually use all of it: performance will be unimaginably bad. Note that the
|
||||
// A000-E000 range is also shared with the MMAP virtual region.
|
||||
pub const SWAP_HAL_VADDR: usize = 0xa000_0000;
|
||||
pub const MMAP_VIRT_BASE: usize = 0xb000_0000;
|
||||
|
||||
pub const USER_AREA_END: usize = 0xff00_0000;
|
||||
pub const EXCEPTION_STACK_TOP: usize = 0xffff_0000;
|
||||
pub const PAGE_SIZE: usize = 4096;
|
||||
pub const PAGE_TABLE_OFFSET: usize = 0xff40_0000;
|
||||
pub const PAGE_TABLE_ROOT_OFFSET: usize = 0xff80_0000;
|
||||
pub const THREAD_CONTEXT_AREA: usize = 0xff80_1000;
|
||||
|
||||
pub const FLG_VALID: usize = 0x1;
|
||||
pub const FLG_R: usize = 0x2;
|
||||
pub const FLG_W: usize = 0x4;
|
||||
pub const FLG_X: usize = 0x8;
|
||||
pub const FLG_U: usize = 0x10; // User
|
||||
pub const FLG_A: usize = 0x40;
|
||||
pub const FLG_D: usize = 0x80; // Dirty (explicitly managed, not automatic)
|
||||
pub const FLG_S: usize = 0x100; // Shared
|
||||
pub const FLG_P: usize = 0x200; // swaP
|
||||
|
||||
/// swap-specific flags
|
||||
pub const SWAP_FLG_WIRED: u32 = 0x1_00;
|
||||
pub const SWAP_PT_VADDR: usize = 0xE000_0000;
|
||||
// E000_0000 - E100_0000 => 16 MiB of vaddr space for page tables; should be more than enough
|
||||
pub const SWAP_CFG_VADDR: usize = 0xE100_0000;
|
||||
pub const SWAP_RPT_VADDR: usize = 0xE100_1000;
|
||||
pub const SWAP_COUNT_VADDR: usize = 0xE110_0000;
|
||||
pub const SWAP_APP_UART_VADDR: usize = 0xE180_0000;
|
||||
pub const SWAP_APP_UART_IFRAM_VADDR: usize = 0xE180_1000;
|
||||
|
||||
pub fn map_memory_pre(
|
||||
_phys: &Option<MemoryAddress>,
|
||||
_virt: &Option<MemoryAddress>,
|
||||
|
|
|
|||
|
|
@ -10,51 +10,6 @@ pub type Connection = usize;
|
|||
|
||||
pub const MAX_CID: usize = 34;
|
||||
|
||||
pub const FLASH_PHYS_BASE: u32 = 0x2000_0000;
|
||||
pub const SOC_REGION_LOC: u32 = 0x0000_0000;
|
||||
pub const SOC_REGION_LEN: u32 = 0x00D0_0000; // gw + staging + loader + kernel
|
||||
|
||||
// note to self: if these locations change, be sure to update the "filters" addresses
|
||||
// in the gateware, so that we are consistent on what parts of the SPINOR are allowed access via USB debug
|
||||
pub const SOC_MAIN_GW_LOC: u32 = 0x0000_0000; // gateware - primary loading address
|
||||
pub const SOC_MAIN_GW_LEN: u32 = 0x0028_0000;
|
||||
pub const SOC_STAGING_GW_LOC: u32 = 0x0028_0000; // gateware - staging copy
|
||||
pub const SOC_STAGING_GW_LEN: u32 = 0x0028_0000;
|
||||
|
||||
pub const LOADER_LOC: u32 = 0x0050_0000; // loader - base
|
||||
pub const LOADER_CODE_LEN: u32 = 0x0003_0000; // code region only
|
||||
pub const LOADER_FONT_LOC: u32 = 0x0053_0000; // should be the same as graphics-server/src/fontmap.rs/FONT_BASE
|
||||
pub const LOADER_FONT_LEN: u32 = 0x0044_0000; // length of font region only
|
||||
pub const LOADER_TOTAL_LEN: u32 = LOADER_CODE_LEN + LOADER_FONT_LEN; // code + font
|
||||
|
||||
pub const EARLY_SETTINGS: u32 = 0x0097_0000;
|
||||
|
||||
pub const KERNEL_LOC: u32 = 0x0098_0000; // kernel start
|
||||
pub const KERNEL_LEN: u32 = 0x0140_0000; // max kernel length = 0xA0_0000 * 2 => half the area for backup kernel & updates
|
||||
pub const KERNEL_BACKUP_OFFSET: u32 = KERNEL_LEN - 0x1000; // last page of kernel is where the backup block gets located = 0x1D7_F000
|
||||
|
||||
pub const EC_REGION_LOC: u32 = 0x07F8_0000; // EC update staging area. Must be aligned to a 64k-address.
|
||||
pub const EC_WF200_PKG_LOC: u32 = 0x07F8_0000;
|
||||
pub const EC_WF200_PKG_LEN: u32 = 0x0004_E000;
|
||||
pub const EC_FW_PKG_LOC: u32 = 0x07FC_E000;
|
||||
pub const EC_FW_PKG_LEN: u32 = 0x0003_2000;
|
||||
pub const EC_REGION_LEN: u32 = 0x0008_0000;
|
||||
|
||||
pub const PDDB_LOC: u32 = 0x01D8_0000; // PDDB start
|
||||
pub const PDDB_LEN: u32 = EC_REGION_LOC - PDDB_LOC; // must be 64k-aligned (bulk erase block size) for proper function.
|
||||
|
||||
// quantum alloted to each process before a context switch is forced
|
||||
pub const BASE_QUANTA_MS: u32 = 10;
|
||||
|
||||
// sentinel used by test infrastructure to assist with parsing
|
||||
// The format of any test infrastructure output to recover is as follows:
|
||||
// _|TT|_<ident>,<data separated by commas>,_|TE|_
|
||||
// where _|TT|_ and _|TE|_ are bookends around the data to be reported
|
||||
// <ident> is a single-word identifier that routes the data to a given parser
|
||||
// <data> is free-form data, which will be split at comma boundaries by the parser
|
||||
pub const BOOKEND_START: &str = "_|TT|_";
|
||||
pub const BOOKEND_END: &str = "_|TE|_";
|
||||
|
||||
/// Hard-wired PID of the swapper
|
||||
#[cfg(feature = "swap")]
|
||||
pub const SWAPPER_PID: u8 = 2;
|
||||
|
|
|
|||
Loading…
Reference in a new issue