Previous 199869 Revisions Next

r26120 Tuesday 12th November, 2013 at 13:02:41 UTC by Jürgen Buchmüller
Fix m_ucode address to byteaddress translations. Avoid crashes in a2drive
[/branches/alto2/src/emu/cpu/alto2]a2drive.c a2mem.c alto2.c

branches/alto2/src/emu/cpu/alto2/a2drive.c
r26119r26120
4747 */
4848void alto2_cpu_device::drive_get_sector(int unit)
4949{
50   diablo_drive_t *d = m_drive[unit];
5150   if (unit < 0 || unit >= DIABLO_DRIVE_MAX)
5251      fatal(1, "invalid unit %d in call to drive_get_sector()\n", unit);
5352
53   /* uninitialized drive? */
54   diablo_drive_t *d = m_drive[unit];
55   if (!d)
56      return;
57
5458   /* If there's no image, just reset the page number */
5559   if (!d->image) {
5660      d->page = -1;
r26119r26120
171175 */
172176void alto2_cpu_device::expand_sector(int unit, int page)
173177{
174   diablo_drive_t *d = m_drive[unit];
175178   diablo_sector_t *s;
176179   UINT32 *bits;
177180   size_t dst;
r26119r26120
182185   if (page < 0 || page >= DIABLO_DRIVE_PAGES)
183186      return;
184187
188   /* uninitialized drive? */
189   diablo_drive_t *d = m_drive[unit];
190   if (!d)
191      return;
192
185193   /* already expanded this sector? */
186194   if (d->bits[page])
187195      return;
r26119r26120
423431 */
424432void alto2_cpu_device::squeeze_sector(int unit)
425433{
426   diablo_drive_t *d = m_drive[unit];
427434   diablo_sector_t *s;
428435   UINT32 *bits;
429436   size_t src;
r26119r26120
432439   if (unit < 0 || unit >= DIABLO_DRIVE_MAX)
433440      fatal(1, "invalid unit %d in call to squeeze_sector()\n", unit);
434441
442   /* uninitialized drive? */
443   diablo_drive_t *d = m_drive[unit];
444   if (!d)
445      return;
446
435447   if (d->rdfirst >= 0) {
436448      LOG((LOG_DRIVE,0,
437449         "   RD #%d %03d/%d/%02d bit#%-5d (@%03d.%02d) ... bit#%-5d (@%03d.%02d)\n",
r26119r26120
557569 */
558570const char* alto2_cpu_device::drive_description(int unit)
559571{
560   diablo_drive_t *d = m_drive[unit];
561572   if (unit < 0 || unit >= DIABLO_DRIVE_MAX)
562573      fatal(1, "invalid unit %d in call to drive_description()\n", unit);
574
575   /* uninitialized drive? */
576   diablo_drive_t *d = m_drive[unit];
577   if (!d)
578      return "";
579
563580   return d->description;
564581}
565582
r26119r26120
571588 */
572589const char* alto2_cpu_device::drive_basename(int unit)
573590{
574   diablo_drive_t *d = m_drive[unit];
575591   if (unit < 0 || unit >= DIABLO_DRIVE_MAX)
576592      fatal(1, "invalid unit %d in call to drive_description()\n", unit);
593
594   /* uninitialized drive? */
595   diablo_drive_t *d = m_drive[unit];
596   if (!d)
597      return "";
598
577599   return d->basename;
578600}
579601
r26119r26120
587609 */
588610int alto2_cpu_device::drive_unit(int unit)
589611{
590   diablo_drive_t *d = m_drive[unit];
591612   if (unit < 0 || unit >= DIABLO_DRIVE_MAX)
592613      fatal(1, "invalid unit %d in call to drive_unit()\n", unit);
614
615   /* uninitialized drive? */
616   diablo_drive_t *d = m_drive[unit];
617   if (!d)
618      return 0;
619
593620   return d->unit;
594621}
595622
r26119r26120
601628 */
602629attotime alto2_cpu_device::drive_rotation_time(int unit)
603630{
604   diablo_drive_t *d = m_drive[unit];
605631   if (unit < 0 || unit >= DIABLO_DRIVE_MAX)
606632      fatal(1, "invalid unit %d in call to drive_rotation_time()\n", unit);
633
634   /* uninitialized drive? */
635   diablo_drive_t *d = m_drive[unit];
636   if (!d)
637      return attotime::never;
638
607639   return d->rotation_time;
608640}
609641
r26119r26120
615647 */
616648attotime alto2_cpu_device::drive_bit_time(int unit)
617649{
618   diablo_drive_t *d = m_drive[unit];
619650   if (unit < 0 || unit >= DIABLO_DRIVE_MAX)
620651      fatal(1, "invalid unit %d in call to drive_bit_time()\n", unit);
652
653   /* uninitialized drive? */
654   diablo_drive_t *d = m_drive[unit];
655   if (!d)
656      return attotime::never;
657
621658   return d->bit_time;
622659}
623660
r26119r26120
629666 */
630667int alto2_cpu_device::drive_seek_read_write_0(int unit)
631668{
632   diablo_drive_t *d = m_drive[unit];
633669   if (unit < 0 || unit >= DIABLO_DRIVE_MAX)
634670      fatal(1, "invalid unit %d in call to drive_seek_read_write_0()\n", unit);
671
672   /* uninitialized drive? */
673   diablo_drive_t *d = m_drive[unit];
674   if (!d)
675      return 0;
676
635677   return d->s_r_w_0;
636678}
637679
r26119r26120
643685 */
644686int alto2_cpu_device::drive_ready_0(int unit)
645687{
646   diablo_drive_t *d = m_drive[unit];
647688   if (unit < 0 || unit >= DIABLO_DRIVE_MAX)
648689      fatal(1, "invalid unit %d in call to drive_ready_0()\n", unit);
690
691   /* uninitialized drive? */
692   diablo_drive_t *d = m_drive[unit];
693   if (!d)
694      return 0;
695
649696   return d->ready_0;
650697}
651698
r26119r26120
659706 */
660707int alto2_cpu_device::drive_sector_mark_0(int unit)
661708{
662   diablo_drive_t *d = m_drive[unit];
663709   if (unit < 0 || unit >= DIABLO_DRIVE_MAX)
664710      fatal(1, "invalid unit %d in call to drive_sector_mark_0()\n", unit);
711
712   /* uninitialized drive? */
713   diablo_drive_t *d = m_drive[unit];
714   if (!d)
715      return 0;
716
665717   /* no sector marks while seeking (?) */
666718   if (d->s_r_w_0)
667719      return 1;
720
668721   /* return the sector mark */
669722   return d->sector_mark_0;
670723}
r26119r26120
677730 */
678731int alto2_cpu_device::drive_addx_acknowledge_0(int unit)
679732{
680   diablo_drive_t *d = m_drive[unit];
681733   if (unit < 0 || unit >= DIABLO_DRIVE_MAX)
682734      fatal(1, "invalid unit %d in call to drive_addx_acknowledge_0()\n", unit);
735
736   /* uninitialized drive? */
737   diablo_drive_t *d = m_drive[unit];
738   if (!d)
739      return 0;
740
683741   return d->addx_acknowledge_0;
684742}
685743
r26119r26120
691749 */
692750int alto2_cpu_device::drive_log_addx_interlock_0(int unit)
693751{
694   diablo_drive_t *d = m_drive[unit];
695752   if (unit < 0 || unit >= DIABLO_DRIVE_MAX)
696753      fatal(1, "invalid unit %d in call to drive_log_addx_interlock_0()\n", unit);
754
755   /* uninitialized drive? */
756   diablo_drive_t *d = m_drive[unit];
757   if (!d)
758      return 0;
759
697760   return d->log_addx_interlock_0;
698761}
699762
r26119r26120
705768 */
706769int alto2_cpu_device::drive_seek_incomplete_0(int unit)
707770{
708   diablo_drive_t *d = m_drive[unit];
709771   if (unit < 0 || unit >= DIABLO_DRIVE_MAX)
710772      fatal(1, "invalid unit %d in call to drive_addx_acknowledge_0()\n", unit);
773
774   /* uninitialized drive? */
775   diablo_drive_t *d = m_drive[unit];
776   if (!d)
777      return 0;
778
711779   return d->seek_incomplete_0;
712780}
713781
r26119r26120
721789 */
722790int alto2_cpu_device::drive_cylinder(int unit)
723791{
724   diablo_drive_t *d = m_drive[unit];
725792   if (unit < 0 || unit >= DIABLO_DRIVE_MAX)
726793      fatal(1, "invalid unit %d in call to drive_cylinder()\n", unit);
794
795   /* uninitialized drive? */
796   diablo_drive_t *d = m_drive[unit];
797   if (!d)
798      return DIABLO_DRIVE_CYLINDER_MASK;
799
727800   return d->cylinder ^ DIABLO_DRIVE_CYLINDER_MASK;
728801}
729802
r26119r26120
737810 */
738811int alto2_cpu_device::drive_head(int unit)
739812{
740   diablo_drive_t *d = m_drive[unit];
741813   if (unit < 0 || unit >= DIABLO_DRIVE_MAX)
742814      fatal(1, "invalid unit %d in call to drive_head()\n", unit);
815
816   /* uninitialized drive? */
817   diablo_drive_t *d = m_drive[unit];
818   if (!d)
819      return DIABLO_DRIVE_HEAD_MASK;
820
743821   return d->head ^ DIABLO_DRIVE_HEAD_MASK;
744822}
745823
r26119r26120
756834 */
757835int alto2_cpu_device::drive_sector(int unit)
758836{
759   diablo_drive_t *d = m_drive[unit];
760837   if (unit < 0 || unit >= DIABLO_DRIVE_MAX)
761838      fatal(1, "invalid unit %d in call to drive_sector()\n", unit);
839
840   /* uninitialized drive? */
841   diablo_drive_t *d = m_drive[unit];
842   if (!d)
843      return DIABLO_DRIVE_SECTOR_MASK;
844
762845   return d->sector ^ DIABLO_DRIVE_SECTOR_MASK;
763846}
764847
r26119r26120
773856 */
774857int alto2_cpu_device::drive_page(int unit)
775858{
776   diablo_drive_t *d = m_drive[unit];
777859   if (unit < 0 || unit >= DIABLO_DRIVE_MAX)
778860      fatal(1, "invalid unit %d in call to drive_page()\n", unit);
861
862   /* uninitialized drive? */
863   diablo_drive_t *d = m_drive[unit];
864   if (!d)
865      return 0;
866
779867   return d->page;
780868}
781869
r26119r26120
787875 */
788876void alto2_cpu_device::drive_select(int unit, int head)
789877{
790   diablo_drive_t *d = m_drive[unit];
791878
792879   if (unit < 0 || unit >= DIABLO_DRIVE_MAX)
793880      fatal(1, "invalid unit %d in call to drive_select()\n", unit);
r26119r26120
799886      printf("select unit:%d head:%d\n", unit, head);
800887   }
801888
889   /* uninitialized drive? */
890   diablo_drive_t *d = m_drive[unit];
891   if (!d)
892      return;
893
802894   if (d->image) {
803895      /* it is ready */
804896      d->ready_0 = 0;
r26119r26120
840932 */
841933void alto2_cpu_device::drive_strobe(int unit, int cylinder, int restore, int strobe)
842934{
843   diablo_drive_t *d = m_drive[unit];
844935   int seekto = restore ? 0 : cylinder;
845936
846937   if (unit < 0 || unit >= DIABLO_DRIVE_MAX)
847938      fatal(1, "invalid unit %d in call to drive_strobe()\n", unit);
848939
940   /* uninitialized drive? */
941   diablo_drive_t *d = m_drive[unit];
942   if (!d)
943      return;
944
849945   if (strobe == 1) {
850946      LOG((LOG_DRIVE,1,"   STROBE end of interlock\n", seekto));
851947      /* deassert the log address interlock */
r26119r26120
9141010 */
9151011void alto2_cpu_device::drive_egate(int unit, int gate)
9161012{
1013   /* uninitialized drive? */
9171014   diablo_drive_t *d = m_drive[unit];
1015   if (!d)
1016      return;
1017
9181018   d->egate_0 = gate;
9191019}
9201020
r26119r26120
9261026 */
9271027void alto2_cpu_device::drive_wrgate(int unit, int gate)
9281028{
1029   /* uninitialized drive? */
9291030   diablo_drive_t *d = m_drive[unit];
1031   if (!d)
1032      return;
1033
9301034   d->wrgate_0 = gate;
9311035}
9321036
r26119r26120
9381042 */
9391043void alto2_cpu_device::drive_rdgate(int unit, int gate)
9401044{
1045   /* uninitialized drive? */
9411046   diablo_drive_t *d = m_drive[unit];
1047   if (!d)
1048      return;
1049
9421050   d->rdgate_0 = gate;
9431051}
9441052
r26119r26120
9621070 */
9631071void alto2_cpu_device::drive_wrdata(int unit, int index, int wrdata)
9641072{
1073   /* uninitialized drive? */
9651074   diablo_drive_t *d = m_drive[unit];
966   UINT32 *bits;
1075   if (!d)
1076      return;
9671077
9681078   if (d->wrgate_0) {
9691079      /* write gate is not asserted (active 0) */
r26119r26120
9791089      return;
9801090   }
9811091
982   bits = d->bits[d->page];
1092   UINT32 *bits = d->bits[d->page];
9831093   if (!bits) {
9841094      /* expand the sector to bits */
9851095      expand_sector(unit, d->page);
r26119r26120
10131123 */
10141124int alto2_cpu_device::drive_rddata(int unit, int index)
10151125{
1016   diablo_drive_t *d = m_drive[unit];
1017   UINT32 *bits;
10181126   int bit = 0;
10191127
1128   /* uninitialized drive? */
1129   diablo_drive_t *d = m_drive[unit];
1130   if (!d)
1131      return bit;
1132
10201133   if (d->rdgate_0) {
10211134      /* read gate is not asserted (active 0) */
10221135      return 0;
r26119r26120
10351148      return 1;
10361149   }
10371150
1038   bits = d->bits[d->page];
1151   UINT32 *bits = d->bits[d->page];
10391152   if (!bits) {
10401153      /* expand the sector to bits */
10411154      expand_sector(unit, d->page);
r26119r26120
10651178 */
10661179int alto2_cpu_device::drive_rdclk(int unit, int index)
10671180{
1068   diablo_drive_t *d = m_drive[unit];
1069   UINT32 *bits;
1070   int clk;
1181   int clk = 0;
10711182
10721183   /* don't read before or beyond the sector */
10731184   if (index < 0 || index >= drive_bits_per_sector())
10741185      return 1;
10751186
1187   /* uninitialized drive? */
1188   diablo_drive_t *d = m_drive[unit];
1189   if (!d)
1190      return clk;
1191
10761192   /* no clock while sector mark is low (?) */
10771193   if (0 == d->sector_mark_0)
10781194      return 1;
r26119r26120
10821198      return 1;
10831199   }
10841200
1085   bits = d->bits[d->page];
1201   UINT32 *bits = d->bits[d->page];
10861202   if (!bits) {
10871203      /* expand the sector to bits */
10881204      expand_sector(unit, d->page);
r26119r26120
11141230 */
11151231int alto2_cpu_device::debug_read_sync(int unit, int page, int offs)
11161232{
1117   diablo_drive_t *d = m_drive[unit];
1118   UINT32 *bits;
1119
11201233   if (unit < 0 || unit > 1)
11211234      return 0;
11221235
r26119r26120
11281241   if (page < 0 || page >= DIABLO_DRIVE_CYLINDERS * DIABLO_DRIVE_HEADS * DIABLO_DRIVE_SPT)
11291242      return 0;
11301243
1131   bits = d->bits[page];
1244   /* uninitialized drive? */
1245   diablo_drive_t *d = m_drive[unit];
1246   if (!d)
1247      return 0;
1248
1249   UINT32 *bits = d->bits[page];
11321250   if (!bits) {
11331251      /* expand the sector to bits */
11341252      expand_sector(unit, page);
r26119r26120
11601278 */
11611279int alto2_cpu_device::debug_read_sec(int unit, int page, int offs)
11621280{
1163   diablo_drive_t *d = m_drive[unit];
1164   UINT32 *bits;
11651281   int i, clks, word;
11661282
11671283   if (unit < 0 || unit > 1)
r26119r26120
11751291   if (page < 0 || page >= DIABLO_DRIVE_CYLINDERS * DIABLO_DRIVE_HEADS * DIABLO_DRIVE_SPT)
11761292      return 0177777;
11771293
1178   bits = d->bits[page];
1294   /* uninitialized drive? */
1295   diablo_drive_t *d = m_drive[unit];
1296   if (!d)
1297      return 0;
1298
1299   UINT32 *bits = d->bits[page];
11791300   if (!bits) {
11801301      /* expand the sector to bits */
11811302      expand_sector(unit, page);
r26119r26120
12061327{
12071328   (void)ptr;
12081329   int unit = m_unit_selected;
1209   diablo_drive_t *d = m_drive[unit];
12101330
1211   LOG((LOG_DRIVE,5, "   next sector (unit #%d sector %d)\n", unit, d->sector));
1212   (void)d;
1213
12141331   switch (arg) {
12151332   case 0:
12161333      m_sector_timer->adjust(DIABLO_SECTOR_MARK_PULSE_PRE, 1);
r26119r26120
12381355 */
12391356void alto2_cpu_device::sector_mark_1(int unit)
12401357{
1358   /* uninitialized drive? */
12411359   diablo_drive_t *d = m_drive[unit];
1360   if (!d)
1361      return;
12421362
12431363   LOG((LOG_DRIVE,5, "   sector mark 1 (unit #%d sector %d)\n", unit, d->sector));
12441364   /* set sector mark to 1 */
r26119r26120
12521372 */
12531373void alto2_cpu_device::sector_mark_0(int unit)
12541374{
1375   /* uninitialized drive? */
12551376   diablo_drive_t *d = m_drive[unit];
1377   if (!d)
1378      return;
12561379
12571380   LOG((LOG_DRIVE,5,"   sector mark 0 (unit #%d sector %d)\n", unit, d->sector));
12581381
branches/alto2/src/emu/cpu/alto2/a2mem.c
r26119r26120
666666
667667   base_addr = m_mem.mar & 0177777;
668668   if (base_addr >= ALTO2_IO_PAGE_BASE) {
669      m_mem.md = ((*this).*mmio_read_fn[base_addr - ALTO2_IO_PAGE_BASE])(base_addr);
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);
670672      LOG((LOG_MEM,6,"   MD = MMIO[%#o] (%#o)\n", base_addr, m_mem.md));
671673      m_mem.access = ALTO2_MEM_NONE;
672674#if   ALTO2_DEBUG
r26119r26120
720722
721723   base_addr = m_mem.mar & 0177777;
722724   if (base_addr >= ALTO2_IO_PAGE_BASE) {
725      offs_t offset = base_addr - ALTO2_IO_PAGE_BASE;
723726      LOG((LOG_MEM,6, "   MMIO[%#o] = MD (%#o)\n", base_addr, m_mem.md));
724      ((*this).*mmio_write_fn[base_addr - ALTO2_IO_PAGE_BASE])(base_addr, m_mem.md);
727      if (mmio_write_fn[offset])
728         ((*this).*mmio_write_fn[offset])(base_addr, m_mem.md);
725729      m_mem.access = ALTO2_MEM_NONE;
726730#if   ALTO2_DEBUG
727731      watch_write(m_mem.mar, m_mem.md);
r26119r26120
787791   int base_addr = addr & 0177777;
788792   int data;
789793   if (base_addr >= ALTO2_IO_PAGE_BASE) {
790      data = ((*this).*mmio_read_fn[base_addr - ALTO2_IO_PAGE_BASE])(addr);
794      offs_t offset = base_addr - ALTO2_IO_PAGE_BASE;
795      if (mmio_read_fn[offset])
796         data = ((*this).*mmio_read_fn[offset])(addr);
791797   } else {
792798      data = (addr & ALTO2_MEM_ODD) ? GET_ODD(m_mem.ram[addr/2]) : GET_EVEN(m_mem.ram[addr/2]);
793799   }
r26119r26120
804810{
805811   int base_addr = addr & 0177777;
806812   if (base_addr >= ALTO2_IO_PAGE_BASE) {
807      ((*this).*mmio_write_fn[base_addr - ALTO2_IO_PAGE_BASE])(addr, data);
813      offs_t offset = base_addr - ALTO2_IO_PAGE_BASE;
814      if (mmio_write_fn[offset])
815         ((*this).*mmio_write_fn[offset])(addr, data);
808816   } else if (addr & ALTO2_MEM_ODD) {
809817      PUT_ODD(m_mem.ram[addr/2], data);
810818   } else {
branches/alto2/src/emu/cpu/alto2/alto2.c
r26119r26120
19651965      LOG((LOG_CPU,0,"invalid address (%06o)\n", val));
19661966      return;
19671967   }
1968   val = m_ucode->read_dword(addr) ^ ALTO2_UCODE_INVERTED;
1968   val = m_ucode->read_dword(m_ucode->address_to_byte(addr)) ^ ALTO2_UCODE_INVERTED;
19691969   if (GET_CRAM_HALFSEL(m_cram_addr)) {
19701970      val = val >> 16;
19711971      LOG((LOG_CPU,0,"upper:%06o\n", val));
r26119r26120
20022002      return;
20032003   }
20042004   LOG((LOG_CPU,0,"\n"));
2005   m_ucode->write_dword(addr, ((m_m << 16) | m_alu) ^ ALTO2_UCODE_INVERTED);
2005   m_ucode->write_dword(m_ucode->address_to_byte(addr), ((m_m << 16) | m_alu) ^ ALTO2_UCODE_INVERTED);
20062006}
20072007
20082008#if   USE_ALU_74181
r26119r26120
24132413
24142414      /* next instruction's mpc */
24152415      m_mpc = m_next;
2416      m_mir = m_ucode->read_dword(m_mpc);
2416      m_mir = m_ucode->read_dword(m_ucode->address_to_byte(m_mpc));
24172417      m_rsel = MIR_RSEL(m_mir);
24182418      m_next = MIR_NEXT(m_mir) | m_next2;
2419      m_next2 = A2_GET32(m_ucode->read_dword(m_next), 32, NEXT0, NEXT9) | (m_next2 & ~ALTO2_UCODE_PAGE_MASK);
2419      m_next2 = A2_GET32(m_ucode->read_dword(m_ucode->address_to_byte(m_next)), 32, NEXT0, NEXT9) | (m_next2 & ~ALTO2_UCODE_PAGE_MASK);
24202420      aluf = MIR_ALUF(m_mir);
24212421      bs = MIR_BS(m_mir);
24222422      f1 = MIR_F1(m_mir);

Previous 199869 Revisions Next


© 1997-2024 The MAME Team