mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
fixes for cramium target
This commit is contained in:
parent
4db82e01d8
commit
61b781892e
4 changed files with 33 additions and 10 deletions
|
|
@ -28,8 +28,8 @@ utralib = { version = "0.1.24", optional = true, default-features = false }
|
|||
[target.'cfg(any(windows,unix))'.dependencies]
|
||||
|
||||
[features]
|
||||
cramium-soc = ["utralib/cramium-soc", "cramium-hal"]
|
||||
spi-alt-channel = [] # needs to match loader setting!
|
||||
cramium-soc = ["utralib/cramium-soc", "cramium-hal", "loader/cramium-soc"]
|
||||
spi-alt-channel = [] # needs to match loader setting!
|
||||
cramium-fpga = ["utralib/cramium-fpga"]
|
||||
precursor = ["utralib/precursor"]
|
||||
hosted = ["utralib/hosted"]
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
use core::fmt::{Error, Write};
|
||||
|
||||
use utralib::*;
|
||||
|
||||
pub struct DebugUart {}
|
||||
impl DebugUart {
|
||||
#[cfg(all(feature = "debug-print", any(feature = "precursor", feature = "renode")))]
|
||||
|
|
@ -23,7 +21,7 @@ impl DebugUart {
|
|||
let mut uart = unsafe {
|
||||
udma::Uart::get_handle(
|
||||
loader::swap::SWAP_APP_UART_VADDR as usize,
|
||||
loader::swap::APP_UART_IFRAM_ADDR as usize,
|
||||
loader::APP_UART_IFRAM_ADDR as usize,
|
||||
loader::swap::SWAP_APP_UART_IFRAM_VADDR as usize,
|
||||
)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -36,10 +36,12 @@ pub enum Opcode {
|
|||
|
||||
/// This structure contains shared state accessible between the userspace code and the blocking swap call
|
||||
/// handler.
|
||||
struct SwapperSharedState {
|
||||
pub struct SwapperSharedState {
|
||||
pub pts: SwapPageTables,
|
||||
pub hal: SwapHal,
|
||||
pub rpt: RuntimePageTracker,
|
||||
pub sram_start: usize,
|
||||
pub sram_size: usize,
|
||||
}
|
||||
impl SwapperSharedState {
|
||||
pub fn pt_walk(&self, pid: u8, va: usize) -> Option<usize> {
|
||||
|
|
@ -66,6 +68,17 @@ struct SharedStateStorage {
|
|||
pub inner: Option<SwapperSharedState>,
|
||||
}
|
||||
|
||||
pub fn change_owner(ss: &mut SwapperSharedState, pid: u8, paddr: usize) {
|
||||
// First, check to see if the region is in RAM,
|
||||
if paddr >= ss.sram_start && paddr < ss.sram_start + ss.sram_size {
|
||||
// Mark this page as in-use by the kernel
|
||||
ss.rpt.allocs[(paddr - ss.sram_start as usize) / PAGE_SIZE] = pid;
|
||||
return;
|
||||
}
|
||||
// The region isn't in RAM. We're in the swapper, we can't handle errors - drop straight to panic.
|
||||
panic!("Tried to swap region {:08x} that isn't in RAM!", paddr);
|
||||
}
|
||||
|
||||
/// blocking swap call handler
|
||||
/// 8 argument values are always pushed on the stack; the meaning is bound differently based upon the specific
|
||||
/// opcode. Not all arguments are used in all cases, unused argument values have no valid meaning (but in
|
||||
|
|
@ -123,6 +136,8 @@ fn swap_handler(
|
|||
)
|
||||
},
|
||||
},
|
||||
sram_start: swap_spec.sram_start as usize,
|
||||
sram_size: swap_spec.sram_size as usize,
|
||||
});
|
||||
}
|
||||
let ss = sss.inner.as_mut().expect("Shared state should be initialized");
|
||||
|
|
@ -174,6 +189,17 @@ fn swap_handler(
|
|||
xous::AllocAdvice::deserialize(a4, a5),
|
||||
xous::AllocAdvice::deserialize(a6, a7),
|
||||
];
|
||||
for advice in advisories {
|
||||
match advice {
|
||||
xous::AllocAdvice::Allocate(pid, _vaddr, paddr) => {
|
||||
change_owner(ss, pid.get(), paddr);
|
||||
}
|
||||
xous::AllocAdvice::Free(_pid, _vaddr, paddr) => {
|
||||
change_owner(ss, 0, paddr);
|
||||
}
|
||||
xous::AllocAdvice::Uninit => {} // not all the records have to be populated
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
writeln!(DebugUart {}, "Unimplemented or unknown opcode: {}", opcode).ok();
|
||||
|
|
|
|||
|
|
@ -2,10 +2,9 @@ use core::fmt::Write;
|
|||
use core::mem::size_of;
|
||||
|
||||
use aes_gcm_siv::{AeadInPlace, Aes256GcmSiv, Error, KeyInit, Nonce, Tag};
|
||||
use cramium_hal::ifram::IframRange;
|
||||
use cramium_hal::udma::*;
|
||||
use loader::swap::{SwapSpec, SPIM_RAM_IFRAM_ADDR, SWAP_HAL_VADDR};
|
||||
use num_traits::ToBytes;
|
||||
use xous::MemoryRange;
|
||||
|
||||
use crate::debug::*;
|
||||
|
||||
|
|
@ -31,9 +30,9 @@ impl SwapHal {
|
|||
let channel = SpimChannel::Channel0;
|
||||
#[cfg(not(feature = "spi-alt-channel"))]
|
||||
let channel = SpimChannel::Channel1;
|
||||
SwapMac {
|
||||
Self {
|
||||
swap_mac_start: ram_size_actual,
|
||||
cipher: Aes256GcmSiv::new((spec.key).into()),
|
||||
cipher: Aes256GcmSiv::new((&spec.key).into()),
|
||||
// safety: this is safe because the global clocks were gated on by the bootloader
|
||||
// note that also the IFRAM0 range is pre-allocated by the bootloader, and pre-mapped
|
||||
// into the correct virtual address as well.
|
||||
|
|
|
|||
Loading…
Reference in a new issue