: add alpha es40 system emulation (v2)
PATCH 1/24 Add support for multi-level phys map.
In reply to Tristan GingoldAs Alpha physical addresses are 44 bits, l1_phys_map can't be anymore 2 levels. Use a more generic multi-level approach and explain why we don't need to extend l1_map.
--- exec.c | 50 ++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 38 insertions(+), 12 deletions(-)
exec.c +38 -12
@@ -147,14 +147,17 @@ typedef struct PhysPageDesc { } PhysPageDesc;#define L2_BITS 10 -#if defined(CONFIG_USER_ONLY ) && defined(TARGET_VIRT_ADDR_SPACE_BITS ) -/* XXX: this is a temporary hack for alpha target. -* In the future, this is to be replaced by a multi-level table -* to actually be able to handle the complete 64 bits address space. -*/ -#define L1_BITS (TARGET_VIRT_ADDR_SPACE_BITS - L2_BITS - TARGET_PAGE_BITS) + +#if TARGET_PHYS_ADDR_SPACE_BITS > (32 +32 -L2_BITS -TARGET_PAGE_BITS ) +# define MULTILEVEL_PHYS_MAP +# define L1_BITS_ ((TARGET_PHYS_ADDR_SPACE_BITS - TARGET_PAGE_BITS) % L2_BITS) +# if L1_BITS_ <4 /* avoid ridiculous small l1 */ +# define L1_BITS (L1_BITS_ + L2_BITS) +# else +# define L1_BITS L1_BITS_ +# endif #else -#define L1_BITS (32 - L2_BITS - TARGET_PAGE_BITS) +# define L1_BITS (32 - L2_BITS - TARGET_PAGE_BITS)#endif #define L1_SIZE (1 << L1_BITS)
@@ -165,7 +168,9 @@ unsigned long qemu_host_page_bits;unsigned long qemu_host_page_size;unsigned long qemu_host_page_mask; -/* XXX: for system emulation, it could just be an array */ +/* XXX: for system emulation, it could just be an array. As this is currently +a two level map this limits the size of RAM memory that can contains +target code. In practice this is large enough (>= 4GB) */ static PageDesc *l1_map[L1_SIZE ];static PhysPageDesc **l1_phys_map;
@@ -339,12 +344,31 @@ static PhysPageDesc *phys_page_find_alloc(target_phys_addr_t index, int alloc)void **lp, **p;PhysPageDesc *pd; +#ifdef MULTILEVEL_PHYS_MAP + int i; +#define L1_SHIFT (TARGET_PHYS_ADDR_SPACE_BITS - TARGET_PAGE_BITS - L1_BITS) + + /* Level 1. */ + p = (void **)l1_phys_map; + lp = p + ((index >> L1_SHIFT) & (L1_SIZE - 1)); + + /* Level 2..n-1 */ + for (i = (L1_SHIFT / L2_BITS) - 1; i > 0; i--) { + p = *lp; + if (!p) { + /* allocate if not found */ + if (!alloc) + return NULL; + p = qemu_vmalloc(sizeof(void *) * L2_SIZE); + memset(p, 0, sizeof(void *) * L2_SIZE); + *lp = p; + } + lp = p + ((index >> (i * L2_BITS)) & (L2_SIZE - 1)); + } +#else p = (void **)l1_phys_map; -#if TARGET_PHYS_ADDR_SPACE_BITS >32 -#if TARGET_PHYS_ADDR_SPACE_BITS > (32 +L1_BITS ) -#error unsupported TARGET_PHYS_ADDR_SPACE_BITS -#endif +#if TARGET_PHYS_ADDR_SPACE_BITS > 32 lp = p + ((index >> (L1_BITS + L2_BITS)) & (L1_SIZE - 1)); p = *lp; if (!p) {
@@ -357,6 +381,8 @@ static PhysPageDesc *phys_page_find_alloc(target_phys_addr_t index, int alloc) }#endif lp = p + ((index >>L2_BITS ) & (L1_SIZE -1 )); +#endif + pd = *lp;if (!pd) {int i;
Signature · 1 line
1.6.2
PATCH 5/24 bug fix: avoid nop to override next instruction
In reply to Tristan GingoldWhile searching PC, always store the pc of a new instruction. Instructions that didn't generate tcg code (such as nop) prevented the next one to be referenced.
--- target-alpha/translate.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
target-alpha/translate.c +3 -3
@@ -2380,10 +2380,10 @@ static always_inline void gen_intermediate_code_internal (CPUState *env, lj++;while (lj < j) gen_opc_instr_start[lj++] =0 ; - gen_opc_pc[lj] = ctx.pc; - gen_opc_instr_start[lj] =1 ; - gen_opc_icount[lj] = num_insns; } + gen_opc_pc[lj] = ctx.pc; + gen_opc_instr_start[lj] =1 ; + gen_opc_icount[lj] = num_insns; }if (num_insns +1 == max_insns && (tb->cflags &CF_LAST_IO ))gen_io_start ();
Signature · 1 line
1.6.2
PATCH 6/24 Be slightly more verbose for unassigned_mem_read*
This was found useful while adding new devices.
--- exec.c | 6 +++--- 1 files changed, 3 insertions(+), 3 deletions(-)
exec.c +3 -3
@@ -2437,7 +2437,7 @@ void qemu_ram_free(ram_addr_t addr)static uint32_t unassigned_mem_readb (void *opaque,target_phys_addr_t addr) {#ifdef DEBUG_UNASSIGNED -printf ("Unassigned mem read " TARGET_FMT_plx"\n" , addr); +printf ("Unassigned mem readb " TARGET_FMT_plx"\n" , addr);#endif #if defined(TARGET_SPARC )do_unassigned_access (addr,0 ,0 ,0 ,1 );
@@ -2448,7 +2448,7 @@ static uint32_t unassigned_mem_readb(void *opaque, target_phys_addr_t addr)static uint32_t unassigned_mem_readw (void *opaque,target_phys_addr_t addr) {#ifdef DEBUG_UNASSIGNED -printf ("Unassigned mem read " TARGET_FMT_plx"\n" , addr); +printf ("Unassigned mem readw " TARGET_FMT_plx"\n" , addr);#endif #if defined(TARGET_SPARC )do_unassigned_access (addr,0 ,0 ,0 ,2 );
@@ -2459,7 +2459,7 @@ static uint32_t unassigned_mem_readw(void *opaque, target_phys_addr_t addr)static uint32_t unassigned_mem_readl (void *opaque,target_phys_addr_t addr) {#ifdef DEBUG_UNASSIGNED -printf ("Unassigned mem read " TARGET_FMT_plx"\n" , addr); +printf ("Unassigned mem readl " TARGET_FMT_plx"\n" , addr);#endif #if defined(TARGET_SPARC )do_unassigned_access (addr,0 ,0 ,0 ,4 );
Signature · 1 line
1.6.2
PATCH 13/24 Add target-alpha/machine.c and hw/es40.c for es40 machine emulation.
In reply to Tristan GingoldThe machine emulation is not yet complete, in particular vm save and load is not yet implemented.
--- Makefile.target | 4 + hw/boards.h | 4 + hw/es40.c | 922 ++++++++++++++++++++++++++++++++++++++++++++++++ target-alpha/machine.c | 22 ++ 4 files changed, 952 insertions(+), 0 deletions(-) create mode 100644 hw/es40.c create mode 100644 target-alpha/machine.c
Makefile.target +4 -0
@@ -683,6 +683,10 @@ ifeq ($(TARGET_BASE_ARCH), m68k) OBJS+= an5206.o mcf5206.o ptimer.o mcf_uart.o mcf_intc.o mcf5208.o mcf_fec.o OBJS+= m68k-semi.o dummy_m68k.o endif +ifeq ($(TARGET_BASE_ARCH), alpha) +OBJS+= es40.o 21272.o serial.o i8259.o mc146818rtc.o i8254.o pcspk.o dma.o +OBJS+= ali1543.o +endif ifdef CONFIG_GDBSTUB OBJS+=gdbstub.o gdbstub-xml.o endif
hw/boards.h +4 -0
@@ -128,4 +128,8 @@ extern QEMUMachine musicpal_machine;/* tosa.c */ extern QEMUMachine tosapda_machine; +/* es40.c */ +extern QEMUMachine es40_machine; +extern QEMUMachine es40_rombuild_machine; +#endif
hw/es40.c new file +922 -0
922 lines not on this page · raw message
target-alpha/machine.c new file +22 -0
@@ -0,0 +1,22 @@ +#include "hw/hw.h" +#include "hw/boards.h" +#include "qemu-timer.h" + +#include "exec-all.h" + +void register_machines (void ) +{ +qemu_register_machine (&es40_machine); +qemu_register_machine (&es40_rombuild_machine); +} + +void cpu_save (QEMUFile *f,void *opaque) +{ +/* FIXME: todo */ +abort (); +} + +int cpu_load (QEMUFile *f,void *opaque,int version_id) +{ +return -EINVAL ; +}
Signature · 1 line
1.6.2
PATCH 14/24 Move softmmu_helper.h from exec.h to op_helper.c on alpha.
There is no real needs to inline these functions everywhere and this simplify debugging.
--- target-alpha/exec.h | 4 ---- target-alpha/op_helper.c | 4 ++++ 2 files changed, 4 insertions(+), 4 deletions(-)
target-alpha/exec.h +0 -4
@@ -36,10 +36,6 @@ register struct CPUAlphaState *env asm(AREG0);#include "cpu.h" #include "exec-all.h" -#if !defined(CONFIG_USER_ONLY ) -#include "softmmu_exec.h" -#endif /* !defined(CONFIG_USER_ONLY) */ - static always_inline void env_to_regs(void) { }
target-alpha/op_helper.c +4 -0
@@ -23,6 +23,10 @@#include "softfloat.h" #include "helper.h" +#if !defined(CONFIG_USER_ONLY ) +#include "softmmu_exec.h" +#endif /* !defined(CONFIG_USER_ONLY) */ +void helper_tb_flush (void ) {tlb_flush (env,1 );
Signature · 1 line
1.6.2
PATCH 10/24 Add square wave output support.
In reply to Tristan GingoldThis is necessary for es40 as the sqw output is directly connected to the core chipset.
--- hw/mc146818rtc.c | 40 ++++++++++++++++++++++++++++++---------- hw/pc.h | 1 + 2 files changed, 31 insertions(+), 10 deletions(-)
hw/mc146818rtc.c +30 -10
@@ -50,11 +50,12 @@#define REG_A_UIP 0x80 -#define REG_B_SET 0x80 -#define REG_B_PIE 0x40 -#define REG_B_AIE 0x20 -#define REG_B_UIE 0x10 -#define REG_B_DM 0x04 +#define REG_B_SET 0x80 +#define REG_B_PIE 0x40 +#define REG_B_AIE 0x20 +#define REG_B_UIE 0x10 +#define REG_B_SQWE 0x08 +#define REG_B_DM 0x04struct RTCState {uint8_t cmos_data[128 ];
@@ -62,6 +63,7 @@ struct RTCState {struct tm current_tm;int base_year;qemu_irq irq; +qemu_irq sqw_irq;int it_shift;/* periodic timer */ QEMUTimer *periodic_timer;
@@ -95,20 +97,25 @@ static void rtc_timer_update(RTCState *s, int64_t current_time) {int period_code, period;int64_t cur_clock, next_irq_clock; +int enable_pie; period_code = s->cmos_data[RTC_REG_A ] &0x0f ;#if definedTARGET_I386 || definedTARGET_X86_64 /* disable periodic timer if hpet is in legacy mode, since interrupts are * disabled anyway. */ -if (period_code !=0 && (s->cmos_data[RTC_REG_B ] ®_B_PIE ) && !hpet_in_legacy_mode ()) { + enable_pie =hpet_in_legacy_mode ();#else -if (period_code !=0 && (s->cmos_data[RTC_REG_B ] ®_B_PIE )) { + enable_pie =1 ;#endif +if (period_code !=0 + && (((s->cmos_data[RTC_REG_B ] ®_B_PIE ) && enable_pie) + || ((s->cmos_data[RTC_REG_B ] ®_B_SQWE ) && s->sqw_irq))) {if (period_code <=2 ) period_code +=7 ;/* period in 32 Khz cycles */ period =1 << (period_code -1 ); +//period *= 2; #ifdef TARGET_I386 if (period != s->period) s->irq_coalesced = (s->irq_coalesced * s->period) / period;
@@ -138,8 +145,15 @@ static void rtc_periodic_timer(void *opaque) return; }#endif - s->cmos_data[RTC_REG_C ] |=0xc0 ; -rtc_irq_raise (s->irq); +if (s->cmos_data[RTC_REG_B ] ®_B_PIE ) { + s->cmos_data[RTC_REG_C ] |=0xc0 ; +rtc_irq_raise (s->irq); + } +if (s->cmos_data[RTC_REG_B ] ®_B_SQWE ) { +/* Not square wave at all but we don't want 2048Hz interrupts! +Must be seen as a pulse. */ +qemu_irq_raise (s->sqw_irq); + } }static void cmos_ioport_write (void *opaque,uint32_t addr,uint32_t data)
@@ -527,13 +541,14 @@ static int rtc_load_td(QEMUFile *f, void *opaque, int version_id) }#endif -RTCState *rtc_init (int base,qemu_irq irq,int base_year) +RTCState *rtc_init_sqw (int base,qemu_irq irq,qemu_irq sqw_irq,int base_year) {RTCState *s; s =qemu_mallocz (sizeof (RTCState)); s->irq = irq; + s->sqw_irq = sqw_irq; s->cmos_data[RTC_REG_A ] =0x26 ; s->cmos_data[RTC_REG_B ] =0x02 ; s->cmos_data[RTC_REG_C ] =0x00 ;
@@ -563,6 +578,11 @@ RTCState *rtc_init(int base, qemu_irq irq, int base_year)return s; } +RTCState *rtc_init (int base,qemu_irq irq,int base_year) +{ +return rtc_init_sqw (base, irq,NULL , base_year); +} +/* Memory mapped interface */ static uint32_t cmos_mm_readb (void *opaque,target_phys_addr_t addr) {
hw/pc.h +1 -0
@@ -90,6 +90,7 @@ void i8042_mm_init(qemu_irq kbd_irq, qemu_irq mouse_irq,typedef struct RTCState RTCState ;RTCState *rtc_init (int base,qemu_irq irq,int base_year); +RTCState *rtc_init_sqw (int base,qemu_irq irq,qemu_irq sqw_irq,int base_year);RTCState *rtc_mm_init (target_phys_addr_t base,int it_shift,qemu_irq irq,int base_year);void rtc_set_memory (RTCState *s,int addr,int val);
Signature · 1 line
1.6.2
PATCH 17/24 Add instruction name in comments for hw_ld opcode.
In reply to Tristan GingoldMake code slightly easier to read.
Also unused hw_ld opcodes now generate an invalid opc fault.
--- target-alpha/translate.c | 40 ++++++++++++++++++++-------------------- 1 files changed, 20 insertions(+), 20 deletions(-)
target-alpha/translate.c +20 -20
@@ -1793,62 +1793,62 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)tcg_gen_movi_i64 (addr, disp12);switch ((insn >>12 ) &0xF ) {case 0x0 : -/* Longword physical access */ +/* Longword physical access (hw_ldl/p) */ gen_helper_ldl_raw (cpu_ir[ra], addr);break ;case 0x1 : -/* Quadword physical access */ +/* Quadword physical access (hw_ldq/p) */ gen_helper_ldq_raw (cpu_ir[ra], addr);break ;case 0x2 : -/* Longword physical access with lock */ +/* Longword physical access with lock (hw_ldl_l/p) */ gen_helper_ldl_l_raw (cpu_ir[ra], addr);break ;case 0x3 : -/* Quadword physical access with lock */ +/* Quadword physical access with lock (hw_ldq_l/p) */ gen_helper_ldq_l_raw (cpu_ir[ra], addr);break ;case 0x4 : -/* Longword virtual PTE fetch */ -gen_helper_ldl_kernel (cpu_ir[ra], addr); +/* Longword virtual PTE fetch (hw_ldl/v) */ +tcg_gen_qemu_ld32s (cpu_ir[ra], addr,0 );break ;case 0x5 : -/* Quadword virtual PTE fetch */ -gen_helper_ldq_kernel (cpu_ir[ra], addr); +/* Quadword virtual PTE fetch (hw_ldq/v) */ +tcg_gen_qemu_ld64 (cpu_ir[ra], addr,0 );break ;case 0x6 :/* Incpu_ir[ra]id */ - goto incpu_ir[ra]id_opc; + goto invalid_opc;case 0x7 :/* Incpu_ir[ra]id */ - goto incpu_ir[ra]id_opc; + goto invalid_opc;case 0x8 : -/* Longword virtual access */ +/* Longword virtual access (hw_ldl) */ gen_helper_st_virt_to_phys (addr, addr);gen_helper_ldl_raw (cpu_ir[ra], addr);break ;case 0x9 : -/* Quadword virtual access */ +/* Quadword virtual access (hw_ldq) */ gen_helper_st_virt_to_phys (addr, addr);gen_helper_ldq_raw (cpu_ir[ra], addr);break ;case 0xA : -/* Longword virtual access with protection check */ -tcg_gen_qemu_ld32s (cpu_ir[ra], addr, ctx->flags); +/* Longword virtual access with protection check (hw_ldl/w) */ +tcg_gen_qemu_ld32s (cpu_ir[ra], addr,0 );break ;case 0xB : -/* Quadword virtual access with protection check */ -tcg_gen_qemu_ld64 (cpu_ir[ra], addr, ctx->flags); +/* Quadword virtual access with protection check (hw_ldq/w) */ +tcg_gen_qemu_ld64 (cpu_ir[ra], addr,0 );break ;case 0xC : -/* Longword virtual access with altenate access mode */ +/* Longword virtual access with alt access mode (hw_ldl/a)*/ gen_helper_set_alt_mode ();gen_helper_st_virt_to_phys (addr, addr);gen_helper_ldl_raw (cpu_ir[ra], addr);gen_helper_restore_mode ();break ;case 0xD : -/* Quadword virtual access with altenate access mode */ +/* Quadword virtual access with alt access mode (hw_ldq/a) */ gen_helper_set_alt_mode ();gen_helper_st_virt_to_phys (addr, addr);gen_helper_ldq_raw (cpu_ir[ra], addr);
@@ -1856,7 +1856,7 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)break ;case 0xE :/* Longword virtual access with alternate access mode and -* protection checks +* protection checks (hw_ldl/wa) */ gen_helper_set_alt_mode ();gen_helper_ldl_data (cpu_ir[ra], addr);
@@ -1864,7 +1864,7 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)break ;case 0xF :/* Quadword virtual access with alternate access mode and -* protection checks +* protection checks (hw_ldq/wa) */ gen_helper_set_alt_mode ();gen_helper_ldq_data (cpu_ir[ra], addr);
Signature · 1 line
1.6.2
PATCH 15/24 Document which IPR are used by 21264.
In reply to Tristan GingoldAdd defines for IPR bits.
--- target-alpha/cpu.h | 96 +++++++++++++++++++++++++++++++++++----------------- 1 files changed, 65 insertions(+), 31 deletions(-)
target-alpha/cpu.h +65 -31
@@ -144,51 +144,85 @@ enum {/* XXX: TOFIX: most of those registers are implementation dependant */ enum {/* Ebox IPRs */ -IPR_CC =0xC0 , -IPR_CC_CTL =0xC1 , -IPR_VA =0xC2 , -IPR_VA_CTL =0xC4 , -IPR_VA_FORM =0xC3 , +IPR_CC =0xC0 ,/* 21264 */ +IPR_CC_CTL =0xC1 ,/* 21264 */ +#define IPR_CC_CTL_ENA_SHIFT 32 +#define IPR_CC_CTL_COUNTER_MASK 0xfffffff0UL +IPR_VA =0xC2 ,/* 21264 */ +IPR_VA_CTL =0xC4 ,/* 21264 */ +#define IPR_VA_CTL_VA_48_SHIFT 1 +#define IPR_VA_CTL_VPTB_SHIFT 30 +IPR_VA_FORM =0xC3 ,/* 21264 */ /* Ibox IPRs */ -IPR_ITB_TAG =0x00 , -IPR_ITB_PTE =0x01 , -IPT_ITB_IAP =0x02 , -IPT_ITB_IA =0x03 , -IPT_ITB_IS =0x04 , +IPR_ITB_TAG =0x00 ,/* 21264 */ +IPR_ITB_PTE =0x01 ,/* 21264 */ +IPR_ITB_IAP =0x02 , +IPR_ITB_IA =0x03 ,/* 21264 */ +IPR_ITB_IS =0x04 ,IPR_PMPC =0x05 , -IPR_EXC_ADDR =0x06 , -IPR_IVA_FORM =0x07 , -IPR_CM =0x09 , -IPR_IER =0x0A , -IPR_SIRR =0x0C , -IPR_ISUM =0x0D , -IPR_HW_INT_CLR =0x0E , +IPR_EXC_ADDR =0x06 ,/* 21264 */ +IPR_IVA_FORM =0x07 ,/* 21264 */ +IPR_CM =0x09 ,/* 21264 */ +#define IPR_CM_SHIFT 3 +#define IPR_CM_MASK (3ULL << IPR_CM_SHIFT) /* 21264 */ +IPR_IER =0x0A ,/* 21264 */ +#define IPR_IER_MASK 0x0000007fffffe000ULL + IPR_IER_CM = 0x0B, /* 21264: = CM | IER */ +IPR_SIRR =0x0C ,/* 21264 */ +#define IPR_SIRR_SHIFT 14 +#define IPR_SIRR_MASK 0x7fff +IPR_ISUM =0x0D ,/* 21264 */ +IPR_HW_INT_CLR =0x0E ,/* 21264 */ IPR_EXC_SUM =0x0F ,IPR_PAL_BASE =0x10 ,IPR_I_CTL =0x11 , -IPR_I_STAT =0x16 , -IPR_IC_FLUSH =0x13 , -IPR_IC_FLUSH_ASM =0x12 , +#define IPR_I_CTL_CHIP_ID_SHIFT 24 /* 21264 */ +#define IPR_I_CTL_BIST_FAIL (1 << 23) /* 21264 */ +#define IPR_I_CTL_IC_EN_SHIFT 2 /* 21264 */ +#define IPR_I_CTL_SDE1_SHIFT 7 /* 21264 */ +#define IPR_I_CTL_HWE_SHIFT 12 /* 21264 */ +#define IPR_I_CTL_VA_48_SHIFT 15 /* 21264 */ +#define IPR_I_CTL_SPE_SHIFT 3 /* 21264 */ +#define IPR_I_CTL_CALL_PAL_R23_SHIFT 20 /* 21264 */ +IPR_I_STAT =0x16 ,/* 21264 */ +IPR_IC_FLUSH =0x13 ,/* 21264 */ +IPR_IC_FLUSH_ASM =0x12 ,/* 21264 */ IPR_CLR_MAP =0x15 ,IPR_SLEEP =0x17 ,IPR_PCTX =0x40 , -IPR_PCTR_CTL =0x14 , +IPR_PCTX_ASN =0x01 ,/* field */ +#define IPR_PCTX_ASN_SHIFT 39 + IPR_PCTX_ASTER = 0x02, /* field */ +#define IPR_PCTX_ASTER_SHIFT 5 + IPR_PCTX_ASTRR = 0x04, /* field */ +#define IPR_PCTX_ASTRR_SHIFT 9 + IPR_PCTX_PPCE = 0x08, /* field */ +#define IPR_PCTX_PPCE_SHIFT 1 + IPR_PCTX_FPE = 0x10, /* field */ +#define IPR_PCTX_FPE_SHIFT 2 + IPR_PCTX_ALL = 0x5f, /* all fields */ +IPR_PCTR_CTL =0x14 ,/* 21264 */ /* Mbox IPRs */ -IPR_DTB_TAG0 =0x20 , -IPR_DTB_TAG1 =0xA0 , -IPR_DTB_PTE0 =0x21 , -IPR_DTB_PTE1 =0xA1 , +IPR_DTB_TAG0 =0x20 ,/* 21264 */ +IPR_DTB_TAG1 =0xA0 ,/* 21264 */ +IPR_DTB_PTE0 =0x21 ,/* 21264 */ +IPR_DTB_PTE1 =0xA1 ,/* 21264 */ IPR_DTB_ALTMODE =0xA6 , +IPR_DTB_ALTMODE0 =0x26 ,/* 21264 */ +#define IPR_DTB_ALTMODE_MASK 3 IPR_DTB_IAP = 0xA2, -IPR_DTB_IA =0xA3 , +IPR_DTB_IA =0xA3 ,/* 21264 */ IPR_DTB_IS0 =0x24 ,IPR_DTB_IS1 =0xA4 , -IPR_DTB_ASN0 =0x25 , -IPR_DTB_ASN1 =0xA5 , -IPR_MM_STAT =0x27 , -IPR_M_CTL =0x28 , +IPR_DTB_ASN0 =0x25 ,/* 21264 */ +IPR_DTB_ASN1 =0xA5 ,/* 21264 */ +#define IPR_DTB_ASN_SHIFT 56 + IPR_MM_STAT = 0x27, /* 21264 */ +IPR_M_CTL =0x28 ,/* 21264 */ +#define IPR_M_CTL_SPE_SHIFT 1 +#define IPR_M_CTL_SPE_MASK 7IPR_DC_CTL =0x29 , -IPR_DC_STAT =0x2A , +IPR_DC_STAT =0x2A ,/* 21264 */ /* Cbox IPRs */ IPR_C_DATA =0x2B ,IPR_C_SHIFT =0x2C ,
Signature · 1 line
1.6.2
PATCH 16/24 tb_flush helper should flush the tb (and not the tlb).
Looks to be a typo fix.
--- target-alpha/op_helper.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
target-alpha/op_helper.c +1 -1
@@ -29,7 +29,7 @@void helper_tb_flush (void ) { -tlb_flush (env,1 ); +tb_flush (env); }/*****************************************************************************/
Signature · 1 line
1.6.2
PATCH 2/24 Fix cpu_physical_memory_rw when operating on IO blocks.
In reply to Tristan GingoldIn some cases, addr was destroyed and the next access was wrong. This occured while making 64bits IO accesses.
--- exec.c | 26 +++++++++++++++----------- 1 files changed, 15 insertions(+), 11 deletions(-)
exec.c +15 -11
@@ -354,16 +354,16 @@ static PhysPageDesc *phys_page_find_alloc(target_phys_addr_t index, int alloc)/* Level 2..n-1 */ for (i = (L1_SHIFT /L2_BITS ) -1 ; i >0 ; i--) { - p = *lp; -if (!p) { -/* allocate if not found */ -if (!alloc) -return NULL ; - p =qemu_vmalloc (sizeof (void *) *L2_SIZE ); -memset (p,0 ,sizeof (void *) *L2_SIZE ); - *lp = p; - } - lp = p + ((index >> (i *L2_BITS )) & (L2_SIZE -1 )); + p = *lp; +if (!p) { +/* allocate if not found */ +if (!alloc) +return NULL ; + p =qemu_vmalloc (sizeof (void *) *L2_SIZE ); +memset (p,0 ,sizeof (void *) *L2_SIZE ); + *lp = p; + } + lp = p + ((index >> (i *L2_BITS )) & (L2_SIZE -1 )); }#else p = (void **)l1_phys_map;
@@ -2988,6 +2988,7 @@ void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf,target_phys_addr_t page;unsigned long pd;PhysPageDesc *p; +unsigned long addr1;while (len >0 ) { page = addr &TARGET_PAGE_MASK ;
@@ -3007,6 +3008,8 @@ void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf, io_index = (pd >>IO_MEM_SHIFT ) & (IO_MEM_NB_ENTRIES -1 );if (p) addr1 = (addr & ~TARGET_PAGE_MASK ) + p->region_offset; +else + addr1 = addr;/* XXX: could force cpu_single_env to NULL to avoid potential bugs */ if (l >=4 && ((addr1 &3 ) ==0 )) {
@@ -3026,7 +3029,6 @@ void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf, l =1 ; } }else { -unsigned long addr1; addr1 = (pd &TARGET_PAGE_MASK ) + (addr & ~TARGET_PAGE_MASK );/* RAM case */ ptr = phys_ram_base + addr1;
@@ -3047,6 +3049,8 @@ void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf, io_index = (pd >>IO_MEM_SHIFT ) & (IO_MEM_NB_ENTRIES -1 );if (p) addr1 = (addr & ~TARGET_PAGE_MASK ) + p->region_offset; +else + addr1 = addr;if (l >=4 && ((addr1 &3 ) ==0 )) {/* 32 bit read access */ val = io_mem_read[io_index][2 ](io_mem_opaque[io_index], addr1);
Signature · 1 line
1.6.2
PATCH 22/24 Move linux-user pal emulation to linux-user/
In reply to Tristan GingoldMove pal emulation for user emulation from alpha_palcode.c to linux-user/main.c Add generic exception names.
Fix offset for PAL calls.
--- Makefile.target | 5 +-- hw/alpha_palcode.c | 44 --------------------- linux-user/main.c | 96 +++++++++++++++++++++++++--------------------- target-alpha/cpu.h | 39 +++++++++++++++--- target-alpha/helper.c | 4 +- target-alpha/translate.c | 1 - 6 files changed, 87 insertions(+), 102 deletions(-)
Makefile.target +1 -4
@@ -157,10 +157,6 @@ ifeq ($(TARGET_BASE_ARCH), arm) LIBOBJS+= neon_helper.o iwmmxt_helper.o endif -ifeq ($(TARGET_BASE_ARCH), alpha) -LIBOBJS+= alpha_palcode.o -endif - ifeq ($(TARGET_BASE_ARCH), cris) LIBOBJS+= cris-dis.o
@@ -686,6 +682,7 @@ endif ifeq ($(TARGET_BASE_ARCH), alpha) OBJS+= es40.o 21272.o serial.o i8259.o mc146818rtc.o i8254.o pcspk.o dma.o OBJS+= ali1543.o +#OBJS+= alpha_palcode.o # Not currently used until pal is virtualized endif ifdef CONFIG_GDBSTUB OBJS+=gdbstub.o gdbstub-xml.o
hw/alpha_palcode.c +0 -44
53 lines not on this page · raw message
linux-user/main.c +52 -44
135 lines not on this page · raw message
target-alpha/cpu.h +32 -7
@@ -291,7 +291,11 @@ struct pal_handler_t {void (*call_pal)(CPUAlphaState *env,uint32_t palcode); }; +#if !defined(CONFIG_USER_ONLY )#define NB_MMU_MODES 4 +#else +#define NB_MMU_MODES 2 +#endif struct CPUAlphaState {uint64_t ir[31 ];
@@ -318,6 +322,12 @@ struct CPUAlphaState {CPU_COMMON uint32_t hflags; +#if defined(CONFIG_USER_ONLY ) +struct { +uint64_t usp; +uint64_t unique; + } user; +#endif int error_code;
@@ -342,6 +352,8 @@ struct CPUAlphaState {#define MMU_KERNEL_IDX 0#define MMU_USER_IDX 3#define MMU_PAL_IDX 4 + +#if !defined(CONFIG_USER_ONLY )static inline int cpu_mmu_index_data (CPUState *env) {return env->mmu_data_index;
@@ -351,8 +363,13 @@ static inline int cpu_mmu_index_code (CPUState *env) {return env->mmu_code_index; } +#else +#define cpu_mmu_index_data cpu_mmu_index_code +static inline int cpu_mmu_index_code (CPUState *env) +{ +return 0 ; +} -#if defined(CONFIG_USER_ONLY )static inline void cpu_clone_regs (CPUState *env,target_ulong newsp) {if (newsp)
@@ -384,9 +401,20 @@ enum {EXCP_UNALIGN =0x11E0 ,EXCP_OPCDEC =0x13E0 ,EXCP_FEN =0x17E0 , -EXCP_CALL_PAL =0x2000 , -EXCP_CALL_PALP =0x3000 , -EXCP_CALL_PALE =0x4000 , + +/* Generic exception - to be mapped to processor. */ +EXCP_GEN_OPCDEC =1 , +EXCP_GEN_ARITH =2 , +EXCP_GEN_INTERRUPT =3 , +EXCP_GEN_LAST =3 , + +/* User linux exception. */ +EXCP_USER_DFAULT =0x0100 , +EXCP_USER_ITB_MISS =0x0101 , + +EXCP_CALL_PALP =0x2000 , +EXCP_CALL_PAL =0x3000 , +EXCP_CALL_PALE =0x4000 ,/* End of Pal */ /* Pseudo exception for console */ EXCP_CONSOLE_DISPATCH =0x4001 , EXCP_CONSOLE_FIXUP = 0x4002,
@@ -448,11 +476,8 @@ void do_interrupt (CPUState *env);int cpu_alpha_mfpr (CPUState *env,int iprn,uint64_t *valp);int cpu_alpha_mtpr (CPUState *env,int iprn,uint64_t val,uint64_t *oldvalp); -void pal_init (CPUState *env);#if !defined (CONFIG_USER_ONLY )void call_pal (CPUState *env); -#else -void call_pal (CPUState *env,int palcode);#endif static inline void cpu_pc_from_tb (CPUState *env,TranslationBlock *tb)
target-alpha/helper.c +2 -2
@@ -31,9 +31,9 @@ int cpu_alpha_handle_mmu_fault (CPUState *env, target_ulong address, int rw, int mmu_idx, int is_softmmu) {if (rw ==2 ) - env->exception_index =EXCP_ITB_MISS ; + env->exception_index =EXCP_USER_ITB_MISS ;else - env->exception_index =EXCP_DFAULT ; + env->exception_index =EXCP_USER_DFAULT ; env->ipr[IPR_EXC_ADDR ] = address;return 1 ;
target-alpha/translate.c +0 -1
@@ -2511,7 +2511,6 @@ CPUAlphaState * cpu_alpha_init (const char *cpu_model)#if defined (CONFIG_USER_ONLY ) env->ps |=1 <<3 ;#endif -pal_init (env);/* Initialize IPR */ hwpcb = env->ipr[IPR_PCBB ]; env->ipr[IPR_ASN ] =0 ;
Signature · 1 line
1.6.2
cover : add alpha es40 system emulation (v2)
Hi,
these patches add alpha system emulation. Currently it emulates an es40 system just enough to get the firmware prompt.
This is the second version of the patches. They addresses the comments made and I made a very improvments too.
Only the last patch adds full cpu emulation. Most of the previous ones fix bugs or add new devices and can be applied independently.
Tristan.
PATCH 8/24 Allow 5 mmu indexes.
In reply to Tristan GingoldThis is necessary for alpha because it has 4 protection levels and pal mode.
--- exec.c | 30 +++++++++++++++++++++++++----- softmmu_exec.h | 29 ++++++++++++++++++++++++----- 2 files changed, 49 insertions(+), 10 deletions(-)
exec.c +25 -5
@@ -1760,12 +1760,18 @@ void tlb_flush(CPUState *env, int flush_global) env->tlb_table[2 ][i].addr_read =-1 ; env->tlb_table[2 ][i].addr_write =-1 ; env->tlb_table[2 ][i].addr_code =-1 ; -#if (NB_MMU_MODES ==4 ) +#endif +#if (NB_MMU_MODES >=4 ) env->tlb_table[3 ][i].addr_read =-1 ; env->tlb_table[3 ][i].addr_write =-1 ; env->tlb_table[3 ][i].addr_code =-1 ;#endif +#if (NB_MMU_MODES >=5 ) + env->tlb_table[4 ][i].addr_read =-1 ; + env->tlb_table[4 ][i].addr_write =-1 ; + env->tlb_table[4 ][i].addr_code =-1 ;#endif + }memset (env->tb_jmp_cache,0 ,TB_JMP_CACHE_SIZE *sizeof (void *));
@@ -1809,9 +1815,12 @@ void tlb_flush_page(CPUState *env, target_ulong addr)tlb_flush_entry (&env->tlb_table[1 ][i], addr);#if (NB_MMU_MODES >=3 )tlb_flush_entry (&env->tlb_table[2 ][i], addr); -#if (NB_MMU_MODES ==4 ) +#endif +#if (NB_MMU_MODES >=4 )tlb_flush_entry (&env->tlb_table[3 ][i], addr);#endif +#if (NB_MMU_MODES >=5 ) +tlb_flush_entry (&env->tlb_table[4 ][i], addr);#endif tlb_flush_jmp_cache (env, addr);
@@ -1895,10 +1904,14 @@ void cpu_physical_memory_reset_dirty(ram_addr_t start, ram_addr_t end,#if (NB_MMU_MODES >=3 )for (i =0 ; i <CPU_TLB_SIZE ; i++)tlb_reset_dirty_range (&env->tlb_table[2 ][i], start1, length); -#if (NB_MMU_MODES ==4 ) +#endif +#if (NB_MMU_MODES >=4 )for (i =0 ; i <CPU_TLB_SIZE ; i++)tlb_reset_dirty_range (&env->tlb_table[3 ][i], start1, length);#endif +#if (NB_MMU_MODES >=5 ) +for (i =0 ; i <CPU_TLB_SIZE ; i++) +tlb_reset_dirty_range (&env->tlb_table[4 ][i], start1, length);#endif } }
@@ -1944,10 +1957,14 @@ void cpu_tlb_update_dirty(CPUState *env)#if (NB_MMU_MODES >=3 )for (i =0 ; i <CPU_TLB_SIZE ; i++)tlb_update_dirty (&env->tlb_table[2 ][i]); -#if (NB_MMU_MODES ==4 ) +#endif +#if (NB_MMU_MODES >=4 )for (i =0 ; i <CPU_TLB_SIZE ; i++)tlb_update_dirty (&env->tlb_table[3 ][i]);#endif +#if (NB_MMU_MODES >=5 ) +for (i =0 ; i <CPU_TLB_SIZE ; i++) +tlb_update_dirty (&env->tlb_table[4 ][i]);#endif }
@@ -1969,9 +1986,12 @@ static inline void tlb_set_dirty(CPUState *env, target_ulong vaddr)tlb_set_dirty1 (&env->tlb_table[1 ][i], vaddr);#if (NB_MMU_MODES >=3 )tlb_set_dirty1 (&env->tlb_table[2 ][i], vaddr); -#if (NB_MMU_MODES ==4 ) +#endif +#if (NB_MMU_MODES >=4 )tlb_set_dirty1 (&env->tlb_table[3 ][i], vaddr);#endif +#if (NB_MMU_MODES >=5 ) +tlb_set_dirty1 (&env->tlb_table[4 ][i], vaddr);#endif }
softmmu_exec.h +24 -5
@@ -60,6 +60,7 @@#include "softmmu_header.h" #undef ACCESS_TYPE#undef MEMSUFFIX +#endif /* (NB_MMU_MODES >= 3) */ #if (NB_MMU_MODES >=4 )
@@ -78,12 +79,30 @@#include "softmmu_header.h" #undef ACCESS_TYPE#undef MEMSUFFIX +#endif /* (NB_MMU_MODES >= 4) */ -#if (NB_MMU_MODES >4 ) -#error "NB_MMU_MODES > 4 is not supported for now" -#endif /* (NB_MMU_MODES > 4) */ -#endif /* (NB_MMU_MODES == 4) */ -#endif /* (NB_MMU_MODES >= 3) */ +#if (NB_MMU_MODES >=5 ) + +#define ACCESS_TYPE 4 +#define MEMSUFFIX MMU_MODE4_SUFFIX +#define DATA_SIZE 1 +#include "softmmu_header.h" + +#define DATA_SIZE 2 +#include "softmmu_header.h" + +#define DATA_SIZE 4 +#include "softmmu_header.h" + +#define DATA_SIZE 8 +#include "softmmu_header.h" +#undef ACCESS_TYPE +#undef MEMSUFFIX +#endif /* (NB_MMU_MODES >= 4) */ + +#if (NB_MMU_MODES >5 ) +#error "NB_MMU_MODES > 5 is not supported for now" +#endif /* (NB_MMU_MODES > 5) */ /* these access are slower, they must be as rare as possible */ #define ACCESS_TYPE (NB_MMU_MODES)
Signature · 1 line
1.6.2
PATCH 11/24 Add ali1543 super IO pci device.
In reply to Tristan GingoldThis is a very partial implementation just enough for es40 firmware.
--- hw/ali1543.c | 133 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/pci.h | 5 ++ hw/pci_ids.h | 3 + 3 files changed, 141 insertions(+), 0 deletions(-) create mode 100644 hw/ali1543.c
hw/ali1543.c new file +133 -0
@@ -0,0 +1,133 @@ +/* +* QEMU Ali 1543c emulation +* +* Copyright (c) 2009 AdaCore +* +* Written by Tristan Gingold. +* +* This work is licensed under the GNU GPL license version 2 or later. +* +*/ +#include <time.h> +#include <sys/time.h> +#include "hw.h" +#include "net.h" +#include "sysemu.h" +#include "devices.h" +#include "boards.h" +#include "pc.h" +#include "isa.h" +#include "qemu-char.h" +#include "pci.h" + +//#define DEBUG_CFG + +struct ali1543_t { +PCIDevice pci; + +qemu_irq *irq;/* Upstream handler. */ +PITState *pit; +qemu_irq *i8259; + +/* Configuration. */ +enum cfg_state {CFG_SNOOP ,CFG_51 ,CFG_EN } cfg_state; +unsigned char cfg_index; +}; + +static void ali_cfg_write (void *opaque,uint32_t addr,uint32_t val) +{ +ali1543_t *ali = opaque; + +if ((addr &1 ) ==0 ) { +switch (ali->cfg_state) { +case CFG_SNOOP : +if (val ==0x51 ) + ali->cfg_state =CFG_51 ; +else +qemu_log ("ali1543-cfg: write %02x to cfg_port\n" , val); +break ; +case CFG_51 : +if (val ==0x23 ) + ali->cfg_state =CFG_EN ; +else { +qemu_log ("ali1543-cfg: write %02x to cfg_port (51)\n" , val); + ali->cfg_state =CFG_SNOOP ; + } +break ; +case CFG_EN : + ali->cfg_index = val; +break ; + } + } +else { +#ifdef DEBUG_CFG +qemu_log ("ali1543-cfg: write %02x to cfg reg %02x (addr=%x)\n" , + val, ali->cfg_index, addr); +#endif + } +} + +static uint32_t ali_cfg_read (void *opaque,uint32_t addr) +{ +ali1543_t *ali = opaque; + +if ((addr &1 ) ==0 ) { +if (ali->cfg_state !=CFG_EN ) { +qemu_log ("ali1543-cfg: read fromcfg_port\n" ); +return 0 ; + } +else +return ali->cfg_index; + } +else { +#ifdef DEBUG_CFG +qemu_log ("ali1543-cfg: read from reg %02x\n" , ali->cfg_index); +#endif +return 0 ; + } +} + +ali1543_t *ali1543_init (PCIBus *bus,int devfn,qemu_irq irq) +{ +ali1543_t *ali; +uint8_t *pci_conf; + + ali = (ali1543_t *)pci_register_device (bus,"Ali1543" ,sizeof (ali1543_t), + devfn,NULL ,NULL ); + + pci_conf = ali->pci.config; + +pci_config_set_vendor_id (pci_conf,PCI_VENDOR_ID_AL ); +pci_config_set_device_id (pci_conf,PCI_DEVICE_ID_AL_M1533 ); + pci_conf[0x08 ] =0xc3 ;// Revision +pci_config_set_class (pci_conf,PCI_CLASS_BRIDGE_ISA ); + pci_conf[0x2c ] =0 ;// Subsystem + pci_conf[0x2d ] =0 ; + pci_conf[0x2e ] =0 ; + pci_conf[0x2f ] =0 ; + +register_ioport_read (0x370 ,2 ,1 , ali_cfg_read, ali); +register_ioport_write (0x370 ,2 ,1 , ali_cfg_write, ali); + + ali->i8259 =i8259_init (irq); + +/* serial_init already handles NULL CharDriverState but this code adds +a more useful label. */ +if (serial_hds[0 ] ==NULL ) + serial_hds[0 ] =qemu_chr_open ("com1" ,"nul" ,NULL ); +if (serial_hds[1 ] ==NULL ) + serial_hds[1 ] =qemu_chr_open ("com2" ,"nul" ,NULL ); + +serial_init (0x3f8 , ali->i8259[4 ],115200 , serial_hds[0 ]); +serial_init (0x2f8 , ali->i8259[3 ],115200 , serial_hds[1 ]); + ali->pit =pit_init (0x40 , ali->i8259[0 ]); +pcspk_init (ali->pit); +DMA_init (0 ); + +return ali; +} + +qemu_irq ali1543_get_irq (ali1543_t *c,int n) +{ +return c->i8259[n]; +}
hw/pci.h +5 -0
@@ -254,4 +254,9 @@ PCIBus *pci_apb_init(target_phys_addr_t special_base,PCIBus *sh_pci_register_bus (pci_set_irq_fn set_irq,pci_map_irq_fn map_irq,qemu_irq *pic,int devfn_min,int nirq); +/* ali1543.c */ +typedef struct ali1543_t ali1543_t ; +ali1543_t *ali1543_init (PCIBus *bus,int devfn,qemu_irq irq); +qemu_irq ali1543_get_irq (ali1543_t *c,int n); +#endif
hw/pci_ids.h +3 -0
@@ -70,6 +70,9 @@#define PCI_VENDOR_ID_CMD 0x1095#define PCI_DEVICE_ID_CMD_646 0x0646 +#define PCI_VENDOR_ID_AL 0x10b9 +#define PCI_DEVICE_ID_AL_M1533 0x1533 +#define PCI_VENDOR_ID_REALTEK 0x10ec#define PCI_DEVICE_ID_REALTEK_8139 0x8139
Signature · 1 line
1.6.2
PATCH 18/24 Remove PALCODE_ declarations (unused).
In reply to Tristan Gingold--- target-alpha/cpu.h | 10 ---------- 1 files changed, 0 insertions(+), 10 deletions(-)
target-alpha/cpu.h +0 -10
@@ -398,16 +398,6 @@ enum { };enum { -PALCODE_CALL =0x00000000 , -PALCODE_LD =0x01000000 , -PALCODE_ST =0x02000000 , -PALCODE_MFPR =0x03000000 , -PALCODE_MTPR =0x04000000 , -PALCODE_REI =0x05000000 , -PALCODE_INIT =0xF0000000 , -}; - -enum {IR_V0 =0 ,IR_T0 =1 ,IR_T1 =2 ,
Signature · 1 line
1.6.2
PATCH 19/24 alpha ld helpers now directly return the value.
Remove _kernel helpers as they can be directly generated. Replace ld/st_raw with _phys (bug fix).
--- target-alpha/helper.h | 22 ++++++++--------- target-alpha/op_helper.c | 58 ++++++++++++++++++++------------------------- target-alpha/translate.c | 32 ++++++++++++------------ 3 files changed, 52 insertions(+), 60 deletions(-)
target-alpha/helper.h +10 -12
@@ -116,18 +116,16 @@ DEF_HELPER_0(restore_mode, void) DEF_HELPER_1(ld_virt_to_phys, i64, i64) DEF_HELPER_1(st_virt_to_phys, i64, i64) -DEF_HELPER_2(ldl_raw, void, i64, i64) -DEF_HELPER_2(ldq_raw, void, i64, i64) -DEF_HELPER_2(ldl_l_raw, void, i64, i64) -DEF_HELPER_2(ldq_l_raw, void, i64, i64) -DEF_HELPER_2(ldl_kernel, void, i64, i64) -DEF_HELPER_2(ldq_kernel, void, i64, i64) -DEF_HELPER_2(ldl_data, void, i64, i64) -DEF_HELPER_2(ldq_data, void, i64, i64) -DEF_HELPER_2(stl_raw, void, i64, i64) -DEF_HELPER_2(stq_raw, void, i64, i64) -DEF_HELPER_2(stl_c_raw, i64, i64, i64) -DEF_HELPER_2(stq_c_raw, i64, i64, i64) +DEF_HELPER_1(ldl_phys, i32, i64) +DEF_HELPER_1(ldq_phys, i64, i64) +DEF_HELPER_1(ldl_l_phys, i32, i64) +DEF_HELPER_1(ldq_l_phys, i64, i64) +DEF_HELPER_1(ldl_data, i32, i64) +DEF_HELPER_1(ldq_data, i64, i64) +DEF_HELPER_2(stl_phys, void, i64, i64) +DEF_HELPER_2(stq_phys, void, i64, i64) +DEF_HELPER_2(stl_c_phys, i64, i64, i64) +DEF_HELPER_2(stq_c_phys, i64, i64, i64)#endif #include "def-helper.h"
target-alpha/op_helper.c +26 -32
102 lines not on this page · raw message
target-alpha/translate.c +16 -16
@@ -1794,19 +1794,19 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)switch ((insn >>12 ) &0xF ) {case 0x0 :/* Longword physical access (hw_ldl/p) */ -gen_helper_ldl_raw (cpu_ir[ra], addr); +gen_helper_ldl_phys (cpu_ir[ra], addr);break ;case 0x1 :/* Quadword physical access (hw_ldq/p) */ -gen_helper_ldq_raw (cpu_ir[ra], addr); +gen_helper_ldq_phys (cpu_ir[ra], addr);break ;case 0x2 :/* Longword physical access with lock (hw_ldl_l/p) */ -gen_helper_ldl_l_raw (cpu_ir[ra], addr); +gen_helper_ldl_l_phys (cpu_ir[ra], addr);break ;case 0x3 :/* Quadword physical access with lock (hw_ldq_l/p) */ -gen_helper_ldq_l_raw (cpu_ir[ra], addr); +gen_helper_ldq_l_phys (cpu_ir[ra], addr);break ;case 0x4 :/* Longword virtual PTE fetch (hw_ldl/v) */
@@ -1825,12 +1825,12 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)case 0x8 :/* Longword virtual access (hw_ldl) */ gen_helper_st_virt_to_phys (addr, addr); -gen_helper_ldl_raw (cpu_ir[ra], addr); +gen_helper_ldl_phys (cpu_ir[ra], addr);break ;case 0x9 :/* Quadword virtual access (hw_ldq) */ gen_helper_st_virt_to_phys (addr, addr); -gen_helper_ldq_raw (cpu_ir[ra], addr); +gen_helper_ldq_phys (cpu_ir[ra], addr);break ;case 0xA :/* Longword virtual access with protection check (hw_ldl/w) */
@@ -1844,14 +1844,14 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)/* Longword virtual access with alt access mode (hw_ldl/a)*/ gen_helper_set_alt_mode ();gen_helper_st_virt_to_phys (addr, addr); -gen_helper_ldl_raw (cpu_ir[ra], addr); +gen_helper_ldl_phys (cpu_ir[ra], addr);gen_helper_restore_mode ();break ;case 0xD :/* Quadword virtual access with alt access mode (hw_ldq/a) */ gen_helper_set_alt_mode ();gen_helper_st_virt_to_phys (addr, addr); -gen_helper_ldq_raw (cpu_ir[ra], addr); +gen_helper_ldq_phys (cpu_ir[ra], addr);gen_helper_restore_mode ();break ;case 0xE :
@@ -2123,29 +2123,29 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)switch ((insn >>12 ) &0xF ) {case 0x0 :/* Longword physical access */ -gen_helper_stl_raw (val, addr); +gen_helper_stl_phys (val, addr);break ;case 0x1 :/* Quadword physical access */ -gen_helper_stq_raw (val, addr); +gen_helper_stq_phys (val, addr);break ;case 0x2 :/* Longword physical access with lock */ -gen_helper_stl_c_raw (val, val, addr); +gen_helper_stl_c_phys (val, val, addr);break ;case 0x3 :/* Quadword physical access with lock */ -gen_helper_stq_c_raw (val, val, addr); +gen_helper_stq_c_phys (val, val, addr);break ;case 0x4 :/* Longword virtual access */ gen_helper_st_virt_to_phys (addr, addr); -gen_helper_stl_raw (val, addr); +gen_helper_stl_phys (val, addr);break ;case 0x5 :/* Quadword virtual access */ gen_helper_st_virt_to_phys (addr, addr); -gen_helper_stq_raw (val, addr); +gen_helper_stq_phys (val, addr);break ;case 0x6 :/* Invalid */
@@ -2169,14 +2169,14 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)/* Longword virtual access with alternate access mode */ gen_helper_set_alt_mode ();gen_helper_st_virt_to_phys (addr, addr); -gen_helper_stl_raw (val, addr); +gen_helper_stl_phys (val, addr);gen_helper_restore_mode ();break ;case 0xD :/* Quadword virtual access with alternate access mode */ gen_helper_set_alt_mode ();gen_helper_st_virt_to_phys (addr, addr); -gen_helper_stl_raw (val, addr); +gen_helper_stl_phys (val, addr);gen_helper_restore_mode ();break ;case 0xE :
Signature · 1 line
1.6.2
PATCH 23/24 Correctly decode hw_ld/hw_st opcodes for all alpha implementations.
In reply to Tristan GingoldAllow privilegied pal_code only in kernel mode.
--- target-alpha/translate.c | 32 ++++++++++++++++++++++++-------- 1 files changed, 24 insertions(+), 8 deletions(-)
target-alpha/translate.c +24 -8
@@ -52,6 +52,7 @@ struct DisasContext {int pal_mode;#endif uint32_t amask; +uint32_t implver; };/* global register indexes */
@@ -103,6 +104,20 @@ static void alpha_translate_init(void) done_init =1 ; } +static inline int get_mxcr_iprn (DisasContext *ctx,uint32_t insn) +{ +switch (ctx->implver) { +case IMPLVER_2106x: +return insn &0xff ; +case IMPLVER_21164 : +return insn &0xffff ; +case IMPLVER_21264 : +return (insn >>8 ) &0xff ; +default : +abort (); + } +} + static always_inline void gen_excp (DisasContext *ctx,int exception,int error_code) {
@@ -689,7 +704,7 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)#if !defined (CONFIG_USER_ONLY ) } else if (palcode < 0x40) {/* Privileged PAL code */ -if (ctx->mem_idx &1 ) +if (ctx->mem_idx !=MMU_KERNEL_IDX ) goto invalid_opc;else gen_excp (ctx,EXCP_CALL_PALP + ((palcode &0x3F ) <<6 ),0 );
@@ -1748,7 +1763,7 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)if (!ctx->pal_mode) goto invalid_opc;if (ra !=31 ) { -TCGv tmp =tcg_const_i32 (insn &0xFF ); +TCGv tmp =tcg_const_i32 (get_mxcr_iprn (ctx, insn));gen_helper_mfpr (cpu_ir[ra], tmp, cpu_ir[ra]);tcg_temp_free (tmp); }
@@ -2063,9 +2078,9 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)if (!ctx->pal_mode) goto invalid_opc;else { -TCGv tmp1 =tcg_const_i32 (insn &0xFF ); -if (ra !=31 ) -gen_helper_mtpr (tmp1, cpu_ir[ra]); +TCGv tmp1 =tcg_const_i32 (get_mxcr_iprn (ctx, insn)); +if (rb !=31 ) +gen_helper_mtpr (tmp1, cpu_ir[rb]);else {TCGv tmp2 =tcg_const_i64 (0 );gen_helper_mtpr (tmp1, tmp2);
@@ -2088,8 +2103,8 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)gen_helper_hw_rei (); }else {TCGv tmp; - -if (ra !=31 ) { + +if (rb !=31 ) { tmp =tcg_temp_new ();tcg_gen_addi_i64 (tmp, cpu_ir[rb], (((int64_t )insn <<51 ) >>51 )); }else
@@ -2097,7 +2112,7 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)gen_helper_hw_ret (tmp); tcg_temp_free(tmp); } - ret =2 ; + ret =3 ;break ;#endif case 0x1F :
@@ -2353,6 +2368,7 @@ static always_inline void gen_intermediate_code_internal (CPUState *env, gen_opc_end = gen_opc_buf +OPC_MAX_SIZE ; ctx.pc = pc_start; ctx.amask = env->amask; + ctx.implver = env->implver;#if defined (CONFIG_USER_ONLY ) ctx.mem_idx =0 ;#else
Signature · 1 line
1.6.2
PATCH 7/24 Increase Alpha physical address size to 44 bits.
In reply to Tristan GingoldRemove unused target virt addr.
--- exec.c | 3 +-- 1 files changed, 1 insertions(+), 2 deletions(-)
exec.c +1 -2
@@ -68,8 +68,7 @@#elif defined(TARGET_SPARC )#define TARGET_PHYS_ADDR_SPACE_BITS 36#elif defined(TARGET_ALPHA ) -#define TARGET_PHYS_ADDR_SPACE_BITS 42 -#define TARGET_VIRT_ADDR_SPACE_BITS 42 +#define TARGET_PHYS_ADDR_SPACE_BITS 44#elif defined(TARGET_PPC64 )#define TARGET_PHYS_ADDR_SPACE_BITS 42#elif defined(TARGET_X86_64 ) && !defined(USE_KQEMU )
Signature · 1 line
1.6.2
PATCH 3/24 Fix bug: palcode is at least 6 bits.
In reply to Tristan Gingold--- target-alpha/translate.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
target-alpha/translate.c +1 -1
@@ -692,7 +692,7 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)if (ctx->mem_idx &1 ) goto invalid_opc;else -gen_excp (ctx,EXCP_CALL_PALP + ((palcode &0x1F ) <<6 ),0 ); +gen_excp (ctx,EXCP_CALL_PALP + ((palcode &0x3F ) <<6 ),0 );#endif }else {/* Invalid PAL call */
Signature · 1 line
1.6.2
PATCH 4/24 Fix bug: do not mask address LSBs for ldwu.
--- target-alpha/translate.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
target-alpha/translate.c +1 -1
@@ -753,7 +753,7 @@ static always_inline int translate_one (DisasContext *ctx, uint32_t insn)/* LDWU */ if (!(ctx->amask &AMASK_BWX )) goto invalid_opc; -gen_load_mem (ctx, &tcg_gen_qemu_ld16u, ra, rb, disp16,0 ,1 ); +gen_load_mem (ctx, &tcg_gen_qemu_ld16u, ra, rb, disp16,0 ,0 );break ;case 0x0D :/* STW */
Signature · 1 line
1.6.2
PATCH 24/24 Add full emulation for 21264.
In reply to Tristan GingoldThis is still work in progress but complete enough to run the firmware.
Remove old and incomplete code for pal virtualization.
--- cpu-exec.c | 1 + hw/alpha_palcode.c | 37 ++- target-alpha/cpu.h | 245 +++++++++----- target-alpha/helper.c | 844 +++++++++++++++++++++++++++++----------------- target-alpha/op_helper.c | 125 +++++--- target-alpha/translate.c | 54 ++-- 6 files changed, 827 insertions(+), 479 deletions(-)
cpu-exec.c +1 -0
@@ -486,6 +486,7 @@ int cpu_exec(CPUState *env1) }#elif defined(TARGET_ALPHA)if (interrupt_request &CPU_INTERRUPT_HARD ) { + env->exception_index =EXCP_GEN_INTERRUPT ;do_interrupt (env); next_tb =0 ; }
hw/alpha_palcode.c +33 -4
@@ -22,10 +22,39 @@#include <stdlib.h> #include <stdio.h> -#include "qemu.h" #include "cpu.h" #include "exec-all.h" +typedef struct pal_handler_t pal_handler_t ; +struct pal_handler_t { +/* Reset */ +void (*reset)(CPUAlphaState *env); +/* Uncorrectable hardware error */ +void (*machine_check)(CPUAlphaState *env); +/* Arithmetic exception */ +void (*arithmetic)(CPUAlphaState *env); +/* Interrupt / correctable hardware error */ +void (*interrupt)(CPUAlphaState *env); +/* Data fault */ +void (*dfault)(CPUAlphaState *env); +/* DTB miss pal */ +void (*dtb_miss_pal)(CPUAlphaState *env); +/* DTB miss native */ +void (*dtb_miss_native)(CPUAlphaState *env); +/* Unaligned access */ +void (*unalign)(CPUAlphaState *env); +/* ITB miss */ +void (*itb_miss)(CPUAlphaState *env); +/* Instruction stream access violation */ +void (*itb_acv)(CPUAlphaState *env); +/* Reserved or privileged opcode */ +void (*opcdec)(CPUAlphaState *env); +/* Floating point exception */ +void (*fen)(CPUAlphaState *env); +/* Call pal instruction */ +void (*call_pal)(CPUAlphaState *env,uint32_t palcode); +}; +/* Shared handlers */ static void pal_reset (CPUState *env);/* Console handlers */
@@ -88,7 +117,7 @@ static void do_swappal (CPUState *env, uint64_t palid) case 0 ... 2: pal_handler = &pal_handlers[palid]; env->pal_handler = pal_handler; - env->ipr[IPR_PAL_BASE ] =-1ULL ; + env->pal_base =-1ULL ; (*pal_handler->reset)(env);break ; case 3 ... 255:
@@ -98,8 +127,8 @@ static void do_swappal (CPUState *env, uint64_t palid)default :/* We were given the entry point address */ env->pal_handler =NULL ; - env->ipr[IPR_PAL_BASE ] = palid; - env->pc = env->ipr[IPR_PAL_BASE ]; + env->pal_base = palid; + env->pc = env->pal_base;cpu_loop_exit (); } }
target-alpha/cpu.h +152 -93
311 lines not on this page · raw message
target-alpha/helper.c +533 -311
906 lines not on this page · raw message
target-alpha/op_helper.c +85 -40
233 lines not on this page · raw message
target-alpha/translate.c +23 -31
100 lines not on this page · raw message
Signature · 1 line
1.6.2
PATCH 9/24 Split cpu_mmu_index into cpu_mmu_index_data and cpu_mmu_index_code.
In reply to Tristan GingoldThis is required by alpha system emulation as PAL mode disable instruction mmu but not data mmu.
This might also be required for other cpus that have a split I/D mmu enable.
--- exec-all.h | 2 +- softmmu_header.h | 4 ++-- target-alpha/cpu.h | 13 +++++++++++-- target-alpha/op_helper.c | 4 ++-- target-arm/cpu.h | 3 ++- target-cris/cpu.h | 3 ++- target-cris/translate.c | 6 +++--- target-i386/cpu.h | 3 ++- target-m68k/cpu.h | 3 ++- target-mips/cpu.h | 3 ++- target-ppc/cpu.h | 3 ++- target-sh4/cpu.h | 3 ++- target-sparc/cpu.h | 3 ++- target-sparc/translate.c | 2 +- 14 files changed, 36 insertions(+), 19 deletions(-)
exec-all.h +1 -1
@@ -318,7 +318,7 @@ static inline target_ulong get_phys_addr_code(CPUState *env1, target_ulong addr)int mmu_idx, page_index, pd; page_index = (addr >>TARGET_PAGE_BITS ) & (CPU_TLB_SIZE -1 ); - mmu_idx =cpu_mmu_index (env1); + mmu_idx =cpu_mmu_index_code (env1);if (unlikely (env1->tlb_table[mmu_idx][page_index].addr_code != (addr &TARGET_PAGE_MASK ))) {ldub_code (addr);
softmmu_header.h +2 -2
@@ -46,12 +46,12 @@#elif ACCESS_TYPE == (NB_MMU_MODES ) -#define CPU_MMU_INDEX (cpu_mmu_index(env)) +#define CPU_MMU_INDEX (cpu_mmu_index_data(env))#define MMUSUFFIX _mmu#elif ACCESS_TYPE == (NB_MMU_MODES +1 ) -#define CPU_MMU_INDEX (cpu_mmu_index(env)) +#define CPU_MMU_INDEX (cpu_mmu_index_code(env))#define MMUSUFFIX _cmmu#else
target-alpha/cpu.h +11 -2
@@ -297,16 +297,25 @@ struct CPUAlphaState {#define cpu_exec cpu_alpha_exec#define cpu_gen_code cpu_alpha_gen_code#define cpu_signal_handler cpu_alpha_signal_handler +#define cpu_list alpha_cpu_list/* MMU modes definitions */ #define MMU_MODE0_SUFFIX _kernel#define MMU_MODE1_SUFFIX _executive#define MMU_MODE2_SUFFIX _supervisor#define MMU_MODE3_SUFFIX _user +#define MMU_MODE4_SUFFIX _pal +#define MMU_KERNEL_IDX 0#define MMU_USER_IDX 3 -static inline int cpu_mmu_index (CPUState *env) +#define MMU_PAL_IDX 4 +static inline int cpu_mmu_index_data (CPUState *env) { -return (env->ps >>3 ) &3 ; +return env->mmu_data_index; +} + +static inline int cpu_mmu_index_code (CPUState *env) +{ +return env->mmu_code_index; }#if defined(CONFIG_USER_ONLY )
target-alpha/op_helper.c +2 -2
@@ -1049,7 +1049,7 @@ uint64_t helper_ld_virt_to_phys (uint64_t virtaddr)int index, mmu_idx;void *retaddr; - mmu_idx =cpu_mmu_index (env); + mmu_idx =cpu_mmu_index_data (env); index = (virtaddr >>TARGET_PAGE_BITS ) & (CPU_TLB_SIZE -1 ); redo: tlb_addr = env->tlb_table[mmu_idx][index].addr_read;
@@ -1071,7 +1071,7 @@ uint64_t helper_st_virt_to_phys (uint64_t virtaddr)int index, mmu_idx;void *retaddr; - mmu_idx =cpu_mmu_index (env); + mmu_idx =cpu_mmu_index_data (env); index = (virtaddr >>TARGET_PAGE_BITS ) & (CPU_TLB_SIZE -1 ); redo: tlb_addr = env->tlb_table[mmu_idx][index].addr_write;
target-arm/cpu.h +2 -1
@@ -412,7 +412,8 @@ void cpu_arm_set_cp_io(CPUARMState *env, int cpnum,#define MMU_MODE0_SUFFIX _kernel#define MMU_MODE1_SUFFIX _user#define MMU_USER_IDX 1 -static inline int cpu_mmu_index (CPUState *env) +#define cpu_mmu_index_data cpu_mmu_index_code +static inline int cpu_mmu_index_code (CPUState *env) {return (env->uncached_cpsr &CPSR_M ) ==ARM_CPU_MODE_USR ?1 :0 ; }
target-cris/cpu.h +2 -1
@@ -212,7 +212,8 @@ enum {#define MMU_MODE0_SUFFIX _kernel#define MMU_MODE1_SUFFIX _user#define MMU_USER_IDX 1 -static inline int cpu_mmu_index (CPUState *env) +#define cpu_mmu_index_data cpu_mmu_index_code +static inline int cpu_mmu_index_code (CPUState *env) {return !!(env->pregs[PR_CCS ] &U_FLAG ); }
target-cris/translate.c +3 -3
@@ -1104,7 +1104,7 @@ static inline void cris_prepare_jmp (DisasContext *dc, unsigned int type)static void gen_load64 (DisasContext *dc,TCGv_i64 dst,TCGv addr) { -int mem_index =cpu_mmu_index (dc->env); +int mem_index =cpu_mmu_index_data (dc->env);/* If we get a fault on a delayslot we must keep the jmp state in the cpu-state to be able to re-execute the jmp. */
@@ -1117,7 +1117,7 @@ static void gen_load64(DisasContext *dc, TCGv_i64 dst, TCGv addr)static void gen_load (DisasContext *dc,TCGv dst,TCGv addr,unsigned int size,int sign) { -int mem_index =cpu_mmu_index (dc->env); +int mem_index =cpu_mmu_index_data (dc->env);/* If we get a fault on a delayslot we must keep the jmp state in the cpu-state to be able to re-execute the jmp. */
@@ -1147,7 +1147,7 @@ static void gen_load(DisasContext *dc, TCGv dst, TCGv addr,static void gen_store (DisasContext *dc,TCGv addr,TCGv val,unsigned int size) { -int mem_index =cpu_mmu_index (dc->env); +int mem_index =cpu_mmu_index_data (dc->env);/* If we get a fault on a delayslot we must keep the jmp state in the cpu-state to be able to re-execute the jmp. */
target-i386/cpu.h +2 -1
@@ -842,7 +842,8 @@ static inline int cpu_get_time_fast(void)#define MMU_MODE0_SUFFIX _kernel#define MMU_MODE1_SUFFIX _user#define MMU_USER_IDX 1 -static inline int cpu_mmu_index (CPUState *env) +#define cpu_mmu_index_data cpu_mmu_index_code +static inline int cpu_mmu_index_code (CPUState *env) {return (env->hflags &HF_CPL_MASK ) ==3 ?1 :0 ; }
target-m68k/cpu.h +2 -1
@@ -218,7 +218,8 @@ void register_m68k_insns (CPUM68KState *env);#define MMU_MODE0_SUFFIX _kernel#define MMU_MODE1_SUFFIX _user#define MMU_USER_IDX 1 -static inline int cpu_mmu_index (CPUState *env) +#define cpu_mmu_index_data cpu_mmu_index_code +static inline int cpu_mmu_index_code (CPUState *env) {return (env->sr &SR_S ) ==0 ?1 :0 ; }
target-mips/cpu.h +2 -1
@@ -489,7 +489,8 @@ void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec,#define MMU_MODE1_SUFFIX _super#define MMU_MODE2_SUFFIX _user#define MMU_USER_IDX 2 -static inline int cpu_mmu_index (CPUState *env) +#define cpu_mmu_index_data cpu_mmu_index_code +static inline int cpu_mmu_index_code (CPUState *env) {return env->hflags &MIPS_HFLAG_KSU ; }
target-ppc/cpu.h +2 -1
@@ -809,7 +809,8 @@ int ppc_dcr_write (ppc_dcr_t *dcr_env, int dcrn, target_ulong val);#define MMU_MODE1_SUFFIX _kernel#define MMU_MODE2_SUFFIX _hypv#define MMU_USER_IDX 0 -static inline int cpu_mmu_index (CPUState *env) +#define cpu_mmu_index_data cpu_mmu_index_code +static inline int cpu_mmu_index_code (CPUState *env) {return env->mmu_idx; }
target-sh4/cpu.h +2 -1
@@ -181,7 +181,8 @@ void cpu_load_tlb(CPUSH4State * env);#define MMU_MODE0_SUFFIX _kernel#define MMU_MODE1_SUFFIX _user#define MMU_USER_IDX 1 -static inline int cpu_mmu_index (CPUState *env) +#define cpu_mmu_index_data cpu_mmu_index_code +static inline int cpu_mmu_index_code (CPUState *env) {return (env->sr &SR_MD ) ==0 ?1 :0 ; }
target-sparc/cpu.h +2 -1
@@ -456,7 +456,8 @@ int cpu_sparc_signal_handler(int host_signum, void *pinfo, void *puc);#define MMU_KERNEL_IDX 1#define MMU_HYPV_IDX 2 -static inline int cpu_mmu_index (CPUState *env1) +#define cpu_mmu_index_data cpu_mmu_index_code +static inline int cpu_mmu_index_code (CPUState *env1) {#if defined(CONFIG_USER_ONLY )return MMU_USER_IDX ;
target-sparc/translate.c +1 -1
@@ -4769,7 +4769,7 @@ static inline void gen_intermediate_code_internal(TranslationBlock * tb, dc->pc = pc_start; last_pc = dc->pc; dc->npc = (target_ulong ) tb->cs_base; - dc->mem_idx =cpu_mmu_index (env); + dc->mem_idx =cpu_mmu_index_code (env); dc->def = env->def;if ((dc->def->features &CPU_FEATURE_FLOAT )) dc->fpu_enabled =cpu_fpu_enabled (env);
Signature · 1 line
1.6.2
PATCH 20/24 Add alpha_cpu_list.
In reply to Tristan GingoldAdd alpha_cpu_list and use cpu_model to select the model in cpu_alpha_init. Set implver and amask from the model.
--- target-alpha/cpu.h | 1 + target-alpha/translate.c | 40 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-)
target-alpha/cpu.h +1 -0
@@ -436,6 +436,7 @@ enum {CPUAlphaState *cpu_alpha_init (const char *cpu_model);int cpu_alpha_exec (CPUAlphaState *s); +void alpha_cpu_list (FILE *f,int (*cpu_fprintf)(FILE *f,const char *fmt, ...));/* you can call this signal handler from your SIGBUS and SIGSEGV signal handlers to inform the virtual CPU of exceptions. non zero is returned if the signal was handled by the virtual CPU. */
target-alpha/translate.c +38 -2
@@ -2460,17 +2460,53 @@ void gen_intermediate_code_pc (CPUState *env, struct TranslationBlock *tb)gen_intermediate_code_internal (env, tb,1 ); } +struct alpha_def { +const char *name; +uint32_t implver; +uint32_t amask; +}; + +static const struct alpha_def alpha_defs[] = { +#if 0 + {"21064" , IMPLVER_2106x,0 }, + {"21164" ,IMPLVER_21164 ,0 }, +#endif + {"21264" ,IMPLVER_21264 , (AMASK_PREFETCH |AMASK_TRAP |AMASK_BWX + |AMASK_FIX ) }, +}; + +void alpha_cpu_list (FILE *f,int (*cpu_fprintf)(FILE *f,const char *fmt, ...)) +{ +int i; + +for (i =0 ; i <ARRAY_SIZE (alpha_defs); i++) + (*cpu_fprintf)(f,"%s\n" , alpha_defs[i].name); +} +CPUAlphaState *cpu_alpha_init (const char *cpu_model) {CPUAlphaState *env;uint64_t hwpcb; +const struct alpha_def *cpu = alpha_defs; + +if (cpu_model !=NULL ) { +int i; +for (i =0 ; i <ARRAY_SIZE (alpha_defs); i++) +if (strcmp (alpha_defs[i].name, cpu_model) ==0 ) { + cpu = &alpha_defs[i]; +break ; + } +if (cpu ==NULL ) +return NULL ; + } env =qemu_mallocz (sizeof (CPUAlphaState));cpu_exec_init (env);alpha_translate_init ();tlb_flush (env,1 ); -/* XXX: should not be hardcoded */ - env->implver = IMPLVER_2106x; + + env->implver = cpu->implver; + env->amask = cpu->amask; env->ps =0x1F00 ;#if defined (CONFIG_USER_ONLY ) env->ps |=1 <<3 ;
Signature · 1 line
1.6.2
PATCH 12/24 Add 21272 chipset (memory and pci controller for alpha)
In reply to Tristan Gingold--- hw/21272.c | 832 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/pci.h | 8 + 2 files changed, 840 insertions(+), 0 deletions(-) create mode 100644 hw/21272.c
hw/21272.c new file +832 -0
@@ -0,0 +1,832 @@ +/* +* Qemu 21272 (Tsunami/Typhoon) chipset emulation. +* +* Copyright (c) 2009 AdaCore +* +* Written by Tristan Gingold. +* +* This work is licensed under the GNU GPL license version 2 or later. +*/ +#include "hw.h" +#include "devices.h" +#include "pci.h" + +//#define DEBUG_CCHIP +//#define DEBUG_PCHIP +//#define DEBUG_DCHIP +//#define DEBUG_PCICFG + +typedef struct pchip_t pchip_t ; +struct pchip_t { +/* IntAck handler. */ +int (*iack_handler)(void *); +void *iack_handler_param; + +PCIBus *pci; + +/* Pchip id. */ +int num; + +/* Used to reconstruct 64bits accesses. Low long word first. */ +uint32_t data; + +uint32_t wsba[3 ]; +uint64_t wsba3; +uint32_t wsm[3 ]; +uint32_t wsm3; +uint64_t tba[3 ]; +uint64_t tba3; +uint32_t perrmask; +/* pctl */ +unsigned char ptevrfy; +unsigned char mwin; +unsigned char hole; +unsigned char chaindis; +}; + +struct typhoon_t { +qemu_irq *irqs; +qemu_irq *intim_irq; +CPUState *cpu[4 ]; + +/* Used to reconstruct 64bits accesses. Low long word first. */ +uint32_t data; + +unsigned char misc_rev; +unsigned char misc_abw; +unsigned char misc_abt; + +int b_irq[4 ]; + +uint64_t dim[4 ]; +uint64_t dir[4 ]; +uint64_t drir; +uint64_t aar[4 ]; + +/* dchip */ +uint64_t csc; +uint64_t str; + +pchip_t pchip[2 ]; +}; + +static void illegal_write (void *opaque, +target_phys_addr_t addr,uint32_t value) +{ +qemu_log ("illegal_write at addr=" TARGET_FMT_lx"\n" , addr); +} + +static uint32_t illegal_read (void *opaque,target_phys_addr_t addr) +{ +qemu_log ("illegal_read at addr=" TARGET_FMT_lx"\n" , addr); +return 0 ; +} + +static uint32_t typhoon_cchip_readl (void *opaque,target_phys_addr_t addr) +{ +typhoon_t *s = opaque; +uint64_t val; +int reg; + +/* Handle 64-bits accesses; */ +if (addr &0x04 ) +return s->data; + + reg = addr >>6 ; +switch (reg) { +case 0x00 :/* CSC */ + val = s->csc; +break ; +case 0x02 :/* MISC */ + val = ((uint64_t )s->misc_rev <<32 ) + | ((uint64_t )s->misc_abt <<20 ) + | ((uint64_t )s->misc_abw <<16 ) + | ((s->b_irq[0 ] &4 ) <<2 ) + | ((s->b_irq[1 ] &4 ) <<3 ) + | ((s->b_irq[2 ] &4 ) <<4 ) + | ((s->b_irq[3 ] &4 ) <<5 ) + | ((s->b_irq[0 ] &8 ) <<5 ) + | ((s->b_irq[1 ] &8 ) <<6 ) + | ((s->b_irq[2 ] &8 ) <<7 ) + | ((s->b_irq[3 ] &8 ) <<8 ); +break ; +case 0x04 : +case 0x05 : +case 0x06 : +case 0x07 : + val = s->aar[reg -4 ]; +break ; +case 0x08 : +case 0x09 : +case 0x18 : +case 0x19 : + val = s->dim[(reg &1 ) | ((reg &0x10 ) >>3 )]; +break ; +case 0x0a : +case 0x0b : +case 0x1a : +case 0x1b : + val = s->dir[(reg &1 ) | ((reg &0x10 ) >>3 )]; +break ; +default : +qemu_log ("21272: unhandled cchip read reg=%x\n" , reg); + val =0 ; +break ; + } + +#ifdef DEBUG_CCHIP +fprintf (stderr,"typhoon cchip read reg=%x, val=%016" PRIx64"\n" , reg, val); +#endif + s->data = val >>32 ; +return (uint32_t )val; +} + +static void typhoon_cchip_writel (void *opaque, +target_phys_addr_t addr,uint32_t value) +{ +typhoon_t *s = opaque; +int reg; +uint64_t val; + +#if 0 +fprintf (stderr,"typhoon write addr=" TARGET_FMT_lx", val=%08x\n" , + addr, value); +#endif + +/* Handle 64-bits accesses. LSB first. */ +if (!(addr &0x04 )) { + s->data = value; +return ; + } +else + val = ((uint64_t )value <<32 ) | s->data; + + reg = addr >>6 ; + +#ifdef DEBUG_CCHIP +fprintf (stderr,"typhoon cchip write reg=%x, val=%016" PRIx64"\n" , reg, val); +#endif + +switch (reg) { +case 0x00 :/* CSC */ + s->csc = (s->csc &0xffffU ) | (val &0x0777777fff3f0000ULL ); +break ; +case 0x02 :/* MISC */ +if (val & (1 <<24 )) { +/* ACL: arbitration clear. */ + s->misc_abt =0 ; + s->misc_abw =0 ; + } +if (val & (0xf <<12 )) { +int i; +for (i =0 ; i <4 && s->cpu[i]; i++) +if ((val & (0x1000 << i))) { + s->b_irq[i] &= ~(1 <<3 ); +cpu_alpha_update_irq (s->cpu[i], s->b_irq[i]); + } + } +if ((val & (0xf <<16 )) && s->misc_abw ==0 ) { +/* ABW: arbitration won. */ + s->misc_abw = (val >>16 ) &0x0f ; + } +if ((val & (0x0f <<20 )) && s->misc_abt ==0 ) { +/* ABT: arbitration try. */ + s->misc_abt = (val >>20 ) &0x0f ; + } +if (val & (1ULL <<28 )) { +/* NXM - not handled. */ + } +if (val & (0x0fULL <<40 )) { +/* DEVUP - not handled. */ + } +if (val & (0x0f <<4 )) { +/* ITINTR */ +int i; +for (i =0 ; i <4 && s->cpu[i]; i++) +if ((val & (0x10 << i))) { + s->b_irq[i] &= ~(1 <<2 ); +cpu_alpha_update_irq (s->cpu[i], s->b_irq[i]); + } + } +if (val & ~((0xfULL <<40 ) | (0xffULL <<32 ) | (1 <<28 ) | (1ULL <<24 ) + | (0x0f <<12 ) | (0xf <<16 ) + | (0x0f <<20 ) | (0x0f <<4 ))) { +qemu_log ("21272: unhandled value %016" PRIx64" written in MISC\n" , + val); + } +break ; +case 0x08 : +case 0x09 : +case 0x18 : +case 0x19 : + s->dim[(reg &1 ) | ((reg &0x10 ) >>3 )] = val; +break ; +default : +qemu_log ("21272: unhandled cchip write reg %x (%016" PRIx64")\n" , + reg, val); +break ; + } +} + +static CPUReadMemoryFunc *typhoon_cchip_read[] = { + &illegal_read, + &illegal_read, + &typhoon_cchip_readl, +}; + +static CPUWriteMemoryFunc *typhoon_cchip_write[] = { + &illegal_write, + &illegal_write, + &typhoon_cchip_writel, +}; + +static uint32_t typhoon_dchip_readl (void *opaque,target_phys_addr_t addr) +{ +typhoon_t *s = opaque; +uint64_t val; +int reg; + +/* Handle 64-bits accesses; */ +if (addr &0x04 ) +return s->data; + + reg = addr >>6 ; +switch (reg) { +case 0x20 :/* DSC */ + val = (s->csc &0x3f ) | ((s->csc >> (14 -6 )) &0x40 ); + val = (val <<8 ) | val; + val = (val <<16 ) | val; + val = (val <<32 ) | val; +break ; +case 0x21 :/* STR */ + val = s->str; +break ; +case 0x22 :/* DREV */ + val =0x02 *0x0101010101010101ULL ; +break ; +case 0x23 :/* DSC2 */ + val =0 ; +default : +qemu_log ("21272: unhandled dchip read reg=%x\n" , reg); + val =0 ; +break ; + } + +#ifdef DEBUG_DCHIP +fprintf (stderr,"typhoon dchip read reg=%x, val=%016" PRIx64"\n" , reg, val); +#endif + s->data = val >>32 ; +return (uint32_t )val; +} + +static void typhoon_dchip_writel (void *opaque, +target_phys_addr_t addr,uint32_t value) +{ +typhoon_t *s = opaque; +int reg; +uint64_t val; + +#if 0 +fprintf (stderr,"typhoon write addr=" TARGET_FMT_lx", val=%08x\n" , + addr, value); +#endif + +/* Handle 64-bits accesses. LSB first. */ +if (!(addr &0x04 )) { + s->data = value; +return ; + } +else + val = ((uint64_t )value <<32 ) | s->data; + + reg = addr >>6 ; + +#ifdef DEBUG_DCHIP +fprintf (stderr,"typhoon dchip write reg=%x, val=%016" PRIx64"\n" , reg, val); +#endif + +switch (reg) { +default : +qemu_log ("21272: unhandled dchip write reg %x (%016" PRIx64")\n" , + reg, val); +break ; + } +} + +static CPUReadMemoryFunc *typhoon_dchip_read[] = { + &illegal_read, + &illegal_read, + &typhoon_dchip_readl, +}; + +static CPUWriteMemoryFunc *typhoon_dchip_write[] = { + &illegal_write, + &illegal_write, + &typhoon_dchip_writel, +}; + +static uint32_t typhoon_pchip_readl (void *opaque,target_phys_addr_t addr) +{ +pchip_t *s = opaque; +uint64_t val; +int reg; + +/* Handle 64-bits accesses; */ +if (addr &0x04 ) +return s->data; + + reg = addr >>6 ; +switch (reg) { +case 0x00 : +case 0x01 : +case 0x02 : + val = s->wsba[reg]; +break ; +case 0x03 : + val = s->wsba3; +break ; +case 0x04 : +case 0x05 : +case 0x06 : + val = s->wsm[reg -4 ]; +break ; +case 0x07 : + val = s->wsm3; +break ; +case 0x08 : +case 0x09 : +case 0x0a : + val = s->tba[reg -0x8 ]; +break ; +case 0x0b : + val = s->tba3; +break ; +case 0x0c :/* pctl */ + val = (((uint64_t )(s->num &3 )) <<46 ) + | (((uint64_t )s->ptevrfy) <<44 ) + | (1ULL <<40 )/* PCLKX */ + | (s->mwin <<6 ) + | (s->hole <<5 ) + | (s->chaindis <<3 ); +break ; +case 0x0f :/* PERROR */ + val =0 ;/* Not emulated. */ +break ; +case 0x10 :/* PERRMASK */ + val = s->perrmask; +break ; +case 0x20 :/* WO. */ + val =0 ; +break ; +default : +qemu_log ("21272: unhandled pchip read reg=%x\n" , reg); + val =0 ; +break ; + } + +#ifdef DEBUG_PCHIP +fprintf (stderr,"typhoon pchip%d read reg=%x, val=%016" PRIx64"\n" , + s->num, reg, val); +#endif + s->data = val >>32 ; +return (uint32_t )val; +} + +static void typhoon_pchip_writel (void *opaque, +target_phys_addr_t addr,uint32_t value) +{ +pchip_t *s = opaque; +int reg; +uint64_t val; + +/* Handle 64-bits accesses. LSB first. */ +if (!(addr &0x04 )) { + s->data = value; +return ; + } +else + val = ((uint64_t )value <<32 ) | s->data; + + reg = addr >>6 ; + +#ifdef DEBUG_PCHIP +fprintf (stderr,"typhoon pchip%d write reg=%x, val=%016" PRIx64"\n" , + s->num, reg, val); +#endif + +switch (reg) { +case 0 : +case 1 : +case 2 : + s->wsba[reg] = val &0xfff00003 ; +if (val &1 ) +qemu_log ("21272: enabling wsba%d!\n" , reg);/* Not yet emulated */ +break ; +case 3 : + s->wsba3 = val &0xffffff80fff00003ULL ; +if (val &1 ) +qemu_log ("21272: enabling wsba3!\n" );/* Not yet emulated */ +break ; +case 0x4 : +case 0x5 : +case 0x6 : + s->wsm[reg -4 ] = val &0xfff00000 ; +break ; +case 0x7 : + s->wsm3 = val &0xfff00000 ; +break ; +case 0x8 : +case 0x9 : +case 0xa : + s->tba[reg -0x8 ] = val &0x7fffffc00 ; +break ; +case 0xb : + s->tba3 = val &0x7fffffc00 ; +break ; +case 0x0c :/* pctl */ + s->ptevrfy = (val >>44 ) &1 ; + s->mwin = (val >>6 ) &1 ; + s->hole = (val >>5 ) &1 ; + s->chaindis = (val >>3 ) &1 ; +if (val & ((1ULL <<43 ) | (1ULL <<42 ) | (3ULL <<36 ) | (0x0fULL <<32 ) + | (0x0f <<20 ) | (1 <<19 ) | (0x3f <<8 ) + | (1 <<2 ) | (1 <<1 ))) +qemu_log ("21272: pchip pctl: unhandled value %016" PRIx64"\n" , + val); +break ; +case 0x0f :/* PERROR */ +break ;/* Not emulated. */ +case 0x10 :/* PERRMASK */ + s->perrmask = val &0xfff ; +break ; +case 0x20 :/* SPRST */ +/* Software pci-reset. FIXME: disable bus? */ +break ; +default : +qemu_log ("21272: unhandled pchip write reg=%x (%016" PRIx64")\n" , + reg, val); +break ; + } +} + +static CPUReadMemoryFunc *typhoon_pchip_read[] = { + &illegal_read, + &illegal_read, + &typhoon_pchip_readl, +}; + +static CPUWriteMemoryFunc *typhoon_pchip_write[] = { + &illegal_write, + &illegal_write, + &typhoon_pchip_writel, +}; + + +static void pchip_pci_io_writeb (void *opaque,target_phys_addr_t addr, +uint32_t value) +{ +cpu_outb (NULL , addr, value); +} + +static uint32_t pchip_pci_io_readb (void *opaque,target_phys_addr_t addr) +{ +return cpu_inb (NULL , addr); +} + +static void pchip_pci_io_writew (void *opaque,target_phys_addr_t addr, +uint32_t value) +{ +#ifdef TARGET_WORDS_BIGENDIAN + value =bswap16 (value); +#endif +cpu_outw (NULL , addr, value); +} + +static uint32_t pchip_pci_io_readw (void *opaque,target_phys_addr_t addr) +{ +uint32_t ret; + + ret =cpu_inw (NULL , addr); +#ifdef TARGET_WORDS_BIGENDIAN + ret =bswap16 (ret); +#endif +return ret; +} + +static void pchip_pci_io_writel (void *opaque,target_phys_addr_t addr, +uint32_t value) +{ +#ifdef TARGET_WORDS_BIGENDIAN + value =bswap32 (value); +#endif +cpu_outl (NULL , addr, value); +} + +static uint32_t pchip_pci_io_readl (void *opaque,target_phys_addr_t addr) +{ +uint32_t ret; + + ret =cpu_inl (NULL , addr); +#ifdef TARGET_WORDS_BIGENDIAN + ret =bswap32 (ret); +#endif +return ret; +} + +static CPUWriteMemoryFunc *pchip_pci_io_write[] = { + &pchip_pci_io_writeb, + &pchip_pci_io_writew, + &pchip_pci_io_writel, +}; + +static CPUReadMemoryFunc *pchip_pci_io_read[] = { + &pchip_pci_io_readb, + &pchip_pci_io_readw, + &pchip_pci_io_readl, +}; + +static void pchip_pci_cfg_writex (void *opaque,target_phys_addr_t addr, +uint32_t value,int sz) +{ +uint32_t a = addr &0xffffffU ; +pchip_t *s = opaque; + +#ifdef DEBUG_PCICFG +fprintf (stderr,"pci_cfg write: addr=%06x, sz=%d %u:%u:%02x, val=%08x\n" , + a, sz, + (a >>11 ) &0x1f , (a >>8 ) &0x7 , a &0xff , value); +#endif + +pci_data_write (s->pci, a, value,1 << sz); +} + +static void pchip_pci_cfg_writel (void *opaque,target_phys_addr_t addr, +uint32_t value) +{ +#ifdef TARGET_WORDS_BIGENDIAN + value =bswap32 (value); +#endif +pchip_pci_cfg_writex (opaque, addr, value,2 ); +} + +static void pchip_pci_cfg_writew (void *opaque,target_phys_addr_t addr, +uint32_t value) +{ +#ifdef TARGET_WORDS_BIGENDIAN + value =bswap16 (value); +#endif +pchip_pci_cfg_writex (opaque, addr, value,1 ); +} + +static void pchip_pci_cfg_writeb (void *opaque,target_phys_addr_t addr, +uint32_t value) +{ +pchip_pci_cfg_writex (opaque, addr, value,0 ); +} + +static uint32_t pchip_pci_cfg_readx (void *opaque,target_phys_addr_t addr, +int sz) +{ +uint32_t a = addr &0xffffffU ; +pchip_t *s = opaque; +uint32_t val; + + val =pci_data_read (s->pci, a,1 << sz); + +#ifdef DEBUG_PCICFG +fprintf (stderr,"pci_cfg read: addr=%06x, sz=%d %u:%u:%02x, val=%08x\n" , + a, sz, + (a >>11 ) &0x1f , (a >>8 ) &0x7 , a &0xff , + val); +#endif + +return val; +} + +static uint32_t pchip_pci_cfg_readb (void *opaque,target_phys_addr_t addr) +{ +return pchip_pci_cfg_readx (opaque, addr,0 ); +} + +static uint32_t pchip_pci_cfg_readw (void *opaque,target_phys_addr_t addr) +{ +return pchip_pci_cfg_readx (opaque, addr,1 ); +} + +static uint32_t pchip_pci_cfg_readl (void *opaque,target_phys_addr_t addr) +{ +return pchip_pci_cfg_readx (opaque, addr,2 ); +} + +static CPUWriteMemoryFunc *pchip_pci_cfg_write[] = { + &pchip_pci_cfg_writeb, + &pchip_pci_cfg_writew, + &pchip_pci_cfg_writel, +}; + +static CPUReadMemoryFunc *pchip_pci_cfg_read[] = { + &pchip_pci_cfg_readb, + &pchip_pci_cfg_readw, + &pchip_pci_cfg_readl, +}; + +static void pchip_pci_iack_writex (void *opaque, +target_phys_addr_t addr,uint32_t value) +{ +qemu_log ("21272: pci iack addr=%08x, val=%08x\n" , (uint32_t )addr, value); +} + +static uint32_t pchip_pci_iack_readx (void *opaque,target_phys_addr_t addr) +{ +pchip_t *s = opaque; +uint32_t res; + +/* Ideally we should have a PCIBus interface. */ + res = (*s->iack_handler)(s->iack_handler_param); +//fprintf(stderr, "21272 iack: addr=%016"PRIx64", res=%d\n", addr, res); +return res; +} + +static CPUWriteMemoryFunc *pchip_pci_iack_write[] = { + &pchip_pci_iack_writex, + &pchip_pci_iack_writex, + &pchip_pci_iack_writex, +}; + +static CPUReadMemoryFunc *pchip_pci_iack_read[] = { + &pchip_pci_iack_readx, + &pchip_pci_iack_readx, + &pchip_pci_iack_readx, +}; + +static void typhoon_reset (void *opaque) +{ +typhoon_t *s = opaque; + + s->misc_rev =8 ; + s->misc_abw =0 ; +} + +static void cchip_set_irq (void *opaque,int irq,int level) +{ +typhoon_t *s = opaque; +uint64_t mask; +int i; + +#if 0 +qemu_log ("cchip_set_irq: irq=%d level=%d\n" , irq, level); +#endif + mask =1ULL << irq; +if (level) + s->drir |= mask; +else + s->drir &= ~mask; + +for (i =0 ; i <4 && s->cpu[i]; i++) { +int old = s->b_irq[i]; + s->dir[i] = s->drir & s->dim[i]; +if (s->dir[i] >>58 ) + s->b_irq[i] |= (1 <<0 ); +else + s->b_irq[i] &= ~(1 <<0 ); + +if (s->dir[i] <<8 ) + s->b_irq[i] |= (1 <<1 ); +else + s->b_irq[i] &= ~(1 <<1 ); + +#if 0 +qemu_log ("cchip_set_irq: cpu[%d]: drir=%016" PRIx64" dim=%016" PRIx64" " +" dir=%016" PRIx64" birq=%02x\n" , + i, s->drir, s->dim[i], s->dir[i], s->b_irq[i]); +#endif +if (s->b_irq[i] != old) +cpu_alpha_update_irq (s->cpu[i], s->b_irq[i]); + } +} + +static void intim_set_irq (void *opaque,int irq,int level) +{ +int i; +typhoon_t *s = opaque; +unsigned char old; + +#if 0 + { +static int cnt; + cnt++; +if ((cnt %1024 ) ==1023 ) +fprintf (stderr,"Clock!\n" ); + } +#endif + +if (0 && (s->b_irq[0 ] &0x04 )) +fprintf (stderr,"!!Interrupt missed\n" ); + +for (i =0 ; i <4 && s->cpu[i]; i++) { + old = s->b_irq[i]; +if (!(old & (1 <<2 ))) { + s->b_irq[i] |= (1 <<2 ); +cpu_alpha_update_irq (s->cpu[i], s->b_irq[i]); + } + } +} + + +static int typhoon_map_irq (PCIDevice *pci_dev,int irq_num) +{ +return irq_num; +} + +static void typhoon_set_irq (qemu_irq *pic,int irq_num,int level) +{ +/* Never called (yet). */ +fprintf (stderr,"typhoon_set_irq: irq_num=%d, level=%d\n" , irq_num, level); +exit (4 ); +} + +typhoon_t *typhoon_21272_init (uint64_t *arr,qemu_irq **irqs, +qemu_irq *intim_irq,void *cpu0) +{ +typhoon_t *s; +int cchip; +int dchip; +int pchip; +int pci_io; +int pci_cfg; +int pci_iack; +int i; + + s =qemu_mallocz (sizeof (typhoon_t)); + +/* Cchip registers. */ + cchip =cpu_register_io_memory (0 , typhoon_cchip_read, + typhoon_cchip_write, s); +cpu_register_physical_memory (0x801a0000000ULL ,0x0002000 , cchip); + +/* Dchip registers. */ + dchip =cpu_register_io_memory (0 , typhoon_dchip_read, + typhoon_dchip_write, s); +cpu_register_physical_memory (0x801b0000000ULL ,0x0002000 , dchip); + +/* Pchip0 registers. */ + pchip =cpu_register_io_memory (0 , typhoon_pchip_read, + typhoon_pchip_write, &s->pchip[0 ]); +cpu_register_physical_memory (0x80180000000ULL ,0x0002000 , pchip); + +/* Pchip1 registers. */ + pchip =cpu_register_io_memory (0 , typhoon_pchip_read, + typhoon_pchip_write, &s->pchip[1 ]); +cpu_register_physical_memory (0x80380000000ULL ,0x0002000 , pchip); + +/* Pchip0 PCI I/O */ + pci_io =cpu_register_io_memory (0 , pchip_pci_io_read, + pchip_pci_io_write, &s->pchip[0 ]); +cpu_register_physical_memory (0x801fc000000ULL ,0x0010000 , pci_io); + +/* Pchip0 PCI cfg */ + pci_cfg =cpu_register_io_memory (0 , pchip_pci_cfg_read, + pchip_pci_cfg_write, &s->pchip[0 ]); +cpu_register_physical_memory (0x801fe000000ULL ,0x0010000 , pci_cfg); + +/* Pchip0 PCI IntAck */ + pci_iack =cpu_register_io_memory (0 , pchip_pci_iack_read, + pchip_pci_iack_write, &s->pchip[0 ]); +cpu_register_physical_memory (0x801f8000000ULL ,0x002000 , pci_iack); + + s->pchip[0 ].pci =pci_register_bus (typhoon_set_irq, + typhoon_map_irq, +NULL ,0 ,64 ); + +typhoon_reset (s); +/* P1 chip present, 8 dchips, 2 memory buses. */ + s->csc = (1 <<14 ) | (3 <<0 ); + +/* Configure cchip array address. */ +for (i =0 ; i <4 ; i++) + s->aar[i] = arr[i]; + + s->cpu[0 ] = cpu0; + s->irqs =qemu_allocate_irqs (cchip_set_irq, s,64 ); + *irqs = s->irqs; + + s->intim_irq =qemu_allocate_irqs (intim_set_irq, s,1 ); + *intim_irq = s->intim_irq[0 ]; + +qemu_register_reset (&typhoon_reset, s); + +return s; +} + +void typhoon_set_iack_handler (typhoon_t *c,int num, +int (*handler)(void *),void *param) +{ + c->pchip[num].iack_handler = handler; + c->pchip[num].iack_handler_param = param; +} + +PCIBus *typhoon_get_pci_bus (typhoon_t *c,int num) +{ +return c->pchip[num].pci; +} +
hw/pci.h +8 -0
@@ -254,6 +254,14 @@ PCIBus *pci_apb_init(target_phys_addr_t special_base,PCIBus *sh_pci_register_bus (pci_set_irq_fn set_irq,pci_map_irq_fn map_irq,qemu_irq *pic,int devfn_min,int nirq); +/* 21272.c */ +typedef struct typhoon_t typhoon_t ; +typhoon_t *typhoon_21272_init (uint64_t *arr,qemu_irq **irqs, +qemu_irq *intim_irq,void *cpu0); +void typhoon_set_iack_handler (typhoon_t *c,int num, +int (*handler)(void *),void *param); +PCIBus *typhoon_get_pci_bus (typhoon_t *c,int num); +/* ali1543.c */ typedef struct ali1543_t ali1543_t ;ali1543_t *ali1543_init (PCIBus *bus,int devfn,qemu_irq irq);
Signature · 1 line
1.6.2
PATCH 21/24 Alpha: lower parent irq when irq is lowered.
In reply to Tristan Gingold--- hw/i8259.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
hw/i8259.c +1 -1
@@ -169,7 +169,7 @@ void pic_update_irq(PicState2 *s) }/* all targets should do this rather than acking the IRQ in the cpu */ -#if defined(TARGET_MIPS ) || defined(TARGET_PPC ) +#if defined(TARGET_MIPS ) || defined(TARGET_PPC ) || defined(TARGET_ALPHA ) else {qemu_irq_lower (s->parent_irq); }
Signature · 1 line
1.6.2
RE: [Qemu-devel] [PATCH 02/24] Fix cpu_physical_memory_rw whenoperating on IO blocks.
In reply to Tristan GingoldHello Tristan,
First thanks for promoting the Alpha.
Quoted 38 lines
-----Original Message-----
From:
[email protected] [mailto:[email protected] rg] On Behalf Of Tristan Gingold
Sent: Thursday, March 19, 2009 9:36 AM
To: [email protected]
Cc: Tristan Gingold
Subject: [Qemu-devel] [PATCH 02/24] Fixcpu_physical_memory_rwwhenoperating on IO blocks.In some cases, addr was destroyed and the next access was wrong. This occured while making 64bits IO accesses.
Signed-off-by Tristan Gingold <[email protected]>--- exec.c | 26 +++++++++++++++----------- 1 files changed, 15 insertions(+), 11 deletions(-)exec.c +0
-10@@ -354,16 +354,16 @@ static PhysPageDesc *phys_page_find_alloc(target_phys_addr_t index, int alloc) /* Level 2..n-1 */for (i = (L1_SHIFT /L2_BITS ) -1 ; i >0 ; i--) { - p = *lp; -if (!p) { -/* allocate if not found */ -if (!alloc) -return NULL ; - p =qemu_vmalloc (sizeof (void *) *L2_SIZE ); -memset (p,0 ,sizeof (void *) *L2_SIZE ); - *lp = p; - } - lp = p + ((index >> (i *L2_BITS )) & (L2_SIZE -1 ));
exec.c static PhysPageDesc · line 367
Quoted 10 lines
exec.c +10
-0+ p = *lp; +if (!p) { +/* allocate if not found */ +if (!alloc) +return NULL ; + p =qemu_vmalloc (sizeof (void *) *L2_SIZE ); +memset (p,0 ,sizeof (void *) *L2_SIZE ); + *lp = p; + } + lp = p + ((index >> (i *L2_BITS )) & (L2_SIZE -1 ));
White space only.
exec.c void · line 2992
Quoted 9 lines
exec.c +0
-0}#else p = (void **)l1_phys_map;exec.c +1
-0@@ -2988,6 +2988,7 @@ void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf, target_phys_addr_t page;unsigned long pd;PhysPageDesc *p; +unsigned long addr1;
You have promoted a variable that is declared differently in severaly inner blocks, and not used it in any new way.
exec.c void · line 3015
Quoted 12 lines
exec.c +2
-0while (len >0 ) { page = addr &TARGET_PAGE_MASK ;@@ -3007,6 +3008,8 @@ void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf, io_index = (pd >>IO_MEM_SHIFT ) & (IO_MEM_NB_ENTRIES -1 );if (p) addr1 = (addr & ~TARGET_PAGE_MASK ) + p->region_offset; +else + addr1 = addr;
I do not have an active source tree, so I did not apply your patch series to get here. So I am sorry if I am commenting blind.
By looking at more context in SVN I see that addr1 is already equal to addr, so this has no affect.
exec.c void · line 3030
Quoted 9 lines
/* XXX: could force cpu_single_env to NULL to avoid potential bugs */ if (l >= 4 && ((addr1 & 3) == 0)) {exec.c +0
-1@@ -3026,7 +3029,6 @@ void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf, l =1 ; } }else { -unsigned long addr1;
This is not used out side of this block, so why promote?
exec.c void · line 3056
Quoted 13 lines
exec.c +0
-0addr1 = (pd &TARGET_PAGE_MASK ) + (addr & ~TARGET_PAGE_MASK );/* RAM case */ ptr = phys_ram_base + addr1;exec.c +2
-0@@ -3047,6 +3049,8 @@ void cpu_physical_memory_rw(target_phys_addr_t addr, uint8_t *buf, io_index = (pd >>IO_MEM_SHIFT ) & (IO_MEM_NB_ENTRIES -1 );if (p) addr1 = (addr & ~TARGET_PAGE_MASK ) + p->region_offset; +else + addr1 = addr;
By looking at more context in SVN I see that addr1 is already equal to addr, so this has no affect.
Quoted 10 lines
if (l >= 4 && ((addr1 & 3) == 0)) { /* 32 bit read access */ val =io_mem_read[io_index][2](io_mem_opaque[io_index], addr1);
Signature · 1 line
1.6.2
Sorry if these comments are out of context, but I see no effect for any of these changes.
Thanks
Chris
RE: [Qemu-devel] [PATCH 11/24] Add ali1543 super IO pci device.
In reply to Tristan GingoldHello Tristan,
Quoted 42 lines
-----Original Message-----
From:
[email protected] [mailto:[email protected] rg] On Behalf Of Tristan Gingold
Sent: Thursday, March 19, 2009 9:36 AM
To: [email protected]
Cc: Tristan Gingold
Subject: [Qemu-devel] [PATCH 11/24] Add ali1543 super IO pci device.This is a very partial implementation just enough for es40 firmware.
Signed-off-by Tristan Gingold <[email protected]>--- hw/ali1543.c | 133 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/pci.h | 5 ++ hw/pci_ids.h | 3 + 3 files changed, 141 insertions(+), 0 deletions(-) create mode 100644 hw/ali1543.chw/ali1543.c new file +8
-0@@ -0,0 +1,133 @@ +/* +* QEMU Ali 1543c emulation +* +* Copyright (c) 2009 AdaCore +* +* Written by Tristan Gingold. +* +* This work is licensed under the GNU GPL license version 2 or later.
+ *
+ */hw/ali1543.c new file +4
-0+#include <time.h> +#include <sys/time.h> +#include "hw.h" +#include "net.h"
hw/ali1543.c line 24
Quoted 10 lines
hw/ali1543.c new file +10
-0+#include "sysemu.h" +#include "devices.h" +#include "boards.h" +#include "pc.h" +#include "isa.h" +#include "qemu-char.h" +#include "pci.h" + +//#define DEBUG_CFG +
Your commit comment says this is a Super IO.
I think a bit of a comment here about the card, which devices are on the card etc. would help people who don't have one laying around.
Quoted 73 lines
hw/ali1543.c new file +29
-0+struct ali1543_t { +PCIDevice pci; + +qemu_irq *irq;/* Upstream handler. */ +PITState *pit; +qemu_irq *i8259; + +/* Configuration. */ +enum cfg_state {CFG_SNOOP ,CFG_51 ,CFG_EN } cfg_state; +unsigned char cfg_index; +}; + +static void ali_cfg_write (void *opaque,uint32_t addr,uint32_t val) +{ +ali1543_t *ali = opaque; + +if ((addr &1 ) ==0 ) { +switch (ali->cfg_state) { +case CFG_SNOOP : +if (val ==0x51 ) + ali->cfg_state =CFG_51 ; +else +qemu_log ("ali1543-cfg: write %02x to cfg_port\n" , val); +break ; +case CFG_51 : +if (val ==0x23 ) + ali->cfg_state =CFG_EN ; +else { + qemu_log("ali1543-cfg: write %02x to cfg_port(51)\n", val);
hw/ali1543.c new file +42
-0+ ali->cfg_state =CFG_SNOOP ; + } +break ; +case CFG_EN : + ali->cfg_index = val; +break ; + } + } +else { +#ifdef DEBUG_CFG +qemu_log ("ali1543-cfg: write %02x to cfg reg %02x (addr=%x)\n" , + val, ali->cfg_index, addr); +#endif + } +} + +static uint32_t ali_cfg_read (void *opaque,uint32_t addr) +{ +ali1543_t *ali = opaque; + +if ((addr &1 ) ==0 ) { +if (ali->cfg_state !=CFG_EN ) { +qemu_log ("ali1543-cfg: read fromcfg_port\n" ); +return 0 ; + } +else +return ali->cfg_index; + } +else { +#ifdef DEBUG_CFG +qemu_log ("ali1543-cfg: read from reg %02x\n" , ali->cfg_index); +#endif +return 0 ; + } +} + +ali1543_t *ali1543_init (PCIBus *bus,int devfn,qemu_irq irq) +{ +ali1543_t *ali; +uint8_t *pci_conf; + + ali = (ali1543_t*)pci_register_device(bus, "Ali1543",
sizeof(ali1543_t),
hw/ali1543.c line 101
Quoted 6 lines
hw/ali1543.c new file +6
-0+ devfn, NULL, NULL); + + pci_conf = ali->pci.config; + +pci_config_set_vendor_id (pci_conf,PCI_VENDOR_ID_AL ); +pci_config_set_device_id (pci_conf,PCI_DEVICE_ID_AL_M1533 );
Is this an enhanced version of a 1533? Is this just a typo?
Thanks Chris
Quoted 69 lines
hw/ali1543.c new file +13
-0+ pci_conf[0x08 ] =0xc3 ;// Revision +pci_config_set_class (pci_conf,PCI_CLASS_BRIDGE_ISA ); + pci_conf[0x2c ] =0 ;// Subsystem + pci_conf[0x2d ] =0 ; + pci_conf[0x2e ] =0 ; + pci_conf[0x2f ] =0 ; + +register_ioport_read (0x370 ,2 ,1 , ali_cfg_read, ali); +register_ioport_write (0x370 ,2 ,1 , ali_cfg_write, ali); + + ali->i8259 =i8259_init (irq); + +/* serial_init already handles NULL CharDriverState but this code adds
hw/ali1543.c new file +19
-0+a more useful label. */ +if (serial_hds[0 ] ==NULL ) + serial_hds[0 ] =qemu_chr_open ("com1" ,"nul" ,NULL ); +if (serial_hds[1 ] ==NULL ) + serial_hds[1 ] =qemu_chr_open ("com2" ,"nul" ,NULL ); + +serial_init (0x3f8 , ali->i8259[4 ],115200 , serial_hds[0 ]); +serial_init (0x2f8 , ali->i8259[3 ],115200 , serial_hds[1 ]); + ali->pit =pit_init (0x40 , ali->i8259[0 ]); +pcspk_init (ali->pit); +DMA_init (0 ); + +return ali; +} + +qemu_irq ali1543_get_irq (ali1543_t *c,int n) +{ +return c->i8259[n]; +}hw/pci.h +5
-0@@ -254,4 +254,9 @@ PCIBus *pci_apb_init(target_phys_addr_t special_base, PCIBus *sh_pci_register_bus(pci_set_irq_fn set_irq, pci_map_irq_fn map_irq, qemu_irq *pic, int devfn_min, int nirq); +/* ali1543.c */ +typedef struct ali1543_t ali1543_t ; +ali1543_t *ali1543_init (PCIBus *bus,int devfn,qemu_irq irq); +qemu_irq ali1543_get_irq (ali1543_t *c,int n); +#endif hw/pci_ids.h +3
-0@@ -70,6 +70,9 @@#define PCI_VENDOR_ID_CMD 0x1095#define PCI_DEVICE_ID_CMD_646 0x0646 +#define PCI_VENDOR_ID_AL 0x10b9 +#define PCI_DEVICE_ID_AL_M1533 0x1533 +#define PCI_VENDOR_ID_REALTEK 0x10ec#define PCI_DEVICE_ID_REALTEK_8139 0x8139Signature · 1 line
1.6.2
RE: [Qemu-devel] [PATCH 13/24] Add target-alpha/machine.c and hw/es40.cfor es40 machine emulation.
In reply to Tristan GingoldHello Tristan,
Quoted 276 lines
-----Original Message-----
From:
[email protected] [mailto:[email protected] rg] On Behalf Of Tristan Gingold
Sent: Thursday, March 19, 2009 9:36 AM
To: [email protected]
Cc: Tristan Gingold
Subject: [Qemu-devel] [PATCH 13/24] Addtarget-alpha/machine.cand hw/es40.cfor es40 machine emulation.The machine emulation is not yet complete, in particular vm save and load is
not yet implemented.Signed-off-by Tristan Gingold <[email protected]>--- Makefile.target | 4 + hw/boards.h | 4 + hw/es40.c | 922 ++++++++++++++++++++++++++++++++++++++++++++++++ target-alpha/machine.c | 22 ++ 4 files changed, 952 insertions(+), 0 deletions(-) create mode 100644 hw/es40.c create mode 100644 target-alpha/machine.cMakefile.target +0
-0@@ -683,6 +683,10 @@ ifeq ($(TARGET_BASE_ARCH), m68k) OBJS+= an5206.o mcf5206.o ptimer.o mcf_uart.o mcf_intc.omcf5208.o mcf_fec.o
OBJS+= m68k-semi.o dummy_m68k.o
endifMakefile.target +2
-0+ifeq ($(TARGET_BASE_ARCH), alpha) +OBJS+= es40.o 21272.o serial.o i8259.o mc146818rtc.o i8254.opcspk.o dma.o
Makefile.target +2
-0+OBJS+= ali1543.o +endif ifdef CONFIG_GDBSTUB OBJS+=gdbstub.o gdbstub-xml.o endifhw/boards.h +4
-0@@ -128,4 +128,8 @@ extern QEMUMachine musicpal_machine;/* tosa.c */ extern QEMUMachine tosapda_machine; +/* es40.c */ +extern QEMUMachine es40_machine; +extern QEMUMachine es40_rombuild_machine; +#endif hw/es40.c new file +8
-0@@ -0,0 +1,922 @@ +/* +* QEMU ES-40 System Emulator +* +* Copyright (c) 2009 AdaCore +* +* Written by Tristan Gingold. +* +* This work is licensed under the GNU GPL license version 2 or later.
+ *
+ */hw/es40.c new file +14
-0+#include <time.h> +#include <sys/time.h> +#include "hw.h" +#include "net.h" +#include "sysemu.h" +#include "devices.h" +#include "boards.h" +#include "pc.h" +#include "isa.h" +#include "pci.h" + +/* Building the firmware for es40: + +The main part of the firmware is called SRM. You can get an original
hw/es40.c new file +3
-0+ image from HP web site: + +ftp://ftp.hp.com/pub/alphaserver/firmware/current_platforms/v7 .3_release/ES40_series/ES40/es40.zip
hw/es40.c new file +8
-0+ + Extract the archive and copy cl67srmrom.exe into a directory. + + Then start Qemu using es40-rombuild machine: + + $ qemu-system-alpha -M es40-rombuild -boot n -L . + + This builds the rom, writes es40.rom file and exits. Nowyou have it.
hw/es40.c new file +133
-0+*/ + +//#define DEBUG_TIGBUS + +/* For Rombuild. */ +#define ROMBUILD_BIOS_FILENAME "cl67srmrom.exe" +#define LFU_HDR_SIZE 0x240 +#define LFU_START_ADDR 0x900000 +#define LFU_LOAD_ADDR 0x900000 +#define LFU_MEM_SIZE 0x1000000 +#define LFU_RAM_OFFSET 0x400000 + +#define SRM_SIZE 0x200000 + +/* For es40. */ +#define BIOS_FILENAME "es40.rom" + +static ram_addr_t ram_offset; + +static void illegal_write (void *opaque, +target_phys_addr_t addr,uint32_t value) +{ +qemu_log ("illegal_write at addr=" TARGET_FMT_lx"\n" , addr); +} + +static uint32_t illegal_read (void *opaque,target_phys_addr_t addr) +{ +qemu_log ("illegal_read at addr=" TARGET_FMT_lx"\n" , addr); +return 0 ; +} + +typedef struct tigbus_t tigbus_t ; +struct tigbus_t { +/* See 264dptrm.pdf. */ +unsigned char halt_a; +unsigned char halt_b; +}; + +static uint32_t tigbus_readl (void *opaque,target_phys_addr_t addr) +{ +tigbus_t *s = opaque; +uint32_t ret; +int reg = addr >>6 ; + +/* TIGbus registers are mostly only 8 bits. */ +if (addr &0x04 ) +return 0 ; + +switch (reg) { +case 0x17 : + ret = s->halt_b; +break ; +case 0x12 :/* Power fault detected. */ + ret =0 ; +break ; +case 0x04 : + ret =0 ; +break ; +default : +qemu_log ("tigbus: unhandled read reg=%02x\n" , reg); + ret =0 ; +break ; + } + +#ifdef DEBUG_TIGBUS +fprintf (stderr,"tigbus read reg=%02x, val=%08x\n" , reg, ret); +#endif +return ret; +} + +static void tigbus_writel (void *opaque, +target_phys_addr_t addr,uint32_t value) +{ +tigbus_t *s = opaque; +int reg = addr >>6 ; + +if (addr &0x04 ) +return ; + +#ifdef DEBUG_TIGBUS +fprintf (stderr,"tigbus write reg=%02x, val=%08x\n" , reg, value); +#endif + +switch (reg) { +case 0x17 : + s->halt_b = value &0x0f ; +break ; +case 0x12 :/* Power fault detected. */ +break ; +default : +qemu_log ("tigbus: unhandled write to reg=0x%02x (%08x)\n" , + reg, value); +break ; + } +} + +static CPUReadMemoryFunc *tigbus_read[] = { + &illegal_read, + &illegal_read, + &tigbus_readl, +}; + +static CPUWriteMemoryFunc *tigbus_write[] = { + &illegal_write, + &illegal_write, + &tigbus_writel, +}; + +/* Dual Port Ram. + +0 0 SROM EV6 BIST status 1=good 0=bad +1 1 SROM Bit[7]=Master Bits[0,1]=CPU_ID +2 2 SROM Test STR status 1=good 0=bad +3 3 SROM Test CSC status 1=good 0=bad +4 4 SROM Test Pchip 0 PCTL status 1=good, 0=bad +5 5 SROM Test Pchip 1 PCTL status 1=good, 0=bad +6 6 SROM Test DIMx status 1=good 0=bad +7 7 SROM Test TIG bus status +8 8 SROM Dual-Port RAM test DD= started +9 9 SROM Status of DPR test 1=good 0=bad +A A SROM Status of CPU speed function FF=good, 0=bad +B B SROM Lower byte of CPU speed in MHz +C C SROM Upper byte of CPU speed in MHz +D:F - - Reserved +10:15 SROM Power On Time Stamp for CPU 0—written as BCD +Byte 10 = Hours (0-23) +Byte 11 = Minutes (0-59) +Byte 12 = Seconds (0-59) +Byte 13 = Day of Month (1-31) +Byte 14 = Month (1-12) +Byte 15 = Year (0-99) +16 SROM SROM Power On Error Indication for CPU is “alive.†+For example; 0 = no error, 2 = Secondary time-out Error, 3 = Bcache Error
+17:1D Unused
+1E SROM Last “sync state†reached; 80=Finished GOOD +1F SROM Size of Bcache in MB+20:3F 20 Repeat for CPU1 of CPU0 0-1F +40:5F 20 Repeat for CPU2 of CPU0 0-1F +60:7F 20 Repeat for CPU3 of CPU0 0-1F+80 80 SROM Array 0 (AAR 0) Configuration
hw/es40.c new file +33
-0+ Bits<7:4> + 4 = non split - lower set only + 5 = split - lower set only + 9 = split - upper set only + D = split - 8 DIMMs + F = Twice split - 8 DIMMs + Bits<3:0> + 0 = Configured - Lowest array + 1 = Configured - Next lowest array + 2 = Configured - Second highest array + 3 = Configured - Highest array + 4 = Misconfigured - Missing DIMM(s) + 8 = Miconfigured - Illegal DIMM(s) + C = Misconfigured - Incompatible DIMM(s) +81 81 SROM Array 0 (AAR 0)Size (x64 Mbytes) + 0 = no good memory + 1 = 64 Mbyte + 2 = 128 Mbyte + 4 = 256 Mbyte + 8 = 512 Mbyte + 10 = 1 Gbyte + 20 = 2 Gbyte + 40 = 4 Gbyte + 80 = 8 Gbyte +82 82 SROM Array 1 (AAR 1) Configuration +83 83 SROM Array 1 (AAR 1) Size (x64 Mbytes) +84 84 SROM Array 2 (AAR 2) Configuration +85 85 SROM Array 2 (AAR 2) Size (x64 Mbytes) +86 86 SROM Array 3 (AAR 3) Configuration +87 87 SROM Array 3 (AAR 3) Size (x64 Mbytes) +88:8B SROM Byte to define failed DIMMs for MMBs +88 - MMB 0 +89 - MMB 1
hw/es40.c
Quoted 10 lines
hw/es40.c new file +10
-0+8A - MMB 2 +8B - MMB 3 + Bit set indicates failure. + Bit definitions ( bit 0 = DIMM 1, bit 1 = DIMM2, + bit 2 = DIMM 3, bit 7 = DIMM 8) +8C:8F 8C-8F SROM Byte to define misconfigured DIMMs for MMBs +8C – MMB 0 +8D – MMB 1 +8E – MMB 2 +8F – MMB 3
There are several mailers involved, but this does not look right. (The mailer I use sucks, but it has a calendar, and proprietary lock in.)
Thanks
Chris
Quoted 758 lines
+ Bit definitions ( bit 0 = DIMM 1, bit 1 = DIMM2,
+ bit 2 = DIMM 3, bit 7 = DIMM 8)
+90 90 RMC Power Supply/VTERM present
+91 91 RMC Power SupplyPS_POKbits
+92 92 RMC AC input value from Power Supply +93:96 93 RMC Temperature from CPU(x) in BCD +97:99 97 RMC Temperature Zone(x) from 3 PCI temp sensors +9A:9F 9A RMC Fan Status; Raw Fan speed valuehw/es40.c new file +25
-0+A0:A9 A0 RMC Failure registers used as part of the 680 machine + check logout frame. See Appendix D. +AA RMC Fan status (bit 0 = fan 1, bit 1 = fan 2, + 1- indicates good; 0 indicates fan failure +AB RMC Status of RMC to read I2C bus of MMB0 DIMMs + Definition: + Bit 7 - DIMM 8 0=OK 1=Fail + Bit 6 - DIMM 7 + Bit 5 - DIMM 6 + ……………… + Bit 0 - DIMM 1 +AC RMC Status of RMC to read I2C bus of MMB1 DIMMs +AD RMC Status of RMC to read I2C bus of MMB2 DIMMs +AE RMC Status of RMC to read I2C bus of MMB3 DIMMs +AF RMC Status of RMC to read MMB and CPU I2C buses + Definition: + Bit 7 - MMB3 0=OK 1=Fail + Bit 6 - MMB2 + Bit 5 - MMB1 + Bit 4 - MMB0 + Bit 3 - CPU3 + Bit 2 - CPU2 + Bit 1 - CPU1 + Bit 0 - CPU0 +B0 RMC Status of RMC to read CPB (PCI backplane) I2C EEROM0=OK 1 = fail
+B1 RMC Status of RMC to read CSB (motherboard) I2C EEROM 0=OK 1 = failhw/es40.c new file +10
-0+B2 RMC Status of RMC to read SCSI backplane +Definition: + Bit 0 — SCSI backplane 0 + Bit 1 — SCSI backplane 1 + Bit 4 — Power supply 0 + Bit 5 — Power supply 1 + Bit 6 — Power supply 2 +B3:B9 Unused Unused +BA RMC I2C done, BA = finished +BB RMC RMC Power on Error indicates error during power-up(1=Flash Corrupted)
hw/es40.c new file +30
-0+BC RMC RMC flash update error status +BD RMC Copy of PS input Value. See Appendix D. +BE RMC Copy of the byte from the I/O expanders on the + SPC loaded by the RMC on fatal errors. See Appendix D. +BF RMC Reason for system failure. See Appendix D. +C0:D8 Unused +D9 RMC Baud rate +DA TIG Indicates TIG finished loading its code (0xAA indicates done) +DB:E3 RMC Fan/Temp info from PS1 +E4:EC RMC Fan/Temp info from PS2 +ED:F5 RMC Fan/Temp info from PS3 +F6:F8 Unused Unused +F9 Firmware Buffer Size (0-0xFF) or 1 to 256 bytes +FA:FB FA Firmware Command address qualifier +FA = lower byte, FB = upper byte +FC FC RMC Command status associated with the RMC + response to a request from the firmware + 0 = successful completion +80 = unsuccessful completion +81 = invalid command code +82 = invalid command qualifier +FD FD RMC Command ID associated with the RMC + response to a request from the firmware +FE FE Firmware Command Code associated with a “command†+sent to the RMC + 1 = update I2C EEROM + 2 = update baud rate + 3 = display to OCP +F0 = update RMC flash +FF FF Firmware Command ID associated with a “commandâ€sent to the RMC
+100:1FF 100 RMC Copy of EEROM on MMB0 J1 DIMM 1,
+ initially read on I2C bus by RMC when 5
+ volts supply turned on. Written by Compaq
+ Analyze after error diagnosed to particular FRU
+200:2FF 200 RMC Copy of EEROM on MMB0 J2 DIMM 2
+300:3FF 300 RMC Copy of EEROM on MMB0 J3 DIMM 3
+400:4FF 400 RMC Copy of EEROM on MMB0 J4 DIMM 4
+500:5FF 500 RMC Copy of EEROM on MMB0 J5 DIMM 5
+600:7FF 600 RMC Copy of EEROM on MMB0 J6 DIMM 6
+700:7FF 700 RMC Copy of EEROM on MMB0 J7 DIMM 7
+800:8FF 800 RMC Copy of EEROM on MMB0 J8 DIMM 8
+900:9FF 900 RMC Copy of EEROM on MMB1 J1 DIMM 1hw/es40.c new file +41
-0+A00:AFF A00 RMC Copy of EEROM on MMB1 J2 DIMM 2 +B00:BFF B00 RMC Copy of EEROM on MMB1 J3 DIMM 3 +C00:CFF C00 RMC Copy of EEROM on MMB1 J4 DIMM 4 +D00:DFF D00 RMC Copy of EEROM on MMB1 J5 DIMM 5 +E00:EFF E00 RMC Copy of EEROM on MMB1 J6 DIMM 6 +F00:FFF F00 RMC Copy of EEROM on MMB1 J7 DIMM 7 +1000:10FF 1000 RMC Copy of EEROM on MMB1 J8 DIMM 8 +1100:11FF 1100 RMC Copy of EEROM on MMB2 J1 DIMM 1 +1200:12FF 1200 RMC Copy of EEROM on MMB2 J2 DIMM 2 +1300:13FF 1300 RMC Copy of EEROM on MMB2 J3 DIMM 3 +1400:14FF 1400 RMC Copy of EEROM on MMB2 J4 DIMM 4 +1500:15FF 1500 RMC Copy of EEROM on MMB2 J5 DIMM 5 +1600:16FF 1600 RMC Copy of EEROM on MMB2 J6 DIMM 6 +1700:17FF 1700 RMC Copy of EEROM on MMB2 J7 DIMM 7 +1800:18FF 1800 RMC Copy of EEROM on MMB2 J8 DIMM 8 +1900:19FF 1900 RMC Copy of EEROM on MMB3 J1 DIMM 1 +1A00:1AFF 1A00 RMC Copy of EEROM on MMB3 J2 DIMM 2 +1B00:1BFF 1B00 RMC Copy of EEROM on MMB3 J3 DIMM 3 +1C00:1CFF 1C00 RMC Copy of EEROM on MMB3 J4 DIMM 4 +1D00:1DFF 1D00 RMC Copy of EEROM on MMB3 J5 DIMM 5 +1E00:1EFF 1E00 RMC Copy of EEROM on MMB3 J6 DIMM 6 +1F00:1FFF 1F00 RMC Copy of EEROM on MMB3 J7 DIMM 7 +2000:20FF 2000 RMC Copy of EEROM on MMB3 J8 DIMM 8 +2100:21FF 2100 RMC Copy of EEROM from CPU0 +2200:22FF 2200 RMC Copy of EEROM from CPU1 +2300:23FF 2300 RMC Copy of EEROM from CPU2 +2400:24FF 2400 RMC Copy of EEROM from CPU3 +2500:25FF 2500 RMC Copy of MMB 0 J5 FRU EEROM +2600:26FF 2600 RMC Copy of MMB 1 J7 FRU EEROM +2700:27FF 2700 RMC Copy of MMB 2 J6 FRU EEROM +2800:28FF 2800 RMC Copy of MMB 3 J8 FRU EEROM +2900:29FF 2900 RMC Copy of EEROM on CPB (PCI backplane) +2A00:2AFF 2A00 RMC Copy of EEROM on CSB (motherboard) +2B00:2BFF 2B00 RMC Last EV6 Correctable Error—ASCII + character string that indicates correctable + error occurred, type, FRU, and so on. Backed + up in CSB (motherboard) EEROM. Written by Compaq Analyze +2C00:2CFF 2C00 RMC Last Redundant Failure—ASCII + character string that indicates redundant + failure occurred, type, FRU, and so on. + Backed up in system CSB (motherboard) EEROM. Written byCompaq Analyze
+2D00:2DFF 2D00 RMC Last System Failure—ASCII character
+ string that indicates system failure occurred, type, FRU, and so on. Backed
+ up in CSB (motherboard) EEROM. Written by Compaq Analyze. +2E00:2FFF 2E00 RMC Uncorrectable machine logout frame (512 bytes) +3000:3008 SROM SROM Version (ASCII string)
+3009:300B RMC Rev Level of RMC first byte is letter Rev
+ [x/t/v] second 2 bytes are major/minor.
+ This is the rev level of the RMC on-chip code. +300C:300E RMC Rev Level of RMC first byte is letter Rev
+ [x/t/v] second 2 bytes are major/minor.
+ This is the rev level of the RMC flash code. +300F:3010 300F RMC Revision Field of the DPR Structure +3011:30FF Unused Unused
+3100:31FF RMC Copy of PS0 EEROM (first 256 bytes) +3200:32FF RMC Copy of PS1 EEROM (first 256 bytes) +3300:33FF RMC Copy of PS2 EEROM (first 256 bytes) +3400 SROM Size of Bcache in MB
+3401 SROM Flash SROM is valid flag; 8 = valid, 0 = invalid +3402 SROM System’s errors determined by SROM +3403:340F SROM/SRM Reserved for future SROM/SRM communication +3410:3417 SROM/SRM Jump to address for CPU0
+3418 SROM/SRM Waiting to jump to flag for CPU0
+3419 SROM Shadow of value written to EV6DC_CTLregister. +341A:341E SROM Shadow of most recent writes to EV6 CBOX “Write-many†chain.
+341F SROM/SRM Reserved for future SROM/SRM communication+3420:342F SROM/SRM Repeat for CPU1 of CPU0 3410-341F +3430:343F SROM/SRM Repeat for CPU2 of CPU0 3410-341F +3440:344F SROM/SRM Repeat for CPU3 of CPU0 3410-341F+3450:349F SROM/RMC Reserved for SROM mini-console via
+ RMC communication area. Future design.
+34A0:34A7 SROM Array 0 to DIMM ID translation
+ Bits<7:5>
+ 0 = Exists, No Error
+ 1 = Expected Missing
+ 2 = Error - Missing DIMM(s)
+ 4 = Error - Illegal DIMM(s)
+ 6 = Error - Incompatible DIMM(s)
+ Bits<4:0>
+ Bits <2:0> = DIMM + 1 (1-8)
+ Bits <4:3> = MMB (0-3)
+34A8:34AF SROM Repeat for Array 1 of Array 0 +34A0:34A7
+34B0:34B7 SROM Repeat for Array 2 of Array 0 +34A0:34A7
+34B8:34CF SROM Repeat for Array 3 of Array 0 +34A0:34A7
+34C0:34FF 34C0 SROM Used as scratch area for SROM +3500:35FF Firmware Used as the dedicated buffer in which
+ SRM writes OCP or FRU EEROM data.
+ Firmware will write this data, RMC will only read this data. +3600:36FF 3600 SRM Reserved
+3700:37FF SRM Reserved
+3800:3AFF RMC RMC scratch space
+3B00:3BFF RMC First SCSI backplane EEROM
+3C00:3CFF RMC Second SCSI backplane EEROM +3D00:3DFF RMC PS0 second 256 bytes
+3E00:3EFF RMC PS1 second 256 bytes
+3F00:3FFF RMC PS2 second 256 byteshw/es40.c new file +9
-0+*/ + +struct dpram_t { +unsigned char mem[0x4000 ]; +uint32_t set_vec[0x4000 >>5 ]; +}; +typedef struct dpram_t dpram_t ; + +static uint32_t tigbus_dpram_readl (void *opaque,
target_phys_addr_taddr)hw/es40.c new file +11
-0+{ +dpram_t *dpr = opaque; +int reg = addr >>6 ; + +/* Discard upper long word. */ +if (addr &0x4 ) +return 0 ; + +#if 0 +if (!(dpr->set_vec[reg >>5 ] &(1 << (reg &0x1f )))) + fprintf(stderr,"tigbus dpram: reading uninitialized0x%04x\n", reg);
hw/es40.c new file +7
-0+#endif + +return dpr->mem[reg]; +} + +static void tigbus_dpram_writel (void *opaque, + target_phys_addr_t addr,
uint32_tvalue)hw/es40.c new file +35
-0+{ +dpram_t *dpr = opaque; +int reg = addr >>6 ; + +/* Discard upper long word. */ +if (addr &0x4 ) +return ; + +#if 0 +fprintf (stderr,"tigbus dpram write %02x at %08x (%04x)\n" , + value, (unsigned int ) addr, reg); +#endif + + dpr->mem[reg] = value; + dpr->set_vec[reg >>5 ] |= (1 << (reg &0x1f )); +if (reg ==0xff ) { +const char *cmd; + dpr->mem[0xfc ] =0 ; + dpr->mem[0xfd ] = dpr->mem[0xff ]; +switch (dpr->mem[0xfe ]) { +case 0x01 : + cmd ="eeprom update" ; +break ; +case 0x02 : + cmd ="baud rate update" ; +break ; +case 0x03 : + { +char buf[17 ]; +memcpy (buf, &dpr->mem[0x3500 ],16 ); + buf[16 ] =0 ; +fprintf (stderr,"OCP message: [%s]\n" , buf); +#if 0 +if (strncmp (buf,"create powerup " ,16 ) ==0 ) { + loglevel =CPU_LOG_TB_IN_ASM |CPU_LOG_EXEC |
CPU_LOG_TB_CPU;hw/es40.c new file +21
-0+ } +#endif +if (1 ) + cmd =NULL ; +else + cmd ="OCP display" ; +break ; + } +case 0xf0 : + cmd ="update RMC flash" ; +break ; +default : + cmd =NULL ; +fprintf (stderr,"tigbus dpram: cmd unknown 0x%02x\n" , + dpr->mem[0xfe ]); + dpr->mem[0xfc ] =0x81 ; +break ; + } +if (cmd) { + fprintf(stderr, + "tigbus dpram: cmd %02x, id=%02x: %s,addr=%04x len=%d\n",
hw/es40.c new file +46
-0+ dpr->mem[0xfe ], dpr->mem[0xff ], + cmd, (dpr->mem[0xfb ] <<8 ) | dpr->mem[0xfa ], + dpr->mem[0xf9] + 1); + } + } +} + +static CPUReadMemoryFunc *tigbus_dpram_read[] = { + &illegal_read, + &illegal_read, + &tigbus_dpram_readl, +}; + +static CPUWriteMemoryFunc *tigbus_dpram_write[] = { + &illegal_write, + &illegal_write, + &tigbus_dpram_writel, +}; + +static void dpr_set (dpram_t *dpr,int reg,unsigned char val) +{ + dpr->mem[reg] = val; + dpr->set_vec[reg >>5 ] |= (1 << (reg &0x1f )); +} + +static void tigbus_reset (void *opaque) +{ +/* tigbus_t *s = opaque; */ +} + +static void tigbus_init (uint64_t arr[]) +{ +tigbus_t *s; +int mem; +int dpram_io; +dpram_t *dpram; +int i; + + s =qemu_mallocz (sizeof (tigbus_t)); + mem =cpu_register_io_memory (0 , tigbus_read, tigbus_write, s); +cpu_register_physical_memory (0x80130000000ULL ,0x0002000 , mem); + + dpram =qemu_mallocz (sizeof (dpram_t)); + dpram_io =cpu_register_io_memory (0 , tigbus_dpram_read, + tigbus_dpram_write, dpram); + cpu_register_physical_memory(0x80110000000ULL,
0x0100000,dpram_io);hw/es40.c new file +164
-0+ +/* Initialize dpram. */ +#define S (r,v) dpr_set(dpram,r,v) +S (0x00 ,1 );/* BIST OK */ +S (0x01 ,0x80 );/* CPU 0 is master */ +S (0x02 ,1 );/* STR ok */ +S (0x03 ,1 );/* CSC ok */ +S (0x04 ,1 );/* Pchip0 ok */ +S (0x05 ,1 );/* Pchip1 ok */ +S (0x06 ,1 );/* DIMx ok */ +S (0x07 ,1 );/* TIG ok */ +S (0x08 ,0xdd );/* DPRam ok */ +S (0x09 ,0x1 );/* DPRDDam ok */ +S (0x0a ,0xff );/* cpu speed ok */ +S (0x0b ,600 %256 ); +S (0x0c ,600 /256 ); +/* Unused. */ +S (0x0d ,0 ); +S (0x0e ,0 ); +S (0x0f ,0 ); +/* Power On time stamp. Use RTC ? */ +S (0x10 ,0x12 ); +S (0x11 ,0x30 ); +S (0x12 ,0x25 ); +S (0x13 ,0x15 ); +S (0x14 ,0x02 ); +S (0x15 ,0x05 ); +S (0x16 ,0x0 );/* Power On indicator. */ +/* Unused. */ +S (0x17 ,0 ); +S (0x18 ,0 ); +S (0x19 ,0 ); +S (0x1a ,0 ); +S (0x1b ,0 ); +S (0x1c ,0 ); +S (0x1d ,0 ); +S (0x1e ,0x80 );/* Finished good */ +S (0x1f ,0x8 );/* Bcache size */ + +for (i =0x20 ; i <0x80 ; i++) +S (i,0 );/* For other cpus. */ + +/* Array configuration */ +for (i =0x0 ; i <0x4 ; i++) { +S (0x80 +2 * i, arr[i] ?0xf0 | i :4 ); +if (arr[i]) { +int msb = ((arr[i] >>12 ) &0x0f ) -1 ; +if (msb <2 ) + msb =2 ; +S (0x80 +2 * i +1 ,1 << (msb -2 )); + } +else +S (0x80 +2 * i +1 ,0 ); + } +for (i =0x88 ; i <0x90 ; i++) +S (i,0 ); +S (0x90 ,0xff );/* PSU */ +S (0x91 ,0x00 );/* PSU */ +S (0x92 ,0x07 );/* AC */ +S (0x93 ,0x30 );/* CPU 0 */ +S (0x94 ,0x00 );/* CPU 1 */ +S (0x95 ,0x00 );/* CPU 2 */ +S (0x96 ,0x00 );/* CPU 3 */ +S (0x97 ,0x22 );/* Pci 0 */ +S (0x98 ,0x22 );/* Pci 1 */ +S (0x99 ,0x22 );/* Pci 2 */ +S (0x9a ,0x90 );/* fan speed */ +S (0x9b ,0x90 );/* fan speed */ +S (0x9c ,0x90 );/* fan speed */ +S (0x9d ,0x90 );/* fan speed */ +S (0x9e ,0x90 );/* fan speed */ +S (0x9f ,0x90 );/* fan speed */ +for (i =0xa0 ; i <0xaa ; i++) +S (i,0 );/* 680 logout frame */ +S (0xaa ,0 );/* Fan status */ +S (0xab ,0 );/* MMB0 dimm i2c */ +S (0xac ,0 );/* MMB1 dimm i2c */ +S (0xad ,0 );/* MMB2 dimm i2c */ +S (0xae ,0 );/* MMB3 dimm i2c */ +S (0xaf ,0 );/* MMB & cpu i2c */ +S (0xb0 ,0 );/* cpb i2c */ +S (0xb1 ,0 );/* csb i2c */ +S (0xb2 ,0 );/* scsi and ps i2c */ +for (i =0xb3 ; i <0xba ; i++) +S (i,0 );/* usued */ +S (0xba ,0xba );/* i2c done */ +S (0xbb ,0x0 );/* rmc flash ok */ +S (0xbc ,0x0 );/* rmc flash ok */ + +S (0xbd ,0x7 );/* PS val */ +S (0xbe ,0x0 );/* SPC fault */ +S (0xbf ,0x0 );/* system fault */ + +for (i =0xc0 ; i <=0xd8 ; i++) +S (i,0 );/* usued */ + +S (0xd9 ,2 );/* RMC baud rate. */ +S (0xda ,0xaa );/* TIG loaded. */ +for (i =0 ; i <3 ; i++) { +S (0xdb + i *9 ,0xf4 + i);/* PS id */ +S (0xdc + i *9 ,0x45 ); +S (0xdd + i *9 ,0x51 ); +S (0xde + i *9 ,0x37 ); +S (0xdf + i *9 ,0x90 );/* Fan speed */ +S (0xe0 + i *9 ,0xd6 ); +S (0xe1 + i *9 ,0x49 ); +S (0xe2 + i *9 ,0x4b ); +S (0xe3 + i *9 ,0x0 ); + } +S (0xf6 ,0 );/* unused. */ +S (0xf7 ,0 );/* unused. */ +S (0xf8 ,0 );/* unused. */ +S (0xf9 ,0 );/* buffer size. */ +S (0xfa ,0 );/* cmd addr. */ +S (0xfb ,0 );/* cmd addr. */ +S (0xfc ,0 );/* command status. */ +S (0xfd ,1 );/* command id. */ +S (0xff ,1 );/* command id. */ + +for (i =0x2900 ; i <0x2a00 ; i++) +S (i,0 );/* PCI backplane FRU. */ +for (i =0x2a00 ; i <0x2b00 ; i++) +S (i,0 );/* motherboard FRU. */ +for (i =0x2b00 ; i <0x2c00 ; i++) +S (i,0 );/* last correctable error. */ +for (i =0x2c00 ; i <0x2d00 ; i++) +S (i,0 );/* last redundant error. */ +for (i =0x2d00 ; i <0x2e00 ; i++) +S (i,0 );/* last system failure. */ + +S (0x3000 ,'V' );/* SROM version */ +S (0x3001 ,'2' ); +S (0x3002 ,'.' ); +S (0x3003 ,'2' ); +S (0x3004 ,'2' ); +S (0x3005 ,'G' ); +S (0x3006 ,0 ); +S (0x3007 ,0 ); +S (0x3008 ,0 ); +S (0x3009 ,'V' );/* RMC rom version */ +S (0x300a ,1 ); +S (0x300b ,0 ); +S (0x300c ,'V' );/* RMC flash version */ +S (0x300d ,1 ); +S (0x300e ,0 ); +S (0x300f ,1 );/* RMC revision field */ +S (0x3010 ,0 ); +for (i =0x3011 ; i <=0x30ff ; i++) +S (i,0 );/* unsued */ + +S (0x3400 ,8 );/* Size of Bcache */ +S (0x3401 ,8 );/* Flash rom valid */ +S (0x3402 ,0 );/* system errors */ +for (i =0x3403 ; i <0x3410 ; i++) +S (i,0 );/* Reserved. */ +for (i =0x3410 ; i <0x3420 ; i++) +S (i,0 );/* Jump to address. */ +for (i =0x3420 ; i <=0x349f ; i++) +S (i,0 );/* cpu 1-3 */ +/* Array map. */ +for (i =0 ; i <0x20 ; i++) { +if (arr[i /8 ]) + S(0x34a0 + i, (((i >> 0) & 1) | (((i >> 1) & 1) << 3) + | (((i >> 2) & 1) << 2) | (((i >>3) & 1) << 1)
hw/es40.c new file +47
-0+ | (((i >> 4) & 1) << 4))); + else + S(0x34a0 + i, 0x20); + } +#undef S + +tigbus_reset (s); +qemu_register_reset (&tigbus_reset, s); +} + +struct srm_patch { +uint64_t addr; +uint32_t old_insn; +uint32_t new_insn; +}; + +static const struct srm_patch srm_patches[] = { + {0x142a0 ,0x259f11e2 ,0x259f0000 },/* ldah s3, 0x11e2 */ + {0x142a4 ,0x218ca300 ,0x218c0001 },/* lda s3,-23808(s3) */ + {0x14260 ,0x259f00e5 ,0x259f0000 },/* ldah s3,229 */ + {0x14264 ,0x218ce1c0 ,0x218c0001 },/* lda s3,-7744(s3) */ + +#if 1 +/* Disable memory testing. */ + {0x8bb88 ,0xe4200004 ,0xc3e00004 },/* beq t0,0x8bb9c -- aa */ + {0x8bbc0 ,0xe400001b ,0xc3e0001b },/* beq v0,0x8bc30 -- 55 */ + {0x8bc48 ,0xe4a0001b ,0xc3e0001b },/* beq t4,0x8bcb8 -- 00 */ +#endif + {0 ,0 ,0 } +}; + +void alpha_21264_srm_write (CPUState *env) +{ +int fd; +int i; +uint32_t insn; +static const char rom_file[] =BIOS_FILENAME ; + + env->a21264.pal_reloc_val =1 ; + env->a21264.pal_reloc_mask =0 ; + env->a21264.pal_reloc_offset =0 ; + +/* Apply patch list. */ +for (i =0 ; srm_patches[i].addr; i++) { + insn =ldl_phys (srm_patches[i].addr); +if (insn != srm_patches[i].old_insn) + fprintf(stderr, "SRM patch mismatch at%"PRIx64": insn=%x\n",
hw/es40.c new file +7
-0+ srm_patches[i].addr, insn); + else + stl_phys(srm_patches[i].addr, srm_patches[i].new_insn); + } + +/* Save SRM. */ + fd = open(rom_file, O_CREAT | O_TRUNC | O_WRONLY |
O_BINARY, 0644);hw/es40.c new file +53
-0+if (fd <0 ) { + save_error: +fprintf (stderr,"qemu: can't open %s\n" , rom_file); +exit (1 ); + } +if (write (fd, phys_ram_base + ram_offset,SRM_SIZE ) !=SRM_SIZE ) + goto save_error; +close (fd); +printf ("Bios written to %s\nExit\n" , rom_file); +exit (0 ); +} + +static void es40_rombuild_init (ram_addr_t ram_size,int vga_ram_size, +const char *boot_device, +const char *kernel_filename, +const char *kernel_cmdline, +const char *initrd_filename, +const char *cpu_model) +{ +CPUState *env; +int bios_size; +int srm_ram_size; +int fd; +char buf[1024 ]; + +if (!cpu_model) + cpu_model ="21264" ; + +printf ("Initializing CPU\n" ); + env =cpu_init (cpu_model); +if (!env) { +fprintf (stderr,"Unable to find Alpha CPU definition\n" ); +exit (1 ); + } + +/* BIOS load */ +if (bios_name ==NULL ) + bios_name =ROMBUILD_BIOS_FILENAME ; +snprintf (buf,sizeof (buf),"%s/%s" , bios_dir, bios_name); + fd =open (buf,O_RDONLY |O_BINARY ); +if (fd <0 ) { + load_error: +fprintf (stderr,"qemu: can't open %s\n" , buf); +exit (1 ); + } + bios_size =lseek (fd,0 ,SEEK_END ); +if (bios_size <=0 ) + goto load_error; + bios_size -=LFU_HDR_SIZE ; + srm_ram_size =TARGET_PAGE_ALIGN (bios_size); + ram_offset =qemu_ram_alloc (LFU_MEM_SIZE ); +lseek (fd,LFU_HDR_SIZE ,SEEK_SET ); + if (read(fd, phys_ram_base + ram_offset + LFU_LOAD_ADDR,
bios_size)hw/es40.c new file +4
-0+ != bios_size) + goto load_error; +close (fd); + memcpy(phys_ram_base + ram_offset + LFU_LOAD_ADDR +
LFU_RAM_OFFSET,hw/es40.c new file +51
-0+ phys_ram_base + ram_offset +LFU_LOAD_ADDR , + bios_size); +printf ("SRM loaded\n" ); + +cpu_register_physical_memory (0 ,LFU_MEM_SIZE , ram_offset); + + env->pc =LFU_START_ADDR ; + env->a21264.pal_reloc_val =LFU_LOAD_ADDR ; + env->a21264.pal_reloc_mask = ~(uint64_t )0xfffffU ; + env->a21264.pal_reloc_offset =LFU_RAM_OFFSET ; +} + +static void es40_cpu_reset (void *opaque) +{ +CPUState *env = opaque; + + env->pc =0x8000 ; +} + +static void configure_mem_array (ram_addr_t ram_size,uint64_t *aar) +{ +int msb; +uint32_t base; +int i; +uint32_t size; + +for (i =0 ; i <4 ; i++) + aar[i] =0 ; + +/* Configure cchip array address. */ + size = ram_size >>24 ; + base =0 ; +for (i =0 ; i <4 ; i++) { + msb =ffs (size); +if (msb ==0 ) +break ; + msb--; +if (msb >8 ) + msb =8 ; + aar[i] = (((uint64_t )base) <<24 ) + | ((msb +1 ) <<12 ) | (1 <<2 ) | (1 <<0 ); + base +=1 << msb; + size -=1 << msb; +printf ("es40: arr[%d]=%016" PRIx64": %4uMB at %5uMB\n" , + i, aar[i],16 << msb, base <<4 ); + } +} + +static void es40_init(ram_addr_t ram_size, int vga_ram_size, + const char *boot_device, + const char *kernel_filename, constchar
*kernel_cmdline,
+ const char*initrd_filename, const
char*cpu_model)hw/es40.c new file +63
-0+{ +CPUState *env; +char buf[1024 ]; +qemu_irq *cchip_irqs; +qemu_irq tim_irq; +typhoon_t *typhoon; +ali1543_t *ali; +PCIBus *hose0; +uint64_t arr[4 ]; + +if (!cpu_model) + cpu_model ="21264" ; + + env =cpu_init (cpu_model); +if (!env) { +fprintf (stderr,"Unable to find Alpha CPU definition\n" ); +exit (1 ); + } +qemu_register_reset (es40_cpu_reset, env); + +/* Allocate RAM. */ + ram_offset =qemu_ram_alloc (ram_size); +cpu_register_physical_memory (0 , ram_size, ram_offset); + +/* SRM load */ +if (bios_name ==NULL ) + bios_name =BIOS_FILENAME ; +snprintf (buf,sizeof (buf),"%s/%s" , bios_dir, bios_name); +if (load_image (buf, phys_ram_base + ram_offset) !=SRM_SIZE ) { +fprintf (stderr,"qemu: can't read %s - (or bad size)\n" , buf); +exit (1 ); + } + +configure_mem_array (ram_size, arr); + typhoon =typhoon_21272_init (arr, &cchip_irqs, &tim_irq, env); +tigbus_init (arr); + + hose0 =typhoon_get_pci_bus (typhoon,0 ); + + ali =ali1543_init (hose0,PCI_DEVFN (7 ,0 ), cchip_irqs[55 ]); + +typhoon_set_iack_handler (typhoon,0 , + (int (*)(void *))pic_read_irq, isa_pic); + +rtc_init_sqw (0x70 ,ali1543_get_irq (ali,8 ), tim_irq,2000 ); + +es40_cpu_reset (env); +} + + +QEMUMachine es40_rombuild_machine = { + .name ="es40-rombuild" , + .desc ="Alpha es40 rom builder" , + .init = es40_rombuild_init, + .ram_require =16 <<20 +}; + +QEMUMachine es40_machine = { + .name ="es40" , + .desc ="Alpha es40" , + .init = es40_init, + .ram_require =64 <<20 +};target-alpha/machine.c new file +22
-0@@ -0,0 +1,22 @@ +#include "hw/hw.h" +#include "hw/boards.h" +#include "qemu-timer.h" + +#include "exec-all.h" + +void register_machines (void ) +{ +qemu_register_machine (&es40_machine); +qemu_register_machine (&es40_rombuild_machine); +} + +void cpu_save (QEMUFile *f,void *opaque) +{ +/* FIXME: todo */ +abort (); +} + +int cpu_load (QEMUFile *f,void *opaque,int version_id) +{ +return -EINVAL ; +}Signature · 1 line
1.6.2
RE: [Qemu-devel] [PATCH 20/24] Add alpha_cpu_list.
In reply to Tristan GingoldHello Tristan,
Quoted 56 lines
-----Original Message-----
From:
[email protected] [mailto:[email protected] rg] On Behalf Of Tristan Gingold
Sent: Thursday, March 19, 2009 9:36 AM
To: [email protected]
Cc: Tristan Gingold
Subject: [Qemu-devel] [PATCH 20/24] Addalpha_cpu_list.Add
alpha_cpu_listand usecpu_modelto select the model incpu_alpha_init.
Set implver and amask from the model.Signed-off-by Tristan Gingold <[email protected]>--- target-alpha/cpu.h | 1 + target-alpha/translate.c | 40 ++++++++++++++++++++++++++++++++++++++-- 2 files changed, 39 insertions(+), 2 deletions(-)target-alpha/cpu.h +1
-0@@ -436,6 +436,7 @@ enum {CPUAlphaState *cpu_alpha_init (const char *cpu_model);int cpu_alpha_exec (CPUAlphaState *s); +void alpha_cpu_list (FILE *f,int (*cpu_fprintf)(FILE *f,const char *fmt, ...));/* you can call this signal handler from your SIGBUS and SIGSEGV signal handlers to inform the virtual CPU of exceptions. non zero is returned if the signal was handled by the virtual CPU. */
target-alpha/translate.c +12
-0@@ -2460,17 +2460,53 @@ void gen_intermediate_code_pc (CPUState *env, struct TranslationBlock *tb)gen_intermediate_code_internal (env, tb,1 ); } +struct alpha_def { +const char *name; +uint32_t implver; +uint32_t amask; +}; + +static const struct alpha_def alpha_defs[] = { +#if 0 + {"21064" , IMPLVER_2106x,0 }, + {"21164" ,IMPLVER_21164 ,0 }, +#endif + { "21264", IMPLVER_21264, (AMASK_PREFETCH | AMASK_TRAP |
AMASK_BWX
target-alpha/translate.c void gen_intermediate_code_pc (CPUState *env, struct TranslationBlock *tb) · line 2476
Quoted 2 lines
target-alpha/translate.c +2
-0+ | AMASK_FIX) }, +};
Again thanks for expanding the Alpha support.
Unless Alpha was completely broken before, I don't think we should drop support for EV4 while adding EV6.
Thanks
Chris
Quoted 45 lines
target-alpha/translate.c +2
-0+ +void alpha_cpu_list(FILE *f, int (*cpu_fprintf)(FILE *f,const char *fmt, ...))
target-alpha/translate.c +22
-2+{ +int i; + +for (i =0 ; i <ARRAY_SIZE (alpha_defs); i++) + (*cpu_fprintf)(f,"%s\n" , alpha_defs[i].name); +} +CPUAlphaState *cpu_alpha_init (const char *cpu_model) {CPUAlphaState *env;uint64_t hwpcb; +const struct alpha_def *cpu = alpha_defs; + +if (cpu_model !=NULL ) { +int i; +for (i =0 ; i <ARRAY_SIZE (alpha_defs); i++) +if (strcmp (alpha_defs[i].name, cpu_model) ==0 ) { + cpu = &alpha_defs[i]; +break ; + } +if (cpu ==NULL ) +return NULL ; + } env =qemu_mallocz (sizeof (CPUAlphaState));cpu_exec_init (env);alpha_translate_init ();tlb_flush (env,1 ); -/* XXX: should not be hardcoded */ - env->implver = IMPLVER_2106x; + + env->implver = cpu->implver; + env->amask = cpu->amask; env->ps =0x1F00 ;#if defined (CONFIG_USER_ONLY ) env->ps |=1 <<3 ;Signature · 1 line
1.6.2
Re: [Qemu-devel] [PATCH 02/24] Fix cpu_physical_memory_rw whenoperating on IO blocks.
In reply to Krumme, ChrisQuoted 3 lines · Chris
Hello Tristan,
First thanks for promoting the Alpha.
Thanks.
Quoted 8 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ else + addr1 = addr;I do not have an active source tree, so I did not apply your patch series to get here. So I am sorry if I am commenting blind.
By looking at more context in SVN I see that addr1 is already equal to addr, so this has no affect.
Oops, many chunks are missing. I missed that.
Sorry.
Tristan.
Re: [Qemu-devel] [PATCH 13/24] Add target-alpha/machine.c and hw/es40.cfor es40 machine emulation.
In reply to Krumme, ChrisQuoted 7 lines · Chris
Quoted 5 lines
+8C:8F 8C-8F SROM Byte to define misconfigured DIMMs for MMBs +8C – MMB 0
+8D – MMB 1
+8E – MMB 2
+8F – MMB 3There are several mailers involved, but this does not look right. (The mailer I use sucks, but it has a calendar, and proprietary lock in.)
Right, I will fix that.
Tristan.
Re: [Qemu-devel] [PATCH 20/24] Add alpha_cpu_list.
In reply to Krumme, ChrisQuoted 1 line · Chris
Hello Tristan,
Hi,
Quoted 12 lines
target-alpha/translate.c void gen_intermediate_code_pc (CPUState *env, struct TranslationBlock *tb) · line 2476
Quoted 9 lines
target-alpha/translate.c +6
-0+static const struct alpha_def alpha_defs[] = { +#if 0 + {"21064" , IMPLVER_2106x,0 }, + {"21164" ,IMPLVER_21164 ,0 }, +#endif + { "21264", IMPLVER_21264, (AMASK_PREFETCH | AMASK_TRAP |
AMASK_BWXtarget-alpha/translate.c +2
-0+ | AMASK_FIX) }, +};Again thanks for expanding the Alpha support.
Quoted 2 lines
Unless Alpha was completely broken before, I don't think we should drop support for EV4 while adding EV6.
EV4 and EV5 are not dropped. They are not supported by system emulation but I can't see any reason not to add it for linux-user emulation.
Thanks,
Tristan.
Re: [Qemu-devel] [PATCH 11/24] Add ali1543 super IO pci device.
In reply to Krumme, ChrisQuoted 4 lines · Chris
Your commit comment says this is a Super IO.
I think a bit of a comment here about the card, which devices are on the card etc. would help people who don't have one laying around.
Ok, I will add a short description. It is simply a south-bridge:
* DMA
* PIC
* PIT
* kbd
* IDE
* USB
* FDC
* 2 serials ports
* 1 parallel port
* PMU
Quoted 7 lines
Quoted 7 lines
hw/ali1543.c new file +6
-0+ali1543_t *ali1543_init (PCIBus *bus,int devfn,qemu_irq irq) +{ +ali1543_t *ali; +uint8_t *pci_conf; + + ali = (ali1543_t*)pci_register_device(bus, "Ali1543",
sizeof(ali1543_t),
Quoted 8 lines
hw/ali1543.c line 101
Quoted 6 lines
hw/ali1543.c new file +6
-0+ devfn, NULL, NULL); + + pci_conf = ali->pci.config; + +pci_config_set_vendor_id (pci_conf,PCI_VENDOR_ID_AL ); +pci_config_set_device_id (pci_conf,PCI_DEVICE_ID_AL_M1533 );Is this an enhanced version of a 1533? Is this just a typo?
Yes, should be. This is not a typo.
Quoted 1 line
Thanks Chris