mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
update apis in hal-service
This commit is contained in:
parent
577efdfdd2
commit
261ea7a880
5 changed files with 44 additions and 2 deletions
|
|
@ -54,6 +54,9 @@ pub enum HalOpcode {
|
||||||
/// Manipulate the OS timer
|
/// Manipulate the OS timer
|
||||||
SetPreemptionState = 64,
|
SetPreemptionState = 64,
|
||||||
|
|
||||||
|
/// Trigger wfi
|
||||||
|
Wfi = 128,
|
||||||
|
|
||||||
/// Exit server
|
/// Exit server
|
||||||
Quit = 255,
|
Quit = 255,
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,3 +42,9 @@ pub fn clk_to_per(top_in_mhz: u32, perclk_in_mhz: u32) -> Option<(u8, u8, u32)>
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(num_derive::FromPrimitive, num_derive::ToPrimitive, Debug)]
|
||||||
|
pub enum PowerOp {
|
||||||
|
Wfi,
|
||||||
|
Invalid,
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -31,7 +31,7 @@ rand = "0.8.5"
|
||||||
rand_core = "0.6.4"
|
rand_core = "0.6.4"
|
||||||
rand_chacha = "0.3.1"
|
rand_chacha = "0.3.1"
|
||||||
bitfield = "0.13.2"
|
bitfield = "0.13.2"
|
||||||
# TOODO: migrate from bitfield to bitbybit
|
# TODO: migrate from bitfield to bitbybit
|
||||||
bitbybit = "1.4.0"
|
bitbybit = "1.4.0"
|
||||||
arbitrary-int = "1.2"
|
arbitrary-int = "1.2"
|
||||||
bytemuck = "1.24.0"
|
bytemuck = "1.24.0"
|
||||||
|
|
@ -54,4 +54,6 @@ bmp180 = ["bao1x-hal/bmp180"]
|
||||||
board-baosec = ["bao1x-hal/board-baosec"]
|
board-baosec = ["bao1x-hal/board-baosec"]
|
||||||
board-baosor = ["bao1x-hal/board-baosor"]
|
board-baosor = ["bao1x-hal/board-baosor"]
|
||||||
board-dabao = ["bao1x-hal/board-dabao"]
|
board-dabao = ["bao1x-hal/board-dabao"]
|
||||||
|
|
||||||
|
with-duart = ["bao1x-hal/debug-print-duart"]
|
||||||
default = ["app-uart", "utralib"]
|
default = ["app-uart", "utralib"]
|
||||||
|
|
|
||||||
|
|
@ -129,6 +129,8 @@ fn try_alloc(ifram_allocs: &mut Vec<Option<Sender>>, size: usize, sender: Sender
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fn main() {
|
fn main() {
|
||||||
|
#[cfg(feature = "with-duart")]
|
||||||
|
bao1x_hal::claim_duart();
|
||||||
log_server::init_wait().unwrap();
|
log_server::init_wait().unwrap();
|
||||||
log::set_max_level(log::LevelFilter::Info);
|
log::set_max_level(log::LevelFilter::Info);
|
||||||
log::info!("my PID is {}", xous::process::id());
|
log::info!("my PID is {}", xous::process::id());
|
||||||
|
|
@ -200,7 +202,13 @@ fn main() {
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
let mut i2c = unsafe {
|
let mut i2c = unsafe {
|
||||||
bao1x_hal::udma::I2c::new_with_ifram(i2c_channel, 400_000, bao1x_api::PERCLK, i2c_ifram, &udma_global)
|
bao1x_hal::udma::I2cDriver::new_with_ifram(
|
||||||
|
i2c_channel,
|
||||||
|
400_000,
|
||||||
|
bao1x_api::PERCLK,
|
||||||
|
i2c_ifram,
|
||||||
|
&udma_global,
|
||||||
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
// os timer initializations
|
// os timer initializations
|
||||||
|
|
@ -265,6 +273,13 @@ fn main() {
|
||||||
|
|
||||||
servers::keyboard::start_keyboard_service();
|
servers::keyboard::start_keyboard_service();
|
||||||
|
|
||||||
|
#[cfg(feature = "board-baosec")]
|
||||||
|
let power_sid = xous::create_server().unwrap();
|
||||||
|
#[cfg(feature = "board-baosec")]
|
||||||
|
servers::power::start_power_service(power_sid);
|
||||||
|
#[cfg(feature = "board-baosec")]
|
||||||
|
let power_cid = xous::connect(power_sid).unwrap();
|
||||||
|
|
||||||
// claim BIO
|
// claim BIO
|
||||||
#[cfg(feature = "board-baosec")]
|
#[cfg(feature = "board-baosec")]
|
||||||
let bio_ss = Arc::new(Mutex::new(xous_bio_bdma::BioSharedState::new()));
|
let bio_ss = Arc::new(Mutex::new(xous_bio_bdma::BioSharedState::new()));
|
||||||
|
|
@ -285,6 +300,19 @@ fn main() {
|
||||||
let opcode = num_traits::FromPrimitive::from_usize(msg.body.id()).unwrap_or(HalOpcode::InvalidCall);
|
let opcode = num_traits::FromPrimitive::from_usize(msg.body.id()).unwrap_or(HalOpcode::InvalidCall);
|
||||||
log::debug!("{:?}", opcode);
|
log::debug!("{:?}", opcode);
|
||||||
match opcode {
|
match opcode {
|
||||||
|
#[cfg(feature = "board-baosec")]
|
||||||
|
HalOpcode::Wfi => {
|
||||||
|
log::info!("turn off preemption");
|
||||||
|
os_timer.wfo(utra::timer0::EV_ENABLE_ZERO, 0);
|
||||||
|
// this call *can't* block because WFI relies on HAL services to operate!
|
||||||
|
xous::send_message(
|
||||||
|
power_cid,
|
||||||
|
xous::Message::new_scalar(PowerOp::Wfi.to_usize().unwrap(), 0, 0, 0, 0),
|
||||||
|
)
|
||||||
|
.unwrap();
|
||||||
|
}
|
||||||
|
#[cfg(not(feature = "board-baosec"))]
|
||||||
|
HalOpcode::Wfi => unimplemented!(),
|
||||||
HalOpcode::MapIfram => {
|
HalOpcode::MapIfram => {
|
||||||
if let Some(scalar) = msg.body.scalar_message_mut() {
|
if let Some(scalar) = msg.body.scalar_message_mut() {
|
||||||
let requested_size = scalar.arg1; // requested size
|
let requested_size = scalar.arg1; // requested size
|
||||||
|
|
|
||||||
|
|
@ -3,5 +3,8 @@ pub mod keyboard;
|
||||||
// TRNG server is only needed for baosec; dabao can cheat and use the kernel TRNG port
|
// TRNG server is only needed for baosec; dabao can cheat and use the kernel TRNG port
|
||||||
#[cfg(feature = "board-baosec")]
|
#[cfg(feature = "board-baosec")]
|
||||||
mod baosec_hw;
|
mod baosec_hw;
|
||||||
|
// only baosec has power management facilities
|
||||||
|
#[cfg(feature = "board-baosec")]
|
||||||
|
pub mod power;
|
||||||
pub mod rtc;
|
pub mod rtc;
|
||||||
pub mod trng; // not public - for internal use only
|
pub mod trng; // not public - for internal use only
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue