Skip to content

Commit

Permalink
fw_cfg: Split fw_cfg_keys.h off fw_cfg.h
Browse files Browse the repository at this point in the history
Much of fw_cfg.h's contents is #ifndef NO_QEMU_PROTOS.  This lets a
few places include it without satisfying the dependencies of the
suppressed code.  If you somehow include it with NO_QEMU_PROTOS, any
future includes are ignored.  Unnecessarily unclean.

Move the stuff not under NO_QEMU_PROTOS into its own header
fw_cfg_keys.h, and include it as appropriate.  Tidy up the moved code
to please checkpatch.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
Markus Armbruster authored and bonzini committed Mar 22, 2016
1 parent c80f6e9 commit 6f061ea
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 57 deletions.
49 changes: 1 addition & 48 deletions include/hw/nvram/fw_cfg.h
@@ -1,54 +1,9 @@
#ifndef FW_CFG_H
#define FW_CFG_H

#ifndef NO_QEMU_PROTOS

#include "exec/hwaddr.h"
#endif
#include "hw/nvram/fw_cfg_keys.h"

#define FW_CFG_SIGNATURE 0x00
#define FW_CFG_ID 0x01
#define FW_CFG_UUID 0x02
#define FW_CFG_RAM_SIZE 0x03
#define FW_CFG_NOGRAPHIC 0x04
#define FW_CFG_NB_CPUS 0x05
#define FW_CFG_MACHINE_ID 0x06
#define FW_CFG_KERNEL_ADDR 0x07
#define FW_CFG_KERNEL_SIZE 0x08
#define FW_CFG_KERNEL_CMDLINE 0x09
#define FW_CFG_INITRD_ADDR 0x0a
#define FW_CFG_INITRD_SIZE 0x0b
#define FW_CFG_BOOT_DEVICE 0x0c
#define FW_CFG_NUMA 0x0d
#define FW_CFG_BOOT_MENU 0x0e
#define FW_CFG_MAX_CPUS 0x0f
#define FW_CFG_KERNEL_ENTRY 0x10
#define FW_CFG_KERNEL_DATA 0x11
#define FW_CFG_INITRD_DATA 0x12
#define FW_CFG_CMDLINE_ADDR 0x13
#define FW_CFG_CMDLINE_SIZE 0x14
#define FW_CFG_CMDLINE_DATA 0x15
#define FW_CFG_SETUP_ADDR 0x16
#define FW_CFG_SETUP_SIZE 0x17
#define FW_CFG_SETUP_DATA 0x18
#define FW_CFG_FILE_DIR 0x19

#define FW_CFG_FILE_FIRST 0x20
#define FW_CFG_FILE_SLOTS 0x10
#define FW_CFG_MAX_ENTRY (FW_CFG_FILE_FIRST+FW_CFG_FILE_SLOTS)

#define FW_CFG_WRITE_CHANNEL 0x4000
#define FW_CFG_ARCH_LOCAL 0x8000
#define FW_CFG_ENTRY_MASK ~(FW_CFG_WRITE_CHANNEL | FW_CFG_ARCH_LOCAL)

#define FW_CFG_INVALID 0xffff

/* width in bytes of fw_cfg control register */
#define FW_CFG_CTL_SIZE 0x02

#define FW_CFG_MAX_FILE_PATH 56

#ifndef NO_QEMU_PROTOS
typedef struct FWCfgFile {
uint32_t size; /* file size */
uint16_t select; /* write this to 0x510 to read it */
Expand Down Expand Up @@ -220,6 +175,4 @@ FWCfgState *fw_cfg_init_mem_wide(hwaddr ctl_addr,

FWCfgState *fw_cfg_find(void);

#endif /* NO_QEMU_PROTOS */

#endif
46 changes: 46 additions & 0 deletions include/hw/nvram/fw_cfg_keys.h
@@ -0,0 +1,46 @@
#ifndef FW_CFG_KEYS_H
#define FW_CFG_KEYS_H

#define FW_CFG_SIGNATURE 0x00
#define FW_CFG_ID 0x01
#define FW_CFG_UUID 0x02
#define FW_CFG_RAM_SIZE 0x03
#define FW_CFG_NOGRAPHIC 0x04
#define FW_CFG_NB_CPUS 0x05
#define FW_CFG_MACHINE_ID 0x06
#define FW_CFG_KERNEL_ADDR 0x07
#define FW_CFG_KERNEL_SIZE 0x08
#define FW_CFG_KERNEL_CMDLINE 0x09
#define FW_CFG_INITRD_ADDR 0x0a
#define FW_CFG_INITRD_SIZE 0x0b
#define FW_CFG_BOOT_DEVICE 0x0c
#define FW_CFG_NUMA 0x0d
#define FW_CFG_BOOT_MENU 0x0e
#define FW_CFG_MAX_CPUS 0x0f
#define FW_CFG_KERNEL_ENTRY 0x10
#define FW_CFG_KERNEL_DATA 0x11
#define FW_CFG_INITRD_DATA 0x12
#define FW_CFG_CMDLINE_ADDR 0x13
#define FW_CFG_CMDLINE_SIZE 0x14
#define FW_CFG_CMDLINE_DATA 0x15
#define FW_CFG_SETUP_ADDR 0x16
#define FW_CFG_SETUP_SIZE 0x17
#define FW_CFG_SETUP_DATA 0x18
#define FW_CFG_FILE_DIR 0x19

#define FW_CFG_FILE_FIRST 0x20
#define FW_CFG_FILE_SLOTS 0x10
#define FW_CFG_MAX_ENTRY (FW_CFG_FILE_FIRST + FW_CFG_FILE_SLOTS)

#define FW_CFG_WRITE_CHANNEL 0x4000
#define FW_CFG_ARCH_LOCAL 0x8000
#define FW_CFG_ENTRY_MASK (~(FW_CFG_WRITE_CHANNEL | FW_CFG_ARCH_LOCAL))

#define FW_CFG_INVALID 0xffff

/* width in bytes of fw_cfg control register */
#define FW_CFG_CTL_SIZE 0x02

#define FW_CFG_MAX_FILE_PATH 56

#endif
3 changes: 1 addition & 2 deletions pc-bios/optionrom/optionrom.h
Expand Up @@ -19,8 +19,7 @@
*/


#define NO_QEMU_PROTOS
#include "../../include/hw/nvram/fw_cfg.h"
#include "../../include/hw/nvram/fw_cfg_keys.h"

#define BIOS_CFG_IOPORT_CFG 0x510
#define BIOS_CFG_IOPORT_DATA 0x511
Expand Down
4 changes: 1 addition & 3 deletions tests/boot-order-test.c
Expand Up @@ -15,9 +15,7 @@
#include "libqos/fw_cfg.h"
#include "libqtest.h"

#define NO_QEMU_PROTOS
#include "hw/nvram/fw_cfg.h"
#undef NO_QEMU_PROTOS
#include "hw/nvram/fw_cfg_keys.h"

typedef struct {
const char *args;
Expand Down
3 changes: 1 addition & 2 deletions tests/fw_cfg-test.c
Expand Up @@ -14,8 +14,7 @@
#include <glib.h>

#include "libqtest.h"
#define NO_QEMU_PROTOS
#include "hw/nvram/fw_cfg.h"
#include "hw/nvram/fw_cfg_keys.h"
#include "libqos/fw_cfg.h"

static uint64_t ram_size = 128 << 20;
Expand Down
3 changes: 1 addition & 2 deletions tests/libqos/malloc-pc.c
Expand Up @@ -14,8 +14,7 @@
#include "libqos/malloc-pc.h"
#include "libqos/fw_cfg.h"

#define NO_QEMU_PROTOS
#include "hw/nvram/fw_cfg.h"
#include "hw/nvram/fw_cfg_keys.h"

#include "qemu-common.h"
#include <glib.h>
Expand Down

0 comments on commit 6f061ea

Please sign in to comment.