mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
migrations for moving constants out of xous-rs/kernel and into board/platform
this is a fairly major re-org of where key constants go that define platform features. things that were in xous-rs that were platform specific (namely precursor) were moved into a boards file, and things that are generic to the system (like PAGE_SIZE) are moved to a public location in xous-rs::arch.
This commit is contained in:
parent
63e4319314
commit
7af009be78
9 changed files with 30 additions and 56 deletions
|
|
@ -52,9 +52,9 @@ cramium-soc = [
|
|||
]
|
||||
verilator-only = []
|
||||
cramium-fpga = ["utralib/cramium-fpga", "rand_chacha"]
|
||||
board-baosec = ["cramium-hal/kernel-baosec"]
|
||||
board-baosor = []
|
||||
board-dabao = []
|
||||
board-baosec = ["cramium-hal/kernel-baosec", "memmap-flash", "swap"]
|
||||
board-baosor = ["cramium-hal/kernel-baosor"]
|
||||
board-dabao = ["cramium-hal/kernel-dabao"]
|
||||
|
||||
atsama5d27 = ["utralib/atsama5d27"]
|
||||
precursor = ["utralib/precursor"]
|
||||
|
|
@ -70,6 +70,7 @@ wrap-print = []
|
|||
big-heap = [] # Cause heaps to start at 12 MM instead of 512 kB
|
||||
v2p = ["xous-kernel/v2p"]
|
||||
swap = ["xous-kernel/swap", "loader/swap"]
|
||||
memmap-flash = []
|
||||
debug-swap = []
|
||||
debug-swap-verbose = []
|
||||
raw-trng = ["xous-kernel/raw-trng"]
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ pub const DEFAULT_HEAP_BASE: usize = 0x3000_0000;
|
|||
pub const DEFAULT_MESSAGE_BASE: usize = 0x4000_0000;
|
||||
pub const DEFAULT_BASE: usize = 0x6000_0000;
|
||||
|
||||
pub const PAGE_SIZE: usize = 4096;
|
||||
pub const PAGE_SIZE: usize = xous_kernel::arch::PAGE_SIZE;
|
||||
pub const PAGE_TABLE_OFFSET: usize = 0xfefe_0000;
|
||||
pub const PAGE_TABLE_ROOT_OFFSET: usize = 0xff80_0000;
|
||||
pub const THREAD_CONTEXT_AREA: usize = 0xff80_4000;
|
||||
|
|
|
|||
|
|
@ -3,10 +3,10 @@
|
|||
|
||||
use core::mem;
|
||||
|
||||
use xous_kernel::arch::PAGE_SIZE;
|
||||
use xous_kernel::{PID, ProcessInit, ProcessStartup, TID, ThreadInit, arch::Arguments};
|
||||
|
||||
use crate::arch::mem::THREAD_CONTEXT_AREA;
|
||||
use crate::mem::PAGE_SIZE;
|
||||
use crate::services::ProcessInner;
|
||||
|
||||
static mut PROCESS: *mut ProcessImpl = THREAD_CONTEXT_AREA as *mut ProcessImpl;
|
||||
|
|
|
|||
|
|
@ -1,17 +1,10 @@
|
|||
// SPDX-FileCopyrightText: 2020 Sean Cross <sean@xobs.io>
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
pub const PAGE_SIZE: usize = 4096;
|
||||
use xous_kernel::{Error, MemoryFlags, PID};
|
||||
|
||||
use crate::mem::MemoryManager;
|
||||
|
||||
pub const DEFAULT_HEAP_BASE: usize = 0x2000_0000;
|
||||
pub const DEFAULT_MESSAGE_BASE: usize = 0x4000_0000;
|
||||
pub const DEFAULT_BASE: usize = 0x6000_0000;
|
||||
|
||||
pub const USER_AREA_END: usize = 0xff00_0000;
|
||||
|
||||
#[derive(Copy, Clone, Default, Debug, PartialEq)]
|
||||
pub struct MemoryMapping {
|
||||
pid: usize,
|
||||
|
|
|
|||
|
|
@ -3,34 +3,14 @@
|
|||
|
||||
use core::fmt;
|
||||
|
||||
use riscv::register::satp;
|
||||
use ::riscv::register::satp;
|
||||
#[cfg(feature = "gdb-stub")]
|
||||
use riscv::register::sstatus;
|
||||
use xous_kernel::{MemoryFlags, PID};
|
||||
use ::riscv::register::sstatus;
|
||||
use xous_kernel::{MemoryFlags, PID, arch::*};
|
||||
|
||||
use crate::arch::process::InitialProcess;
|
||||
use crate::mem::MemoryManager;
|
||||
|
||||
// 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;
|
||||
|
||||
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;
|
||||
pub const FLG_A: usize = 0x40;
|
||||
pub const FLG_D: usize = 0x80;
|
||||
|
||||
extern "C" {
|
||||
pub fn flush_mmu();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,9 +8,9 @@ pub const EXCEPTION_TID: TID = 1;
|
|||
pub const INITIAL_TID: TID = 2;
|
||||
pub const IRQ_TID: TID = 0;
|
||||
|
||||
use xous_kernel::arch::PAGE_SIZE;
|
||||
use xous_kernel::{PID, ProcessInit, ProcessStartup, TID, ThreadInit};
|
||||
|
||||
use crate::arch::mem::PAGE_SIZE;
|
||||
use crate::services::ProcessInner;
|
||||
|
||||
// use crate::args::KernelArguments;
|
||||
|
|
@ -89,7 +89,7 @@ struct ProcessImpl {
|
|||
/// is a multiple of the page size.
|
||||
fn _assert_processimpl_is_page_sized() {
|
||||
unsafe {
|
||||
mem::transmute::<ProcessImpl, [u8; crate::mem::PAGE_SIZE]>(ProcessImpl {
|
||||
mem::transmute::<ProcessImpl, [u8; xous_kernel::arch::PAGE_SIZE]>(ProcessImpl {
|
||||
scratch: 0,
|
||||
hardware_thread: 0,
|
||||
inner: Default::default(),
|
||||
|
|
|
|||
|
|
@ -276,7 +276,7 @@ impl Server {
|
|||
let queue = {
|
||||
let mut queue = vec![];
|
||||
// TODO: Replace this with a direct operation on a passed-in page
|
||||
queue.resize_with(crate::arch::mem::PAGE_SIZE / mem::size_of::<QueuedMessage>(), || {
|
||||
queue.resize_with(xous_kernel::arch::PAGE_SIZE / mem::size_of::<QueuedMessage>(), || {
|
||||
QueuedMessage::Empty
|
||||
});
|
||||
queue
|
||||
|
|
@ -343,7 +343,7 @@ impl Server {
|
|||
if !cfg!(baremetal) && virt & 0xfff != 0 {
|
||||
return Err(xous_kernel::Error::BadAlignment);
|
||||
}
|
||||
for addr in (virt..(virt + size)).step_by(crate::mem::PAGE_SIZE) {
|
||||
for addr in (virt..(virt + size)).step_by(xous_kernel::arch::PAGE_SIZE) {
|
||||
if let Err(e) = mm.unmap_page(addr as *mut usize) {
|
||||
if result.is_ok() {
|
||||
result = Err(e);
|
||||
|
|
@ -460,7 +460,7 @@ impl Server {
|
|||
MemoryManager::with_mut(|mm| {
|
||||
let virt = self.queue.as_mut_ptr() as usize;
|
||||
let size = self.queue.len();
|
||||
for addr in (virt..(virt + size)).step_by(crate::arch::mem::PAGE_SIZE) {
|
||||
for addr in (virt..(virt + size)).step_by(xous_kernel::arch::PAGE_SIZE) {
|
||||
mm.unmap_page(addr as *mut usize).unwrap();
|
||||
}
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@
|
|||
use core::num::NonZeroU8;
|
||||
|
||||
use xous_kernel::MemoryRange;
|
||||
use xous_kernel::arch::ProcessStartup;
|
||||
use xous_kernel::arch::*;
|
||||
// use core::mem;
|
||||
use xous_kernel::{
|
||||
CID, Error, MemoryAddress, Message, PID, ProcessInit, SID, TID, ThreadInit, pid_from_usize,
|
||||
|
|
@ -219,11 +219,11 @@ pub struct ProcessInner {
|
|||
impl Default for ProcessInner {
|
||||
fn default() -> Self {
|
||||
ProcessInner {
|
||||
mem_default_base: arch::mem::DEFAULT_BASE,
|
||||
mem_default_last: arch::mem::DEFAULT_BASE,
|
||||
mem_message_base: arch::mem::DEFAULT_MESSAGE_BASE,
|
||||
mem_message_last: arch::mem::DEFAULT_MESSAGE_BASE,
|
||||
mem_heap_base: arch::mem::DEFAULT_HEAP_BASE,
|
||||
mem_default_base: DEFAULT_BASE,
|
||||
mem_default_last: DEFAULT_BASE,
|
||||
mem_message_base: DEFAULT_MESSAGE_BASE,
|
||||
mem_message_last: DEFAULT_MESSAGE_BASE,
|
||||
mem_heap_base: DEFAULT_HEAP_BASE,
|
||||
mem_heap_size: 0,
|
||||
mem_heap_max: if cfg!(feature = "big-heap") { 1024 * 1024 * 12 } else { 1024 * 512 },
|
||||
connection_map: [None; 32],
|
||||
|
|
@ -713,7 +713,7 @@ impl SystemServices {
|
|||
// causing an instruction fault and exiting the interrupt.
|
||||
ArchProcess::with_current_mut(|arch_process| {
|
||||
let sp = if pid.get() == 1 {
|
||||
arch::mem::EXCEPTION_STACK_TOP
|
||||
EXCEPTION_STACK_TOP
|
||||
} else {
|
||||
arch_process.current_thread().stack_pointer()
|
||||
};
|
||||
|
|
@ -1304,7 +1304,7 @@ impl SystemServices {
|
|||
if dest_virt as usize & 0xfff != 0 {
|
||||
return Err(xous_kernel::Error::BadAddress);
|
||||
}
|
||||
if (dest_virt as usize) + len > crate::arch::mem::USER_AREA_END {
|
||||
if (dest_virt as usize) + len > USER_AREA_END {
|
||||
return Err(xous_kernel::Error::BadAddress);
|
||||
}
|
||||
|
||||
|
|
@ -1313,7 +1313,7 @@ impl SystemServices {
|
|||
// Iterators and `ptr.wrapping_add()` operate on `usize` types,
|
||||
// which effectively lowers the `len`.
|
||||
let usize_len = len / core::mem::size_of::<usize>();
|
||||
let usize_page = crate::mem::PAGE_SIZE / core::mem::size_of::<usize>();
|
||||
let usize_page = PAGE_SIZE / core::mem::size_of::<usize>();
|
||||
|
||||
// If the dest and src PID is the same, do nothing.
|
||||
if current_pid == dest_pid {
|
||||
|
|
@ -1420,7 +1420,7 @@ impl SystemServices {
|
|||
// Iterators and `ptr.wrapping_add()` operate on `usize` types,
|
||||
// which effectively lowers the `len`.
|
||||
let usize_len = len / core::mem::size_of::<usize>();
|
||||
let usize_page = crate::mem::PAGE_SIZE / core::mem::size_of::<usize>();
|
||||
let usize_page = xous_kernel::arch::PAGE_SIZE / core::mem::size_of::<usize>();
|
||||
|
||||
let current_pid = self.current_pid();
|
||||
// If it's within the same process, ignore the move operation and
|
||||
|
|
@ -1551,7 +1551,7 @@ impl SystemServices {
|
|||
// Iterators and `ptr.wrapping_add()` operate on `usize` types,
|
||||
// which effectively lowers the `len`.
|
||||
let usize_len = len / core::mem::size_of::<usize>();
|
||||
let usize_page = crate::mem::PAGE_SIZE / core::mem::size_of::<usize>();
|
||||
let usize_page = PAGE_SIZE / core::mem::size_of::<usize>();
|
||||
|
||||
let current_pid = self.current_pid();
|
||||
// If it's within the same process, ignore the operation.
|
||||
|
|
@ -1765,7 +1765,7 @@ impl SystemServices {
|
|||
#[cfg(baremetal)]
|
||||
// Allocate a single page for the server queue
|
||||
let backing = crate::mem::MemoryManager::with_mut(|mm| unsafe {
|
||||
MemoryRange::new(mm.map_zeroed_page(pid, false)? as _, crate::arch::mem::PAGE_SIZE)
|
||||
MemoryRange::new(mm.map_zeroed_page(pid, false)? as _, PAGE_SIZE)
|
||||
})?;
|
||||
|
||||
#[cfg(not(baremetal))]
|
||||
|
|
|
|||
|
|
@ -3,15 +3,15 @@
|
|||
|
||||
use core::cmp::Ordering;
|
||||
|
||||
use loader::swap::SWAP_FLG_WIRED;
|
||||
use loader::swap::SWAP_RPT_VADDR;
|
||||
use xous_kernel::SWAPPER_PID;
|
||||
use xous_kernel::arch::EXCEPTION_STACK_TOP;
|
||||
use xous_kernel::arch::PAGE_SIZE;
|
||||
use xous_kernel::arch::SWAP_FLG_WIRED;
|
||||
use xous_kernel::arch::SWAP_RPT_VADDR;
|
||||
use xous_kernel::{PID, SysCallResult, TID};
|
||||
|
||||
use crate::arch::current_pid;
|
||||
use crate::arch::mem::EXCEPTION_STACK_TOP;
|
||||
use crate::arch::mem::MMUFlags;
|
||||
use crate::arch::mem::PAGE_SIZE;
|
||||
use crate::mem::MemoryManager;
|
||||
use crate::services::SystemServices;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue