src/mess/machine/3c505.c
| r14956 | r14957 | |
| 180 | 180 | //------------------------------------------------- |
| 181 | 181 | |
| 182 | 182 | threecom3c505_device::threecom3c505_device(const machine_config &mconfig, const char *tag, device_t *owner, UINT32 clock) |
| 183 | | : device_t(mconfig, THREECOM3C505, "Threecom 3C505", tag, owner, clock) |
| 183 | : device_t(mconfig, THREECOM3C505, "Threecom 3C505", tag, owner, clock), |
| 184 | device_network_interface(mconfig, *this, 10.0f) |
| 184 | 185 | { |
| 185 | 186 | memset(static_cast<threecom3c505_interface *>(this), 0, sizeof(threecom3c505_interface)); |
| 186 | 187 | } |
| r14956 | r14957 | |
| 246 | 247 | memset(m_station_address, 0 , sizeof(m_station_address)); |
| 247 | 248 | memset(m_multicast_list, 0 , sizeof(m_multicast_list)); |
| 248 | 249 | set_filter_list(); |
| 250 | set_promisc(true); |
| 249 | 251 | } |
| 250 | 252 | |
| 251 | 253 | /*************************************************************************** |
| r14956 | r14957 | |
| 775 | 777 | memcpy(m_station_address, m_command_buffer+2 , m_command_buffer[1]); |
| 776 | 778 | } |
| 777 | 779 | set_filter_list(); |
| 780 | set_mac((char *)m_station_address); |
| 778 | 781 | break; |
| 779 | 782 | |
| 780 | 783 | case CMD_CONFIGURE_82586: // 0x02 |
| r14956 | r14957 | |
| 829 | 832 | } |
| 830 | 833 | |
| 831 | 834 | /*************************************************************************** |
| 832 | | threecom3c505_receive - receive and process an ethernet packet |
| 835 | recv_cb - receive callback - receive and process an ethernet packet |
| 833 | 836 | ***************************************************************************/ |
| 834 | 837 | |
| 835 | | int threecom3c505_device::threecom3c505_receive(const UINT8 data[], int length) |
| 838 | void threecom3c505_device::recv_cb(UINT8 *data, int length) |
| 836 | 839 | { |
| 837 | 840 | if (length < ETHERNET_ADDR_SIZE || !ethernet_packet_is_for_me(data)) |
| 838 | 841 | { |
| 839 | 842 | // skip packet |
| 840 | | return 0; |
| 841 | 843 | } |
| 842 | 844 | // else if (m_command_pending && m_command_buffer[0] == CMD_MC_F9) |
| 843 | 845 | // { |
| 844 | | // LOG(("threecom3c505_receive: data_length=%x !!!! skipped data while CMD_MC_F9 is pending!", length)); |
| 845 | | // return 0; |
| 846 | // LOG(("recv_cb: data_length=%x !!!! skipped data while CMD_MC_F9 is pending!", length)); |
| 846 | 847 | // } |
| 847 | 848 | else if (!m_rx_fifo.put(data, length)) |
| 848 | 849 | { |
| 849 | 850 | // fifo overrun |
| 850 | | LOG1(("threecom3c505_receive: data_length=%x !!! RX FIFO OVERRUN !!!", length)); |
| 851 | | return 0; |
| 851 | LOG1(("recv_cb: data_length=%x !!! RX FIFO OVERRUN !!!", length)); |
| 852 | 852 | } |
| 853 | 853 | else |
| 854 | 854 | { |
| 855 | | LOG1(("threecom3c505_receive: data_length=%x m_rx_pending=%d", length, m_rx_pending)); |
| 855 | LOG1(("recv_cb: data_length=%x m_rx_pending=%d", length, m_rx_pending)); |
| 856 | 856 | |
| 857 | 857 | if (m_rx_data_buffer.get_length() == 0) |
| 858 | 858 | { |
| r14956 | r14957 | |
| 877 | 877 | // { |
| 878 | 878 | // m_status |= ACRF; /* adapter command register full */ |
| 879 | 879 | // |
| 880 | | // LOG(("threecom3c505_receive - set_interrupt(%d)",ASSERT_LINE)); |
| 880 | // LOG(("recv_cb - set_interrupt(%d)",ASSERT_LINE)); |
| 881 | 881 | // set_interrupt(ASSERT_LINE); |
| 882 | 882 | // } |
| 883 | } |
| 884 | } |
| 883 | 885 | |
| 884 | | return 1; |
| 886 | bool threecom3c505_device::mcast_chk(const UINT8 *buf, int len) { |
| 887 | int i; |
| 888 | for (i = 0; i + ETHERNET_ADDR_SIZE < sizeof(m_multicast_list); i += ETHERNET_ADDR_SIZE) |
| 889 | { |
| 890 | if (memcmp(buf, m_multicast_list + i, ETHERNET_ADDR_SIZE) == 0) |
| 891 | { |
| 892 | LOG2(("threecom3c505_device::mcast_chk: true (len=%d)", len)); |
| 893 | return true; |
| 894 | } |
| 885 | 895 | } |
| 896 | return false; |
| 886 | 897 | } |
| 887 | 898 | |
| 888 | 899 | void threecom3c505_device::write_command_port( UINT8 data) |
| r14956 | r14957 | |
| 1025 | 1036 | |
| 1026 | 1037 | case CMD_TRANSMIT_PACKET_COMPLETE: |
| 1027 | 1038 | case CMD_TRANSMIT_PACKET_18_COMPLETE: |
| 1039 | if(!send(m_tx_data_buffer.get_data(), m_tx_data_buffer.get_length())) |
| 1040 | { |
| 1041 | // FIXME: failed to send the ethernet packet |
| 1042 | LOG(("read_command_port(): failed to send ethernet packet")); |
| 1043 | } |
| 1044 | |
| 1028 | 1045 | if (tx_data != NULL && // |
| 1029 | 1046 | (*tx_data)(this, m_tx_data_buffer.get_data(), m_tx_data_buffer.get_length()) == 0) |
| 1030 | 1047 | { |
| r14956 | r14957 | |
| 1378 | 1395 | |
| 1379 | 1396 | int threecom3c505_receive(device_t *device, const UINT8 data[], int length) |
| 1380 | 1397 | { |
| 1381 | | return downcast<threecom3c505_device *> (device)->threecom3c505_receive(data,length); |
| 1398 | downcast<threecom3c505_device *> (device)->recv_cb((UINT8 *)data,length); |
| 1399 | return 1; |
| 1382 | 1400 | } |
| 1383 | 1401 | |
| 1384 | 1402 | void threecom3c505_set_verbose(int on_off) |
src/mess/machine/3c505.h
| r14956 | r14957 | |
| 151 | 151 | |
| 152 | 152 | // ======================> threecom3c505_device |
| 153 | 153 | |
| 154 | | class threecom3c505_device: public device_t, public threecom3c505_interface |
| 154 | class threecom3c505_device: public device_t, |
| 155 | public device_network_interface, |
| 156 | public threecom3c505_interface |
| 155 | 157 | { |
| 156 | 158 | public: |
| 157 | 159 | // construction/destruction |
| r14956 | r14957 | |
| 160 | 162 | // static configuration helpers |
| 161 | 163 | static void static_set_interface(device_t &device, const threecom3c505_interface &interface); |
| 162 | 164 | |
| 163 | | int threecom3c505_receive(const UINT8 data[], int length); |
| 165 | void recv_cb(UINT8 *buf, int len); |
| 166 | bool mcast_chk(const UINT8 *buf, int len); |
| 167 | |
| 164 | 168 | // device register I/O |
| 165 | 169 | UINT8 read_port(offs_t offset); |
| 166 | 170 | void write_port(offs_t offset, UINT8 data); |