Previous 199869 Revisions Next

r26371 Saturday 23rd November, 2013 at 08:38:37 UTC by Jürgen Buchmüller
Rename "duckbreath", a term that was coined in the Stanford code, to the more appropriate "breath_of_life".
[/branches/alto2/src/emu/cpu/alto2]a2ether.c a2ether.h alto2cpu.c

branches/alto2/src/emu/cpu/alto2/a2ether.c
r26370r26371
164164#define   BF(a49)   ((a49 & ether_a49_BF) ? 1 : 0)      //! buffer full
165165
166166#define   BREATHLEN   ALTO2_ETHER_PACKET_SIZE   //!< ethernet packet length
167#define   BREATHADDR   0177400               //!< destination and source
168#define   BREATHTYPE   0000602               //!< ethernet packet type
169static const UINT16 duckbreath_data[BREATHLEN] =
167#define   BREATHADDR   (0377<<8)            //!< destination (0377) and source (0000)
168#define   BREATHTYPE   0602               //!< ethernet packet type
169static const UINT16 breath_of_life_data[BREATHLEN] =
170170{
171171   BREATHADDR,      /* 3MB destination and source */
172172   BREATHTYPE,      /* ether packet type  */
r26370r26371
211211#if   DEBUG_PACKETS
212212static void dump_ascii(const UINT16 *src, size_t size)
213213{
214   printf(" [");
214   logerror(" [");
215215   for (size_t offs = 0; offs < size; offs++) {
216216      char ch1 = src[offs] / 256;
217217      char ch2 = src[offs] % 256;
218      printf("%c", ch1 < 32 || ch1 > 126 ? '.' : ch1);
219      printf("%c", ch2 < 32 || ch2 > 126 ? '.' : ch2);
218      logerror("%c", ch1 < 32 || ch1 > 126 ? '.' : ch1);
219      logerror("%c", ch2 < 32 || ch2 > 126 ? '.' : ch2);
220220   }
221   printf("]\n");
221   logerror("]\n");
222222}
223223
224size_t dump_packet(const UINT16 *src, size_t addr, size_t size)
224static void dump_packet(const char* name, const UINT16 *src, size_t addr, size_t size)
225225{
226226   size_t offs;
227227   for (offs = 0; offs < size; offs++) {
228228      UINT16 word = src[offs];
229229      if (offs % 8) {
230         printf(" %06o", word);
230         logerror(" %06o", word);
231231      } else {
232232         if (offs > 0)
233233            dump_ascii(&src[offs-8], 8);
234         printf("\t%05o: %06o", static_cast<unsigned>(addr + offs), word);
234         logerror("%s\t%05o: %06o", name, static_cast<unsigned>(addr + offs), word);
235235      }
236236   }
237237   if (offs % 8) {
r26370r26371
239239   } else if (offs > 0) {
240240      dump_ascii(&src[offs - 8], 8);
241241   }
242   return size;
243242}
244243#endif
245244
r26370r26371
448447}
449448
450449/**
451 * @brief HACK: pull the next word from the duckbreath_data in the fifo
450 * @brief HACK: pull the next word from the breath_of_life_data in the fifo
452451 *
453452 * This is probably lacking the updates to one or more of
454453 * the status flip flops.
455454 */
456void alto2_cpu_device::rx_duckbreath(void* ptr, INT32 arg)
455void alto2_cpu_device::rx_breath_of_life(void* ptr, INT32 arg)
457456{
458457   UINT32 data;
459458
r26370r26371
469468      arg++;
470469   } else {
471470      // next data word
472      data = duckbreath_data[arg++];
471      data = breath_of_life_data[arg++];
473472   }
474473   m_eth.rx_crc = f9401_7(m_eth.rx_crc, data);
475474   m_eth.fifo[m_eth.fifo_wr] = data;
r26370r26371
489488       */
490489      m_eth.rx_crc = 0;
491490      PUT_ETH_IGONE(m_eth.status, 1);      // set the IGONE flip flop
492      m_eth.rx_timer->adjust(attotime::from_seconds(m_duckbreath_sec), 0);
491      m_eth.rx_timer->adjust(attotime::from_seconds(m_eth.breath_of_life), 0);
493492   } else {
494493      // receive at a rate of 5.44us per word
495494      m_eth.rx_timer->adjust(attotime::from_usec(5.44), arg);
r26370r26371
564563      m_eth.rx_packet[m_eth.rx_count] = r;
565564   m_eth.rx_count++;
566565   if (ALTO2_ETHER_PACKET_SIZE == m_eth.rx_count) {
567      dump_packet(m_eth.rx_packet, 0, m_eth.rx_count);
566      dump_packet("RX", m_eth.rx_packet, 0, m_eth.rx_count);
568567      m_eth.rx_count = 0;
569568   }
570569#endif
r26370r26371
666665      m_eth.tx_packet[m_eth.tx_count] = m_bus;
667666   m_eth.tx_count++;
668667   if (ALTO2_ETHER_PACKET_SIZE == m_eth.tx_count) {
669      dump_packet(m_eth.tx_packet, 0, m_eth.tx_count);
668      dump_packet("TX", m_eth.tx_packet, 0, m_eth.tx_count);
670669      m_eth.tx_count = 0;
671670   }
672671#endif
r26370r26371
831830   m_eth.tx_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(alto2_cpu_device::tx_packet),this));
832831   m_eth.tx_timer->reset();
833832
834   m_eth.rx_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(alto2_cpu_device::rx_duckbreath),this));
835   if (m_eth.duckbreath)
836      m_eth.rx_timer->adjust(attotime::from_seconds(m_eth.duckbreath), 0);
833   m_eth.rx_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(alto2_cpu_device::rx_breath_of_life),this));
834   if (m_eth.breath_of_life)
835      m_eth.rx_timer->adjust(attotime::from_seconds(m_eth.breath_of_life), 0);
837836   else
838837      m_eth.rx_timer->reset();
839838}
r26370r26371
843842   // nothing to do yet
844843}
845844
846//! delay between two duckbreaths in seconds
847static const int duckbreath_sec[8] = {
845//! delay between two breath_of_lifes in seconds
846static const int breath_of_life_sec[8] = {
848847   0, 5, 10, 15, 30, 60, 90, 120
849848};
850849void alto2_cpu_device::reset_ether()
r26370r26371
862861   ioport_port* config = ioport(":CONFIG");
863862   // config should be valid, unless the driver doesn't define it
864863   if (config)
865      m_eth.duckbreath = duckbreath_sec[(config->read() >> 4) & 7];
864      m_eth.breath_of_life = breath_of_life_sec[(config->read() >> 4) & 7];
866865   else
867      m_eth.duckbreath = 0;
868   logerror("Ethernet duckbreath %d sec\n", m_eth.duckbreath);
866      m_eth.breath_of_life = 0;
867   logerror("Ethernet breath_of_life %d sec\n", m_eth.breath_of_life);
869868}
branches/alto2/src/emu/cpu/alto2/a2ether.h
r26370r26371
4949   ether_a49_BF   = (1 << 3)               //!< buffer full
5050};
5151
52static const int m_duckbreath_sec = 15;         //!< send duckbreath every 15 seconds
53
5452struct {
5553   UINT16 fifo[ALTO2_ETHER_FIFO_SIZE];         //!< FIFO buffer
5654   UINT16 fifo_rd;                        //!< FIFO input pointer
r26370r26371
6462   UINT16* tx_packet;                     //!< buffer to collect transmitted words
6563   emu_timer* rx_timer;                  //!< receiver timer
6664   emu_timer* tx_timer;                  //!< transmitter timer
67   int duckbreath;                        //!< if non-zero, interval in seconds at which to broadcast the duckbreath
65   int breath_of_life;                     //!< if non-zero, interval in seconds at which to broadcast the breath-of-life
6866}   m_eth;
6967
70TIMER_CALLBACK_MEMBER( rx_duckbreath );         //!< HACK: pull the next word from the duckbreath in the fifo
68TIMER_CALLBACK_MEMBER( rx_breath_of_life );      //!< HACK: pull the next word from the breath-of-life in the fifo
7169TIMER_CALLBACK_MEMBER( tx_packet );            //!< transmit data from the FIFO to <nirvana for now>
7270void eth_wakeup();                        //!< check for the various reasons to wakeup the Ethernet task
7371void eth_startf();                        //!< start input or output depending on m_bus
branches/alto2/src/emu/cpu/alto2/alto2cpu.c
r26370r26371
966966   save_item(NAME(m_eth.tx_crc));
967967   save_item(NAME(m_eth.rx_count));
968968   save_item(NAME(m_eth.tx_count));
969   save_item(NAME(m_eth.duckbreath));
969   save_item(NAME(m_eth.breath_of_life));
970970
971971   state_add( A2_TASK,    "TASK",    m_task).callimport().formatstr("%6s");
972972   state_add( A2_MPC,     "MPC",     m_mpc).formatstr("%06O");

Previous 199869 Revisions Next


© 1997-2024 The MAME Team