Strip non-MACRAW enums, unused macros, and set_socket_dest_mac

This commit is contained in:
Ian Gulliver
2026-04-10 21:42:20 +09:00
parent 394628b8da
commit 0d41f63533
3 changed files with 0 additions and 45 deletions

View File

@@ -29,8 +29,6 @@ static ResponseTest test_discovery() {
ResponseTest resp; ResponseTest resp;
resp.pass = true; resp.pass = true;
w6300::set_socket_dest_mac(test_socket, picomap_discovery_mac);
auto req = encode_request(0, RequestInfo{}); auto req = encode_request(0, RequestInfo{});
auto send_result = w6300::send(test_socket, std::span<const uint8_t>{req}); auto send_result = w6300::send(test_socket, std::span<const uint8_t>{req});
if (!send_result) { if (!send_result) {

View File

@@ -272,7 +272,6 @@ constexpr uint32_t REG_SN_CR(uint8_t n) { return (0x0010 << 8) + SREG_BLOCK
constexpr uint32_t REG_SN_IR(uint8_t n) { return (0x0020 << 8) + SREG_BLOCK(n); } constexpr uint32_t REG_SN_IR(uint8_t n) { return (0x0020 << 8) + SREG_BLOCK(n); }
constexpr uint32_t REG_SN_IRCLR(uint8_t n) { return (0x0028 << 8) + SREG_BLOCK(n); } constexpr uint32_t REG_SN_IRCLR(uint8_t n) { return (0x0028 << 8) + SREG_BLOCK(n); }
constexpr uint32_t REG_SN_SR(uint8_t n) { return (0x0030 << 8) + SREG_BLOCK(n); } constexpr uint32_t REG_SN_SR(uint8_t n) { return (0x0030 << 8) + SREG_BLOCK(n); }
constexpr uint32_t REG_SN_DHAR(uint8_t n) { return (0x0118 << 8) + SREG_BLOCK(n); }
constexpr uint32_t REG_SN_MR2(uint8_t n) { return (0x0144 << 8) + SREG_BLOCK(n); } constexpr uint32_t REG_SN_MR2(uint8_t n) { return (0x0144 << 8) + SREG_BLOCK(n); }
constexpr uint32_t REG_SN_TX_BSR(uint8_t n) { return (0x0200 << 8) + SREG_BLOCK(n); } constexpr uint32_t REG_SN_TX_BSR(uint8_t n) { return (0x0200 << 8) + SREG_BLOCK(n); }
constexpr uint32_t REG_SN_TX_FSR(uint8_t n) { return (0x0204 << 8) + SREG_BLOCK(n); } constexpr uint32_t REG_SN_TX_FSR(uint8_t n) { return (0x0204 << 8) + SREG_BLOCK(n); }
@@ -339,7 +338,6 @@ uint8_t get_sn_ir(uint8_t sn) { return reg_read(REG_SN_IR(sn)); }
void set_sn_irclr(uint8_t sn, uint8_t v) { reg_write(REG_SN_IRCLR(sn), v); } void set_sn_irclr(uint8_t sn, uint8_t v) { reg_write(REG_SN_IRCLR(sn), v); }
void set_sn_ir(uint8_t sn, uint8_t v) { set_sn_irclr(sn, v); } void set_sn_ir(uint8_t sn, uint8_t v) { set_sn_irclr(sn, v); }
uint8_t get_sn_sr(uint8_t sn) { return reg_read(REG_SN_SR(sn)); } uint8_t get_sn_sr(uint8_t sn) { return reg_read(REG_SN_SR(sn)); }
void set_sn_dhar(uint8_t sn, uint8_t* v) { reg_write_buf(REG_SN_DHAR(sn), v, 6); }
void set_sn_mr2(uint8_t sn, uint8_t v) { reg_write(REG_SN_MR2(sn), v); } void set_sn_mr2(uint8_t sn, uint8_t v) { reg_write(REG_SN_MR2(sn), v); }
void set_sn_tx_bsr(uint8_t sn, uint8_t v) { reg_write(REG_SN_TX_BSR(sn), v); } void set_sn_tx_bsr(uint8_t sn, uint8_t v) { reg_write(REG_SN_TX_BSR(sn), v); }
void set_sn_txbuf_size(uint8_t sn, uint8_t v) { set_sn_tx_bsr(sn, v); } void set_sn_txbuf_size(uint8_t sn, uint8_t v) { set_sn_tx_bsr(sn, v); }
@@ -475,9 +473,7 @@ uint8_t sock_pack_info[sock_count] = {0,};
#define FAIL(e) return std::unexpected(sock_error::e) #define FAIL(e) return std::unexpected(sock_error::e)
#define CHECK_SOCKNUM() do { if(sn >= sock_count) FAIL(sock_num); } while(0) #define CHECK_SOCKNUM() do { if(sn >= sock_count) FAIL(sock_num); } while(0)
#define CHECK_SOCKMODE(mode) do { if((get_sn_mr(sn) & 0x0F) != mode) FAIL(sock_mode); } while(0)
#define CHECK_SOCKDATA() do { if(len == 0) FAIL(data_len); } while(0) #define CHECK_SOCKDATA() do { if(len == 0) FAIL(data_len); } while(0)
#define CHECK_IPZERO(addr, addrlen) do { uint16_t ipzero=0; for(uint8_t i=0; i<addrlen; i++) ipzero += (uint16_t)addr[i]; if(ipzero == 0) FAIL(ip_invalid); } while(0)
std::expected<void, sock_error> close(socket_id sid) { std::expected<void, sock_error> close(socket_id sid) {
uint8_t sn = static_cast<uint8_t>(sid); uint8_t sn = static_cast<uint8_t>(sid);
@@ -522,7 +518,6 @@ std::expected<socket_id, sock_error> open_socket(socket_id sid, protocol proto,
set_sn_cr(sn, SN_CR_OPEN); set_sn_cr(sn, SN_CR_OPEN);
while (get_sn_cr(sn)); while (get_sn_cr(sn));
sock_io_mode_bits &= ~(1 << sn); sock_io_mode_bits &= ~(1 << sn);
sock_io_mode_bits |= ((fl & (static_cast<uint8_t>(sock_flag::io_nonblock) >> 3)) << sn);
sock_is_sending &= ~(1 << sn); sock_is_sending &= ~(1 << sn);
sock_remained_size[sn] = 0; sock_remained_size[sn] = 0;
sock_pack_info[sn] = PACK_COMPLETED; sock_pack_info[sn] = PACK_COMPLETED;
@@ -650,9 +645,6 @@ std::expected<void, sock_error> set_socket_io_mode(socket_id sid, sock_io_mode m
return {}; return {};
} }
void set_socket_dest_mac(socket_id sid, const std::array<uint8_t, 6>& mac) {
set_sn_dhar(static_cast<uint8_t>(sid), const_cast<uint8_t*>(mac.data()));
}
uint16_t get_socket_recv_buf(socket_id sid) { uint16_t get_socket_recv_buf(socket_id sid) {
return get_sn_rx_rsr(static_cast<uint8_t>(sid)); return get_sn_rx_rsr(static_cast<uint8_t>(sid));

View File

@@ -13,55 +13,21 @@ enum class socket_id : uint8_t {};
enum class sock_error : int16_t { enum class sock_error : int16_t {
busy = 0, busy = 0,
sock_num = -1, sock_num = -1,
sock_opt = -2,
sock_init = -3,
sock_closed = -4, sock_closed = -4,
sock_mode = -5, sock_mode = -5,
sock_flag = -6,
sock_status = -7,
arg = -10, arg = -10,
port_zero = -11,
ip_invalid = -12,
timeout = -13, timeout = -13,
data_len = -14, data_len = -14,
buffer = -15,
fatal_packlen = -1001, fatal_packlen = -1001,
}; };
enum class protocol : uint8_t { enum class protocol : uint8_t {
tcp = 0x01,
udp = 0x02,
ipraw = 0x03,
macraw = 0x07, macraw = 0x07,
tcp6 = 0x09,
udp6 = 0x0A,
ipraw6 = 0x0B,
tcp_dual = 0x0D,
udp_dual = 0x0E,
}; };
enum class sock_flag : uint8_t { enum class sock_flag : uint8_t {
none = 0, none = 0,
multi_enable = 1 << 7,
ether_own = 1 << 7,
broad_block = 1 << 6,
tcp_fpsh = 1 << 6,
tcp_nodelay = 1 << 5,
igmp_ver2 = 1 << 5,
solicit_block = 1 << 5,
ether_multi4b = 1 << 5,
uni_block = 1 << 4,
ether_multi6b = 1 << 4,
force_arp = 1 << 0,
dha_manual = 1 << 1,
io_nonblock = 1 << 3,
}; };
constexpr sock_flag operator|(sock_flag a, sock_flag b) {
return static_cast<sock_flag>(static_cast<uint8_t>(a) | static_cast<uint8_t>(b));
}
constexpr uint8_t operator&(sock_flag a, sock_flag b) {
return static_cast<uint8_t>(a) & static_cast<uint8_t>(b);
}
enum class sock_io_mode : uint8_t { enum class sock_io_mode : uint8_t {
block = 0, block = 0,
@@ -93,7 +59,6 @@ std::expected<uint16_t, sock_error> send(socket_id sn, std::span<const uint8_t>
std::expected<uint16_t, sock_error> recv(socket_id sn, std::span<uint8_t> buf); std::expected<uint16_t, sock_error> recv(socket_id sn, std::span<uint8_t> buf);
std::expected<void, sock_error> set_socket_io_mode(socket_id sn, sock_io_mode mode); std::expected<void, sock_error> set_socket_io_mode(socket_id sn, sock_io_mode mode);
void set_socket_dest_mac(socket_id sn, const std::array<uint8_t, 6>& mac);
uint16_t get_socket_recv_buf(socket_id sn); uint16_t get_socket_recv_buf(socket_id sn);
} // namespace w6300 } // namespace w6300