|
|
9ae3a8 |
From f865f4fe293db1dfdfbb2e03963d0c6a25a398cc Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= <marcandre.lureau@redhat.com>
|
|
|
9ae3a8 |
Date: Wed, 13 Dec 2017 13:38:42 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 11/41] fw_cfg: add write callback
|
|
|
9ae3a8 |
MIME-Version: 1.0
|
|
|
9ae3a8 |
Content-Type: text/plain; charset=UTF-8
|
|
|
9ae3a8 |
Content-Transfer-Encoding: 8bit
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
|
9ae3a8 |
Message-id: <20171213133912.26176-12-marcandre.lureau@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 78361
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.5 qemu-kvm PATCH v3 11/41] fw_cfg: add write callback
|
|
|
9ae3a8 |
Bugzilla: 1411490
|
|
|
9ae3a8 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Reintroduce the write callback that was removed when write support was
|
|
|
9ae3a8 |
removed in commit 023e3148567ac898c7258138f8e86c3c2bb40d07.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Contrary to the previous callback implementation, the write_cb
|
|
|
9ae3a8 |
callback is called whenever a write happened, so handlers must be
|
|
|
9ae3a8 |
ready to handle partial write as necessary.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
(cherry picked from commit 5f9252f7cc12c5cec1b3c6695aca02eb52ea7acc)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RHEL: major conflict due to API changes, but minor functional changes.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
hw/core/loader.c | 2 +-
|
|
|
9ae3a8 |
hw/nvram/fw_cfg.c | 32 ++++++++++++++++++++------------
|
|
|
9ae3a8 |
include/hw/nvram/fw_cfg.h | 8 ++++++--
|
|
|
9ae3a8 |
3 files changed, 27 insertions(+), 15 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/hw/core/loader.c b/hw/core/loader.c
|
|
|
9ae3a8 |
index c824bc2..5a15449 100644
|
|
|
9ae3a8 |
--- a/hw/core/loader.c
|
|
|
9ae3a8 |
+++ b/hw/core/loader.c
|
|
|
9ae3a8 |
@@ -700,7 +700,7 @@ void *rom_add_blob(const char *name, const void *blob, size_t len,
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
fw_cfg_add_file_callback(fw_cfg, fw_file_name,
|
|
|
9ae3a8 |
- fw_callback, callback_opaque,
|
|
|
9ae3a8 |
+ fw_callback, NULL, callback_opaque,
|
|
|
9ae3a8 |
data, rom->romsize, read_only);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
return data;
|
|
|
9ae3a8 |
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
|
|
|
9ae3a8 |
index a7bc98e..616c782 100644
|
|
|
9ae3a8 |
--- a/hw/nvram/fw_cfg.c
|
|
|
9ae3a8 |
+++ b/hw/nvram/fw_cfg.c
|
|
|
9ae3a8 |
@@ -54,6 +54,7 @@ typedef struct FWCfgEntry {
|
|
|
9ae3a8 |
uint8_t *data;
|
|
|
9ae3a8 |
void *callback_opaque;
|
|
|
9ae3a8 |
FWCfgReadCallback read_callback;
|
|
|
9ae3a8 |
+ FWCfgWriteCallback write_cb;
|
|
|
9ae3a8 |
} FWCfgEntry;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
struct FWCfgState {
|
|
|
9ae3a8 |
@@ -365,6 +366,8 @@ static void fw_cfg_dma_transfer(FWCfgState *s)
|
|
|
9ae3a8 |
dma_memory_read(s->dma, dma.address,
|
|
|
9ae3a8 |
&e->data[s->cur_offset], len)) {
|
|
|
9ae3a8 |
dma.control |= FW_CFG_DMA_CTL_ERROR;
|
|
|
9ae3a8 |
+ } else if (e->write_cb) {
|
|
|
9ae3a8 |
+ e->write_cb(e->callback_opaque, s->cur_offset, len);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -556,11 +559,12 @@ static const VMStateDescription vmstate_fw_cfg = {
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
};
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-static void fw_cfg_add_bytes_read_callback(FWCfgState *s, uint16_t key,
|
|
|
9ae3a8 |
- FWCfgReadCallback callback,
|
|
|
9ae3a8 |
- void *callback_opaque,
|
|
|
9ae3a8 |
- void *data, size_t len,
|
|
|
9ae3a8 |
- bool read_only)
|
|
|
9ae3a8 |
+static void fw_cfg_add_bytes_callback(FWCfgState *s, uint16_t key,
|
|
|
9ae3a8 |
+ FWCfgReadCallback callback,
|
|
|
9ae3a8 |
+ FWCfgWriteCallback write_cb,
|
|
|
9ae3a8 |
+ void *callback_opaque,
|
|
|
9ae3a8 |
+ void *data, size_t len,
|
|
|
9ae3a8 |
+ bool read_only)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
int arch = !!(key & FW_CFG_ARCH_LOCAL);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -572,13 +576,14 @@ static void fw_cfg_add_bytes_read_callback(FWCfgState *s, uint16_t key,
|
|
|
9ae3a8 |
s->entries[arch][key].data = data;
|
|
|
9ae3a8 |
s->entries[arch][key].len = (uint32_t)len;
|
|
|
9ae3a8 |
s->entries[arch][key].read_callback = callback;
|
|
|
9ae3a8 |
+ s->entries[arch][key].write_cb = write_cb;
|
|
|
9ae3a8 |
s->entries[arch][key].callback_opaque = callback_opaque;
|
|
|
9ae3a8 |
s->entries[arch][key].allow_write = !read_only;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
void fw_cfg_add_bytes(FWCfgState *s, uint16_t key, void *data, size_t len)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
- fw_cfg_add_bytes_read_callback(s, key, NULL, NULL, data, len, true);
|
|
|
9ae3a8 |
+ fw_cfg_add_bytes_callback(s, key, NULL, NULL, NULL, data, len, true);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
void fw_cfg_add_string(FWCfgState *s, uint16_t key, const char *value)
|
|
|
9ae3a8 |
@@ -616,8 +621,11 @@ void fw_cfg_add_i64(FWCfgState *s, uint16_t key, uint64_t value)
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
void fw_cfg_add_file_callback(FWCfgState *s, const char *filename,
|
|
|
9ae3a8 |
- FWCfgReadCallback callback, void *callback_opaque,
|
|
|
9ae3a8 |
- void *data, size_t len, bool read_only)
|
|
|
9ae3a8 |
+ FWCfgReadCallback callback,
|
|
|
9ae3a8 |
+ FWCfgWriteCallback write_cb,
|
|
|
9ae3a8 |
+ void *callback_opaque,
|
|
|
9ae3a8 |
+ void *data, size_t len,
|
|
|
9ae3a8 |
+ bool read_only)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
int i, index;
|
|
|
9ae3a8 |
size_t dsize;
|
|
|
9ae3a8 |
@@ -641,9 +649,9 @@ void fw_cfg_add_file_callback(FWCfgState *s, const char *filename,
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- fw_cfg_add_bytes_read_callback(s, FW_CFG_FILE_FIRST + index,
|
|
|
9ae3a8 |
- callback, callback_opaque, data, len,
|
|
|
9ae3a8 |
- read_only);
|
|
|
9ae3a8 |
+ fw_cfg_add_bytes_callback(s, FW_CFG_FILE_FIRST + index,
|
|
|
9ae3a8 |
+ callback, write_cb, callback_opaque, data, len,
|
|
|
9ae3a8 |
+ read_only);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
s->files->f[index].size = cpu_to_be32(len);
|
|
|
9ae3a8 |
s->files->f[index].select = cpu_to_be16(FW_CFG_FILE_FIRST + index);
|
|
|
9ae3a8 |
@@ -655,7 +663,7 @@ void fw_cfg_add_file_callback(FWCfgState *s, const char *filename,
|
|
|
9ae3a8 |
void fw_cfg_add_file(FWCfgState *s, const char *filename,
|
|
|
9ae3a8 |
void *data, size_t len)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
- fw_cfg_add_file_callback(s, filename, NULL, NULL, data, len, true);
|
|
|
9ae3a8 |
+ fw_cfg_add_file_callback(s, filename, NULL, NULL, NULL, data, len, true);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
static void fw_cfg_machine_ready(struct Notifier *n, void *data)
|
|
|
9ae3a8 |
diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h
|
|
|
9ae3a8 |
index 76fc787..a77ab84 100644
|
|
|
9ae3a8 |
--- a/include/hw/nvram/fw_cfg.h
|
|
|
9ae3a8 |
+++ b/include/hw/nvram/fw_cfg.h
|
|
|
9ae3a8 |
@@ -73,6 +73,7 @@ typedef struct FWCfgDmaAccess {
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
typedef void (*FWCfgCallback)(void *opaque, uint8_t *data);
|
|
|
9ae3a8 |
typedef void (*FWCfgReadCallback)(void *opaque, uint32_t offset);
|
|
|
9ae3a8 |
+typedef void (*FWCfgWriteCallback)(void *opaque, off_t start, size_t len);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
void fw_cfg_add_bytes(FWCfgState *s, uint16_t key, void *data, size_t len);
|
|
|
9ae3a8 |
void fw_cfg_add_string(FWCfgState *s, uint16_t key, const char *value);
|
|
|
9ae3a8 |
@@ -82,8 +83,11 @@ void fw_cfg_add_i64(FWCfgState *s, uint16_t key, uint64_t value);
|
|
|
9ae3a8 |
void fw_cfg_add_file(FWCfgState *s, const char *filename, void *data,
|
|
|
9ae3a8 |
size_t len);
|
|
|
9ae3a8 |
void fw_cfg_add_file_callback(FWCfgState *s, const char *filename,
|
|
|
9ae3a8 |
- FWCfgReadCallback callback, void *callback_opaque,
|
|
|
9ae3a8 |
- void *data, size_t len, bool read_only);
|
|
|
9ae3a8 |
+ FWCfgReadCallback callback,
|
|
|
9ae3a8 |
+ FWCfgWriteCallback write_cb,
|
|
|
9ae3a8 |
+ void *callback_opaque,
|
|
|
9ae3a8 |
+ void *data, size_t len,
|
|
|
9ae3a8 |
+ bool read_only);
|
|
|
9ae3a8 |
FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port,
|
|
|
9ae3a8 |
hwaddr crl_addr, hwaddr data_addr);
|
|
|
9ae3a8 |
FWCfgState *fw_cfg_init_io_dma(uint32_t iobase, uint32_t dma_iobase,
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|