Previous 15994 Revisions Next

r14957 Wednesday 18th April, 2012 at 02:20:00 UTC by R. Belmont
3c505: Switched to using core device_network_interface [Hans Ostermeyer]
[src/mess/machine]3c505.c 3c505.h

src/mess/machine/3c505.c
r14956r14957
180180//-------------------------------------------------
181181
182182threecom3c505_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)
184185{
185186   memset(static_cast<threecom3c505_interface *>(this), 0, sizeof(threecom3c505_interface));
186187}
r14956r14957
246247   memset(m_station_address, 0 , sizeof(m_station_address));
247248   memset(m_multicast_list, 0 , sizeof(m_multicast_list));
248249   set_filter_list();
250   set_promisc(true);
249251}
250252
251253/***************************************************************************
r14956r14957
775777         memcpy(m_station_address, m_command_buffer+2 , m_command_buffer[1]);
776778      }
777779      set_filter_list();
780      set_mac((char *)m_station_address);
778781      break;
779782
780783   case CMD_CONFIGURE_82586: // 0x02
r14956r14957
829832}
830833
831834/***************************************************************************
832 threecom3c505_receive - receive and process an ethernet packet
835 recv_cb - receive callback - receive and process an ethernet packet
833836 ***************************************************************************/
834837
835int threecom3c505_device::threecom3c505_receive(const UINT8 data[], int length)
838void threecom3c505_device::recv_cb(UINT8 *data, int length)
836839{
837840   if (length < ETHERNET_ADDR_SIZE || !ethernet_packet_is_for_me(data))
838841   {
839842      // skip packet
840      return 0;
841843   }
842844//  else if (m_command_pending && m_command_buffer[0] == CMD_MC_F9)
843845//  {
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));
846847//  }
847848   else if (!m_rx_fifo.put(data, length))
848849   {
849850      // 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));
852852   }
853853   else
854854   {
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));
856856
857857      if (m_rx_data_buffer.get_length() == 0)
858858      {
r14956r14957
877877//      {
878878//          m_status |= ACRF; /* adapter command register full */
879879//
880//          LOG(("threecom3c505_receive - set_interrupt(%d)",ASSERT_LINE));
880//          LOG(("recv_cb - set_interrupt(%d)",ASSERT_LINE));
881881//          set_interrupt(ASSERT_LINE);
882882//      }
883   }
884}
883885
884      return 1;
886bool 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      }
885895   }
896   return  false;
886897}
887898
888899void threecom3c505_device::write_command_port( UINT8 data)
r14956r14957
10251036
10261037         case CMD_TRANSMIT_PACKET_COMPLETE:
10271038         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
10281045            if (tx_data != NULL && //
10291046               (*tx_data)(this, m_tx_data_buffer.get_data(), m_tx_data_buffer.get_length()) == 0)
10301047            {
r14956r14957
13781395
13791396int threecom3c505_receive(device_t *device, const UINT8 data[], int length)
13801397{
1381   return downcast<threecom3c505_device *> (device)->threecom3c505_receive(data,length);
1398    downcast<threecom3c505_device *> (device)->recv_cb((UINT8 *)data,length);
1399    return 1;
13821400}
13831401
13841402void threecom3c505_set_verbose(int on_off)
src/mess/machine/3c505.h
r14956r14957
151151
152152// ======================> threecom3c505_device
153153
154class threecom3c505_device:  public device_t, public threecom3c505_interface
154class threecom3c505_device:  public device_t,
155                 public device_network_interface,
156                 public threecom3c505_interface
155157{
156158public:
157159   // construction/destruction
r14956r14957
160162   // static configuration helpers
161163   static void static_set_interface(device_t &device, const threecom3c505_interface &interface);
162164
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
164168   // device register I/O
165169   UINT8 read_port(offs_t offset);
166170   void write_port(offs_t offset, UINT8 data);

Previous 15994 Revisions Next


© 1998-2018 The MESS Team