|
SatCat5
|
Driver for the internal "MailMap" Ethernet port.
This class interfaces with "port_axi_mailmap" through ConfigBus. It can be used to send and receive Ethernet frames.
Unlike the byte-at-a-time MailBox interface, the MailMap makes the entire transmit/receive buffer available for direct access, as if they were a regular array. For now, this remains accessible through Writeable and Readable interfaces.
If PTP features are enabled on the gateware side, then this driver supports the ptp::Interface API for precision packet timestamps. (This requires CFG_CLK_HZ and VCONFIG to be set in the HDL.)
Definition at line 31 of file port_mailmap.h.
#include <port_mailmap.h>
Classes | |
| struct | ctrl_reg |
Public Member Functions | |
| Mailmap (satcat5::cfg::ConfigBusMmap *cfg, unsigned devaddr) | |
| Constructor links this driver to a ConfigBus address. | |
| unsigned | get_write_space () const override |
| How many bytes can be written without blocking? More... | |
| void | write_bytes (unsigned nbytes, const void *src) override |
| Write 0 or more bytes from a buffer. More... | |
| void | write_abort () override |
| If possible, abort the current partially-written packet. More... | |
| bool | write_finalize () override |
| Mark end of frame and release temporary working data. 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... | |
| void | read_finalize () override |
| Consume any remaining bytes in this frame, if applicable. More... | |
| satcat5::ptp::Time | ptp_time_now () override |
| Return the best available estimate of the current time. More... | |
| satcat5::ptp::Time | ptp_tx_start () override |
| Begin sending a timestamped message. More... | |
| satcat5::ptp::Time | ptp_tx_timestamp () override |
| Return timestamp of the most recent outgoing message. More... | |
| satcat5::ptp::Time | ptp_rx_timestamp () override |
| Return timestamp of the current incoming message. More... | |
| satcat5::io::Writeable * | ptp_tx_write () override |
| Return an object suitable for writing the next PTP frame. More... | |
| satcat5::io::Readable * | ptp_rx_read () override |
| Return an object suitable for reading the next PTP frame. More... | |
| satcat5::cfg::Register | ptp_clock_reg () const |
| Control register for creating a cfg::PtpRealtime object. More... | |
| virtual void | set_callback (satcat5::io::EventListener *callback) |
| Update registered callback for data_rcvd() events. More... | |
| u8 | read_u8 () |
| One of many functions for reading integer/floating point values, see details. More... | |
| virtual bool | read_consume (unsigned nbytes) |
| Read and discard 0 or more bytes. 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(). | |
| void | write_u8 (u8 data) |
| One of many functions for writing integer/floating point values, see details. More... | |
| void | write_str (const char *str) |
| Write the contents of a null-terminated string. More... | |
| template<class T > | |
| void | write_obj (const T &obj) |
Templated wrapper for any object with the following method: void write_to(satcat5::io::Writeable* wr) const; | |
| void | ptp_callback (satcat5::poll::OnDemand *obj) |
| Set callback object for PTP-related packet handling. | |
| satcat5::ptp::PacketType | ptp_rx_type () const |
| Return the packet type for the most recent message. | |
Static Public Member Functions | |
| static unsigned | count_ondemand () |
| Count queued objects of this type (i.e., non-idle). | |
Protected Member Functions | |
| void | write_next (u8 data) override |
| Write the next byte to the underlying buffer or device. More... | |
| void | write_overflow () override |
| Optional error handling for write overflow. More... | |
| void | read_underflow () override |
| Optional error handling for read underflow. More... | |
| u8 | read_next () override |
| Read the next byte from the underlying buffer or device. More... | |
| void | irq_event () override |
| Interrupt service routine. More... | |
| void | read_notify () |
Attempt notification by calling m_callback->data_rcvd(). More... | |
| bool | ptp_dispatch (const u8 *peek, unsigned length) |
| Determine if an incoming packet is a PTP message. More... | |
| void | ptp_notify_now () |
| Notify the PTP callback object in immediate mode. | |
| void | ptp_notify_req () |
| Notify the PTP callback object in deferred mode. | |
| void | irq_check () |
| Check if this interrupt may need service. More... | |
| void | irq_enable () |
| Enable this interrupt. More... | |
| void | irq_disable () |
| Temporarily disable this interrupt. More... | |
Protected Attributes | |
| ctrl_reg *const | m_ctrl |
| satcat5::cfg::Register | m_clock_reg |
| unsigned | m_wridx |
| unsigned | m_wrovr |
| unsigned | m_rdidx |
| unsigned | m_rdlen |
| unsigned | m_rdovr |
| friend | LimitedWrite |
| friend | WriteableBroadcast |
| friend | WriteableRedirect |
Private Member Functions | |
| void | poll_demand () |
| Event handler for on-demand polling. | |
Private Attributes | |
| satcat5::io::EventListener * | m_callback |
| Pointer to the callback object, or NULL. More... | |
| satcat5::poll::OnDemand * | m_next |
| bool | m_idle |
| satcat5::poll::OnDemand * | m_ptp_callback |
| satcat5::ptp::PacketType | m_ptp_rx_type |
| satcat5::cfg::ConfigBus *const | m_cfg |
|
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.
| dst | The destination object. |
| mode | Select packet mode or stream mode. |
Definition at line 234 of file io_readable.cc.
|
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,
Definition at line 214 of file io_readable.cc.
|
overridevirtual |
How many bytes can be read without blocking?
Child objects of io::Readable MUST override this method.
Implements satcat5::io::Readable.
Definition at line 104 of file port_mailmap.cc.
|
overridevirtual |
How many bytes can be written without blocking?
Child objects of io::Writeable MUST override this method.
Implements satcat5::io::Writeable.
Definition at line 55 of file port_mailmap.cc.
|
inherited |
Check if this interrupt may need service.
If the interrupt needs service, this calls irq_event.
Definition at line 46 of file cfgbus_interrupt.cc.
|
inherited |
Temporarily disable this interrupt.
Interrupts are enabled by default, but some peripherals may wish to temporary toggle this setting. For use with standard "cfgbus_interrupt" only.
Definition at line 63 of file cfgbus_interrupt.cc.
|
inherited |
Enable this interrupt.
Interrupts are enabled by default, but some peripherals may wish to temporary toggle this setting. For use with standard "cfgbus_interrupt" only.
Definition at line 58 of file cfgbus_interrupt.cc.
|
overrideprotectedvirtual |
Interrupt service routine.
(Child class must override this method.)
Implements satcat5::cfg::Interrupt.
Definition at line 145 of file port_mailmap.cc.
|
inline |
Control register for creating a cfg::PtpRealtime object.
(Requires CFG_CLK_HZ and VCONFIG to be set in the HDL.)
Definition at line 61 of file port_mailmap.h.
|
protectedinherited |
Determine if an incoming packet is a PTP message.
Child class MUST call this method for each received packet. If this method returns true, call ptp_notify_now() or ptp_notify_req(). Otherwise, continue normal processing.
Definition at line 18 of file ptp_interface.cc.
|
overridevirtual |
Return an object suitable for reading the next PTP frame.
(This may be the primary interface or a separate pointer.) Child class MUST override this method.
Implements satcat5::ptp::Interface.
Definition at line 195 of file port_mailmap.cc.
|
overridevirtual |
Return timestamp of the current incoming message.
Child class MUST override this method.
Implements satcat5::ptp::Interface.
Definition at line 183 of file port_mailmap.cc.
|
overridevirtual |
Return the best available estimate of the current time.
(This method may be less accurate than Tx and Rx timestamps.)
Implements satcat5::ptp::Interface.
Definition at line 157 of file port_mailmap.cc.
|
overridevirtual |
Begin sending a timestamped message.
Return effective one-step timestamp if known, otherwise zero. Child class MUST override this method.
Implements satcat5::ptp::Interface.
Definition at line 166 of file port_mailmap.cc.
|
overridevirtual |
Return timestamp of the most recent outgoing message.
Child class MUST override this method.
Implements satcat5::ptp::Interface.
Definition at line 175 of file port_mailmap.cc.
|
overridevirtual |
Return an object suitable for writing the next PTP frame.
(This may be the primary interface or a separate pointer.) Child class MUST override this method.
Implements satcat5::ptp::Interface.
Definition at line 191 of file port_mailmap.cc.
|
overridevirtual |
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.
Reimplemented in satcat5::port::MailmapAligned.
Definition at line 114 of file port_mailmap.cc.
|
virtualinherited |
Read and discard 0 or more bytes.
Child objects of io::Readable MAY override this method for improved performance.
Reimplemented in satcat5::io::PacketBuffer, satcat5::io::MultiPacket::Reader, satcat5::io::ReadableRedirect, satcat5::io::LimitedRead, and satcat5::io::FileReader.
Definition at line 204 of file io_readable.cc.
|
overridevirtual |
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 127 of file port_mailmap.cc.
|
overrideprotectedvirtual |
Read the next byte from the underlying buffer or device.
Child objects of io::Readable MUST override this method.
Implements satcat5::io::Readable.
Reimplemented in satcat5::port::MailmapAligned.
Definition at line 141 of file port_mailmap.cc.
|
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.
|
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.
Definition at line 179 of file io_readable.cc.
|
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.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.
|
overrideprotectedvirtual |
Optional error handling for read underflow.
Child objects of io::Readable MAY override this method.
Reimplemented from satcat5::io::Readable.
Definition at line 100 of file port_mailmap.cc.
|
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.
|
virtualinherited |
Update registered callback for data_rcvd() events.
Child objects of io::Readable SHOULD usually leave this method as-is.
Reimplemented in satcat5::io::ReadableRedirect, satcat5::io::Override, satcat5::io::MuxPort, and satcat5::test::EthernetInterface.
Definition at line 39 of file io_readable.cc.
|
overridevirtual |
If possible, abort the current partially-written packet.
Child objects of io::Writeable SHOULD override this method if it is practical to prevent in-progress data from being relayed downstream.
Reimplemented from satcat5::io::Writeable.
Definition at line 79 of file port_mailmap.cc.
|
overridevirtual |
Write 0 or more bytes from a buffer.
Child objects of io::Writeable MAY override write_bytes as needed for performance.
Reimplemented from satcat5::io::Writeable.
Reimplemented in satcat5::port::MailmapAligned.
Definition at line 65 of file port_mailmap.cc.
|
overridevirtual |
Mark end of frame and release temporary working data.
Child objects of io::Writeable SHOULD override this method to mark frame bounds.
Reimplemented from satcat5::io::Writeable.
Definition at line 85 of file port_mailmap.cc.
|
overrideprotectedvirtual |
Write the next byte to the underlying buffer or device.
Child objects of io::Writeable MUST override this method.
Implements satcat5::io::Writeable.
Reimplemented in satcat5::port::MailmapAligned.
Definition at line 137 of file port_mailmap.cc.
|
overrideprotectedvirtual |
Optional error handling for write overflow.
Child objects of io::Writeable MAY override this method for error handling.
Reimplemented from satcat5::io::Writeable.
Definition at line 74 of file port_mailmap.cc.
|
inherited |
Write the contents of a null-terminated string.
Note: Null-termination is not copied to the output.
Definition at line 180 of file io_writeable.cc.
|
inherited |
One of many functions for writing 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.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 20 of file io_writeable.cc.
|
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.