[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 39/43] vt82c686: Remove index field of SuperIOConfig
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 39/43] vt82c686: Remove index field of SuperIOConfig |
Date: |
Sun, 21 Feb 2021 15:34:28 +0100 |
From: BALATON Zoltan <balaton@eik.bme.hu>
Remove the separate index value from SuperIOConfig and store
the index at reg 0 which is reserved and returns 0 on read.
This simplifies the object state.
Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
Message-Id:
<15b2968fd300a12d06b42368d084f6f80d3c3be5.1610223397.git.balaton@eik.bme.hu>
[PMD: Split original patch in 5, this is part 1/5]
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
---
hw/isa/vt82c686.c | 21 ++++++++++++++-------
1 file changed, 14 insertions(+), 7 deletions(-)
diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
index a37f1931ce0..eebaa0d444c 100644
--- a/hw/isa/vt82c686.c
+++ b/hw/isa/vt82c686.c
@@ -250,7 +250,6 @@ static const TypeInfo vt8231_pm_info = {
typedef struct SuperIOConfig {
uint8_t regs[0x100];
- uint8_t index;
MemoryRegion io;
} SuperIOConfig;
@@ -258,14 +257,15 @@ static void superio_cfg_write(void *opaque, hwaddr addr,
uint64_t data,
unsigned size)
{
SuperIOConfig *sc = opaque;
+ uint8_t idx = sc->regs[0];
if (addr == 0x3f0) { /* config index register */
- sc->index = data & 0xff;
+ idx = data & 0xff;
} else {
bool can_write = true;
/* 0x3f1, config data register */
- trace_via_superio_write(sc->index, data & 0xff);
- switch (sc->index) {
+ trace_via_superio_write(idx, data & 0xff);
+ switch (idx) {
case 0x00 ... 0xdf:
case 0xe4:
case 0xe5:
@@ -283,7 +283,7 @@ static void superio_cfg_write(void *opaque, hwaddr addr,
uint64_t data,
}
if (can_write) {
- sc->regs[sc->index] = data & 0xff;
+ sc->regs[idx] = data & 0xff;
}
}
}
@@ -291,9 +291,16 @@ static void superio_cfg_write(void *opaque, hwaddr addr,
uint64_t data,
static uint64_t superio_cfg_read(void *opaque, hwaddr addr, unsigned size)
{
SuperIOConfig *sc = opaque;
- uint8_t val = sc->regs[sc->index];
+ uint8_t idx = sc->regs[0];
+ uint8_t val = sc->regs[idx];
- trace_via_superio_read(sc->index, val);
+ if (addr == 0) {
+ return idx;
+ }
+ if (addr == 1 && idx == 0) {
+ val = 0; /* reading reg 0 where we store index value */
+ }
+ trace_via_superio_read(idx, val);
return val;
}
--
2.26.2
- [PULL 26/43] target/mips: Introduce gen_load_gpr_hi() / gen_store_gpr_hi() helpers, (continued)
- [PULL 26/43] target/mips: Introduce gen_load_gpr_hi() / gen_store_gpr_hi() helpers, Philippe Mathieu-Daudé, 2021/02/21
- [PULL 32/43] vt82c686: Correct vt82c686-pm I/O size, Philippe Mathieu-Daudé, 2021/02/21
- [PULL 27/43] target/mips: Use GPR move functions in gen_HILO1_tx79(), Philippe Mathieu-Daudé, 2021/02/21
- [PULL 30/43] vt82c686: Fix SMBus IO base and configuration registers, Philippe Mathieu-Daudé, 2021/02/21
- [PULL 33/43] vt82c686: Correctly reset all registers to default values on reset, Philippe Mathieu-Daudé, 2021/02/21
- [PULL 34/43] vt82c686: Fix up power management io base and config, Philippe Mathieu-Daudé, 2021/02/21
- [PULL 35/43] vt82c686: Set user_creatable=false for VT82C686B_PM, Philippe Mathieu-Daudé, 2021/02/21
- [PULL 36/43] vt82c686: Make vt82c686b-pm an abstract base class and add vt8231-pm based on it, Philippe Mathieu-Daudé, 2021/02/21
- [PULL 37/43] vt82c686: Simplify vt82c686b_realize(), Philippe Mathieu-Daudé, 2021/02/21
- [PULL 38/43] vt82c686: Move creation of ISA devices to the ISA bridge, Philippe Mathieu-Daudé, 2021/02/21
- [PULL 39/43] vt82c686: Remove index field of SuperIOConfig,
Philippe Mathieu-Daudé <=
- [PULL 40/43] vt82c686: Reduce indentation by returning early, Philippe Mathieu-Daudé, 2021/02/21
- [PULL 42/43] vt82c686: Log superio_cfg unimplemented accesses, Philippe Mathieu-Daudé, 2021/02/21
- [PULL 41/43] vt82c686: Simplify by returning earlier, Philippe Mathieu-Daudé, 2021/02/21
- [PULL 43/43] vt82c686: Fix superio_cfg_{read,write}() functions, Philippe Mathieu-Daudé, 2021/02/21
- Re: [PULL 00/43] MIPS patches for 2021-02-21, Philippe Mathieu-Daudé, 2021/02/21