mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-16 08:38:26 +00:00
Merge branch 'swap-kernel' of github.com:betrusted-io/xous-core into swap-kernel
This commit is contained in:
commit
3bd6b8b645
4 changed files with 59 additions and 6 deletions
BIN
docs/images/modals_show_notification.png
Normal file
BIN
docs/images/modals_show_notification.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 38 KiB |
|
|
@ -196,7 +196,33 @@ impl Modals {
|
|||
}
|
||||
}
|
||||
|
||||
/// this blocks until the notification has been acknowledged.
|
||||
/// Text/QR code notification modal dialog.
|
||||
///
|
||||
/// - `qrtext` turns submitted text into a qr code.
|
||||
/// - This dialog blocks until the notification has been acknowledged via [ Press any key ].
|
||||
/// - Dialog does not scroll, burden is on the consumer to make sure text + qr code do not overflow
|
||||
/// available space.
|
||||
///
|
||||
/// <details>
|
||||
/// <summary>Example Image</summary>
|
||||
///
|
||||
/// 
|
||||
///
|
||||
/// </details>
|
||||
///
|
||||
/// # Examples
|
||||
/// ```
|
||||
/// use modals::Modals;
|
||||
/// use xous_names::XousNames;
|
||||
/// let xns = XousNames::new().unwrap();
|
||||
/// let modals = Modals::new(&xns).unwrap();
|
||||
/// modals
|
||||
/// .show_notification(
|
||||
/// "Check the wiki:",
|
||||
/// Some("https://github.com/betrusted-io/betrusted-wiki/wiki"),
|
||||
/// )
|
||||
/// .unwrap();
|
||||
/// ```
|
||||
pub fn show_notification(&self, notification: &str, qrtext: Option<&str>) -> Result<(), xous::Error> {
|
||||
self.lock();
|
||||
let qrtext = match qrtext {
|
||||
|
|
|
|||
|
|
@ -295,12 +295,17 @@ pub fn process_minielf(b: &[u8]) -> Result<MiniElf, ElfReadError> {
|
|||
// This keeps a running offset of where data is getting copied.
|
||||
let mut program_offset = 0;
|
||||
let mut section_iter = elf.section_iter().peekable();
|
||||
let mut init_offset = 0;
|
||||
while let Some(s) = section_iter.next() {
|
||||
let mut flags = MiniElfFlags::NONE;
|
||||
let name = s.get_name(&elf).unwrap_or("<<error>>");
|
||||
|
||||
if s.address() == 0 {
|
||||
debug!("(Skipping section {} -- invalid address)", name);
|
||||
// only extract the initial offset once per ELF file
|
||||
if init_offset == 0 {
|
||||
init_offset = if let Some(s) = section_iter.peek() { s.offset() } else { 0 };
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if alignment_offset == 0 {
|
||||
|
|
@ -308,8 +313,7 @@ pub fn process_minielf(b: &[u8]) -> Result<MiniElf, ElfReadError> {
|
|||
}
|
||||
|
||||
debug!("Section {}:", name);
|
||||
debug!("Official header:");
|
||||
debug!("{:?}", s);
|
||||
debug!("{} official header: {:x?}", name, s);
|
||||
debug!("Interpreted:");
|
||||
debug!(" flags: {:?}", s.flags());
|
||||
debug!(" type: {:?}", s.get_type());
|
||||
|
|
@ -354,9 +358,13 @@ pub fn process_minielf(b: &[u8]) -> Result<MiniElf, ElfReadError> {
|
|||
if s.get_type() != Ok(ShType::NoBits) {
|
||||
let section_data = s.raw_data(&elf);
|
||||
let pad_amount = if let Some(next_section) = section_iter.peek() {
|
||||
if section_data.len() % next_section.align() as usize != 0 {
|
||||
let pad_amount =
|
||||
next_section.align() as usize - (section_data.len() % next_section.align() as usize);
|
||||
if (section_data.len() + program_offset as usize + init_offset as usize)
|
||||
% next_section.align() as usize
|
||||
!= 0
|
||||
{
|
||||
let pad_amount = next_section.align() as usize
|
||||
- ((section_data.len() + program_offset as usize + init_offset as usize)
|
||||
% next_section.align() as usize);
|
||||
if s.address() + size + pad_amount as u64 > next_section.address() {
|
||||
(next_section.address() - (s.address() + size)) as usize
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use std::fmt;
|
||||
use std::io;
|
||||
|
||||
use crate::elf::MiniElfFlags;
|
||||
use crate::elf::MiniElfSection;
|
||||
use crate::xous_arguments::{XousArgument, XousArgumentCode, XousSize};
|
||||
|
||||
|
|
@ -74,11 +75,29 @@ impl XousArgument for IniF {
|
|||
let mut written = 0;
|
||||
written += output.write(&self.load_offset.to_le_bytes())?;
|
||||
written += output.write(&self.entrypoint.to_le_bytes())?;
|
||||
let mut flash_offset = self.load_offset;
|
||||
for section in &self.sections {
|
||||
log::debug!("section.virt: {:x} <> flash_offset: {:x}", section.virt, flash_offset);
|
||||
// Check that the padding fix worked
|
||||
if section.flags & MiniElfFlags::NOCOPY == MiniElfFlags::NONE {
|
||||
// Only modestly informative panic, because we're deep in a serialize
|
||||
// routine and we don't have metadata about the process or anything:
|
||||
// But if these offsets don't line up, it's definitely a problem.
|
||||
assert!(
|
||||
section.virt & 0xFFF == flash_offset & 0xFFF,
|
||||
"IniF page offsets must align: ({:x}){:x} <> ({:x}){:x} ({:x?})",
|
||||
section.virt >> 12,
|
||||
section.virt & 0xFFF,
|
||||
flash_offset >> 12,
|
||||
flash_offset & 0xFFF,
|
||||
section
|
||||
);
|
||||
}
|
||||
written += output.write(§ion.virt.to_le_bytes())?;
|
||||
let mut word2 = section.size.to_le_bytes();
|
||||
word2[3] = section.flags.bits();
|
||||
written += output.write(&word2)?;
|
||||
flash_offset += section.size;
|
||||
}
|
||||
Ok(written)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue