dev: Fix cpu/reg decoding logic in multi-instance LupIO devices
The current decoding logic is flawed and complicated to understand. Using simple division and modulo instead; the compiler is smart enough to generate efficient code since the divisor is a power of 2. Change-Id: I95cbb4969e37132343f557e772984a48749731f0 Signed-off-by: Joël Porquet-Lupine <joel@porquet.org> Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/61529 Reviewed-by: Jason Lowe-Power <power.jg@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com> Maintainer: Jason Lowe-Power <power.jg@gmail.com>
This commit is contained in:
committed by
Joël Porquet-Lupine
parent
62efcae89e
commit
0800c060d8
@@ -90,8 +90,8 @@ LupioPIC::lupioPicRead(uint8_t addr)
|
||||
{
|
||||
uint32_t r = 0;
|
||||
|
||||
int cpu = addr >> LUPIO_PIC_MAX;
|
||||
int reg = (addr >> 2) & (LUPIO_PIC_MAX - 1);
|
||||
int cpu = addr / LUPIO_PIC_MAX;
|
||||
int reg = addr % LUPIO_PIC_MAX;
|
||||
|
||||
switch (reg) {
|
||||
case LUPIO_PIC_PRIO:
|
||||
@@ -124,8 +124,8 @@ LupioPIC::lupioPicWrite(uint8_t addr, uint64_t val64)
|
||||
{
|
||||
uint32_t val = val64;
|
||||
|
||||
int cpu = addr >> LUPIO_PIC_MAX;
|
||||
int reg = (addr >> 2) & (LUPIO_PIC_MAX - 1);
|
||||
int cpu = addr / LUPIO_PIC_MAX;
|
||||
int reg = addr % LUPIO_PIC_MAX;
|
||||
|
||||
switch (reg) {
|
||||
case LUPIO_PIC_MASK:
|
||||
|
||||
@@ -61,13 +61,13 @@ class LupioPIC : public BasicPioDevice
|
||||
private:
|
||||
enum
|
||||
{
|
||||
LUPIO_PIC_PRIO,
|
||||
LUPIO_PIC_MASK,
|
||||
LUPIO_PIC_PEND,
|
||||
LUPIO_PIC_ENAB,
|
||||
LUPIO_PIC_PRIO = 0x0,
|
||||
LUPIO_PIC_MASK = 0x4,
|
||||
LUPIO_PIC_PEND = 0x8,
|
||||
LUPIO_PIC_ENAB = 0xC,
|
||||
|
||||
// Max offset
|
||||
LUPIO_PIC_MAX,
|
||||
LUPIO_PIC_MAX = 0x10,
|
||||
};
|
||||
|
||||
uint32_t pending = 0;
|
||||
|
||||
@@ -123,8 +123,8 @@ LupioTMR::lupioTMRRead(uint8_t addr, int size)
|
||||
{
|
||||
uint32_t r = 0;
|
||||
|
||||
size_t cpu = addr >> LUPIO_TMR_MAX;
|
||||
size_t reg = (addr >> 2) & (LUPIO_TMR_MAX - 1);
|
||||
size_t cpu = addr / LUPIO_TMR_MAX;
|
||||
size_t reg = addr % LUPIO_TMR_MAX;
|
||||
|
||||
switch (reg) {
|
||||
case LUPIO_TMR_TIME:
|
||||
@@ -159,8 +159,8 @@ LupioTMR::lupioTMRWrite(uint8_t addr, uint64_t val64, int size)
|
||||
{
|
||||
uint32_t val = val64;
|
||||
|
||||
size_t cpu = addr >> LUPIO_TMR_MAX;
|
||||
size_t reg = (addr >> 2) & (LUPIO_TMR_MAX - 1);
|
||||
size_t cpu = addr / LUPIO_TMR_MAX;
|
||||
size_t reg = addr % LUPIO_TMR_MAX;
|
||||
|
||||
switch (reg) {
|
||||
case LUPIO_TMR_LOAD:
|
||||
|
||||
@@ -54,13 +54,13 @@ class LupioTMR : public BasicPioDevice
|
||||
// Register map
|
||||
enum
|
||||
{
|
||||
LUPIO_TMR_TIME,
|
||||
LUPIO_TMR_LOAD,
|
||||
LUPIO_TMR_CTRL,
|
||||
LUPIO_TMR_STAT,
|
||||
LUPIO_TMR_TIME = 0x0,
|
||||
LUPIO_TMR_LOAD = 0x4,
|
||||
LUPIO_TMR_CTRL = 0x8,
|
||||
LUPIO_TMR_STAT = 0xC,
|
||||
|
||||
// Max offset
|
||||
LUPIO_TMR_MAX,
|
||||
LUPIO_TMR_MAX = 0x10,
|
||||
};
|
||||
|
||||
struct LupioTimer
|
||||
|
||||
Reference in New Issue
Block a user