Previous 199869 Revisions Next

r26198 Saturday 16th November, 2013 at 16:22:21 UTC by Jürgen Buchmüller
Get rid of home grown memory mapped i/o handling
[/branches/alto2/src/emu/cpu/alto2]a2disk.c a2hw.c a2kbd.c a2mem.c alto2.c alto2.h alto2dsm.c
[/branches/alto2/src/emu/machine]diablo_hd.c

branches/alto2/src/emu/machine/diablo_hd.c
r26197r26198
139139
140140void diablo_hd_device::set_sector_callback(void *cookie, void (*callback)(void *, int))
141141{
142   if (m_sector_callback_cookie == cookie && m_sector_callback == callback)
143      return;
142144   LOG_DRIVE((0,"[DHD] %s cookie=%p callback=%p\n", __FUNCTION__, cookie, callback));
143145   m_sector_callback_cookie = cookie;
144146   m_sector_callback = callback;
r26197r26198
982984   }
983985
984986   if (m_image) {
985      /* it is ready */
986      m_ready_0 = 0;
987      /* and can take seek/read/write commands */
988      m_s_r_w_0 = 0;
989      /* address acknowledge (?) */
990      m_addx_acknowledge_0 = 0;
991      /* clear log address interlock (?) */
992      m_log_addx_interlock_0 = 1;
987      m_ready_0 = 0;               // it is ready
988      m_s_r_w_0 = 0;               // and can take seek/read/write commands
989      m_addx_acknowledge_0 = 0;      // assert address acknowledge (?)
990      m_log_addx_interlock_0 = 1;      // deassert log address interlock (?)
993991      LOG_DRIVE((1,"[DHD]   %s: UNIT select %d ready\n", __FUNCTION__, unit));
994992   } else {
995      /* it is not ready (?) */
996      m_ready_0 = 1;
997      /* can't take seek/read/write commands (?) */
998      m_s_r_w_0 = 1;
999      /* address acknowledge (?) */
1000      m_addx_acknowledge_0 = 0;
993      m_ready_0 = 1;               // it is not ready (?)
994      m_s_r_w_0 = 1;               // can't take seek/read/write commands (?)
995      m_addx_acknowledge_0 = 0;      // assert address acknowledge (?)
996      m_log_addx_interlock_0 = 1;      // deassert log address interlock (?)
1001997      LOG_DRIVE((1,"[DHD]   %s: UNIT select %d not ready (no image)\n", __FUNCTION__, unit));
1002998   }
1003999   read_sector();
branches/alto2/src/emu/cpu/alto2/alto2.c
r26197r26198
3232
3333DEVICE_ADDRESS_MAP_START( iomem_map, 16, alto2_cpu_device )
3434   AM_RANGE(0,                          ALTO2_IO_PAGE_BASE - 1)            AM_READWRITE( ioram_r, ioram_w )
35   AM_RANGE(ALTO2_IO_PAGE_BASE,         0177777)                           AM_READWRITE( mmio_r,  mmio_w  )
36   AM_RANGE(0200000,                    0200000+ALTO2_IO_PAGE_BASE - 1)    AM_READWRITE( ioram_r, ioram_w )
37   AM_RANGE(0200000+ALTO2_IO_PAGE_BASE, 0377777)                           AM_READWRITE( mmio_r,  mmio_w  )
35   AM_RANGE(ALTO2_IO_PAGE_BASE,         0177777)                           AM_NOP
36   AM_RANGE(0177016,                    0177016)                           AM_READWRITE( utilout_r, utilout_w )
37   AM_RANGE(0177020,                    0177023)                           AM_READWRITE( xbus_r,  xbus_w )
38   AM_RANGE(0177024,                    0177024)                           AM_READ     ( mear_r )
39   AM_RANGE(0177025,                    0177025)                           AM_READWRITE( mesr_r,  mesr_w  )
40   AM_RANGE(0177026,                    0177026)                           AM_READWRITE( mecr_r,  mecr_w  )
41   AM_RANGE(0177030,                    0177033)                           AM_READ     ( utilin_r )
42   AM_RANGE(0177034,                    0177037)                           AM_READ     ( kbd_ad_r )
43   AM_RANGE(0177040,                    0177057)                           AM_READWRITE( bank_reg_r, bank_reg_w )
44   AM_RANGE(0200000,                    0377777)                           AM_READWRITE( ioram_r, ioram_w )
3845ADDRESS_MAP_END
3946
4047//-------------------------------------------------
r26197r26198
4451alto2_cpu_device::alto2_cpu_device(const machine_config& mconfig, const char* tag, device_t* owner, UINT32 clock) :
4552   cpu_device(mconfig, ALTO2, "Xerox Alto-II", tag, owner, clock, "alto2", __FILE__),
4653#if   ALTO2_DEBUG
47   m_log_types(LOG_CPU|LOG_DISK|LOG_KSEC|LOG_KWD),
54   m_log_types(LOG_DISK|LOG_KSEC|LOG_KWD|LOG_KBD),
4855   m_log_level(6),
4956   m_log_newline(true),
5057#endif
r26197r26198
120127   m_disp_a63(0),
121128   m_disp_a66(0),
122129   m_mem(),
123   mmio_read_fn(),
124   mmio_write_fn(),
125130   m_emu(),
126131   m_ether_a41(0),
127132   m_ether_a42(0),
r26197r26198
12201225      PUT_EVEN(m_mem.ram[dword_addr], data);
12211226}
12221227
1223//! read memory mapped i/o
1224READ16_MEMBER ( alto2_cpu_device::mmio_r )
1225{
1226   if (mmio_read_fn[offset])
1227      return ((*this).*mmio_read_fn[offset])(offset);
1228   return 0177777;
1229}
1230
1231//! write memory mapped i/o
1232WRITE16_MEMBER( alto2_cpu_device::mmio_w )
1233{
1234   if (mmio_write_fn[offset])
1235      return ((*this).*mmio_write_fn[offset])(offset, data);
1236}
1237
12381228//-------------------------------------------------
12391229//  device_reset - device-specific reset
12401230//-------------------------------------------------
r26197r26198
15141504 *
15151505 * The bank registers are stored in a 16x4-bit RAM 74S189.
15161506 */
1517UINT16 alto2_cpu_device::bank_reg_r(UINT32 address)
1507READ16_MEMBER( alto2_cpu_device::bank_reg_r )
15181508{
1519   int task = address & 017;
1509   int task = offset & 017;
15201510   int bank = m_bank_reg[task] | 0177760;
15211511   return bank;
15221512}
r26197r26198
15261516 *
15271517 * The bank registers are stored in a 16x4-bit RAM 74S189.
15281518 */
1529void alto2_cpu_device::bank_reg_w(UINT32 address, UINT16 data)
1519WRITE16_MEMBER( alto2_cpu_device::bank_reg_w )
15301520{
1531   int task = address & 017;
1521   int task = offset & 017;
15321522   m_bank_reg[task] = data & 017;
15331523   LOG((LOG_CPU,0,"   write bank[%02o]=%#o normal:%o extended:%o (%s)\n",
15341524      task, data,
r26197r26198
30673057      set_f2(task, f2_task_17,      &alto2_cpu_device::fn_f2_bad_0,   &alto2_cpu_device::fn_f2_bad_1);   // f2_task_10 to f2_task_17 are task specific
30683058   }
30693059
3060   init_memory();
30703061   init_disk();
30713062   init_disp();
3072   init_memory();
3073   init_hardware();
30743063   init_kbd();
3064   init_hw();
30753065
30763066   init_emu(task_emu);
3077   init_001(task_1);
3078   init_002(task_2);
3079   init_003(task_3);
30803067   init_ksec(task_ksec);
3081   init_005(task_5);
3082   init_006(task_6);
30833068   init_ether(task_ether);
30843069   init_mrt(task_mrt);
30853070   init_dwt(task_dwt);
r26197r26198
30883073   init_dvt(task_dvt);
30893074   init_part(task_part);
30903075   init_kwd(task_kwd);
3091   init_017(task_17);
30923076
3093   install_mmio_fn(0177740, 0177757, &alto2_cpu_device::bank_reg_r, &alto2_cpu_device::bank_reg_w);
3094
30953077   m_dsp_time = 0;         // reset the display state machine values
30963078   m_dsp_state = 020;
30973079
r26197r26198
31173099
31183100   return m_next_task;      // return next task (?)
31193101}
3120
3121void alto2_cpu_device::init_001(int task)
3122{
3123
3124}
3125
3126void alto2_cpu_device::init_002(int task)
3127{
3128
3129}
3130
3131void alto2_cpu_device::init_003(int task)
3132{
3133
3134}
3135
3136void alto2_cpu_device::init_005(int task)
3137{
3138
3139}
3140
3141void alto2_cpu_device::init_006(int task)
3142{
3143
3144}
3145
3146void alto2_cpu_device::init_017(int task)
3147{
3148
3149}
branches/alto2/src/emu/cpu/alto2/a2kbd.c
r26197r26198
1515 * @param addr memory mapped I/O address to be read
1616 * @return keyboard matrix value for address modulo 4
1717 */
18UINT16 alto2_cpu_device::kbd_ad_r(UINT32 addr)
18READ16_MEMBER( alto2_cpu_device::kbd_ad_r )
1919{
2020   UINT16 data = 0177777;
21   switch (addr & 3) {
21   switch (offset & 3) {
2222   case 0:
2323      data = machine().root_device().ioport("ROW0")->read();
2424      break;
r26197r26198
3232      data = machine().root_device().ioport("ROW3")->read();
3333      break;
3434   }
35   m_kbd.matrix[addr & 03] = data;
36   LOG((LOG_KBD,2,"   read KBDAD+%o (%#o)\n", addr & 3, data));
37   if (0 == (addr & 3) && (m_kbd.bootkey != 0177777)) {
35   m_kbd.matrix[offset & 03] = data;
36   LOG((LOG_KBD,2,"   read KBDAD+%o (%#o)\n", offset & 3, data));
37   if (0 == (offset & 3) && (m_kbd.bootkey != 0177777)) {
3838      LOG((0,2,"   boot keys (%#o & %#o)\n", data, m_kbd.bootkey));
3939      data &= m_kbd.bootkey;
4040      m_kbd.bootkey = 0177777;
r26197r26198
4949   m_kbd.matrix[1] = 0177777;
5050   m_kbd.matrix[2] = 0177777;
5151   m_kbd.matrix[3] = 0177777;
52   // install memory handler
53   install_mmio_fn(0177034, 0177037, &alto2_cpu_device::kbd_ad_r, 0);
5452}
5553
branches/alto2/src/emu/cpu/alto2/alto2dsm.c
r26197r26198
245245   switch (aluf) {
246246   case  0: // T?: BUS
247247      // this is somehow redundant and just wasting space
248      // dst += snprintf(dst, len - (size_t)(dst - buffer), "ALUF(BUS) ");
248      dst += snprintf(dst, len - (size_t)(dst - buffer), "ALUF(BUS) ");
249249      break;
250250   case  1: //   : T
251251      dst += snprintf(dst, len - (size_t)(dst - buffer), "ALUF(T) ");
branches/alto2/src/emu/cpu/alto2/alto2.h
r26197r26198
10801080   void fn_f2_bad_0();                        //! f2 dummy early function
10811081   void fn_f2_bad_1();                        //! f2 dummy late function
10821082
1083   UINT16 bank_reg_r(UINT32 address);            //!< read bank register in memory mapped I/O range
1084   void bank_reg_w(UINT32 address, UINT16 data);   //!< write bank register in memory mapped I/O range
1083   DECLARE_READ16_MEMBER( bank_reg_r );         //!< read bank register in memory mapped I/O range
1084   DECLARE_WRITE16_MEMBER( bank_reg_w );         //!< write bank register in memory mapped I/O range
10851085
10861086   void bs_read_r_0();                        //!< bs_read_r early: drive bus by R register
10871087   void bs_load_r_0();                        //!< bs_load_r early: load R places 0 on the BUS
r26197r26198
12891289      UINT16 utilin;         //!< the UTILIN port at 0177030 to 0177033 (same value on all addresses)
12901290   }   m_hw;
12911291
1292   UINT16 utilin_r(UINT32 addr);            //!< read an UTILIN address
1293   UINT16 utilout_r(UINT32 addr);            //!< read the UTILOUT address
1294   void utilout_w(UINT32 addr, UINT16 data);   //!< write the UTILOUT address
1295   UINT16 xbus_r(UINT32 addr);               //!< read an XBUS address
1296   void xbus_w(UINT32 addr, UINT16 data);      //!< write an XBUS address (?)
1297   void init_hardware();                  //!< initialize miscellaneous hardware
1292   DECLARE_READ16_MEMBER( utilin_r );         //!< read an UTILIN address
1293   DECLARE_READ16_MEMBER( utilout_r );         //!< read the UTILOUT address
1294   DECLARE_WRITE16_MEMBER( utilout_w );      //!< write the UTILOUT address
1295   DECLARE_READ16_MEMBER( xbus_r );         //!< read an XBUS address
1296   DECLARE_WRITE16_MEMBER( xbus_w );         //!< write an XBUS address (?)
1297   void init_hw();                        //!< initialize miscellaneous hardware
12981298
12991299   // ************************************************
13001300   // keyboard stuff
r26197r26198
13031303      UINT16 bootkey;                     //!< boot key - key code pressed before power on
13041304      UINT16 matrix[4];                  //!< a bit map of the keys pressed (ioports ROW0 ... ROW3)
13051305   }   m_kbd;
1306   UINT16 kbd_ad_r(UINT32 addr);            //!< read the keyboard matrix
1306   DECLARE_READ16_MEMBER( kbd_ad_r );         //!< read the keyboard matrix
13071307   void init_kbd(UINT16 bootkey = 0177777);   //!< initialize the keyboard hardware, optinally set the boot key
13081308
13091309   // ************************************************
r26197r26198
18471847      return (ALTO2_MEM_NONE == m_mem.access ? false : cycle() < m_mem.cycle+2);
18481848   }
18491849
1850   //! memory mapped I/O read functions - FIXME: use MAME memory handlers for AS_IO
1851   a2io_rd mmio_read_fn[ALTO2_IO_PAGE_SIZE];
1852
1853   //! memory mapped I/O write functions - FIXME: use MAME memory handlers for AS_IO
1854   a2io_wr mmio_write_fn[ALTO2_IO_PAGE_SIZE];
1855
1856   //! catch unmapped memory mapped I/O reads
1857   UINT16 bad_mmio_read_fn(UINT32 address);
1858
1859   //! catch unmapped memory mapped I/O writes
1860   void bad_mmio_write_fn(UINT32 address, UINT16 data);
1861
18621850   //! memory error address register read
1863   UINT16 mear_r(UINT32 address);
1851   DECLARE_READ16_MEMBER( mear_r );
18641852
18651853   //! memory error status register read
1866   UINT16 mesr_r(UINT32 address);
1854   DECLARE_READ16_MEMBER( mesr_r );
18671855
18681856   //! memory error status register write (clear)
1869   void mesr_w(UINT32 address, UINT16 data);
1857   DECLARE_WRITE16_MEMBER( mesr_w );
18701858
18711859   //! memory error control register read
1872   UINT16 mecr_r(UINT32 address);
1860   DECLARE_READ16_MEMBER( mecr_r );
18731861
18741862   //! memory error control register write
1875   void mecr_w(UINT32 address, UINT16 data);
1863   DECLARE_WRITE16_MEMBER( mecr_w );
18761864
18771865   //! read or write a memory double-word and caluclate its Hamming code
18781866   UINT32 hamming_code(int write, UINT32 dw_addr, UINT32 dw_data);
r26197r26198
18861874   //! write memory or memory mapped I/O from md to the address in mar
18871875   void write_mem(UINT16 data);
18881876
1889   //! install read and/or write memory mapped I/O handler(s) for a range first to last
1890   void install_mmio_fn(int first, int last, a2io_rd rfn, a2io_wr wfn);
1891
18921877   //! debugger interface to read memory
18931878   UINT16 debug_read_mem(UINT32 addr);
18941879
r26197r26198
20892074   // disk word task
20902075   void f1_kwd_block_0(void);
20912076   void init_kwd(int task);                  //!< 016 initialize disk word task
2092
2093   void init_001(int task);                  //!< 001 initialize unused task
2094   void init_002(int task);                  //!< 002 initialize unused task
2095   void init_003(int task);                  //!< 003 initialize unused task
2096   void init_005(int task);                  //!< 005 initialize unused task
2097   void init_006(int task);                  //!< 006 initialize unused task
2098   void init_017(int task);                  //!< 017 initialize unused task
20992077};
21002078
21012079extern const device_type ALTO2;
branches/alto2/src/emu/cpu/alto2/a2hw.c
r26197r26198
1515 * @param addr memory mapped I/O address to be read
1616 * @return current value on the UTILIN port
1717 */
18UINT16 alto2_cpu_device::utilin_r(UINT32 addr)
18READ16_MEMBER( alto2_cpu_device::utilin_r )
1919{
2020   UINT16  data;
2121   // FIXME: update the printer status
r26197r26198
2323
2424   data = m_hw.utilin;
2525
26   LOG((LOG_HW,2,"   read UTILIN %#o (%#o)\n", addr, data));
26   LOG((LOG_HW,2,"   read UTILIN %#o (%#o)\n", offset, data));
2727   return data;
2828}
2929
r26197r26198
3333 * @param addr memory mapped I/O address to be read
3434 * @return current value on the XBUS port latch
3535 */
36UINT16 alto2_cpu_device::xbus_r(UINT32 addr)
36READ16_MEMBER( alto2_cpu_device::xbus_r )
3737{
38   UINT16 data = m_hw.xbus[addr & 3];
38   UINT16 data = m_hw.xbus[offset & 3];
3939
40   LOG((LOG_HW,2,"   read XBUS[%d] %#o (%#o)\n", addr&3, addr, data));
40   LOG((LOG_HW,2,"   read XBUS[%d] %#o (%#o)\n", offset & 3, offset, data));
4141   return data;
4242}
4343
r26197r26198
4949 * @param addr memory mapped I/O address to be read
5050 * @param data value to write to the XBUS port latch
5151 */
52void alto2_cpu_device::xbus_w(UINT32 addr, UINT16 data)
52WRITE16_MEMBER( alto2_cpu_device::xbus_w )
5353{
54   LOG((LOG_HW,2,"   write XBUS[%d] %#o (%#o)\n", addr & 3, addr, data));
55   m_hw.xbus[addr&3] = data;
54   LOG((LOG_HW,2,"   write XBUS[%d] %#o (%#o)\n", offset & 3, offset, data));
55   m_hw.xbus[offset&3] = data;
5656}
5757
5858/**
r26197r26198
6161 * @param addr memory mapped I/O address to be read
6262 * @return current value on the UTILOUT port latch
6363 */
64UINT16 alto2_cpu_device::utilout_r(UINT32 addr)
64READ16_MEMBER( alto2_cpu_device::utilout_r )
6565{
6666   UINT16 data = m_hw.utilout ^ 0177777;
67   LOG((0,2,"   read UTILOUT %#o (%#o)\n", addr, data));
67   LOG((0,2,"   read UTILOUT %#o (%#o)\n", offset, data));
6868   return data;
6969}
7070
r26197r26198
7676 * @param addr memory mapped I/O address to be read
7777 * @param data value to write to the UTILOUT port latch
7878 */
79void alto2_cpu_device::utilout_w(UINT32 addr, UINT16 data)
79WRITE16_MEMBER( alto2_cpu_device::utilout_w )
8080{
81   LOG((LOG_HW,2,"   write UTILOUT %#o (%#o)\n", addr, data));
81   LOG((LOG_HW,2,"   write UTILOUT %#o (%#o)\n", offset, data));
8282   m_hw.utilout = data ^ 0177777;
8383
8484   // FIXME: write printer data
r26197r26198
8888/**
8989 * @brief clear all keys and install the mmio handler for KBDAD to KBDAD+3
9090 */
91void alto2_cpu_device::init_hardware()
91void alto2_cpu_device::init_hw()
9292{
9393   memset(&m_hw, 0, sizeof(m_hw));
9494
r26197r26198
100100   m_hw.xbus[1] = 0177777;
101101   m_hw.xbus[2] = 0177777;
102102   m_hw.xbus[3] = 0177777;
103
104   // install memory handlers
105   install_mmio_fn(0177016, 0177016, &alto2_cpu_device::utilout_r, &alto2_cpu_device::utilout_w);
106   install_mmio_fn(0177020, 0177023, &alto2_cpu_device::xbus_r, &alto2_cpu_device::xbus_w);
107   install_mmio_fn(0177030, 0177033, &alto2_cpu_device::utilin_r, 0);
108103}
109104
branches/alto2/src/emu/cpu/alto2/a2mem.c
r26197r26198
482482}
483483#endif   /* ALTO2_HAMMING_CHECK */
484484
485
486485/**
487 * @brief catch unmapped memory mapped I/O reads
488 *
489 * @param address address that is read from
490 */
491UINT16 alto2_cpu_device::bad_mmio_read_fn(UINT32 address)
492{
493   LOG((LOG_MEM,1,"   stray I/O read of address %#o\n", address));
494   (void)address;
495   return 0177777;
496}
497
498/**
499 * @brief catch unmapped memory mapped I/O writes
500 *
501 * @param address address that is written to
502 * @param data data that is written
503 */
504void alto2_cpu_device::bad_mmio_write_fn(UINT32 address, UINT16 data)
505{
506   LOG((LOG_MEM,1,"   stray I/O write of address %06o, data %#o\n", address, data));
507   (void)address;
508   (void)data;
509}
510
511/**
512486 * @brief memory error address register read
513487 *
514488 * This register is a 'shadow MAR'; it holds the address of the
r26197r26198
517491 * memory access. Note that MEAR is set whenever an error of
518492 * _any kind_ (single-bit or double-bit) is detected.
519493 */
520UINT16 alto2_cpu_device::mear_r(UINT32 address)
494READ16_MEMBER( alto2_cpu_device::mear_r )
521495{
522496   int data = m_mem.error ? m_mem.mear : m_mem.mar;
523497   LOG((LOG_MEM,2,"   MEAR read %07o\n", data));
r26197r26198
540514 * MESR[14-15]   Bank number in which error occured
541515 * </PRE>
542516 */
543UINT16 alto2_cpu_device::mesr_r(UINT32 address)
517READ16_MEMBER( alto2_cpu_device::mesr_r )
544518{
545519   UINT16 data = m_mem.mesr ^ 0177777;
546   (void)address;
547520   LOG((LOG_MEM,2,"   MESR read %07o\n", data));
548521   LOG((LOG_MEM,6,"      Hamming code read    : %#o\n", GET_MESR_HAMMING(data)));
549522   LOG((LOG_MEM,6,"      Parity error         : %o\n", GET_MESR_PERR(data)));
r26197r26198
557530   return data;
558531}
559532
560void alto2_cpu_device::mesr_w(UINT32 address, UINT16 data)
533WRITE16_MEMBER( alto2_cpu_device::mesr_w )
561534{
562535   LOG((LOG_MEM,2,"   MESR write %07o (clear MESR; was %07o)\n", data, m_mem.mesr));
563536   m_mem.mesr = 0;      // set all bits to 0
r26197r26198
586559 * MECR[15]   Spare
587560 * </PRE>
588561 */
589void alto2_cpu_device::mecr_w(UINT32 address, UINT16 data)
562WRITE16_MEMBER( alto2_cpu_device::mecr_w )
590563{
591564   m_mem.mecr = data ^ 0177777;
592   (void)address;
593565   A2_PUT16(m_mem.mecr,16, 0, 3,0);
594566   A2_PUT16(m_mem.mecr,16,15,15,0);
595567   LOG((LOG_MEM,2,"   MECR write %07o\n", data));
r26197r26198
603575/**
604576 * @brief memory error control register read
605577 */
606UINT16 alto2_cpu_device::mecr_r(UINT32 address)
578READ16_MEMBER( alto2_cpu_device::mecr_r )
607579{
608580   UINT16 data = m_mem.mecr ^ 0177777;
609581   /* set all spare bits */
r26197r26198
666638
667639   base_addr = m_mem.mar & 0177777;
668640   if (base_addr >= ALTO2_IO_PAGE_BASE) {
669      offs_t offset = base_addr - ALTO2_IO_PAGE_BASE;
670      if (mmio_read_fn[offset])
671         m_mem.md = ((*this).*mmio_read_fn[offset])(base_addr);
641      m_mem.md = m_iomem->read_word(m_iomem->address_to_byte(base_addr));
672642      LOG((LOG_MEM,6,"   MD = MMIO[%#o] (%#o)\n", base_addr, m_mem.md));
673643      m_mem.access = ALTO2_MEM_NONE;
674644#if   ALTO2_DEBUG
r26197r26198
722692
723693   base_addr = m_mem.mar & 0177777;
724694   if (base_addr >= ALTO2_IO_PAGE_BASE) {
725      offs_t offset = base_addr - ALTO2_IO_PAGE_BASE;
695      m_iomem->write_word(m_iomem->address_to_byte(base_addr), m_mem.md);
726696      LOG((LOG_MEM,6, "   MMIO[%#o] = MD (%#o)\n", base_addr, m_mem.md));
727      if (mmio_write_fn[offset])
728         ((*this).*mmio_write_fn[offset])(base_addr, m_mem.md);
729697      m_mem.access = ALTO2_MEM_NONE;
730698#if   ALTO2_DEBUG
731699      watch_write(m_mem.mar, m_mem.md);
r26197r26198
757725}
758726
759727/**
760 * @brief install read and/or writte memory mapped I/O handler(s) for a range first to last
761 *
762 * This function fatal()s, if you specify a bad address for first and/or last.
763 *
764 * @param first first memory address to map
765 * @param last last memory address to map
766 * @param rfn pointer to a read function of type 'UINT16 (*read)(UINT32)'
767 * @param wfn pointer to a write function of type 'void (*write)(UINT32,UINT16)'
768 */
769void alto2_cpu_device::install_mmio_fn(int first, int last, a2io_rd rfn, a2io_wr wfn)
770{
771   int address;
772
773   if (first <= ALTO2_IO_PAGE_BASE || last >= (ALTO2_IO_PAGE_BASE + ALTO2_IO_PAGE_SIZE) || first > last) {
774      fatal(3, "internal error - bad memory-mapped I/O address\n");
775   }
776
777   for (address = first; address <= last; address++) {
778      mmio_read_fn[address - ALTO2_IO_PAGE_BASE] = rfn ? rfn : &alto2_cpu_device::bad_mmio_read_fn;
779      mmio_write_fn[address - ALTO2_IO_PAGE_BASE] = wfn ? wfn : &alto2_cpu_device::bad_mmio_write_fn;
780   }
781}
782
783/**
784728 * @brief debugger interface to read memory
785729 *
786730 * @param addr address to read
r26197r26198
791735   int base_addr = addr & 0177777;
792736   int data = 0177777;
793737   if (base_addr >= ALTO2_IO_PAGE_BASE) {
794      offs_t offset = base_addr - ALTO2_IO_PAGE_BASE;
795      if (mmio_read_fn[offset])
796         data = ((*this).*mmio_read_fn[offset])(addr);
738      data = m_iomem->read_word(m_iomem->address_to_byte(base_addr));
797739   } else {
798740      data = (addr & ALTO2_MEM_ODD) ? GET_ODD(m_mem.ram[addr/2]) : GET_EVEN(m_mem.ram[addr/2]);
799741   }
r26197r26198
810752{
811753   int base_addr = addr & 0177777;
812754   if (base_addr >= ALTO2_IO_PAGE_BASE) {
813      offs_t offset = base_addr - ALTO2_IO_PAGE_BASE;
814      if (mmio_write_fn[offset])
815         ((*this).*mmio_write_fn[offset])(addr, data);
755      m_iomem->write_word(m_iomem->address_to_byte(base_addr), data);
816756   } else if (addr & ALTO2_MEM_ODD) {
817757      PUT_ODD(m_mem.ram[addr/2], data);
818758   } else {
r26197r26198
832772{
833773   memset(&m_mem, 0, sizeof(m_mem));
834774
835   for (UINT32 addr = 0; addr < ALTO2_IO_PAGE_SIZE; addr++) {
836      mmio_read_fn[addr] = &alto2_cpu_device::bad_mmio_read_fn;
837      mmio_write_fn[addr] = &alto2_cpu_device::bad_mmio_write_fn;
838   }
839
840775   // allocate 128KB of main memory
841776   m_mem.ram = global_alloc_array(UINT32, sizeof(UINT16)*ALTO2_RAM_SIZE);
842777   memset(m_mem.ram, 0, sizeof(UINT32)*sizeof(UINT16)*ALTO2_RAM_SIZE);
r26197r26198
888823    *   D3      & MISYSCLK -> LOADERC
889824    * </PRE>
890825    */
891   install_mmio_fn(0177024, 0177024, &alto2_cpu_device::mear_r, 0);
892   install_mmio_fn(0177025, 0177025, &alto2_cpu_device::mesr_r, &alto2_cpu_device::mesr_w);
893   install_mmio_fn(0177026, 0177026, &alto2_cpu_device::mecr_r, &alto2_cpu_device::mecr_w);
894826
895827#if   ALTO2_HAMMING_CHECK
896828   // Initialize the hamming codes and parity bit
branches/alto2/src/emu/cpu/alto2/a2disk.c
r26197r26198
10231023 * Whoa there! :-)
10241024 * </PRE>
10251025 */
1026#define   INIT   (m_task == task_kwd && m_dsk.wdinit0)
1027
10281026#define   WDALLOW   (!GET_KCOM_WDINHIB(m_dsk.kcom))
10291027#define   WDINIT   ((m_dsk.ff_53b & JKFF_Q) ? 1 : 0)
10301028#define   RDYLAT   ((m_dsk.ff_45a & JKFF_Q) ? 1 : 0)
r26197r26198
11711169       */
11721170      DEBUG_NAME("\t\t53b KWD   ");
11731171      s0 = m_dsk.ff_53b;
1174      s1 = m_sysclkb1[i] ? JKFF_CLK : JKFF_0;
1172      s1 = m_sysclkb1[i];
11751173      if (block != task_kwd)
11761174         s1 |= JKFF_K;         // (BLOCK & WDTSKACT)'
11771175      if (WDALLOW)
r26197r26198
11921190       */
11931191      DEBUG_NAME("\t\t53a KWD   ");
11941192      s0 = m_dsk.ff_53a;
1195      s1 = m_sysclkb1[i] ? JKFF_CLK : JKFF_0;
1193      s1 = m_sysclkb1[i];
11961194      if (m_dsk.ff_43b & JKFF_Q)
11971195         s1 |= JKFF_J;
11981196      if (block != task_kwd)
r26197r26198
12151213       */
12161214      DEBUG_NAME("\t\t43a KWD   ");
12171215      s0 = m_dsk.ff_43a;
1218      s1 = m_sysclka1[i] ? JKFF_CLK : JKFF_0;
1216      s1 = m_sysclka1[i];
12191217      if (m_dsk.ff_53a & JKFF_Q)
12201218         s1 |= JKFF_J;
12211219      if (m_dsk.ff_53a & JKFF_Q)
r26197r26198
12381236       */
12391237      DEBUG_NAME("\t\t45a RDYLAT");
12401238      s0 = m_dsk.ff_45a;
1241      s1 = m_sysclka1[i] ? JKFF_CLK : JKFF_0;
1239      s1 = m_sysclka1[i];
12421240      if (dhd->get_ready_0())
12431241         s1 |= JKFF_J;
12441242      s1 |= JKFF_K;
r26197r26198
12601258       */
12611259      DEBUG_NAME("\t\t45b SEQERR");
12621260      s0 = m_dsk.ff_45b;
1263      s1 = m_sysclka1[i] ? JKFF_CLK : JKFF_0;
1261      s1 = m_sysclka1[i];
12641262      s1 |= JKFF_J;
12651263      if (SEQERR)
12661264         s1 |= JKFF_K;
r26197r26198
12811279       */
12821280      DEBUG_NAME("\t\t22b KSEC  ");
12831281      s0 = m_dsk.ff_22b;
1284      s1 = m_sysclkb1[i] ? JKFF_CLK : JKFF_0;
1282      s1 = m_sysclkb1[i];
12851283      if (m_dsk.ff_22a & JKFF_Q)
12861284         s1 |= JKFF_J;
12871285      if (block != task_ksec)
r26197r26198
13031301       */
13041302      DEBUG_NAME("\t\t22a KSEC  ");
13051303      s0 = m_dsk.ff_22a;
1306      s1 = m_sysclkb1[i] ? JKFF_CLK : JKFF_0;
1304      s1 = m_sysclkb1[i];
13071305      if (m_dsk.ff_21b & JKFF_Q)
13081306         s1 |= JKFF_J;
13091307      s1 |= JKFF_K;
r26197r26198
13251323       */
13261324      DEBUG_NAME("\t\t21b KSEC  ");
13271325      s0 = m_dsk.ff_21b;
1328      s1 = m_sysclkb1[i] ? JKFF_CLK : JKFF_0;
1326      s1 = m_sysclkb1[i];
13291327      if (m_dsk.ff_21a & JKFF_Q)
13301328         s1 |= JKFF_J;
13311329      s1 |= JKFF_K;
r26197r26198
16541652   /* KSTAT[9] latch the drive seek/read/write status */
16551653   PUT_KSTAT_SEEK(m_dsk.kstat, dhd->get_seek_read_write_0());
16561654
1657   /* KSTAT[10] latch the latched (FF 45a at CLRSTAT) ready status */
1655   /* KSTAT[10] latch the latched (FF 45a at CLRSTAT) ready status (Q) */
16581656   PUT_KSTAT_NOTRDY(m_dsk.kstat, m_dsk.ff_45a & JKFF_Q ? 1 : 0);
16591657
16601658   /* KSTAT[11] latch the latched (FF 45b at CLRSTAT) seqerr status (Q') */
r26197r26198
17541752      UINT8 s0, s1;
17551753      DEBUG_NAME("\t\t44b CKSUM ");
17561754      s0 = m_dsk.ff_44b;
1757      s1 = i ? JKFF_CLK : 0;
1758      if (!A2_GET16(m_bus,16,13,13))
1755      s1 = i ? JKFF_CLK : JKFF_0;
1756      if (!GET_KSTAT_CKSUM(m_bus))
17591757         s1 |= JKFF_J;
17601758      s1 |= JKFF_K;
17611759      s1 |= JKFF_S;
r26197r26198
18801878void alto2_cpu_device::f1_clrstat_1()
18811879{
18821880   diablo_hd_device* dhd = m_drive[m_dsk.drive];
1883   LOG((LOG_DISK,1,"   CLRSTAT\n"));
18841881   UINT8 s0, s1;
18851882
18861883   /* clears the LAI clocked flip-flop 44a
r26197r26198
18981895   s1 |= JKFF_J;
18991896   s1 |= JKFF_K;
19001897   s1 |= JKFF_S;
1898   s1 &= ~JKFF_C;
19011899   m_dsk.ff_44a = update_jkff(s0, s1);
19021900
19031901   /* clears the CKSUM flip-flop 44b
r26197r26198
19151913   s1 |= m_dsk.ff_44b & JKFF_J;
19161914   s1 |= JKFF_K;
19171915   s1 |= JKFF_S;
1916   s1 &= ~JKFF_C;
19181917   m_dsk.ff_44b = update_jkff(s0, s1);
19191918
19201919   /* clears the rdylat flip-flop 45a
r26197r26198
19351934      s1 |= JKFF_J;
19361935   s1 |= JKFF_K;
19371936   s1 |= JKFF_S;
1937   s1 &= ~JKFF_C;
19381938   m_dsk.ff_45a = update_jkff(s0, s1);
19391939
19401940   /* sets the seqerr flip-flop 45b (Q' is SEQERR)
r26197r26198
19521952   s1 |= JKFF_J;
19531953   if (!SEQERR)
19541954      s1 |= JKFF_K;
1955   s1 &= ~JKFF_S;
19551956   s1 |= JKFF_C;
19561957   m_dsk.ff_45b = update_jkff(s0, s1);
19571958
r26197r26198
19601961
19611962   /* start monoflop 31a, which resets ready_mf31a */
19621963   m_dsk.ready_timer->adjust(attotime::from_nsec(TW_READY), 1);
1964
1965   LOG((LOG_DISK,1,"   CLRSTAT (44a_Q:%d 44b_Q:%d 45a_Q:%d 45b_Q:%d 31a_Q:%d)\n",
1966       m_dsk.ff_44a & JKFF_Q ? 1 : 0, m_dsk.ff_44b & JKFF_Q ? 1 : 0,
1967       m_dsk.ff_45a & JKFF_Q ? 1 : 0, m_dsk.ff_45b & JKFF_Q ? 1 : 0,
1968       m_dsk.ready_mf31a));
19631969}
19641970
19651971/**
r26197r26198
20402046 */
20412047void alto2_cpu_device::f2_init_1()
20422048{
2043   UINT16 r = INIT ? 037 : 0;
2049   // INIT = current task == KWD and WDINIT
2050   UINT16 r = (m_task == task_kwd && m_dsk.wdinit0) ? 037 : 0;
20442051   LOG((LOG_DISK,1,"   INIT; %sbranch (%#o | %#o)\n", r ? "" : "no ", m_next2, r));
20452052   m_next2 |= r;
20462053   m_dsk.wdinit0 = 0;
r26197r26198
20492056/**
20502057 * @brief f2_rwc late: branch on read/write/check state of the current record
20512058 * <PRE>
2052 * NEXT ← NEXT OR (current record to be written ? 3 :
2053 *   current record to be checked ? 2 : 0);
2059 * NEXT ← NEXT OR (current record to be written ? 3 : current record to be checked ? 2 : 0);
20542060 *
20552061 * NB: note how krecno counts 0,2,3,1 ... etc.
20562062 * on 0: it presents the RWC for HEADER
r26197r26198
20732079{
20742080   static UINT16 branch_map[4] = {0,2,3,3};
20752081   UINT16 r = branch_map[m_dsk.krwc];;
2076   UINT16 init = INIT ? 037 : 0;
2082   UINT16 init = (m_task == task_kwd && m_dsk.wdinit0) ? 037 : 0;
20772083
20782084   switch (m_dsk.krecno) {
20792085   case RECNO_HEADER:
r26197r26198
21152121void alto2_cpu_device::f2_recno_1()
21162122{
21172123   UINT16 r = m_dsk.krecno;
2118   UINT16 init = INIT ? 037 : 0;
2124   UINT16 init = (m_task == task_kwd && m_dsk.wdinit0) ? 037 : 0;
21192125   LOG((LOG_DISK,1,"   RECNO; %sbranch recno:%d (%#o|%#o|%#o)\n", (r | init) ? "" : "no ", m_dsk.krecno, m_next2, r, init));
21202126   m_next2 |= r | init;
21212127   m_dsk.wdinit0 = 0;
r26197r26198
21292135void alto2_cpu_device::f2_xfrdat_1()
21302136{
21312137   UINT16 r = GET_KADR_NOXFER(m_dsk.kadr) ? 0 : 1;
2132   UINT16 init = INIT ? 037 : 0;
2138   UINT16 init = (m_task == task_kwd && m_dsk.wdinit0) ? 037 : 0;
21332139   LOG((LOG_DISK,1,"   XFRDAT; %sbranch (%#o|%#o|%#o)\n", (r | init) ? "" : "no ", m_next2, r, init));
21342140   m_next2 |= r | init;
21352141   m_dsk.wdinit0 = 0;
r26197r26198
21442150{
21452151   diablo_hd_device* dhd = m_drive[m_dsk.drive];
21462152   UINT16 r = dhd ? dhd->get_seek_read_write_0() : 1;
2147   UINT16 init = INIT ? 037 : 0;
2153   UINT16 init = (m_task == task_kwd && m_dsk.wdinit0) ? 037 : 0;
21482154
21492155   LOG((LOG_DISK,1,"   SWRNRDY; %sbranch (%#o|%#o|%#o)\n", (r | init) ? "" : "no ", m_next2, r, init));
21502156   m_next2 |= r | init;
r26197r26198
21592165void alto2_cpu_device::f2_nfer_1()
21602166{
21612167   UINT16 r = m_dsk.kfer ? 0 : 1;
2162   UINT16 init = INIT ? 037 : 0;
2168   UINT16 init = (m_task == task_kwd && m_dsk.wdinit0) ? 037 : 0;
21632169
21642170   LOG((LOG_DISK,1,"   NFER; %sbranch (%#o|%#o|%#o)\n", (r | init) ? "" : "no ", m_next2, r, init));
21652171   m_next2 |= r | init;
r26197r26198
21882194void alto2_cpu_device::f2_strobon_1()
21892195{
21902196   UINT16 r = m_dsk.strobe;
2191   UINT16 init = INIT ? 037 : 0;
2197   UINT16 init = (m_task == task_kwd && m_dsk.wdinit0) ? 037 : 0;
21922198
21932199   LOG((LOG_DISK,2,"   STROBON; %sbranch (%#o|%#o|%#o)\n", (r | init) ? "" : "no ", m_next2, r, init));
21942200   m_next2 |= r | init;
r26197r26198
23612367#endif
23622368
23632369   m_dsk.strobon_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(alto2_cpu_device::disk_strobon),this));
2364   m_dsk.strobon_timer->adjust(attotime::from_nsec(TW_STROBON), (1<<1));
2370   m_dsk.strobon_timer->reset();
23652371
23662372   m_dsk.seclate_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(alto2_cpu_device::disk_seclate),this));
2367   m_dsk.seclate_timer->adjust(attotime::from_nsec(TW_SECLATE), 1);
2373   // m_dsk.seclate_timer->adjust(attotime::from_nsec(TW_SECLATE), 1);
2374   m_dsk.seclate_timer->reset();
23682375
23692376   m_dsk.ok_to_run_timer = machine().scheduler().timer_alloc(timer_expired_delegate(FUNC(alto2_cpu_device::disk_ok_to_run),this));
23702377   m_dsk.ok_to_run_timer->adjust(attotime::from_nsec(15 * ALTO2_UCYCLE), 1);

Previous 199869 Revisions Next


© 1997-2024 The MAME Team