mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-19 09:00:54 +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]
|
[target.'cfg(any(windows,unix))'.dependencies]
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
cramium-soc = ["utralib/cramium-soc", "cramium-hal"]
|
cramium-soc = ["utralib/cramium-soc", "cramium-hal", "loader/cramium-soc"]
|
||||||
spi-alt-channel = [] # needs to match loader setting!
|
spi-alt-channel = [] # needs to match loader setting!
|
||||||
cramium-fpga = ["utralib/cramium-fpga"]
|
cramium-fpga = ["utralib/cramium-fpga"]
|
||||||
precursor = ["utralib/precursor"]
|
precursor = ["utralib/precursor"]
|
||||||
hosted = ["utralib/hosted"]
|
hosted = ["utralib/hosted"]
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,5 @@
|
||||||
use core::fmt::{Error, Write};
|
use core::fmt::{Error, Write};
|
||||||
|
|
||||||
use utralib::*;
|
|
||||||
|
|
||||||
pub struct DebugUart {}
|
pub struct DebugUart {}
|
||||||
impl DebugUart {
|
impl DebugUart {
|
||||||
#[cfg(all(feature = "debug-print", any(feature = "precursor", feature = "renode")))]
|
#[cfg(all(feature = "debug-print", any(feature = "precursor", feature = "renode")))]
|
||||||
|
|
@ -23,7 +21,7 @@ impl DebugUart {
|
||||||
let mut uart = unsafe {
|
let mut uart = unsafe {
|
||||||
udma::Uart::get_handle(
|
udma::Uart::get_handle(
|
||||||
loader::swap::SWAP_APP_UART_VADDR as usize,
|
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,
|
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
|
/// This structure contains shared state accessible between the userspace code and the blocking swap call
|
||||||
/// handler.
|
/// handler.
|
||||||
struct SwapperSharedState {
|
pub struct SwapperSharedState {
|
||||||
pub pts: SwapPageTables,
|
pub pts: SwapPageTables,
|
||||||
pub hal: SwapHal,
|
pub hal: SwapHal,
|
||||||
pub rpt: RuntimePageTracker,
|
pub rpt: RuntimePageTracker,
|
||||||
|
pub sram_start: usize,
|
||||||
|
pub sram_size: usize,
|
||||||
}
|
}
|
||||||
impl SwapperSharedState {
|
impl SwapperSharedState {
|
||||||
pub fn pt_walk(&self, pid: u8, va: usize) -> Option<usize> {
|
pub fn pt_walk(&self, pid: u8, va: usize) -> Option<usize> {
|
||||||
|
|
@ -66,6 +68,17 @@ struct SharedStateStorage {
|
||||||
pub inner: Option<SwapperSharedState>,
|
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
|
/// blocking swap call handler
|
||||||
/// 8 argument values are always pushed on the stack; the meaning is bound differently based upon the specific
|
/// 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
|
/// 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");
|
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(a4, a5),
|
||||||
xous::AllocAdvice::deserialize(a6, a7),
|
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();
|
writeln!(DebugUart {}, "Unimplemented or unknown opcode: {}", opcode).ok();
|
||||||
|
|
|
||||||
|
|
@ -2,10 +2,9 @@ use core::fmt::Write;
|
||||||
use core::mem::size_of;
|
use core::mem::size_of;
|
||||||
|
|
||||||
use aes_gcm_siv::{AeadInPlace, Aes256GcmSiv, Error, KeyInit, Nonce, Tag};
|
use aes_gcm_siv::{AeadInPlace, Aes256GcmSiv, Error, KeyInit, Nonce, Tag};
|
||||||
|
use cramium_hal::ifram::IframRange;
|
||||||
use cramium_hal::udma::*;
|
use cramium_hal::udma::*;
|
||||||
use loader::swap::{SwapSpec, SPIM_RAM_IFRAM_ADDR, SWAP_HAL_VADDR};
|
use loader::swap::{SwapSpec, SPIM_RAM_IFRAM_ADDR, SWAP_HAL_VADDR};
|
||||||
use num_traits::ToBytes;
|
|
||||||
use xous::MemoryRange;
|
|
||||||
|
|
||||||
use crate::debug::*;
|
use crate::debug::*;
|
||||||
|
|
||||||
|
|
@ -31,9 +30,9 @@ impl SwapHal {
|
||||||
let channel = SpimChannel::Channel0;
|
let channel = SpimChannel::Channel0;
|
||||||
#[cfg(not(feature = "spi-alt-channel"))]
|
#[cfg(not(feature = "spi-alt-channel"))]
|
||||||
let channel = SpimChannel::Channel1;
|
let channel = SpimChannel::Channel1;
|
||||||
SwapMac {
|
Self {
|
||||||
swap_mac_start: ram_size_actual,
|
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
|
// 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
|
// note that also the IFRAM0 range is pre-allocated by the bootloader, and pre-mapped
|
||||||
// into the correct virtual address as well.
|
// into the correct virtual address as well.
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue