From cc266ce39c51595527eeaf2d855bdea06303ba11 Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Sat, 22 Feb 2014 19:04:23 +0200 Subject: [PATCH] 2710b9 --- cpummu.cpp | 1 + custom.cpp | 23 ++++++++++++++--------- drawing.cpp | 4 ++++ filesys.cpp | 2 +- gayle.cpp | 20 ++++++++++++-------- include/cpummu.h | 17 +++++++++++++---- ncr_scsi.cpp | 6 ++++-- od-win32/hardfile_win32.cpp | 4 ++-- od-win32/mman.cpp | 2 ++ od-win32/win32.h | 4 ++-- qemuvga/lsi53c895a.cpp | 36 ++++++++++++++++++++++++++++-------- 11 files changed, 83 insertions(+), 36 deletions(-) diff --git a/cpummu.cpp b/cpummu.cpp index c5c18796..15bcf3d7 100644 --- a/cpummu.cpp +++ b/cpummu.cpp @@ -53,6 +53,7 @@ bool mmu_restart; static bool locked_rmw_cycle; static bool ismoves; bool mmu_ttr_enabled; +int mmu_atc_ways; int mmu040_movem; uaecptr mmu040_movem_ea; diff --git a/custom.cpp b/custom.cpp index 9af2acbb..af803d7b 100644 --- a/custom.cpp +++ b/custom.cpp @@ -4487,12 +4487,12 @@ STATIC_INLINE int use_eventmode (uae_u16 v) { if (!currprefs.cpu_cycle_exact) return 0; + if (currprefs.cachesize || currprefs.m68k_speed < 0) + return 0; if (currprefs.cpu_cycle_exact && currprefs.cpu_model <= 68020) return 1; if (v & 0x8000) return 1; - if (currprefs.cachesize || currprefs.m68k_speed < 0) - return 0; if (event2_count) return 1; return 0; @@ -4541,18 +4541,15 @@ static void send_intena_do (uae_u32 v) { setclr (&intena_internal, v); doint (); - int_recursive++; - rethink_intreq (); - int_recursive--; } static void send_intreq_do (uae_u32 v) { setclr (&intreq_internal, v); - doint (); int_recursive++; rethink_intreq (); int_recursive--; + doint (); } static void INTENA (uae_u16 v) @@ -4560,9 +4557,14 @@ static void INTENA (uae_u16 v) uae_u16 old = intena; setclr (&intena, v); - if (!(v & 0x8000) && old == intena) + if (!(v & 0x8000) && old == intena && intena == intena_internal) return; + + //write_log (_T("%04x %04x %04x %04x\n"), intena, intena_internal, intreq, intreq_internal); + if (use_eventmode (v)) { + if (old == intena && intena == intena_internal) + return; event2_newevent_xx (-1, INT_PROCESSING_DELAY, v, send_intena_do); } else { intena_internal = intena; @@ -4622,7 +4624,7 @@ bool INTREQ_0 (uae_u16 v) intreq_internal = intreq; if (old == intreq && old2 == intreq_internal) return false; - if ((v & 0x8000) || currprefs.cpu_cycle_exact) + if (v & 0x8000) doint (); return true; } @@ -4694,6 +4696,9 @@ void set_picasso_hack_rate (int hz) #endif +/* "Dangerous" blitter D-channel: Writing to memory which is also currently + * read by bitplane DMA + */ static void dcheck_is_blit_dangerous (void) { check_is_blit_dangerous (bplpt, bplcon0_planes, 50 << bplcon0_res); @@ -7764,7 +7769,7 @@ void custom_reset (bool hardreset, bool keyboardreset) if (hardreset) { if (!aga_mode) { - uae_u16 c = (currprefs.chipset_mask & CSMASK_ECS_DENISE) ? 0xfff : 0x000; + uae_u16 c = ((currprefs.chipset_mask & CSMASK_ECS_DENISE) && !(currprefs.chipset_mask & CSMASK_AGA)) ? 0xfff : 0x000; for (i = 0; i < 32; i++) { current_colors.color_regs_ecs[i] = c; current_colors.acolors[i] = getxcolor (c); diff --git a/drawing.cpp b/drawing.cpp index c1476799..0e463f90 100644 --- a/drawing.cpp +++ b/drawing.cpp @@ -2563,12 +2563,14 @@ static void center_image (void) visible_left_border = max_diwstop - w - (max_diwstop - min_diwstart - w) / 2; visible_left_border &= ~((xshift (1, lores_shift)) - 1); +#if 0 /* Would the old value be good enough? If so, leave it as it is if we want to * be clever. */ if (currprefs.gfx_xcenter == 2) { if (center_reset || (visible_left_border < prev_x_adjust && prev_x_adjust < min_diwstart && min_diwstart - visible_left_border <= 32)) visible_left_border = prev_x_adjust; } +#endif } else if (gfxvidinfo.drawbuffer.extrawidth) { visible_left_border = max_diwlastword - w; if (gfxvidinfo.drawbuffer.extrawidth > 0) @@ -2603,12 +2605,14 @@ static void center_image (void) else thisframe_y_adjust = thisframe_first_drawn_line + ((thisframe_last_drawn_line - thisframe_first_drawn_line) - max_drawn_amiga_line) / 2; +#if 0 /* Would the old value be good enough? If so, leave it as it is if we want to * be clever. */ if (currprefs.gfx_ycenter == 2 && thisframe_y_adjust != prev_y_adjust) { if (center_reset || (prev_y_adjust <= thisframe_first_drawn_line && prev_y_adjust + max_drawn_amiga_line > thisframe_last_drawn_line)) thisframe_y_adjust = prev_y_adjust; } +#endif } /* Make sure the value makes sense */ diff --git a/filesys.cpp b/filesys.cpp index ac86ab00..5d7e0749 100644 --- a/filesys.cpp +++ b/filesys.cpp @@ -7287,7 +7287,7 @@ static uae_u32 REGPARAM2 filesys_dev_storeinfo (TrapContext *context) if (ci->dostype) { // forced dostype? put_long (parmpacket + 80, ci->dostype); /* dostype */ } else if (hdf_read (&uip[unit_no].hf, buf, 0, sizeof buf)) { - uae_u32 dt = get_long (rl (buf)); + uae_u32 dt = rl (buf); if (dt != 0x00000000 && dt != 0xffffffff) put_long (parmpacket + 80, dt); } diff --git a/gayle.cpp b/gayle.cpp index dc60dcd3..3625914f 100644 --- a/gayle.cpp +++ b/gayle.cpp @@ -196,7 +196,8 @@ struct ide_hdf int data_multi; int direction; // 0 = read, 1 = write bool intdrq; - int lba48; + bool lba48; + bool lba48cmd; uae_u8 multiple_mode; int irq_delay; int irq; @@ -663,7 +664,7 @@ static void ide_set_features (struct ide_hdf *ide) static void get_lbachs (struct ide_hdf *ide, uae_u64 *lbap, unsigned int *cyl, unsigned int *head, unsigned int *sec) { - if (ide->lba48 && (ide->regs.ide_select & 0x40)) { + if (ide->lba48 && ide->lba48cmd && (ide->regs.ide_select & 0x40)) { uae_u64 lba; lba = (ide->regs.ide_hcyl << 16) | (ide->regs.ide_lcyl << 8) | ide->regs.ide_sector; lba |= ((ide->regs.ide_hcyl2 << 16) | (ide->regs.ide_lcyl2 << 8) | ide->regs.ide_sector2) << 24; @@ -682,14 +683,14 @@ static void get_lbachs (struct ide_hdf *ide, uae_u64 *lbap, unsigned int *cyl, u static int get_nsec (struct ide_hdf *ide) { - if (ide->lba48) + if (ide->lba48 && ide->lba48cmd) return (ide->regs.ide_nsector == 0 && ide->regs.ide_nsector2 == 0) ? 65536 : (ide->regs.ide_nsector2 * 256 + ide->regs.ide_nsector); else return ide->regs.ide_nsector == 0 ? 256 : ide->regs.ide_nsector; } static int dec_nsec (struct ide_hdf *ide, int v) { - if (ide->lba48) { + if (ide->lba48 && ide->lba48cmd) { uae_u16 nsec; nsec = ide->regs.ide_nsector2 * 256 + ide->regs.ide_nsector; ide->regs.ide_nsector -= v; @@ -704,7 +705,7 @@ static int dec_nsec (struct ide_hdf *ide, int v) static void put_lbachs (struct ide_hdf *ide, uae_u64 lba, unsigned int cyl, unsigned int head, unsigned int sec, unsigned int inc) { - if (ide->lba48) { + if (ide->lba48 && ide->lba48cmd) { lba += inc; ide->regs.ide_hcyl = (lba >> 16) & 0xff; ide->regs.ide_lcyl = (lba >> 8) & 0xff; @@ -915,7 +916,7 @@ static void do_process_rw_command (struct ide_hdf *ide) get_lbachs (ide, &lba, &cyl, &head, &sec); nsec = get_nsec (ide); if (IDE_LOG > 1) - write_log (_T("IDE%d off=%d, nsec=%d (%d) lba%d\n"), ide->num, (uae_u32)lba, nsec, ide->multiple_mode, ide->lba48 ? 48 : 28); + write_log (_T("IDE%d off=%d, nsec=%d (%d) lba48=%d\n"), ide->num, (uae_u32)lba, nsec, ide->multiple_mode, ide->lba48 + ide->lba48cmd); if (nsec * ide->blocksize > ide->hdhfd.size - lba * ide->blocksize) { nsec = (ide->hdhfd.size - lba * ide->blocksize) / ide->blocksize; if (IDE_LOG > 1) @@ -955,6 +956,7 @@ static void ide_read_sectors (struct ide_hdf *ide, int flags) uae_u64 lba; int multi = flags & 1; + ide->lba48cmd = (flags & 2) != 0; if (multi && ide->multiple_mode == 0) { ide_fail (ide); return; @@ -969,7 +971,7 @@ static void ide_read_sectors (struct ide_hdf *ide, int flags) return; } if (IDE_LOG > 0) - write_log (_T("IDE%d read off=%d, sec=%d (%d) lba%d\n"), ide->num, (uae_u32)lba, nsec, ide->multiple_mode, ide->lba48 ? 48 : 28); + write_log (_T("IDE%d read off=%d, sec=%d (%d) lba48=%d\n"), ide->num, (uae_u32)lba, nsec, ide->multiple_mode, ide->lba48 + ide->lba48cmd); ide->data_multi = multi ? ide->multiple_mode : 1; ide->data_offset = 0; ide->data_size = nsec * ide->blocksize; @@ -984,6 +986,7 @@ static void ide_write_sectors (struct ide_hdf *ide, int flags) uae_u64 lba; int multi = flags & 1; + ide->lba48cmd = (flags & 2) != 0; if (multi && ide->multiple_mode == 0) { ide_fail (ide); return; @@ -998,7 +1001,7 @@ static void ide_write_sectors (struct ide_hdf *ide, int flags) return; } if (IDE_LOG > 0) - write_log (_T("IDE%d write off=%d, sec=%d (%d) lba%d\n"), ide->num, (uae_u32)lba, nsec, ide->multiple_mode, ide->lba48 ? 48 : 28); + write_log (_T("IDE%d write off=%d, sec=%d (%d) lba48=%d\n"), ide->num, (uae_u32)lba, nsec, ide->multiple_mode, ide->lba48 + ide->lba48cmd); if (nsec * ide->blocksize > ide->hdhfd.size - lba * ide->blocksize) nsec = (ide->hdhfd.size - lba * ide->blocksize) / ide->blocksize; if (nsec <= 0) { @@ -1023,6 +1026,7 @@ static void ide_do_command (struct ide_hdf *ide, uae_u8 cmd) write_log (_T("**** IDE%d command %02X\n"), ide->num, cmd); ide->regs.ide_status &= ~ (IDE_STATUS_DRDY | IDE_STATUS_DRQ | IDE_STATUS_ERR); ide->regs.ide_error = 0; + ide->lba48cmd = false; if (ide->atapi) { diff --git a/include/cpummu.h b/include/cpummu.h index 93b1f88b..2dfe7fdb 100644 --- a/include/cpummu.h +++ b/include/cpummu.h @@ -189,6 +189,9 @@ extern uae_u32 mmu_is_super; extern uae_u32 mmu_tagmask, mmu_pagemask; extern struct mmu_atc_line mmu_atc_array[ATC_TYPE][ATC_WAYS][ATC_SLOTS]; +/* Last matched ATC index, next lookup starts from this index as an optimization */ +extern int mmu_atc_ways; + /* * mmu access is a 4 step process: * if mmu is not enabled just read physical @@ -199,7 +202,7 @@ extern struct mmu_atc_line mmu_atc_array[ATC_TYPE][ATC_WAYS][ATC_SLOTS]; static ALWAYS_INLINE bool mmu_lookup(uaecptr addr, bool data, bool write, struct mmu_atc_line **cl) { - int way,index; + int way, i, index; static int way_miss=0; uae_u32 tag = (mmu_is_super | (addr >> 1)) & mmu_tagmask; @@ -207,7 +210,8 @@ static ALWAYS_INLINE bool mmu_lookup(uaecptr addr, bool data, bool write, index=(addr & 0x0001E000)>>13; else index=(addr & 0x0000F000)>>12; - for (way=0;way> 1)) & mmu_tagmask; @@ -237,7 +243,8 @@ static ALWAYS_INLINE bool mmu_user_lookup(uaecptr addr, bool super, bool data, index=(addr & 0x0001E000)>>13; else index=(addr & 0x0000F000)>>12; - for (way=0;way= 0x41000000) + value = 0x40000000; value >>= 16; chipmem_wput (regs.regs[11] + 0x20, value); chipmem_wput (regs.regs[11] + 0x28, value); @@ -334,7 +336,7 @@ static void REGPARAM2 ncr_bput (uaecptr addr, uae_u32 b) ncr_bput2 (addr, b); } -addrbank ncr_bank = { +static addrbank ncr_bank = { ncr_lget, ncr_wget, ncr_bget, ncr_lput, ncr_wput, ncr_bput, default_xlate, default_check, NULL, _T("A4091"), diff --git a/od-win32/hardfile_win32.cpp b/od-win32/hardfile_win32.cpp index aba44a76..0f3ac7ba 100644 --- a/od-win32/hardfile_win32.cpp +++ b/od-win32/hardfile_win32.cpp @@ -75,11 +75,11 @@ struct uae_driveinfo { * - block 0 is zeroed */ -int harddrive_dangerous = 0x1234dead; +int harddrive_dangerous; // = 0x1234dead; // test only! int do_rdbdump; static struct uae_driveinfo uae_drives[MAX_FILESYSTEM_UNITS]; -#if 0 +#if 1 static void fixdrive (struct hardfiledata *hfd) { uae_u8 data[512]; diff --git a/od-win32/mman.cpp b/od-win32/mman.cpp index 8a56e37b..fc61a6cb 100644 --- a/od-win32/mman.cpp +++ b/od-win32/mman.cpp @@ -146,6 +146,8 @@ bool preinit_shm (void) #endif } #endif + if (maxmem > max_allowed_mman) + max_allowed_mman = maxmem; memstats.dwLength = sizeof(memstats); GlobalMemoryStatus(&memstats); diff --git a/od-win32/win32.h b/od-win32/win32.h index ea459ba0..0ac8f272 100644 --- a/od-win32/win32.h +++ b/od-win32/win32.h @@ -19,11 +19,11 @@ #define LANG_DLL 1 #if WINUAEPUBLICBETA -#define WINUAEBETA _T("8") +#define WINUAEBETA _T("9") #else #define WINUAEBETA _T("") #endif -#define WINUAEDATE MAKEBD(2014, 2, 16) +#define WINUAEDATE MAKEBD(2014, 2, 22) #define WINUAEEXTRA _T("") //#define WINUAEEXTRA _T("AmiKit Preview") //#define WINUAEEXTRA _T("Amiga Forever Edition") diff --git a/qemuvga/lsi53c895a.cpp b/qemuvga/lsi53c895a.cpp index e5799ed9..162af4eb 100644 --- a/qemuvga/lsi53c895a.cpp +++ b/qemuvga/lsi53c895a.cpp @@ -159,6 +159,15 @@ do { write_log("lsi_scsi: error: " fmt , ## __VA_ARGS__);} while (0) #define LSI_CCNTL1_DDAC 0x08 #define LSI_CCNTL1_ZMOD 0x80 +#define LSI_SBCL_IO 0x01 +#define LSI_SBCL_CD 0x02 +#define LSI_SBCL_MSG 0x04 +#define LSI_SBCL_ATN 0x08 +#define LSI_SBCL_SEL 0x10 +#define LSI_SBCL_BSY 0x20 +#define LSI_SBCL_ACK 0x40 +#define LSI_SBCL_REQ 0x80 + /* Enable Response to Reselection */ #define LSI_SCID_RRE 0x60 @@ -256,6 +265,7 @@ typedef struct { uint8_t lcrc; uint8_t sstat2; uint8_t dwt; + uint8_t sbcl; uint8_t script_active; } LSIState; @@ -440,6 +450,7 @@ static inline void lsi_set_phase(LSIState *s, int phase) s->ctest0 &= ~1; if (phase == PHASE_DI) s->ctest0 |= 1; + s->sbcl &= ~LSI_SBCL_REQ; } static void lsi_bad_phase(LSIState *s, int out, int new_phase) @@ -449,6 +460,7 @@ static void lsi_bad_phase(LSIState *s, int out, int new_phase) lsi_script_scsi_interrupt(s, LSI_SSTAT0_MA); lsi_stop_script(s); lsi_set_phase(s, new_phase); + s->sbcl |= LSI_SBCL_REQ; } @@ -733,8 +745,8 @@ static void lsi_do_command(LSIState *s) s->sfbr = buf[0]; s->command_complete = 0; - id = (s->select_tag >> 8) & 0xf; - s->lcrc = 1 << (id & 0x7); + id = (s->select_tag >> 8) & 0xff; + s->lcrc = id; //1 << (id & 0x7); dev = scsi_device_find(&s->bus, 0, idbitstonum(id), s->current_lun); if (!dev) { lsi_bad_selection(s, id); @@ -1107,7 +1119,8 @@ again: if ((s->sstat2 & PHASE_MASK) != ((insn >> 24) & 7)) { DPRINTF("Wrong phase got %d expected %d\n", s->sstat2 & PHASE_MASK, (insn >> 24) & 7); - lsi_script_scsi_interrupt(s, LSI_SSTAT0_SGE); + lsi_script_scsi_interrupt(s, LSI_SSTAT0_MA); + s->sbcl |= LSI_SBCL_REQ; break; } s->dnad = addr; @@ -1158,7 +1171,6 @@ again: if (insn & (1 << 26)) { addr = s->dsp + sextract32(addr, 0, 24); } - id &= ~s->scid; s->dnad = addr; switch (opcode) { case 0: /* Select */ @@ -1648,11 +1660,18 @@ static uint8_t lsi_reg_readb2(LSIState *s, int offset) return s->sien0; case 0x05: /* SXFER */ return s->sxfer; - + case 0x09: /* SIDL */ + /* This is needed by the linux drivers. We currently only update it + during the MSG IN phase. */ + return s->sidl; case 0xb: /* SBCL */ - /* ??? This is not correct. However it's (hopefully) only - used for diagnostics, so should be ok. */ - return 0; + /* NetBSD 1.x checks for REQ */ + tmp = s->sstat2 & PHASE_MASK; + /* if phase mismatch, REQ is also active */ + tmp |= s->sbcl; + if (s->socl & LSI_SOCL_ATN) + tmp |= LSI_SBCL_ATN; + return tmp; case 0xc: /* DSTAT */ tmp = s->dstat | LSI_DSTAT_DFE; s->dstat = 0; @@ -1777,6 +1796,7 @@ static void lsi_reg_writeb(LSIState *s, int offset, uint8_t val) s->sxfer = val; break; case 0x0b: /* SBCL */ + lsi_set_phase (s, val & PHASE_MASK); break; case 0x0c: case 0x0d: case 0x0e: case 0x0f: /* Linux writes to these readonly registers on startup. */ -- 2.47.3