Skip to content
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
1 change: 1 addition & 0 deletions Cargo.lock

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

17 changes: 17 additions & 0 deletions lib/ringbuf/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -639,6 +639,23 @@ where
}
}

#[cfg(feature = "counters")]
impl<T, C, const N: usize> CountedRingbuf<T, C, { N }>
where
T: Count + Copy,
{
/// Increment the counter for the provided variant of `T` in this
/// `CountedRingbuf`'s counters table, *without* isnerting it into the
/// ringbuffer itself.
///
/// This is intended to be used in situations where it is desirable to count
/// some events without consuming ring buffer slots without creating a
/// separate counters table.
pub fn count(&self, entry: &T) {
entry.count(&self.counters);
}
}

impl<T> RecordEntry<T> for ()
where
T: Copy + PartialEq,
Expand Down
5 changes: 3 additions & 2 deletions task/hiffy/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ drv-stm32xx-i2c = { path = "../../drv/stm32xx-i2c", optional = true }
drv-stm32xx-sys-api = { path = "../../drv/stm32xx-sys-api", optional = true }
task-net-api = { path = "../../task/net-api", optional = true }
hubris-num-tasks = { path = "../../sys/num-tasks", features = ["task-enum"] }
ringbuf = { path = "../../lib/ringbuf" }
counters = { path = "../../lib/counters", features = ["derive"] }
ringbuf = { path = "../../lib/ringbuf" }
static-cell = { path = "../../lib/static-cell" }
userlib = { path = "../../sys/userlib" }
test-api = { path = "../../test/test-api", optional = true}
Expand Down Expand Up @@ -55,7 +56,7 @@ h743 = ["stm32h7", "drv-stm32xx-i2c/h743", "build-i2c/h743"]
h753 = ["stm32h7", "drv-stm32xx-i2c/h753", "build-i2c/h753"]
g031 = ["stm32g0", "drv-stm32xx-i2c/g031", "build-i2c/g031"]
g030 = ["stm32g0", "drv-stm32xx-i2c/g030", "build-i2c/g030"]
micro = ["no-ipc-counters"]
micro = ["no-ipc-counters", "ringbuf/disabled"]
# enables large memory buffer to make data transfers through hiffy (e.g.
# `humility qspi` and such) not slow. this conflicts with the "micro" feature,
# which makes the buffer smaller for memory constrained-targets, and is off by
Expand Down
5 changes: 0 additions & 5 deletions task/hiffy/src/generic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,3 @@ pub(crate) static HIFFY_FUNCS: &[Function] = &[
crate::common::send_lease_write,
];

pub(crate) fn trace_execute(_offset: usize, _op: hif::Op) {}

pub(crate) fn trace_success() {}

pub(crate) fn trace_failure(_f: hif::Failure) {}
19 changes: 7 additions & 12 deletions task/hiffy/src/lpc55.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,20 @@
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at https://mozilla.org/MPL/2.0/.

use crate::Trace;
#[cfg(feature = "spi")]
use crate::common::{spi_read, spi_write};
use byteorder::ByteOrder;
use drv_lpc55_gpio_api::*;
use hif::*;
use hubris_num_tasks::Task;
use ringbuf::*;
use ringbuf::ringbuf_entry_root;
use userlib::*;

#[cfg(feature = "gpio")]
task_slot!(GPIO, gpio_driver);
#[cfg(feature = "spctrl")]
task_slot!(SP_CTRL, swd);

#[derive(Copy, Clone, PartialEq)]
enum Trace {
None,
Execute((usize, hif::Op)),
Failure(Failure),
Success,
}

ringbuf!(Trace, 64, Trace::None);

// TODO: this type is copy-pasted in several modules
pub struct Buffer(#[allow(dead_code)] u8);

Expand Down Expand Up @@ -246,6 +236,9 @@ fn gpio_configure(
let task = GPIO.get_task_id();
let gpio = drv_lpc55_gpio_api::Pins::from(task);

ringbuf_entry_root!(Trace::GpioConfigure(
pin, alt, mode, slew, invert, digimode, opendrain
));
gpio.iocon_configure(
pin, alt, mode, slew, invert, digimode, opendrain, None,
);
Expand Down Expand Up @@ -310,6 +303,8 @@ fn gpio_input(

let pin = gpio_args(stack)?;

ringbuf_entry_root!(Trace::GpioInput(pin));

let input = gpio.read_val(pin);

byteorder::LittleEndian::write_u16(rval, input as u16);
Expand Down
Loading
Loading