Skip to content

Commit

Permalink
target-microblaze: make cpu-qom.h not target specific
Browse files Browse the repository at this point in the history
Make MicroBlazeCPU an opaque type within cpu-qom.h, and move all
definitions of private methods, as well as all type definitions that
require knowledge of the layout to cpu.h.  This helps making files
independent of NEED_CPU_H if they only need to pass around CPU pointers.

Signed-off-by: Paolo Bonzini <[email protected]>
  • Loading branch information
bonzini committed May 19, 2016
1 parent a836b8f commit ffa3a3c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 44 deletions.
44 changes: 1 addition & 43 deletions target-microblaze/cpu-qom.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,48 +47,6 @@ typedef struct MicroBlazeCPUClass {
void (*parent_reset)(CPUState *cpu);
} MicroBlazeCPUClass;

/**
* MicroBlazeCPU:
* @env: #CPUMBState
*
* A MicroBlaze CPU.
*/
typedef struct MicroBlazeCPU {
/*< private >*/
CPUState parent_obj;

/*< public >*/

/* Microblaze Configuration Settings */
struct {
bool stackprot;
uint32_t base_vectors;
uint8_t use_fpu;
bool use_mmu;
bool dcache_writeback;
bool endi;
char *version;
uint8_t pvr;
} cfg;

CPUMBState env;
} MicroBlazeCPU;

static inline MicroBlazeCPU *mb_env_get_cpu(CPUMBState *env)
{
return container_of(env, MicroBlazeCPU, env);
}

#define ENV_GET_CPU(e) CPU(mb_env_get_cpu(e))

#define ENV_OFFSET offsetof(MicroBlazeCPU, env)

void mb_cpu_do_interrupt(CPUState *cs);
bool mb_cpu_exec_interrupt(CPUState *cs, int int_req);
void mb_cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf,
int flags);
hwaddr mb_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
int mb_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg);
int mb_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);
typedef struct MicroBlazeCPU MicroBlazeCPU;

#endif
45 changes: 44 additions & 1 deletion target-microblaze/cpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#define CPU_MICROBLAZE_H

#include "qemu-common.h"
#include "cpu-qom.h"

#define TARGET_LONG_BITS 32

Expand Down Expand Up @@ -274,7 +275,49 @@ struct CPUMBState {
} pvr;
};

#include "cpu-qom.h"
/**
* MicroBlazeCPU:
* @env: #CPUMBState
*
* A MicroBlaze CPU.
*/
struct MicroBlazeCPU {
/*< private >*/
CPUState parent_obj;

/*< public >*/

/* Microblaze Configuration Settings */
struct {
bool stackprot;
uint32_t base_vectors;
uint8_t use_fpu;
bool use_mmu;
bool dcache_writeback;
bool endi;
char *version;
uint8_t pvr;
} cfg;

CPUMBState env;
};

static inline MicroBlazeCPU *mb_env_get_cpu(CPUMBState *env)
{
return container_of(env, MicroBlazeCPU, env);
}

#define ENV_GET_CPU(e) CPU(mb_env_get_cpu(e))

#define ENV_OFFSET offsetof(MicroBlazeCPU, env)

void mb_cpu_do_interrupt(CPUState *cs);
bool mb_cpu_exec_interrupt(CPUState *cs, int int_req);
void mb_cpu_dump_state(CPUState *cpu, FILE *f, fprintf_function cpu_fprintf,
int flags);
hwaddr mb_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr);
int mb_cpu_gdb_read_register(CPUState *cpu, uint8_t *buf, int reg);
int mb_cpu_gdb_write_register(CPUState *cpu, uint8_t *buf, int reg);

void mb_tcg_init(void);
MicroBlazeCPU *cpu_mb_init(const char *cpu_model);
Expand Down

0 comments on commit ffa3a3c

Please sign in to comment.