mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
cleanup loader path to use dynamically derived perclk
This commit is contained in:
parent
d21789beff
commit
9867a3e488
5 changed files with 20 additions and 14 deletions
|
|
@ -91,7 +91,9 @@ pub unsafe extern "C" fn rust_entry(signed_buffer: *const usize, signature: u32)
|
|||
// but it is just a handy tool to use when it *does* work.
|
||||
//
|
||||
#[cfg(feature = "cramium-soc")]
|
||||
crate::platform::early_init(); // sets up PLLs so we're not running at 16MHz...
|
||||
let perclk_freq = crate::platform::early_init(); // sets up PLLs so we're not running at 16MHz...
|
||||
#[cfg(not(feature = "cramium-soc"))]
|
||||
let perclk_freq = 0;
|
||||
|
||||
#[cfg(feature = "cramium-soc")]
|
||||
crate::platform::process_update();
|
||||
|
|
@ -116,10 +118,10 @@ pub unsafe extern "C" fn rust_entry(signed_buffer: *const usize, signature: u32)
|
|||
// But for now, the basic "validate everything as a blob" is perhaps good enough to
|
||||
// armor code-at-rest against front-line patching attacks.
|
||||
let kab = KernelArguments::new(arg_buffer);
|
||||
boot_sequence(kab, signature, fs_prehash);
|
||||
boot_sequence(kab, signature, fs_prehash, perclk_freq);
|
||||
}
|
||||
|
||||
fn boot_sequence(args: KernelArguments, _signature: u32, fs_prehash: [u8; 64]) -> ! {
|
||||
fn boot_sequence(args: KernelArguments, _signature: u32, fs_prehash: [u8; 64], _perclk_freq: u32) -> ! {
|
||||
// Store the initial boot config on the stack. We don't know
|
||||
// where in heap this memory will go.
|
||||
#[allow(clippy::cast_ptr_alignment)] // This test only works on 32-bit systems
|
||||
|
|
@ -133,7 +135,7 @@ fn boot_sequence(args: KernelArguments, _signature: u32, fs_prehash: [u8; 64]) -
|
|||
|
||||
#[cfg(feature = "swap")]
|
||||
{
|
||||
cfg.swap_hal = SwapHal::new(&cfg);
|
||||
cfg.swap_hal = SwapHal::new(&cfg, _perclk_freq);
|
||||
read_swap_config(&mut cfg);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
use cramium_hal::iox::{IoGpio, IoSetup};
|
||||
use cramium_hal::udma::UdmaGlobalConfig;
|
||||
|
||||
pub fn show_logo<T>(pclk_freq: u32, udma_global: &dyn UdmaGlobalConfig, iox: &T)
|
||||
pub fn show_logo<T>(perclk_freq: u32, udma_global: &dyn UdmaGlobalConfig, iox: &T)
|
||||
where
|
||||
T: IoSetup + IoGpio,
|
||||
{
|
||||
// test the display SPI interface
|
||||
// safety: this is called exactly once on boot
|
||||
let mut sh1107 = cramium_hal::sh1107::Oled128x128::new(iox, udma_global);
|
||||
let mut sh1107 = cramium_hal::sh1107::Oled128x128::new(perclk_freq, iox, udma_global);
|
||||
sh1107.init();
|
||||
{
|
||||
/* // pattern test for debugging pixel orientations - done with this now, I think?
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ pub const FLASH_BASE: usize = utralib::generated::HW_RERAM_MEM;
|
|||
pub const KERNEL_OFFSET: usize = 0x4_0000;
|
||||
|
||||
#[cfg(feature = "cramium-soc")]
|
||||
pub fn early_init() {
|
||||
pub fn early_init() -> u32 {
|
||||
// Set up the initial clocks. This is done as a "poke array" into a table of addresses.
|
||||
// Why? because this is actually how it's done for the chip verification code. We can
|
||||
// make this nicer and more abstract with register meanings down the road, if necessary,
|
||||
|
|
@ -740,6 +740,8 @@ pub fn early_init() {
|
|||
udma_uart.write("Press any key to continue...".as_bytes());
|
||||
getc();
|
||||
udma_uart.write(b"\n\rBooting!\n\r");
|
||||
|
||||
perclk
|
||||
}
|
||||
|
||||
#[cfg(feature = "clock-tests")]
|
||||
|
|
|
|||
|
|
@ -86,12 +86,12 @@ SECTIONS
|
|||
. = ALIGN(4);
|
||||
_edata = .;
|
||||
} > REGION_DATA AT > REGION_RODATA
|
||||
|
||||
/*
|
||||
.fonts : ALIGN(65536)
|
||||
{
|
||||
KEEP(*(.fontdata));
|
||||
} > FONTS
|
||||
|
||||
*/
|
||||
.bss (NOLOAD) :
|
||||
{
|
||||
_sbss = .;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ pub struct SwapHal {
|
|||
}
|
||||
|
||||
impl SwapHal {
|
||||
pub fn new(cfg: &BootConfig) -> Option<SwapHal> {
|
||||
pub fn new(cfg: &BootConfig, perclk_freq: u32) -> Option<SwapHal> {
|
||||
if let Some(swap) = cfg.swap {
|
||||
let udma_global = GlobalConfig::new(utralib::generated::HW_UDMA_CTRL_BASE as *mut u32);
|
||||
|
||||
|
|
@ -49,8 +49,10 @@ impl SwapHal {
|
|||
let mut flash_spim = unsafe {
|
||||
Spim::new_with_ifram(
|
||||
channel,
|
||||
25_000_000,
|
||||
50_000_000,
|
||||
// has to be half the clock frequency reaching the block, but run it as fast
|
||||
// as we can run perclk
|
||||
perclk_freq / 4,
|
||||
perclk_freq / 2,
|
||||
SpimClkPol::LeadingEdgeRise,
|
||||
SpimClkPha::CaptureOnLeading,
|
||||
SpimCs::Cs0,
|
||||
|
|
@ -68,8 +70,8 @@ impl SwapHal {
|
|||
let mut ram_spim = unsafe {
|
||||
Spim::new_with_ifram(
|
||||
channel,
|
||||
25_000_000,
|
||||
50_000_000,
|
||||
perclk_freq / 4,
|
||||
perclk_freq / 2,
|
||||
SpimClkPol::LeadingEdgeRise,
|
||||
SpimClkPha::CaptureOnLeading,
|
||||
SpimCs::Cs1,
|
||||
|
|
|
|||
Loading…
Reference in a new issue