Previous 15994 Revisions Next

r6407 Tuesday 17th November, 2009 at 18:35:28 UTC by Harmony
[N64] Multiple fixes:
- Many core fixes to fix TLB behavior [Aaron Giles]
- Corrected a typo in BLENDER2_16 [Harmony]
- Corrected memory mirroring during PI transfers [DrgnMndd]
- Reduced tcache to 4Kbytes as it should be [angrylion]
- Improved TLUT loads, fixes characters in Goldeneye [angrylion]
[src/emu/cpu]vtlb.c
[src/emu/cpu/mips]mips3com.c mips3com.h mips3drc.c
[src/mame/machine]n64.c
[src/mame/video]n64.c
[src/mess/drivers]n64.c

src/mame/machine/n64.c
r6406r6407
138138
139139void signal_rcp_interrupt(running_machine *machine, int interrupt)
140140{
141   mi_interrupt |= interrupt;
142
141143   if (mi_intr_mask & interrupt)
142144   {
143      mi_interrupt |= interrupt;
144145
145146      cputag_set_input_line(machine, "maincpu", INPUT_LINE_IRQ0, ASSERT_LINE);
146147   }
r6406r6407
150151{
151152   mi_interrupt &= ~interrupt;
152153
153   //if (!mi_interrupt)
154   if (!(mi_interrupt & mi_intr_mask))
154155   {
155156      cputag_set_input_line(machine, "maincpu", INPUT_LINE_IRQ0, CLEAR_LINE);
156157   }
r6406r6407
12781279                dma_length = (dma_length + 3) & ~3;
12791280            }*/
12801281
1281         //mame_printf_debug("PI DMA: %08X to %08X, length %08X\n", pi_dram_addr, pi_cart_addr, dma_length);
1282         //printf("PI DMA: %08X to %08X, length %08X\n", pi_dram_addr, pi_cart_addr, dma_length);
12821283
12831284         if (pi_dram_addr != 0xffffffff)
12841285         {
r6406r6407
13061307                dma_length = (dma_length + 3) & ~3;
13071308            }
13081309
1309         //mame_printf_debug("PI DMA: %08X to %08X, length %08X\n", pi_cart_addr, pi_dram_addr, dma_length);
1310         //printf("PI DMA: %08X to %08X, length %08X\n", pi_cart_addr, pi_dram_addr, dma_length);
13101311
13111312         if (pi_dram_addr != 0xffffffff)
13121313         {
r6406r6407
13171318                    pi_cart_addr += 4;
13181319                    pi_dram_addr += 4;*/
13191320
1320               UINT8 b = memory_read_byte(space, pi_cart_addr);
1321               UINT8 b = memory_read_byte(space, pi_cart_addr & 0x1fffffff);
13211322               memory_write_byte(space, pi_dram_addr & 0x1fffffff, b);
13221323               pi_cart_addr += 1;
13231324               pi_dram_addr += 1;
r6406r6407
13301331            // TODO: CIC-6105 has different address...
13311332            memory_write_dword(space, 0x00000318, 0x400000);
13321333            memory_write_dword(space, 0x000003f0, 0x800000);
1333            pi_first_dma = 0;
1334            //pi_first_dma = 0;
13341335         }
13351336
13361337         break;
r6406r6407
18591860
18601861   if (direction)      // RDRAM -> PIF RAM
18611862   {
1862      src = (UINT32*)&rdram[(si_dram_addr & 0x1fffffff) / 4];
1863      src = (UINT32*)&rdram[(si_dram_addr & 0x1ffffff) / 4];
18631864
18641865      for (i=0; i < 64; i+=4)
18651866      {
r6406r6407
19201921         // PIF RAM -> RDRAM
19211922         si_pif_addr = data;
19221923            si_pif_addr_rd64b = data;
1924            //printf( "si_pif_addr = %08x, si_pif_addr_rd64b = %08x\n", si_pif_addr, si_pif_addr_rd64b );
19231925            pif_dma(space->machine, 0);
19241926         break;
19251927
r6406r6407
19271929         // RDRAM -> PIF RAM
19281930         si_pif_addr = data;
19291931            si_pif_addr_wr64b = data;
1932            //printf( "si_pif_addr = %08x, si_pif_addr_wr64b = %08x\n", si_pif_addr, si_pif_addr_wr64b );
19301933            pif_dma(space->machine, 1);
19311934         break;
19321935
src/mame/video/n64.c
r6406r6407
242242
243243static RECTANGLE clip;
244244
245static UINT8 *texture_cache;
246static UINT32 tlut[256];
245static UINT8 *TMEM;
246#define tlut ((UINT16*)(TMEM + 0x800))
247247
248248static INT32 k0, k1, k2, k3, k4, k5;
249249static UINT8 primitive_lod_frac = 0;
r6406r6407
473473   if (LOG_RDP_EXECUTION)
474474      rdp_exec = fopen("rdp_execute.txt", "wt");
475475
476   texture_cache = auto_alloc_array(machine, UINT8, 0x100000);
476   TMEM = auto_alloc_array(machine, UINT8, 0x1004); // 4 guard bytes
477   memset(TMEM, 0, 0x1000);
478   TMEM[0x1000] = TMEM[0x1001] = 25;
477479
478480   combiner_rgbsub_a_r[0] = combiner_rgbsub_a_r[1] = &one_color.r;
479481   combiner_rgbsub_a_g[0] = combiner_rgbsub_a_g[1] = &one_color.g;
r6406r6407
11261128   }
11271129
11281130   memory_color.r = (((mem >> 11) & 0x1f) << 3) | (((mem >> 11) & 0x1f) >> 2);
1129   memory_color.g = (((mem >>  6) & 0x1f) << 3) | (((mem >> 11) & 0x1f) >> 2);
1130   memory_color.b = (((mem >>  1) & 0x1f) << 3) | (((mem >> 11) & 0x1f) >> 2);
1131   memory_color.g = (((mem >>  6) & 0x1f) << 3) | (((mem >>  6) & 0x1f) >> 2);
1132   memory_color.b = (((mem >>  1) & 0x1f) << 3) | (((mem >>  1) & 0x1f) >> 2);
11311133
11321134   if (other_modes.image_read_en)
11331135   {
r6406r6407
13331335         {
13341336            case PIXEL_SIZE_4BIT:
13351337            {
1336               UINT8 *tc = (UINT8*)texture_cache;
1338               UINT8 *tc = (UINT8*)TMEM;
13371339                    int taddr = ((tbase + ((t) * twidth) + ((s) / 2)) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0x7ff;
13381340               UINT8 p = ((s) & 1) ? (tc[taddr ^ BYTE_ADDR_XOR] & 0xf) : (tc[taddr ^ BYTE_ADDR_XOR] >> 4);
1339               UINT16 c = tlut[((tpal << 4) | p) ^ WORD_ADDR_XOR];
1341               UINT16 c = tlut[(((tpal << 4) | p) ^ WORD_ADDR_XOR) << 2];
13401342
13411343               if (other_modes.en_tlut)
13421344               {
r6406r6407
13611363            }
13621364            case PIXEL_SIZE_8BIT:
13631365            {
1364               UINT8 *tc = (UINT8*)texture_cache;
1366               UINT8 *tc = (UINT8*)TMEM;
13651367                    int taddr = ((tbase + ((t) * twidth) + ((s))) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0x7ff;
13661368               UINT8 p = tc[taddr ^ BYTE_ADDR_XOR];
1367               UINT16 c = tlut[p ^ WORD_ADDR_XOR];
1369               UINT16 c = tlut[(p ^ WORD_ADDR_XOR) << 2];
13681370
13691371               if (other_modes.en_tlut)
13701372               {
r6406r6407
13891391            }
13901392            case PIXEL_SIZE_16BIT:
13911393            {
1392               UINT16 *tc = (UINT16*)texture_cache;
1394               UINT16 *tc = (UINT16*)TMEM;
13931395                    int taddr = ((tbase>>1) + ((t) * (twidth>>1)) + (s))  ^ ((t & 1) ? XOR_SWAP_WORD : 0);
13941396               UINT16 c = tc[(taddr & 0x7ff) ^ WORD_ADDR_XOR]; // PGA European Tour (U)
13951397
r6406r6407
14201422            }
14211423            case PIXEL_SIZE_32BIT:
14221424            {
1423               UINT32 *tc = (UINT32*)texture_cache;
1425               UINT32 *tc = (UINT32*)TMEM;
14241426               int xorval = (fb_size == PIXEL_SIZE_16BIT) ? XOR_SWAP_WORD : XOR_SWAP_DWORD; // Conker's Bad Fur Day, Jet Force Gemini, Super Smash Bros., Mickey's Speedway USA, Ogre Battle, Wave Race, Gex 3, South Park Rally
14251427                    int taddr = (((tbase >> 2) + ((t) * (twidth >> 1)) + (s)) ^ ((t & 1) ? xorval : 0)) & 0x3ff;
14261428               UINT32 c = tc[taddr];
r6406r6407
14661468               INT32 newr = 0;
14671469               INT32 newg = 0;
14681470               INT32 newb = 0;
1469               UINT16 *tc = (UINT16*)texture_cache;
1471               UINT16 *tc = (UINT16*)TMEM;
14701472               int taddr = ((tbase >> 1) + ((t) * (twidth)) + (s)) ^ ((t & 1) ? XOR_SWAP_WORD : 0);
14711473               UINT16 c1, c2;
14721474               INT32 y;
r6406r6407
15101512         {
15111513            case PIXEL_SIZE_4BIT:
15121514            {
1513               UINT8 *tc = (UINT8*)texture_cache;
1515               UINT8 *tc = (UINT8*)TMEM;
15141516                    int taddr = ((tbase + ((t) * twidth) + ((s) / 2)) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0x7ff;
15151517               UINT8 p = ((s) & 1) ? (tc[taddr ^ BYTE_ADDR_XOR] & 0xf) : (tc[taddr ^ BYTE_ADDR_XOR] >> 4);
1516               UINT16 c = tlut[((tpal << 4) | p) ^ WORD_ADDR_XOR];
1518               UINT16 c = tlut[(((tpal << 4) | p) ^ WORD_ADDR_XOR) << 2];
15171519
15181520               if (other_modes.en_tlut)
15191521               {
r6406r6407
15381540            }
15391541            case PIXEL_SIZE_8BIT:
15401542            {
1541               UINT8 *tc = (UINT8*)texture_cache;
1543               UINT8 *tc = (UINT8*)TMEM;
15421544                    int taddr = ((tbase + ((t) * twidth) + ((s))) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0x7ff;
15431545               UINT8 p = tc[taddr ^ BYTE_ADDR_XOR];
1544               UINT16 c = tlut[p ^ WORD_ADDR_XOR];
1546               UINT16 c = tlut[(p ^ WORD_ADDR_XOR) << 2];
15451547
15461548               if (other_modes.en_tlut)
15471549               {
r6406r6407
15671569            case PIXEL_SIZE_16BIT:
15681570            {
15691571                    // 16-bit CI is a "valid" mode; some games use it, it behaves the same as 16-bit RGBA
1570               UINT16 *tc = (UINT16*)texture_cache;
1572               UINT16 *tc = (UINT16*)TMEM;
15711573                    int taddr = ((tbase>>1) + ((t) * (twidth>>1)) + (s))  ^ ((t & 1) ? XOR_SWAP_WORD : 0);
15721574               UINT16 c = tc[(taddr & 0x7ff) ^ WORD_ADDR_XOR]; // PGA European Tour (U)
15731575
r6406r6407
16091611         {
16101612            case PIXEL_SIZE_4BIT:
16111613            {
1612               UINT8 *tc = (UINT8*)texture_cache;
1614               UINT8 *tc = (UINT8*)TMEM;
16131615                    int taddr = (tbase + ((t) * twidth) + (s >> 1)) ^ ((t & 1) ? XOR_SWAP_BYTE : 0);
16141616               UINT8 p = ((s) & 1) ? (tc[taddr ^ BYTE_ADDR_XOR] & 0xf) : (tc[taddr ^ BYTE_ADDR_XOR] >> 4);
16151617               UINT8 i = ((p & 0xe) << 4) | ((p & 0xe) << 1) | (p & 0xe >> 2);
r6406r6407
16261628                  UINT16 c = tlut[((tpal << 4) | p) << 2];
16271629                  if (!other_modes.tlut_type)
16281630                  {
1629                          color->r = (((c >> 11) & 0x1f) << 3) | (((c >> 11) & 0x1f) << 3);
1630                          color->g = (((c >>  6) & 0x1f) << 3) | (((c >>  6) & 0x1f) << 3);
1631                          color->b = (((c >>  1) & 0x1f) << 3) | (((c >>  1) & 0x1f) << 3);
1631                          color->r = (((c >> 11) & 0x1f) << 3) | (((c >> 11) & 0x1f) >> 2);
1632                          color->g = (((c >>  6) & 0x1f) << 3) | (((c >>  6) & 0x1f) >> 2);
1633                          color->b = (((c >>  1) & 0x1f) << 3) | (((c >>  1) & 0x1f) >> 2);
16321634                          color->a = (c & 1) ? 0xff : 0;
16331635                  }
16341636                  else
r6406r6407
16411643            }
16421644            case PIXEL_SIZE_8BIT:
16431645            {
1644               UINT8 *tc = (UINT8*)texture_cache;
1646               UINT8 *tc = (UINT8*)TMEM;
16451647                    int taddr = ((tbase + ((t) * twidth) + ((s))) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0xfff;
16461648               UINT8 p = tc[taddr ^ BYTE_ADDR_XOR];
16471649               UINT8 i = 0;
r6406r6407
16741676            }
16751677            case PIXEL_SIZE_16BIT:
16761678            {
1677               UINT16 *tc = (UINT16*)texture_cache;
1679               UINT16 *tc = (UINT16*)TMEM;
16781680                    int taddr = ((tbase >> 1) + ((t) * (twidth >> 1)) + (s)) ^ ((t & 1) ? XOR_SWAP_WORD : 0);
16791681               UINT16 c = tc[taddr ^ WORD_ADDR_XOR];
16801682               UINT8 i = (c >> 8);
r6406r6407
17191721         {
17201722            case PIXEL_SIZE_4BIT:
17211723            {
1722               UINT8 *tc = (UINT8*)texture_cache;
1724               UINT8 *tc = (UINT8*)TMEM;
17231725                    int taddr = ((tbase + ((t) * twidth) + ((s) / 2)) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0xfff;
17241726               UINT8 c = ((s) & 1) ? (tc[taddr ^ BYTE_ADDR_XOR] & 0xf) : (tc[taddr ^ BYTE_ADDR_XOR] >> 4);
17251727               c |= (c << 4);
r6406r6407
17511753            }
17521754            case PIXEL_SIZE_8BIT:
17531755            {
1754               UINT8 *tc = (UINT8*)texture_cache;
1756               UINT8 *tc = (UINT8*)TMEM;
17551757                    int taddr = ((tbase + ((t) * twidth) + ((s))) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0xfff;
17561758               UINT8 c = tc[taddr ^ BYTE_ADDR_XOR];
17571759
r6406r6407
51335135   sh = tile[tilenum].sh = ((w2 >> 12) & 0xfff);
51345136   th = tile[tilenum].th = w2 & 0xfff;
51355137
5136   switch (ti_format)
5138   switch (ti_size)
51375139   {
5138      case 0:      // RGBA
5140      case PIXEL_SIZE_16BIT:
51395141      {
5140         switch (ti_size)
5142         UINT16 *src = (UINT16*)&rdram[(ti_address + (tl >> 2) * (ti_width << 1) + (sl >> 1)) >> 2];
5143         UINT16 *dst = (UINT16*)&TMEM[tile[tilenum].tmem];
5144         int count = ((sh >> 2) - (sl >> 2)) + 1;
5145
5146         for (i = 0; i < count; i++)
51415147         {
5142            case PIXEL_SIZE_16BIT:
5148            if((i*4) < 0x400)
51435149            {
5144               UINT16 *src = (UINT16*)&rdram[(ti_address + (tl >> 2) * (ti_width << 1) + (sl >> 1)) >> 2];
5145
5146               for (i = (sl >> 2); i <= (sh >> 2); i++)
5147               {
5148                  tlut[i] = src[i];
5149               }
5150               break;
5150               dst[i*4] = src[i];
5151               dst[i*4+1] = 0;
5152               dst[i*4+2] = 0;
5153               dst[i*4+3] = 0;
51515154            }
5152            default:   fatalerror("RDP: load_tlut: size = %d\n", ti_size);
5155            //tlut[i] = src[i];
51535156         }
51545157         break;
51555158      }
5159      /*
5160      case PIXEL_SIZE_16BIT:
5161      {
5162         UINT16 *src = (UINT16*)&rdram[(ti_address + (tl >> 2) * (ti_width << 1) + (sl >> 1)) >> 2];
51565163
5157      default:   fatalerror("RDP: load_tlut: format = %d\n", ti_format);
5164         for (i = (sl >> 2); i <= (sh >> 2); i++)
5165         {
5166            tlut[i] = src[i];
5167         }
5168         break;
5169      }*/
5170      default:   stricterror("RDP: load_tlut: size = %d\n", ti_size);
51585171   }
5172
5173   if (TMEM[0x1000] != 25 || TMEM[0x1001] != 25)
5174   {
5175      stricterror("rdp_load_tlut: TMEM has been written out-of-bounds");
5176   }
51595177}
51605178
51615179static RDP_COMMAND( rdp_set_tile_size )
r6406r6407
52115229   }
52125230
52135231   src = (UINT32*)&ram16[ti_address2 >> 1];
5214   tc = (UINT32*)texture_cache;
5232   tc = (UINT32*)TMEM;
52155233   tb = tile[tilenum].tmem >> 2;
52165234
52175235   if ((tb + (width >> 2)) > 0x400)
r6406r6407
53245342      case PIXEL_SIZE_8BIT:
53255343      {
53265344         UINT8 *src = (UINT8*)rdram;
5327         UINT8 *tc = (UINT8*)texture_cache;
5345         UINT8 *tc = (UINT8*)TMEM;
53285346         int tb = tile[tilenum].tmem;
53295347
53305348         if (tb + (width * height) > 4096)
r6406r6407
53545372      {
53555373         UINT16 *src = (UINT16*)rdram;
53565374         UINT32 ti_addr16 = ti_address >> 1;
5357         UINT16 *tc = (UINT16*)texture_cache;
5375         UINT16 *tc = (UINT16*)TMEM;
53585376         int tb = (tile[tilenum].tmem / 2);
53595377         int taddr;
53605378
r6406r6407
53945412      case PIXEL_SIZE_32BIT:
53955413      {
53965414         UINT32 *src = (UINT32*)&rdram[ti_address / 4];
5397         UINT32 *tc = (UINT32*)texture_cache;
5415         UINT32 *tc = (UINT32*)TMEM;
53985416         int tb = (tile[tilenum].tmem / 4);
53995417         int xorval32 = ((fb_size == PIXEL_SIZE_16BIT) ? 2 : 1);
54005418
src/emu/cpu/vtlb.c
r6406r6407
211211   if (vtlb->live[liveindex] != 0)
212212   {
213213      int pagecount = vtlb->fixedpages[entrynum];
214      int oldtableindex = vtlb->live[liveindex] - 1;
214215      for (pagenum = 0; pagenum < pagecount; pagenum++)
215         vtlb->table[vtlb->live[liveindex] - 1 + pagenum] = 0;
216         vtlb->table[oldtableindex + pagenum] = 0;
216217   }
217218
218219   /* claim this new entry */
r6406r6407
220221
221222   /* store the raw value, making sure the "fixed" flag is set */
222223   value |= VTLB_FLAG_FIXED;
224   vtlb->fixedpages[entrynum] = numpages;
223225   for (pagenum = 0; pagenum < numpages; pagenum++)
224226      vtlb->table[tableindex + pagenum] = value + (pagenum << vtlb->pageshift);
225227}
src/emu/cpu/mips/mips3com.h
r6406r6407
2626#define MIPS3_MIN_PAGE_SIZE         (1 << MIPS3_MIN_PAGE_SHIFT)
2727#define MIPS3_MIN_PAGE_MASK         (MIPS3_MIN_PAGE_SIZE - 1)
2828#define MIPS3_MAX_PADDR_SHIFT      32
29#define MIPS3_TLB_ENTRIES         48
29#define MIPS3_MAX_TLB_ENTRIES      48
3030
3131/* cycle parameters */
3232#define MIPS3_COUNT_READ_CYCLES      250
r6406r6407
204204   UINT64         count_zero_time;
205205   UINT32         compare_armed;
206206   emu_timer *      compare_int_timer;
207   
208   /* derived info based on flavor */
209   UINT32         pfnmask;
210   UINT8         tlbentries;
207211
208212   /* memory accesses */
209213   UINT8         bigendian;
r6406r6407
215219
216220   /* MMU */
217221   vtlb_state *   vtlb;
218   mips3_tlb_entry tlb[MIPS3_TLB_ENTRIES];
222   mips3_tlb_entry tlb[MIPS3_MAX_TLB_ENTRIES];
219223
220224   /* for use by specific implementations */
221225   mips3imp_state *impstate;
src/emu/cpu/mips/mips3drc.c
r6406r6407
11031103   }
11041104   UML_TEST(block, IREG(1), IMM(VTLB_FETCH_ALLOWED));                        // test    i1,VTLB_FETCH_ALLOWED
11051105   UML_JMPc(block, IF_NZ, 1);                                          // jmp     1,nz
1106   UML_TEST(block, IREG(1), IMM(VTLB_FLAG_VALID));                           // test    i1,VTLB_FLAG_VALID
1107   UML_EXHc(block, IF_Z, mips3->impstate->exception[EXCEPTION_TLBLOAD], IREG(0));   // exh     exception[TLBLOAD],i0,z
1106   UML_TEST(block, IREG(1), IMM(VTLB_FLAG_FIXED));                           // test    i1,VTLB_FLAG_FIXED
1107   UML_EXHc(block, IF_NZ, mips3->impstate->exception[EXCEPTION_TLBLOAD], IREG(0));   // exh     exception[TLBLOAD],i0,nz
11081108   UML_EXH(block, mips3->impstate->exception[EXCEPTION_TLBLOAD_FILL], IREG(0));   // exh     exception[TLBLOAD_FILL],i0
11091109   UML_LABEL(block, 1);                                          // 1:
11101110   save_fast_iregs(mips3, block);
r6406r6407
11571157
11581158   if (exception == EXCEPTION_TLBLOAD || exception == EXCEPTION_TLBSTORE)
11591159   {
1160      offset = 0x000;
11611160      /* set the upper bits of EntryHi and the lower bits of Context to the fault page */
11621161      UML_ROLINS(block, CPR032(COP0_EntryHi), IREG(0), IMM(0), IMM(0xffffe000));   // rolins  [EntryHi],i0,0,0xffffe000
1163      UML_ROLINS(block, CPR032(COP0_Context), IREG(0), IMM(32-9), IMM(0x7ffff0));   // rolins  [Context],i0,32-9,0x7fffff
1162      UML_ROLINS(block, CPR032(COP0_Context), IREG(0), IMM(32-9), IMM(0x7ffff0));   // rolins  [Context],i0,32-9,0x7ffff
11641163   }
11651164
11661165   /* set the EPC and Cause registers */
r6406r6407
11761175   UML_OR(block, IREG(2), IREG(2), IMM(0x80000000));                        // or      i2,i2,0x80000000
11771176   UML_SUB(block, IREG(0), IREG(0), IMM(1));                              // sub     i0,i0,1
11781177   UML_LABEL(block, next);                                          // <next>:
1178   UML_MOV(block, IREG(3), IMM(offset));                                 // mov     i3,offset
11791179   UML_TEST(block, CPR032(COP0_Status), IMM(SR_EXL));                        // test    [Status],SR_EXL
11801180   UML_MOVc(block, IF_Z, CPR032(COP0_EPC), IREG(0));                        // mov     [EPC],i0,Z
1181   UML_MOVc(block, IF_NZ, IREG(3), IMM(0x180));                           // mov     i3,0x180,NZ
11811182   UML_OR(block, CPR032(COP0_Cause), IREG(2), IMM(exception << 2));            // or      [Cause],i2,exception << 2
11821183
11831184   /* for BADCOP exceptions, we use the exception parameter to know which COP */
r6406r6407
12001201   }
12011202
12021203   /* choose our target PC */
1203   UML_MOV(block, IREG(0), IMM(0xbfc00200 + offset));                        // mov     i0,0xbfc00200 + offset
1204   UML_ADD(block, IREG(0), IREG(3), IMM(0xbfc00200));                        // add     i0,i3,0xbfc00200
12041205   UML_TEST(block, IREG(1), IMM(SR_BEV));                                 // test    i1,SR_BEV
1205   UML_MOVc(block, IF_Z, IREG(0), IMM(0x80000000 + offset));                  // mov     i0,0x80000000 + offset,z
1206   UML_ADDc(block, IF_Z, IREG(0), IREG(3), IMM(0x80000000));                  // add     i0,i3,0x80000000,z
12061207
12071208   /* adjust cycles */
12081209   UML_SUB(block, MEM(&mips3->icount), MEM(&mips3->icount), IREG(1));             // sub icount,icount,cycles,S
r6406r6407
14261427         UML_EXHc(block, IF_NZ, mips3->impstate->exception[EXCEPTION_TLBMOD], IREG(0));
14271428                                                               // exh     tlbmod,i0,nz
14281429      }
1429      UML_TEST(block, IREG(3), IMM(VTLB_FLAG_VALID));                        // test    i3,VTLB_FLAG_VALID
1430      UML_EXHc(block, IF_Z, exception_tlb, IREG(0));                        // exh     tlb,i0,z
1430      UML_TEST(block, IREG(3), IMM(VTLB_FLAG_FIXED));                        // test    i3,VTLB_FLAG_FIXED
1431      UML_EXHc(block, IF_NZ, exception_tlb, IREG(0));                        // exh     tlb,i0,nz
14311432      UML_EXH(block, exception_tlbfill, IREG(0));                           // exh     tlbfill,i0
14321433   }
14331434
src/emu/cpu/mips/mips3com.c
r6406r6407
8686   mips->icache_size = config->icache;
8787   mips->dcache_size = config->dcache;
8888   mips->system_clock = config->system_clock;
89   
90   /* configure flavor-specific parameters */
91   mips->pfnmask = 0x00ffffff;
92   mips->tlbentries = MIPS3_MAX_TLB_ENTRIES;
93   
94   /* VR4300 and VR5432 have 4 fewer PFN bits, and only 32 TLB entries */
95   if (flavor == MIPS3_TYPE_VR4300)
96   {
97      mips->pfnmask = 0x000fffff;
98      mips->tlbentries = 32;
99   }
89100
90101   /* set up the endianness */
91102   mips->memory = mips->program->accessors;
92103
93104   /* allocate the virtual TLB */
94   mips->vtlb = vtlb_alloc(device, ADDRESS_SPACE_PROGRAM, 2 * MIPS3_TLB_ENTRIES + 2, 0);
105   mips->vtlb = vtlb_alloc(device, ADDRESS_SPACE_PROGRAM, 2 * mips->tlbentries + 2, 0);
95106
96107   /* allocate a timer for the compare interrupt */
97108   mips->compare_int_timer = timer_alloc(device->machine, compare_int_callback, (void *)device);
r6406r6407
106117   state_save_register_device_item_2d_array(device, 0, mips->ccr);
107118   state_save_register_device_item(device, 0, mips->llbit);
108119   state_save_register_device_item(device, 0, mips->count_zero_time);
109   for (tlbindex = 0; tlbindex < ARRAY_LENGTH(mips->tlb); tlbindex++)
120   for (tlbindex = 0; tlbindex < mips->tlbentries; tlbindex++)
110121   {
111122      state_save_register_device_item(device, tlbindex, mips->tlb[tlbindex].page_mask);
112123      state_save_register_device_item(device, tlbindex, mips->tlb[tlbindex].entry_hi);
r6406r6407
146157   mips->count_zero_time = cpu_get_total_cycles(mips->device);
147158
148159   /* initialize the TLB state */
149   for (tlbindex = 0; tlbindex < ARRAY_LENGTH(mips->tlb); tlbindex++)
160   for (tlbindex = 0; tlbindex < mips->tlbentries; tlbindex++)
150161   {
151162      mips3_tlb_entry *entry = &mips->tlb[tlbindex];
152163      entry->page_mask = 0;
r6406r6407
158169   }
159170
160171   /* load the fixed TLB range */
161   vtlb_load(mips->vtlb, 2 * MIPS3_TLB_ENTRIES + 0, (0xa0000000 - 0x80000000) >> MIPS3_MIN_PAGE_SHIFT, 0x80000000, 0x00000000 | VTLB_READ_ALLOWED | VTLB_WRITE_ALLOWED | VTLB_FETCH_ALLOWED | VTLB_FLAG_VALID);
162   vtlb_load(mips->vtlb, 2 * MIPS3_TLB_ENTRIES + 1, (0xc0000000 - 0xa0000000) >> MIPS3_MIN_PAGE_SHIFT, 0xa0000000, 0x00000000 | VTLB_READ_ALLOWED | VTLB_WRITE_ALLOWED | VTLB_FETCH_ALLOWED | VTLB_FLAG_VALID);
172   vtlb_load(mips->vtlb, 2 * mips->tlbentries + 0, (0xa0000000 - 0x80000000) >> MIPS3_MIN_PAGE_SHIFT, 0x80000000, 0x00000000 | VTLB_READ_ALLOWED | VTLB_WRITE_ALLOWED | VTLB_FETCH_ALLOWED | VTLB_FLAG_VALID);
173   vtlb_load(mips->vtlb, 2 * mips->tlbentries + 1, (0xc0000000 - 0xa0000000) >> MIPS3_MIN_PAGE_SHIFT, 0xa0000000, 0x00000000 | VTLB_READ_ALLOWED | VTLB_WRITE_ALLOWED | VTLB_FETCH_ALLOWED | VTLB_FLAG_VALID);
163174}
164175
165176
r6406r6407
216227   int tlbindex;
217228
218229   /* iterate over all non-global TLB entries and remap them */
219   for (tlbindex = 0; tlbindex < ARRAY_LENGTH(mips->tlb); tlbindex++)
230   for (tlbindex = 0; tlbindex < mips->tlbentries; tlbindex++)
220231      if (!tlb_entry_is_global(&mips->tlb[tlbindex]))
221232         tlb_map_entry(mips, tlbindex);
222233}
r6406r6407
251262   UINT32 tlbindex = mips->cpr[0][COP0_Index] & 0x3f;
252263
253264   /* only handle entries within the TLB */
254   if (tlbindex < ARRAY_LENGTH(mips->tlb))
265   if (tlbindex < mips->tlbentries)
255266   {
256267      mips3_tlb_entry *entry = &mips->tlb[tlbindex];
257268
r6406r6407
282293void mips3com_tlbwr(mips3_state *mips)
283294{
284295   UINT32 wired = mips->cpr[0][COP0_Wired] & 0x3f;
285   UINT32 unwired = ARRAY_LENGTH(mips->tlb) - wired;
286   UINT32 tlbindex = ARRAY_LENGTH(mips->tlb) - 1;
296   UINT32 unwired = mips->tlbentries - wired;
297   UINT32 tlbindex = mips->tlbentries - 1;
287298
288299   /* "random" is based off of the current cycle counting through the non-wired pages */
289300   if (unwired > 0)
r6406r6407
304315   UINT64 vpn;
305316
306317   /* iterate over TLB entries */
307   for (tlbindex = 0; tlbindex < ARRAY_LENGTH(mips->tlb); tlbindex++)
318   for (tlbindex = 0; tlbindex < mips->tlbentries; tlbindex++)
308319   {
309320      mips3_tlb_entry *entry = &mips->tlb[tlbindex];
310321      UINT64 mask = ~((entry->page_mask >> 13) & 0xfff) << 13;
r6406r6407
319330
320331   /* validate that our tlb_table was in sync */
321332   vpn = ((mips->cpr[0][COP0_EntryHi] >> 13) & 0x07ffffff) << 1;
322   if (tlbindex != ARRAY_LENGTH(mips->tlb))
333   if (tlbindex != mips->tlbentries)
323334      mips->cpr[0][COP0_Index] = tlbindex;
324335   else
325336      mips->cpr[0][COP0_Index] = 0x80000000;
r6406r6407
892903      UINT32 pfn;
893904      UINT32 flags = 0;
894905
895      if (mips->flavor == MIPS3_TYPE_VR4300)
896      {
897         pfn = (lo >> 6) & 0x000fffff;    // VR4300 and VR5432 have 4 fewer PFN bits
898      }
899      else
900      {
901         pfn = (lo >> 6) & 0x00ffffff;
902      }
906      /* compute physical page index */
907      pfn = (lo >> 6) & mips->pfnmask;
903908
904909      /* valid? */
905910      if ((lo & 2) != 0)
r6406r6407
918923      /* load the virtual TLB with the corresponding entries */
919924      if ((effvpn + count) <= (0x80000000 >> MIPS3_MIN_PAGE_SHIFT) || effvpn >= (0xc0000000 >> MIPS3_MIN_PAGE_SHIFT))
920925         vtlb_load(mips->vtlb, 2 * tlbindex + which, count, effvpn << MIPS3_MIN_PAGE_SHIFT, (pfn << MIPS3_MIN_PAGE_SHIFT) | flags);
926      else
927         vtlb_load(mips->vtlb, 2 * tlbindex + which, 0, 0, 0);
921928   }
922929}
923930
r6406r6407
930937static void tlb_write_common(mips3_state *mips, int tlbindex)
931938{
932939   /* only handle entries within the TLB */
933   if (tlbindex < ARRAY_LENGTH(mips->tlb))
940   if (tlbindex < mips->tlbentries)
934941   {
935942      mips3_tlb_entry *entry = &mips->tlb[tlbindex];
936943
src/mess/drivers/n64.c
r6406r6407
117117
118118static MACHINE_DRIVER_START( n64 )
119119   /* basic machine hardware */
120   MDRV_CPU_ADD("maincpu", R4600BE, 93750000)
120   MDRV_CPU_ADD("maincpu", VR4300BE, 93750000)
121121   MDRV_CPU_CONFIG(config)
122122   MDRV_CPU_PROGRAM_MAP(n64_map)
123123   MDRV_CPU_VBLANK_INT("screen", n64_vblank)

Previous 15994 Revisions Next


© 1998-2018 The MESS Team