mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-17 08:40:52 +00:00
fix startup race-condition on baosec platform
This commit is contained in:
parent
7590984e4f
commit
b669d65f80
3 changed files with 19 additions and 15 deletions
|
|
@ -143,15 +143,11 @@ fn main() {
|
|||
servers::susres::start_susres_service();
|
||||
|
||||
// these two servers need to start so that update_perclk calls can succeed
|
||||
let clk_mgr = bao1x_hal_service::ClockManager::new();
|
||||
servers::i2c::start_i2c_service();
|
||||
servers::others::start_peri_service(clk_mgr.get_per());
|
||||
let i2c_conn =
|
||||
xns.request_connection(SERVER_NAME_BAO1X_I2C).expect("Couldn't connect to bao1x I2C server");
|
||||
let peri_conn =
|
||||
xns.request_connection(SERVER_NAME_BAO1X_OTHERS).expect("Couldn't connect to bao1x misc peri server");
|
||||
servers::others::start_peri_service();
|
||||
|
||||
std::thread::spawn(move || {
|
||||
let xns = xous_names::XousNames::new().unwrap();
|
||||
let mut ifram_allocs = [Vec::new(), Vec::new()];
|
||||
// code is written assuming the IFRAM blocks have the same size. Since this is fixed in
|
||||
// hardware, it's a good assumption; but the assert is put here in case we port this to
|
||||
|
|
@ -259,6 +255,12 @@ fn main() {
|
|||
// we want a static array defined like this.
|
||||
let mut irq_table: [Option<IrqLocalRegistration>; 8] = [const { None }; 8];
|
||||
|
||||
let i2c_conn =
|
||||
xns.request_connection(SERVER_NAME_BAO1X_I2C).expect("Couldn't connect to bao1x I2C server");
|
||||
let peri_conn = xns
|
||||
.request_connection(SERVER_NAME_BAO1X_OTHERS)
|
||||
.expect("Couldn't connect to bao1x misc peri server");
|
||||
|
||||
let mut msg_opt = None;
|
||||
log::debug!("Starting main loop");
|
||||
loop {
|
||||
|
|
@ -641,7 +643,7 @@ fn main() {
|
|||
}
|
||||
});
|
||||
|
||||
servers::bio::start_bio_service(clk_mgr.get_fclk());
|
||||
servers::bio::start_bio_service();
|
||||
|
||||
servers::keyboard::start_keyboard_service();
|
||||
|
||||
|
|
|
|||
|
|
@ -2,13 +2,13 @@ use bao1x_api::bio::*;
|
|||
use bao1x_api::bio_resources::*;
|
||||
use bao1x_hal::bio_hw;
|
||||
|
||||
pub fn start_bio_service(clk_freq: u32) {
|
||||
pub fn start_bio_service() {
|
||||
std::thread::spawn(move || {
|
||||
bio_service(clk_freq);
|
||||
bio_service();
|
||||
});
|
||||
}
|
||||
|
||||
fn bio_service(clk_freq: u32) {
|
||||
fn bio_service() {
|
||||
let xns = xous_names::XousNames::new().unwrap();
|
||||
// claim the server name
|
||||
let sid = xns.register_name(BIO_SERVER_NAME, None).unwrap();
|
||||
|
|
@ -18,7 +18,8 @@ fn bio_service(clk_freq: u32) {
|
|||
#[cfg(feature = "oem-baosec-lite")]
|
||||
let led_conn = xns.request_connection_blocking("_oem_led_").unwrap();
|
||||
|
||||
let mut bio_ss = bio_hw::BioSharedState::new(clk_freq);
|
||||
let clk_mgr = bao1x_hal_service::ClockManager::new();
|
||||
let mut bio_ss = bio_hw::BioSharedState::new(clk_mgr.get_fclk());
|
||||
let mut msg_opt = None;
|
||||
loop {
|
||||
xous::reply_and_receive_next(sid, &mut msg_opt).unwrap();
|
||||
|
|
|
|||
|
|
@ -7,15 +7,15 @@ use bao1x_api::{IoxDir, IoxEnable, IoxFunction, PeripheralOpcode, SERVER_NAME_BA
|
|||
use bao1x_hal::udma::{Adc, AdcExtChannel, AdcSource};
|
||||
use bao1x_hal_service::UdmaGlobal;
|
||||
|
||||
pub fn start_peri_service(clk_freq: u32) {
|
||||
pub fn start_peri_service() {
|
||||
let _ = std::thread::spawn({
|
||||
move || {
|
||||
peri_service(clk_freq);
|
||||
peri_service();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
fn peri_service(clk_freq: u32) -> ! {
|
||||
fn peri_service() -> ! {
|
||||
let xns = xous_names::XousNames::new().unwrap();
|
||||
// claim the server name
|
||||
let sid = xns.register_name(SERVER_NAME_BAO1X_OTHERS, None).unwrap();
|
||||
|
|
@ -23,8 +23,9 @@ fn peri_service(clk_freq: u32) -> ! {
|
|||
let iox = crate::iox::IoxHal::new();
|
||||
let udma_global = UdmaGlobal::new();
|
||||
udma_global.udma_clock_config(bao1x_api::PeriphId::Adc, true);
|
||||
let clk_mgr = bao1x_hal_service::ClockManager::new();
|
||||
// safety: clocks are turned on, and perclk already configured as so
|
||||
let mut adc = unsafe { Adc::new(clk_freq) };
|
||||
let mut adc = unsafe { Adc::new(clk_mgr.get_per()) };
|
||||
|
||||
let mut msg_opt = None;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue