~fboudra/qemu-linaro/new-upstream-release-1.2.0-2012.09-0ubuntu1

« back to all changes in this revision

Viewing changes to target-mips/op_helper.c

  • Committer: Fathi Boudra
  • Author(s): Fathi Boudra
  • Date: 2012-08-21 06:47:11 UTC
  • mfrom: (0.1.16)
  • Revision ID: fathi.boudra@linaro.org-20120821064711-7yxmubp2v8a44xce
Tags: 1.1.50-2012.08-0ubuntu1
* New upstream release.
  - support emulated systems with more than 2G of memory. (LP: #1030588)
* Drop powerpc-missing-include.patch - merged upstream.
* Update debian/control: 
  - drop perl build dependency.
  - add libfdt-dev build dependency.
* Update debian/qemu-keymaps.install file.
* Update debian/rules:
  - update QEMU_CPU for ARM architecture: armv4l -> armv7l.
  - update conf_audio_drv: default to PulseAudio since PA is the default on
    Ubuntu.
  - enable KVM on ARM architecture.
  - enable flat device tree support (--enable-fdt). (LP: #1030594)

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
#endif /* !defined(CONFIG_USER_ONLY) */
30
30
 
31
31
#ifndef CONFIG_USER_ONLY
32
 
static inline void cpu_mips_tlb_flush (CPUState *env, int flush_global);
 
32
static inline void cpu_mips_tlb_flush (CPUMIPSState *env, int flush_global);
33
33
#endif
34
34
 
35
 
static inline void compute_hflags(CPUState *env)
 
35
static inline void compute_hflags(CPUMIPSState *env)
36
36
{
37
37
    env->hflags &= ~(MIPS_HFLAG_COP1X | MIPS_HFLAG_64 | MIPS_HFLAG_CP0 |
38
38
                     MIPS_HFLAG_F64 | MIPS_HFLAG_FPU | MIPS_HFLAG_KSU |
101
101
}
102
102
 
103
103
#if !defined(CONFIG_USER_ONLY)
104
 
static void do_restore_state (void *pc_ptr)
 
104
static void do_restore_state(uintptr_t pc)
105
105
{
106
106
    TranslationBlock *tb;
107
 
    unsigned long pc = (unsigned long) pc_ptr;
108
 
    
 
107
 
109
108
    tb = tb_find_pc (pc);
110
109
    if (tb) {
111
110
        cpu_restore_state(tb, env, pc);
193
192
    return ((uint64_t)(env->active_tc.HI[0]) << 32) | (uint32_t)env->active_tc.LO[0];
194
193
}
195
194
 
196
 
static inline void set_HILO (uint64_t HILO)
197
 
{
198
 
    env->active_tc.LO[0] = (int32_t)HILO;
199
 
    env->active_tc.HI[0] = (int32_t)(HILO >> 32);
200
 
}
201
 
 
202
195
static inline void set_HIT0_LO (target_ulong arg1, uint64_t HILO)
203
196
{
204
197
    env->active_tc.LO[0] = (int32_t)(HILO & 0xFFFFFFFF);
750
743
 
751
744
#ifndef CONFIG_USER_ONLY
752
745
/* SMP helpers.  */
753
 
static int mips_vpe_is_wfi(CPUState *c)
 
746
static int mips_vpe_is_wfi(CPUMIPSState *c)
754
747
{
755
748
    /* If the VPE is halted but otherwise active, it means it's waiting for
756
749
       an interrupt.  */
757
750
    return c->halted && mips_vpe_active(c);
758
751
}
759
752
 
760
 
static inline void mips_vpe_wake(CPUState *c)
 
753
static inline void mips_vpe_wake(CPUMIPSState *c)
761
754
{
762
755
    /* Dont set ->halted = 0 directly, let it be done via cpu_has_work
763
756
       because there might be other conditions that state that c should
765
758
    cpu_interrupt(c, CPU_INTERRUPT_WAKE);
766
759
}
767
760
 
768
 
static inline void mips_vpe_sleep(CPUState *c)
 
761
static inline void mips_vpe_sleep(CPUMIPSState *c)
769
762
{
770
763
    /* The VPE was shut off, really go to bed.
771
764
       Reset any old _WAKE requests.  */
773
766
    cpu_reset_interrupt(c, CPU_INTERRUPT_WAKE);
774
767
}
775
768
 
776
 
static inline void mips_tc_wake(CPUState *c, int tc)
 
769
static inline void mips_tc_wake(CPUMIPSState *c, int tc)
777
770
{
778
771
    /* FIXME: TC reschedule.  */
779
772
    if (mips_vpe_active(c) && !mips_vpe_is_wfi(c)) {
781
774
    }
782
775
}
783
776
 
784
 
static inline void mips_tc_sleep(CPUState *c, int tc)
 
777
static inline void mips_tc_sleep(CPUMIPSState *c, int tc)
785
778
{
786
779
    /* FIXME: TC reschedule.  */
787
780
    if (!mips_vpe_active(c)) {
791
784
 
792
785
/* tc should point to an int with the value of the global TC index.
793
786
   This function will transform it into a local index within the
794
 
   returned CPUState.
 
787
   returned CPUMIPSState.
795
788
 
796
789
   FIXME: This code assumes that all VPEs have the same number of TCs,
797
790
          which depends on runtime setup. Can probably be fixed by
798
 
          walking the list of CPUStates.  */
799
 
static CPUState *mips_cpu_map_tc(int *tc)
 
791
          walking the list of CPUMIPSStates.  */
 
792
static CPUMIPSState *mips_cpu_map_tc(int *tc)
800
793
{
801
 
    CPUState *other;
 
794
    CPUMIPSState *other;
802
795
    int vpe_idx, nr_threads = env->nr_threads;
803
796
    int tc_idx = *tc;
804
797
 
823
816
   These helper call synchronizes the regs for a given cpu.  */
824
817
 
825
818
/* Called for updates to CP0_Status.  */
826
 
static void sync_c0_status(CPUState *cpu, int tc)
 
819
static void sync_c0_status(CPUMIPSState *cpu, int tc)
827
820
{
828
821
    int32_t tcstatus, *tcst;
829
822
    uint32_t v = cpu->CP0_Status;
858
851
}
859
852
 
860
853
/* Called for updates to CP0_TCStatus.  */
861
 
static void sync_c0_tcstatus(CPUState *cpu, int tc, target_ulong v)
 
854
static void sync_c0_tcstatus(CPUMIPSState *cpu, int tc, target_ulong v)
862
855
{
863
856
    uint32_t status;
864
857
    uint32_t tcu, tmx, tasid, tksu;
889
882
}
890
883
 
891
884
/* Called for updates to CP0_EntryHi.  */
892
 
static void sync_c0_entryhi(CPUState *cpu, int tc)
 
885
static void sync_c0_entryhi(CPUMIPSState *cpu, int tc)
893
886
{
894
887
    int32_t *tcst;
895
888
    uint32_t asid, v = cpu->CP0_EntryHi;
935
928
target_ulong helper_mftc0_tcstatus(void)
936
929
{
937
930
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
938
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
931
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
939
932
 
940
933
    if (other_tc == other->current_tc)
941
934
        return other->active_tc.CP0_TCStatus;
951
944
target_ulong helper_mftc0_tcbind(void)
952
945
{
953
946
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
954
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
947
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
955
948
 
956
949
    if (other_tc == other->current_tc)
957
950
        return other->active_tc.CP0_TCBind;
967
960
target_ulong helper_mftc0_tcrestart(void)
968
961
{
969
962
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
970
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
963
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
971
964
 
972
965
    if (other_tc == other->current_tc)
973
966
        return other->active_tc.PC;
983
976
target_ulong helper_mftc0_tchalt(void)
984
977
{
985
978
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
986
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
979
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
987
980
 
988
981
    if (other_tc == other->current_tc)
989
982
        return other->active_tc.CP0_TCHalt;
999
992
target_ulong helper_mftc0_tccontext(void)
1000
993
{
1001
994
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1002
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
995
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
1003
996
 
1004
997
    if (other_tc == other->current_tc)
1005
998
        return other->active_tc.CP0_TCContext;
1015
1008
target_ulong helper_mftc0_tcschedule(void)
1016
1009
{
1017
1010
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1018
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
1011
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
1019
1012
 
1020
1013
    if (other_tc == other->current_tc)
1021
1014
        return other->active_tc.CP0_TCSchedule;
1031
1024
target_ulong helper_mftc0_tcschefback(void)
1032
1025
{
1033
1026
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1034
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
1027
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
1035
1028
 
1036
1029
    if (other_tc == other->current_tc)
1037
1030
        return other->active_tc.CP0_TCScheFBack;
1047
1040
target_ulong helper_mftc0_entryhi(void)
1048
1041
{
1049
1042
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1050
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
1043
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
1051
1044
 
1052
1045
    return other->CP0_EntryHi;
1053
1046
}
1056
1049
{
1057
1050
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1058
1051
    int32_t tccause;
1059
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
1052
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
1060
1053
 
1061
1054
    if (other_tc == other->current_tc) {
1062
1055
        tccause = other->CP0_Cause;
1070
1063
target_ulong helper_mftc0_status(void)
1071
1064
{
1072
1065
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1073
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
1066
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
1074
1067
 
1075
1068
    return other->CP0_Status;
1076
1069
}
1103
1096
{
1104
1097
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1105
1098
    int32_t tcstatus;
1106
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
1099
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
1107
1100
 
1108
1101
    if (other_tc == other->current_tc)
1109
1102
        tcstatus = other->active_tc.CP0_Debug_tcstatus;
1201
1194
void helper_mttc0_vpecontrol(target_ulong arg1)
1202
1195
{
1203
1196
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1204
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
1197
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
1205
1198
    uint32_t mask;
1206
1199
    uint32_t newval;
1207
1200
 
1217
1210
target_ulong helper_mftc0_vpecontrol(void)
1218
1211
{
1219
1212
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1220
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
1213
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
1221
1214
    /* FIXME: Mask away return zero on read bits.  */
1222
1215
    return other->CP0_VPEControl;
1223
1216
}
1225
1218
target_ulong helper_mftc0_vpeconf0(void)
1226
1219
{
1227
1220
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1228
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
1221
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
1229
1222
 
1230
1223
    return other->CP0_VPEConf0;
1231
1224
}
1250
1243
void helper_mttc0_vpeconf0(target_ulong arg1)
1251
1244
{
1252
1245
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1253
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
1246
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
1254
1247
    uint32_t mask = 0;
1255
1248
    uint32_t newval;
1256
1249
 
1311
1304
void helper_mttc0_tcstatus (target_ulong arg1)
1312
1305
{
1313
1306
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1314
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
1307
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
1315
1308
 
1316
1309
    if (other_tc == other->current_tc)
1317
1310
        other->active_tc.CP0_TCStatus = arg1;
1336
1329
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1337
1330
    uint32_t mask = (1 << CP0TCBd_TBE);
1338
1331
    uint32_t newval;
1339
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
1332
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
1340
1333
 
1341
1334
    if (other->mvp->CP0_MVPControl & (1 << CP0MVPCo_VPC))
1342
1335
        mask |= (1 << CP0TCBd_CurVPE);
1360
1353
void helper_mttc0_tcrestart (target_ulong arg1)
1361
1354
{
1362
1355
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1363
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
1356
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
1364
1357
 
1365
1358
    if (other_tc == other->current_tc) {
1366
1359
        other->active_tc.PC = arg1;
1390
1383
void helper_mttc0_tchalt (target_ulong arg1)
1391
1384
{
1392
1385
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1393
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
1386
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
1394
1387
 
1395
1388
    // TODO: Halt TC / Restart (if allocated+active) TC.
1396
1389
 
1414
1407
void helper_mttc0_tccontext (target_ulong arg1)
1415
1408
{
1416
1409
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1417
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
1410
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
1418
1411
 
1419
1412
    if (other_tc == other->current_tc)
1420
1413
        other->active_tc.CP0_TCContext = arg1;
1430
1423
void helper_mttc0_tcschedule (target_ulong arg1)
1431
1424
{
1432
1425
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1433
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
1426
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
1434
1427
 
1435
1428
    if (other_tc == other->current_tc)
1436
1429
        other->active_tc.CP0_TCSchedule = arg1;
1446
1439
void helper_mttc0_tcschefback (target_ulong arg1)
1447
1440
{
1448
1441
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1449
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
1442
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
1450
1443
 
1451
1444
    if (other_tc == other->current_tc)
1452
1445
        other->active_tc.CP0_TCScheFBack = arg1;
1542
1535
void helper_mttc0_entryhi(target_ulong arg1)
1543
1536
{
1544
1537
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1545
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
1538
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
1546
1539
 
1547
1540
    other->CP0_EntryHi = arg1;
1548
1541
    sync_c0_entryhi(other, other_tc);
1584
1577
void helper_mttc0_status(target_ulong arg1)
1585
1578
{
1586
1579
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1587
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
1580
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
1588
1581
 
1589
1582
    other->CP0_Status = arg1 & ~0xf1000018;
1590
1583
    sync_c0_status(other, other_tc);
1602
1595
    env->CP0_SRSCtl = (env->CP0_SRSCtl & ~mask) | (arg1 & mask);
1603
1596
}
1604
1597
 
1605
 
static void mtc0_cause(CPUState *cpu, target_ulong arg1)
 
1598
static void mtc0_cause(CPUMIPSState *cpu, target_ulong arg1)
1606
1599
{
1607
1600
    uint32_t mask = 0x00C00300;
1608
1601
    uint32_t old = cpu->CP0_Cause;
1638
1631
void helper_mttc0_cause(target_ulong arg1)
1639
1632
{
1640
1633
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1641
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
1634
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
1642
1635
 
1643
1636
    mtc0_cause(other, arg1);
1644
1637
}
1646
1639
target_ulong helper_mftc0_epc(void)
1647
1640
{
1648
1641
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1649
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
1642
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
1650
1643
 
1651
1644
    return other->CP0_EPC;
1652
1645
}
1654
1647
target_ulong helper_mftc0_ebase(void)
1655
1648
{
1656
1649
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1657
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
1650
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
1658
1651
 
1659
1652
    return other->CP0_EBase;
1660
1653
}
1668
1661
void helper_mttc0_ebase(target_ulong arg1)
1669
1662
{
1670
1663
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1671
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
1664
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
1672
1665
    other->CP0_EBase = (other->CP0_EBase & ~0x3FFFF000) | (arg1 & 0x3FFFF000);
1673
1666
}
1674
1667
 
1675
1668
target_ulong helper_mftc0_configx(target_ulong idx)
1676
1669
{
1677
1670
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1678
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
1671
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
1679
1672
 
1680
1673
    switch (idx) {
1681
1674
    case 0: return other->CP0_Config0;
1746
1739
{
1747
1740
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1748
1741
    uint32_t val = arg1 & ((1 << CP0DB_SSt) | (1 << CP0DB_Halt));
1749
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
1742
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
1750
1743
 
1751
1744
    /* XXX: Might be wrong, check with EJTAG spec. */
1752
1745
    if (other_tc == other->current_tc)
1787
1780
target_ulong helper_mftgpr(uint32_t sel)
1788
1781
{
1789
1782
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1790
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
1783
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
1791
1784
 
1792
1785
    if (other_tc == other->current_tc)
1793
1786
        return other->active_tc.gpr[sel];
1798
1791
target_ulong helper_mftlo(uint32_t sel)
1799
1792
{
1800
1793
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1801
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
1794
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
1802
1795
 
1803
1796
    if (other_tc == other->current_tc)
1804
1797
        return other->active_tc.LO[sel];
1809
1802
target_ulong helper_mfthi(uint32_t sel)
1810
1803
{
1811
1804
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1812
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
1805
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
1813
1806
 
1814
1807
    if (other_tc == other->current_tc)
1815
1808
        return other->active_tc.HI[sel];
1820
1813
target_ulong helper_mftacx(uint32_t sel)
1821
1814
{
1822
1815
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1823
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
1816
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
1824
1817
 
1825
1818
    if (other_tc == other->current_tc)
1826
1819
        return other->active_tc.ACX[sel];
1831
1824
target_ulong helper_mftdsp(void)
1832
1825
{
1833
1826
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1834
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
1827
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
1835
1828
 
1836
1829
    if (other_tc == other->current_tc)
1837
1830
        return other->active_tc.DSPControl;
1842
1835
void helper_mttgpr(target_ulong arg1, uint32_t sel)
1843
1836
{
1844
1837
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1845
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
1838
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
1846
1839
 
1847
1840
    if (other_tc == other->current_tc)
1848
1841
        other->active_tc.gpr[sel] = arg1;
1853
1846
void helper_mttlo(target_ulong arg1, uint32_t sel)
1854
1847
{
1855
1848
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1856
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
1849
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
1857
1850
 
1858
1851
    if (other_tc == other->current_tc)
1859
1852
        other->active_tc.LO[sel] = arg1;
1864
1857
void helper_mtthi(target_ulong arg1, uint32_t sel)
1865
1858
{
1866
1859
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1867
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
1860
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
1868
1861
 
1869
1862
    if (other_tc == other->current_tc)
1870
1863
        other->active_tc.HI[sel] = arg1;
1875
1868
void helper_mttacx(target_ulong arg1, uint32_t sel)
1876
1869
{
1877
1870
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1878
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
1871
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
1879
1872
 
1880
1873
    if (other_tc == other->current_tc)
1881
1874
        other->active_tc.ACX[sel] = arg1;
1886
1879
void helper_mttdsp(target_ulong arg1)
1887
1880
{
1888
1881
    int other_tc = env->CP0_VPEControl & (0xff << CP0VPECo_TargTC);
1889
 
    CPUState *other = mips_cpu_map_tc(&other_tc);
 
1882
    CPUMIPSState *other = mips_cpu_map_tc(&other_tc);
1890
1883
 
1891
1884
    if (other_tc == other->current_tc)
1892
1885
        other->active_tc.DSPControl = arg1;
1909
1902
 
1910
1903
target_ulong helper_dvpe(void)
1911
1904
{
1912
 
    CPUState *other_cpu = first_cpu;
 
1905
    CPUMIPSState *other_cpu = first_cpu;
1913
1906
    target_ulong prev = env->mvp->CP0_MVPControl;
1914
1907
 
1915
1908
    do {
1925
1918
 
1926
1919
target_ulong helper_evpe(void)
1927
1920
{
1928
 
    CPUState *other_cpu = first_cpu;
 
1921
    CPUMIPSState *other_cpu = first_cpu;
1929
1922
    target_ulong prev = env->mvp->CP0_MVPControl;
1930
1923
 
1931
1924
    do {
1932
1925
        if (other_cpu != env
1933
 
           /* If the VPE is WFI, dont distrub it's sleep.  */
 
1926
           /* If the VPE is WFI, don't disturb its sleep.  */
1934
1927
           && !mips_vpe_is_wfi(other_cpu)) {
1935
1928
            /* Enable the VPE.  */
1936
1929
            other_cpu->mvp->CP0_MVPControl |= (1 << CP0MVPCo_EVP);
1981
1974
 
1982
1975
#ifndef CONFIG_USER_ONLY
1983
1976
/* TLB management */
1984
 
static void cpu_mips_tlb_flush (CPUState *env, int flush_global)
 
1977
static void cpu_mips_tlb_flush (CPUMIPSState *env, int flush_global)
1985
1978
{
1986
1979
    /* Flush qemu's TLB and discard all shadowed entries.  */
1987
1980
    tlb_flush (env, flush_global);
1988
1981
    env->tlb->tlb_in_use = env->tlb->nb_tlb;
1989
1982
}
1990
1983
 
1991
 
static void r4k_mips_tlb_flush_extra (CPUState *env, int first)
 
1984
static void r4k_mips_tlb_flush_extra (CPUMIPSState *env, int first)
1992
1985
{
1993
1986
    /* Discard entries from env->tlb[first] onwards.  */
1994
1987
    while (env->tlb->tlb_in_use > first) {
2276
2269
        break;
2277
2270
    case 158:
2278
2271
        {
2279
 
            unsigned char *fmt = (void *)(unsigned long)env->active_tc.gpr[4];
 
2272
            unsigned char *fmt = (void *)(uintptr_t)env->active_tc.gpr[4];
2280
2273
            printf("%s", fmt);
2281
2274
        }
2282
2275
        break;
2292
2285
 
2293
2286
#if !defined(CONFIG_USER_ONLY)
2294
2287
 
2295
 
static void do_unaligned_access (target_ulong addr, int is_write, int is_user, void *retaddr);
 
2288
static void QEMU_NORETURN do_unaligned_access(target_ulong addr, int is_write,
 
2289
                                              int is_user, uintptr_t retaddr);
2296
2290
 
2297
2291
#define MMUSUFFIX _mmu
2298
2292
#define ALIGNED_ONLY
2309
2303
#define SHIFT 3
2310
2304
#include "softmmu_template.h"
2311
2305
 
2312
 
static void do_unaligned_access (target_ulong addr, int is_write, int is_user, void *retaddr)
 
2306
static void do_unaligned_access(target_ulong addr, int is_write,
 
2307
                                int is_user, uintptr_t retaddr)
2313
2308
{
2314
2309
    env->CP0_BadVAddr = addr;
2315
2310
    do_restore_state (retaddr);
2316
2311
    helper_raise_exception ((is_write == 1) ? EXCP_AdES : EXCP_AdEL);
2317
2312
}
2318
2313
 
2319
 
void tlb_fill(CPUState *env1, target_ulong addr, int is_write, int mmu_idx,
2320
 
              void *retaddr)
 
2314
void tlb_fill(CPUMIPSState *env1, target_ulong addr, int is_write, int mmu_idx,
 
2315
              uintptr_t retaddr)
2321
2316
{
2322
2317
    TranslationBlock *tb;
2323
 
    CPUState *saved_env;
2324
 
    unsigned long pc;
 
2318
    CPUMIPSState *saved_env;
2325
2319
    int ret;
2326
2320
 
2327
2321
    saved_env = env;
2330
2324
    if (ret) {
2331
2325
        if (retaddr) {
2332
2326
            /* now we have a real cpu fault */
2333
 
            pc = (unsigned long)retaddr;
2334
 
            tb = tb_find_pc(pc);
 
2327
            tb = tb_find_pc(retaddr);
2335
2328
            if (tb) {
2336
2329
                /* the PC is inside the translated code. It means that we have
2337
2330
                   a virtual CPU fault */
2338
 
                cpu_restore_state(tb, env, pc);
 
2331
                cpu_restore_state(tb, env, retaddr);
2339
2332
            }
2340
2333
        }
2341
2334
        helper_raise_exception_err(env->exception_index, env->error_code);
2343
2336
    env = saved_env;
2344
2337
}
2345
2338
 
2346
 
void cpu_unassigned_access(CPUState *env1, target_phys_addr_t addr,
 
2339
void cpu_unassigned_access(CPUMIPSState *env1, target_phys_addr_t addr,
2347
2340
                           int is_write, int is_exec, int unused, int size)
2348
2341
{
2349
2342
    env = env1;