src/mame/machine/n64.c
| r6406 | r6407 | |
| 138 | 138 | |
| 139 | 139 | void signal_rcp_interrupt(running_machine *machine, int interrupt) |
| 140 | 140 | { |
| 141 | mi_interrupt |= interrupt; |
| 142 | |
| 141 | 143 | if (mi_intr_mask & interrupt) |
| 142 | 144 | { |
| 143 | | mi_interrupt |= interrupt; |
| 144 | 145 | |
| 145 | 146 | cputag_set_input_line(machine, "maincpu", INPUT_LINE_IRQ0, ASSERT_LINE); |
| 146 | 147 | } |
| r6406 | r6407 | |
| 150 | 151 | { |
| 151 | 152 | mi_interrupt &= ~interrupt; |
| 152 | 153 | |
| 153 | | //if (!mi_interrupt) |
| 154 | if (!(mi_interrupt & mi_intr_mask)) |
| 154 | 155 | { |
| 155 | 156 | cputag_set_input_line(machine, "maincpu", INPUT_LINE_IRQ0, CLEAR_LINE); |
| 156 | 157 | } |
| r6406 | r6407 | |
| 1278 | 1279 | dma_length = (dma_length + 3) & ~3; |
| 1279 | 1280 | }*/ |
| 1280 | 1281 | |
| 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); |
| 1282 | 1283 | |
| 1283 | 1284 | if (pi_dram_addr != 0xffffffff) |
| 1284 | 1285 | { |
| r6406 | r6407 | |
| 1306 | 1307 | dma_length = (dma_length + 3) & ~3; |
| 1307 | 1308 | } |
| 1308 | 1309 | |
| 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); |
| 1310 | 1311 | |
| 1311 | 1312 | if (pi_dram_addr != 0xffffffff) |
| 1312 | 1313 | { |
| r6406 | r6407 | |
| 1317 | 1318 | pi_cart_addr += 4; |
| 1318 | 1319 | pi_dram_addr += 4;*/ |
| 1319 | 1320 | |
| 1320 | | UINT8 b = memory_read_byte(space, pi_cart_addr); |
| 1321 | UINT8 b = memory_read_byte(space, pi_cart_addr & 0x1fffffff); |
| 1321 | 1322 | memory_write_byte(space, pi_dram_addr & 0x1fffffff, b); |
| 1322 | 1323 | pi_cart_addr += 1; |
| 1323 | 1324 | pi_dram_addr += 1; |
| r6406 | r6407 | |
| 1330 | 1331 | // TODO: CIC-6105 has different address... |
| 1331 | 1332 | memory_write_dword(space, 0x00000318, 0x400000); |
| 1332 | 1333 | memory_write_dword(space, 0x000003f0, 0x800000); |
| 1333 | | pi_first_dma = 0; |
| 1334 | //pi_first_dma = 0; |
| 1334 | 1335 | } |
| 1335 | 1336 | |
| 1336 | 1337 | break; |
| r6406 | r6407 | |
| 1859 | 1860 | |
| 1860 | 1861 | if (direction) // RDRAM -> PIF RAM |
| 1861 | 1862 | { |
| 1862 | | src = (UINT32*)&rdram[(si_dram_addr & 0x1fffffff) / 4]; |
| 1863 | src = (UINT32*)&rdram[(si_dram_addr & 0x1ffffff) / 4]; |
| 1863 | 1864 | |
| 1864 | 1865 | for (i=0; i < 64; i+=4) |
| 1865 | 1866 | { |
| r6406 | r6407 | |
| 1920 | 1921 | // PIF RAM -> RDRAM |
| 1921 | 1922 | si_pif_addr = data; |
| 1922 | 1923 | si_pif_addr_rd64b = data; |
| 1924 | //printf( "si_pif_addr = %08x, si_pif_addr_rd64b = %08x\n", si_pif_addr, si_pif_addr_rd64b ); |
| 1923 | 1925 | pif_dma(space->machine, 0); |
| 1924 | 1926 | break; |
| 1925 | 1927 | |
| r6406 | r6407 | |
| 1927 | 1929 | // RDRAM -> PIF RAM |
| 1928 | 1930 | si_pif_addr = data; |
| 1929 | 1931 | si_pif_addr_wr64b = data; |
| 1932 | //printf( "si_pif_addr = %08x, si_pif_addr_wr64b = %08x\n", si_pif_addr, si_pif_addr_wr64b ); |
| 1930 | 1933 | pif_dma(space->machine, 1); |
| 1931 | 1934 | break; |
| 1932 | 1935 | |
src/mame/video/n64.c
| r6406 | r6407 | |
| 242 | 242 | |
| 243 | 243 | static RECTANGLE clip; |
| 244 | 244 | |
| 245 | | static UINT8 *texture_cache; |
| 246 | | static UINT32 tlut[256]; |
| 245 | static UINT8 *TMEM; |
| 246 | #define tlut ((UINT16*)(TMEM + 0x800)) |
| 247 | 247 | |
| 248 | 248 | static INT32 k0, k1, k2, k3, k4, k5; |
| 249 | 249 | static UINT8 primitive_lod_frac = 0; |
| r6406 | r6407 | |
| 473 | 473 | if (LOG_RDP_EXECUTION) |
| 474 | 474 | rdp_exec = fopen("rdp_execute.txt", "wt"); |
| 475 | 475 | |
| 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; |
| 477 | 479 | |
| 478 | 480 | combiner_rgbsub_a_r[0] = combiner_rgbsub_a_r[1] = &one_color.r; |
| 479 | 481 | combiner_rgbsub_a_g[0] = combiner_rgbsub_a_g[1] = &one_color.g; |
| r6406 | r6407 | |
| 1126 | 1128 | } |
| 1127 | 1129 | |
| 1128 | 1130 | 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); |
| 1131 | 1133 | |
| 1132 | 1134 | if (other_modes.image_read_en) |
| 1133 | 1135 | { |
| r6406 | r6407 | |
| 1333 | 1335 | { |
| 1334 | 1336 | case PIXEL_SIZE_4BIT: |
| 1335 | 1337 | { |
| 1336 | | UINT8 *tc = (UINT8*)texture_cache; |
| 1338 | UINT8 *tc = (UINT8*)TMEM; |
| 1337 | 1339 | int taddr = ((tbase + ((t) * twidth) + ((s) / 2)) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0x7ff; |
| 1338 | 1340 | 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]; |
| 1340 | 1342 | |
| 1341 | 1343 | if (other_modes.en_tlut) |
| 1342 | 1344 | { |
| r6406 | r6407 | |
| 1361 | 1363 | } |
| 1362 | 1364 | case PIXEL_SIZE_8BIT: |
| 1363 | 1365 | { |
| 1364 | | UINT8 *tc = (UINT8*)texture_cache; |
| 1366 | UINT8 *tc = (UINT8*)TMEM; |
| 1365 | 1367 | int taddr = ((tbase + ((t) * twidth) + ((s))) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0x7ff; |
| 1366 | 1368 | UINT8 p = tc[taddr ^ BYTE_ADDR_XOR]; |
| 1367 | | UINT16 c = tlut[p ^ WORD_ADDR_XOR]; |
| 1369 | UINT16 c = tlut[(p ^ WORD_ADDR_XOR) << 2]; |
| 1368 | 1370 | |
| 1369 | 1371 | if (other_modes.en_tlut) |
| 1370 | 1372 | { |
| r6406 | r6407 | |
| 1389 | 1391 | } |
| 1390 | 1392 | case PIXEL_SIZE_16BIT: |
| 1391 | 1393 | { |
| 1392 | | UINT16 *tc = (UINT16*)texture_cache; |
| 1394 | UINT16 *tc = (UINT16*)TMEM; |
| 1393 | 1395 | int taddr = ((tbase>>1) + ((t) * (twidth>>1)) + (s)) ^ ((t & 1) ? XOR_SWAP_WORD : 0); |
| 1394 | 1396 | UINT16 c = tc[(taddr & 0x7ff) ^ WORD_ADDR_XOR]; // PGA European Tour (U) |
| 1395 | 1397 | |
| r6406 | r6407 | |
| 1420 | 1422 | } |
| 1421 | 1423 | case PIXEL_SIZE_32BIT: |
| 1422 | 1424 | { |
| 1423 | | UINT32 *tc = (UINT32*)texture_cache; |
| 1425 | UINT32 *tc = (UINT32*)TMEM; |
| 1424 | 1426 | 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 |
| 1425 | 1427 | int taddr = (((tbase >> 2) + ((t) * (twidth >> 1)) + (s)) ^ ((t & 1) ? xorval : 0)) & 0x3ff; |
| 1426 | 1428 | UINT32 c = tc[taddr]; |
| r6406 | r6407 | |
| 1466 | 1468 | INT32 newr = 0; |
| 1467 | 1469 | INT32 newg = 0; |
| 1468 | 1470 | INT32 newb = 0; |
| 1469 | | UINT16 *tc = (UINT16*)texture_cache; |
| 1471 | UINT16 *tc = (UINT16*)TMEM; |
| 1470 | 1472 | int taddr = ((tbase >> 1) + ((t) * (twidth)) + (s)) ^ ((t & 1) ? XOR_SWAP_WORD : 0); |
| 1471 | 1473 | UINT16 c1, c2; |
| 1472 | 1474 | INT32 y; |
| r6406 | r6407 | |
| 1510 | 1512 | { |
| 1511 | 1513 | case PIXEL_SIZE_4BIT: |
| 1512 | 1514 | { |
| 1513 | | UINT8 *tc = (UINT8*)texture_cache; |
| 1515 | UINT8 *tc = (UINT8*)TMEM; |
| 1514 | 1516 | int taddr = ((tbase + ((t) * twidth) + ((s) / 2)) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0x7ff; |
| 1515 | 1517 | 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]; |
| 1517 | 1519 | |
| 1518 | 1520 | if (other_modes.en_tlut) |
| 1519 | 1521 | { |
| r6406 | r6407 | |
| 1538 | 1540 | } |
| 1539 | 1541 | case PIXEL_SIZE_8BIT: |
| 1540 | 1542 | { |
| 1541 | | UINT8 *tc = (UINT8*)texture_cache; |
| 1543 | UINT8 *tc = (UINT8*)TMEM; |
| 1542 | 1544 | int taddr = ((tbase + ((t) * twidth) + ((s))) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0x7ff; |
| 1543 | 1545 | UINT8 p = tc[taddr ^ BYTE_ADDR_XOR]; |
| 1544 | | UINT16 c = tlut[p ^ WORD_ADDR_XOR]; |
| 1546 | UINT16 c = tlut[(p ^ WORD_ADDR_XOR) << 2]; |
| 1545 | 1547 | |
| 1546 | 1548 | if (other_modes.en_tlut) |
| 1547 | 1549 | { |
| r6406 | r6407 | |
| 1567 | 1569 | case PIXEL_SIZE_16BIT: |
| 1568 | 1570 | { |
| 1569 | 1571 | // 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; |
| 1571 | 1573 | int taddr = ((tbase>>1) + ((t) * (twidth>>1)) + (s)) ^ ((t & 1) ? XOR_SWAP_WORD : 0); |
| 1572 | 1574 | UINT16 c = tc[(taddr & 0x7ff) ^ WORD_ADDR_XOR]; // PGA European Tour (U) |
| 1573 | 1575 | |
| r6406 | r6407 | |
| 1609 | 1611 | { |
| 1610 | 1612 | case PIXEL_SIZE_4BIT: |
| 1611 | 1613 | { |
| 1612 | | UINT8 *tc = (UINT8*)texture_cache; |
| 1614 | UINT8 *tc = (UINT8*)TMEM; |
| 1613 | 1615 | int taddr = (tbase + ((t) * twidth) + (s >> 1)) ^ ((t & 1) ? XOR_SWAP_BYTE : 0); |
| 1614 | 1616 | UINT8 p = ((s) & 1) ? (tc[taddr ^ BYTE_ADDR_XOR] & 0xf) : (tc[taddr ^ BYTE_ADDR_XOR] >> 4); |
| 1615 | 1617 | UINT8 i = ((p & 0xe) << 4) | ((p & 0xe) << 1) | (p & 0xe >> 2); |
| r6406 | r6407 | |
| 1626 | 1628 | UINT16 c = tlut[((tpal << 4) | p) << 2]; |
| 1627 | 1629 | if (!other_modes.tlut_type) |
| 1628 | 1630 | { |
| 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); |
| 1632 | 1634 | color->a = (c & 1) ? 0xff : 0; |
| 1633 | 1635 | } |
| 1634 | 1636 | else |
| r6406 | r6407 | |
| 1641 | 1643 | } |
| 1642 | 1644 | case PIXEL_SIZE_8BIT: |
| 1643 | 1645 | { |
| 1644 | | UINT8 *tc = (UINT8*)texture_cache; |
| 1646 | UINT8 *tc = (UINT8*)TMEM; |
| 1645 | 1647 | int taddr = ((tbase + ((t) * twidth) + ((s))) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0xfff; |
| 1646 | 1648 | UINT8 p = tc[taddr ^ BYTE_ADDR_XOR]; |
| 1647 | 1649 | UINT8 i = 0; |
| r6406 | r6407 | |
| 1674 | 1676 | } |
| 1675 | 1677 | case PIXEL_SIZE_16BIT: |
| 1676 | 1678 | { |
| 1677 | | UINT16 *tc = (UINT16*)texture_cache; |
| 1679 | UINT16 *tc = (UINT16*)TMEM; |
| 1678 | 1680 | int taddr = ((tbase >> 1) + ((t) * (twidth >> 1)) + (s)) ^ ((t & 1) ? XOR_SWAP_WORD : 0); |
| 1679 | 1681 | UINT16 c = tc[taddr ^ WORD_ADDR_XOR]; |
| 1680 | 1682 | UINT8 i = (c >> 8); |
| r6406 | r6407 | |
| 1719 | 1721 | { |
| 1720 | 1722 | case PIXEL_SIZE_4BIT: |
| 1721 | 1723 | { |
| 1722 | | UINT8 *tc = (UINT8*)texture_cache; |
| 1724 | UINT8 *tc = (UINT8*)TMEM; |
| 1723 | 1725 | int taddr = ((tbase + ((t) * twidth) + ((s) / 2)) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0xfff; |
| 1724 | 1726 | UINT8 c = ((s) & 1) ? (tc[taddr ^ BYTE_ADDR_XOR] & 0xf) : (tc[taddr ^ BYTE_ADDR_XOR] >> 4); |
| 1725 | 1727 | c |= (c << 4); |
| r6406 | r6407 | |
| 1751 | 1753 | } |
| 1752 | 1754 | case PIXEL_SIZE_8BIT: |
| 1753 | 1755 | { |
| 1754 | | UINT8 *tc = (UINT8*)texture_cache; |
| 1756 | UINT8 *tc = (UINT8*)TMEM; |
| 1755 | 1757 | int taddr = ((tbase + ((t) * twidth) + ((s))) ^ ((t & 1) ? XOR_SWAP_BYTE : 0)) & 0xfff; |
| 1756 | 1758 | UINT8 c = tc[taddr ^ BYTE_ADDR_XOR]; |
| 1757 | 1759 | |
| r6406 | r6407 | |
| 5133 | 5135 | sh = tile[tilenum].sh = ((w2 >> 12) & 0xfff); |
| 5134 | 5136 | th = tile[tilenum].th = w2 & 0xfff; |
| 5135 | 5137 | |
| 5136 | | switch (ti_format) |
| 5138 | switch (ti_size) |
| 5137 | 5139 | { |
| 5138 | | case 0: // RGBA |
| 5140 | case PIXEL_SIZE_16BIT: |
| 5139 | 5141 | { |
| 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++) |
| 5141 | 5147 | { |
| 5142 | | case PIXEL_SIZE_16BIT: |
| 5148 | if((i*4) < 0x400) |
| 5143 | 5149 | { |
| 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; |
| 5151 | 5154 | } |
| 5152 | | default: fatalerror("RDP: load_tlut: size = %d\n", ti_size); |
| 5155 | //tlut[i] = src[i]; |
| 5153 | 5156 | } |
| 5154 | 5157 | break; |
| 5155 | 5158 | } |
| 5159 | /* |
| 5160 | case PIXEL_SIZE_16BIT: |
| 5161 | { |
| 5162 | UINT16 *src = (UINT16*)&rdram[(ti_address + (tl >> 2) * (ti_width << 1) + (sl >> 1)) >> 2]; |
| 5156 | 5163 | |
| 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); |
| 5158 | 5171 | } |
| 5172 | |
| 5173 | if (TMEM[0x1000] != 25 || TMEM[0x1001] != 25) |
| 5174 | { |
| 5175 | stricterror("rdp_load_tlut: TMEM has been written out-of-bounds"); |
| 5176 | } |
| 5159 | 5177 | } |
| 5160 | 5178 | |
| 5161 | 5179 | static RDP_COMMAND( rdp_set_tile_size ) |
| r6406 | r6407 | |
| 5211 | 5229 | } |
| 5212 | 5230 | |
| 5213 | 5231 | src = (UINT32*)&ram16[ti_address2 >> 1]; |
| 5214 | | tc = (UINT32*)texture_cache; |
| 5232 | tc = (UINT32*)TMEM; |
| 5215 | 5233 | tb = tile[tilenum].tmem >> 2; |
| 5216 | 5234 | |
| 5217 | 5235 | if ((tb + (width >> 2)) > 0x400) |
| r6406 | r6407 | |
| 5324 | 5342 | case PIXEL_SIZE_8BIT: |
| 5325 | 5343 | { |
| 5326 | 5344 | UINT8 *src = (UINT8*)rdram; |
| 5327 | | UINT8 *tc = (UINT8*)texture_cache; |
| 5345 | UINT8 *tc = (UINT8*)TMEM; |
| 5328 | 5346 | int tb = tile[tilenum].tmem; |
| 5329 | 5347 | |
| 5330 | 5348 | if (tb + (width * height) > 4096) |
| r6406 | r6407 | |
| 5354 | 5372 | { |
| 5355 | 5373 | UINT16 *src = (UINT16*)rdram; |
| 5356 | 5374 | UINT32 ti_addr16 = ti_address >> 1; |
| 5357 | | UINT16 *tc = (UINT16*)texture_cache; |
| 5375 | UINT16 *tc = (UINT16*)TMEM; |
| 5358 | 5376 | int tb = (tile[tilenum].tmem / 2); |
| 5359 | 5377 | int taddr; |
| 5360 | 5378 | |
| r6406 | r6407 | |
| 5394 | 5412 | case PIXEL_SIZE_32BIT: |
| 5395 | 5413 | { |
| 5396 | 5414 | UINT32 *src = (UINT32*)&rdram[ti_address / 4]; |
| 5397 | | UINT32 *tc = (UINT32*)texture_cache; |
| 5415 | UINT32 *tc = (UINT32*)TMEM; |
| 5398 | 5416 | int tb = (tile[tilenum].tmem / 4); |
| 5399 | 5417 | int xorval32 = ((fb_size == PIXEL_SIZE_16BIT) ? 2 : 1); |
| 5400 | 5418 | |
src/emu/cpu/mips/mips3drc.c
| r6406 | r6407 | |
| 1103 | 1103 | } |
| 1104 | 1104 | UML_TEST(block, IREG(1), IMM(VTLB_FETCH_ALLOWED)); // test i1,VTLB_FETCH_ALLOWED |
| 1105 | 1105 | 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 |
| 1108 | 1108 | UML_EXH(block, mips3->impstate->exception[EXCEPTION_TLBLOAD_FILL], IREG(0)); // exh exception[TLBLOAD_FILL],i0 |
| 1109 | 1109 | UML_LABEL(block, 1); // 1: |
| 1110 | 1110 | save_fast_iregs(mips3, block); |
| r6406 | r6407 | |
| 1157 | 1157 | |
| 1158 | 1158 | if (exception == EXCEPTION_TLBLOAD || exception == EXCEPTION_TLBSTORE) |
| 1159 | 1159 | { |
| 1160 | | offset = 0x000; |
| 1161 | 1160 | /* set the upper bits of EntryHi and the lower bits of Context to the fault page */ |
| 1162 | 1161 | 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 |
| 1164 | 1163 | } |
| 1165 | 1164 | |
| 1166 | 1165 | /* set the EPC and Cause registers */ |
| r6406 | r6407 | |
| 1176 | 1175 | UML_OR(block, IREG(2), IREG(2), IMM(0x80000000)); // or i2,i2,0x80000000 |
| 1177 | 1176 | UML_SUB(block, IREG(0), IREG(0), IMM(1)); // sub i0,i0,1 |
| 1178 | 1177 | UML_LABEL(block, next); // <next>: |
| 1178 | UML_MOV(block, IREG(3), IMM(offset)); // mov i3,offset |
| 1179 | 1179 | UML_TEST(block, CPR032(COP0_Status), IMM(SR_EXL)); // test [Status],SR_EXL |
| 1180 | 1180 | 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 |
| 1181 | 1182 | UML_OR(block, CPR032(COP0_Cause), IREG(2), IMM(exception << 2)); // or [Cause],i2,exception << 2 |
| 1182 | 1183 | |
| 1183 | 1184 | /* for BADCOP exceptions, we use the exception parameter to know which COP */ |
| r6406 | r6407 | |
| 1200 | 1201 | } |
| 1201 | 1202 | |
| 1202 | 1203 | /* 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 |
| 1204 | 1205 | 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 |
| 1206 | 1207 | |
| 1207 | 1208 | /* adjust cycles */ |
| 1208 | 1209 | UML_SUB(block, MEM(&mips3->icount), MEM(&mips3->icount), IREG(1)); // sub icount,icount,cycles,S |
| r6406 | r6407 | |
| 1426 | 1427 | UML_EXHc(block, IF_NZ, mips3->impstate->exception[EXCEPTION_TLBMOD], IREG(0)); |
| 1427 | 1428 | // exh tlbmod,i0,nz |
| 1428 | 1429 | } |
| 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 |
| 1431 | 1432 | UML_EXH(block, exception_tlbfill, IREG(0)); // exh tlbfill,i0 |
| 1432 | 1433 | } |
| 1433 | 1434 | |
src/emu/cpu/mips/mips3com.c
| r6406 | r6407 | |
| 86 | 86 | mips->icache_size = config->icache; |
| 87 | 87 | mips->dcache_size = config->dcache; |
| 88 | 88 | 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 | } |
| 89 | 100 | |
| 90 | 101 | /* set up the endianness */ |
| 91 | 102 | mips->memory = mips->program->accessors; |
| 92 | 103 | |
| 93 | 104 | /* 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); |
| 95 | 106 | |
| 96 | 107 | /* allocate a timer for the compare interrupt */ |
| 97 | 108 | mips->compare_int_timer = timer_alloc(device->machine, compare_int_callback, (void *)device); |
| r6406 | r6407 | |
| 106 | 117 | state_save_register_device_item_2d_array(device, 0, mips->ccr); |
| 107 | 118 | state_save_register_device_item(device, 0, mips->llbit); |
| 108 | 119 | 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++) |
| 110 | 121 | { |
| 111 | 122 | state_save_register_device_item(device, tlbindex, mips->tlb[tlbindex].page_mask); |
| 112 | 123 | state_save_register_device_item(device, tlbindex, mips->tlb[tlbindex].entry_hi); |
| r6406 | r6407 | |
| 146 | 157 | mips->count_zero_time = cpu_get_total_cycles(mips->device); |
| 147 | 158 | |
| 148 | 159 | /* initialize the TLB state */ |
| 149 | | for (tlbindex = 0; tlbindex < ARRAY_LENGTH(mips->tlb); tlbindex++) |
| 160 | for (tlbindex = 0; tlbindex < mips->tlbentries; tlbindex++) |
| 150 | 161 | { |
| 151 | 162 | mips3_tlb_entry *entry = &mips->tlb[tlbindex]; |
| 152 | 163 | entry->page_mask = 0; |
| r6406 | r6407 | |
| 158 | 169 | } |
| 159 | 170 | |
| 160 | 171 | /* 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); |
| 163 | 174 | } |
| 164 | 175 | |
| 165 | 176 | |
| r6406 | r6407 | |
| 216 | 227 | int tlbindex; |
| 217 | 228 | |
| 218 | 229 | /* 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++) |
| 220 | 231 | if (!tlb_entry_is_global(&mips->tlb[tlbindex])) |
| 221 | 232 | tlb_map_entry(mips, tlbindex); |
| 222 | 233 | } |
| r6406 | r6407 | |
| 251 | 262 | UINT32 tlbindex = mips->cpr[0][COP0_Index] & 0x3f; |
| 252 | 263 | |
| 253 | 264 | /* only handle entries within the TLB */ |
| 254 | | if (tlbindex < ARRAY_LENGTH(mips->tlb)) |
| 265 | if (tlbindex < mips->tlbentries) |
| 255 | 266 | { |
| 256 | 267 | mips3_tlb_entry *entry = &mips->tlb[tlbindex]; |
| 257 | 268 | |
| r6406 | r6407 | |
| 282 | 293 | void mips3com_tlbwr(mips3_state *mips) |
| 283 | 294 | { |
| 284 | 295 | 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; |
| 287 | 298 | |
| 288 | 299 | /* "random" is based off of the current cycle counting through the non-wired pages */ |
| 289 | 300 | if (unwired > 0) |
| r6406 | r6407 | |
| 304 | 315 | UINT64 vpn; |
| 305 | 316 | |
| 306 | 317 | /* iterate over TLB entries */ |
| 307 | | for (tlbindex = 0; tlbindex < ARRAY_LENGTH(mips->tlb); tlbindex++) |
| 318 | for (tlbindex = 0; tlbindex < mips->tlbentries; tlbindex++) |
| 308 | 319 | { |
| 309 | 320 | mips3_tlb_entry *entry = &mips->tlb[tlbindex]; |
| 310 | 321 | UINT64 mask = ~((entry->page_mask >> 13) & 0xfff) << 13; |
| r6406 | r6407 | |
| 319 | 330 | |
| 320 | 331 | /* validate that our tlb_table was in sync */ |
| 321 | 332 | vpn = ((mips->cpr[0][COP0_EntryHi] >> 13) & 0x07ffffff) << 1; |
| 322 | | if (tlbindex != ARRAY_LENGTH(mips->tlb)) |
| 333 | if (tlbindex != mips->tlbentries) |
| 323 | 334 | mips->cpr[0][COP0_Index] = tlbindex; |
| 324 | 335 | else |
| 325 | 336 | mips->cpr[0][COP0_Index] = 0x80000000; |
| r6406 | r6407 | |
| 892 | 903 | UINT32 pfn; |
| 893 | 904 | UINT32 flags = 0; |
| 894 | 905 | |
| 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; |
| 903 | 908 | |
| 904 | 909 | /* valid? */ |
| 905 | 910 | if ((lo & 2) != 0) |
| r6406 | r6407 | |
| 918 | 923 | /* load the virtual TLB with the corresponding entries */ |
| 919 | 924 | if ((effvpn + count) <= (0x80000000 >> MIPS3_MIN_PAGE_SHIFT) || effvpn >= (0xc0000000 >> MIPS3_MIN_PAGE_SHIFT)) |
| 920 | 925 | 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); |
| 921 | 928 | } |
| 922 | 929 | } |
| 923 | 930 | |
| r6406 | r6407 | |
| 930 | 937 | static void tlb_write_common(mips3_state *mips, int tlbindex) |
| 931 | 938 | { |
| 932 | 939 | /* only handle entries within the TLB */ |
| 933 | | if (tlbindex < ARRAY_LENGTH(mips->tlb)) |
| 940 | if (tlbindex < mips->tlbentries) |
| 934 | 941 | { |
| 935 | 942 | mips3_tlb_entry *entry = &mips->tlb[tlbindex]; |
| 936 | 943 | |