mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-18 08:52:45 +00:00
refactor: utra -> utralib naming
this cleans up some namespace issues when including the utra crate which also refers to utra::generated::utra, and there are CONST at the crate-level, and also functions at the module-level which need disambiguation. By naming the crate utra-lib this saves a bit of syntatic wrangling at the top of every file.
This commit is contained in:
parent
cb6fcb60e8
commit
9a50de8b4e
16 changed files with 24 additions and 19 deletions
6
Cargo.lock
generated
6
Cargo.lock
generated
|
|
@ -213,7 +213,7 @@ version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"embedded-graphics",
|
"embedded-graphics",
|
||||||
"minifb",
|
"minifb",
|
||||||
"utra",
|
"utralib",
|
||||||
"xous",
|
"xous",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -720,7 +720,7 @@ version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"graphics-server",
|
"graphics-server",
|
||||||
"utra",
|
"utralib",
|
||||||
"xous",
|
"xous",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -824,7 +824,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
|
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "utra"
|
name = "utralib"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"svd2utra",
|
"svd2utra",
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ xous = { path = "../../xous-rs" }
|
||||||
embedded-graphics = "0.6"
|
embedded-graphics = "0.6"
|
||||||
|
|
||||||
[target.'cfg(not(any(windows,unix)))'.dependencies]
|
[target.'cfg(not(any(windows,unix)))'.dependencies]
|
||||||
utra = { path = "../../utra"}
|
utralib = { path = "../../utralib"}
|
||||||
|
|
||||||
[target.'cfg(any(windows,unix))'.dependencies]
|
[target.'cfg(any(windows,unix))'.dependencies]
|
||||||
minifb = "0.17"
|
minifb = "0.17"
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
use embedded_graphics::{drawable::Pixel, geometry::Size, pixelcolor::BinaryColor, DrawTarget};
|
use embedded_graphics::{drawable::Pixel, geometry::Size, pixelcolor::BinaryColor, DrawTarget};
|
||||||
use xous::MemoryRange;
|
use xous::MemoryRange;
|
||||||
use utra;
|
use utralib::generated::*;
|
||||||
|
|
||||||
const FB_WIDTH_WORDS: usize = 11;
|
const FB_WIDTH_WORDS: usize = 11;
|
||||||
const FB_WIDTH_PIXELS: usize = 336;
|
const FB_WIDTH_PIXELS: usize = 336;
|
||||||
|
|
@ -20,7 +20,7 @@ pub struct XousDisplay {
|
||||||
impl XousDisplay {
|
impl XousDisplay {
|
||||||
pub fn new() -> XousDisplay {
|
pub fn new() -> XousDisplay {
|
||||||
let fb = xous::syscall::map_memory(
|
let fb = xous::syscall::map_memory(
|
||||||
xous::MemoryAddress::new(utra::HW_MEMLCD_MEM),
|
xous::MemoryAddress::new(HW_MEMLCD_MEM),
|
||||||
None,
|
None,
|
||||||
((FB_WIDTH_WORDS * FB_LINES * 4) + 4096) & !4095,
|
((FB_WIDTH_WORDS * FB_LINES * 4) + 4096) & !4095,
|
||||||
xous::MemoryFlags::R | xous::MemoryFlags::W,
|
xous::MemoryFlags::R | xous::MemoryFlags::W,
|
||||||
|
|
@ -28,7 +28,7 @@ impl XousDisplay {
|
||||||
.expect("couldn't map frame buffer");
|
.expect("couldn't map frame buffer");
|
||||||
|
|
||||||
let control = xous::syscall::map_memory(
|
let control = xous::syscall::map_memory(
|
||||||
xous::MemoryAddress::new(utra::HW_MEMLCD_BASE),
|
xous::MemoryAddress::new(HW_MEMLCD_BASE),
|
||||||
None,
|
None,
|
||||||
4096,
|
4096,
|
||||||
xous::MemoryFlags::R | xous::MemoryFlags::W,
|
xous::MemoryFlags::R | xous::MemoryFlags::W,
|
||||||
|
|
|
||||||
|
|
@ -11,4 +11,4 @@ xous = { path = "../../xous-rs" }
|
||||||
graphics-server = { path = "../graphics-server" }
|
graphics-server = { path = "../graphics-server" }
|
||||||
|
|
||||||
[target.'cfg(not(any(windows,unix)))'.dependencies]
|
[target.'cfg(not(any(windows,unix)))'.dependencies]
|
||||||
utra = { path = "../../utra"}
|
utralib = { path = "../../utralib"}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,8 @@ mod timer;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
extern crate utralib;
|
||||||
|
|
||||||
fn move_lfsr(mut lfsr: u32) -> u32 {
|
fn move_lfsr(mut lfsr: u32) -> u32 {
|
||||||
lfsr ^= lfsr >> 7;
|
lfsr ^= lfsr >> 7;
|
||||||
lfsr ^= lfsr << 9;
|
lfsr ^= lfsr << 9;
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@ const SYSTEM_CLOCK_FREQUENCY: u32 = 100_000_000;
|
||||||
#[cfg(baremetal)]
|
#[cfg(baremetal)]
|
||||||
const TIMER_BASE: usize = 0xF000_3000;
|
const TIMER_BASE: usize = 0xF000_3000;
|
||||||
|
|
||||||
|
use utralib::generated::*;
|
||||||
|
|
||||||
#[cfg(baremetal)]
|
#[cfg(baremetal)]
|
||||||
fn timer_tick(_irq_no: usize, _arg: *mut usize) {
|
fn timer_tick(_irq_no: usize, _arg: *mut usize) {
|
||||||
println!(">>> Timer tick");
|
println!(">>> Timer tick");
|
||||||
|
|
@ -21,7 +23,7 @@ pub fn init() {
|
||||||
use xous::{MemoryAddress, MemorySize};
|
use xous::{MemoryAddress, MemorySize};
|
||||||
println!("Allocating timer...");
|
println!("Allocating timer...");
|
||||||
xous::rsyscall(xous::SysCall::MapMemory(
|
xous::rsyscall(xous::SysCall::MapMemory(
|
||||||
MemoryAddress::new(utra::HW_TIMER0_BASE),
|
MemoryAddress::new(HW_TIMER0_BASE),
|
||||||
MemoryAddress::new(TIMER_BASE),
|
MemoryAddress::new(TIMER_BASE),
|
||||||
MemorySize::new(4096).unwrap(),
|
MemorySize::new(4096).unwrap(),
|
||||||
xous::MemoryFlags::R | xous::MemoryFlags::W,
|
xous::MemoryFlags::R | xous::MemoryFlags::W,
|
||||||
|
|
@ -42,8 +44,8 @@ pub fn init() {
|
||||||
en(true);
|
en(true);
|
||||||
|
|
||||||
// Set EV_ENABLE
|
// Set EV_ENABLE
|
||||||
let ptr = TIMER_BASE as *mut usize;
|
let mut timer = CSR::new(TIMER_BASE as *mut u32);
|
||||||
unsafe { ptr.add(7).write_volatile(1) };
|
unsafe { timer.wfo(utra::timer0::EV_ENABLE_ENABLE, 0b1); }
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(baremetal))]
|
#[cfg(not(baremetal))]
|
||||||
|
|
|
||||||
4
kernel/Cargo.lock
generated
4
kernel/Cargo.lock
generated
|
|
@ -218,7 +218,7 @@ dependencies = [
|
||||||
"riscv",
|
"riscv",
|
||||||
"sha3",
|
"sha3",
|
||||||
"stats_alloc",
|
"stats_alloc",
|
||||||
"utra",
|
"utralib",
|
||||||
"xous",
|
"xous",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
@ -458,7 +458,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
|
checksum = "f7fe0bb3479651439c9112f72b6c505038574c9fbb575ed1bf3b797fa39dd564"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "utra"
|
name = "utralib"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"svd2utra",
|
"svd2utra",
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ stats_alloc = { version = "0.1.8", optional = true }
|
||||||
sha3 = { default-features = false, version = "0.8.2" }
|
sha3 = { default-features = false, version = "0.8.2" }
|
||||||
|
|
||||||
[target.'cfg(not(any(windows, unix)))'.dependencies]
|
[target.'cfg(not(any(windows, unix)))'.dependencies]
|
||||||
utra = { path = "../utra"}
|
utralib = { path = "../utralib"}
|
||||||
|
|
||||||
[target.'cfg(target_arch = "riscv32")'.dependencies]
|
[target.'cfg(target_arch = "riscv32")'.dependencies]
|
||||||
riscv = "0.5.6"
|
riscv = "0.5.6"
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ mod syscall;
|
||||||
|
|
||||||
use services::SystemServices;
|
use services::SystemServices;
|
||||||
use xous_kernel::*;
|
use xous_kernel::*;
|
||||||
|
use utralib::generated::*;
|
||||||
|
|
||||||
#[cfg(baremetal)]
|
#[cfg(baremetal)]
|
||||||
use core::panic::PanicInfo;
|
use core::panic::PanicInfo;
|
||||||
|
|
@ -64,7 +65,7 @@ pub extern "C" fn init(arg_offset: *const u32, init_offset: *const u32, rpt_offs
|
||||||
mem::MemoryManager::with_mut(|memory_manager| {
|
mem::MemoryManager::with_mut(|memory_manager| {
|
||||||
memory_manager
|
memory_manager
|
||||||
.map_range(
|
.map_range(
|
||||||
utra::HW_UART_BASE as *mut u8,
|
HW_UART_BASE as *mut u8,
|
||||||
((debug::SUPERVISOR_UART.base as u32) & !4095) as *mut u8,
|
((debug::SUPERVISOR_UART.base as u32) & !4095) as *mut u8,
|
||||||
4096,
|
4096,
|
||||||
PID::new(1).unwrap(),
|
PID::new(1).unwrap(),
|
||||||
|
|
|
||||||
|
|
@ -588,7 +588,7 @@ fn print_peripherals<U: Write>(peripherals: &[Peripheral], out: &mut U) -> std::
|
||||||
for peripheral in peripherals {
|
for peripheral in peripherals {
|
||||||
writeln!(
|
writeln!(
|
||||||
out,
|
out,
|
||||||
"pub const HW_{}_BASE : usize = {};",
|
"pub const HW_{}_BASE : usize = 0x{:08x};",
|
||||||
peripheral.name.to_uppercase(), peripheral.base
|
peripheral.name.to_uppercase(), peripheral.base
|
||||||
)?;
|
)?;
|
||||||
}
|
}
|
||||||
|
|
@ -606,7 +606,7 @@ fn print_peripherals<U: Write>(peripherals: &[Peripheral], out: &mut U) -> std::
|
||||||
writeln!(
|
writeln!(
|
||||||
out,
|
out,
|
||||||
" pub const {}: crate::Register = crate::Register::new({});",
|
" pub const {}: crate::Register = crate::Register::new({});",
|
||||||
register.name.to_uppercase(), register.offset
|
register.name.to_uppercase(), register.offset / 4
|
||||||
)?;
|
)?;
|
||||||
for field in ®ister.fields {
|
for field in ®ister.fields {
|
||||||
writeln!(
|
writeln!(
|
||||||
|
|
|
||||||
0
utra/.gitignore → utralib/.gitignore
vendored
0
utra/.gitignore → utralib/.gitignore
vendored
0
utra/Cargo.lock → utralib/Cargo.lock
generated
0
utra/Cargo.lock → utralib/Cargo.lock
generated
|
|
@ -1,5 +1,5 @@
|
||||||
[package]
|
[package]
|
||||||
name = "utra"
|
name = "utralib"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Sean Cross <sean@xobs.io>"]
|
authors = ["Sean Cross <sean@xobs.io>"]
|
||||||
edition = "2018"
|
edition = "2018"
|
||||||
|
|
@ -1,3 +1,3 @@
|
||||||
#![cfg_attr(target_os = "none", no_std)]
|
#![cfg_attr(target_os = "none", no_std)]
|
||||||
mod generated;
|
pub mod generated;
|
||||||
pub use generated::*;
|
pub use generated::*;
|
||||||
Loading…
Reference in a new issue