提交 c4241c7d 编写于 作者: P Peter Maydell

target-arm: Drop success/fail return from cpreg read and write functions

All cpreg read and write functions now return 0, so we can clean up
their prototypes:
 * write functions return void
 * read functions return the value rather than taking a pointer
   to write the value to

This is a fairly mechanical change which makes only the bare
minimum set of changes to the callers of read and write functions.
Signed-off-by: NPeter Maydell <peter.maydell@linaro.org>
Reviewed-by: NPeter Crosthwaite <peter.crosthwaite@xilinx.com>
上级 92611c00
...@@ -224,27 +224,24 @@ static const VMStateDescription vmstate_pxa2xx_cm = { ...@@ -224,27 +224,24 @@ static const VMStateDescription vmstate_pxa2xx_cm = {
} }
}; };
static int pxa2xx_clkcfg_read(CPUARMState *env, const ARMCPRegInfo *ri, static uint64_t pxa2xx_clkcfg_read(CPUARMState *env, const ARMCPRegInfo *ri)
uint64_t *value)
{ {
PXA2xxState *s = (PXA2xxState *)ri->opaque; PXA2xxState *s = (PXA2xxState *)ri->opaque;
*value = s->clkcfg; return s->clkcfg;
return 0;
} }
static int pxa2xx_clkcfg_write(CPUARMState *env, const ARMCPRegInfo *ri, static void pxa2xx_clkcfg_write(CPUARMState *env, const ARMCPRegInfo *ri,
uint64_t value) uint64_t value)
{ {
PXA2xxState *s = (PXA2xxState *)ri->opaque; PXA2xxState *s = (PXA2xxState *)ri->opaque;
s->clkcfg = value & 0xf; s->clkcfg = value & 0xf;
if (value & 2) { if (value & 2) {
printf("%s: CPU frequency change attempt\n", __func__); printf("%s: CPU frequency change attempt\n", __func__);
} }
return 0;
} }
static int pxa2xx_pwrmode_write(CPUARMState *env, const ARMCPRegInfo *ri, static void pxa2xx_pwrmode_write(CPUARMState *env, const ARMCPRegInfo *ri,
uint64_t value) uint64_t value)
{ {
PXA2xxState *s = (PXA2xxState *)ri->opaque; PXA2xxState *s = (PXA2xxState *)ri->opaque;
static const char *pwrmode[8] = { static const char *pwrmode[8] = {
...@@ -310,36 +307,29 @@ static int pxa2xx_pwrmode_write(CPUARMState *env, const ARMCPRegInfo *ri, ...@@ -310,36 +307,29 @@ static int pxa2xx_pwrmode_write(CPUARMState *env, const ARMCPRegInfo *ri,
printf("%s: machine entered %s mode\n", __func__, printf("%s: machine entered %s mode\n", __func__,
pwrmode[value & 7]); pwrmode[value & 7]);
} }
return 0;
} }
static int pxa2xx_cppmnc_read(CPUARMState *env, const ARMCPRegInfo *ri, static uint64_t pxa2xx_cppmnc_read(CPUARMState *env, const ARMCPRegInfo *ri)
uint64_t *value)
{ {
PXA2xxState *s = (PXA2xxState *)ri->opaque; PXA2xxState *s = (PXA2xxState *)ri->opaque;
*value = s->pmnc; return s->pmnc;
return 0;
} }
static int pxa2xx_cppmnc_write(CPUARMState *env, const ARMCPRegInfo *ri, static void pxa2xx_cppmnc_write(CPUARMState *env, const ARMCPRegInfo *ri,
uint64_t value) uint64_t value)
{ {
PXA2xxState *s = (PXA2xxState *)ri->opaque; PXA2xxState *s = (PXA2xxState *)ri->opaque;
s->pmnc = value; s->pmnc = value;
return 0;
} }
static int pxa2xx_cpccnt_read(CPUARMState *env, const ARMCPRegInfo *ri, static uint64_t pxa2xx_cpccnt_read(CPUARMState *env, const ARMCPRegInfo *ri)
uint64_t *value)
{ {
PXA2xxState *s = (PXA2xxState *)ri->opaque; PXA2xxState *s = (PXA2xxState *)ri->opaque;
if (s->pmnc & 1) { if (s->pmnc & 1) {
*value = qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL); return qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
} else { } else {
*value = 0; return 0;
} }
return 0;
} }
static const ARMCPRegInfo pxa_cp_reginfo[] = { static const ARMCPRegInfo pxa_cp_reginfo[] = {
......
...@@ -217,20 +217,17 @@ static const int pxa2xx_cp_reg_map[0x10] = { ...@@ -217,20 +217,17 @@ static const int pxa2xx_cp_reg_map[0x10] = {
[0xa] = ICPR2, [0xa] = ICPR2,
}; };
static int pxa2xx_pic_cp_read(CPUARMState *env, const ARMCPRegInfo *ri, static uint64_t pxa2xx_pic_cp_read(CPUARMState *env, const ARMCPRegInfo *ri)
uint64_t *value)
{ {
int offset = pxa2xx_cp_reg_map[ri->crn]; int offset = pxa2xx_cp_reg_map[ri->crn];
*value = pxa2xx_pic_mem_read(ri->opaque, offset, 4); return pxa2xx_pic_mem_read(ri->opaque, offset, 4);
return 0;
} }
static int pxa2xx_pic_cp_write(CPUARMState *env, const ARMCPRegInfo *ri, static void pxa2xx_pic_cp_write(CPUARMState *env, const ARMCPRegInfo *ri,
uint64_t value) uint64_t value)
{ {
int offset = pxa2xx_cp_reg_map[ri->crn]; int offset = pxa2xx_cp_reg_map[ri->crn];
pxa2xx_pic_mem_write(ri->opaque, offset, value, 4); pxa2xx_pic_mem_write(ri->opaque, offset, value, 4);
return 0;
} }
#define REGINFO_FOR_PIC_CP(NAME, CRN) \ #define REGINFO_FOR_PIC_CP(NAME, CRN) \
......
...@@ -681,14 +681,12 @@ static void cortex_a9_initfn(Object *obj) ...@@ -681,14 +681,12 @@ static void cortex_a9_initfn(Object *obj)
} }
#ifndef CONFIG_USER_ONLY #ifndef CONFIG_USER_ONLY
static int a15_l2ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri, static uint64_t a15_l2ctlr_read(CPUARMState *env, const ARMCPRegInfo *ri)
uint64_t *value)
{ {
/* Linux wants the number of processors from here. /* Linux wants the number of processors from here.
* Might as well set the interrupt-controller bit too. * Might as well set the interrupt-controller bit too.
*/ */
*value = ((smp_cpus - 1) << 24) | (1 << 23); return ((smp_cpus - 1) << 24) | (1 << 23);
return 0;
} }
#endif #endif
......
...@@ -827,11 +827,12 @@ typedef enum CPAccessResult { ...@@ -827,11 +827,12 @@ typedef enum CPAccessResult {
CP_ACCESS_TRAP_UNCATEGORIZED = 2, CP_ACCESS_TRAP_UNCATEGORIZED = 2,
} CPAccessResult; } CPAccessResult;
/* Access functions for coprocessor registers. These should always succeed. */ /* Access functions for coprocessor registers. These cannot fail and
typedef int CPReadFn(CPUARMState *env, const ARMCPRegInfo *opaque, * may not raise exceptions.
uint64_t *value); */
typedef int CPWriteFn(CPUARMState *env, const ARMCPRegInfo *opaque, typedef uint64_t CPReadFn(CPUARMState *env, const ARMCPRegInfo *opaque);
uint64_t value); typedef void CPWriteFn(CPUARMState *env, const ARMCPRegInfo *opaque,
uint64_t value);
/* Access permission check functions for coprocessor registers. */ /* Access permission check functions for coprocessor registers. */
typedef CPAccessResult CPAccessFn(CPUARMState *env, const ARMCPRegInfo *opaque); typedef CPAccessResult CPAccessFn(CPUARMState *env, const ARMCPRegInfo *opaque);
/* Hook function for register reset */ /* Hook function for register reset */
...@@ -906,14 +907,14 @@ struct ARMCPRegInfo { ...@@ -906,14 +907,14 @@ struct ARMCPRegInfo {
/* Function for doing a "raw" read; used when we need to copy /* Function for doing a "raw" read; used when we need to copy
* coprocessor state to the kernel for KVM or out for * coprocessor state to the kernel for KVM or out for
* migration. This only needs to be provided if there is also a * migration. This only needs to be provided if there is also a
* readfn and it makes an access permission check. * readfn and it has side effects (for instance clear-on-read bits).
*/ */
CPReadFn *raw_readfn; CPReadFn *raw_readfn;
/* Function for doing a "raw" write; used when we need to copy KVM /* Function for doing a "raw" write; used when we need to copy KVM
* kernel coprocessor state into userspace, or for inbound * kernel coprocessor state into userspace, or for inbound
* migration. This only needs to be provided if there is also a * migration. This only needs to be provided if there is also a
* writefn and it makes an access permission check or masks out * writefn and it masks out "unwritable" bits or has write-one-to-clear
* "unwritable" bits or has write-one-to-clear or similar behaviour. * or similar behaviour.
*/ */
CPWriteFn *raw_writefn; CPWriteFn *raw_writefn;
/* Function for resetting the register. If NULL, then reset will be done /* Function for resetting the register. If NULL, then reset will be done
...@@ -948,10 +949,10 @@ static inline void define_one_arm_cp_reg(ARMCPU *cpu, const ARMCPRegInfo *regs) ...@@ -948,10 +949,10 @@ static inline void define_one_arm_cp_reg(ARMCPU *cpu, const ARMCPRegInfo *regs)
const ARMCPRegInfo *get_arm_cp_reginfo(GHashTable *cpregs, uint32_t encoded_cp); const ARMCPRegInfo *get_arm_cp_reginfo(GHashTable *cpregs, uint32_t encoded_cp);
/* CPWriteFn that can be used to implement writes-ignored behaviour */ /* CPWriteFn that can be used to implement writes-ignored behaviour */
int arm_cp_write_ignore(CPUARMState *env, const ARMCPRegInfo *ri, void arm_cp_write_ignore(CPUARMState *env, const ARMCPRegInfo *ri,
uint64_t value); uint64_t value);
/* CPReadFn that can be used for read-as-zero behaviour */ /* CPReadFn that can be used for read-as-zero behaviour */
int arm_cp_read_zero(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t *value); uint64_t arm_cp_read_zero(CPUARMState *env, const ARMCPRegInfo *ri);
/* CPResetFn that does nothing, for use if no reset is required even /* CPResetFn that does nothing, for use if no reset is required even
* if fieldoffset is non zero. * if fieldoffset is non zero.
......
此差异已折叠。
...@@ -294,41 +294,29 @@ void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip) ...@@ -294,41 +294,29 @@ void HELPER(access_check_cp_reg)(CPUARMState *env, void *rip)
void HELPER(set_cp_reg)(CPUARMState *env, void *rip, uint32_t value) void HELPER(set_cp_reg)(CPUARMState *env, void *rip, uint32_t value)
{ {
const ARMCPRegInfo *ri = rip; const ARMCPRegInfo *ri = rip;
int excp = ri->writefn(env, ri, value);
if (excp) { ri->writefn(env, ri, value);
raise_exception(env, excp);
}
} }
uint32_t HELPER(get_cp_reg)(CPUARMState *env, void *rip) uint32_t HELPER(get_cp_reg)(CPUARMState *env, void *rip)
{ {
const ARMCPRegInfo *ri = rip; const ARMCPRegInfo *ri = rip;
uint64_t value;
int excp = ri->readfn(env, ri, &value); return ri->readfn(env, ri);
if (excp) {
raise_exception(env, excp);
}
return value;
} }
void HELPER(set_cp_reg64)(CPUARMState *env, void *rip, uint64_t value) void HELPER(set_cp_reg64)(CPUARMState *env, void *rip, uint64_t value)
{ {
const ARMCPRegInfo *ri = rip; const ARMCPRegInfo *ri = rip;
int excp = ri->writefn(env, ri, value);
if (excp) { ri->writefn(env, ri, value);
raise_exception(env, excp);
}
} }
uint64_t HELPER(get_cp_reg64)(CPUARMState *env, void *rip) uint64_t HELPER(get_cp_reg64)(CPUARMState *env, void *rip)
{ {
const ARMCPRegInfo *ri = rip; const ARMCPRegInfo *ri = rip;
uint64_t value;
int excp = ri->readfn(env, ri, &value); return ri->readfn(env, ri);
if (excp) {
raise_exception(env, excp);
}
return value;
} }
/* ??? Flag setting arithmetic is awkward because we need to do comparisons. /* ??? Flag setting arithmetic is awkward because we need to do comparisons.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册