From 191c5ae0cde0b753eaa6d4e9074ddab465933700 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Wed, 30 Oct 2024 01:44:34 -0600 Subject: Finish the W5500 driver? --- libhw/rp2040_include/libhw/w5500.h | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'libhw/rp2040_include') diff --git a/libhw/rp2040_include/libhw/w5500.h b/libhw/rp2040_include/libhw/w5500.h index 037d4f1..16f88cc 100644 --- a/libhw/rp2040_include/libhw/w5500.h +++ b/libhw/rp2040_include/libhw/w5500.h @@ -7,6 +7,8 @@ #ifndef _LIBHW_W5500_H_ #define _LIBHW_W5500_H_ +#include /* for bi_* */ + #include #include #include @@ -14,27 +16,27 @@ #include #include -struct _w5500_tcp_conn { - /* const-after-init */ - implements_net_stream_conn; - /* mutable */ - BEGIN_PRIVATE(LIBHW_W5500_H) - bool read_open; - bool write_open; - END_PRIVATE(LIBHW_W5500_H) -}; - -struct _w5500_tcp_listener { +struct _w5500_socket { /* const-after-init */ - implements_net_stream_listener; + implements_net_stream_listener implements_net_stream_listener; + implements_net_stream_conn implements_net_stream_conn; + implements_net_packet_conn implements_net_packet_conn; BEGIN_PRIVATE(LIBHW_W5500_H) uint8_t socknum; - struct _w5500_tcp_conn active_conn; /* mutable */ - uint16_t port; + enum { + W5500_MODE_NONE = 0, + W5500_MODE_TCP, + W5500_MODE_UDP, + } mode; + uint16_t port; /* MODE_{TCP,UDP} */ + uint64_t read_deadline_ns; /* MODE_{TCP,UDP} */ + cr_sema_t listen_sema; /* MODE_TCP */ + cr_sema_t read_sema; /* MODE_{TCP,UDP} */ + bool read_open, write_open; /* MODE_TCP */ + cr_mutex_t cmd_mu; - cr_sema_t listen_sema, read_sema; END_PRIVATE(LIBHW_W5500_H) }; @@ -48,7 +50,7 @@ struct w5500 { /* mutable */ uint16_t next_local_port; - struct _w5500_tcp_listener listeners[8]; + struct _w5500_socket sockets[8]; cr_sema_t intr; END_PRIVATE(LIBHW_W5500_H) }; -- cgit v1.2.3-2-g168b