netlog.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334
  1. /* netlog: mirror kernel debug output (COM1) and terminal text to UDP, so a
  2. * serial-less board has a `make monitor` equivalent (`make netmon`).
  3. *
  4. * Producers (serial_putc / screen_putchar) only append to a RAM ring buffer;
  5. * the WM loop flushes complete lines (or after a short idle delay) as UDP
  6. * datagrams. Nothing is sent before the NIC is up, and nothing blocks the
  7. * producer. */
  8. #ifndef NETLOG_H
  9. #define NETLOG_H
  10. /* UDP port both the mirror and the `netlog` command use. */
  11. #define NETLOG_PORT 19290
  12. /* Enable the mirror and clear the buffer; call at boot (before the NIC is
  13. * initialized, so the driver's bring-up trail is captured). */
  14. void netlog_init(void);
  15. /* Producer: append one character. Cheap and safe from any context (IRQ,
  16. * boot, process); drops the character when the ring is full. */
  17. void netlog_char(char c);
  18. /* Consumer: send pending text as one datagram (call from the WM loop). */
  19. void netlog_flush(void);
  20. void netlog_set_enabled(int on);
  21. int netlog_get_enabled(void);
  22. /* Destination: all-0xFF (default) broadcasts; otherwise datagrams carry the
  23. * broadcast MAC and this IP, so no ARP cache is needed (the switch floods
  24. * them and the host with that address presents them to its sockets). */
  25. void netlog_set_host(const unsigned char ip[4]);
  26. void netlog_get_host(unsigned char ip[4]);
  27. #endif