Skip to content

Commit

Permalink
libqos: Generalize I/O-mapped fw_cfg
Browse files Browse the repository at this point in the history
Provide a constructor that takes the base address in addition to the
PC-specific one.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Message-id: 1372254743-15808-12-git-send-email-armbru@redhat.com
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
  • Loading branch information
Markus Armbruster authored and Anthony Liguori committed Jul 18, 2013
1 parent f88dc7d commit 26491a3
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 63 deletions.
2 changes: 1 addition & 1 deletion tests/Makefile
Expand Up @@ -128,7 +128,7 @@ tests/test-mul64$(EXESUF): tests/test-mul64.o libqemuutil.a

libqos-obj-y = tests/libqos/pci.o tests/libqos/fw_cfg.o
libqos-obj-y += tests/libqos/i2c.o
libqos-pc-obj-y = $(libqos-obj-y) tests/libqos/pci-pc.o tests/libqos/fw_cfg-pc.o
libqos-pc-obj-y = $(libqos-obj-y) tests/libqos/pci-pc.o
libqos-pc-obj-y += tests/libqos/malloc-pc.o
libqos-omap-obj-y = $(libqos-obj-y) tests/libqos/i2c-omap.o

Expand Down
2 changes: 1 addition & 1 deletion tests/fw_cfg-test.c
Expand Up @@ -14,7 +14,7 @@

#include "libqtest.h"
#include "hw/nvram/fw_cfg.h"
#include "libqos/fw_cfg-pc.h"
#include "libqos/fw_cfg.h"

#include <string.h>
#include <glib.h>
Expand Down
40 changes: 0 additions & 40 deletions tests/libqos/fw_cfg-pc.c

This file was deleted.

20 changes: 0 additions & 20 deletions tests/libqos/fw_cfg-pc.h

This file was deleted.

26 changes: 26 additions & 0 deletions tests/libqos/fw_cfg.c
Expand Up @@ -79,3 +79,29 @@ QFWCFG *mm_fw_cfg_init(uint64_t base)

return fw_cfg;
}

static void io_fw_cfg_select(QFWCFG *fw_cfg, uint16_t key)
{
outw(fw_cfg->base, key);
}

static void io_fw_cfg_read(QFWCFG *fw_cfg, void *data, size_t len)
{
uint8_t *ptr = data;
int i;

for (i = 0; i < len; i++) {
ptr[i] = inb(fw_cfg->base + 1);
}
}

QFWCFG *io_fw_cfg_init(uint16_t base)
{
QFWCFG *fw_cfg = g_malloc0(sizeof(*fw_cfg));

fw_cfg->base = base;
fw_cfg->select = io_fw_cfg_select;
fw_cfg->read = io_fw_cfg_read;

return fw_cfg;
}
6 changes: 6 additions & 0 deletions tests/libqos/fw_cfg.h
Expand Up @@ -33,5 +33,11 @@ uint32_t qfw_cfg_get_u32(QFWCFG *fw_cfg, uint16_t key);
uint64_t qfw_cfg_get_u64(QFWCFG *fw_cfg, uint16_t key);

QFWCFG *mm_fw_cfg_init(uint64_t base);
QFWCFG *io_fw_cfg_init(uint16_t base);

static inline QFWCFG *pc_fw_cfg_init(void)
{
return io_fw_cfg_init(0x510);
}

#endif
2 changes: 1 addition & 1 deletion tests/libqos/malloc-pc.c
Expand Up @@ -11,7 +11,7 @@
*/

#include "libqos/malloc-pc.h"
#include "libqos/fw_cfg-pc.h"
#include "libqos/fw_cfg.h"

#define NO_QEMU_PROTOS
#include "hw/nvram/fw_cfg.h"
Expand Down

0 comments on commit 26491a3

Please sign in to comment.