Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

devcon: Log reset/enable events #20

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions clicky-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ async-channel = "1.4"
blocking = "0.5"
futures-executor = { version = "0.3", features = ["thread-pool"] } # TEMP
pin-utils = "0.1"

# enum
strum = "0.17.1"
strum_macros = "0.17.1"

[dependencies.futures]
version = "0.3"
default-features = false
Expand Down
57 changes: 55 additions & 2 deletions clicky-core/src/devices/platform/pp/devcon.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,23 @@
use crate::devices::prelude::*;
use strum::IntoEnumIterator;
use strum_macros::EnumIter;

#[derive(Debug, Copy, Clone, EnumIter)]
pub enum DevIdentifier {
EXTCLOCKS = 1,
SYS = 2,
USB0 = 3,
SER0 = 6,
SER1 = 7,
I2S = 11,
I2C = 12,
ATA = 14,
OPTO = 16,
USB1 = 22,
FIREWIRE = 23,
IDE0 = 25,
LCD = 26,
}

/// PP5020 Device Controller.
#[derive(Debug)]
Expand Down Expand Up @@ -26,6 +45,8 @@ impl DevCon {
mystery: [0; 1],
}
}


}

impl Device for DevCon {
Expand Down Expand Up @@ -73,9 +94,41 @@ impl Memory for DevCon {

fn w32(&mut self, offset: u32, val: u32) -> MemResult<()> {
match offset {
0x04 => Err(StubWrite(Error, self.reset[0] = val)),
0x04 => Err(StubWrite(Error, {
let mut rising_edges = !self.reset[0] & val;
for device in DevIdentifier::iter() {
if rising_edges.get_bit(device as usize) {
println!("{:?} got reset", device);
rising_edges.set_bit(device as usize, false);
}
}
if rising_edges != 0 {
for i in 0..31 {
if rising_edges.get_bit(i) {
println!("Unknown device being reset (bit pos {})", i);
}
}
}
self.reset[0] = val;
})),
0x08 => Err(StubWrite(Error, self.reset[1] = val)),
0x0c => Err(StubWrite(Info, self.enable[0] = val)),
0x0c => Err(StubWrite(Info, {
let mut rising_edges = !self.enable[0] & val;
for device in DevIdentifier::iter() {
if rising_edges.get_bit(device as usize) {
println!("{:?} got enabled", device);
rising_edges.set_bit(device as usize, false);
}
}
if rising_edges != 0 {
for i in 0..31 {
if rising_edges.get_bit(i) {
println!("Unknown device being enabled (bit pos {})", i);
}
}
}
self.enable[0] = val;
})),
0x10 => Err(StubWrite(Info, self.enable[1] = val)),
0x20 => Err(StubWrite(Trace, self.clock_source = val)),
0x34 => Err(StubWrite(Trace, self.pll_control = val)),
Expand Down
Loading