mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-19 09:00:54 +00:00
services/keyboard: remove explicit early settings FLASH access
Use early_settings service.
This commit is contained in:
parent
e6d44795a1
commit
523ec0ac80
2 changed files with 14 additions and 28 deletions
|
|
@ -22,6 +22,7 @@ num-traits = {version = "0.2.14", default-features = false}
|
||||||
rkyv = {version = "0.4.3", default-features = false, features = ["const_generics"]}
|
rkyv = {version = "0.4.3", default-features = false, features = ["const_generics"]}
|
||||||
|
|
||||||
utralib = {version = "0.1.17", optional = true, default-features = false }
|
utralib = {version = "0.1.17", optional = true, default-features = false }
|
||||||
|
early_settings ={ path = "../early_settings"}
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
precursor = ["utralib/precursor"]
|
precursor = ["utralib/precursor"]
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@ mod implementation {
|
||||||
use num_traits::ToPrimitive;
|
use num_traits::ToPrimitive;
|
||||||
use susres::{RegManager, RegOrField, SuspendResume};
|
use susres::{RegManager, RegOrField, SuspendResume};
|
||||||
use std::collections::HashSet;
|
use std::collections::HashSet;
|
||||||
use std::convert::TryInto;
|
|
||||||
|
|
||||||
/// note: the code is structured to use at most 16 rows or 16 cols
|
/// note: the code is structured to use at most 16 rows or 16 cols
|
||||||
const KBD_ROWS: usize = 9;
|
const KBD_ROWS: usize = 9;
|
||||||
|
|
@ -69,10 +68,8 @@ mod implementation {
|
||||||
susres: RegManager::<{utra::keyboard::KEYBOARD_NUMREGS}>,
|
susres: RegManager::<{utra::keyboard::KEYBOARD_NUMREGS}>,
|
||||||
/// a field used for debugging various keyboard issues, especially with the interrupt handler
|
/// a field used for debugging various keyboard issues, especially with the interrupt handler
|
||||||
pub debug: usize,
|
pub debug: usize,
|
||||||
/// a slice that contains the location of the early-boot keyboard settings
|
/// access to settings stored in the first few sectors of FLASH
|
||||||
settings: xous::MemoryRange,
|
early_settings: early_settings::EarlySettings,
|
||||||
/// a handle to the spinor block so we can update our settings
|
|
||||||
spinor: spinor::Spinor,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn handle_kbd(_irq_no: usize, arg: *mut usize) {
|
fn handle_kbd(_irq_no: usize, arg: *mut usize) {
|
||||||
|
|
@ -139,17 +136,13 @@ mod implementation {
|
||||||
xous::MemoryFlags::R | xous::MemoryFlags::W,
|
xous::MemoryFlags::R | xous::MemoryFlags::W,
|
||||||
)
|
)
|
||||||
.expect("couldn't map Keyboard CSR range");
|
.expect("couldn't map Keyboard CSR range");
|
||||||
let setting_page = xous::syscall::map_memory(
|
|
||||||
xous::MemoryAddress::new((xous::EARLY_SETTINGS + xous::FLASH_PHYS_BASE) as usize),
|
|
||||||
None,
|
|
||||||
4096,
|
|
||||||
xous::MemoryFlags::R,
|
|
||||||
)
|
|
||||||
.expect("couldn't map Keyboard pre-boot setting");
|
|
||||||
|
|
||||||
let ticktimer = ticktimer_server::Ticktimer::new().expect("couldn't connect to ticktimer");
|
let ticktimer = ticktimer_server::Ticktimer::new().expect("couldn't connect to ticktimer");
|
||||||
let timestamp = ticktimer.elapsed_ms();
|
let timestamp = ticktimer.elapsed_ms();
|
||||||
let settings: &[u8] = setting_page.as_slice();
|
|
||||||
|
let xns = xous_names::XousNames::new().unwrap();
|
||||||
|
|
||||||
|
let ea = early_settings::EarlySettings::new(&xns).unwrap();
|
||||||
|
|
||||||
let default_map = if cfg!(feature = "braille") {
|
let default_map = if cfg!(feature = "braille") {
|
||||||
KeyMap::Braille
|
KeyMap::Braille
|
||||||
|
|
@ -160,10 +153,10 @@ mod implementation {
|
||||||
// unencrypted and plaintext bit of memory that anyone can read or mess with. The only reason the keyboard
|
// unencrypted and plaintext bit of memory that anyone can read or mess with. The only reason the keyboard
|
||||||
// layout is kept here is because you want your keyboard to be in the right language before typing in the
|
// layout is kept here is because you want your keyboard to be in the right language before typing in the
|
||||||
// password to unlock the PDDB, which is *actually* where all the user settings should be located.
|
// password to unlock the PDDB, which is *actually* where all the user settings should be located.
|
||||||
let code = u32::from_le_bytes(settings[..4].try_into().unwrap());
|
let kb_raw = ea.get_keymap().expect("cannot fetch keymap from early settings");
|
||||||
KeyMap::from(code as usize)
|
let map = KeyMap::from(kb_raw);
|
||||||
|
map
|
||||||
};
|
};
|
||||||
let xns = xous_names::XousNames::new().unwrap();
|
|
||||||
|
|
||||||
let mut kbd = Keyboard {
|
let mut kbd = Keyboard {
|
||||||
conn: xous::connect(sid).unwrap(),
|
conn: xous::connect(sid).unwrap(),
|
||||||
|
|
@ -187,8 +180,7 @@ mod implementation {
|
||||||
chord_captured: false,
|
chord_captured: false,
|
||||||
susres: RegManager::new(csr.as_mut_ptr() as *mut u32),
|
susres: RegManager::new(csr.as_mut_ptr() as *mut u32),
|
||||||
debug: 0,
|
debug: 0,
|
||||||
settings: setting_page,
|
early_settings: ea,
|
||||||
spinor: spinor::Spinor::new(&xns).unwrap(),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
xous::claim_interrupt(
|
xous::claim_interrupt(
|
||||||
|
|
@ -239,19 +231,12 @@ mod implementation {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn set_map(&mut self, map: KeyMap) {
|
pub(crate) fn set_map(&mut self, map: KeyMap) {
|
||||||
let code_usize: usize = map.into();
|
self.early_settings.set_keymap(map.into()).expect("cannot set early keymap");
|
||||||
let code = (code_usize as u32).to_le_bytes();
|
|
||||||
let settings: &[u8] = self.settings.as_slice();
|
|
||||||
self.spinor.patch(settings, xous::EARLY_SETTINGS,
|
|
||||||
&code, 0
|
|
||||||
).expect("couldn't patch our keyboard code");
|
|
||||||
self.map = map;
|
self.map = map;
|
||||||
}
|
}
|
||||||
pub(crate) fn get_map(&mut self) -> KeyMap {
|
pub(crate) fn get_map(&mut self) -> KeyMap {
|
||||||
// refresh the map from the setting in the FLASH
|
let kb_raw = self.early_settings.get_keymap().expect("cannot fetch early keymap");
|
||||||
let settings: &[u8] = self.settings.as_slice();
|
self.map = KeyMap::from(kb_raw);
|
||||||
let code = u32::from_le_bytes(settings[..4].try_into().unwrap());
|
|
||||||
self.map = KeyMap::from(code as usize);
|
|
||||||
self.map
|
self.map
|
||||||
}
|
}
|
||||||
pub(crate) fn set_repeat(&mut self, rate: u32, delay: u32) {
|
pub(crate) fn set_repeat(&mut self, rate: u32, delay: u32) {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue