|
|
9ae3a8 |
From 8ef464d9f69895ad603c8104460ec667892be48c Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
Message-Id: <8ef464d9f69895ad603c8104460ec667892be48c.1387298827.git.minovotn@redhat.com>
|
|
|
9ae3a8 |
In-Reply-To: <3ed0fb61a3dc912ef036d7ef450bed192090709e.1387298827.git.minovotn@redhat.com>
|
|
|
9ae3a8 |
References: <3ed0fb61a3dc912ef036d7ef450bed192090709e.1387298827.git.minovotn@redhat.com>
|
|
|
9ae3a8 |
From: "Michael S. Tsirkin" <mst@redhat.com>
|
|
|
9ae3a8 |
Date: Tue, 17 Dec 2013 15:17:56 +0100
|
|
|
9ae3a8 |
Subject: [PATCH 26/56] fw_cfg: interface to trigger callback on read
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1387293161-4085-27-git-send-email-mst@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 56332
|
|
|
9ae3a8 |
O-Subject: [PATCH qemu-kvm RHEL7.0 v2 26/57] fw_cfg: interface to trigger callback on read
|
|
|
9ae3a8 |
Bugzilla: 1034876
|
|
|
9ae3a8 |
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Marcel Apfelbaum <marcel.a@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
9ae3a8 |
Tested-by: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
9ae3a8 |
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
|
|
|
9ae3a8 |
Tested-by: Igor Mammedov <imammedo@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit d87072ceeccf4f84a64d4bc59124bcd64286c070)
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
include/hw/nvram/fw_cfg.h | 4 ++++
|
|
|
9ae3a8 |
hw/nvram/fw_cfg.c | 33 ++++++++++++++++++++++++++++-----
|
|
|
9ae3a8 |
2 files changed, 32 insertions(+), 5 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Signed-off-by: Michal Novotny <minovotn@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
hw/nvram/fw_cfg.c | 33 ++++++++++++++++++++++++++++-----
|
|
|
9ae3a8 |
include/hw/nvram/fw_cfg.h | 4 ++++
|
|
|
9ae3a8 |
2 files changed, 32 insertions(+), 5 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/hw/nvram/fw_cfg.c b/hw/nvram/fw_cfg.c
|
|
|
9ae3a8 |
index 064344d..b865c09 100644
|
|
|
9ae3a8 |
--- a/hw/nvram/fw_cfg.c
|
|
|
9ae3a8 |
+++ b/hw/nvram/fw_cfg.c
|
|
|
9ae3a8 |
@@ -41,6 +41,7 @@ typedef struct FWCfgEntry {
|
|
|
9ae3a8 |
uint8_t *data;
|
|
|
9ae3a8 |
void *callback_opaque;
|
|
|
9ae3a8 |
FWCfgCallback callback;
|
|
|
9ae3a8 |
+ FWCfgReadCallback read_callback;
|
|
|
9ae3a8 |
} FWCfgEntry;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
struct FWCfgState {
|
|
|
9ae3a8 |
@@ -245,8 +246,12 @@ static uint8_t fw_cfg_read(FWCfgState *s)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
if (s->cur_entry == FW_CFG_INVALID || !e->data || s->cur_offset >= e->len)
|
|
|
9ae3a8 |
ret = 0;
|
|
|
9ae3a8 |
- else
|
|
|
9ae3a8 |
+ else {
|
|
|
9ae3a8 |
+ if (e->read_callback) {
|
|
|
9ae3a8 |
+ e->read_callback(e->callback_opaque, s->cur_offset);
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
ret = e->data[s->cur_offset++];
|
|
|
9ae3a8 |
+ }
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
trace_fw_cfg_read(s, ret);
|
|
|
9ae3a8 |
return ret;
|
|
|
9ae3a8 |
@@ -377,7 +382,10 @@ static const VMStateDescription vmstate_fw_cfg = {
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
};
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-void fw_cfg_add_bytes(FWCfgState *s, uint16_t key, void *data, size_t len)
|
|
|
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 |
{
|
|
|
9ae3a8 |
int arch = !!(key & FW_CFG_ARCH_LOCAL);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
@@ -387,6 +395,13 @@ void fw_cfg_add_bytes(FWCfgState *s, uint16_t key, void *data, size_t len)
|
|
|
9ae3a8 |
|
|
|
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].callback_opaque = callback_opaque;
|
|
|
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);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
void fw_cfg_add_string(FWCfgState *s, uint16_t key, const char *value)
|
|
|
9ae3a8 |
@@ -440,8 +455,9 @@ void fw_cfg_add_callback(FWCfgState *s, uint16_t key, FWCfgCallback callback,
|
|
|
9ae3a8 |
s->entries[arch][key].callback = callback;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
-void fw_cfg_add_file(FWCfgState *s, const char *filename,
|
|
|
9ae3a8 |
- void *data, 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)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
int i, index;
|
|
|
9ae3a8 |
size_t dsize;
|
|
|
9ae3a8 |
@@ -455,7 +471,8 @@ void fw_cfg_add_file(FWCfgState *s, const char *filename,
|
|
|
9ae3a8 |
index = be32_to_cpu(s->files->count);
|
|
|
9ae3a8 |
assert(index < FW_CFG_FILE_SLOTS);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
- fw_cfg_add_bytes(s, FW_CFG_FILE_FIRST + index, data, len);
|
|
|
9ae3a8 |
+ fw_cfg_add_bytes_read_callback(s, FW_CFG_FILE_FIRST + index,
|
|
|
9ae3a8 |
+ callback, callback_opaque, data, len);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
pstrcpy(s->files->f[index].name, sizeof(s->files->f[index].name),
|
|
|
9ae3a8 |
filename);
|
|
|
9ae3a8 |
@@ -473,6 +490,12 @@ void fw_cfg_add_file(FWCfgState *s, const char *filename,
|
|
|
9ae3a8 |
s->files->count = cpu_to_be32(index+1);
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
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);
|
|
|
9ae3a8 |
+}
|
|
|
9ae3a8 |
+
|
|
|
9ae3a8 |
static void fw_cfg_machine_ready(struct Notifier *n, void *data)
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
size_t len;
|
|
|
9ae3a8 |
diff --git a/include/hw/nvram/fw_cfg.h b/include/hw/nvram/fw_cfg.h
|
|
|
9ae3a8 |
index f60dd67..2ab0fc2 100644
|
|
|
9ae3a8 |
--- a/include/hw/nvram/fw_cfg.h
|
|
|
9ae3a8 |
+++ b/include/hw/nvram/fw_cfg.h
|
|
|
9ae3a8 |
@@ -60,6 +60,7 @@ typedef struct FWCfgFiles {
|
|
|
9ae3a8 |
} FWCfgFiles;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
typedef void (*FWCfgCallback)(void *opaque, uint8_t *data);
|
|
|
9ae3a8 |
+typedef void (*FWCfgReadCallback)(void *opaque, uint32_t offset);
|
|
|
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 |
@@ -70,6 +71,9 @@ void fw_cfg_add_callback(FWCfgState *s, uint16_t key, FWCfgCallback callback,
|
|
|
9ae3a8 |
void *callback_opaque, void *data, size_t len);
|
|
|
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);
|
|
|
9ae3a8 |
FWCfgState *fw_cfg_init(uint32_t ctl_port, uint32_t data_port,
|
|
|
9ae3a8 |
hwaddr crl_addr, hwaddr data_addr);
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.7.11.7
|
|
|
9ae3a8 |
|