SatCat5
satcat5::ublaze::TemacAvb Class Reference

Detailed Description

Xilinx TEMAC with Audio-Video-Bridge (AVB) functionality.

This class is a child of ublaze::Temac that provides additional hooks used for the IEEE1588 Precision Time Protocol (PTP).

Definition at line 53 of file temac.h.

#include <temac.h>

Inheritance diagram for satcat5::ublaze::TemacAvb:
[legend]
Collaboration diagram for satcat5::ublaze::TemacAvb:
[legend]

Public Member Functions

 TemacAvb (uintptr_t baseaddr, int irq_idx)
 Initialize the core and link to specified instance.
 
void set_tx_callback (TemacAvbTxCallback *tx_callback)
 Register callbacks for transmitted timestamps for PTP packets.
 
satcat5::ublaze::TemacTime avb_get_time ()
 Read current time from the AVB internal timer.
 
void avb_set_rate (u32 incr)
 Update AVB rate register. More...
 
void avb_jump_by (const satcat5::ublaze::TemacTime &delta)
 One-time increment of the AVB internal timer. More...
 
void send_frame (const u8 *buf, unsigned buflen)
 Send an arbitrary PTP frame with Ethernet header.
 
void set_callback (satcat5::io::EventListener *callback) override
 Update registered callback for data_rcvd() events. More...
 
unsigned get_read_ready () const override
 How many bytes can be read without blocking? More...
 
bool read_bytes (unsigned nbytes, void *dst) override
 Read 0 or more bytes into a buffer. More...
 
bool read_consume (unsigned nbytes) override
 Read and discard 0 or more bytes. More...
 
void read_finalize () override
 Consume any remaining bytes in this frame, if applicable. More...
 
u8 read_u8 ()
 One of many functions for reading integer/floating point values, see details. More...
 
unsigned read_str (unsigned dst_size, char *dst)
 Safely read a null-terminated input string. More...
 
template<class T >
bool read_obj (T &t)
 Templated wrapper for any object with the following method: bool read_from(satcat5::io::Readable* rd);
 
unsigned copy_to (satcat5::io::Writeable *dst)
 Copy data to a Writeable object, without finalizing. More...
 
bool copy_and_finalize (satcat5::io::Writeable *dst, satcat5::io::CopyMode mode=CopyMode::PACKET)
 Copy data to a Writeable object, then finalize. More...
 
void request_poll ()
 Call this method to request polling at a later time. More...
 
void request_cancel ()
 Call this method to cancel a previous request_poll().
 
s64 get_rate () const
 Read the current clock-tuning parameter. More...
 
satcat5::ptp::Time clock_adjust (const satcat5::ptp::Time &amount) override
 Clock-adjustment API for ptp::TrackingClock. More...
 
void clock_rate (s64 offset) override
 Clock-adjustment API for ptp::TrackingClock. More...
 
satcat5::ptp::Time clock_now () override
 Clock-adjustment API for ptp::TrackingClock. More...
 

Static Public Member Functions

static unsigned count_ondemand ()
 Count queued objects of this type (i.e., non-idle).
 
static unsigned count_always ()
 Count active objects of this type.
 

Public Attributes

const char *const m_label
 Human-readable label, for debugging.
 
const int m_irq_idx
 IRQ index for this interrupt handler.
 

Static Public Attributes

static constexpr double CLOCK_SCALE = 0.125 / (1u << 20)
 Scaling factor for use with avb_set_rate.
 

Protected Member Functions

u8 read_next () override
 Read the next byte from the underlying buffer or device. More...
 
void read_underflow () override
 Optional error handling for read underflow. More...
 
void read_src (satcat5::io::Readable *src)
 Children may reset the source object as needed.
 
void read_notify ()
 Attempt notification by calling m_callback->data_rcvd(). More...
 
void poll_register ()
 Register this pollable object, called by the constructor.
 
void poll_unregister ()
 Unregister this pollable object, called by the destructor.
 

Protected Attributes

volatile u32 *const m_regs
 
u32 m_max_irqtime
 Statistics tracking for time consumed by this interrupt.
 
s64 m_offset
 

Private Member Functions

void irq_event () override
 Method called whenever an interrupt is triggered.
 
void poll_always () override
 Child class MUST override this method. More...
 
void check_frames_waiting ()
 
void poll_demand ()
 Event handler for on-demand polling.
 

Private Attributes

satcat5::io::PacketBuffer m_txbuff
 
satcat5::io::PacketBuffer m_rxbuff
 
TemacAvbTxCallbackm_tx_callback
 
u32 m_prev_buf_idx
 
u8 m_frames_waiting
 
u8 m_txrawbuff [2048]
 
u8 m_rxrawbuff [2048]
 
satcat5::io::Readablem_src
 
satcat5::io::EventListenerm_callback
 Pointer to the callback object, or NULL. More...
 
satcat5::poll::OnDemandm_next
 
bool m_idle
 

Member Function Documentation

◆ avb_jump_by()

void TemacAvb::avb_jump_by ( const satcat5::ublaze::TemacTime delta)

One-time increment of the AVB internal timer.

TODO: This may be deprecated in favor of clock_adjust(...)

Definition at line 113 of file temac.cc.

◆ avb_set_rate()

void TemacAvb::avb_set_rate ( u32  incr)

Update AVB rate register.

Rate is a fixed-point integer with a resolution of 2^-20 nsec. (i.e., Set counter increment to N / 2^20 nanoseconds per clock.) TODO: This may be deprecated in favor of clock_rate(...)

Definition at line 106 of file temac.cc.

◆ clock_adjust()

Time TemacAvb::clock_adjust ( const satcat5::ptp::Time amount)
overridevirtual

Clock-adjustment API for ptp::TrackingClock.

Note: Recommend use of ptp::TrackingDither, due to the limited resolution of the rate register.

Implements satcat5::ptp::TrackingClock.

Definition at line 121 of file temac.cc.

◆ clock_now()

Time TemacAvb::clock_now ( )
overridevirtual

Clock-adjustment API for ptp::TrackingClock.

Note: Recommend use of ptp::TrackingDither, due to the limited resolution of the rate register.

Implements satcat5::ptp::TrackingClock.

Definition at line 144 of file temac.cc.

◆ clock_rate()

void TemacAvb::clock_rate ( s64  offset)
overridevirtual

Clock-adjustment API for ptp::TrackingClock.

Note: Recommend use of ptp::TrackingDither, due to the limited resolution of the rate register.

Implements satcat5::ptp::TrackingClock.

Definition at line 132 of file temac.cc.

◆ copy_and_finalize()

bool Readable::copy_and_finalize ( satcat5::io::Writeable dst,
satcat5::io::CopyMode  mode = CopyMode::PACKET 
)
inherited

Copy data to a Writeable object, then finalize.

As copy_to(), but also calls read_finalize() and/or write_finalize() depending on the input/output mode.

In packet mode (the default), call both read_finalize() and write_finalize() if the operation copies all available data. Use this mode whenever the input is packetized.

In byte-stream mode, call write_finalize() if the operation copies any data, but never call read_finalize(). Use this mode for inputs that do not delimit packet boundaries.

Parameters
dstThe destination object.
modeSelect packet mode or stream mode.
Returns
True if the output was finalized successfully.

Definition at line 234 of file io_readable.cc.

◆ copy_to()

unsigned Readable::copy_to ( satcat5::io::Writeable dst)
inherited

Copy data to a Writeable object, without finalizing.

Copy the contents of this Readable to a Writeable object, stopping at end-of-input, end-of-frame, or the capacity of the destination buffer (whichever comes first). This method does not call read_finalize or write_finalize(). To automatically make finalize calls,

See also
copy_and_finalize.
Returns
The number of bytes copied.

Definition at line 214 of file io_readable.cc.

◆ get_rate()

s64 satcat5::ptp::TrackingClock::get_rate ( ) const
inlineinherited

Read the current clock-tuning parameter.

Returns
The most recent value passed to "clock_rate", above.

Definition at line 70 of file ptp_tracking.h.

◆ get_read_ready()

unsigned ReadableRedirect::get_read_ready ( ) const
overridevirtualinherited

How many bytes can be read without blocking?

Child objects of io::Readable MUST override this method.

Implements satcat5::io::Readable.

Definition at line 336 of file io_readable.cc.

◆ poll_always()

void TemacAvb::poll_always ( )
overrideprivatevirtual

Child class MUST override this method.

(This method should rarely be called directly.)

Implements satcat5::poll::Always.

Definition at line 180 of file temac.cc.

◆ read_bytes()

bool ReadableRedirect::read_bytes ( unsigned  nbytes,
void *  dst 
)
overridevirtualinherited

Read 0 or more bytes into a buffer.

Child objects of io::Readable MAY override this method for improved performance.

Reimplemented from satcat5::io::Readable.

Definition at line 339 of file io_readable.cc.

◆ read_consume()

bool ReadableRedirect::read_consume ( unsigned  nbytes)
overridevirtualinherited

Read and discard 0 or more bytes.

Child objects of io::Readable MAY override this method for improved performance.

Reimplemented from satcat5::io::Readable.

Definition at line 342 of file io_readable.cc.

◆ read_finalize()

void ReadableRedirect::read_finalize ( )
overridevirtualinherited

Consume any remaining bytes in this frame, if applicable.

Child objects of io::Readable SHOULD override this method if they support framing.

Reimplemented from satcat5::io::Readable.

Definition at line 345 of file io_readable.cc.

◆ read_next()

u8 ReadableRedirect::read_next ( )
overrideprotectedvirtualinherited

Read the next byte from the underlying buffer or device.

Child objects of io::Readable MUST override this method.

Implements satcat5::io::Readable.

Definition at line 348 of file io_readable.cc.

◆ read_notify()

void Readable::read_notify ( )
protectedinherited

Attempt notification by calling m_callback->data_rcvd().

Child objects of io::Readable MAY call this to override default notifications.

Definition at line 254 of file io_readable.cc.

◆ read_str()

unsigned Readable::read_str ( unsigned  dst_size,
char *  dst 
)
inherited

Safely read a null-terminated input string.

The input is always consumed up to the end-of-input or the first zero byte, whichever comes first.

Returns
The length of the output string, which may be truncated as needed to fit in the provided buffer.

Definition at line 179 of file io_readable.cc.

◆ read_u8()

u8 Readable::read_u8 ( )
inherited

One of many functions for reading integer/floating point values, see details.

Several functions are provided for reading and writing scalar types to/from io::Readable and io::Writeable instances. Since there are many of these that are frequently inherited, they are hidden from documentation. These functions follow a shared template:

  • read_ or write_ prefix.
  • u for unsigned, s for signed, f for floating-point.
  • Data-type width in bits.
    • Available widths for ints: 8/16/24/32/48/64.
    • Available widths for floats: 32/64.
  • l suffix if little-endian, no suffix if big-endian.

Example: write_s48l is "Write 48 bits (6 bytes) to this io::Writeable as a signed value in little-endian order".

Definition at line 44 of file io_readable.cc.

◆ read_underflow()

void ReadableRedirect::read_underflow ( )
overrideprotectedvirtualinherited

Optional error handling for read underflow.

Child objects of io::Readable MAY override this method.

Reimplemented from satcat5::io::Readable.

Definition at line 351 of file io_readable.cc.

◆ request_poll()

void satcat5::poll::OnDemand::request_poll ( )
inherited

Call this method to request polling at a later time.

Safe to stack requests, but only one call to poll().

Definition at line 208 of file polling.cc.

◆ set_callback()

void ReadableRedirect::set_callback ( satcat5::io::EventListener callback)
overridevirtualinherited

Update registered callback for data_rcvd() events.

Child objects of io::Readable SHOULD usually leave this method as-is.

Reimplemented from satcat5::io::Readable.

Definition at line 331 of file io_readable.cc.

Member Data Documentation

◆ m_callback

satcat5::io::EventListener* satcat5::io::Readable::m_callback
privateinherited

Pointer to the callback object, or NULL.

This can only be modified through the set_callback(...) method.

Definition at line 199 of file io_readable.h.


The documentation for this class was generated from the following files: