mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-21 09:14:34 +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.
|
// but it is just a handy tool to use when it *does* work.
|
||||||
//
|
//
|
||||||
#[cfg(feature = "cramium-soc")]
|
#[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")]
|
#[cfg(feature = "cramium-soc")]
|
||||||
crate::platform::process_update();
|
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
|
// But for now, the basic "validate everything as a blob" is perhaps good enough to
|
||||||
// armor code-at-rest against front-line patching attacks.
|
// armor code-at-rest against front-line patching attacks.
|
||||||
let kab = KernelArguments::new(arg_buffer);
|
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
|
// Store the initial boot config on the stack. We don't know
|
||||||
// where in heap this memory will go.
|
// where in heap this memory will go.
|
||||||
#[allow(clippy::cast_ptr_alignment)] // This test only works on 32-bit systems
|
#[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(feature = "swap")]
|
||||||
{
|
{
|
||||||
cfg.swap_hal = SwapHal::new(&cfg);
|
cfg.swap_hal = SwapHal::new(&cfg, _perclk_freq);
|
||||||
read_swap_config(&mut cfg);
|
read_swap_config(&mut cfg);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
use cramium_hal::iox::{IoGpio, IoSetup};
|
use cramium_hal::iox::{IoGpio, IoSetup};
|
||||||
use cramium_hal::udma::UdmaGlobalConfig;
|
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
|
where
|
||||||
T: IoSetup + IoGpio,
|
T: IoSetup + IoGpio,
|
||||||
{
|
{
|
||||||
// test the display SPI interface
|
// test the display SPI interface
|
||||||
// safety: this is called exactly once on boot
|
// 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();
|
sh1107.init();
|
||||||
{
|
{
|
||||||
/* // pattern test for debugging pixel orientations - done with this now, I think?
|
/* // 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;
|
pub const KERNEL_OFFSET: usize = 0x4_0000;
|
||||||
|
|
||||||
#[cfg(feature = "cramium-soc")]
|
#[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.
|
// 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
|
// 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,
|
// 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());
|
udma_uart.write("Press any key to continue...".as_bytes());
|
||||||
getc();
|
getc();
|
||||||
udma_uart.write(b"\n\rBooting!\n\r");
|
udma_uart.write(b"\n\rBooting!\n\r");
|
||||||
|
|
||||||
|
perclk
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "clock-tests")]
|
#[cfg(feature = "clock-tests")]
|
||||||
|
|
|
||||||
|
|
@ -86,12 +86,12 @@ SECTIONS
|
||||||
. = ALIGN(4);
|
. = ALIGN(4);
|
||||||
_edata = .;
|
_edata = .;
|
||||||
} > REGION_DATA AT > REGION_RODATA
|
} > REGION_DATA AT > REGION_RODATA
|
||||||
|
/*
|
||||||
.fonts : ALIGN(65536)
|
.fonts : ALIGN(65536)
|
||||||
{
|
{
|
||||||
KEEP(*(.fontdata));
|
KEEP(*(.fontdata));
|
||||||
} > FONTS
|
} > FONTS
|
||||||
|
*/
|
||||||
.bss (NOLOAD) :
|
.bss (NOLOAD) :
|
||||||
{
|
{
|
||||||
_sbss = .;
|
_sbss = .;
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ pub struct SwapHal {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl 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 {
|
if let Some(swap) = cfg.swap {
|
||||||
let udma_global = GlobalConfig::new(utralib::generated::HW_UDMA_CTRL_BASE as *mut u32);
|
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 {
|
let mut flash_spim = unsafe {
|
||||||
Spim::new_with_ifram(
|
Spim::new_with_ifram(
|
||||||
channel,
|
channel,
|
||||||
25_000_000,
|
// has to be half the clock frequency reaching the block, but run it as fast
|
||||||
50_000_000,
|
// as we can run perclk
|
||||||
|
perclk_freq / 4,
|
||||||
|
perclk_freq / 2,
|
||||||
SpimClkPol::LeadingEdgeRise,
|
SpimClkPol::LeadingEdgeRise,
|
||||||
SpimClkPha::CaptureOnLeading,
|
SpimClkPha::CaptureOnLeading,
|
||||||
SpimCs::Cs0,
|
SpimCs::Cs0,
|
||||||
|
|
@ -68,8 +70,8 @@ impl SwapHal {
|
||||||
let mut ram_spim = unsafe {
|
let mut ram_spim = unsafe {
|
||||||
Spim::new_with_ifram(
|
Spim::new_with_ifram(
|
||||||
channel,
|
channel,
|
||||||
25_000_000,
|
perclk_freq / 4,
|
||||||
50_000_000,
|
perclk_freq / 2,
|
||||||
SpimClkPol::LeadingEdgeRise,
|
SpimClkPol::LeadingEdgeRise,
|
||||||
SpimClkPha::CaptureOnLeading,
|
SpimClkPha::CaptureOnLeading,
|
||||||
SpimCs::Cs1,
|
SpimCs::Cs1,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue