2012-12-06 12:15:58 +01:00
|
|
|
#ifndef HW_PPC_H
|
|
|
|
#define HW_PPC_H 1
|
|
|
|
|
2012-12-01 03:55:58 +01:00
|
|
|
void ppc_set_irq(PowerPCCPU *cpu, int n_IRQ, int level);
|
2011-09-13 06:00:32 +02:00
|
|
|
|
2007-11-17 18:14:51 +01:00
|
|
|
/* PowerPC hardware exceptions management helpers */
|
|
|
|
typedef void (*clk_setup_cb)(void *opaque, uint32_t freq);
|
2009-10-01 23:12:16 +02:00
|
|
|
typedef struct clk_setup_t clk_setup_t;
|
|
|
|
struct clk_setup_t {
|
2007-11-17 18:14:51 +01:00
|
|
|
clk_setup_cb cb;
|
|
|
|
void *opaque;
|
|
|
|
};
|
2009-10-01 23:12:16 +02:00
|
|
|
static inline void clk_setup (clk_setup_t *clk, uint32_t freq)
|
2007-11-17 18:14:51 +01:00
|
|
|
{
|
|
|
|
if (clk->cb != NULL)
|
|
|
|
(*clk->cb)(clk->opaque, freq);
|
|
|
|
}
|
|
|
|
|
2011-09-13 06:00:32 +02:00
|
|
|
struct ppc_tb_t {
|
|
|
|
/* Time base management */
|
|
|
|
int64_t tb_offset; /* Compensation */
|
|
|
|
int64_t atb_offset; /* Compensation */
|
|
|
|
uint32_t tb_freq; /* TB frequency */
|
|
|
|
/* Decrementer management */
|
|
|
|
uint64_t decr_next; /* Tick for next decr interrupt */
|
|
|
|
uint32_t decr_freq; /* decrementer frequency */
|
|
|
|
struct QEMUTimer *decr_timer;
|
|
|
|
/* Hypervisor decrementer management */
|
|
|
|
uint64_t hdecr_next; /* Tick for next hdecr interrupt */
|
|
|
|
struct QEMUTimer *hdecr_timer;
|
|
|
|
uint64_t purr_load;
|
|
|
|
uint64_t purr_start;
|
|
|
|
void *opaque;
|
|
|
|
uint32_t flags;
|
|
|
|
};
|
|
|
|
|
|
|
|
/* PPC Timers flags */
|
|
|
|
#define PPC_TIMER_BOOKE (1 << 0) /* Enable Booke support */
|
|
|
|
#define PPC_TIMER_E500 (1 << 1) /* Enable e500 support */
|
|
|
|
#define PPC_DECR_UNDERFLOW_TRIGGERED (1 << 2) /* Decr interrupt triggered when
|
|
|
|
* the most significant bit
|
|
|
|
* changes from 0 to 1.
|
|
|
|
*/
|
|
|
|
#define PPC_DECR_ZERO_TRIGGERED (1 << 3) /* Decr interrupt triggered when
|
|
|
|
* the decrementer reaches zero.
|
|
|
|
*/
|
|
|
|
|
|
|
|
uint64_t cpu_ppc_get_tb(ppc_tb_t *tb_env, uint64_t vmclk, int64_t tb_offset);
|
2012-03-14 01:38:23 +01:00
|
|
|
clk_setup_cb cpu_ppc_tb_init (CPUPPCState *env, uint32_t freq);
|
2007-11-17 18:14:51 +01:00
|
|
|
/* Embedded PowerPC DCR management */
|
2009-12-21 14:02:39 +01:00
|
|
|
typedef uint32_t (*dcr_read_cb)(void *opaque, int dcrn);
|
|
|
|
typedef void (*dcr_write_cb)(void *opaque, int dcrn, uint32_t val);
|
2012-03-14 01:38:23 +01:00
|
|
|
int ppc_dcr_init (CPUPPCState *env, int (*dcr_read_error)(int dcrn),
|
2007-11-17 18:14:51 +01:00
|
|
|
int (*dcr_write_error)(int dcrn));
|
2012-03-14 01:38:23 +01:00
|
|
|
int ppc_dcr_register (CPUPPCState *env, int dcrn, void *opaque,
|
2007-11-17 18:14:51 +01:00
|
|
|
dcr_read_cb drc_read, dcr_write_cb dcr_write);
|
2012-03-14 01:38:23 +01:00
|
|
|
clk_setup_cb ppc_40x_timers_init (CPUPPCState *env, uint32_t freq,
|
2010-09-20 19:08:42 +02:00
|
|
|
unsigned int decr_excp);
|
|
|
|
|
2007-11-17 18:14:51 +01:00
|
|
|
/* Embedded PowerPC reset */
|
2012-03-14 01:38:23 +01:00
|
|
|
void ppc40x_core_reset (CPUPPCState *env);
|
|
|
|
void ppc40x_chip_reset (CPUPPCState *env);
|
|
|
|
void ppc40x_system_reset (CPUPPCState *env);
|
2007-11-17 18:14:51 +01:00
|
|
|
void PREP_debug_write (void *opaque, uint32_t addr, uint32_t val);
|
|
|
|
|
2009-08-25 20:29:31 +02:00
|
|
|
extern CPUWriteMemoryFunc * const PPC_io_write[];
|
|
|
|
extern CPUReadMemoryFunc * const PPC_io_read[];
|
2007-11-17 18:14:51 +01:00
|
|
|
void PPC_debug_write (void *opaque, uint32_t addr, uint32_t val);
|
2008-10-26 14:43:07 +01:00
|
|
|
|
2012-03-14 01:38:23 +01:00
|
|
|
void ppc40x_irq_init (CPUPPCState *env);
|
|
|
|
void ppce500_irq_init (CPUPPCState *env);
|
|
|
|
void ppc6xx_irq_init (CPUPPCState *env);
|
|
|
|
void ppc970_irq_init (CPUPPCState *env);
|
|
|
|
void ppcPOWER7_irq_init (CPUPPCState *env);
|
2009-01-08 17:01:23 +01:00
|
|
|
|
2013-01-17 11:32:21 +01:00
|
|
|
void ppce500_set_mpic_proxy(bool enabled);
|
|
|
|
|
2009-01-08 17:01:23 +01:00
|
|
|
/* PPC machines for OpenBIOS */
|
|
|
|
enum {
|
|
|
|
ARCH_PREP = 0,
|
|
|
|
ARCH_MAC99,
|
|
|
|
ARCH_HEATHROW,
|
2010-02-09 17:37:02 +01:00
|
|
|
ARCH_MAC99_U3,
|
2009-01-08 17:01:23 +01:00
|
|
|
};
|
|
|
|
|
2009-08-08 12:19:24 +02:00
|
|
|
#define FW_CFG_PPC_WIDTH (FW_CFG_ARCH_LOCAL + 0x00)
|
|
|
|
#define FW_CFG_PPC_HEIGHT (FW_CFG_ARCH_LOCAL + 0x01)
|
|
|
|
#define FW_CFG_PPC_DEPTH (FW_CFG_ARCH_LOCAL + 0x02)
|
2010-02-09 17:37:05 +01:00
|
|
|
#define FW_CFG_PPC_TBFREQ (FW_CFG_ARCH_LOCAL + 0x03)
|
2010-08-03 15:22:42 +02:00
|
|
|
#define FW_CFG_PPC_IS_KVM (FW_CFG_ARCH_LOCAL + 0x05)
|
|
|
|
#define FW_CFG_PPC_KVM_HC (FW_CFG_ARCH_LOCAL + 0x06)
|
|
|
|
#define FW_CFG_PPC_KVM_PID (FW_CFG_ARCH_LOCAL + 0x07)
|
2009-08-15 16:27:05 +02:00
|
|
|
|
|
|
|
#define PPC_SERIAL_MM_BAUDBASE 399193
|
2011-09-13 06:00:32 +02:00
|
|
|
|
|
|
|
/* ppc_booke.c */
|
2012-12-01 04:43:18 +01:00
|
|
|
void ppc_booke_timers_init(PowerPCCPU *cpu, uint32_t freq, uint32_t flags);
|
2012-12-06 12:15:58 +01:00
|
|
|
|
|
|
|
#endif
|