Remove socket IO mode (nonblock unnecessary with pre-checked recv buffer)

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

View File

@@ -279,7 +279,6 @@ bool net_init() {
state.ip[3] = state.mac[5];
w6300::open_socket(raw_socket, w6300::protocol::macraw, w6300::sock_flag::none);
w6300::set_socket_io_mode(raw_socket, w6300::sock_io_mode::nonblock);
w6300::set_interrupt_mask(w6300::ik_sock_0);
return true;

View File

@@ -466,7 +466,6 @@ int8_t init_buffers(std::span<const uint8_t> txsize, std::span<const uint8_t> rx
return 0;
}
uint16_t sock_io_mode_bits = 0;
uint16_t sock_is_sending = 0;
uint16_t sock_remained_size[sock_count] = {0,};
uint8_t sock_pack_info[sock_count] = {0,};
@@ -481,7 +480,6 @@ std::expected<void, sock_error> close(socket_id sid) {
set_sn_cr(sn, SN_CR_CLOSE);
while (get_sn_cr(sn));
set_sn_ir(sn, 0xFF);
sock_io_mode_bits &= ~(1 << sn);
sock_is_sending &= ~(1 << sn);
sock_remained_size[sn] = 0;
sock_pack_info[sn] = PACK_NONE;
@@ -517,7 +515,6 @@ std::expected<socket_id, sock_error> open_socket(socket_id sid, protocol proto,
set_sn_mr2(sn, fl & 0x03);
set_sn_cr(sn, SN_CR_OPEN);
while (get_sn_cr(sn));
sock_io_mode_bits &= ~(1 << sn);
sock_is_sending &= ~(1 << sn);
sock_remained_size[sn] = 0;
sock_pack_info[sn] = PACK_COMPLETED;
@@ -538,7 +535,6 @@ std::expected<uint16_t, sock_error> send(socket_id sid, std::span<const uint8_t>
while (1) {
freesize = get_sn_tx_fsr(sn);
if (get_sn_sr(sn) == SOCK_CLOSED) FAIL(sock_closed);
if ((sock_io_mode_bits & (1 << sn)) && (len > freesize)) FAIL(busy);
if (len <= freesize) break;
};
send_data(sn, const_cast<uint8_t*>(buf.data()), len);
@@ -574,7 +570,6 @@ std::expected<uint16_t, sock_error> recv(socket_id sid, std::span<uint8_t> buf)
sock_pack_info[sn] = PACK_NONE;
break;
}
if (sock_io_mode_bits & (1 << sn)) FAIL(busy);
};
}
@@ -636,14 +631,6 @@ bool check() {
return get_cidr() == 0x6300;
}
std::expected<void, sock_error> set_socket_io_mode(socket_id sid, sock_io_mode mode) {
uint8_t sn = static_cast<uint8_t>(sid);
if (sn >= sock_count) FAIL(sock_num);
if (mode == sock_io_mode::nonblock) sock_io_mode_bits |= (1 << sn);
else if (mode == sock_io_mode::block) sock_io_mode_bits &= ~(1 << sn);
else FAIL(arg);
return {};
}
uint16_t get_socket_recv_buf(socket_id sid) {

View File

@@ -29,11 +29,6 @@ enum class sock_flag : uint8_t {
none = 0,
};
enum class sock_io_mode : uint8_t {
block = 0,
nonblock = 1,
};
enum intr_kind : uint32_t {
ik_pppoe_terminated = (1 << 0), ik_dest_unreach = (1 << 1), ik_ip_conflict = (1 << 2),
ik_dest_unreach6 = (1 << 4), ik_wol = (1 << 7), ik_net_all = 0x97,
@@ -58,7 +53,6 @@ std::expected<socket_id, sock_error> open_socket(socket_id sn, protocol proto, s
std::expected<uint16_t, sock_error> send(socket_id sn, std::span<const 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);
uint16_t get_socket_recv_buf(socket_id sn);
} // namespace w6300