mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
devboot mode support
This commit is contained in:
parent
22906ce366
commit
00be94d913
13 changed files with 119 additions and 18 deletions
|
|
@ -3,7 +3,7 @@
|
|||
<device schemaVersion="1.1" xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="CMSIS-SVD.xsd" >
|
||||
<vendor>litex</vendor>
|
||||
<name>SOC</name>
|
||||
<description><![CDATA[Litex SoC 2021-06-28 03:35:41]]></description>
|
||||
<description><![CDATA[Litex SoC 2021-07-03 18:21:53]]></description>
|
||||
|
||||
<addressUnitBits>8</addressUnitBits>
|
||||
<width>32</width>
|
||||
|
|
@ -1222,10 +1222,10 @@ register to disable individual events.]]></description>
|
|||
<register>
|
||||
<name>GIT_GITREV</name>
|
||||
<description><![CDATA[First 32-bits of the git revision. This documentation was built from git rev
|
||||
``fce2f15c``, so this value is 4242731356, which should be enough to check out
|
||||
``977355ba``, so this value is 2540918202, which should be enough to check out
|
||||
the exact git version used to build this firmware.]]></description>
|
||||
<addressOffset>0x0014</addressOffset>
|
||||
<resetValue>0xfce2f15c</resetValue>
|
||||
<resetValue>0x977355ba</resetValue>
|
||||
<size>32</size>
|
||||
<fields>
|
||||
<field>
|
||||
|
|
@ -1242,7 +1242,7 @@ the exact git version used to build this firmware.]]></description>
|
|||
is ``1``, then the repository this was built from has one additional commit
|
||||
beyond the tag indicated in `MAJOR`, `MINOR`, and `REVISION`.]]></description>
|
||||
<addressOffset>0x0018</addressOffset>
|
||||
<resetValue>0x21</resetValue>
|
||||
<resetValue>0x26</resetValue>
|
||||
<size>32</size>
|
||||
<fields>
|
||||
<field>
|
||||
|
|
@ -1487,10 +1487,26 @@ register to disable individual events.]]></description>
|
|||
</field>
|
||||
</fields>
|
||||
</register>
|
||||
<register>
|
||||
<name>DEVBOOT</name>
|
||||
<addressOffset>0x0018</addressOffset>
|
||||
<resetValue>0x00</resetValue>
|
||||
<size>32</size>
|
||||
<fields>
|
||||
<field>
|
||||
<name>devboot</name>
|
||||
<msb>0</msb>
|
||||
<bitRange>[0:0]</bitRange>
|
||||
<lsb>0</lsb>
|
||||
<description><![CDATA[When set to ``1``, permanently add a strike-through on the top of the screen.
|
||||
Cannot be cleared, except by a full reset.]]></description>
|
||||
</field>
|
||||
</fields>
|
||||
</register>
|
||||
</registers>
|
||||
<addressBlock>
|
||||
<offset>0</offset>
|
||||
<size>0x18</size>
|
||||
<size>0x1c</size>
|
||||
<usage>registers</usage>
|
||||
</addressBlock>
|
||||
</peripheral>
|
||||
|
|
@ -3451,7 +3467,7 @@ inject too fast.]]></description>
|
|||
<name>SEED1</name>
|
||||
<description><![CDATA[Bits 32-63 of `SEED_SEED`. Seed used for the build]]></description>
|
||||
<addressOffset>0x0000</addressOffset>
|
||||
<resetValue>0x314fcffc</resetValue>
|
||||
<resetValue>0x698bb704</resetValue>
|
||||
<size>32</size>
|
||||
<fields>
|
||||
<field>
|
||||
|
|
@ -3466,7 +3482,7 @@ inject too fast.]]></description>
|
|||
<name>SEED0</name>
|
||||
<description><![CDATA[Bits 0-31 of `SEED_SEED`.]]></description>
|
||||
<addressOffset>0x0004</addressOffset>
|
||||
<resetValue>0x67a42778</resetValue>
|
||||
<resetValue>0x5d2ea7df</resetValue>
|
||||
<size>32</size>
|
||||
<fields>
|
||||
<field>
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -11,6 +11,7 @@ use core::sync::atomic::{AtomicBool, Ordering};
|
|||
use xous::msg_blocking_scalar_unpack;
|
||||
use xous_ipc::Buffer;
|
||||
|
||||
#[cfg(target_os = "none")]
|
||||
#[macro_use]
|
||||
extern crate engine25519_as;
|
||||
|
||||
|
|
@ -715,6 +716,11 @@ mod implementation {
|
|||
}
|
||||
pub fn power_on(&mut self, _on: bool) {
|
||||
}
|
||||
pub fn montgomery(&mut self, _job: MontgomeryJob) {
|
||||
}
|
||||
pub fn get_single_result(&mut self, _r: usize) -> JobResult {
|
||||
JobResult::EngineUnavailable
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -147,6 +147,9 @@ pub(crate) enum Opcode {
|
|||
/// raise a context menu
|
||||
RaiseMenu,
|
||||
|
||||
/// Turn on Devboot Flag
|
||||
Devboot,
|
||||
|
||||
Quit,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -273,6 +273,17 @@ impl Gam {
|
|||
let buf = Buffer::into_buf(menu_name).or(Err(xous::Error::InternalError))?;
|
||||
buf.send(self.conn, Opcode::RaiseMenu.to_u32().unwrap()).or(Err(xous::Error::InternalError)).map(|_|())
|
||||
}
|
||||
|
||||
/// this is a one-way door, once you've set it, you can't unset it.
|
||||
pub fn set_devboot(&self, enable: bool) -> Result<(), xous::Error> {
|
||||
let ena =
|
||||
if enable { 1 }
|
||||
else { 0 };
|
||||
send_message(self.conn,
|
||||
Message::new_scalar(Opcode::Devboot.to_usize().unwrap(),
|
||||
ena, 0, 0, 0,)
|
||||
).map(|_| ())
|
||||
}
|
||||
}
|
||||
|
||||
use core::sync::atomic::{AtomicU32, Ordering};
|
||||
|
|
|
|||
|
|
@ -927,7 +927,11 @@ fn xmain() -> ! {
|
|||
let menu_name = buffer.to_original::<String::<128>, _>().unwrap();
|
||||
log::debug!("got request to raise menu {}", menu_name);
|
||||
context_mgr.raise_menu(menu_name.as_str().unwrap(), &gfx, &mut canvases);
|
||||
}
|
||||
},
|
||||
Some(Opcode::Devboot) => msg_scalar_unpack!(msg, ena, _, _, _, {
|
||||
if ena != 0 { gfx.set_devboot(true).expect("couldn't send devboot message"); }
|
||||
else { gfx.set_devboot(false).expect("couldn't send devboot message"); }
|
||||
}),
|
||||
Some(Opcode::Quit) => break,
|
||||
None => {log::error!("unhandled message {:?}", msg);}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -84,6 +84,9 @@ pub(crate) enum Opcode {
|
|||
/// sets whether a sleep note should be rendered or not on suspend
|
||||
SetSleepNote,
|
||||
|
||||
/// permanently turns on the Devboot mark
|
||||
Devboot,
|
||||
|
||||
/// SuspendResume callback
|
||||
SuspendResume,
|
||||
|
||||
|
|
|
|||
|
|
@ -208,4 +208,12 @@ impl XousDisplay {
|
|||
fn busy(&self) -> bool {
|
||||
self.csr.rf(utra::memlcd::BUSY_BUSY) == 1
|
||||
}
|
||||
|
||||
pub fn set_devboot(&mut self, ena: bool) {
|
||||
if ena {
|
||||
self.csr.wfo(utra::memlcd::DEVBOOT_DEVBOOT, 1);
|
||||
} else {
|
||||
self.csr.wfo(utra::memlcd::DEVBOOT_DEVBOOT, 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ pub struct XousDisplay {
|
|||
native_buffer: Vec<u32>, //[u32; WIDTH * HEIGHT],
|
||||
emulated_buffer: [u32; FB_SIZE],
|
||||
window: Window,
|
||||
devboot: bool,
|
||||
}
|
||||
|
||||
struct XousKeyboardHandler {
|
||||
|
|
@ -65,8 +66,15 @@ impl XousDisplay {
|
|||
native_buffer,
|
||||
window,
|
||||
emulated_buffer: [0u32; FB_SIZE],
|
||||
devboot: false,
|
||||
}
|
||||
}
|
||||
pub fn set_devboot(&mut self, ena: bool) {
|
||||
if ena {
|
||||
self.devboot = true;
|
||||
}
|
||||
// ignore attempts to turn off devboot
|
||||
}
|
||||
pub fn suspend(&self, _flag: bool) {}
|
||||
pub fn resume(&self, _flag: bool) {}
|
||||
|
||||
|
|
@ -110,6 +118,8 @@ impl XousDisplay {
|
|||
}
|
||||
|
||||
fn emulated_to_native(&mut self) {
|
||||
const DEVBOOT_LINE: usize = 12;
|
||||
let mut row = 0;
|
||||
for (dest_row, src_row) in self
|
||||
.native_buffer
|
||||
.chunks_mut(WIDTH as _)
|
||||
|
|
@ -117,13 +127,18 @@ impl XousDisplay {
|
|||
{
|
||||
for (dest_cell, src_cell) in dest_row.chunks_mut(32).zip(src_row) {
|
||||
for (bit, dest) in dest_cell.iter_mut().enumerate() {
|
||||
*dest = if src_cell & (1 << bit) != 0 {
|
||||
DARK_COLOUR
|
||||
if self.devboot && ((bit >> 1) % 2) == 0 && (row == DEVBOOT_LINE) { // try to render the devboot defile somewhat accurately
|
||||
*dest = LIGHT_COLOUR
|
||||
} else {
|
||||
LIGHT_COLOUR
|
||||
};
|
||||
*dest = if src_cell & (1 << bit) != 0 {
|
||||
DARK_COLOUR
|
||||
} else {
|
||||
LIGHT_COLOUR
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
row += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,6 +141,17 @@ impl Gfx {
|
|||
Message::new_scalar(Opcode::SetSleepNote.to_usize().unwrap(), arg, 0, 0, 0,
|
||||
)).map(|_|())
|
||||
}
|
||||
|
||||
/// this is a one-way door, once you've set it, you can't unset it.
|
||||
pub fn set_devboot(&self, enable: bool) -> Result<(), xous::Error> {
|
||||
let ena =
|
||||
if enable { 1 }
|
||||
else { 0 };
|
||||
send_message(self.conn,
|
||||
Message::new_scalar(Opcode::Devboot.to_usize().unwrap(),
|
||||
ena, 0, 0, 0,)
|
||||
).map(|_| ())
|
||||
}
|
||||
}
|
||||
|
||||
use core::sync::atomic::{AtomicU32, Ordering};
|
||||
|
|
|
|||
|
|
@ -393,6 +393,10 @@ fn xmain() -> ! {
|
|||
display.update();
|
||||
display.redraw();
|
||||
}),
|
||||
Some(Opcode::Devboot) => msg_scalar_unpack!(msg, ena, _, _, _, {
|
||||
if ena != 0 { display.set_devboot(true); }
|
||||
else { display.set_devboot(false); }
|
||||
}),
|
||||
Some(Opcode::Quit) => break,
|
||||
None => {log::error!("received opcode scalar that is not handled");}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ impl CommonEnv {
|
|||
|
||||
///// 1. add your module here, and pull its namespace into the local crate
|
||||
mod echo; use echo::*;
|
||||
//mod test; use test::*;
|
||||
mod test; use test::*;
|
||||
mod sleep; use sleep::*;
|
||||
mod sensors; use sensors::*;
|
||||
mod callback; use callback::*;
|
||||
|
|
@ -104,7 +104,7 @@ pub struct CmdEnv {
|
|||
common_env: CommonEnv,
|
||||
lastverb: String::<256>,
|
||||
///// 2. declare storage for your command here.
|
||||
//test_cmd: Test,
|
||||
test_cmd: Test,
|
||||
sleep_cmd: Sleep,
|
||||
sensors_cmd: Sensors,
|
||||
callback_cmd: CallBack,
|
||||
|
|
@ -152,7 +152,7 @@ impl CmdEnv {
|
|||
common_env: common,
|
||||
lastverb: String::<256>::new(),
|
||||
///// 3. initialize your storage, by calling new()
|
||||
//test_cmd: Test::new(),
|
||||
test_cmd: Test::new(),
|
||||
sleep_cmd: Sleep::new(&xns),
|
||||
sensors_cmd: Sensors::new(),
|
||||
callback_cmd: CallBack::new(),
|
||||
|
|
@ -181,7 +181,7 @@ impl CmdEnv {
|
|||
let commands: &mut [& mut dyn ShellCmdApi] = &mut [
|
||||
///// 4. add your command to this array, so that it can be looked up and dispatched
|
||||
&mut echo_cmd,
|
||||
//&mut self.test_cmd,
|
||||
&mut self.test_cmd,
|
||||
&mut self.sleep_cmd,
|
||||
&mut self.sensors_cmd,
|
||||
&mut self.callback_cmd,
|
||||
|
|
|
|||
|
|
@ -16,12 +16,32 @@ impl Test {
|
|||
impl<'a> ShellCmdApi<'a> for Test {
|
||||
cmd_api!(test);
|
||||
|
||||
fn process(&mut self, _args: String::<1024>, _env: &mut CommonEnv) -> Result<Option<String::<1024>>, xous::Error> {
|
||||
fn process(&mut self, args: String::<1024>, env: &mut CommonEnv) -> Result<Option<String::<1024>>, xous::Error> {
|
||||
use core::fmt::Write;
|
||||
|
||||
self.state += 1;
|
||||
let mut ret = String::<1024>::new();
|
||||
write!(ret, "Test has run {} times.", self.state).unwrap();
|
||||
write!(ret, "Test has run {} times.\n", self.state).unwrap();
|
||||
|
||||
let mut tokens = args.as_str().unwrap().split(' ');
|
||||
|
||||
if let Some(sub_cmd) = tokens.next() {
|
||||
match sub_cmd {
|
||||
"devboot" => {
|
||||
env.gam.set_devboot(true).unwrap();
|
||||
write!(ret, "devboot on").unwrap();
|
||||
}
|
||||
"devbootoff" => {
|
||||
env.gam.set_devboot(false).unwrap();
|
||||
write!(ret, "devboot off").unwrap();
|
||||
}
|
||||
_ => {
|
||||
() // do nothing
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Ok(Some(ret))
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue