]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Don't count DMA transfers as CPU idle.
authorToni Wilen <twilen@winuae.net>
Sat, 30 Sep 2017 17:02:00 +0000 (20:02 +0300)
committerToni Wilen <twilen@winuae.net>
Sat, 30 Sep 2017 17:02:00 +0000 (20:02 +0300)
a2091.cpp
custom.cpp
filesys.cpp
hardfile.cpp
include/newcpu.h
ncr9x_scsi.cpp
newcpu.cpp
scsi.cpp

index 60c57d721819557c3dfc654f8500368afdffce40..61c1b694d611a8abec6fe90c075a773a4fe1e287 100644 (file)
--- a/a2091.cpp
+++ b/a2091.cpp
@@ -889,6 +889,7 @@ static bool do_dma(struct wd_state *wd)
 {
        struct scsi_data *scsi = wd->wc.scsi;
        wd->wc.wd_data_avail = 0;
+       m68k_cancel_idle();
        if (scsi->direction == 0)
                write_log (_T("%s DMA but no data!?\n"), WD33C93);
        switch (wd->dmac_type)
index af4f710c3fa7212181b05e133263dc6cd89601ee..79327be952dbff623cf0f1902669def01f40a321 100644 (file)
@@ -7806,7 +7806,11 @@ static void vsync_handler_pre (void)
 #if 1
        if (currprefs.m68k_speed < 0) {
                if (regs.stopped) {
-                       cpu_stopped_lines += maxvpos - cpu_last_stop_vpos;
+                       if (cpu_last_stop_vpos >= 0) {
+                               cpu_stopped_lines += maxvpos - cpu_last_stop_vpos;
+                       } else {
+                               cpu_stopped_lines = 0;
+                       }
                }
                int mv = 12 - currprefs.cpu_idle / 15;
                if (mv >= 1 && mv <= 11) {
index e0092f82ef77c9795f1de66c0b41513a5dffcbc1..d83d8386d784223c89229add22cd1d31d3af9f2e 100644 (file)
@@ -6800,6 +6800,8 @@ end:
 
 static int handle_packet(TrapContext *ctx, Unit *unit, dpacket *pck, uae_u32 msg, int isvolume)
 {
+       bool noidle = false;
+       int ret = 1;
        uae_s32 type = GET_PCK_TYPE (pck);
        PUT_PCK_RES2 (pck, 0);
 
@@ -6827,13 +6829,13 @@ static int handle_packet(TrapContext *ctx, Unit *unit, dpacket *pck, uae_u32 msg
        case ACTION_DISK_INFO: action_disk_info (ctx, unit, pck); break;
        case ACTION_INFO: action_info (ctx, unit, pck); break;
        case ACTION_EXAMINE_OBJECT: action_examine_object (ctx, unit, pck); break;
-       case ACTION_EXAMINE_NEXT: action_examine_next (ctx, unit, pck, false); break;
+       case ACTION_EXAMINE_NEXT: noidle = true; action_examine_next (ctx, unit, pck, false); break;
        case ACTION_FIND_INPUT: action_find_input (ctx, unit, pck); break;
        case ACTION_FIND_WRITE: action_find_write (ctx, unit, pck); break;
        case ACTION_FIND_OUTPUT: action_find_output (ctx, unit, pck); break;
        case ACTION_END: action_end (ctx, unit, pck); break;
-       case ACTION_READ: action_read (ctx, unit, pck); break;
-       case ACTION_WRITE: action_write (ctx, unit, pck); break;
+       case ACTION_READ: noidle = true; action_read(ctx, unit, pck); break;
+       case ACTION_WRITE: noidle = true; action_write (ctx, unit, pck); break;
        case ACTION_SEEK: action_seek (ctx, unit, pck); break;
        case ACTION_SET_PROTECT: action_set_protect (ctx, unit, pck); break;
        case ACTION_SET_COMMENT: action_set_comment (ctx, unit, pck); break;
@@ -6860,9 +6862,9 @@ static int handle_packet(TrapContext *ctx, Unit *unit, dpacket *pck, uae_u32 msg
        case ACTION_PARENT_FH: action_parent_fh (ctx, unit, pck); break;
        case ACTION_ADD_NOTIFY: action_add_notify (ctx, unit, pck); break;
        case ACTION_REMOVE_NOTIFY: action_remove_notify (ctx, unit, pck); break;
-       case ACTION_EXAMINE_ALL: return action_examine_all (ctx, unit, pck);
-       case ACTION_EXAMINE_ALL_END: return action_examine_all_end (ctx, unit, pck);
-       case ACTION_LOCK_RECORD: return action_lock_record (ctx, unit, pck, msg); break;
+       case ACTION_EXAMINE_ALL: noidle = true; ret = action_examine_all(ctx, unit, pck); break;
+       case ACTION_EXAMINE_ALL_END: ret = action_examine_all_end(ctx, unit, pck); break;
+       case ACTION_LOCK_RECORD: ret = action_lock_record (ctx, unit, pck, msg); break;
        case ACTION_FREE_RECORD: action_free_record (ctx, unit, pck); break;
        case ACTION_READ_LINK: action_read_link (ctx, unit, pck); break;
        case ACTION_MAKE_LINK: action_make_link (ctx, unit, pck); break;
@@ -6878,9 +6880,9 @@ static int handle_packet(TrapContext *ctx, Unit *unit, dpacket *pck, uae_u32 msg
        case ACTION_SEEK64: action_seek64(ctx, unit, pck); break;
        case ACTION_SET_FILE_SIZE64: action_set_file_size64(ctx, unit, pck); break;
        case ACTION_EXAMINE_OBJECT64: action_examine_object64(ctx, unit, pck); break;
-       case ACTION_EXAMINE_NEXT64: action_examine_next(ctx, unit, pck, true); break;
+       case ACTION_EXAMINE_NEXT64: noidle = true; action_examine_next(ctx, unit, pck, true); break;
        case ACTION_EXAMINE_FH64: action_examine_fh(ctx, unit, pck, true); break;
-       case ACTION_LOCK_RECORD64: return action_lock_record64(ctx, unit, pck, msg); break;
+       case ACTION_LOCK_RECORD64: ret = action_lock_record64(ctx, unit, pck, msg); break;
        case ACTION_FREE_RECORD64: action_free_record64(ctx, unit, pck); break;
 
                /* unsupported packets */
@@ -6891,7 +6893,10 @@ static int handle_packet(TrapContext *ctx, Unit *unit, dpacket *pck, uae_u32 msg
                write_log (_T("FILESYS: UNKNOWN PACKET %x\n"), type);
                return 0;
        }
-       return 1;
+       if (noidle) {
+               m68k_cancel_idle();
+       }
+       return ret;
 }
 
 #ifdef UAE_FILESYS_THREADS
index feb3f0db9af958f4618f030a8fc7053eb5e14038..971c88019715cb538225462c53c6719c3d4700aa 100644 (file)
@@ -1095,6 +1095,7 @@ int hdf_write(struct hardfiledata *hfd, void *buffer, uae_u64 offset, int len)
 
 static uae_u64 cmd_readx(struct hardfiledata *hfd, uae_u8 *dataptr, uae_u64 offset, uae_u64 len)
 {
+       m68k_cancel_idle();
        gui_flicker_led (LED_HD, hfd->unitnum, 1);
        return hdf_read (hfd, dataptr, offset, len);
 }
@@ -1126,6 +1127,7 @@ static uae_u64 cmd_read(TrapContext *ctx, struct hardfiledata *hfd, uaecptr data
 }
 static uae_u64 cmd_writex(struct hardfiledata *hfd, uae_u8 *dataptr, uae_u64 offset, uae_u64 len)
 {
+       m68k_cancel_idle();
        gui_flicker_led (LED_HD, hfd->unitnum, 2);
        return hdf_write (hfd, dataptr, offset, len);
 }
index 464f0c2fd6898fb95697916a8387177721acac8c..e37901555fadde658b013a283e1eeb94839d70b9 100644 (file)
@@ -595,6 +595,7 @@ extern void REGPARAM3 x_put_bitfield (uae_u32 dst, uae_u32 bdata[2], uae_u32 val
 
 extern void m68k_setstopped (void);
 extern void m68k_resumestopped (void);
+extern void m68k_cancel_idle(void);
 
 extern uae_u32 REGPARAM3 get_disp_ea_020 (uae_u32 base, int idx) REGPARAM;
 extern uae_u32 REGPARAM3 get_bitfield (uae_u32 src, uae_u32 bdata[2], uae_s32 offset, int width) REGPARAM;
index 92d60517c9847ff9c4fcca62ddd889b79cb5b102..ab60175eac91988ff2d2caa79682d5fdc81873d2 100644 (file)
@@ -438,6 +438,7 @@ static int masoboshi_dma_read(void *opaque, uint8_t *buf, int len)
 {
        struct ncr9x_state *ncr = (struct ncr9x_state*)opaque;
        if (ncr->dma_on) {
+               m68k_cancel_idle();
                while (len > 0) {
                        uae_u16 v = get_word(ncr->dma_ptr & ~1);
                        *buf++ = v >> 8;
@@ -462,6 +463,7 @@ static int masoboshi_dma_write(void *opaque, uint8_t *buf, int len)
 {
        struct ncr9x_state *ncr = (struct ncr9x_state*)opaque;
        if (ncr->dma_on) {
+               m68k_cancel_idle();
                while (len > 0) {
                        uae_u16 v;
                        v = *buf++;
@@ -494,6 +496,7 @@ static int fastlane_dma_read(void *opaque, uint8_t *buf, int len)
                write_log(_T("fastlane_dma_read mismatched direction!\n"));
                return -1;
        }
+       m68k_cancel_idle();
        while (len > 0) {
                uae_u16 v = get_word(ncr->dma_ptr & ~1);
                *buf++ = v >> 8;
@@ -513,6 +516,7 @@ static int fastlane_dma_write(void *opaque, uint8_t *buf, int len)
                write_log(_T("fastlane_dma_write mismatched direction!\n"));
                return -1;
        }
+       m68k_cancel_idle();
        while (len > 0) {
                uae_u16 v;
                v = *buf++;
@@ -535,6 +539,7 @@ static int cyberstorm_mk1_mk2_dma_read(void *opaque, uint8_t *buf, int len)
                write_log(_T("cyberstorm_dma_read mismatched direction!\n"));
                return -1;
        }
+       m68k_cancel_idle();
        while (len > 0) {
                uae_u16 v = get_word(ncr->dma_ptr & ~1);
                *buf++ = v >> 8;
@@ -554,6 +559,7 @@ static int cyberstorm_mk1_mk2_dma_write(void *opaque, uint8_t *buf, int len)
                write_log(_T("cyberstorm_dma_write mismatched direction!\n"));
                return -1;
        }
+       m68k_cancel_idle();
        while (len > 0) {
                uae_u16 v;
                v = *buf++;
@@ -576,6 +582,7 @@ static int blizzard_dma_read(void *opaque, uint8_t *buf, int len)
                write_log(_T("blizzard_dma_read mismatched direction!\n"));
                return -1;
        }
+       m68k_cancel_idle();
        while (len > 0) {
                uae_u16 v = get_word((ncr->dma_ptr & 0x7fffffff) * 2);
                *buf++ = v >> 8;
@@ -595,6 +602,7 @@ static int blizzard_dma_write(void *opaque, uint8_t *buf, int len)
                write_log(_T("blizzard_dma_write mismatched direction!\n"));
                return -1;
        }
+       m68k_cancel_idle();
        while (len > 0) {
                uae_u16 v;
                v = *buf++;
index 74ab9c2fd4c255fe6fd788374699479743b356a3..40968df3a1c3487be0b2a7b67dc349b91821e02d 100644 (file)
@@ -2593,21 +2593,30 @@ STATIC_INLINE int adjust_cycles (int cycles)
        return cycles + mc;
 }
 
+void m68k_cancel_idle(void)
+{
+       cpu_last_stop_vpos = -1;
+}
+
 static void m68k_set_stop(void)
 {
        if (regs.stopped)
                return;
        regs.stopped = 1;
        set_special(SPCFLAG_STOP);
-       cpu_last_stop_vpos = vpos;
+       if (cpu_last_stop_vpos >= 0) {
+               cpu_last_stop_vpos = vpos;
+       }
 }
 
 static void m68k_unset_stop(void)
 {
        regs.stopped = 0;
        unset_special(SPCFLAG_STOP);
-       cpu_stopped_lines += vpos - cpu_last_stop_vpos;
-       cpu_last_stop_vpos = vpos;
+       if (cpu_last_stop_vpos >= 0) {
+               cpu_stopped_lines += vpos - cpu_last_stop_vpos;
+               cpu_last_stop_vpos = vpos;
+       }
 }
 
 static void activate_trace(void)
@@ -4622,7 +4631,7 @@ static int do_specialties (int cycles)
        unset_special (SPCFLAG_END_COMPILE);   /* has done its job */
 #endif
 
-       while ((regs.spcflags & SPCFLAG_BLTNASTY) && dmaen (DMA_BLITTER) && cycles > 0 && !currprefs.blitter_cycle_exact) {
+       while ((regs.spcflags & SPCFLAG_BLTNASTY) && dmaen (DMA_BLITTER) && cycles > 0 && ((currprefs.waiting_blits && currprefs.cpu_model >= 68020) || !currprefs.blitter_cycle_exact)) {
                int c = blitnasty ();
                if (c < 0) {
                        break;
@@ -5438,8 +5447,8 @@ void cpu_halt (int id)
                        MakeSR ();
                        audio_deactivate ();
                }
-               set_special(SPCFLAG_CHECK);
        }
+       set_special(SPCFLAG_CHECK);
 }
 
 #ifdef CPUEMU_33
index b1bd7937870969b4c365af59b7bb70c9397ecaf9..725fe2701ca2eee602b8fd817a12614ee31e1c9f 100644 (file)
--- a/scsi.cpp
+++ b/scsi.cpp
@@ -1413,6 +1413,8 @@ static void dma_check(struct soft_scsi *ncr)
 {
        if (ncr->dmac_active && ncr->dma_direction) {
 
+               m68k_cancel_idle();
+
                if (ncr->type == NCR5380_SUPRA && ncr->subtype == 4) {
                        if (ncr->dmac_direction != ncr->dma_direction)  {
                                write_log(_T("SUPRADMA: mismatched direction\n"));