[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 09/13] vt82c686: Fix superio_cfg_{read,write}() functions
From: |
BALATON Zoltan |
Subject: |
[PATCH v2 09/13] vt82c686: Fix superio_cfg_{read,write}() functions |
Date: |
Sat, 09 Jan 2021 21:16:36 +0100 |
These functions are memory region callbacks so we have to check
against relative address not the mapped address. Also reduce
indentation by returning early and log unimplemented accesses.
Additionally we remove separate index value from SuperIOConfig and
store the index at reg 0 which is reserved and returns 0 on read. This
simplifies object state.
Signed-off-by: BALATON Zoltan <balaton@eik.bme.hu>
---
hw/isa/vt82c686.c | 63 ++++++++++++++++++++++++++---------------------
1 file changed, 35 insertions(+), 28 deletions(-)
diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
index 5df9be8ff4..2921d5c55c 100644
--- a/hw/isa/vt82c686.c
+++ b/hw/isa/vt82c686.c
@@ -26,6 +26,7 @@
#include "hw/acpi/acpi.h"
#include "hw/i2c/pm_smbus.h"
#include "qapi/error.h"
+#include "qemu/log.h"
#include "qemu/module.h"
#include "qemu/range.h"
#include "qemu/timer.h"
@@ -250,7 +251,6 @@ static const TypeInfo vt8231_pm_info = {
typedef struct SuperIOConfig {
uint8_t regs[0x100];
- uint8_t index;
MemoryRegion io;
} SuperIOConfig;
@@ -258,42 +258,49 @@ 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;
- } else {
- bool can_write = true;
- /* 0x3f1, config data register */
- trace_via_superio_write(sc->index, data & 0xff);
- switch (sc->index) {
- case 0x00 ... 0xdf:
- case 0xe4:
- case 0xe5:
- case 0xe9 ... 0xed:
- case 0xf3:
- case 0xf5:
- case 0xf7:
- case 0xf9 ... 0xfb:
- case 0xfd ... 0xff:
- can_write = false;
- break;
- /* case 0xe6 ... 0xe8: Should set base port of parallel and serial */
- default:
- break;
+ if (addr == 0) { /* config index register */
+ sc->regs[0] = data;
+ return;
+ }
- }
- if (can_write) {
- sc->regs[sc->index] = data & 0xff;
- }
+ /* config data register */
+ trace_via_superio_write(idx, data);
+ switch (idx) {
+ case 0x00 ... 0xdf:
+ case 0xe4:
+ case 0xe5:
+ case 0xe9 ... 0xed:
+ case 0xf3:
+ case 0xf5:
+ case 0xf7:
+ case 0xf9 ... 0xfb:
+ case 0xfd ... 0xff:
+ /* ignore write to read only registers */
+ return;
+ /* case 0xe6 ... 0xe8: Should set base port of parallel and serial */
+ default:
+ qemu_log_mask(LOG_UNIMP,
+ "via_superio_cfg: unimplemented register 0x%x\n", idx);
+ break;
}
+ sc->regs[idx] = 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.21.3
- Re: [PATCH v2 08/13] vt82c686: Move creation of ISA devices to the ISA bridge, (continued)
- Re: [PATCH v2 08/13] vt82c686: Move creation of ISA devices to the ISA bridge, Philippe Mathieu-Daudé, 2021/01/09
- Re: [PATCH v2 08/13] vt82c686: Move creation of ISA devices to the ISA bridge, BALATON Zoltan, 2021/01/09
- Re: [PATCH v2 08/13] vt82c686: Move creation of ISA devices to the ISA bridge, Philippe Mathieu-Daudé, 2021/01/10
- Re: [PATCH v2 08/13] vt82c686: Move creation of ISA devices to the ISA bridge, BALATON Zoltan, 2021/01/10
- Re: [PATCH v2 08/13] vt82c686: Move creation of ISA devices to the ISA bridge, Jiaxun Yang, 2021/01/10
- Re: [PATCH v2 08/13] vt82c686: Move creation of ISA devices to the ISA bridge, BALATON Zoltan, 2021/01/11
- Re: [PATCH v2 08/13] vt82c686: Move creation of ISA devices to the ISA bridge, Philippe Mathieu-Daudé, 2021/01/25
[PATCH v2 06/13] vt82c686: Make vt82c686b-pm an abstract base class and add vt8231-pm based on it, BALATON Zoltan, 2021/01/09
[PATCH v2 10/13] vt82c686: Implement control of serial port io ranges via config regs, BALATON Zoltan, 2021/01/09
[PATCH v2 09/13] vt82c686: Fix superio_cfg_{read,write}() functions,
BALATON Zoltan <=
[PATCH v2 11/13] vt82c686: QOM-ify superio related functionality, BALATON Zoltan, 2021/01/09