mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-20 09:03:28 +00:00
format libs/xous-pl230
This commit is contained in:
parent
ee2c7ef140
commit
59c6d6ae77
3 changed files with 27 additions and 33 deletions
|
|
@ -8,22 +8,21 @@ pub struct Uart {
|
||||||
impl Uart {
|
impl Uart {
|
||||||
fn put_digit(&mut self, d: u8) {
|
fn put_digit(&mut self, d: u8) {
|
||||||
let nyb = d & 0xF;
|
let nyb = d & 0xF;
|
||||||
let c = if nyb < 10 {
|
let c = if nyb < 10 { nyb + 0x30 } else { nyb + 0x61 - 10 };
|
||||||
nyb + 0x30
|
|
||||||
} else {
|
|
||||||
nyb + 0x61 - 10
|
|
||||||
};
|
|
||||||
assert!(c >= 0x30, "conversion failed!");
|
assert!(c >= 0x30, "conversion failed!");
|
||||||
self.putc(c);
|
self.putc(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn put_hex(&mut self, c: u8) {
|
pub fn put_hex(&mut self, c: u8) {
|
||||||
self.put_digit(c >> 4);
|
self.put_digit(c >> 4);
|
||||||
self.put_digit(c & 0xF);
|
self.put_digit(c & 0xF);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn newline(&mut self) {
|
pub fn newline(&mut self) {
|
||||||
self.putc(0xa);
|
self.putc(0xa);
|
||||||
self.putc(0xd);
|
self.putc(0xd);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn print_hex_word(&mut self, word: u32) {
|
pub fn print_hex_word(&mut self, word: u32) {
|
||||||
for &byte in word.to_be_bytes().iter() {
|
for &byte in word.to_be_bytes().iter() {
|
||||||
self.put_hex(byte);
|
self.put_hex(byte);
|
||||||
|
|
@ -42,7 +41,6 @@ impl Uart {
|
||||||
self.putc(c);
|
self.putc(c);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
use core::fmt::{Error, Write};
|
use core::fmt::{Error, Write};
|
||||||
|
|
@ -74,9 +72,7 @@ mod debug_print_hardware {
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
#[allow(unused_variables)]
|
#[allow(unused_variables)]
|
||||||
macro_rules! print {
|
macro_rules! print {
|
||||||
($($args:tt)+) => ({
|
($($args:tt)+) => {{ () }};
|
||||||
()
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,13 +1,13 @@
|
||||||
#![cfg_attr(target_os = "none", no_std)]
|
#![cfg_attr(target_os = "none", no_std)]
|
||||||
|
|
||||||
#[cfg(not(any(target_os="xous")))]
|
#[cfg(not(any(target_os = "xous")))]
|
||||||
mod debug;
|
mod debug;
|
||||||
|
|
||||||
#[cfg(feature="tests")]
|
#[cfg(feature = "tests")]
|
||||||
pub mod pl230_tests;
|
pub mod pl230_tests;
|
||||||
|
|
||||||
use utralib::*;
|
|
||||||
use bitfield::bitfield;
|
use bitfield::bitfield;
|
||||||
|
use utralib::*;
|
||||||
|
|
||||||
#[repr(C, align(16))]
|
#[repr(C, align(16))]
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
|
|
@ -24,21 +24,21 @@ struct ControlChannels {
|
||||||
pub channels: [ChannelControl; 8],
|
pub channels: [ChannelControl; 8],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub struct Pl230 {
|
pub struct Pl230 {
|
||||||
pub csr: CSR<u32>,
|
pub csr: CSR<u32>,
|
||||||
pub mdma: CSR<u32>,
|
pub mdma: CSR<u32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Pl230 {
|
impl Pl230 {
|
||||||
#[cfg(not(any(target_os="xous")))]
|
#[cfg(not(any(target_os = "xous")))]
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Pl230 {
|
Pl230 {
|
||||||
csr: CSR::new(utralib::HW_PL230_BASE as *mut u32),
|
csr: CSR::new(utralib::HW_PL230_BASE as *mut u32),
|
||||||
mdma: CSR::new(utralib::HW_MDMA_BASE as *mut u32),
|
mdma: CSR::new(utralib::HW_MDMA_BASE as *mut u32),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#[cfg(target_os="xous")]
|
|
||||||
|
#[cfg(target_os = "xous")]
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
let csr = xous::syscall::map_memory(
|
let csr = xous::syscall::map_memory(
|
||||||
xous::MemoryAddress::new(utralib::HW_PL230_BASE),
|
xous::MemoryAddress::new(utralib::HW_PL230_BASE),
|
||||||
|
|
@ -47,18 +47,15 @@ impl Pl230 {
|
||||||
xous::MemoryFlags::R | xous::MemoryFlags::W,
|
xous::MemoryFlags::R | xous::MemoryFlags::W,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let mdma = xous::syscall::map_memory(
|
let mdma = xous::syscall::map_memory(
|
||||||
xous::MemoryAddress::new(utralib::HW_MDMA_BASE),
|
xous::MemoryAddress::new(utralib::HW_MDMA_BASE),
|
||||||
None,
|
None,
|
||||||
4096,
|
4096,
|
||||||
xous::MemoryFlags::R | xous::MemoryFlags::W,
|
xous::MemoryFlags::R | xous::MemoryFlags::W,
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
Pl230 {
|
Pl230 { csr: CSR::new(csr.as_mut_ptr() as *mut u32), mdma: CSR::new(mdma.as_mut_ptr() as *mut u32) }
|
||||||
csr: CSR::new(csr.as_mut_ptr() as *mut u32),
|
|
||||||
mdma: CSR::new(mdma.as_mut_ptr() as *mut u32),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -70,6 +67,7 @@ pub enum DmaWidth {
|
||||||
NoInc = 0b11,
|
NoInc = 0b11,
|
||||||
}
|
}
|
||||||
#[repr(u32)]
|
#[repr(u32)]
|
||||||
|
#[rustfmt::skip]
|
||||||
pub enum ArbitrateAfter {
|
pub enum ArbitrateAfter {
|
||||||
XferEach = 0b0000,
|
XferEach = 0b0000,
|
||||||
Xfer2 = 0b0001,
|
Xfer2 = 0b0001,
|
||||||
|
|
@ -88,11 +86,11 @@ pub enum DmaCycleControl {
|
||||||
Stop = 0b000,
|
Stop = 0b000,
|
||||||
Basic = 0b001,
|
Basic = 0b001,
|
||||||
AutoRequest = 0b010,
|
AutoRequest = 0b010,
|
||||||
PingPong = 0b011,
|
PingPong = 0b011,
|
||||||
MemoryScatterGatherPrimary = 0b100,
|
MemoryScatterGatherPrimary = 0b100,
|
||||||
MemoryScatterGatherAlt = 0b101,
|
MemoryScatterGatherAlt = 0b101,
|
||||||
PeripheralScatterGatherPrimary = 0b110,
|
PeripheralScatterGatherPrimary = 0b110,
|
||||||
PeripheralScatterGatherAlt = 0b111,
|
PeripheralScatterGatherAlt = 0b111,
|
||||||
}
|
}
|
||||||
|
|
||||||
bitfield! {
|
bitfield! {
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,19 @@
|
||||||
pub mod units;
|
pub mod units;
|
||||||
|
|
||||||
pub fn report_api(desc: &str, d: u32) {
|
pub fn report_api(desc: &str, d: u32) {
|
||||||
#[cfg(not(any(target_os="xous")))]
|
#[cfg(not(any(target_os = "xous")))]
|
||||||
{
|
{
|
||||||
use core::fmt::Write;
|
use core::fmt::Write;
|
||||||
let mut uart = crate::debug::Uart{};
|
let mut uart = crate::debug::Uart {};
|
||||||
writeln!(uart, "pl230: [{}] 0x{:x}", desc, d).ok();
|
writeln!(uart, "pl230: [{}] 0x{:x}", desc, d).ok();
|
||||||
}
|
}
|
||||||
#[cfg(target_os="xous")]
|
#[cfg(target_os = "xous")]
|
||||||
log::info!("pl230: [{}] 0x{:x}", desc, d);
|
log::info!("pl230: [{}] 0x{:x}", desc, d);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn pl230_tests() {
|
pub fn pl230_tests() {
|
||||||
let mut pl230 = crate::Pl230::new();
|
let mut pl230 = crate::Pl230::new();
|
||||||
units::basic_tests(&mut pl230);
|
units::basic_tests(&mut pl230);
|
||||||
#[cfg(feature="pio")]
|
#[cfg(feature = "pio")]
|
||||||
units::pio_test(&mut pl230);
|
units::pio_test(&mut pl230);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue