1fcf5ef2aSThomas Huth /* 2fcf5ef2aSThomas Huth * Miscellaneous PowerPC emulation helpers for QEMU. 3fcf5ef2aSThomas Huth * 4fcf5ef2aSThomas Huth * Copyright (c) 2003-2007 Jocelyn Mayer 5fcf5ef2aSThomas Huth * 6fcf5ef2aSThomas Huth * This library is free software; you can redistribute it and/or 7fcf5ef2aSThomas Huth * modify it under the terms of the GNU Lesser General Public 8fcf5ef2aSThomas Huth * License as published by the Free Software Foundation; either 96bd039cdSChetan Pant * version 2.1 of the License, or (at your option) any later version. 10fcf5ef2aSThomas Huth * 11fcf5ef2aSThomas Huth * This library is distributed in the hope that it will be useful, 12fcf5ef2aSThomas Huth * but WITHOUT ANY WARRANTY; without even the implied warranty of 13fcf5ef2aSThomas Huth * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14fcf5ef2aSThomas Huth * Lesser General Public License for more details. 15fcf5ef2aSThomas Huth * 16fcf5ef2aSThomas Huth * You should have received a copy of the GNU Lesser General Public 17fcf5ef2aSThomas Huth * License along with this library; if not, see <http://www.gnu.org/licenses/>. 18fcf5ef2aSThomas Huth */ 19db725815SMarkus Armbruster 20fcf5ef2aSThomas Huth #include "qemu/osdep.h" 21cd617484SPhilippe Mathieu-Daudé #include "qemu/log.h" 22fcf5ef2aSThomas Huth #include "cpu.h" 23fcf5ef2aSThomas Huth #include "exec/exec-all.h" 24fcf5ef2aSThomas Huth #include "exec/helper-proto.h" 256b375544SJoel Stanley #include "qemu/error-report.h" 26db725815SMarkus Armbruster #include "qemu/main-loop.h" 2722adb61fSBruno Larsen (billionai) #include "mmu-book3s-v3.h" 287b694df6SMatheus Ferst #include "hw/ppc/ppc.h" 29fcf5ef2aSThomas Huth 30fcf5ef2aSThomas Huth #include "helper_regs.h" 31fcf5ef2aSThomas Huth 32fcf5ef2aSThomas Huth /*****************************************************************************/ 33fcf5ef2aSThomas Huth /* SPR accesses */ 34fcf5ef2aSThomas Huth void helper_load_dump_spr(CPUPPCState *env, uint32_t sprn) 35fcf5ef2aSThomas Huth { 36fcf5ef2aSThomas Huth qemu_log("Read SPR %d %03x => " TARGET_FMT_lx "\n", sprn, sprn, 37fcf5ef2aSThomas Huth env->spr[sprn]); 38fcf5ef2aSThomas Huth } 39fcf5ef2aSThomas Huth 40fcf5ef2aSThomas Huth void helper_store_dump_spr(CPUPPCState *env, uint32_t sprn) 41fcf5ef2aSThomas Huth { 42fcf5ef2aSThomas Huth qemu_log("Write SPR %d %03x <= " TARGET_FMT_lx "\n", sprn, sprn, 43fcf5ef2aSThomas Huth env->spr[sprn]); 44fcf5ef2aSThomas Huth } 45fcf5ef2aSThomas Huth 46*9cdfd1b9SNicholas Piggin void helper_spr_core_write_generic(CPUPPCState *env, uint32_t sprn, 47*9cdfd1b9SNicholas Piggin target_ulong val) 48*9cdfd1b9SNicholas Piggin { 49*9cdfd1b9SNicholas Piggin CPUState *cs = env_cpu(env); 50*9cdfd1b9SNicholas Piggin CPUState *ccs; 51*9cdfd1b9SNicholas Piggin uint32_t nr_threads = cs->nr_threads; 52*9cdfd1b9SNicholas Piggin uint32_t core_id = env->spr[SPR_PIR] & ~(nr_threads - 1); 53*9cdfd1b9SNicholas Piggin 54*9cdfd1b9SNicholas Piggin assert(core_id == env->spr[SPR_PIR] - env->spr[SPR_TIR]); 55*9cdfd1b9SNicholas Piggin 56*9cdfd1b9SNicholas Piggin if (nr_threads == 1) { 57*9cdfd1b9SNicholas Piggin env->spr[sprn] = val; 58*9cdfd1b9SNicholas Piggin return; 59*9cdfd1b9SNicholas Piggin } 60*9cdfd1b9SNicholas Piggin 61*9cdfd1b9SNicholas Piggin THREAD_SIBLING_FOREACH(cs, ccs) { 62*9cdfd1b9SNicholas Piggin CPUPPCState *cenv = &POWERPC_CPU(ccs)->env; 63*9cdfd1b9SNicholas Piggin cenv->spr[sprn] = val; 64*9cdfd1b9SNicholas Piggin } 65*9cdfd1b9SNicholas Piggin } 66*9cdfd1b9SNicholas Piggin 67c5d98a7bSNicholas Piggin void helper_spr_write_CTRL(CPUPPCState *env, uint32_t sprn, 68c5d98a7bSNicholas Piggin target_ulong val) 69c5d98a7bSNicholas Piggin { 70c5d98a7bSNicholas Piggin CPUState *cs = env_cpu(env); 71c5d98a7bSNicholas Piggin CPUState *ccs; 72c5d98a7bSNicholas Piggin uint32_t run = val & 1; 73c5d98a7bSNicholas Piggin uint32_t ts, ts_mask; 74c5d98a7bSNicholas Piggin 75c5d98a7bSNicholas Piggin assert(sprn == SPR_CTRL); 76c5d98a7bSNicholas Piggin 77c5d98a7bSNicholas Piggin env->spr[sprn] &= ~1U; 78c5d98a7bSNicholas Piggin env->spr[sprn] |= run; 79c5d98a7bSNicholas Piggin 80c5d98a7bSNicholas Piggin ts_mask = ~(1U << (8 + env->spr[SPR_TIR])); 81c5d98a7bSNicholas Piggin ts = run << (8 + env->spr[SPR_TIR]); 82c5d98a7bSNicholas Piggin 83c5d98a7bSNicholas Piggin THREAD_SIBLING_FOREACH(cs, ccs) { 84c5d98a7bSNicholas Piggin CPUPPCState *cenv = &POWERPC_CPU(ccs)->env; 85c5d98a7bSNicholas Piggin 86c5d98a7bSNicholas Piggin cenv->spr[sprn] &= ts_mask; 87c5d98a7bSNicholas Piggin cenv->spr[sprn] |= ts; 88c5d98a7bSNicholas Piggin } 89c5d98a7bSNicholas Piggin } 90c5d98a7bSNicholas Piggin 91c5d98a7bSNicholas Piggin 92fcf5ef2aSThomas Huth #ifdef TARGET_PPC64 93493028d8SCédric Le Goater static void raise_hv_fu_exception(CPUPPCState *env, uint32_t bit, 94493028d8SCédric Le Goater const char *caller, uint32_t cause, 95493028d8SCédric Le Goater uintptr_t raddr) 96493028d8SCédric Le Goater { 97493028d8SCédric Le Goater qemu_log_mask(CPU_LOG_INT, "HV Facility %d is unavailable (%s)\n", 98493028d8SCédric Le Goater bit, caller); 99493028d8SCédric Le Goater 100493028d8SCédric Le Goater env->spr[SPR_HFSCR] &= ~((target_ulong)FSCR_IC_MASK << FSCR_IC_POS); 101493028d8SCédric Le Goater 102493028d8SCédric Le Goater raise_exception_err_ra(env, POWERPC_EXCP_HV_FU, cause, raddr); 103493028d8SCédric Le Goater } 104493028d8SCédric Le Goater 105fcf5ef2aSThomas Huth static void raise_fu_exception(CPUPPCState *env, uint32_t bit, 106fcf5ef2aSThomas Huth uint32_t sprn, uint32_t cause, 107fcf5ef2aSThomas Huth uintptr_t raddr) 108fcf5ef2aSThomas Huth { 109fcf5ef2aSThomas Huth qemu_log("Facility SPR %d is unavailable (SPR FSCR:%d)\n", sprn, bit); 110fcf5ef2aSThomas Huth 111fcf5ef2aSThomas Huth env->spr[SPR_FSCR] &= ~((target_ulong)FSCR_IC_MASK << FSCR_IC_POS); 112fcf5ef2aSThomas Huth cause &= FSCR_IC_MASK; 113fcf5ef2aSThomas Huth env->spr[SPR_FSCR] |= (target_ulong)cause << FSCR_IC_POS; 114fcf5ef2aSThomas Huth 115fcf5ef2aSThomas Huth raise_exception_err_ra(env, POWERPC_EXCP_FU, 0, raddr); 116fcf5ef2aSThomas Huth } 117fcf5ef2aSThomas Huth #endif 118fcf5ef2aSThomas Huth 119493028d8SCédric Le Goater void helper_hfscr_facility_check(CPUPPCState *env, uint32_t bit, 120493028d8SCédric Le Goater const char *caller, uint32_t cause) 121493028d8SCédric Le Goater { 122493028d8SCédric Le Goater #ifdef TARGET_PPC64 1239de754d3SVíctor Colombo if ((env->msr_mask & MSR_HVB) && !FIELD_EX64(env->msr, MSR, HV) && 124493028d8SCédric Le Goater !(env->spr[SPR_HFSCR] & (1UL << bit))) { 125493028d8SCédric Le Goater raise_hv_fu_exception(env, bit, caller, cause, GETPC()); 126493028d8SCédric Le Goater } 127493028d8SCédric Le Goater #endif 128493028d8SCédric Le Goater } 129493028d8SCédric Le Goater 130fcf5ef2aSThomas Huth void helper_fscr_facility_check(CPUPPCState *env, uint32_t bit, 131fcf5ef2aSThomas Huth uint32_t sprn, uint32_t cause) 132fcf5ef2aSThomas Huth { 133fcf5ef2aSThomas Huth #ifdef TARGET_PPC64 134fcf5ef2aSThomas Huth if (env->spr[SPR_FSCR] & (1ULL << bit)) { 135fcf5ef2aSThomas Huth /* Facility is enabled, continue */ 136fcf5ef2aSThomas Huth return; 137fcf5ef2aSThomas Huth } 138fcf5ef2aSThomas Huth raise_fu_exception(env, bit, sprn, cause, GETPC()); 139fcf5ef2aSThomas Huth #endif 140fcf5ef2aSThomas Huth } 141fcf5ef2aSThomas Huth 142fcf5ef2aSThomas Huth void helper_msr_facility_check(CPUPPCState *env, uint32_t bit, 143fcf5ef2aSThomas Huth uint32_t sprn, uint32_t cause) 144fcf5ef2aSThomas Huth { 145fcf5ef2aSThomas Huth #ifdef TARGET_PPC64 146fcf5ef2aSThomas Huth if (env->msr & (1ULL << bit)) { 147fcf5ef2aSThomas Huth /* Facility is enabled, continue */ 148fcf5ef2aSThomas Huth return; 149fcf5ef2aSThomas Huth } 150fcf5ef2aSThomas Huth raise_fu_exception(env, bit, sprn, cause, GETPC()); 151fcf5ef2aSThomas Huth #endif 152fcf5ef2aSThomas Huth } 153fcf5ef2aSThomas Huth 154fcf5ef2aSThomas Huth #if !defined(CONFIG_USER_ONLY) 155fcf5ef2aSThomas Huth 156fcf5ef2aSThomas Huth void helper_store_sdr1(CPUPPCState *env, target_ulong val) 157fcf5ef2aSThomas Huth { 158fcf5ef2aSThomas Huth if (env->spr[SPR_SDR1] != val) { 159fcf5ef2aSThomas Huth ppc_store_sdr1(env, val); 160db70b311SRichard Henderson tlb_flush(env_cpu(env)); 161fcf5ef2aSThomas Huth } 162fcf5ef2aSThomas Huth } 163fcf5ef2aSThomas Huth 1644a7518e0SCédric Le Goater #if defined(TARGET_PPC64) 1654a7518e0SCédric Le Goater void helper_store_ptcr(CPUPPCState *env, target_ulong val) 1664a7518e0SCédric Le Goater { 1674a7518e0SCédric Le Goater if (env->spr[SPR_PTCR] != val) { 16822adb61fSBruno Larsen (billionai) PowerPCCPU *cpu = env_archcpu(env); 16922adb61fSBruno Larsen (billionai) target_ulong ptcr_mask = PTCR_PATB | PTCR_PATS; 17022adb61fSBruno Larsen (billionai) target_ulong patbsize = val & PTCR_PATS; 17122adb61fSBruno Larsen (billionai) 17222adb61fSBruno Larsen (billionai) qemu_log_mask(CPU_LOG_MMU, "%s: " TARGET_FMT_lx "\n", __func__, val); 17322adb61fSBruno Larsen (billionai) 17422adb61fSBruno Larsen (billionai) assert(!cpu->vhyp); 17522adb61fSBruno Larsen (billionai) assert(env->mmu_model & POWERPC_MMU_3_00); 17622adb61fSBruno Larsen (billionai) 17722adb61fSBruno Larsen (billionai) if (val & ~ptcr_mask) { 17822adb61fSBruno Larsen (billionai) error_report("Invalid bits 0x"TARGET_FMT_lx" set in PTCR", 17922adb61fSBruno Larsen (billionai) val & ~ptcr_mask); 18022adb61fSBruno Larsen (billionai) val &= ptcr_mask; 18122adb61fSBruno Larsen (billionai) } 18222adb61fSBruno Larsen (billionai) 18322adb61fSBruno Larsen (billionai) if (patbsize > 24) { 18422adb61fSBruno Larsen (billionai) error_report("Invalid Partition Table size 0x" TARGET_FMT_lx 18522adb61fSBruno Larsen (billionai) " stored in PTCR", patbsize); 18622adb61fSBruno Larsen (billionai) return; 18722adb61fSBruno Larsen (billionai) } 18822adb61fSBruno Larsen (billionai) 18922adb61fSBruno Larsen (billionai) env->spr[SPR_PTCR] = val; 190db70b311SRichard Henderson tlb_flush(env_cpu(env)); 1914a7518e0SCédric Le Goater } 1924a7518e0SCédric Le Goater } 1936b375544SJoel Stanley 1946b375544SJoel Stanley void helper_store_pcr(CPUPPCState *env, target_ulong value) 1956b375544SJoel Stanley { 196db70b311SRichard Henderson PowerPCCPU *cpu = env_archcpu(env); 1976b375544SJoel Stanley PowerPCCPUClass *pcc = POWERPC_CPU_GET_CLASS(cpu); 1986b375544SJoel Stanley 1996b375544SJoel Stanley env->spr[SPR_PCR] = value & pcc->pcr_mask; 2006b375544SJoel Stanley } 2015ba7ba1dSCédric Le Goater 2025ba7ba1dSCédric Le Goater /* 2035ba7ba1dSCédric Le Goater * DPDES register is shared. Each bit reflects the state of the 2045ba7ba1dSCédric Le Goater * doorbell interrupt of a thread of the same core. 2055ba7ba1dSCédric Le Goater */ 2065ba7ba1dSCédric Le Goater target_ulong helper_load_dpdes(CPUPPCState *env) 2075ba7ba1dSCédric Le Goater { 208d24e80b2SNicholas Piggin CPUState *cs = env_cpu(env); 209d24e80b2SNicholas Piggin CPUState *ccs; 210d24e80b2SNicholas Piggin uint32_t nr_threads = cs->nr_threads; 2115ba7ba1dSCédric Le Goater target_ulong dpdes = 0; 2125ba7ba1dSCédric Le Goater 213493028d8SCédric Le Goater helper_hfscr_facility_check(env, HFSCR_MSGP, "load DPDES", HFSCR_IC_MSGP); 214493028d8SCédric Le Goater 2153401ea3cSNicholas Piggin if (!(env->flags & POWERPC_FLAG_SMT_1LPAR)) { 2163401ea3cSNicholas Piggin nr_threads = 1; /* DPDES behaves as 1-thread in LPAR-per-thread mode */ 2173401ea3cSNicholas Piggin } 2183401ea3cSNicholas Piggin 219d24e80b2SNicholas Piggin if (nr_threads == 1) { 220f003109fSMatheus Ferst if (env->pending_interrupts & PPC_INTERRUPT_DOORBELL) { 2215ba7ba1dSCédric Le Goater dpdes = 1; 2225ba7ba1dSCédric Le Goater } 223d24e80b2SNicholas Piggin return dpdes; 224d24e80b2SNicholas Piggin } 225d24e80b2SNicholas Piggin 226d24e80b2SNicholas Piggin qemu_mutex_lock_iothread(); 227d24e80b2SNicholas Piggin THREAD_SIBLING_FOREACH(cs, ccs) { 228d24e80b2SNicholas Piggin PowerPCCPU *ccpu = POWERPC_CPU(ccs); 229d24e80b2SNicholas Piggin CPUPPCState *cenv = &ccpu->env; 230d24e80b2SNicholas Piggin uint32_t thread_id = ppc_cpu_tir(ccpu); 231d24e80b2SNicholas Piggin 232d24e80b2SNicholas Piggin if (cenv->pending_interrupts & PPC_INTERRUPT_DOORBELL) { 233d24e80b2SNicholas Piggin dpdes |= (0x1 << thread_id); 234d24e80b2SNicholas Piggin } 235d24e80b2SNicholas Piggin } 236d24e80b2SNicholas Piggin qemu_mutex_unlock_iothread(); 2375ba7ba1dSCédric Le Goater 2385ba7ba1dSCédric Le Goater return dpdes; 2395ba7ba1dSCédric Le Goater } 2405ba7ba1dSCédric Le Goater 2415ba7ba1dSCédric Le Goater void helper_store_dpdes(CPUPPCState *env, target_ulong val) 2425ba7ba1dSCédric Le Goater { 2435ba7ba1dSCédric Le Goater PowerPCCPU *cpu = env_archcpu(env); 244d24e80b2SNicholas Piggin CPUState *cs = env_cpu(env); 245d24e80b2SNicholas Piggin CPUState *ccs; 246d24e80b2SNicholas Piggin uint32_t nr_threads = cs->nr_threads; 2475ba7ba1dSCédric Le Goater 248493028d8SCédric Le Goater helper_hfscr_facility_check(env, HFSCR_MSGP, "store DPDES", HFSCR_IC_MSGP); 249493028d8SCédric Le Goater 2503401ea3cSNicholas Piggin if (!(env->flags & POWERPC_FLAG_SMT_1LPAR)) { 2513401ea3cSNicholas Piggin nr_threads = 1; /* DPDES behaves as 1-thread in LPAR-per-thread mode */ 2523401ea3cSNicholas Piggin } 2533401ea3cSNicholas Piggin 254d24e80b2SNicholas Piggin if (val & ~(nr_threads - 1)) { 2555ba7ba1dSCédric Le Goater qemu_log_mask(LOG_GUEST_ERROR, "Invalid DPDES register value " 2565ba7ba1dSCédric Le Goater TARGET_FMT_lx"\n", val); 257d24e80b2SNicholas Piggin val &= (nr_threads - 1); /* Ignore the invalid bits */ 258d24e80b2SNicholas Piggin } 259d24e80b2SNicholas Piggin 260d24e80b2SNicholas Piggin if (nr_threads == 1) { 261d24e80b2SNicholas Piggin ppc_set_irq(cpu, PPC_INTERRUPT_DOORBELL, val & 0x1); 2625ba7ba1dSCédric Le Goater return; 2635ba7ba1dSCédric Le Goater } 2645ba7ba1dSCédric Le Goater 265d24e80b2SNicholas Piggin /* Does iothread need to be locked for walking CPU list? */ 266d24e80b2SNicholas Piggin qemu_mutex_lock_iothread(); 267d24e80b2SNicholas Piggin THREAD_SIBLING_FOREACH(cs, ccs) { 268d24e80b2SNicholas Piggin PowerPCCPU *ccpu = POWERPC_CPU(ccs); 269d24e80b2SNicholas Piggin uint32_t thread_id = ppc_cpu_tir(ccpu); 270d24e80b2SNicholas Piggin 271d24e80b2SNicholas Piggin ppc_set_irq(cpu, PPC_INTERRUPT_DOORBELL, val & (0x1 << thread_id)); 272d24e80b2SNicholas Piggin } 273d24e80b2SNicholas Piggin qemu_mutex_unlock_iothread(); 2745ba7ba1dSCédric Le Goater } 2754a7518e0SCédric Le Goater #endif /* defined(TARGET_PPC64) */ 2764a7518e0SCédric Le Goater 27731b2b0f8SSuraj Jitindar Singh void helper_store_pidr(CPUPPCState *env, target_ulong val) 27831b2b0f8SSuraj Jitindar Singh { 279fbda88f7SNicholas Piggin env->spr[SPR_BOOKS_PID] = (uint32_t)val; 280db70b311SRichard Henderson tlb_flush(env_cpu(env)); 28131b2b0f8SSuraj Jitindar Singh } 28231b2b0f8SSuraj Jitindar Singh 283c4dae9cdSBenjamin Herrenschmidt void helper_store_lpidr(CPUPPCState *env, target_ulong val) 284c4dae9cdSBenjamin Herrenschmidt { 285fbda88f7SNicholas Piggin env->spr[SPR_LPIDR] = (uint32_t)val; 286c4dae9cdSBenjamin Herrenschmidt 287c4dae9cdSBenjamin Herrenschmidt /* 288c4dae9cdSBenjamin Herrenschmidt * We need to flush the TLB on LPID changes as we only tag HV vs 289c4dae9cdSBenjamin Herrenschmidt * guest in TCG TLB. Also the quadrants means the HV will 290c4dae9cdSBenjamin Herrenschmidt * potentially access and cache entries for the current LPID as 291c4dae9cdSBenjamin Herrenschmidt * well. 292c4dae9cdSBenjamin Herrenschmidt */ 293db70b311SRichard Henderson tlb_flush(env_cpu(env)); 294c4dae9cdSBenjamin Herrenschmidt } 295c4dae9cdSBenjamin Herrenschmidt 296fcf5ef2aSThomas Huth void helper_store_40x_dbcr0(CPUPPCState *env, target_ulong val) 297fcf5ef2aSThomas Huth { 2987da31f26SRichard Henderson /* Bits 26 & 27 affect single-stepping. */ 2997da31f26SRichard Henderson hreg_compute_hflags(env); 3007da31f26SRichard Henderson /* Bits 28 & 29 affect reset or shutdown. */ 301fcf5ef2aSThomas Huth store_40x_dbcr0(env, val); 302fcf5ef2aSThomas Huth } 303fcf5ef2aSThomas Huth 304fcf5ef2aSThomas Huth void helper_store_40x_sler(CPUPPCState *env, target_ulong val) 305fcf5ef2aSThomas Huth { 306fcf5ef2aSThomas Huth store_40x_sler(env, val); 307fcf5ef2aSThomas Huth } 308fcf5ef2aSThomas Huth #endif 309fcf5ef2aSThomas Huth 310fcf5ef2aSThomas Huth /*****************************************************************************/ 311fcf5ef2aSThomas Huth /* Special registers manipulation */ 312fcf5ef2aSThomas Huth 313d81b4327SDavid Gibson /* 314d81b4327SDavid Gibson * This code is lifted from MacOnLinux. It is called whenever THRM1,2 315d81b4327SDavid Gibson * or 3 is read an fixes up the values in such a way that will make 316d81b4327SDavid Gibson * MacOS not hang. These registers exist on some 75x and 74xx 317d81b4327SDavid Gibson * processors. 318fcf5ef2aSThomas Huth */ 319fcf5ef2aSThomas Huth void helper_fixup_thrm(CPUPPCState *env) 320fcf5ef2aSThomas Huth { 321fcf5ef2aSThomas Huth target_ulong v, t; 322fcf5ef2aSThomas Huth int i; 323fcf5ef2aSThomas Huth 324fcf5ef2aSThomas Huth #define THRM1_TIN (1 << 31) 325fcf5ef2aSThomas Huth #define THRM1_TIV (1 << 30) 326fcf5ef2aSThomas Huth #define THRM1_THRES(x) (((x) & 0x7f) << 23) 327fcf5ef2aSThomas Huth #define THRM1_TID (1 << 2) 328fcf5ef2aSThomas Huth #define THRM1_TIE (1 << 1) 329fcf5ef2aSThomas Huth #define THRM1_V (1 << 0) 330fcf5ef2aSThomas Huth #define THRM3_E (1 << 0) 331fcf5ef2aSThomas Huth 332fcf5ef2aSThomas Huth if (!(env->spr[SPR_THRM3] & THRM3_E)) { 333fcf5ef2aSThomas Huth return; 334fcf5ef2aSThomas Huth } 335fcf5ef2aSThomas Huth 336fcf5ef2aSThomas Huth /* Note: Thermal interrupts are unimplemented */ 337fcf5ef2aSThomas Huth for (i = SPR_THRM1; i <= SPR_THRM2; i++) { 338fcf5ef2aSThomas Huth v = env->spr[i]; 339fcf5ef2aSThomas Huth if (!(v & THRM1_V)) { 340fcf5ef2aSThomas Huth continue; 341fcf5ef2aSThomas Huth } 342fcf5ef2aSThomas Huth v |= THRM1_TIV; 343fcf5ef2aSThomas Huth v &= ~THRM1_TIN; 344fcf5ef2aSThomas Huth t = v & THRM1_THRES(127); 345fcf5ef2aSThomas Huth if ((v & THRM1_TID) && t < THRM1_THRES(24)) { 346fcf5ef2aSThomas Huth v |= THRM1_TIN; 347fcf5ef2aSThomas Huth } 348fcf5ef2aSThomas Huth if (!(v & THRM1_TID) && t > THRM1_THRES(24)) { 349fcf5ef2aSThomas Huth v |= THRM1_TIN; 350fcf5ef2aSThomas Huth } 351fcf5ef2aSThomas Huth env->spr[i] = v; 352fcf5ef2aSThomas Huth } 353fcf5ef2aSThomas Huth } 354