mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-04 08:13:54 -06:00
target/openrisc: Support non-busy idle state using PMR SPR
The OpenRISC architecture has the Power Management Register (PMR) special purpose register to manage cpu power states. The interesting modes are: * Doze Mode (DME) - Stop cpu except timer & pic - wake on interrupt * Sleep Mode (SME) - Stop cpu and all units - wake on interrupt * Suspend Model (SUME) - Stop cpu and all units - wake on reset The linux kernel will set DME when idle. This patch implements the PMR SPR and halts the qemu cpu when there is a change to DME or SME. This means that openrisc qemu in no longer peggs a host cpu at 100%. In order for this to work we need to kick the CPU when timers are expired. Update the cpu timer to kick the cpu upon each timer event. Reviewed-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Stafford Horne <shorne@gmail.com>
This commit is contained in:
parent
48a1b62baa
commit
f4d1414a93
6 changed files with 29 additions and 1 deletions
|
@ -22,6 +22,7 @@
|
|||
#include "cpu.h"
|
||||
#include "exec/exec-all.h"
|
||||
#include "exec/helper-proto.h"
|
||||
#include "exception.h"
|
||||
|
||||
#define TO_SPR(group, number) (((group) << 11) + (number))
|
||||
|
||||
|
@ -141,6 +142,15 @@ void HELPER(mtspr)(CPUOpenRISCState *env,
|
|||
case TO_SPR(5, 2): /* MACHI */
|
||||
env->mac = deposit64(env->mac, 32, 32, rb);
|
||||
break;
|
||||
case TO_SPR(8, 0): /* PMR */
|
||||
env->pmr = rb;
|
||||
if (env->pmr & PMR_DME || env->pmr & PMR_SME) {
|
||||
cpu_restore_state(cs, GETPC());
|
||||
env->pc += 4;
|
||||
cs->halted = 1;
|
||||
raise_exception(cpu, EXCP_HALTED);
|
||||
}
|
||||
break;
|
||||
case TO_SPR(9, 0): /* PICMR */
|
||||
env->picmr |= rb;
|
||||
break;
|
||||
|
@ -287,6 +297,9 @@ target_ulong HELPER(mfspr)(CPUOpenRISCState *env,
|
|||
return env->mac >> 32;
|
||||
break;
|
||||
|
||||
case TO_SPR(8, 0): /* PMR */
|
||||
return env->pmr;
|
||||
|
||||
case TO_SPR(9, 0): /* PICMR */
|
||||
return env->picmr;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue