Previous 199869 Revisions Next

r26173 Friday 15th November, 2013 at 11:24:20 UTC by Jürgen Buchmüller
One bug squashed: wrong task_kwd instead of task_ksec when checking FF 22b
[/branches/alto2/src/emu/cpu/alto2]a2disk.c alto2.c
[/branches/alto2/src/emu/machine]diablo_hd.c

branches/alto2/src/emu/machine/diablo_hd.c
r26172r26173
103103{
104104}
105105
106/**
107 * @brief diablo_hd_device destructor
108 * Free all m_cache and m_bits pages and the arrays
109 */
106110diablo_hd_device::~diablo_hd_device()
107111{
108112   for (int page = 0; page < m_pages; page++) {
r26172r26173
121125   }
122126}
123127
124void diablo_hd_device::set_sector_callback(void *cookie, void (*callback)(void *, int))
125{
126   LOG_DRIVE((0,"[DHD] %s cookie=%p callback=%p\n", __FUNCTION__, cookie, callback));
127   m_sector_callback_cookie = cookie;
128   m_sector_callback = callback;
129}
130
131128#if   DIABLO_DEBUG
132129void diablo_hd_device::logprintf(int level, const char* format, ...)
133130{
r26172r26173
140137}
141138#endif
142139
140void diablo_hd_device::set_sector_callback(void *cookie, void (*callback)(void *, int))
141{
142   LOG_DRIVE((0,"[DHD] %s cookie=%p callback=%p\n", __FUNCTION__, cookie, callback));
143   m_sector_callback_cookie = cookie;
144   m_sector_callback = callback;
145}
146
143147#define   DIABLO31_ROTATION_TIME attotime::from_msec(39.9999)      //!< DIABLO 31 rotation time is approx. 40ms
144148#define   DIABLO31_SECTOR_TIME attotime::from_msec(39.9999/12)   //!< DIABLO 31 sector time
145149/**
r26172r26173
246250   UINT8 data[2*DIABLO_DATA_WORDS];      //!< sector data words
247251}   diablo_sector_t;
248252
249/** @brief write a bit into an array of UINT32 */
253/**
254 * @brief write a bit into an array of UINT32
255 * @param bits pointer to array of bits
256 * @param dst destination index
257 * @param bit bit value
258 * @return next destination index
259 */
250260static inline size_t WRBIT(UINT32* bits, size_t dst, int bit)
251261{
252262   if (bit) {
r26172r26173
257267   return ++dst;
258268}
259269
260/** @brief read a bit from an array of UINT32 */
270/**
271 * @brief read a bit from an array of UINT32
272 * @param bits pointer to array of bits
273 * @param src source index
274 * @param bit reference to the bit to set
275 * @return next source index
276 */
261277static inline size_t RDBIT(UINT32* bits, size_t src, int& bit)
262278{
263279   bit = (bits[src/32] >> (src % 32)) & 1;
r26172r26173
415431 * @brief expand a sector into an array of clock and data bits
416432 *
417433 * @param page page number (0 to DRIVE_PAGES-1)
434 * @return pointer to the newly allocated array of bits
418435 */
419436UINT32* diablo_hd_device::expand_sector()
420437{
r26172r26173
529546 * @brief find a sync bit in an array of clock and data bits
530547 *
531548 * @param bits pointer to the sector's bits
532 * @param src source offset into bits (bit number)
549 * @param src source index into bits (bit number)
533550 * @param size number of words to scan for a sync word
534 * @return next source offset for reading
551 * @return next source index for reading
535552 */
536553size_t diablo_hd_device::squeeze_sync(UINT32 *bits, size_t src, size_t size)
537554{
r26172r26173
565582 * @brief find a 16 x 0 bits sequence in an array of clock and data bits
566583 *
567584 * @param bits pointer to the sector's bits
568 * @param src source offset into bits (bit number)
585 * @param src source index into bits (bit number)
569586 * @param size number of words to scan for a sync word
570 * @return next source offset for reading
587 * @return next source index for reading
571588 */
572589size_t diablo_hd_device::squeeze_unsync(UINT32 *bits, size_t src, size_t size)
573590{
r26172r26173
600617 * @brief squeeze an array of clock and data bits into a sector's record
601618 *
602619 * @param bits pointer to the sector's bits
603 * @param src source offset into bits (bit number)
620 * @param src source index into bits (bit number)
604621 * @param field pointer to the record data (bytes)
605622 * @param size size of the record in bytes
606 * @return next source offset for reading
623 * @return next source index for reading
607624 */
608625size_t diablo_hd_device::squeeze_record(UINT32 *bits, size_t src, UINT8 *field, size_t size)
609626{
r26172r26173
630647 * @brief squeeze an array of 32 clock and data bits into a checksum word
631648 *
632649 * @param bits pointer to the sector's bits
633 * @param src source offset into bits (bit number)
650 * @param src source index into bits (bit number)
634651 * @param cksum pointer to an int to receive the checksum word
635 * @return next source offset for reading
652 * @return next source index for reading
636653 */
637654size_t diablo_hd_device::squeeze_cksum(UINT32 *bits, size_t src, int *cksum)
638655{
r26172r26173
654671/**
655672 * @brief squeeze a array of clock and data bits into a sector's data
656673 *
657 * Find and squeeze header, label and data and verify for
658 * zero checksums (starting with 0521)
674 * Find and squeeze header, label and data fields and verify for
675 * zero checksums, starting with a value of 0521.
659676 * Write the page back to the media and free the bitmap
660677 */
661678void diablo_hd_device::squeeze_sector()
r26172r26173
773790
774791/**
775792 * @brief return number of bitclk edges for a sector
776 * @return number of bitclk edges for a sector
793 * @return number of bitclks for a sector
777794 */
778795int diablo_hd_device::bits_per_sector() const
779796{
r26172r26173
791808
792809/**
793810 * @brief return the number of a drive unit
794 * @return the unit number
811 * @return the unit number of this instance
795812 */
796813int diablo_hd_device::unit() const
797814{
r26172r26173
847864 * @brief return the current sector mark status of a drive
848865 *
849866 * The sector mark is derived from the offset into the current sector.
867 * It is deasserted except for a short time (a few micro seconds)
868 * around each new sector.
850869 *
851870 * @return the current sector mark for the drive (0:active 1:inactive)
852871 */
r26172r26173
862881
863882/**
864883 * @brief return the address acknowledge state
865 * @return the address acknowledge state (0:active 1:inactive)
884 * @return address acknowledge state (0:active 1:inactive)
866885 */
867886int diablo_hd_device::get_addx_acknowledge_0() const
868887{
r26172r26173
871890
872891/**
873892 * @brief return the log address interlock state
874 * @return the log address interlock state (0:active 1:inactive)
893 * @return log address interlock state (0:active 1:inactive)
875894 */
876895int diablo_hd_device::get_log_addx_interlock_0() const
877896{
r26172r26173
880899
881900/**
882901 * @brief return the seek incomplete state
883 * @return the address acknowledge state (0:active 1:inactive)
902 * @return address acknowledge state (0:active 1:inactive)
884903 */
885904int diablo_hd_device::get_seek_incomplete_0() const
886905{
r26172r26173
892911 *
893912 * Note: The bus lines are active low
894913 * The value on the BUS needs an XOR with DIABLO_CYLINDER_MASK
914 * to resemble the physical line levels.
895915 *
896 * @return the current cylinder number for the drive
916 * @return current cylinder number for the drive
897917 */
898918int diablo_hd_device::get_cylinder() const
899919{
r26172r26173
905925 *
906926 * Note: The bus lines are active low
907927 * The value on the BUS needs an XOR with DIABLO_HEAD_MASK
928 * to resemble the physical line levels.
908929 *
909 * @return the currently selected head for the drive
930 * @return currently selected head for the drive
910931 */
911932int diablo_hd_device::get_head() const
912933{
r26172r26173
918939 *
919940 * The current sector number is derived from the time since the
920941 * most recent track rotation started.
921 * It counts modulo DIABLO_SPT
942 * It counts modulo DIABLO_SPT (12).
922943 *
923944 * Note: The bus lines are active low
924945 * The value on the BUS needs an XOR with DIABLO_SECTOR_MASK
946 * to resemble the physical line levels.
925947 *
926 * @return the current sector for the drive
948 * @return current sector for the drive
927949 */
928950int diablo_hd_device::get_sector() const
929951{
r26172r26173
933955/**
934956 * @brief return the current page of a drive unit
935957 *
936 * The current page number is derived from the cylinder, head,
937 * and sector numbers.
958 * The current page number is derived from the cylinder, head, and sector numbers.
959 * This is a convenience function.
960 * There is no such signal on the BUS.
938961 *
939962 * @return the current page for the drive
940963 */
r26172r26173
11311154   int bit = 0;
11321155
11331156   if (m_rdgate_0) {
1134      LOG_DRIVE((9,"[DHD]   %s: unit #%d rdgate not asserted\n", __FUNCTION__, m_unit));
1157      LOG_DRIVE((0,"[DHD]   %s: unit #%d rdgate not asserted\n", __FUNCTION__, m_unit));
11351158      return 1;   // read gate is not asserted (active 0)
11361159   }
11371160
branches/alto2/src/emu/cpu/alto2/a2disk.c
r26172r26173
10601060   int i;
10611061   UINT8 s0, s1;
10621062
1063   LOG((LOG_DISK,8,"   >>> KWD timing bitclk:%d datin:%d sect4:%d\n", bitclk, datin, m_dsk.sect4));
1063   LOG((LOG_DISK,8,"   >>> KWD timing bitclk:%d datin:%d block:%d SECT[4]:%d\n", bitclk, datin, block, m_dsk.sect4));
1064
10641065   if (m_dsk.sect4 != dhd->get_sector_mark_0()) {
10651066      // SECT[4] transition
10661067      m_dsk.sect4 = dhd->get_sector_mark_0();
r26172r26173
10761077      }
10771078   }
10781079   if (0 != m_dsk.seclate && m_dsk.bitclk && !bitclk) {
1079      // if SECLATE is 1, the counter will count or load:
1080      // if SECLATE is 1, the counter will count or load:
10801081      if ((m_dsk.shiftin & (1 << 16)) && !WFFO) {
10811082         /*
10821083          * If HIORDBIT is 1 at the falling edge of BITCLK, it sets the
r26172r26173
11011102          */
11021103         m_dsk.bitcount = (m_dsk.bitcount + 1) % 16;
11031104         m_dsk.carry = m_dsk.bitcount == 15;
1104         LOG((LOG_DISK,7,"   WFFO:1 count bitcount:%2d\n", m_dsk.bitcount));
1105         LOG((LOG_DISK,6,"   WFFO:1 count bitcount:%2d\n", m_dsk.bitcount));
11051106      } else {
11061107         /*
11071108          * If BUS[4] (WFFO) was 0, both J and K' will be 0, and Q
r26172r26173
11091110          */
11101111         m_dsk.bitcount = 15;
11111112         m_dsk.carry = 1;
1112         LOG((LOG_DISK,7,"   WFFO:0 load bitcount:%2d\n", m_dsk.bitcount));
1113         LOG((LOG_DISK,6,"   WFFO:0 load bitcount:%2d\n", m_dsk.bitcount));
11131114      }
11141115   } else if (!m_dsk.bitclk && bitclk) {
1115      m_dsk.shiftin = (m_dsk.shiftin << 1) | datin;      // clock the shift register on the rising edge of bitclk
1116      // rising edge of bitclk
1117      m_dsk.shiftin = (m_dsk.shiftin << 1) | datin;      // clock the input shift register
11161118      m_dsk.shiftout = m_dsk.shiftout << 1;            // and the output shift register too
11171119   }
11181120
r26172r26173
14131415   if (m_dsk.ff_22b & JKFF_Q) {
14141416      if (0 == (m_task_wakeup & (1 << task_ksec))) {
14151417         LOG((LOG_DISK,6,"   STSKENA:1; WAKEST':0 wake KSEC\n"));
1416         m_task_wakeup |= 1 << task_kwd;
1418         m_task_wakeup |= 1 << task_ksec;
14171419      }
1418   } else {
1420   }
1421   if (m_dsk.ff_22b & JKFF_Q0) {
14191422      if (0 != (m_task_wakeup & (1 << task_ksec))) {
14201423         LOG((LOG_DISK,6,"   STSKENA:0; WAKEST':1\n"));
1421         m_task_wakeup &= ~(1 << task_kwd);
1424         m_task_wakeup &= ~(1 << task_ksec);
14221425      }
14231426   }
14241427
r26172r26173
14591462
14601463   // check if write and erase gate, or read gate are changed
14611464   if ((m_task_wakeup & (1 << task_ksec)) || GET_KCOM_XFEROFF(m_dsk.kcom) || m_dsk.kfer) {
1465#if   ALTO2_DEBUG
1466      if (0 == m_dsk.egate || 0 == m_dsk.wrgate || 0 == m_dsk.rdgate) {
1467         // log the reason why gates are deasserted
1468         LOG((LOG_DISK,6,"   deassert gates because of"));
1469         if (m_task_wakeup & (1 << task_ksec)) {
1470            LOG((LOG_DISK,6," wake KSEC"));
1471         }
1472         if (GET_KCOM_XFEROFF(m_dsk.kcom)) {
1473            LOG((LOG_DISK,6," XFEROFF"));
1474         }
1475         if (m_dsk.kfer) {
1476            LOG((LOG_DISK,6," KFER"));
1477         }
1478      }
1479#endif
14621480      // sector task is active OR xferoff is set OR fatal error
14631481      dhd->set_egate(m_dsk.egate = 1);
14641482      dhd->set_wrgate(m_dsk.wrgate = 1);
14651483      dhd->set_rdgate(m_dsk.rdgate = 1);
1466   } else {
1467      // assert either erase and read or write gates depending on current record R/W
1468      if (m_dsk.krwc & RWC_WRITE) {
1469         // assert erase and write gates only if OKTORUN is high
1470         if (m_dsk.ok_to_run) {
1471            dhd->set_egate(m_dsk.egate = 0);
1472            dhd->set_wrgate(m_dsk.wrgate = 0);
1473         }
1484   } else if (m_dsk.ok_to_run) {
1485       if (m_dsk.krwc & RWC_WRITE) {
1486         // assert erase and write gates
1487         dhd->set_egate(m_dsk.egate = 0);
1488         dhd->set_wrgate(m_dsk.wrgate = 0);
14741489      } else {
1475         // assert read gate only if OKTORUN is high
1476         if (m_dsk.ok_to_run) {
1477            dhd->set_rdgate(m_dsk.rdgate = 0);
1478         }
1490         // assert read gate
1491         dhd->set_rdgate(m_dsk.rdgate = 0);
14791492      }
14801493   }
14811494
r26172r26173
16691682   r = m_dsk.kstat;
16701683
16711684   LOG((LOG_DISK,1,"   ←KSTAT; BUS &= %#o\n", r));
1672   LOG((LOG_DISK,2,"      sector     : %#o\n", GET_KSTAT_SECTOR(m_dsk.kstat)));
1673   LOG((LOG_DISK,2,"      done       : %#o\n", GET_KSTAT_DONE(m_dsk.kstat)));
1674   LOG((LOG_DISK,2,"      seekfail   : %d\n", GET_KSTAT_SEEKFAIL(m_dsk.kstat)));
1675   LOG((LOG_DISK,2,"      seek       : %d\n", GET_KSTAT_SEEK(m_dsk.kstat)));
1676   LOG((LOG_DISK,2,"      notrdy     : %d\n", GET_KSTAT_NOTRDY(m_dsk.kstat)));
1677   LOG((LOG_DISK,2,"      datalate   : %d\n", GET_KSTAT_DATALATE(m_dsk.kstat)));
1678   LOG((LOG_DISK,2,"      idle       : %d\n", GET_KSTAT_IDLE(m_dsk.kstat)));
1679   LOG((LOG_DISK,2,"      cksum      : %d\n", GET_KSTAT_CKSUM(m_dsk.kstat)));
1680   LOG((LOG_DISK,2,"      completion : %#o\n", GET_KSTAT_COMPLETION(m_dsk.kstat)));
1685   LOG((LOG_DISK,2,"      SECTOR     : %#o\n", GET_KSTAT_SECTOR(m_dsk.kstat)));
1686   LOG((LOG_DISK,2,"      DONE       : %#o\n", GET_KSTAT_DONE(m_dsk.kstat)));
1687   LOG((LOG_DISK,2,"      SEEKFAIL   : %d\n", GET_KSTAT_SEEKFAIL(m_dsk.kstat)));
1688   LOG((LOG_DISK,2,"      SEEK       : %d\n", GET_KSTAT_SEEK(m_dsk.kstat)));
1689   LOG((LOG_DISK,2,"      NOTRDY     : %d\n", GET_KSTAT_NOTRDY(m_dsk.kstat)));
1690   LOG((LOG_DISK,2,"      DATALATE   : %d\n", GET_KSTAT_DATALATE(m_dsk.kstat)));
1691   LOG((LOG_DISK,2,"      IDLE       : %d\n", GET_KSTAT_IDLE(m_dsk.kstat)));
1692   LOG((LOG_DISK,2,"      CKSUM      : %d\n", GET_KSTAT_CKSUM(m_dsk.kstat)));
1693   LOG((LOG_DISK,2,"      COMPLETION : %#o\n", GET_KSTAT_COMPLETION(m_dsk.kstat)));
16811694
16821695   m_bus &= r;
16831696}
r26172r26173
17341747{
17351748   int i;
17361749   LOG((LOG_DISK,1,"   KSTAT←; BUS[12-15] %#o\n", m_bus));
1737   LOG((LOG_DISK,2,"      idle       : %#o\n", GET_KSTAT_IDLE(m_bus)));
1738   LOG((LOG_DISK,2,"      cksum      : %#o\n", GET_KSTAT_CKSUM(m_bus)));
1739   LOG((LOG_DISK,2,"      completion : %#o\n", GET_KSTAT_COMPLETION(m_bus)));
1750   LOG((LOG_DISK,2,"      IDLE       : %d\n", GET_KSTAT_IDLE(m_bus)));
1751   LOG((LOG_DISK,2,"      CKSUM      : %d\n", GET_KSTAT_CKSUM(m_bus)));
1752   LOG((LOG_DISK,2,"      COMPLETION : %#o\n", GET_KSTAT_COMPLETION(m_bus)));
17401753
17411754   /* KSTAT[12] is just taken from BUS[12] */
17421755   PUT_KSTAT_IDLE(m_dsk.kstat, GET_KSTAT_IDLE(m_bus));
r26172r26173
19831996 */
19841997void alto2_cpu_device::f1_load_kcom_1()
19851998{
1986   if (m_dsk.kcom != m_bus) {
1987      m_dsk.kcom = m_bus;
1988      LOG((LOG_DISK,2,"   KCOM←; BUS %06o\n", m_dsk.kcom));
1989      LOG((LOG_DISK,2,"      xferoff    : %#o\n", GET_KCOM_XFEROFF(m_dsk.kcom)));
1990      LOG((LOG_DISK,2,"      wdinhib    : %#o\n", GET_KCOM_WDINHIB(m_dsk.kcom)));
1991      LOG((LOG_DISK,2,"      bclksrc    : %#o\n", GET_KCOM_BCLKSRC(m_dsk.kcom)));
1992      LOG((LOG_DISK,2,"      wffo       : %#o\n", GET_KCOM_WFFO(m_dsk.kcom)));
1993      LOG((LOG_DISK,2,"      sendadr    : %#o\n", GET_KCOM_SENDADR(m_dsk.kcom)));
1994
1995      // TODO: show disk indicator in the GUI?
1996   }
1999   m_dsk.kcom = m_bus;
2000   LOG((LOG_DISK,2,"   KCOM←; BUS %06o\n", m_dsk.kcom));
2001   LOG((LOG_DISK,2,"      XFEROFF    : %d\n", GET_KCOM_XFEROFF(m_dsk.kcom)));
2002   LOG((LOG_DISK,2,"      WDINHIB    : %d\n", GET_KCOM_WDINHIB(m_dsk.kcom)));
2003   LOG((LOG_DISK,2,"      BCLKSRC    : %d\n", GET_KCOM_BCLKSRC(m_dsk.kcom)));
2004   LOG((LOG_DISK,2,"      WFFO       : %d\n", GET_KCOM_WFFO(m_dsk.kcom)));
2005   LOG((LOG_DISK,2,"      SENDADR    : %d\n", GET_KCOM_SENDADR(m_dsk.kcom)));
2006   // TODO: show disk indicator in the GUI?
19972007}
19982008
19992009/**
r26172r26173
20312041   m_dsk.krwc = GET_KADR_HEADER(m_dsk.kadr);
20322042
20332043   LOG((LOG_DISK,1,"   KADR←; BUS[8-14] #%o\n", m_dsk.kadr));
2034   LOG((LOG_DISK,2,"      seal       : %#o\n", GET_KADR_SEAL(m_dsk.kadr)));
2035   LOG((LOG_DISK,2,"      header     : %s (%#o)\n",  rwc_name[GET_KADR_HEADER(m_dsk.kadr)], GET_KADR_HEADER(m_dsk.kadr)));
2036   LOG((LOG_DISK,2,"      label      : %s (%#o)\n",  rwc_name[GET_KADR_LABEL(m_dsk.kadr)], GET_KADR_LABEL(m_dsk.kadr)));
2037   LOG((LOG_DISK,2,"      data       : %s (%#o)\n",  rwc_name[GET_KADR_DATA(m_dsk.kadr)], GET_KADR_DATA(m_dsk.kadr)));
2038   LOG((LOG_DISK,2,"      noxfer     : %#o\n",  GET_KADR_NOXFER(m_dsk.kadr)));
2039   LOG((LOG_DISK,2,"      unused     : %#o (drive?)\n",  GET_KADR_UNUSED(m_dsk.kadr)));
2044   LOG((LOG_DISK,2,"      SEAL       : %d\n", GET_KADR_SEAL(m_dsk.kadr)));
2045   LOG((LOG_DISK,2,"      HEADER     : %s (%#o)\n",  rwc_name[GET_KADR_HEADER(m_dsk.kadr)], GET_KADR_HEADER(m_dsk.kadr)));
2046   LOG((LOG_DISK,2,"      LABEL      : %s (%#o)\n",  rwc_name[GET_KADR_LABEL(m_dsk.kadr)], GET_KADR_LABEL(m_dsk.kadr)));
2047   LOG((LOG_DISK,2,"      DATA       : %s (%#o)\n",  rwc_name[GET_KADR_DATA(m_dsk.kadr)], GET_KADR_DATA(m_dsk.kadr)));
2048   LOG((LOG_DISK,2,"      NOXFER     : %d\n",  GET_KADR_NOXFER(m_dsk.kadr)));
2049   LOG((LOG_DISK,2,"      unused     : %d (drive?)\n",  GET_KADR_UNUSED(m_dsk.kadr)));
20402050   // TODO: show disk indicator in the GUI?
20412051}
20422052
branches/alto2/src/emu/cpu/alto2/alto2.c
r26172r26173
4242alto2_cpu_device::alto2_cpu_device(const machine_config& mconfig, const char* tag, device_t* owner, UINT32 clock) :
4343   cpu_device(mconfig, ALTO2, "Xerox Alto-II", tag, owner, clock, "alto2", __FILE__),
4444#if   ALTO2_DEBUG
45   m_log_types(LOG_DISK|LOG_KSEC|LOG_KWD),
45   m_log_types(LOG_CPU|LOG_DISK|LOG_KSEC|LOG_KWD),
4646   m_log_level(6),
4747   m_log_newline(true),
4848#endif

Previous 199869 Revisions Next


© 1997-2024 The MAME Team