Skip to contentSkip to conversation

Prepare QOM support for machines and CPU

PATCH Applied Andreas Färber 20 participants 173 messages Mar 4, 2012 – Mar 24, 2012 Page 2 of 3

Subsystems (5)
lore
Share & tools
lore
#58 lore raw

RFC PATCH v4 38/44 ppc hw/: Don't use CPUState

In reply to Andreas Färber

Scripted conversion:
for file in hw/ppc*.[hc] hw/mpc8544_guts.c hw/spapr*.[hc] hw/virtex_ml507.c hw/xics.c; do
sed -i "s/CPUState/CPUPPCState/g" $file
done

---
 hw/mpc8544_guts.c      |    2 +-
 hw/ppc.c               |  110 ++++++++++++++++++++++++------------------------
 hw/ppc.h               |   28 ++++++------
 hw/ppc405.h            |    8 ++--
 hw/ppc405_uc.c         |   34 +++++++-------
 hw/ppc440_bamboo.c     |    6 +-
 hw/ppc4xx.h            |    8 ++--
 hw/ppc4xx_devs.c       |   10 ++--
 hw/ppc_booke.c         |   20 ++++----
 hw/ppc_newworld.c      |    4 +-
 hw/ppc_oldworld.c      |    4 +-
 hw/ppc_prep.c          |    6 +-
 hw/ppce500_mpc8544ds.c |   12 +++---
 hw/ppce500_spin.c      |    8 ++--
 hw/spapr.c             |   10 ++--
 hw/spapr.h             |    4 +-
 hw/spapr_hcall.c       |   42 +++++++++---------
 hw/spapr_llan.c        |   10 ++--
 hw/spapr_rtas.c        |    4 +-
 hw/spapr_vio.c         |   12 +++---
 hw/spapr_vty.c         |    4 +-
 hw/virtex_ml507.c      |   10 ++--
 hw/xics.c              |   10 ++--
 23 files changed, 183 insertions(+), 183 deletions(-)
hw/mpc8544_guts.c +1 -1
index aeb2de7..13b0ddd 100644
@@ -62,7 +62,7 @@ static uint64_t mpc8544_guts_read(void *opaque, target_phys_addr_t addr,
                                   unsigned size)
 {
     uint32_t value = 0;
-    CPUState *env = cpu_single_env;
+    CPUPPCState *env = cpu_single_env;
 
     addr &= MPC8544_GUTS_MMIO_SIZE - 1;
     switch (addr) {
hw/ppc.c +55 -55

415 lines not on this page · raw message

hw/ppc.h +14 -14
index 9f91170..2f3ea27 100644
@@ -1,4 +1,4 @@
-void ppc_set_irq (CPUState *env, int n_IRQ, int level);
+void ppc_set_irq (CPUPPCState *env, int n_IRQ, int level);
 
 /* PowerPC hardware exceptions management helpers */
 typedef void (*clk_setup_cb)(void *opaque, uint32_t freq);
@@ -43,32 +43,32 @@ struct ppc_tb_t {
                                                */
 
 uint64_t cpu_ppc_get_tb(ppc_tb_t *tb_env, uint64_t vmclk, int64_t tb_offset);
-clk_setup_cb cpu_ppc_tb_init (CPUState *env, uint32_t freq);
+clk_setup_cb cpu_ppc_tb_init (CPUPPCState *env, uint32_t freq);
 /* Embedded PowerPC DCR management */
 typedef uint32_t (*dcr_read_cb)(void *opaque, int dcrn);
 typedef void (*dcr_write_cb)(void *opaque, int dcrn, uint32_t val);
-int ppc_dcr_init (CPUState *env, int (*dcr_read_error)(int dcrn),
+int ppc_dcr_init (CPUPPCState *env, int (*dcr_read_error)(int dcrn),
                   int (*dcr_write_error)(int dcrn));
-int ppc_dcr_register (CPUState *env, int dcrn, void *opaque,
+int ppc_dcr_register (CPUPPCState *env, int dcrn, void *opaque,
                       dcr_read_cb drc_read, dcr_write_cb dcr_write);
-clk_setup_cb ppc_40x_timers_init (CPUState *env, uint32_t freq,
+clk_setup_cb ppc_40x_timers_init (CPUPPCState *env, uint32_t freq,
                                   unsigned int decr_excp);
 
 /* Embedded PowerPC reset */
-void ppc40x_core_reset (CPUState *env);
-void ppc40x_chip_reset (CPUState *env);
-void ppc40x_system_reset (CPUState *env);
+void ppc40x_core_reset (CPUPPCState *env);
+void ppc40x_chip_reset (CPUPPCState *env);
+void ppc40x_system_reset (CPUPPCState *env);
 void PREP_debug_write (void *opaque, uint32_t addr, uint32_t val);
 
 extern CPUWriteMemoryFunc * const PPC_io_write[];
 extern CPUReadMemoryFunc * const PPC_io_read[];
 void PPC_debug_write (void *opaque, uint32_t addr, uint32_t val);
 
-void ppc40x_irq_init (CPUState *env);
-void ppce500_irq_init (CPUState *env);
-void ppc6xx_irq_init (CPUState *env);
-void ppc970_irq_init (CPUState *env);
-void ppcPOWER7_irq_init (CPUState *env);
+void ppc40x_irq_init (CPUPPCState *env);
+void ppce500_irq_init (CPUPPCState *env);
+void ppc6xx_irq_init (CPUPPCState *env);
+void ppc970_irq_init (CPUPPCState *env);
+void ppcPOWER7_irq_init (CPUPPCState *env);
 
 /* PPC machines for OpenBIOS */
 enum {
@@ -89,4 +89,4 @@ enum {
 #define PPC_SERIAL_MM_BAUDBASE 399193
 
 /* ppc_booke.c */
-void ppc_booke_timers_init(CPUState *env, uint32_t freq, uint32_t flags);
+void ppc_booke_timers_init(CPUPPCState *env, uint32_t freq, uint32_t flags);
hw/ppc405.h +4 -4
index d8fdf09..1f5dc5f 100644
@@ -56,23 +56,23 @@ struct ppc4xx_bd_info_t {
 };
 
 /* PowerPC 405 core */
-ram_addr_t ppc405_set_bootinfo (CPUState *env, ppc4xx_bd_info_t *bd,
+ram_addr_t ppc405_set_bootinfo (CPUPPCState *env, ppc4xx_bd_info_t *bd,
                                 uint32_t flags);
 
-CPUState *ppc405cr_init(MemoryRegion *address_space_mem,
+CPUPPCState *ppc405cr_init(MemoryRegion *address_space_mem,
                         MemoryRegion ram_memories[4],
                         target_phys_addr_t ram_bases[4],
                         target_phys_addr_t ram_sizes[4],
                         uint32_t sysclk, qemu_irq **picp,
                         int do_init);
-CPUState *ppc405ep_init(MemoryRegion *address_space_mem,
+CPUPPCState *ppc405ep_init(MemoryRegion *address_space_mem,
                         MemoryRegion ram_memories[2],
                         target_phys_addr_t ram_bases[2],
                         target_phys_addr_t ram_sizes[2],
                         uint32_t sysclk, qemu_irq **picp,
                         int do_init);
 /* IBM STBxxx microcontrollers */
-CPUState *ppc_stb025_init (MemoryRegion ram_memories[2],
+CPUPPCState *ppc_stb025_init (MemoryRegion ram_memories[2],
                            target_phys_addr_t ram_bases[2],
                            target_phys_addr_t ram_sizes[2],
                            uint32_t sysclk, qemu_irq **picp,
hw/ppc405_uc.c +17 -17
index 951b389..6f8342e 100644
@@ -41,7 +41,7 @@
 #define DEBUG_CLOCKS
 //#define DEBUG_CLOCKS_LL
 
-ram_addr_t ppc405_set_bootinfo (CPUState *env, ppc4xx_bd_info_t *bd,
+ram_addr_t ppc405_set_bootinfo (CPUPPCState *env, ppc4xx_bd_info_t *bd,
                                 uint32_t flags)
 {
     ram_addr_t bdloc;
@@ -169,7 +169,7 @@ static void ppc4xx_plb_reset (void *opaque)
     plb->besr = 0x00000000;
 }
 
-static void ppc4xx_plb_init(CPUState *env)
+static void ppc4xx_plb_init(CPUPPCState *env)
 {
     ppc4xx_plb_t *plb;
 
@@ -245,7 +245,7 @@ static void ppc4xx_pob_reset (void *opaque)
     pob->besr[1] = 0x0000000;
 }
 
-static void ppc4xx_pob_init(CPUState *env)
+static void ppc4xx_pob_init(CPUPPCState *env)
 {
     ppc4xx_pob_t *pob;
 
@@ -574,7 +574,7 @@ static void ebc_reset (void *opaque)
     ebc->cfg = 0x80400000;
 }
 
-static void ppc405_ebc_init(CPUState *env)
+static void ppc405_ebc_init(CPUPPCState *env)
 {
     ppc4xx_ebc_t *ebc;
 
@@ -657,7 +657,7 @@ static void ppc405_dma_reset (void *opaque)
     dma->pol = 0x00000000;
 }
 
-static void ppc405_dma_init(CPUState *env, qemu_irq irqs[4])
+static void ppc405_dma_init(CPUPPCState *env, qemu_irq irqs[4])
 {
     ppc405_dma_t *dma;
 
@@ -960,7 +960,7 @@ static void ocm_reset (void *opaque)
     ocm->dsacntl = dsacntl;
 }
 
-static void ppc405_ocm_init(CPUState *env)
+static void ppc405_ocm_init(CPUPPCState *env)
 {
     ppc405_ocm_t *ocm;
 
@@ -1713,7 +1713,7 @@ static void ppc40x_mal_reset (void *opaque)
     mal->txeobisr = 0x00000000;
 }
 
-static void ppc405_mal_init(CPUState *env, qemu_irq irqs[4])
+static void ppc405_mal_init(CPUPPCState *env, qemu_irq irqs[4])
 {
     ppc40x_mal_t *mal;
     int i;
@@ -1764,7 +1764,7 @@ static void ppc405_mal_init(CPUState *env, qemu_irq irqs[4])
 
 /*****************************************************************************/
 /* SPR */
-void ppc40x_core_reset (CPUState *env)
+void ppc40x_core_reset (CPUPPCState *env)
 {
     target_ulong dbsr;
 
@@ -1776,7 +1776,7 @@ void ppc40x_core_reset (CPUState *env)
     env->spr[SPR_40x_DBSR] = dbsr;
 }
 
-void ppc40x_chip_reset (CPUState *env)
+void ppc40x_chip_reset (CPUPPCState *env)
 {
     target_ulong dbsr;
 
@@ -1789,13 +1789,13 @@ void ppc40x_chip_reset (CPUState *env)
     env->spr[SPR_40x_DBSR] = dbsr;
 }
 
-void ppc40x_system_reset (CPUState *env)
+void ppc40x_system_reset (CPUPPCState *env)
 {
     printf("Reset PowerPC system\n");
     qemu_system_reset_request();
 }
 
-void store_40x_dbcr0 (CPUState *env, uint32_t val)
+void store_40x_dbcr0 (CPUPPCState *env, uint32_t val)
 {
     switch ((val >> 28) & 0x3) {
     case 0x0:
@@ -2066,7 +2066,7 @@ static void ppc405cr_clk_init (ppc405cr_cpc_t *cpc)
     cpc->psr |= D << 17;
 }
 
-static void ppc405cr_cpc_init (CPUState *env, clk_setup_t clk_setup[7],
+static void ppc405cr_cpc_init (CPUPPCState *env, clk_setup_t clk_setup[7],
                                uint32_t sysclk)
 {
     ppc405cr_cpc_t *cpc;
@@ -2096,7 +2096,7 @@ static void ppc405cr_cpc_init (CPUState *env, clk_setup_t clk_setup[7],
     qemu_register_reset(ppc405cr_cpc_reset, cpc);
 }
 
-CPUState *ppc405cr_init(MemoryRegion *address_space_mem,
+CPUPPCState *ppc405cr_init(MemoryRegion *address_space_mem,
                         MemoryRegion ram_memories[4],
                         target_phys_addr_t ram_bases[4],
                         target_phys_addr_t ram_sizes[4],
@@ -2105,7 +2105,7 @@ CPUState *ppc405cr_init(MemoryRegion *address_space_mem,
 {
     clk_setup_t clk_setup[PPC405CR_CLK_NB];
     qemu_irq dma_irqs[4];
-    CPUState *env;
+    CPUPPCState *env;
     qemu_irq *pic, *irqs;
 
     memset(clk_setup, 0, sizeof(clk_setup));
@@ -2408,7 +2408,7 @@ static void ppc405ep_cpc_reset (void *opaque)
 }
 
 /* XXX: sysclk should be between 25 and 100 MHz */
-static void ppc405ep_cpc_init (CPUState *env, clk_setup_t clk_setup[8],
+static void ppc405ep_cpc_init (CPUPPCState *env, clk_setup_t clk_setup[8],
                                uint32_t sysclk)
 {
     ppc405ep_cpc_t *cpc;
@@ -2445,7 +2445,7 @@ static void ppc405ep_cpc_init (CPUState *env, clk_setup_t clk_setup[8],
 #endif
 }
 
-CPUState *ppc405ep_init(MemoryRegion *address_space_mem,
+CPUPPCState *ppc405ep_init(MemoryRegion *address_space_mem,
                         MemoryRegion ram_memories[2],
                         target_phys_addr_t ram_bases[2],
                         target_phys_addr_t ram_sizes[2],
@@ -2454,7 +2454,7 @@ CPUState *ppc405ep_init(MemoryRegion *address_space_mem,
 {
     clk_setup_t clk_setup[PPC405EP_CLK_NB], tlb_clk_setup;
     qemu_irq dma_irqs[4], gpt_irqs[5], mal_irqs[4];
-    CPUState *env;
+    CPUPPCState *env;
     qemu_irq *pic, *irqs;
 
     memset(clk_setup, 0, sizeof(clk_setup));
hw/ppc440_bamboo.c +3 -3
index 835e36d..220c81d 100644
@@ -121,7 +121,7 @@ out:
 }
 
 /* Create reset TLB entries for BookE, spanning the 32bit addr space.  */
-static void mmubooke_create_initial_mapping(CPUState *env,
+static void mmubooke_create_initial_mapping(CPUPPCState *env,
                                      target_ulong va,
                                      target_phys_addr_t pa)
 {
@@ -145,7 +145,7 @@ static void mmubooke_create_initial_mapping(CPUState *env,
 
 static void main_cpu_reset(void *opaque)
 {
-    CPUState *env = opaque;
+    CPUPPCState *env = opaque;
 
     cpu_state_reset(env);
     env->gpr[1] = (16<<20) - 8;
@@ -172,7 +172,7 @@ static void bamboo_init(ram_addr_t ram_size,
     qemu_irq *pic;
     qemu_irq *irqs;
     PCIBus *pcibus;
-    CPUState *env;
+    CPUPPCState *env;
     uint64_t elf_entry;
     uint64_t elf_lowaddr;
     target_phys_addr_t loadaddr = 0;
hw/ppc4xx.h +4 -4
index f969e44..b511020 100644
@@ -28,7 +28,7 @@
 #include "pci.h"
 
 /* PowerPC 4xx core initialization */
-CPUState *ppc4xx_init (const char *cpu_model,
+CPUPPCState *ppc4xx_init (const char *cpu_model,
                        clk_setup_t *cpu_clk, clk_setup_t *tb_clk,
                        uint32_t sysclk);
 
@@ -38,7 +38,7 @@ enum {
     PPCUIC_OUTPUT_CINT = 1,
     PPCUIC_OUTPUT_NB,
 };
-qemu_irq *ppcuic_init (CPUState *env, qemu_irq *irqs,
+qemu_irq *ppcuic_init (CPUPPCState *env, qemu_irq *irqs,
                        uint32_t dcr_base, int has_ssr, int has_vr);
 
 ram_addr_t ppc4xx_sdram_adjust(ram_addr_t ram_size, int nr_banks,
@@ -47,13 +47,13 @@ ram_addr_t ppc4xx_sdram_adjust(ram_addr_t ram_size, int nr_banks,
                                target_phys_addr_t ram_sizes[],
                                const unsigned int sdram_bank_sizes[]);
 
-void ppc4xx_sdram_init (CPUState *env, qemu_irq irq, int nbanks,
+void ppc4xx_sdram_init (CPUPPCState *env, qemu_irq irq, int nbanks,
                         MemoryRegion ram_memories[],
                         target_phys_addr_t *ram_bases,
                         target_phys_addr_t *ram_sizes,
                         int do_init);
 
-PCIBus *ppc4xx_pci_init(CPUState *env, qemu_irq pci_irqs[4],
+PCIBus *ppc4xx_pci_init(CPUPPCState *env, qemu_irq pci_irqs[4],
                         target_phys_addr_t config_space,
                         target_phys_addr_t int_ack,
                         target_phys_addr_t special_cycle,
hw/ppc4xx_devs.c +5 -5
index 2311162..00e36f4 100644
@@ -40,18 +40,18 @@
 
 static void ppc4xx_reset(void *opaque)
 {
-    CPUState *env = opaque;
+    CPUPPCState *env = opaque;
 
     cpu_state_reset(env);
 }
 
 /*****************************************************************************/
 /* Generic PowerPC 4xx processor instantiation */
-CPUState *ppc4xx_init (const char *cpu_model,
+CPUPPCState *ppc4xx_init (const char *cpu_model,
                        clk_setup_t *cpu_clk, clk_setup_t *tb_clk,
                        uint32_t sysclk)
 {
-    CPUState *env;
+    CPUPPCState *env;
 
     /* init CPUs */
     env = cpu_init(cpu_model);
@@ -295,7 +295,7 @@ static void ppcuic_reset (void *opaque)
     }
 }
 
-qemu_irq *ppcuic_init (CPUState *env, qemu_irq *irqs,
+qemu_irq *ppcuic_init (CPUPPCState *env, qemu_irq *irqs,
                        uint32_t dcr_base, int has_ssr, int has_vr)
 {
     ppcuic_t *uic;
@@ -641,7 +641,7 @@ static void sdram_reset (void *opaque)
     sdram->cfg = 0x00800000;
 }
 
-void ppc4xx_sdram_init (CPUState *env, qemu_irq irq, int nbanks,
+void ppc4xx_sdram_init (CPUPPCState *env, qemu_irq irq, int nbanks,
                         MemoryRegion *ram_memories,
                         target_phys_addr_t *ram_bases,
                         target_phys_addr_t *ram_sizes,
hw/ppc_booke.c +10 -10
index 8871945..d51e7fa 100644
@@ -71,7 +71,7 @@ struct booke_timer_t {
     uint32_t flags;
 };
 
-static void booke_update_irq(CPUState *env)
+static void booke_update_irq(CPUPPCState *env)
 {
     ppc_set_irq(env, PPC_INTERRUPT_DECR,
                 (env->spr[SPR_BOOKE_TSR] & TSR_DIS
@@ -88,7 +88,7 @@ static void booke_update_irq(CPUState *env)
 
 /* Return the location of the bit of time base at which the FIT will raise an
    interrupt */
-static uint8_t booke_get_fit_target(CPUState *env, ppc_tb_t *tb_env)
+static uint8_t booke_get_fit_target(CPUPPCState *env, ppc_tb_t *tb_env)
 {
     uint8_t fp = (env->spr[SPR_BOOKE_TCR] & TCR_FP_MASK) >> TCR_FP_SHIFT;
 
@@ -106,7 +106,7 @@ static uint8_t booke_get_fit_target(CPUState *env, ppc_tb_t *tb_env)
 
 /* Return the location of the bit of time base at which the WDT will raise an
    interrupt */
-static uint8_t booke_get_wdt_target(CPUState *env, ppc_tb_t *tb_env)
+static uint8_t booke_get_wdt_target(CPUPPCState *env, ppc_tb_t *tb_env)
 {
     uint8_t wp = (env->spr[SPR_BOOKE_TCR] & TCR_WP_MASK) >> TCR_WP_SHIFT;
 
@@ -122,7 +122,7 @@ static uint8_t booke_get_wdt_target(CPUState *env, ppc_tb_t *tb_env)
     return wp;
 }
 
-static void booke_update_fixed_timer(CPUState         *env,
+static void booke_update_fixed_timer(CPUPPCState         *env,
                                      uint8_t           target_bit,
                                      uint64_t          *next,
                                      struct QEMUTimer *timer)
@@ -153,7 +153,7 @@ static void booke_update_fixed_timer(CPUState         *env,
 
 static void booke_decr_cb(void *opaque)
 {
-    CPUState *env = opaque;
+    CPUPPCState *env = opaque;
 
     env->spr[SPR_BOOKE_TSR] |= TSR_DIS;
     booke_update_irq(env);
@@ -166,7 +166,7 @@ static void booke_decr_cb(void *opaque)
 
 static void booke_fit_cb(void *opaque)
 {
-    CPUState *env;
+    CPUPPCState *env;
     ppc_tb_t *tb_env;
     booke_timer_t *booke_timer;
 
@@ -185,7 +185,7 @@ static void booke_fit_cb(void *opaque)
 
 static void booke_wdt_cb(void *opaque)
 {
-    CPUState *env;
+    CPUPPCState *env;
     ppc_tb_t *tb_env;
     booke_timer_t *booke_timer;
 
@@ -203,13 +203,13 @@ static void booke_wdt_cb(void *opaque)
                              booke_timer->wdt_timer);
 }
 
-void store_booke_tsr(CPUState *env, target_ulong val)
+void store_booke_tsr(CPUPPCState *env, target_ulong val)
 {
     env->spr[SPR_BOOKE_TSR] &= ~val;
     booke_update_irq(env);
 }
 
-void store_booke_tcr(CPUState *env, target_ulong val)
+void store_booke_tcr(CPUPPCState *env, target_ulong val)
 {
     ppc_tb_t *tb_env = env->tb_env;
     booke_timer_t *booke_timer = tb_env->opaque;
@@ -231,7 +231,7 @@ void store_booke_tcr(CPUState *env, target_ulong val)
 
 }
 
-void ppc_booke_timers_init(CPUState *env, uint32_t freq, uint32_t flags)
+void ppc_booke_timers_init(CPUPPCState *env, uint32_t freq, uint32_t flags)
 {
     ppc_tb_t *tb_env;
     booke_timer_t *booke_timer;
hw/ppc_newworld.c +2 -2
index fd8e21d..c60cfa0 100644
@@ -124,7 +124,7 @@ static target_phys_addr_t round_page(target_phys_addr_t addr)
 
 static void ppc_core99_reset(void *opaque)
 {
-    CPUState *env = opaque;
+    CPUPPCState *env = opaque;
 
     cpu_state_reset(env);
 }
@@ -137,7 +137,7 @@ static void ppc_core99_init (ram_addr_t ram_size,
                              const char *initrd_filename,
                              const char *cpu_model)
 {
-    CPUState *env = NULL;
+    CPUPPCState *env = NULL;
     char *filename;
     qemu_irq *pic, **openpic_irqs;
     MemoryRegion *unin_memory = g_new(MemoryRegion, 1);
hw/ppc_oldworld.c +2 -2
index 085b825..36aaf97 100644
@@ -68,7 +68,7 @@ static target_phys_addr_t round_page(target_phys_addr_t addr)
 
 static void ppc_heathrow_reset(void *opaque)
 {
-    CPUState *env = opaque;
+    CPUPPCState *env = opaque;
 
     cpu_state_reset(env);
 }
@@ -81,7 +81,7 @@ static void ppc_heathrow_init (ram_addr_t ram_size,
                                const char *cpu_model)
 {
     MemoryRegion *sysmem = get_system_memory();
-    CPUState *env = NULL;
+    CPUPPCState *env = NULL;
     char *filename;
     qemu_irq *pic, **heathrow_irqs;
     int linux_boot, i;
hw/ppc_prep.c +3 -3
index c5f2542..7a92f49 100644
@@ -464,7 +464,7 @@ static const MemoryRegionOps PPC_prep_io_ops = {
 
 static void cpu_request_exit(void *opaque, int irq, int level)
 {
-    CPUState *env = cpu_single_env;
+    CPUPPCState *env = cpu_single_env;
 
     if (env && level) {
         cpu_exit(env);
@@ -473,7 +473,7 @@ static void cpu_request_exit(void *opaque, int irq, int level)
 
 static void ppc_prep_reset(void *opaque)
 {
-    CPUState *env = opaque;
+    CPUPPCState *env = opaque;
 
     cpu_state_reset(env);
 }
@@ -487,7 +487,7 @@ static void ppc_prep_init (ram_addr_t ram_size,
                            const char *cpu_model)
 {
     MemoryRegion *sysmem = get_system_memory();
-    CPUState *env = NULL;
+    CPUPPCState *env = NULL;
     char *filename;
     nvram_t nvram;
     M48t59State *m48t59;
hw/ppce500_mpc8544ds.c +6 -6
index 752aed9..5ee8cb3 100644
@@ -58,7 +58,7 @@ struct boot_info
     uint32_t entry;
 };
 
-static int mpc8544_load_device_tree(CPUState *env,
+static int mpc8544_load_device_tree(CPUPPCState *env,
                                     target_phys_addr_t addr,
                                     uint32_t ramsize,
                                     target_phys_addr_t initrd_base,
@@ -178,7 +178,7 @@ static inline target_phys_addr_t booke206_page_size_to_tlb(uint64_t size)
     return ffs(size >> 10) - 1;
 }
 
-static void mmubooke_create_initial_mapping(CPUState *env,
+static void mmubooke_create_initial_mapping(CPUPPCState *env,
                                      target_ulong va,
                                      target_phys_addr_t pa)
 {
@@ -196,7 +196,7 @@ static void mmubooke_create_initial_mapping(CPUState *env,
 
 static void mpc8544ds_cpu_reset_sec(void *opaque)
 {
-    CPUState *env = opaque;
+    CPUPPCState *env = opaque;
 
     cpu_state_reset(env);
 
@@ -208,7 +208,7 @@ static void mpc8544ds_cpu_reset_sec(void *opaque)
 
 static void mpc8544ds_cpu_reset(void *opaque)
 {
-    CPUState *env = opaque;
+    CPUPPCState *env = opaque;
     struct boot_info *bi = env->load_info;
 
     cpu_state_reset(env);
@@ -231,7 +231,7 @@ static void mpc8544ds_init(ram_addr_t ram_size,
     MemoryRegion *address_space_mem = get_system_memory();
     MemoryRegion *ram = g_new(MemoryRegion, 1);
     PCIBus *pci_bus;
-    CPUState *env = NULL;
+    CPUPPCState *env = NULL;
     uint64_t elf_entry;
     uint64_t elf_lowaddr;
     target_phys_addr_t entry=0;
@@ -244,7 +244,7 @@ static void mpc8544ds_init(ram_addr_t ram_size,
     unsigned int pci_irq_nrs[4] = {1, 2, 3, 4};
     qemu_irq **irqs, *mpic;
     DeviceState *dev;
-    CPUState *firstenv = NULL;
+    CPUPPCState *firstenv = NULL;
 
     /* Setup CPUs */
     if (cpu_model == NULL) {
hw/ppce500_spin.c +4 -4
index 6b8a189..268f5fd 100644
@@ -49,7 +49,7 @@ typedef struct spin_state {
 } SpinState;
 
 typedef struct spin_kick {
-    CPUState *env;
+    CPUPPCState *env;
     SpinInfo *spin;
 } SpinKick;
 
@@ -73,7 +73,7 @@ static inline target_phys_addr_t booke206_page_size_to_tlb(uint64_t size)
     return (ffs(size >> 10) - 1) >> 1;
 }
 
-static void mmubooke_create_initial_mapping(CPUState *env,
+static void mmubooke_create_initial_mapping(CPUPPCState *env,
                                      target_ulong va,
                                      target_phys_addr_t pa,
                                      target_phys_addr_t len)
@@ -91,7 +91,7 @@ static void mmubooke_create_initial_mapping(CPUState *env,
 static void spin_kick(void *data)
 {
     SpinKick *kick = data;
-    CPUState *env = kick->env;
+    CPUPPCState *env = kick->env;
     SpinInfo *curspin = kick->spin;
     target_phys_addr_t map_size = 64 * 1024 * 1024;
     target_phys_addr_t map_start;
@@ -121,7 +121,7 @@ static void spin_write(void *opaque, target_phys_addr_t addr, uint64_t value,
 {
     SpinState *s = opaque;
     int env_idx = addr / sizeof(SpinInfo);
-    CPUState *env;
+    CPUPPCState *env;
     SpinInfo *curspin = &s->spin[env_idx];
     uint8_t *curspin_p = (uint8_t*)curspin;
 
hw/spapr.c +5 -5
index 3f9d87c..3719e0e 100644
@@ -110,7 +110,7 @@ qemu_irq spapr_allocate_irq(uint32_t hint, uint32_t *irq_num)
 static int spapr_set_associativity(void *fdt, sPAPREnvironment *spapr)
 {
     int ret = 0, offset;
-    CPUState *env;
+    CPUPPCState *env;
     char cpu_model[32];
     int smt = kvmppc_smt_threads();
 
@@ -155,7 +155,7 @@ static void *spapr_create_fdt_skel(const char *cpu_model,
                                    long hash_shift)
 {
     void *fdt;
-    CPUState *env;
+    CPUPPCState *env;
     uint64_t mem_reg_property[2];
     uint32_t start_prop = cpu_to_be32(initrd_base);
     uint32_t end_prop = cpu_to_be32(initrd_base + initrd_size);
@@ -476,7 +476,7 @@ static uint64_t translate_kernel_address(void *opaque, uint64_t addr)
     return (addr & 0x0fffffff) + KERNEL_LOAD_ADDR;
 }
 
-static void emulate_spapr_hypercall(CPUState *env)
+static void emulate_spapr_hypercall(CPUPPCState *env)
 {
     env->gpr[3] = spapr_hypercall(env, env->gpr[3], &env->gpr[4]);
 }
@@ -504,7 +504,7 @@ static void spapr_reset(void *opaque)
 
 static void spapr_cpu_reset(void *opaque)
 {
-    CPUState *env = opaque;
+    CPUPPCState *env = opaque;
 
     cpu_state_reset(env);
 }
@@ -517,7 +517,7 @@ static void ppc_spapr_init(ram_addr_t ram_size,
                            const char *initrd_filename,
                            const char *cpu_model)
 {
-    CPUState *env;
+    CPUPPCState *env;
     int i;
     MemoryRegion *sysmem = get_system_memory();
     MemoryRegion *ram = g_new(MemoryRegion, 1);
hw/spapr.h +2 -2
index e946a34..a41641f 100644
@@ -278,12 +278,12 @@ extern sPAPREnvironment *spapr;
     do { } while (0)
 #endif
 
-typedef target_ulong (*spapr_hcall_fn)(CPUState *env, sPAPREnvironment *spapr,
+typedef target_ulong (*spapr_hcall_fn)(CPUPPCState *env, sPAPREnvironment *spapr,
                                        target_ulong opcode,
                                        target_ulong *args);
 
 void spapr_register_hypercall(target_ulong opcode, spapr_hcall_fn fn);
-target_ulong spapr_hypercall(CPUState *env, target_ulong opcode,
+target_ulong spapr_hypercall(CPUPPCState *env, target_ulong opcode,
                              target_ulong *args);
 
 qemu_irq spapr_allocate_irq(uint32_t hint, uint32_t *irq_num);
hw/spapr_hcall.c +21 -21

167 lines not on this page · raw message

hw/spapr_llan.c +5 -5
index 77d4047..cfc7778 100644
@@ -254,7 +254,7 @@ static int check_bd(VIOsPAPRVLANDevice *dev, vlan_bd_t bd,
     return 0;
 }
 
-static target_ulong h_register_logical_lan(CPUState *env,
+static target_ulong h_register_logical_lan(CPUPPCState *env,
                                            sPAPREnvironment *spapr,
                                            target_ulong opcode,
                                            target_ulong *args)
@@ -320,7 +320,7 @@ static target_ulong h_register_logical_lan(CPUState *env,
 }
 
 
-static target_ulong h_free_logical_lan(CPUState *env, sPAPREnvironment *spapr,
+static target_ulong h_free_logical_lan(CPUPPCState *env, sPAPREnvironment *spapr,
                                        target_ulong opcode, target_ulong *args)
 {
     target_ulong reg = args[0];
@@ -343,7 +343,7 @@ static target_ulong h_free_logical_lan(CPUState *env, sPAPREnvironment *spapr,
     return H_SUCCESS;
 }
 
-static target_ulong h_add_logical_lan_buffer(CPUState *env,
+static target_ulong h_add_logical_lan_buffer(CPUPPCState *env,
                                              sPAPREnvironment *spapr,
                                              target_ulong opcode,
                                              target_ulong *args)
@@ -392,7 +392,7 @@ static target_ulong h_add_logical_lan_buffer(CPUState *env,
     return H_SUCCESS;
 }
 
-static target_ulong h_send_logical_lan(CPUState *env, sPAPREnvironment *spapr,
+static target_ulong h_send_logical_lan(CPUPPCState *env, sPAPREnvironment *spapr,
                                        target_ulong opcode, target_ulong *args)
 {
     target_ulong reg = args[0];
@@ -461,7 +461,7 @@ static target_ulong h_send_logical_lan(CPUState *env, sPAPREnvironment *spapr,
     return H_SUCCESS;
 }
 
-static target_ulong h_multicast_ctrl(CPUState *env, sPAPREnvironment *spapr,
+static target_ulong h_multicast_ctrl(CPUPPCState *env, sPAPREnvironment *spapr,
                                      target_ulong opcode, target_ulong *args)
 {
     target_ulong reg = args[0];
hw/spapr_rtas.c +2 -2
index c0723b3..0946585 100644
@@ -118,7 +118,7 @@ static void rtas_query_cpu_stopped_state(sPAPREnvironment *spapr,
                                          uint32_t nret, target_ulong rets)
 {
     target_ulong id;
-    CPUState *env;
+    CPUPPCState *env;
 
     if (nargs != 1 || nret != 2) {
         rtas_st(rets, 0, -3);
@@ -151,7 +151,7 @@ static void rtas_start_cpu(sPAPREnvironment *spapr,
                            uint32_t nret, target_ulong rets)
 {
     target_ulong id, start, r3;
-    CPUState *env;
+    CPUPPCState *env;
 
     if (nargs != 3 || nret != 1) {
         rtas_st(rets, 0, -3);
hw/spapr_vio.c +6 -6
index ea317ef..2fb3cee 100644
@@ -194,7 +194,7 @@ static void rtce_init(VIOsPAPRDevice *dev)
     }
 }
 
-static target_ulong h_put_tce(CPUState *env, sPAPREnvironment *spapr,
+static target_ulong h_put_tce(CPUPPCState *env, sPAPREnvironment *spapr,
                               target_ulong opcode, target_ulong *args)
 {
     target_ulong liobn = args[0];
@@ -405,7 +405,7 @@ uint64_t ldq_tce(VIOsPAPRDevice *dev, uint64_t taddr)
 /*
  * CRQ handling
  */
-static target_ulong h_reg_crq(CPUState *env, sPAPREnvironment *spapr,
+static target_ulong h_reg_crq(CPUPPCState *env, sPAPREnvironment *spapr,
                               target_ulong opcode, target_ulong *args)
 {
     target_ulong reg = args[0];
@@ -453,7 +453,7 @@ static target_ulong h_reg_crq(CPUState *env, sPAPREnvironment *spapr,
     return H_SUCCESS;
 }
 
-static target_ulong h_free_crq(CPUState *env, sPAPREnvironment *spapr,
+static target_ulong h_free_crq(CPUPPCState *env, sPAPREnvironment *spapr,
                                target_ulong opcode, target_ulong *args)
 {
     target_ulong reg = args[0];
@@ -474,7 +474,7 @@ static target_ulong h_free_crq(CPUState *env, sPAPREnvironment *spapr,
     return H_SUCCESS;
 }
 
-static target_ulong h_send_crq(CPUState *env, sPAPREnvironment *spapr,
+static target_ulong h_send_crq(CPUPPCState *env, sPAPREnvironment *spapr,
                                target_ulong opcode, target_ulong *args)
 {
     target_ulong reg = args[0];
@@ -498,7 +498,7 @@ static target_ulong h_send_crq(CPUState *env, sPAPREnvironment *spapr,
     return H_HARDWARE;
 }
 
-static target_ulong h_enable_crq(CPUState *env, sPAPREnvironment *spapr,
+static target_ulong h_enable_crq(CPUPPCState *env, sPAPREnvironment *spapr,
                                  target_ulong opcode, target_ulong *args)
 {
     target_ulong reg = args[0];
@@ -680,7 +680,7 @@ static int spapr_vio_busdev_init(DeviceState *qdev)
     return pc->init(dev);
 }
 
-static target_ulong h_vio_signal(CPUState *env, sPAPREnvironment *spapr,
+static target_ulong h_vio_signal(CPUPPCState *env, sPAPREnvironment *spapr,
                                  target_ulong opcode,
                                  target_ulong *args)
 {
hw/spapr_vty.c +2 -2
index 3efe242..60e22b1 100644
@@ -72,7 +72,7 @@ static int spapr_vty_init(VIOsPAPRDevice *sdev)
 /* Forward declaration */
 static VIOsPAPRDevice *vty_lookup(sPAPREnvironment *spapr, target_ulong reg);
 
-static target_ulong h_put_term_char(CPUState *env, sPAPREnvironment *spapr,
+static target_ulong h_put_term_char(CPUPPCState *env, sPAPREnvironment *spapr,
                                     target_ulong opcode, target_ulong *args)
 {
     target_ulong reg = args[0];
@@ -99,7 +99,7 @@ static target_ulong h_put_term_char(CPUState *env, sPAPREnvironment *spapr,
     return H_SUCCESS;
 }
 
-static target_ulong h_get_term_char(CPUState *env, sPAPREnvironment *spapr,
+static target_ulong h_get_term_char(CPUPPCState *env, sPAPREnvironment *spapr,
                                     target_ulong opcode, target_ulong *args)
 {
     target_ulong reg = args[0];
hw/virtex_ml507.c +5 -5
index e672490..4a133b5 100644
@@ -56,7 +56,7 @@ static struct boot_info
 } boot_info;
 
 /* Create reset TLB entries for BookE, spanning the 32bit addr space.  */
-static void mmubooke_create_initial_mapping(CPUState *env,
+static void mmubooke_create_initial_mapping(CPUPPCState *env,
                                      target_ulong va,
                                      target_phys_addr_t pa)
 {
@@ -78,12 +78,12 @@ static void mmubooke_create_initial_mapping(CPUState *env,
     tlb->PID = 0;
 }
 
-static CPUState *ppc440_init_xilinx(ram_addr_t *ram_size,
+static CPUPPCState *ppc440_init_xilinx(ram_addr_t *ram_size,
                                     int do_init,
                                     const char *cpu_model,
                                     uint32_t sysclk)
 {
-    CPUState *env;
+    CPUPPCState *env;
     qemu_irq *irqs;
 
     env = cpu_init(cpu_model);
@@ -106,7 +106,7 @@ static CPUState *ppc440_init_xilinx(ram_addr_t *ram_size,
 
 static void main_cpu_reset(void *opaque)
 {
-    CPUState *env = opaque;
+    CPUPPCState *env = opaque;
     struct boot_info *bi = env->load_info;
 
     cpu_state_reset(env);
@@ -188,7 +188,7 @@ static void virtex_init(ram_addr_t ram_size,
 {
     MemoryRegion *address_space_mem = get_system_memory();
     DeviceState *dev;
-    CPUState *env;
+    CPUPPCState *env;
     target_phys_addr_t ram_base = 0;
     DriveInfo *dinfo;
     MemoryRegion *phys_ram = g_new(MemoryRegion, 1);
hw/xics.c +5 -5
index 1c5eaa4..f7963f3 100644
@@ -268,7 +268,7 @@ qemu_irq xics_find_qirq(struct icp_state *icp, int irq)
     return icp->ics->qirqs[irq - icp->ics->offset];
 }
 
-static target_ulong h_cppr(CPUState *env, sPAPREnvironment *spapr,
+static target_ulong h_cppr(CPUPPCState *env, sPAPREnvironment *spapr,
                            target_ulong opcode, target_ulong *args)
 {
     target_ulong cppr = args[0];
@@ -277,7 +277,7 @@ static target_ulong h_cppr(CPUState *env, sPAPREnvironment *spapr,
     return H_SUCCESS;
 }
 
-static target_ulong h_ipi(CPUState *env, sPAPREnvironment *spapr,
+static target_ulong h_ipi(CPUPPCState *env, sPAPREnvironment *spapr,
                           target_ulong opcode, target_ulong *args)
 {
     target_ulong server = args[0];
@@ -292,7 +292,7 @@ static target_ulong h_ipi(CPUState *env, sPAPREnvironment *spapr,
 
 }
 
-static target_ulong h_xirr(CPUState *env, sPAPREnvironment *spapr,
+static target_ulong h_xirr(CPUPPCState *env, sPAPREnvironment *spapr,
                            target_ulong opcode, target_ulong *args)
 {
     uint32_t xirr = icp_accept(spapr->icp->ss + env->cpu_index);
@@ -301,7 +301,7 @@ static target_ulong h_xirr(CPUState *env, sPAPREnvironment *spapr,
     return H_SUCCESS;
 }
 
-static target_ulong h_eoi(CPUState *env, sPAPREnvironment *spapr,
+static target_ulong h_eoi(CPUPPCState *env, sPAPREnvironment *spapr,
                           target_ulong opcode, target_ulong *args)
 {
     target_ulong xirr = args[0];
@@ -424,7 +424,7 @@ static void rtas_int_on(sPAPREnvironment *spapr, uint32_t token,
 
 struct icp_state *xics_system_init(int nr_irqs)
 {
-    CPUState *env;
+    CPUPPCState *env;
     int max_server_num;
     int i;
     struct icp_state *icp;
Signature · 1 line
1.7.7
#59 lore raw

RFC PATCH v4 39/44 s390x hw/: Don't use CPUState

In reply to Andreas Färber

Scripted conversion:
for file in hw/s390-*.[hc]; do
sed -i "s/CPUState/CPUS390XState/g" $file
done

---
 hw/s390-virtio-bus.c |    6 +++---
 hw/s390-virtio.c     |   16 ++++++++--------
 2 files changed, 11 insertions(+), 11 deletions(-)
hw/s390-virtio-bus.c +3 -3
index c450e4b..be1f5f1 100644
@@ -85,7 +85,7 @@ VirtIOS390Bus *s390_virtio_bus_init(ram_addr_t *ram_size)
     return bus;
 }
 
-static void s390_virtio_irq(CPUState *env, int config_change, uint64_t token)
+static void s390_virtio_irq(CPUS390XState *env, int config_change, uint64_t token)
 {
     if (kvm_enabled()) {
         kvm_s390_virtio_irq(env, config_change, token);
@@ -116,7 +116,7 @@ static int s390_virtio_device_init(VirtIOS390Device *dev, VirtIODevice *vdev)
     s390_virtio_device_sync(dev);
 
     if (dev->qdev.hotplugged) {
-        CPUState *env = s390_cpu_addr2state(0);
+        CPUS390XState *env = s390_cpu_addr2state(0);
         s390_virtio_irq(env, VIRTIO_PARAM_DEV_ADD, dev->dev_offs);
     }
 
@@ -331,7 +331,7 @@ static void virtio_s390_notify(void *opaque, uint16_t vector)
 {
     VirtIOS390Device *dev = (VirtIOS390Device*)opaque;
     uint64_t token = s390_virtio_device_vq_token(dev, vector);
-    CPUState *env = s390_cpu_addr2state(0);
+    CPUS390XState *env = s390_cpu_addr2state(0);
 
     s390_virtio_irq(env, 0, token);
 }
hw/s390-virtio.c +8 -8
index 15e3ef3..1ebe70d 100644
@@ -61,9 +61,9 @@
 #define MAX_BLK_DEVS                    10
 
 static VirtIOS390Bus *s390_bus;
-static CPUState **ipi_states;
+static CPUS390XState **ipi_states;
 
-CPUState *s390_cpu_addr2state(uint16_t cpu_addr)
+CPUS390XState *s390_cpu_addr2state(uint16_t cpu_addr)
 {
     if (cpu_addr >= smp_cpus) {
         return NULL;
@@ -72,7 +72,7 @@ CPUState *s390_cpu_addr2state(uint16_t cpu_addr)
     return ipi_states[cpu_addr];
 }
 
-int s390_virtio_hypercall(CPUState *env, uint64_t mem, uint64_t hypercall)
+int s390_virtio_hypercall(CPUS390XState *env, uint64_t mem, uint64_t hypercall)
 {
     int r = 0, i;
 
@@ -129,7 +129,7 @@ int s390_virtio_hypercall(CPUState *env, uint64_t mem, uint64_t hypercall)
  */
 static unsigned s390_running_cpus;
 
-void s390_add_running_cpu(CPUState *env)
+void s390_add_running_cpu(CPUS390XState *env)
 {
     if (env->halted) {
         s390_running_cpus++;
@@ -138,7 +138,7 @@ void s390_add_running_cpu(CPUState *env)
     }
 }
 
-unsigned s390_del_running_cpu(CPUState *env)
+unsigned s390_del_running_cpu(CPUS390XState *env)
 {
     if (env->halted == 0) {
         assert(s390_running_cpus >= 1);
@@ -157,7 +157,7 @@ static void s390_init(ram_addr_t my_ram_size,
                       const char *initrd_filename,
                       const char *cpu_model)
 {
-    CPUState *env = NULL;
+    CPUS390XState *env = NULL;
     MemoryRegion *sysmem = get_system_memory();
     MemoryRegion *ram = g_new(MemoryRegion, 1);
     ram_addr_t kernel_size = 0;
@@ -205,10 +205,10 @@ static void s390_init(ram_addr_t my_ram_size,
         cpu_model = "host";
     }
 
-    ipi_states = g_malloc(sizeof(CPUState *) * smp_cpus);
+    ipi_states = g_malloc(sizeof(CPUS390XState *) * smp_cpus);
 
     for (i = 0; i < smp_cpus; i++) {
-        CPUState *tmp_env;
+        CPUS390XState *tmp_env;
 
         tmp_env = cpu_init(cpu_model);
         if (!env) {
Signature · 1 line
1.7.7
#60 lore raw

RFC PATCH v4 40/44 sh4 hw/: Don't use CPUState

In reply to Andreas Färber

Scripted conversion:
for file in hw/sh.h hw/shix.c hw/r2d.c; do
sed -i "s/CPUState/CPUSH4State/g" $file
done

---
 hw/r2d.c  |    6 +++---
 hw/sh.h   |    2 +-
 hw/shix.c |    2 +-
 3 files changed, 5 insertions(+), 5 deletions(-)
hw/r2d.c +3 -3
index ae327a7..c55de01 100644
@@ -192,14 +192,14 @@ static qemu_irq *r2d_fpga_init(MemoryRegion *sysmem,
 }
 
 typedef struct ResetData {
-    CPUState *env;
+    CPUSH4State *env;
     uint32_t vector;
 } ResetData;
 
 static void main_cpu_reset(void *opaque)
 {
     ResetData *s = (ResetData *)opaque;
-    CPUState *env = s->env;
+    CPUSH4State *env = s->env;
 
     cpu_state_reset(env);
     env->pc = s->vector;
@@ -224,7 +224,7 @@ static void r2d_init(ram_addr_t ram_size,
 	      const char *kernel_filename, const char *kernel_cmdline,
 	      const char *initrd_filename, const char *cpu_model)
 {
-    CPUState *env;
+    CPUSH4State *env;
     ResetData *reset_info;
     struct SH7750State *s;
     MemoryRegion *sdram = g_new(MemoryRegion, 1);
hw/sh.h +1 -1
index 6488db2..40df18c 100644
@@ -11,7 +11,7 @@
 struct SH7750State;
 struct MemoryRegion;
 
-struct SH7750State *sh7750_init(CPUState * cpu, struct MemoryRegion *sysmem);
+struct SH7750State *sh7750_init(CPUSH4State * cpu, struct MemoryRegion *sysmem);
 
 typedef struct {
     /* The callback will be triggered if any of the designated lines change */
hw/shix.c +1 -1
index e259c17..dd9ce17 100644
@@ -43,7 +43,7 @@ static void shix_init(ram_addr_t ram_size,
 	       const char *initrd_filename, const char *cpu_model)
 {
     int ret;
-    CPUState *env;
+    CPUSH4State *env;
     struct SH7750State *s;
     MemoryRegion *sysmem = get_system_memory();
     MemoryRegion *rom = g_new(MemoryRegion, 1);
Signature · 1 line
1.7.7
#61 lore raw

RFC PATCH v4 41/44 sparc hw/: Don't use CPUState

In reply to Andreas Färber

Scripted conversion:
for file in hw/sun4m.c hw/sun4u.c hw/grlib.h hw/leon3.c; do
sed -i "s/CPUState/CPUSPARCState/g" $file
done

---
 hw/grlib.h |    2 +-
 hw/leon3.c |    8 ++++----
 hw/sun4m.c |   12 ++++++------
 hw/sun4u.c |   24 ++++++++++++------------
 4 files changed, 23 insertions(+), 23 deletions(-)
hw/grlib.h +1 -1
index fdf4b11..e1c4137 100644
@@ -42,7 +42,7 @@ void grlib_irqmp_ack(DeviceState *dev, int intno);
 
 static inline
 DeviceState *grlib_irqmp_create(target_phys_addr_t   base,
-                                CPUState            *env,
+                                CPUSPARCState            *env,
                                 qemu_irq           **cpu_irqs,
                                 uint32_t             nr_irqs,
                                 set_pil_in_fn        set_pil_in)
hw/leon3.c +4 -4
index 1dc5a02..0a5ff16 100644
@@ -42,14 +42,14 @@
 #define MAX_PILS 16
 
 typedef struct ResetData {
-    CPUState *env;
+    CPUSPARCState *env;
     uint32_t  entry;            /* save kernel entry in case of reset */
 } ResetData;
 
 static void main_cpu_reset(void *opaque)
 {
     ResetData *s   = (ResetData *)opaque;
-    CPUState  *env = s->env;
+    CPUSPARCState  *env = s->env;
 
     cpu_state_reset(env);
 
@@ -65,7 +65,7 @@ void leon3_irq_ack(void *irq_manager, int intno)
 
 static void leon3_set_pil_in(void *opaque, uint32_t pil_in)
 {
-    CPUState *env = (CPUState *)opaque;
+    CPUSPARCState *env = (CPUSPARCState *)opaque;
 
     assert(env != NULL);
 
@@ -101,7 +101,7 @@ static void leon3_generic_hw_init(ram_addr_t  ram_size,
                                   const char *initrd_filename,
                                   const char *cpu_model)
 {
-    CPUState   *env;
+    CPUSPARCState   *env;
     MemoryRegion *address_space_mem = get_system_memory();
     MemoryRegion *ram = g_new(MemoryRegion, 1);
     MemoryRegion *prom = g_new(MemoryRegion, 1);
hw/sun4m.c +6 -6
index 4045740..7bcbf37 100644
@@ -228,7 +228,7 @@ void sun4m_irq_info(Monitor *mon)
         slavio_irq_info(mon, slavio_intctl);
 }
 
-void cpu_check_irqs(CPUState *env)
+void cpu_check_irqs(CPUSPARCState *env)
 {
     if (env->pil_in && (env->interrupt_index == 0 ||
                         (env->interrupt_index & ~15) == TT_EXTINT)) {
@@ -253,7 +253,7 @@ void cpu_check_irqs(CPUState *env)
     }
 }
 
-static void cpu_kick_irq(CPUState *env)
+static void cpu_kick_irq(CPUSPARCState *env)
 {
     env->halted = 0;
     cpu_check_irqs(env);
@@ -262,7 +262,7 @@ static void cpu_kick_irq(CPUState *env)
 
 static void cpu_set_irq(void *opaque, int irq, int level)
 {
-    CPUState *env = opaque;
+    CPUSPARCState *env = opaque;
 
     if (level) {
         trace_sun4m_cpu_set_irq_raise(irq);
@@ -281,7 +281,7 @@ static void dummy_cpu_set_irq(void *opaque, int irq, int level)
 
 static void main_cpu_reset(void *opaque)
 {
-    CPUState *env = opaque;
+    CPUSPARCState *env = opaque;
 
     cpu_state_reset(env);
     env->halted = 0;
@@ -289,7 +289,7 @@ static void main_cpu_reset(void *opaque)
 
 static void secondary_cpu_reset(void *opaque)
 {
-    CPUState *env = opaque;
+    CPUSPARCState *env = opaque;
 
     cpu_state_reset(env);
     env->halted = 1;
@@ -809,7 +809,7 @@ static TypeInfo ram_info = {
 static void cpu_devinit(const char *cpu_model, unsigned int id,
                         uint64_t prom_addr, qemu_irq **cpu_irqs)
 {
-    CPUState *env;
+    CPUSPARCState *env;
 
     env = cpu_init(cpu_model);
     if (!env) {
hw/sun4u.c +12 -12
index 8b043f2..c32eddb 100644
@@ -243,7 +243,7 @@ static unsigned long sun4u_load_kernel(const char *kernel_filename,
     return kernel_size;
 }
 
-void cpu_check_irqs(CPUState *env)
+void cpu_check_irqs(CPUSPARCState *env)
 {
     uint32_t pil = env->pil_in |
                   (env->softint & ~(SOFTINT_TIMER | SOFTINT_STIMER));
@@ -297,7 +297,7 @@ void cpu_check_irqs(CPUState *env)
     }
 }
 
-static void cpu_kick_irq(CPUState *env)
+static void cpu_kick_irq(CPUSPARCState *env)
 {
     env->halted = 0;
     cpu_check_irqs(env);
@@ -306,7 +306,7 @@ static void cpu_kick_irq(CPUState *env)
 
 static void cpu_set_irq(void *opaque, int irq, int level)
 {
-    CPUState *env = opaque;
+    CPUSPARCState *env = opaque;
 
     if (level) {
         CPUIRQ_DPRINTF("Raise CPU IRQ %d\n", irq);
@@ -320,7 +320,7 @@ static void cpu_set_irq(void *opaque, int irq, int level)
 }
 
 typedef struct ResetData {
-    CPUState *env;
+    CPUSPARCState *env;
     uint64_t prom_addr;
 } ResetData;
 
@@ -344,7 +344,7 @@ void cpu_get_timer(QEMUFile *f, CPUTimer *s)
     qemu_get_timer(f, s->qtimer);
 }
 
-static CPUTimer* cpu_timer_create(const char* name, CPUState *env,
+static CPUTimer* cpu_timer_create(const char* name, CPUSPARCState *env,
                                   QEMUBHFunc *cb, uint32_t frequency,
                                   uint64_t disabled_mask)
 {
@@ -373,7 +373,7 @@ static void cpu_timer_reset(CPUTimer *timer)
 static void main_cpu_reset(void *opaque)
 {
     ResetData *s = (ResetData *)opaque;
-    CPUState *env = s->env;
+    CPUSPARCState *env = s->env;
     static unsigned int nr_resets;
 
     cpu_state_reset(env);
@@ -396,7 +396,7 @@ static void main_cpu_reset(void *opaque)
 
 static void tick_irq(void *opaque)
 {
-    CPUState *env = opaque;
+    CPUSPARCState *env = opaque;
 
     CPUTimer* timer = env->tick;
 
@@ -413,7 +413,7 @@ static void tick_irq(void *opaque)
 
 static void stick_irq(void *opaque)
 {
-    CPUState *env = opaque;
+    CPUSPARCState *env = opaque;
 
     CPUTimer* timer = env->stick;
 
@@ -430,7 +430,7 @@ static void stick_irq(void *opaque)
 
 static void hstick_irq(void *opaque)
 {
-    CPUState *env = opaque;
+    CPUSPARCState *env = opaque;
 
     CPUTimer* timer = env->hstick;
 
@@ -714,9 +714,9 @@ static TypeInfo ram_info = {
     .class_init    = ram_class_init,
 };
 
-static CPUState *cpu_devinit(const char *cpu_model, const struct hwdef *hwdef)
+static CPUSPARCState *cpu_devinit(const char *cpu_model, const struct hwdef *hwdef)
 {
-    CPUState *env;
+    CPUSPARCState *env;
     ResetData *reset_info;
 
     uint32_t   tick_frequency = 100*1000000;
@@ -755,7 +755,7 @@ static void sun4uv_init(MemoryRegion *address_space_mem,
                         const char *initrd_filename, const char *cpu_model,
                         const struct hwdef *hwdef)
 {
-    CPUState *env;
+    CPUSPARCState *env;
     M48t59State *nvram;
     unsigned int i;
     long initrd_size, kernel_size;
Signature · 1 line
1.7.7
#62 lore raw

RFC PATCH v4 42/44 xtensa hw/: Don't use CPUState

In reply to Andreas Färber

Scripted conversion:
for file in hw/xtensa_*.[hc]; do
sed -i "s/CPUState/CPUXtensaState/g" $file
done

---
 hw/xtensa_lx60.c |    4 ++--
 hw/xtensa_pic.c  |   16 ++++++++--------
 hw/xtensa_sim.c  |    2 +-
 3 files changed, 11 insertions(+), 11 deletions(-)
hw/xtensa_lx60.c +2 -2
index 80ba4d7..afdef49 100644
@@ -148,7 +148,7 @@ static uint64_t translate_phys_addr(void *env, uint64_t addr)
 
 static void lx60_reset(void *opaque)
 {
-    CPUState *env = opaque;
+    CPUXtensaState *env = opaque;
 
     cpu_state_reset(env);
 }
@@ -164,7 +164,7 @@ static void lx_init(const LxBoardDesc *board,
     int be = 0;
 #endif
     MemoryRegion *system_memory = get_system_memory();
-    CPUState *env = NULL;
+    CPUXtensaState *env = NULL;
     MemoryRegion *ram, *rom, *system_io;
     DriveInfo *dinfo;
     pflash_t *flash = NULL;
hw/xtensa_pic.c +8 -8
index 71d5fc8..653ded6 100644
@@ -29,7 +29,7 @@
 #include "qemu-log.h"
 #include "qemu-timer.h"
 
-void xtensa_advance_ccount(CPUState *env, uint32_t d)
+void xtensa_advance_ccount(CPUXtensaState *env, uint32_t d)
 {
     uint32_t old_ccount = env->sregs[CCOUNT];
 
@@ -45,7 +45,7 @@ void xtensa_advance_ccount(CPUState *env, uint32_t d)
     }
 }
 
-void check_interrupts(CPUState *env)
+void check_interrupts(CPUXtensaState *env)
 {
     int minlevel = xtensa_get_cintlevel(env);
     uint32_t int_set_enabled = env->sregs[INTSET] & env->sregs[INTENABLE];
@@ -84,7 +84,7 @@ void check_interrupts(CPUState *env)
 
 static void xtensa_set_irq(void *opaque, int irq, int active)
 {
-    CPUState *env = opaque;
+    CPUXtensaState *env = opaque;
 
     if (irq >= env->config->ninterrupt) {
         qemu_log("%s: bad IRQ %d\n", __func__, irq);
@@ -101,12 +101,12 @@ static void xtensa_set_irq(void *opaque, int irq, int active)
     }
 }
 
-void xtensa_timer_irq(CPUState *env, uint32_t id, uint32_t active)
+void xtensa_timer_irq(CPUXtensaState *env, uint32_t id, uint32_t active)
 {
     qemu_set_irq(env->irq_inputs[env->config->timerint[id]], active);
 }
 
-void xtensa_rearm_ccompare_timer(CPUState *env)
+void xtensa_rearm_ccompare_timer(CPUXtensaState *env)
 {
     int i;
     uint32_t wake_ccount = env->sregs[CCOUNT] - 1;
@@ -125,7 +125,7 @@ void xtensa_rearm_ccompare_timer(CPUState *env)
 
 static void xtensa_ccompare_cb(void *opaque)
 {
-    CPUState *env = opaque;
+    CPUXtensaState *env = opaque;
 
     if (env->halted) {
         env->halt_clock = qemu_get_clock_ns(vm_clock);
@@ -137,7 +137,7 @@ static void xtensa_ccompare_cb(void *opaque)
     }
 }
 
-void xtensa_irq_init(CPUState *env)
+void xtensa_irq_init(CPUXtensaState *env)
 {
     env->irq_inputs = (void **)qemu_allocate_irqs(
             xtensa_set_irq, env, env->config->ninterrupt);
@@ -148,7 +148,7 @@ void xtensa_irq_init(CPUState *env)
     }
 }
 
-void *xtensa_get_extint(CPUState *env, unsigned extint)
+void *xtensa_get_extint(CPUXtensaState *env, unsigned extint)
 {
     if (extint < env->config->nextint) {
         unsigned irq = env->config->extint[extint];
hw/xtensa_sim.c +1 -1
index 445cfde..c7e05dc 100644
@@ -47,7 +47,7 @@ static void sim_init(ram_addr_t ram_size,
         const char *kernel_filename, const char *kernel_cmdline,
         const char *initrd_filename, const char *cpu_model)
 {
-    CPUState *env = NULL;
+    CPUXtensaState *env = NULL;
     MemoryRegion *ram, *rom;
     int n;
 
Signature · 1 line
1.7.7
#63 lore raw

RFC PATCH v4 43/44 Rename CPUState -> CPUArchState

In reply to Andreas Färber
---
 bsd-user/main.c         |    8 ++--
 bsd-user/qemu.h         |   12 +++---
 bsd-user/signal.c       |    2 +-
 cpu-all.h               |   56 +++++++++++-----------
 cpu-defs.h              |    2 +-
 cpu-exec.c              |   16 +++---
 cpus.c                  |   76 ++++++++++++++++----------------
 darwin-user/main.c      |    6 +-
 darwin-user/qemu.h      |    6 +-
 darwin-user/signal.c    |    4 +-
 def-helper.h            |    2 +-
 disas.c                 |    4 +-
 disas.h                 |    2 +-
 dyngen-exec.h           |    4 +-
 exec-all.h              |   38 ++++++++--------
 exec.c                  |  114 +++++++++++++++++++++++-----------------------
 gdbstub.c               |   44 +++++++++---------
 gdbstub.h               |   16 +++---
 gen-icount.h            |    8 ++--
 kvm-all.c               |   54 +++++++++++-----------
 kvm-stub.c              |   22 +++++-----
 kvm.h                   |   60 ++++++++++++------------
 linux-user/elfload.c    |   16 +++---
 linux-user/main.c       |   14 +++---
 linux-user/qemu.h       |   14 +++---
 linux-user/signal.c     |   16 +++---
 linux-user/syscall.c    |   28 ++++++------
 monitor.c               |   56 +++++++++++-----------
 poison.h                |    2 +-
 softmmu-semi.h          |   12 +++---
 target-alpha/cpu.h      |    2 +-
 target-arm/cpu.h        |    2 +-
 target-cris/cpu.h       |    2 +-
 target-i386/cpu.h       |    2 +-
 target-lm32/cpu.h       |    2 +-
 target-m68k/cpu.h       |    2 +-
 target-microblaze/cpu.h |    2 +-
 target-mips/cpu.h       |    2 +-
 target-ppc/cpu.h        |    2 +-
 target-s390x/cpu.h      |    2 +-
 target-sh4/cpu.h        |    2 +-
 target-sparc/cpu.h      |    2 +-
 target-unicore32/cpu.h  |    2 +-
 target-xtensa/cpu.h     |    2 +-
 tcg/arm/tcg-target.c    |   22 +++++-----
 tcg/hppa/tcg-target.c   |    8 ++--
 tcg/i386/tcg-target.c   |    2 +-
 tcg/ia64/tcg-target.c   |   10 ++--
 tcg/mips/tcg-target.c   |   14 +++---
 tcg/ppc/tcg-target.c    |    4 +-
 tcg/ppc64/tcg-target.c  |    4 +-
 tcg/s390/tcg-target.c   |    8 ++--
 tcg/sparc/tcg-target.c  |    4 +-
 tcg/tci/tcg-target.c    |    2 +-
 tcg/tci/tcg-target.h    |    2 +-
 tci.c                   |    4 +-
 translate-all.c         |    4 +-
 user-exec.c             |    4 +-
 xen-all.c               |    4 +-
 59 files changed, 419 insertions(+), 419 deletions(-)
bsd-user/main.c +4 -4
index 78533d5..48cb715 100644
@@ -70,11 +70,11 @@ int cpu_get_pic_interrupt(CPUX86State *env)
 #endif
 
 /* These are no-ops because we are not threadsafe.  */
-static inline void cpu_exec_start(CPUState *env)
+static inline void cpu_exec_start(CPUArchState *env)
 {
 }
 
-static inline void cpu_exec_end(CPUState *env)
+static inline void cpu_exec_end(CPUArchState *env)
 {
 }
 
@@ -713,7 +713,7 @@ static void usage(void)
     exit(1);
 }
 
-THREAD CPUState *thread_env;
+THREAD CPUArchState *thread_env;
 
 /* Assumes contents are already zeroed.  */
 void init_task_state(TaskState *ts)
@@ -737,7 +737,7 @@ int main(int argc, char **argv)
     struct target_pt_regs regs1, *regs = &regs1;
     struct image_info info1, *info = &info1;
     TaskState ts1, *ts = &ts1;
-    CPUState *env;
+    CPUArchState *env;
     int optind;
     const char *r;
     int gdbstub_port = 0;
bsd-user/qemu.h +6 -6
index 1ba2d08..8a5ee3d 100644
@@ -139,8 +139,8 @@ abi_long do_openbsd_syscall(void *cpu_env, int num, abi_long arg1,
                             abi_long arg2, abi_long arg3, abi_long arg4,
                             abi_long arg5, abi_long arg6);
 void gemu_log(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
-extern THREAD CPUState *thread_env;
-void cpu_loop(CPUState *env);
+extern THREAD CPUArchState *thread_env;
+void cpu_loop(CPUArchState *env);
 char *target_strerror(int err);
 int get_osversion(void);
 void fork_start(void);
@@ -167,13 +167,13 @@ void print_openbsd_syscall_ret(int num, abi_long ret);
 extern int do_strace;
 
 /* signal.c */
-void process_pending_signals(CPUState *cpu_env);
+void process_pending_signals(CPUArchState *cpu_env);
 void signal_init(void);
-//int queue_signal(CPUState *env, int sig, target_siginfo_t *info);
+//int queue_signal(CPUArchState *env, int sig, target_siginfo_t *info);
 //void host_to_target_siginfo(target_siginfo_t *tinfo, const siginfo_t *info);
 //void target_to_host_siginfo(siginfo_t *info, const target_siginfo_t *tinfo);
-long do_sigreturn(CPUState *env);
-long do_rt_sigreturn(CPUState *env);
+long do_sigreturn(CPUArchState *env);
+long do_rt_sigreturn(CPUArchState *env);
 abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, abi_ulong sp);
 
 /* mmap.c */
bsd-user/signal.c +1 -1
index 40313c8..445f69e 100644
@@ -33,6 +33,6 @@ void signal_init(void)
 {
 }
 
-void process_pending_signals(CPUState *cpu_env)
+void process_pending_signals(CPUArchState *cpu_env)
 {
 }
cpu-all.h +28 -28

116 lines not on this page · raw message

cpu-defs.h +1 -1
index 4527cbf..3268968 100644
@@ -202,7 +202,7 @@ typedef struct CPUWatchpoint {
     jmp_buf jmp_env;                                                    \
     int exception_index;                                                \
                                                                         \
-    CPUState *next_cpu; /* next CPU sharing TB cache */                 \
+    CPUArchState *next_cpu; /* next CPU sharing TB cache */                 \
     int cpu_index; /* CPU index (informative) */                        \
     uint32_t host_tid; /* host thread ID */                             \
     int numa_node; /* NUMA node this cpu is belonging to  */            \
cpu-exec.c +8 -8
index 2bf1735..bd5791f 100644
@@ -26,12 +26,12 @@ int tb_invalidated_flag;
 
 //#define CONFIG_DEBUG_EXEC
 
-bool qemu_cpu_has_work(CPUState *env)
+bool qemu_cpu_has_work(CPUArchState *env)
 {
     return cpu_has_work(env);
 }
 
-void cpu_loop_exit(CPUState *env)
+void cpu_loop_exit(CPUArchState *env)
 {
     env->current_tb = NULL;
     longjmp(env->jmp_env, 1);
@@ -41,7 +41,7 @@ void cpu_loop_exit(CPUState *env)
    restored in a state compatible with the CPU emulator
  */
 #if defined(CONFIG_SOFTMMU)
-void cpu_resume_from_signal(CPUState *env, void *puc)
+void cpu_resume_from_signal(CPUArchState *env, void *puc)
 {
     /* XXX: restore cpu registers saved in host registers */
 
@@ -52,7 +52,7 @@ void cpu_resume_from_signal(CPUState *env, void *puc)
 
 /* Execute the code without caching the generated code. An interpreter
    could be used if available. */
-static void cpu_exec_nocache(CPUState *env, int max_cycles,
+static void cpu_exec_nocache(CPUArchState *env, int max_cycles,
                              TranslationBlock *orig_tb)
 {
     unsigned long next_tb;
@@ -79,7 +79,7 @@ static void cpu_exec_nocache(CPUState *env, int max_cycles,
     tb_free(tb);
 }
 
-static TranslationBlock *tb_find_slow(CPUState *env,
+static TranslationBlock *tb_find_slow(CPUArchState *env,
                                       target_ulong pc,
                                       target_ulong cs_base,
                                       uint64_t flags)
@@ -135,7 +135,7 @@ static TranslationBlock *tb_find_slow(CPUState *env,
     return tb;
 }
 
-static inline TranslationBlock *tb_find_fast(CPUState *env)
+static inline TranslationBlock *tb_find_fast(CPUArchState *env)
 {
     TranslationBlock *tb;
     target_ulong cs_base, pc;
@@ -163,7 +163,7 @@ CPUDebugExcpHandler *cpu_set_debug_excp_handler(CPUDebugExcpHandler *handler)
     return old_handler;
 }
 
-static void cpu_handle_debug_exception(CPUState *env)
+static void cpu_handle_debug_exception(CPUArchState *env)
 {
     CPUWatchpoint *wp;
 
@@ -181,7 +181,7 @@ static void cpu_handle_debug_exception(CPUState *env)
 
 volatile sig_atomic_t exit_request;
 
-int cpu_exec(CPUState *env)
+int cpu_exec(CPUArchState *env)
 {
     int ret, interrupt_request;
     TranslationBlock *tb;
cpus.c +38 -38

304 lines not on this page · raw message

darwin-user/main.c +3 -3
index f5cadc7..544e219 100644
@@ -71,7 +71,7 @@ void gemu_log(const char *fmt, ...)
     va_end(ap);
 }
 
-int cpu_get_pic_interrupt(CPUState *env)
+int cpu_get_pic_interrupt(CPUArchState *env)
 {
     return -1;
 }
@@ -729,7 +729,7 @@ static void usage(void)
 }
 
 /* XXX: currently only used for async signals (see signal.c) */
-CPUState *global_env;
+CPUArchState *global_env;
 
 /* used to free thread contexts */
 TaskState *first_task_state;
@@ -741,7 +741,7 @@ int main(int argc, char **argv)
     const char *log_mask = NULL;
     struct target_pt_regs regs1, *regs = &regs1;
     TaskState ts1, *ts = &ts1;
-    CPUState *env;
+    CPUArchState *env;
     int optind;
     short use_gdbstub = 0;
     const char *r;
darwin-user/qemu.h +3 -3
index b6d3e6c..9e16c8e 100644
@@ -104,8 +104,8 @@ void qerror(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
 
 void write_dt(void *ptr, unsigned long addr, unsigned long limit, int flags);
 
-extern CPUState *global_env;
-void cpu_loop(CPUState *env);
+extern CPUArchState *global_env;
+void cpu_loop(CPUArchState *env);
 void init_paths(const char *prefix);
 const char *path(const char *pathname);
 
@@ -122,7 +122,7 @@ void signal_init(void);
 int queue_signal(int sig, target_siginfo_t *info);
 void host_to_target_siginfo(target_siginfo_t *tinfo, const siginfo_t *info);
 void target_to_host_siginfo(siginfo_t *info, const target_siginfo_t *tinfo);
-long do_sigreturn(CPUState *env, int num);
+long do_sigreturn(CPUArchState *env, int num);
 
 /* machload.c */
 int mach_exec(const char * filename, char ** argv, char ** envp,
darwin-user/signal.c +2 -2
index 8f9705d..489cb64 100644
@@ -377,12 +377,12 @@ long do_sigreturn(CPUX86State *env, int num)
 #else
 
 static void setup_frame(int sig, struct emulated_sigaction *ka,
-			void *set, CPUState *env)
+			void *set, CPUArchState *env)
 {
     fprintf(stderr, "setup_frame: not implemented\n");
 }
 
-long do_sigreturn(CPUState *env, int num)
+long do_sigreturn(CPUArchState *env, int num)
 {
     int i = 0;
     struct target_sigcontext *scp = get_int_arg(&i, env);
def-helper.h +1 -1
index 8a822c7..5d057d6 100644
@@ -52,7 +52,7 @@
 #define dh_ctype_tl target_ulong
 #define dh_ctype_ptr void *
 #define dh_ctype_void void
-#define dh_ctype_env CPUState *
+#define dh_ctype_env CPUArchState *
 #define dh_ctype(t) dh_ctype_##t
 
 /* We can't use glue() here because it falls foul of C preprocessor
disas.c +2 -2
index 3b1fd97..4945c44 100644
@@ -339,7 +339,7 @@ const char *lookup_symbol(target_ulong orig_addr)
 #include "monitor.h"
 
 static int monitor_disas_is_physical;
-static CPUState *monitor_disas_env;
+static CPUArchState *monitor_disas_env;
 
 static int
 monitor_read_memory (bfd_vma memaddr, bfd_byte *myaddr, int length,
@@ -363,7 +363,7 @@ monitor_fprintf(FILE *stream, const char *fmt, ...)
     return 0;
 }
 
-void monitor_disas(Monitor *mon, CPUState *env,
+void monitor_disas(Monitor *mon, CPUArchState *env,
                    target_ulong pc, int nb_insn, int is_physical, int flags)
 {
     int count, i;
disas.h +1 -1
index f9287f7..3ab42af 100644
@@ -8,7 +8,7 @@
 void disas(FILE *out, void *code, unsigned long size);
 void target_disas(FILE *out, target_ulong code, target_ulong size, int flags);
 
-void monitor_disas(Monitor *mon, CPUState *env,
+void monitor_disas(Monitor *mon, CPUArchState *env,
                    target_ulong pc, int nb_insn, int is_physical, int flags);
 
 /* Look up symbol for debugging purpose.  Returns "" if unknown. */
dyngen-exec.h +2 -2
index 09be9ea..083e20b 100644
@@ -61,10 +61,10 @@
 #endif
 
 #if defined(AREG0)
-register CPUState *env asm(AREG0);
+register CPUArchState *env asm(AREG0);
 #else
 /* TODO: Try env = cpu_single_env. */
-extern CPUState *env;
+extern CPUArchState *env;
 #endif
 
 #endif /* !defined(__DYNGEN_EXEC_H__) */
exec-all.h +19 -19
index 51d01f2..0fcdaf0 100644
@@ -76,30 +76,30 @@ extern uint16_t gen_opc_icount[OPC_BUF_SIZE];
 
 #include "qemu-log.h"
 
-void gen_intermediate_code(CPUState *env, struct TranslationBlock *tb);
-void gen_intermediate_code_pc(CPUState *env, struct TranslationBlock *tb);
-void restore_state_to_opc(CPUState *env, struct TranslationBlock *tb,
+void gen_intermediate_code(CPUArchState *env, struct TranslationBlock *tb);
+void gen_intermediate_code_pc(CPUArchState *env, struct TranslationBlock *tb);
+void restore_state_to_opc(CPUArchState *env, struct TranslationBlock *tb,
                           int pc_pos);
 
 void cpu_gen_init(void);
-int cpu_gen_code(CPUState *env, struct TranslationBlock *tb,
+int cpu_gen_code(CPUArchState *env, struct TranslationBlock *tb,
                  int *gen_code_size_ptr);
 int cpu_restore_state(struct TranslationBlock *tb,
-                      CPUState *env, unsigned long searched_pc);
-void cpu_resume_from_signal(CPUState *env1, void *puc);
-void cpu_io_recompile(CPUState *env, void *retaddr);
-TranslationBlock *tb_gen_code(CPUState *env, 
+                      CPUArchState *env, unsigned long searched_pc);
+void cpu_resume_from_signal(CPUArchState *env1, void *puc);
+void cpu_io_recompile(CPUArchState *env, void *retaddr);
+TranslationBlock *tb_gen_code(CPUArchState *env, 
                               target_ulong pc, target_ulong cs_base, int flags,
                               int cflags);
-void cpu_exec_init(CPUState *env);
-void QEMU_NORETURN cpu_loop_exit(CPUState *env1);
+void cpu_exec_init(CPUArchState *env);
+void QEMU_NORETURN cpu_loop_exit(CPUArchState *env1);
 int page_unprotect(target_ulong address, unsigned long pc, void *puc);
 void tb_invalidate_phys_page_range(tb_page_addr_t start, tb_page_addr_t end,
                                    int is_cpu_write_access);
-void tlb_flush_page(CPUState *env, target_ulong addr);
-void tlb_flush(CPUState *env, int flush_global);
+void tlb_flush_page(CPUArchState *env, target_ulong addr);
+void tlb_flush(CPUArchState *env, int flush_global);
 #if !defined(CONFIG_USER_ONLY)
-void tlb_set_page(CPUState *env, target_ulong vaddr,
+void tlb_set_page(CPUArchState *env, target_ulong vaddr,
                   target_phys_addr_t paddr, int prot,
                   int mmu_idx, target_ulong size);
 #endif
@@ -182,7 +182,7 @@ static inline unsigned int tb_phys_hash_func(tb_page_addr_t pc)
 }
 
 void tb_free(TranslationBlock *tb);
-void tb_flush(CPUState *env);
+void tb_flush(CPUArchState *env);
 void tb_link_page(TranslationBlock *tb,
                   tb_page_addr_t phys_pc, tb_page_addr_t phys_page2);
 void tb_phys_invalidate(TranslationBlock *tb, tb_page_addr_t page_addr);
@@ -304,7 +304,7 @@ void io_mem_write(int index, target_phys_addr_t addr, uint64_t value,
                   unsigned size);
 extern struct MemoryRegion *io_mem_region[IO_MEM_NB_ENTRIES];
 
-void tlb_fill(CPUState *env1, target_ulong addr, int is_write, int mmu_idx,
+void tlb_fill(CPUArchState *env1, target_ulong addr, int is_write, int mmu_idx,
               void *retaddr);
 
 #include "softmmu_defs.h"
@@ -332,15 +332,15 @@ void tlb_fill(CPUState *env1, target_ulong addr, int is_write, int mmu_idx,
 #endif
 
 #if defined(CONFIG_USER_ONLY)
-static inline tb_page_addr_t get_page_addr_code(CPUState *env1, target_ulong addr)
+static inline tb_page_addr_t get_page_addr_code(CPUArchState *env1, target_ulong addr)
 {
     return addr;
 }
 #else
-tb_page_addr_t get_page_addr_code(CPUState *env1, target_ulong addr);
+tb_page_addr_t get_page_addr_code(CPUArchState *env1, target_ulong addr);
 #endif
 
-typedef void (CPUDebugExcpHandler)(CPUState *env);
+typedef void (CPUDebugExcpHandler)(CPUArchState *env);
 
 CPUDebugExcpHandler *cpu_set_debug_excp_handler(CPUDebugExcpHandler *handler);
 
@@ -352,7 +352,7 @@ extern volatile sig_atomic_t exit_request;
 
 /* Deterministic execution requires that IO only be performed on the last
    instruction of a TB so that interrupts take effect immediately.  */
-static inline int can_do_io(CPUState *env)
+static inline int can_do_io(CPUArchState *env)
 {
     if (!use_icount) {
         return 1;
exec.c +57 -57

410 lines not on this page · raw message

gdbstub.c +22 -22

157 lines not on this page · raw message

gdbstub.h +8 -8
index d82334f..b44e275 100644
@@ -11,22 +11,22 @@
 #define GDB_WATCHPOINT_ACCESS    4
 
 #ifdef NEED_CPU_H
-typedef void (*gdb_syscall_complete_cb)(CPUState *env,
+typedef void (*gdb_syscall_complete_cb)(CPUArchState *env,
                                         target_ulong ret, target_ulong err);
 
 void gdb_do_syscall(gdb_syscall_complete_cb cb, const char *fmt, ...);
 int use_gdb_syscalls(void);
-void gdb_set_stop_cpu(CPUState *env);
-void gdb_exit(CPUState *, int);
+void gdb_set_stop_cpu(CPUArchState *env);
+void gdb_exit(CPUArchState *, int);
 #ifdef CONFIG_USER_ONLY
 int gdb_queuesig (void);
-int gdb_handlesig (CPUState *, int);
-void gdb_signalled(CPUState *, int);
-void gdbserver_fork(CPUState *);
+int gdb_handlesig (CPUArchState *, int);
+void gdb_signalled(CPUArchState *, int);
+void gdbserver_fork(CPUArchState *);
 #endif
 /* Get or set a register.  Returns the size of the register.  */
-typedef int (*gdb_reg_cb)(CPUState *env, uint8_t *buf, int reg);
-void gdb_register_coprocessor(CPUState *env,
+typedef int (*gdb_reg_cb)(CPUArchState *env, uint8_t *buf, int reg);
+void gdb_register_coprocessor(CPUArchState *env,
                               gdb_reg_cb get_reg, gdb_reg_cb set_reg,
                               int num_regs, const char *xml, int g_pos);
 
gen-icount.h +4 -4
index 5fb3829..430cb44 100644
@@ -14,13 +14,13 @@ static inline void gen_icount_start(void)
 
     icount_label = gen_new_label();
     count = tcg_temp_local_new_i32();
-    tcg_gen_ld_i32(count, cpu_env, offsetof(CPUState, icount_decr.u32));
+    tcg_gen_ld_i32(count, cpu_env, offsetof(CPUArchState, icount_decr.u32));
     /* This is a horrid hack to allow fixing up the value later.  */
     icount_arg = gen_opparam_ptr + 1;
     tcg_gen_subi_i32(count, count, 0xdeadbeef);
 
     tcg_gen_brcondi_i32(TCG_COND_LT, count, 0, icount_label);
-    tcg_gen_st16_i32(count, cpu_env, offsetof(CPUState, icount_decr.u16.low));
+    tcg_gen_st16_i32(count, cpu_env, offsetof(CPUArchState, icount_decr.u16.low));
     tcg_temp_free_i32(count);
 }
 
@@ -36,13 +36,13 @@ static void gen_icount_end(TranslationBlock *tb, int num_insns)
 static inline void gen_io_start(void)
 {
     TCGv_i32 tmp = tcg_const_i32(1);
-    tcg_gen_st_i32(tmp, cpu_env, offsetof(CPUState, can_do_io));
+    tcg_gen_st_i32(tmp, cpu_env, offsetof(CPUArchState, can_do_io));
     tcg_temp_free_i32(tmp);
 }
 
 static inline void gen_io_end(void)
 {
     TCGv_i32 tmp = tcg_const_i32(0);
-    tcg_gen_st_i32(tmp, cpu_env, offsetof(CPUState, can_do_io));
+    tcg_gen_st_i32(tmp, cpu_env, offsetof(CPUArchState, can_do_io));
     tcg_temp_free_i32(tmp);
 }
kvm-all.c +27 -27

197 lines not on this page · raw message

kvm-stub.c +11 -11
index 1f1c686..69a1228 100644
@@ -22,7 +22,7 @@ int kvm_pit_in_kernel(void)
 }
 
 
-int kvm_init_vcpu(CPUState *env)
+int kvm_init_vcpu(CPUArchState *env)
 {
     return -ENOSYS;
 }
@@ -46,19 +46,19 @@ void kvm_flush_coalesced_mmio_buffer(void)
 {
 }
 
-void kvm_cpu_synchronize_state(CPUState *env)
+void kvm_cpu_synchronize_state(CPUArchState *env)
 {
 }
 
-void kvm_cpu_synchronize_post_reset(CPUState *env)
+void kvm_cpu_synchronize_post_reset(CPUArchState *env)
 {
 }
 
-void kvm_cpu_synchronize_post_init(CPUState *env)
+void kvm_cpu_synchronize_post_init(CPUArchState *env)
 {
 }
 
-int kvm_cpu_exec(CPUState *env)
+int kvm_cpu_exec(CPUArchState *env)
 {
     abort ();
 }
@@ -87,29 +87,29 @@ void kvm_setup_guest_memory(void *start, size_t size)
 {
 }
 
-int kvm_update_guest_debug(CPUState *env, unsigned long reinject_trap)
+int kvm_update_guest_debug(CPUArchState *env, unsigned long reinject_trap)
 {
     return -ENOSYS;
 }
 
-int kvm_insert_breakpoint(CPUState *current_env, target_ulong addr,
+int kvm_insert_breakpoint(CPUArchState *current_env, target_ulong addr,
                           target_ulong len, int type)
 {
     return -EINVAL;
 }
 
-int kvm_remove_breakpoint(CPUState *current_env, target_ulong addr,
+int kvm_remove_breakpoint(CPUArchState *current_env, target_ulong addr,
                           target_ulong len, int type)
 {
     return -EINVAL;
 }
 
-void kvm_remove_all_breakpoints(CPUState *current_env)
+void kvm_remove_all_breakpoints(CPUArchState *current_env)
 {
 }
 
 #ifndef _WIN32
-int kvm_set_signal_mask(CPUState *env, const sigset_t *sigset)
+int kvm_set_signal_mask(CPUArchState *env, const sigset_t *sigset)
 {
     abort();
 }
@@ -125,7 +125,7 @@ int kvm_set_ioeventfd_mmio_long(int fd, uint32_t adr, uint32_t val, bool assign)
     return -ENOSYS;
 }
 
-int kvm_on_sigbus_vcpu(CPUState *env, int code, void *addr)
+int kvm_on_sigbus_vcpu(CPUArchState *env, int code, void *addr)
 {
     return 1;
 }
kvm.h +30 -30

142 lines not on this page · raw message

linux-user/elfload.c +8 -8
index 48e3232..e502b39 100644
@@ -1044,7 +1044,7 @@ static inline void bswap_sym(struct elf_sym *sym) { }
 #endif
 
 #ifdef USE_ELF_CORE_DUMP
-static int elf_core_dump(int, const CPUState *);
+static int elf_core_dump(int, const CPUArchState *);
 #endif /* USE_ELF_CORE_DUMP */
 static void load_symbols(struct elfhdr *hdr, int fd, abi_ulong load_bias);
 
@@ -1930,7 +1930,7 @@ int load_elf_binary(struct linux_binprm * bprm, struct target_pt_regs * regs,
  * from given cpu into just specified register set.  Prototype is:
  *
  * static void elf_core_copy_regs(taret_elf_gregset_t *regs,
- *                                const CPUState *env);
+ *                                const CPUArchState *env);
  *
  * Parameters:
  *     regs - copy register values into here (allocated and zeroed by caller)
@@ -2054,8 +2054,8 @@ static void fill_auxv_note(struct memelfnote *, const TaskState *);
 static void fill_elf_note_phdr(struct elf_phdr *, int, off_t);
 static size_t note_size(const struct memelfnote *);
 static void free_note_info(struct elf_note_info *);
-static int fill_note_info(struct elf_note_info *, long, const CPUState *);
-static void fill_thread_info(struct elf_note_info *, const CPUState *);
+static int fill_note_info(struct elf_note_info *, long, const CPUArchState *);
+static void fill_thread_info(struct elf_note_info *, const CPUArchState *);
 static int core_dump_filename(const TaskState *, char *, size_t);
 
 static int dump_write(int, const void *, size_t);
@@ -2448,7 +2448,7 @@ static int write_note(struct memelfnote *men, int fd)
     return (0);
 }
 
-static void fill_thread_info(struct elf_note_info *info, const CPUState *env)
+static void fill_thread_info(struct elf_note_info *info, const CPUArchState *env)
 {
     TaskState *ts = (TaskState *)env->opaque;
     struct elf_thread_status *ets;
@@ -2466,10 +2466,10 @@ static void fill_thread_info(struct elf_note_info *info, const CPUState *env)
 }
 
 static int fill_note_info(struct elf_note_info *info,
-                          long signr, const CPUState *env)
+                          long signr, const CPUArchState *env)
 {
 #define NUMNOTES 3
-    CPUState *cpu = NULL;
+    CPUArchState *cpu = NULL;
     TaskState *ts = (TaskState *)env->opaque;
     int i;
 
@@ -2595,7 +2595,7 @@ static int write_note_info(struct elf_note_info *info, int fd)
  * handler (provided that target process haven't registered
  * handler for that) that does the dump when signal is received.
  */
-static int elf_core_dump(int signr, const CPUState *env)
+static int elf_core_dump(int signr, const CPUArchState *env)
 {
     const TaskState *ts = (const TaskState *)env->opaque;
     struct vm_area_struct *vma = NULL;
linux-user/main.c +7 -7
index 3b48882..962677e 100644
@@ -146,7 +146,7 @@ static inline void exclusive_idle(void)
    Must only be called from outside cpu_arm_exec.   */
 static inline void start_exclusive(void)
 {
-    CPUState *other;
+    CPUArchState *other;
     pthread_mutex_lock(&exclusive_lock);
     exclusive_idle();
 
@@ -172,7 +172,7 @@ static inline void end_exclusive(void)
 }
 
 /* Wait for exclusive ops to finish, and begin cpu execution.  */
-static inline void cpu_exec_start(CPUState *env)
+static inline void cpu_exec_start(CPUArchState *env)
 {
     pthread_mutex_lock(&exclusive_lock);
     exclusive_idle();
@@ -181,7 +181,7 @@ static inline void cpu_exec_start(CPUState *env)
 }
 
 /* Mark cpu as not executing, and release pending exclusive ops.  */
-static inline void cpu_exec_end(CPUState *env)
+static inline void cpu_exec_end(CPUArchState *env)
 {
     pthread_mutex_lock(&exclusive_lock);
     env->running = 0;
@@ -206,11 +206,11 @@ void cpu_list_unlock(void)
 }
 #else /* if !CONFIG_USE_NPTL */
 /* These are no-ops because we are not threadsafe.  */
-static inline void cpu_exec_start(CPUState *env)
+static inline void cpu_exec_start(CPUArchState *env)
 {
 }
 
-static inline void cpu_exec_end(CPUState *env)
+static inline void cpu_exec_end(CPUArchState *env)
 {
 }
 
@@ -2888,7 +2888,7 @@ void cpu_loop(CPUS390XState *env)
 
 #endif /* TARGET_S390X */
 
-THREAD CPUState *thread_env;
+THREAD CPUArchState *thread_env;
 
 void task_settid(TaskState *ts)
 {
@@ -3277,7 +3277,7 @@ int main(int argc, char **argv, char **envp)
     struct image_info info1, *info = &info1;
     struct linux_binprm bprm;
     TaskState *ts;
-    CPUState *env;
+    CPUArchState *env;
     int optind;
     char **target_environ, **wrk;
     char **target_argv;
linux-user/qemu.h +7 -7
index 308dbc0..6889567 100644
@@ -171,7 +171,7 @@ struct linux_binprm {
         char **argv;
         char **envp;
         char * filename;        /* Name of binary */
-        int (*core_dump)(int, const CPUState *); /* coredump routine */
+        int (*core_dump)(int, const CPUArchState *); /* coredump routine */
 };
 
 void do_init_thread(struct target_pt_regs *regs, struct image_info *infop);
@@ -196,8 +196,8 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
                     abi_long arg5, abi_long arg6, abi_long arg7,
                     abi_long arg8);
 void gemu_log(const char *fmt, ...) GCC_FMT_ATTR(1, 2);
-extern THREAD CPUState *thread_env;
-void cpu_loop(CPUState *env);
+extern THREAD CPUArchState *thread_env;
+void cpu_loop(CPUArchState *env);
 char *target_strerror(int err);
 int get_osversion(void);
 void fork_start(void);
@@ -219,15 +219,15 @@ void print_syscall_ret(int num, abi_long arg1);
 extern int do_strace;
 
 /* signal.c */
-void process_pending_signals(CPUState *cpu_env);
+void process_pending_signals(CPUArchState *cpu_env);
 void signal_init(void);
-int queue_signal(CPUState *env, int sig, target_siginfo_t *info);
+int queue_signal(CPUArchState *env, int sig, target_siginfo_t *info);
 void host_to_target_siginfo(target_siginfo_t *tinfo, const siginfo_t *info);
 void target_to_host_siginfo(siginfo_t *info, const target_siginfo_t *tinfo);
 int target_to_host_signal(int sig);
 int host_to_target_signal(int sig);
-long do_sigreturn(CPUState *env);
-long do_rt_sigreturn(CPUState *env);
+long do_sigreturn(CPUArchState *env);
+long do_rt_sigreturn(CPUArchState *env);
 abi_long do_sigaltstack(abi_ulong uss_addr, abi_ulong uoss_addr, abi_ulong sp);
 
 #ifdef TARGET_I386
linux-user/signal.c +8 -8
index f44f78e..fca51e2 100644
@@ -347,7 +347,7 @@ void signal_init(void)
 
 /* signal queue handling */
 
-static inline struct sigqueue *alloc_sigqueue(CPUState *env)
+static inline struct sigqueue *alloc_sigqueue(CPUArchState *env)
 {
     TaskState *ts = env->opaque;
     struct sigqueue *q = ts->first_free;
@@ -357,7 +357,7 @@ static inline struct sigqueue *alloc_sigqueue(CPUState *env)
     return q;
 }
 
-static inline void free_sigqueue(CPUState *env, struct sigqueue *q)
+static inline void free_sigqueue(CPUArchState *env, struct sigqueue *q)
 {
     TaskState *ts = env->opaque;
     q->next = ts->first_free;
@@ -415,7 +415,7 @@ static void QEMU_NORETURN force_sig(int target_sig)
 
 /* queue a signal so that it will be send to the virtual CPU as soon
    as possible */
-int queue_signal(CPUState *env, int sig, target_siginfo_t *info)
+int queue_signal(CPUArchState *env, int sig, target_siginfo_t *info)
 {
     TaskState *ts = env->opaque;
     struct emulated_sigtable *k;
@@ -5214,25 +5214,25 @@ long do_rt_sigreturn(CPUAlphaState *env)
 #else
 
 static void setup_frame(int sig, struct target_sigaction *ka,
-			target_sigset_t *set, CPUState *env)
+			target_sigset_t *set, CPUArchState *env)
 {
     fprintf(stderr, "setup_frame: not implemented\n");
 }
 
 static void setup_rt_frame(int sig, struct target_sigaction *ka,
                            target_siginfo_t *info,
-			   target_sigset_t *set, CPUState *env)
+			   target_sigset_t *set, CPUArchState *env)
 {
     fprintf(stderr, "setup_rt_frame: not implemented\n");
 }
 
-long do_sigreturn(CPUState *env)
+long do_sigreturn(CPUArchState *env)
 {
     fprintf(stderr, "do_sigreturn: not implemented\n");
     return -TARGET_ENOSYS;
 }
 
-long do_rt_sigreturn(CPUState *env)
+long do_rt_sigreturn(CPUArchState *env)
 {
     fprintf(stderr, "do_rt_sigreturn: not implemented\n");
     return -TARGET_ENOSYS;
@@ -5240,7 +5240,7 @@ long do_rt_sigreturn(CPUState *env)
 
 #endif
 
-void process_pending_signals(CPUState *cpu_env)
+void process_pending_signals(CPUArchState *cpu_env)
 {
     int sig;
     abi_ulong handler;
linux-user/syscall.c +14 -14
index 29888bd..9f5e53a 100644
@@ -3955,7 +3955,7 @@ static abi_long do_arch_prctl(CPUX86State *env, int code, abi_ulong addr)
 
 static pthread_mutex_t clone_lock = PTHREAD_MUTEX_INITIALIZER;
 typedef struct {
-    CPUState *env;
+    CPUArchState *env;
     pthread_mutex_t mutex;
     pthread_cond_t cond;
     pthread_t thread;
@@ -3968,7 +3968,7 @@ typedef struct {
 static void *clone_func(void *arg)
 {
     new_thread_info *info = arg;
-    CPUState *env;
+    CPUArchState *env;
     TaskState *ts;
 
     env = info->env;
@@ -3998,7 +3998,7 @@ static void *clone_func(void *arg)
 
 static int clone_func(void *arg)
 {
-    CPUState *env = arg;
+    CPUArchState *env = arg;
     cpu_loop(env);
     /* never exits */
     return 0;
@@ -4007,13 +4007,13 @@ static int clone_func(void *arg)
 
 /* do_fork() Must return host values and target errnos (unlike most
    do_*() functions). */
-static int do_fork(CPUState *env, unsigned int flags, abi_ulong newsp,
+static int do_fork(CPUArchState *env, unsigned int flags, abi_ulong newsp,
                    abi_ulong parent_tidptr, target_ulong newtls,
                    abi_ulong child_tidptr)
 {
     int ret;
     TaskState *ts;
-    CPUState *new_env;
+    CPUArchState *new_env;
 #if defined(CONFIG_USE_NPTL)
     unsigned int nptl_flags;
     sigset_t sigmask;
@@ -4640,7 +4640,7 @@ int get_osversion(void)
 
 static int open_self_maps(void *cpu_env, int fd)
 {
-    TaskState *ts = ((CPUState *)cpu_env)->opaque;
+    TaskState *ts = ((CPUArchState *)cpu_env)->opaque;
 
     dprintf(fd, "%08llx-%08llx rw-p %08llx 00:00 0          [stack]\n",
                 (unsigned long long)ts->info->stack_limit,
@@ -4653,7 +4653,7 @@ static int open_self_maps(void *cpu_env, int fd)
 
 static int open_self_stat(void *cpu_env, int fd)
 {
-    TaskState *ts = ((CPUState *)cpu_env)->opaque;
+    TaskState *ts = ((CPUArchState *)cpu_env)->opaque;
     abi_ulong start_stack = ts->info->start_stack;
     int i;
 
@@ -4678,7 +4678,7 @@ static int open_self_stat(void *cpu_env, int fd)
 
 static int open_self_auxv(void *cpu_env, int fd)
 {
-    TaskState *ts = ((CPUState *)cpu_env)->opaque;
+    TaskState *ts = ((CPUArchState *)cpu_env)->opaque;
     abi_ulong auxv = ts->info->saved_auxv;
     abi_ulong len = ts->info->auxv_len;
     char *ptr;
@@ -4784,13 +4784,13 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
          be disabling signals.  */
       if (first_cpu->next_cpu) {
           TaskState *ts;
-          CPUState **lastp;
-          CPUState *p;
+          CPUArchState **lastp;
+          CPUArchState *p;
 
           cpu_list_lock();
           lastp = &first_cpu;
           p = first_cpu;
-          while (p && p != (CPUState *)cpu_env) {
+          while (p && p != (CPUArchState *)cpu_env) {
               lastp = &p->next_cpu;
               p = p->next_cpu;
           }
@@ -4801,7 +4801,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
           /* Remove the CPU from the list.  */
           *lastp = p->next_cpu;
           cpu_list_unlock();
-          ts = ((CPUState *)cpu_env)->opaque;
+          ts = ((CPUArchState *)cpu_env)->opaque;
           if (ts->child_tidptr) {
               put_user_u32(0, ts->child_tidptr);
               sys_futex(g2h(ts->child_tidptr), FUTEX_WAKE, INT_MAX,
@@ -6091,7 +6091,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
         break;
     case TARGET_NR_mprotect:
         {
-            TaskState *ts = ((CPUState *)cpu_env)->opaque;
+            TaskState *ts = ((CPUArchState *)cpu_env)->opaque;
             /* Special hack to detect libc making the stack executable.  */
             if ((arg3 & PROT_GROWSDOWN)
                 && arg1 >= ts->info->stack_limit
@@ -7076,7 +7076,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1,
 #if defined(TARGET_I386) || defined(TARGET_ARM) || defined(TARGET_MIPS) || \
     defined(TARGET_SPARC) || defined(TARGET_PPC) || defined(TARGET_ALPHA) || \
     defined(TARGET_M68K) || defined(TARGET_S390X)
-        ret = do_sigaltstack(arg1, arg2, get_sp_from_cpustate((CPUState *)cpu_env));
+        ret = do_sigaltstack(arg1, arg2, get_sp_from_cpustate((CPUArchState *)cpu_env));
         break;
 #else
         goto unimplemented;
monitor.c +28 -28

220 lines not on this page · raw message

poison.h +1 -1
index 5354e77..d396f20 100644
@@ -34,7 +34,7 @@
 #pragma GCC poison TARGET_PAGE_BITS
 #pragma GCC poison TARGET_PAGE_ALIGN
 
-#pragma GCC poison CPUState
+#pragma GCC poison CPUArchState
 #pragma GCC poison env
 
 #pragma GCC poison lduw_phys
softmmu-semi.h +6 -6
index 86a9f8a..648cb95 100644
@@ -7,14 +7,14 @@
  * This code is licensed under the GPL
  */
 
-static inline uint32_t softmmu_tget32(CPUState *env, uint32_t addr)
+static inline uint32_t softmmu_tget32(CPUArchState *env, uint32_t addr)
 {
     uint32_t val;
 
     cpu_memory_rw_debug(env, addr, (uint8_t *)&val, 4, 0);
     return tswap32(val);
 }
-static inline uint32_t softmmu_tget8(CPUState *env, uint32_t addr)
+static inline uint32_t softmmu_tget8(CPUArchState *env, uint32_t addr)
 {
     uint8_t val;
 
@@ -26,7 +26,7 @@ static inline uint32_t softmmu_tget8(CPUState *env, uint32_t addr)
 #define get_user_u8(arg, p) ({ arg = softmmu_tget8(env, p) ; 0; })
 #define get_user_ual(arg, p) get_user_u32(arg, p)
 
-static inline void softmmu_tput32(CPUState *env, uint32_t addr, uint32_t val)
+static inline void softmmu_tput32(CPUArchState *env, uint32_t addr, uint32_t val)
 {
     val = tswap32(val);
     cpu_memory_rw_debug(env, addr, (uint8_t *)&val, 4, 1);
@@ -34,7 +34,7 @@ static inline void softmmu_tput32(CPUState *env, uint32_t addr, uint32_t val)
 #define put_user_u32(arg, p) ({ softmmu_tput32(env, p, arg) ; 0; })
 #define put_user_ual(arg, p) put_user_u32(arg, p)
 
-static void *softmmu_lock_user(CPUState *env, uint32_t addr, uint32_t len,
+static void *softmmu_lock_user(CPUArchState *env, uint32_t addr, uint32_t len,
                                int copy)
 {
     uint8_t *p;
@@ -45,7 +45,7 @@ static void *softmmu_lock_user(CPUState *env, uint32_t addr, uint32_t len,
     return p;
 }
 #define lock_user(type, p, len, copy) softmmu_lock_user(env, p, len, copy)
-static char *softmmu_lock_user_string(CPUState *env, uint32_t addr)
+static char *softmmu_lock_user_string(CPUArchState *env, uint32_t addr)
 {
     char *p;
     char *s;
@@ -60,7 +60,7 @@ static char *softmmu_lock_user_string(CPUState *env, uint32_t addr)
     return s;
 }
 #define lock_user_string(p) softmmu_lock_user_string(env, p)
-static void softmmu_unlock_user(CPUState *env, void *p, target_ulong addr,
+static void softmmu_unlock_user(CPUArchState *env, void *p, target_ulong addr,
                                 target_ulong len)
 {
     if (len)
target-alpha/cpu.h +1 -1
index ecc2a35..48c0fdc 100644
@@ -25,7 +25,7 @@
 
 #define TARGET_LONG_BITS 64
 
-#define CPUState struct CPUAlphaState
+#define CPUArchState struct CPUAlphaState
 
 #include "cpu-defs.h"
 
target-arm/cpu.h +1 -1
index 2bbb5d1..26c114b 100644
@@ -23,7 +23,7 @@
 
 #define ELF_MACHINE	EM_ARM
 
-#define CPUState struct CPUARMState
+#define CPUArchState struct CPUARMState
 
 #include "config.h"
 #include "qemu-common.h"
target-cris/cpu.h +1 -1
index f38393a..31899c2 100644
@@ -25,7 +25,7 @@
 
 #define TARGET_LONG_BITS 32
 
-#define CPUState struct CPUCRISState
+#define CPUArchState struct CPUCRISState
 
 #include "cpu-defs.h"
 
target-i386/cpu.h +1 -1
index f337dd0..aacccb6 100644
@@ -42,7 +42,7 @@
 #define ELF_MACHINE	EM_386
 #endif
 
-#define CPUState struct CPUX86State
+#define CPUArchState struct CPUX86State
 
 #include "cpu-defs.h"
 
target-lm32/cpu.h +1 -1
index 684b2fa..0902a24 100644
@@ -22,7 +22,7 @@
 
 #define TARGET_LONG_BITS 32
 
-#define CPUState struct CPULM32State
+#define CPUArchState struct CPULM32State
 
 #include "config.h"
 #include "qemu-common.h"
target-m68k/cpu.h +1 -1
index 2c83b89..6696e30 100644
@@ -22,7 +22,7 @@
 
 #define TARGET_LONG_BITS 32
 
-#define CPUState struct CPUM68KState
+#define CPUArchState struct CPUM68KState
 
 #include "config.h"
 #include "qemu-common.h"
target-microblaze/cpu.h +1 -1
index 6ae5649..3b52421 100644
@@ -24,7 +24,7 @@
 
 #define TARGET_LONG_BITS 32
 
-#define CPUState struct CPUMBState
+#define CPUArchState struct CPUMBState
 
 #include "cpu-defs.h"
 #include "softfloat.h"
target-mips/cpu.h +1 -1
index 94381ec..7430aa5 100644
@@ -7,7 +7,7 @@
 
 #define ELF_MACHINE	EM_MIPS
 
-#define CPUState struct CPUMIPSState
+#define CPUArchState struct CPUMIPSState
 
 #include "config.h"
 #include "qemu-common.h"
target-ppc/cpu.h +1 -1
index 3508d8a..ad09cbe 100644
@@ -71,7 +71,7 @@
 
 #endif /* defined (TARGET_PPC64) */
 
-#define CPUState struct CPUPPCState
+#define CPUArchState struct CPUPPCState
 
 #include "cpu-defs.h"
 
target-s390x/cpu.h +1 -1
index af6cc4e..ea849fc 100644
@@ -26,7 +26,7 @@
 
 #define ELF_MACHINE	EM_S390
 
-#define CPUState struct CPUS390XState
+#define CPUArchState struct CPUS390XState
 
 #include "cpu-defs.h"
 #define TARGET_PAGE_BITS 12
target-sh4/cpu.h +1 -1
index b45e54f..965536d 100644
@@ -37,7 +37,7 @@
 #define SH_CPU_SH7750_ALL (SH_CPU_SH7750 | SH_CPU_SH7750S | SH_CPU_SH7750R)
 #define SH_CPU_SH7751_ALL (SH_CPU_SH7751 | SH_CPU_SH7751R)
 
-#define CPUState struct CPUSH4State
+#define CPUArchState struct CPUSH4State
 
 #include "cpu-defs.h"
 
target-sparc/cpu.h +1 -1
index 2c2cea7..86f9de6 100644
@@ -23,7 +23,7 @@
 # endif
 #endif
 
-#define CPUState struct CPUSPARCState
+#define CPUArchState struct CPUSPARCState
 
 #include "cpu-defs.h"
 
target-unicore32/cpu.h +1 -1
index 171f0a9..a3f8589 100644
@@ -18,7 +18,7 @@
 
 #define ELF_MACHINE             EM_UNICORE32
 
-#define CPUState                struct CPUUniCore32State
+#define CPUArchState                struct CPUUniCore32State
 
 #include "config.h"
 #include "qemu-common.h"
target-xtensa/cpu.h +1 -1
index b7723ca..a7bcf52 100644
@@ -31,7 +31,7 @@
 #define TARGET_LONG_BITS 32
 #define ELF_MACHINE EM_XTENSA
 
-#define CPUState struct CPUXtensaState
+#define CPUArchState struct CPUXtensaState
 
 #include "config.h"
 #include "qemu-common.h"
tcg/arm/tcg-target.c +11 -11
index 5b233f5..5af21b3 100644
@@ -990,10 +990,10 @@ static inline void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, int opc)
     tcg_out_dat_reg(s, COND_AL, ARITH_ADD, TCG_REG_R0, TCG_AREG0,
                     TCG_REG_R0, SHIFT_IMM_LSL(CPU_TLB_ENTRY_BITS));
     /* In the
-     *  ldr r1 [r0, #(offsetof(CPUState, tlb_table[mem_index][0].addr_read))]
+     *  ldr r1 [r0, #(offsetof(CPUArchState, tlb_table[mem_index][0].addr_read))]
      * below, the offset is likely to exceed 12 bits if mem_index != 0 and
      * not exceed otherwise, so use an
-     *  add r0, r0, #(mem_index * sizeof *CPUState.tlb_table)
+     *  add r0, r0, #(mem_index * sizeof *CPUArchState.tlb_table)
      * before.
      */
     if (mem_index)
@@ -1001,7 +1001,7 @@ static inline void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, int opc)
                         (mem_index << (TLB_SHIFT & 1)) |
                         ((16 - (TLB_SHIFT >> 1)) << 8));
     tcg_out_ld32_12(s, COND_AL, TCG_REG_R1, TCG_REG_R0,
-                    offsetof(CPUState, tlb_table[0][0].addr_read));
+                    offsetof(CPUArchState, tlb_table[0][0].addr_read));
     tcg_out_dat_reg(s, COND_AL, ARITH_CMP, 0, TCG_REG_R1,
                     TCG_REG_R8, SHIFT_IMM_LSL(TARGET_PAGE_BITS));
     /* Check alignment.  */
@@ -1012,12 +1012,12 @@ static inline void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, int opc)
     /* XXX: possibly we could use a block data load or writeback in
      * the first access.  */
     tcg_out_ld32_12(s, COND_EQ, TCG_REG_R1, TCG_REG_R0,
-                    offsetof(CPUState, tlb_table[0][0].addr_read) + 4);
+                    offsetof(CPUArchState, tlb_table[0][0].addr_read) + 4);
     tcg_out_dat_reg(s, COND_EQ, ARITH_CMP, 0,
                     TCG_REG_R1, addr_reg2, SHIFT_IMM_LSL(0));
 #  endif
     tcg_out_ld32_12(s, COND_EQ, TCG_REG_R1, TCG_REG_R0,
-                    offsetof(CPUState, tlb_table[0][0].addend));
+                    offsetof(CPUArchState, tlb_table[0][0].addend));
 
     switch (opc) {
     case 0:
@@ -1210,10 +1210,10 @@ static inline void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, int opc)
     tcg_out_dat_reg(s, COND_AL, ARITH_ADD, TCG_REG_R0,
                     TCG_AREG0, TCG_REG_R0, SHIFT_IMM_LSL(CPU_TLB_ENTRY_BITS));
     /* In the
-     *  ldr r1 [r0, #(offsetof(CPUState, tlb_table[mem_index][0].addr_write))]
+     *  ldr r1 [r0, #(offsetof(CPUArchState, tlb_table[mem_index][0].addr_write))]
      * below, the offset is likely to exceed 12 bits if mem_index != 0 and
      * not exceed otherwise, so use an
-     *  add r0, r0, #(mem_index * sizeof *CPUState.tlb_table)
+     *  add r0, r0, #(mem_index * sizeof *CPUArchState.tlb_table)
      * before.
      */
     if (mem_index)
@@ -1221,7 +1221,7 @@ static inline void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, int opc)
                         (mem_index << (TLB_SHIFT & 1)) |
                         ((16 - (TLB_SHIFT >> 1)) << 8));
     tcg_out_ld32_12(s, COND_AL, TCG_REG_R1, TCG_REG_R0,
-                    offsetof(CPUState, tlb_table[0][0].addr_write));
+                    offsetof(CPUArchState, tlb_table[0][0].addr_write));
     tcg_out_dat_reg(s, COND_AL, ARITH_CMP, 0, TCG_REG_R1,
                     TCG_REG_R8, SHIFT_IMM_LSL(TARGET_PAGE_BITS));
     /* Check alignment.  */
@@ -1232,12 +1232,12 @@ static inline void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, int opc)
     /* XXX: possibly we could use a block data load or writeback in
      * the first access.  */
     tcg_out_ld32_12(s, COND_EQ, TCG_REG_R1, TCG_REG_R0,
-                    offsetof(CPUState, tlb_table[0][0].addr_write) + 4);
+                    offsetof(CPUArchState, tlb_table[0][0].addr_write) + 4);
     tcg_out_dat_reg(s, COND_EQ, ARITH_CMP, 0,
                     TCG_REG_R1, addr_reg2, SHIFT_IMM_LSL(0));
 #  endif
     tcg_out_ld32_12(s, COND_EQ, TCG_REG_R1, TCG_REG_R0,
-                    offsetof(CPUState, tlb_table[0][0].addend));
+                    offsetof(CPUArchState, tlb_table[0][0].addend));
 
     switch (opc) {
     case 0:
@@ -1797,7 +1797,7 @@ static void tcg_target_init(TCGContext *s)
     tcg_regset_set_reg(s->reserved_regs, TCG_REG_PC);
 
     tcg_add_target_add_op_defs(arm_op_defs);
-    tcg_set_frame(s, TCG_AREG0, offsetof(CPUState, temp_buf),
+    tcg_set_frame(s, TCG_AREG0, offsetof(CPUArchState, temp_buf),
                   CPU_TEMP_BUF_NLONGS * sizeof(long));
 }
 
tcg/hppa/tcg-target.c +4 -4
index 59d4d12..6a67a41 100644
@@ -1040,13 +1040,13 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, int opc)
     lab1 = gen_new_label();
     lab2 = gen_new_label();
 
-    offset = offsetof(CPUState, tlb_table[mem_index][0].addr_read);
+    offset = offsetof(CPUArchState, tlb_table[mem_index][0].addr_read);
     offset = tcg_out_tlb_read(s, TCG_REG_R26, TCG_REG_R25, addrlo_reg, addrhi_reg,
                               opc & 3, lab1, offset);
 
     /* TLB Hit.  */
     tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_R20, (offset ? TCG_REG_R1 : TCG_REG_R25),
-               offsetof(CPUState, tlb_table[mem_index][0].addend) - offset);
+               offsetof(CPUArchState, tlb_table[mem_index][0].addend) - offset);
     tcg_out_qemu_ld_direct(s, datalo_reg, datahi_reg, addrlo_reg, TCG_REG_R20, opc);
     tcg_out_branch(s, lab2, 1);
 
@@ -1155,13 +1155,13 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, int opc)
     lab1 = gen_new_label();
     lab2 = gen_new_label();
 
-    offset = offsetof(CPUState, tlb_table[mem_index][0].addr_write);
+    offset = offsetof(CPUArchState, tlb_table[mem_index][0].addr_write);
     offset = tcg_out_tlb_read(s, TCG_REG_R26, TCG_REG_R25, addrlo_reg, addrhi_reg,
                               opc, lab1, offset);
 
     /* TLB Hit.  */
     tcg_out_ld(s, TCG_TYPE_PTR, TCG_REG_R20, (offset ? TCG_REG_R1 : TCG_REG_R25),
-               offsetof(CPUState, tlb_table[mem_index][0].addend) - offset);
+               offsetof(CPUArchState, tlb_table[mem_index][0].addend) - offset);
 
     /* There are no indexed stores, so we must do this addition explitly.
        Careful to avoid R20, which is used for the bswaps to follow.  */
tcg/i386/tcg-target.c +1 -1
index dc81572..424a56e 100644
@@ -1031,7 +1031,7 @@ static inline void tcg_out_tlb_load(TCGContext *s, int addrlo_idx,
                 (CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS, 0);
 
     tcg_out_modrm_sib_offset(s, OPC_LEA + P_REXW, r1, TCG_AREG0, r1, 0,
-                             offsetof(CPUState, tlb_table[mem_index][0])
+                             offsetof(CPUArchState, tlb_table[mem_index][0])
                              + which);
 
     /* cmp 0(r1), r0 */
tcg/ia64/tcg-target.c +5 -5
index e3de79f..f90252a 100644
@@ -1479,8 +1479,8 @@ static inline void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args, int opc)
 
     /* Read the TLB entry */
     tcg_out_qemu_tlb(s, addr_reg, s_bits,
-                     offsetof(CPUState, tlb_table[mem_index][0].addr_read),
-                     offsetof(CPUState, tlb_table[mem_index][0].addend));
+                     offsetof(CPUArchState, tlb_table[mem_index][0].addr_read),
+                     offsetof(CPUArchState, tlb_table[mem_index][0].addend));
 
     /* P6 is the fast path, and P7 the slow path */
     tcg_out_bundle(s, mLX,
@@ -1570,8 +1570,8 @@ static inline void tcg_out_qemu_st(TCGContext *s, const TCGArg *args, int opc)
 #endif
 
     tcg_out_qemu_tlb(s, addr_reg, opc,
-                     offsetof(CPUState, tlb_table[mem_index][0].addr_write),
-                     offsetof(CPUState, tlb_table[mem_index][0].addend));
+                     offsetof(CPUArchState, tlb_table[mem_index][0].addr_write),
+                     offsetof(CPUArchState, tlb_table[mem_index][0].addend));
 
     /* P6 is the fast path, and P7 the slow path */
     tcg_out_bundle(s, mLX,
@@ -2368,6 +2368,6 @@ static void tcg_target_init(TCGContext *s)
     tcg_regset_set_reg(s->reserved_regs, TCG_REG_R6);
 
     tcg_add_target_add_op_defs(ia64_op_defs);
-    tcg_set_frame(s, TCG_AREG0, offsetof(CPUState, temp_buf),
+    tcg_set_frame(s, TCG_AREG0, offsetof(CPUArchState, temp_buf),
                   CPU_TEMP_BUF_NLONGS * sizeof(long));
 }
tcg/mips/tcg-target.c +7 -7
index c5c3282..c6aa5bc 100644
@@ -827,7 +827,7 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args,
     tcg_out_opc_imm(s, OPC_ANDI, TCG_REG_A0, TCG_REG_A0, (CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS);
     tcg_out_opc_reg(s, OPC_ADDU, TCG_REG_A0, TCG_REG_A0, TCG_AREG0);
     tcg_out_opc_imm(s, OPC_LW, TCG_REG_AT, TCG_REG_A0,
-                    offsetof(CPUState, tlb_table[mem_index][0].addr_read) + addr_meml);
+                    offsetof(CPUArchState, tlb_table[mem_index][0].addr_read) + addr_meml);
     tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_T0, TARGET_PAGE_MASK | ((1 << s_bits) - 1));
     tcg_out_opc_reg(s, OPC_AND, TCG_REG_T0, TCG_REG_T0, addr_regl);
 
@@ -837,7 +837,7 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args,
     tcg_out_nop(s);
 
     tcg_out_opc_imm(s, OPC_LW, TCG_REG_AT, TCG_REG_A0,
-                    offsetof(CPUState, tlb_table[mem_index][0].addr_read) + addr_memh);
+                    offsetof(CPUArchState, tlb_table[mem_index][0].addr_read) + addr_memh);
 
     label1_ptr = s->code_ptr;
     tcg_out_opc_br(s, OPC_BEQ, addr_regh, TCG_REG_AT);
@@ -893,7 +893,7 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args,
     reloc_pc16(label1_ptr, (tcg_target_long) s->code_ptr);
 
     tcg_out_opc_imm(s, OPC_LW, TCG_REG_A0, TCG_REG_A0,
-                    offsetof(CPUState, tlb_table[mem_index][0].addend));
+                    offsetof(CPUArchState, tlb_table[mem_index][0].addend));
     tcg_out_opc_reg(s, OPC_ADDU, TCG_REG_V0, TCG_REG_A0, addr_regl);
 #else
     if (GUEST_BASE == (int16_t)GUEST_BASE) {
@@ -1013,7 +1013,7 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args,
     tcg_out_opc_imm(s, OPC_ANDI, TCG_REG_A0, TCG_REG_A0, (CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS);
     tcg_out_opc_reg(s, OPC_ADDU, TCG_REG_A0, TCG_REG_A0, TCG_AREG0);
     tcg_out_opc_imm(s, OPC_LW, TCG_REG_AT, TCG_REG_A0,
-                    offsetof(CPUState, tlb_table[mem_index][0].addr_write) + addr_meml);
+                    offsetof(CPUArchState, tlb_table[mem_index][0].addr_write) + addr_meml);
     tcg_out_movi(s, TCG_TYPE_I32, TCG_REG_T0, TARGET_PAGE_MASK | ((1 << s_bits) - 1));
     tcg_out_opc_reg(s, OPC_AND, TCG_REG_T0, TCG_REG_T0, addr_regl);
 
@@ -1023,7 +1023,7 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args,
     tcg_out_nop(s);
 
     tcg_out_opc_imm(s, OPC_LW, TCG_REG_AT, TCG_REG_A0,
-                    offsetof(CPUState, tlb_table[mem_index][0].addr_write) + addr_memh);
+                    offsetof(CPUArchState, tlb_table[mem_index][0].addr_write) + addr_memh);
 
     label1_ptr = s->code_ptr;
     tcg_out_opc_br(s, OPC_BEQ, addr_regh, TCG_REG_AT);
@@ -1080,7 +1080,7 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args,
     reloc_pc16(label1_ptr, (tcg_target_long) s->code_ptr);
 
     tcg_out_opc_imm(s, OPC_LW, TCG_REG_A0, TCG_REG_A0,
-                    offsetof(CPUState, tlb_table[mem_index][0].addend));
+                    offsetof(CPUArchState, tlb_table[mem_index][0].addend));
     tcg_out_opc_reg(s, OPC_ADDU, TCG_REG_A0, TCG_REG_A0, addr_regl);
 #else
     if (GUEST_BASE == (int16_t)GUEST_BASE) {
@@ -1529,6 +1529,6 @@ static void tcg_target_init(TCGContext *s)
     tcg_regset_set_reg(s->reserved_regs, TCG_REG_SP);   /* stack pointer */
 
     tcg_add_target_add_op_defs(mips_op_defs);
-    tcg_set_frame(s, TCG_AREG0, offsetof(CPUState, temp_buf),
+    tcg_set_frame(s, TCG_AREG0, offsetof(CPUArchState, temp_buf),
                   CPU_TEMP_BUF_NLONGS * sizeof(long));
 }
tcg/ppc/tcg-target.c +2 -2
index f5d9bf3..6a34cab 100644
@@ -564,7 +564,7 @@ static void tcg_out_qemu_ld (TCGContext *s, const TCGArg *args, int opc)
     tcg_out32 (s, (LWZU
                    | RT (r1)
                    | RA (r0)
-                   | offsetof (CPUState, tlb_table[mem_index][0].addr_read)
+                   | offsetof (CPUArchState, tlb_table[mem_index][0].addr_read)
                    )
         );
     tcg_out32 (s, (RLWINM
@@ -760,7 +760,7 @@ static void tcg_out_qemu_st (TCGContext *s, const TCGArg *args, int opc)
     tcg_out32 (s, (LWZU
                    | RT (r1)
                    | RA (r0)
-                   | offsetof (CPUState, tlb_table[mem_index][0].addr_write)
+                   | offsetof (CPUArchState, tlb_table[mem_index][0].addr_write)
                    )
         );
     tcg_out32 (s, (RLWINM
tcg/ppc64/tcg-target.c +2 -2
index 4419378..7f723b5 100644
@@ -635,7 +635,7 @@ static void tcg_out_qemu_ld (TCGContext *s, const TCGArg *args, int opc)
     rbase = 0;
 
     tcg_out_tlb_read (s, r0, r1, r2, addr_reg, s_bits,
-                      offsetof (CPUState, tlb_table[mem_index][0].addr_read));
+                      offsetof (CPUArchState, tlb_table[mem_index][0].addr_read));
 
     tcg_out32 (s, CMP | BF (7) | RA (r2) | RB (r1) | CMP_L);
 
@@ -782,7 +782,7 @@ static void tcg_out_qemu_st (TCGContext *s, const TCGArg *args, int opc)
     rbase = 0;
 
     tcg_out_tlb_read (s, r0, r1, r2, addr_reg, opc,
-                      offsetof (CPUState, tlb_table[mem_index][0].addr_write));
+                      offsetof (CPUArchState, tlb_table[mem_index][0].addr_write));
 
     tcg_out32 (s, CMP | BF (7) | RA (r2) | RB (r1) | CMP_L);
 
tcg/s390/tcg-target.c +4 -4
index 9317fe8..47ffcc1 100644
@@ -1439,9 +1439,9 @@ static void tcg_prepare_qemu_ldst(TCGContext* s, TCGReg data_reg,
     tgen64_andi_tmp(s, arg1, (CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS);
 
     if (is_store) {
-        ofs = offsetof(CPUState, tlb_table[mem_index][0].addr_write);
+        ofs = offsetof(CPUArchState, tlb_table[mem_index][0].addr_write);
     } else {
-        ofs = offsetof(CPUState, tlb_table[mem_index][0].addr_read);
+        ofs = offsetof(CPUArchState, tlb_table[mem_index][0].addr_read);
     }
     assert(ofs < 0x80000);
 
@@ -1515,7 +1515,7 @@ static void tcg_prepare_qemu_ldst(TCGContext* s, TCGReg data_reg,
     *(label1_ptr + 1) = ((unsigned long)s->code_ptr -
                          (unsigned long)label1_ptr) >> 1;
 
-    ofs = offsetof(CPUState, tlb_table[mem_index][0].addend);
+    ofs = offsetof(CPUArchState, tlb_table[mem_index][0].addend);
     assert(ofs < 0x80000);
 
     tcg_out_mem(s, 0, RXY_AG, arg0, arg1, TCG_AREG0, ofs);
@@ -2293,7 +2293,7 @@ static void tcg_target_init(TCGContext *s)
     tcg_regset_set_reg(s->reserved_regs, TCG_REG_CALL_STACK);
 
     tcg_add_target_add_op_defs(s390_op_defs);
-    tcg_set_frame(s, TCG_AREG0, offsetof(CPUState, temp_buf),
+    tcg_set_frame(s, TCG_AREG0, offsetof(CPUArchState, temp_buf),
                   CPU_TEMP_BUF_NLONGS * sizeof(long));
 }
 
tcg/sparc/tcg-target.c +2 -2
index 5cd5a3b..d723f1b 100644
@@ -776,7 +776,7 @@ static void tcg_out_qemu_ld(TCGContext *s, const TCGArg *args,
     tcg_out_andi(s, arg1, (CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS);
 
     /* add arg1, x, arg1 */
-    tcg_out_addi(s, arg1, offsetof(CPUState,
+    tcg_out_addi(s, arg1, offsetof(CPUArchState,
                                    tlb_table[mem_index][0].addr_read));
 
     /* add env, arg1, arg1 */
@@ -988,7 +988,7 @@ static void tcg_out_qemu_st(TCGContext *s, const TCGArg *args,
     tcg_out_andi(s, arg1, (CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS);
 
     /* add arg1, x, arg1 */
-    tcg_out_addi(s, arg1, offsetof(CPUState,
+    tcg_out_addi(s, arg1, offsetof(CPUArchState,
                                    tlb_table[mem_index][0].addr_write));
 
     /* add env, arg1, arg1 */
tcg/tci/tcg-target.c +1 -1
index fc0880c..bd85073 100644
@@ -891,7 +891,7 @@ static void tcg_target_init(TCGContext *s)
     tcg_regset_clear(s->reserved_regs);
     tcg_regset_set_reg(s->reserved_regs, TCG_REG_CALL_STACK);
     tcg_add_target_add_op_defs(tcg_target_op_defs);
-    tcg_set_frame(s, TCG_AREG0, offsetof(CPUState, temp_buf),
+    tcg_set_frame(s, TCG_AREG0, offsetof(CPUArchState, temp_buf),
                   CPU_TEMP_BUF_NLONGS * sizeof(long));
 }
 
tcg/tci/tcg-target.h +1 -1
index 81fcc0f..b61e99a 100644
@@ -154,7 +154,7 @@ typedef enum {
 
 void tci_disas(uint8_t opc);
 
-unsigned long tcg_qemu_tb_exec(CPUState *env, uint8_t *tb_ptr);
+unsigned long tcg_qemu_tb_exec(CPUArchState *env, uint8_t *tb_ptr);
 #define tcg_qemu_tb_exec tcg_qemu_tb_exec
 
 static inline void flush_icache_range(tcg_target_ulong start,
tci.c +2 -2
index a20a714..fb9ebef 100644
@@ -52,7 +52,7 @@ typedef uint64_t (*helper_function)(tcg_target_ulong, tcg_target_ulong,
 
 /* TCI can optionally use a global register variable for env. */
 #if !defined(AREG0)
-CPUState *env;
+CPUArchState *env;
 #endif
 
 /* Targets which don't use GETPC also don't need tci_tb_ptr
@@ -429,7 +429,7 @@ static bool tci_compare64(uint64_t u0, uint64_t u1, TCGCond condition)
 }
 
 /* Interpret pseudo code in tb. */
-unsigned long tcg_qemu_tb_exec(CPUState *cpustate, uint8_t *tb_ptr)
+unsigned long tcg_qemu_tb_exec(CPUArchState *cpustate, uint8_t *tb_ptr)
 {
     unsigned long next_tb = 0;
 
translate-all.c +2 -2
index 041c108..8c7d303 100644
@@ -51,7 +51,7 @@ void cpu_gen_init(void)
    '*gen_code_size_ptr' contains the size of the generated code (host
    code).
 */
-int cpu_gen_code(CPUState *env, TranslationBlock *tb, int *gen_code_size_ptr)
+int cpu_gen_code(CPUArchState *env, TranslationBlock *tb, int *gen_code_size_ptr)
 {
     TCGContext *s = &tcg_ctx;
     uint8_t *gen_code_buf;
@@ -109,7 +109,7 @@ int cpu_gen_code(CPUState *env, TranslationBlock *tb, int *gen_code_size_ptr)
 /* The cpu state corresponding to 'searched_pc' is restored.
  */
 int cpu_restore_state(TranslationBlock *tb,
-                      CPUState *env, unsigned long searched_pc)
+                      CPUArchState *env, unsigned long searched_pc)
 {
     TCGContext *s = &tcg_ctx;
     int j;
user-exec.c +2 -2
index abf6885..cd905ff 100644
@@ -38,7 +38,7 @@
 
 //#define DEBUG_SIGNAL
 
-static void exception_action(CPUState *env1)
+static void exception_action(CPUArchState *env1)
 {
 #if defined(TARGET_I386)
     raise_exception_err_env(env1, env1->exception_index, env1->error_code);
@@ -50,7 +50,7 @@ static void exception_action(CPUState *env1)
 /* exit the current TB from a signal handler. The host registers are
    restored in a state compatible with the CPU emulator
  */
-void cpu_resume_from_signal(CPUState *env1, void *puc)
+void cpu_resume_from_signal(CPUArchState *env1, void *puc)
 {
 #ifdef __linux__
     struct ucontext *uc = puc;
xen-all.c +2 -2
index 6cef506..493112b 100644
@@ -530,14 +530,14 @@ static MemoryListener xen_memory_listener = {
 
 static void xen_reset_vcpu(void *opaque)
 {
-    CPUState *env = opaque;
+    CPUArchState *env = opaque;
 
     env->halted = 1;
 }
 
 void xen_vcpu_init(void)
 {
-    CPUState *first_cpu;
+    CPUArchState *first_cpu;
 
     if ((first_cpu = qemu_get_cpu(0))) {
         qemu_register_reset(xen_reset_vcpu, first_cpu);
Signature · 1 line
1.7.7
#64 lore raw

Re: [Qemu-devel] [PATCH RFC v4 43/44] Rename CPUState -> CPUArchState

Am 10.03.2012 03:28, schrieb Andreas Färber:

Quoted 2 lines

---

FWIW this commit message is missing the sed command used for automatic conversion. It's in the cover letter, and I'll add it for v5/PULL if there is consensus to go ahead with "CPUState".

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Reviewed-by
#65 lore raw

Re: [Qemu-devel] [PATCH RFC v4 43/44] Rename CPUState -> CPUArchState

Quoted 7 lines · Andreas Färber

Am 10.03.2012 03:28, schrieb Andreas Färber:

Quoted 2 lines

---

FWIW this commit message is missing the sed command used for automatic conversion. It's in the cover letter, and I'll add it for v5/PULL if there is consensus to go ahead with "CPUState".

Even without the sed command, the conversion is straight forward.

Regards,

Anthony Liguori

Quoted 3 lines

Andreas

#66 lore raw

RFC PATCH v4 44/44 qom: Introduce CPU class

In reply to Andreas Färber

Reintroduce CPUState as QOM object: It's abstract and derived directly from TYPE_OBJECT for compatibility with the user emulators. The identifier CPUState avoids conflicts between CPU() and the struct.

Introduce $(qom-twice-y) to build it separately for system and for user emulators.

Prepare a virtual reset method, (re)introduce cpu_reset() as wrapper.

---
 Makefile.objs      |    3 ++
 configure          |    1 +
 include/qemu/cpu.h |   75 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 qom/Makefile       |    1 +
 qom/cpu.c          |   58 ++++++++++++++++++++++++++++++++++++++++
 5 files changed, 138 insertions(+), 0 deletions(-)
 create mode 100644 include/qemu/cpu.h
 create mode 100644 qom/cpu.c
Makefile.objs +3 -0
index 431b7a1..291baf5 100644
@@ -14,6 +14,7 @@ universal-obj-y += $(qobject-obj-y)
 # QOM
 include $(SRC_PATH)/qom/Makefile
 qom-obj-y = $(addprefix qom/, $(qom-y))
+qom-obj-twice-y = $(addprefix qom/, $(qom-twice-y))
 
 universal-obj-y += $(qom-obj-y)
 
@@ -89,6 +90,7 @@ fsdev-obj-$(CONFIG_VIRTFS) += $(addprefix fsdev/, $(fsdev-nested-y))
 
 common-obj-y = $(block-obj-y) blockdev.o
 common-obj-y += $(net-obj-y)
+common-obj-y += $(qom-obj-twice-y)
 common-obj-$(CONFIG_LINUX) += $(fsdev-obj-$(CONFIG_LINUX))
 common-obj-y += readline.o console.o cursor.o
 common-obj-y += $(oslib-obj-y)
@@ -194,6 +196,7 @@ user-obj-y += cutils.o cache-utils.o
 user-obj-y += module.o
 user-obj-y += qemu-user.o
 user-obj-y += $(trace-obj-y)
+user-obj-y += $(qom-obj-twice-y)
 
 ######################################################################
 # libhw
configure +1 -0
index 66a65d9..1826af5 100755
@@ -3888,6 +3888,7 @@ fi
 d=libuser
 mkdir -p $d
 mkdir -p $d/trace
+mkdir -p $d/qom
 symlink $source_path/Makefile.user $d/Makefile
 
 if test "$docs" = "yes" ; then
include/qemu/cpu.h new file +75 -0

75 lines not on this page · raw message

qom/Makefile +1 -0
index 885a263..34c6de5 100644
@@ -1 +1,2 @@
 qom-y = object.o container.o qom-qobject.o
+qom-twice-y = cpu.o
qom/cpu.c new file +58 -0

58 lines not on this page · raw message

Signature · 1 line
1.7.7
#67 lore raw

Re: [Qemu-devel] [PATCH RFC v4 44/44] qom: Introduce CPU class

Quoted 108 lines · Andreas Färber

Reintroduce CPUState as QOM object: It's abstract and derived directly from TYPE_OBJECT for compatibility with the user emulators. The identifier CPUState avoids conflicts between CPU() and the struct.

Introduce $(qom-twice-y) to build it separately for system and for user emulators.

Prepare a virtual reset method, (re)introduce cpu_reset() as wrapper.

---
  Makefile.objs      |    3 ++
  configure          |    1 +
  include/qemu/cpu.h |   75 ++++++++++++++++++++++++++++++++++++++++++++++++++++
  qom/Makefile       |    1 +
  qom/cpu.c          |   58 ++++++++++++++++++++++++++++++++++++++++
  5 files changed, 138 insertions(+), 0 deletions(-)

create mode 100644 include/qemu/cpu.h
create mode 100644 qom/cpu.c

Makefile.objs +3 -0
index 431b7a1..291baf5 100644
@@ -14,6 +14,7 @@ universal-obj-y += $(qobject-obj-y)
  # QOM
  include $(SRC_PATH)/qom/Makefile
  qom-obj-y = $(addprefix qom/, $(qom-y))
+qom-obj-twice-y = $(addprefix qom/, $(qom-twice-y))
 
  universal-obj-y += $(qom-obj-y)
 
@@ -89,6 +90,7 @@ fsdev-obj-$(CONFIG_VIRTFS) += $(addprefix fsdev/, $(fsdev-nested-y))
 
  common-obj-y = $(block-obj-y) blockdev.o
  common-obj-y += $(net-obj-y)
+common-obj-y += $(qom-obj-twice-y)
  common-obj-$(CONFIG_LINUX) += $(fsdev-obj-$(CONFIG_LINUX))
  common-obj-y += readline.o console.o cursor.o
  common-obj-y += $(oslib-obj-y)
@@ -194,6 +196,7 @@ user-obj-y += cutils.o cache-utils.o
  user-obj-y += module.o
  user-obj-y += qemu-user.o
  user-obj-y += $(trace-obj-y)
+user-obj-y += $(qom-obj-twice-y)
 
  ######################################################################
  # libhw
configure +1 -0
index 66a65d9..1826af5 100755
@@ -3888,6 +3888,7 @@ fi
  d=libuser
  mkdir -p $d
  mkdir -p $d/trace
+mkdir -p $d/qom
  symlink $source_path/Makefile.user $d/Makefile
 
  if test "$docs" = "yes" ; then
include/qemu/cpu.h new file +41 -0
new file mode 100644
index 0000000..4291279
@@ -0,0 +1,75 @@
+/*
+ * QEMU CPU model
+ *
+ * Copyright (c) 2012 SUSE LINUX Products GmbH
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see
+ *<http://www.gnu.org/licenses/gpl-2.0.html>
+ */
+#ifndef QEMU_CPU_H
+#define QEMU_CPU_H
+
+#include "qemu/object.h"
+
+/**
+ * SECTION:cpu
+ * @section_id: QEMU-cpu
+ * @title: CPU Class
+ * @short_description: Base class for all CPUs
+ */
+
+#define TYPE_CPU "cpu"
+
+#define CPU(obj) OBJECT_CHECK(CPUState, (obj), TYPE_CPU)
+#define CPU_CLASS(class) OBJECT_CLASS_CHECK(CPUClass, (class), TYPE_CPU)
+#define CPU_GET_CLASS(obj) OBJECT_GET_CLASS(CPUClass, (obj), TYPE_CPU)
+
+typedef struct CPUState CPUState;
+
+/**
+ * CPUClass:

include/qemu/cpu.h line 51

Quoted 10 lines
include/qemu/cpu.h new file +10 -0
+ * @reset: Callback to reset the #CPU to its initial state.
+ *
+ * Represents a CPU family or model.
+ */
+typedef struct CPUClass {
+    /*<  private>*/
+    ObjectClass parent_class;
+    /*<  public>*/
+
+    void (*reset)(CPUState *cpu);

Why not use Object* as argument here?
It will be easier to generalize later qdev code and not make special case when adding cpus.

BTW how we are going to generalize qdev and make its infrastructure available to other types except of DEVICE_TYPE.
Maybe we should introduce some (abstract) base class (or interface) for basic device that will define methods like reset, realize, unrealize and use it in qdev code instead of DEVICE_TYPE?

Quoted 95 lines
include/qemu/cpu.h new file +24 -0
+} CPUClass;
+
+/**
+ * CPUState:
+ *
+ * State of one CPU core or thread.
+ */
+struct CPUState {
+    /*<  private>*/
+    Object parent_obj;
+    /*<  public>*/
+
+    /* TODO Move common fields from CPUState here. */
+};
+
+
+/**
+ * cpu_reset:
+ * @cpu: The CPU whose state is to be reset.
+ */
+void cpu_reset(CPUState *cpu);
+
+
+#endif
qom/Makefile +1 -0
index 885a263..34c6de5 100644
@@ -1 +1,2 @@
  qom-y = object.o container.o qom-qobject.o
+qom-twice-y = cpu.o
qom/cpu.c new file +58 -0
new file mode 100644
index 0000000..5b36046
@@ -0,0 +1,58 @@
+/*
+ * QEMU CPU model
+ *
+ * Copyright (c) 2012 SUSE LINUX Products GmbH
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see
+ *<http://www.gnu.org/licenses/gpl-2.0.html>
+ */
+
+#include "qemu/cpu.h"
+#include "qemu-common.h"
+
+void cpu_reset(CPUState *cpu)
+{
+    CPUClass *klass = CPU_GET_CLASS(cpu);
+
+    if (klass->reset != NULL) {
+        (*klass->reset)(cpu);
+    }
+}
+
+static void cpu_common_reset(CPUState *cpu)
+{
+}
+
+static void cpu_class_init(ObjectClass *klass, void *data)
+{
+    CPUClass *k = CPU_CLASS(klass);
+
+    k->reset = cpu_common_reset;
+}
+
+static TypeInfo cpu_type_info = {
+    .name = TYPE_CPU,
+    .parent = TYPE_OBJECT,
+    .instance_size = sizeof(CPUState),
+    .abstract = true,
+    .class_size = sizeof(CPUClass),
+    .class_init = cpu_class_init,
+};
+
+static void cpu_register_types(void)
+{
+    type_register_static(&cpu_type_info);
+}
+
+type_init(cpu_register_types)
Signature · 2 lines
-----
 Igor
#68 lore raw

Re: [Qemu-devel] [PATCH RFC v4 44/44] qom: Introduce CPU class

Am 12.03.2012 10:38, schrieb Igor Mammedov:

Quoted 29 lines · Andreas Färber
Quoted 27 lines

Reintroduce CPUState as QOM object: It's abstract and derived directly from TYPE_OBJECT for compatibility with the user emulators. The identifier CPUState avoids conflicts between CPU() and the struct.

Introduce $(qom-twice-y) to build it separately for system and for user emulators.

Prepare a virtual reset method, (re)introduce cpu_reset() as wrapper.

---
  Makefile.objs      |    3 ++
  configure          |    1 +
  include/qemu/cpu.h |   75
++++++++++++++++++++++++++++++++++++++++++++++++++++
  qom/Makefile       |    1 +
  qom/cpu.c          |   58 ++++++++++++++++++++++++++++++++++++++++
  5 files changed, 138 insertions(+), 0 deletions(-)

create mode 100644 include/qemu/cpu.h
create mode 100644 qom/cpu.c

include/qemu/cpu.h new file +0 -0
new file mode 100644
index 0000000..4291279
Quoted 13 lines

include/qemu/cpu.h line 51

Quoted 12 lines
include/qemu/cpu.h new file +12 -0
+/**
+ * CPUClass:
+ * @reset: Callback to reset the #CPU to its initial state.
+ *
+ * Represents a CPU family or model.
+ */
+typedef struct CPUClass {
+    /*<  private>*/
+    ObjectClass parent_class;
+    /*<  public>*/
+
+    void (*reset)(CPUState *cpu);

Why not use Object* as argument here?

In SysBusDeviceClass etc. we use the specific object type, too. Obviously my CPU is the first "new" QOM type, so we can go different ways if we want to. As long as it's a CPU-specific mechanism, using the specific type avoids some casts.

Quoted 3 lines

It will be easier to generalize later qdev code and not make special case when
adding cpus.

I never heard anyone wanting to generalize reset so far. I don't think it belongs into Object at least. Maybe DeviceState. Anthony? Paolo?

Quoted 8 lines

BTW how we are going to generalize qdev and make its infrastructure available
to other types except of DEVICE_TYPE.
Maybe we should introduce some (abstract) base class (or interface) for basic
device that will define methods like reset, realize, unrealize and use it in
qdev code instead of DEVICE_TYPE?

I thought Anthony wanted to do realize/unrealize and "realized" property in Object.

For SH4 I worked around that with my own sh7750_realize() function. This series is taking much too long to move forward (the QOM "steam" seems to be gone?) and I'm worried that introducing much more basic infrastructure will make review and applying even slower, cf. object_class_foreach_ordered()/_get_list().

Thanks for reviewing so far,

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
maintainer
#69 lore raw

Re: [Qemu-devel] [PATCH RFC v4 44/44] qom: Introduce CPU class

Il 13/03/2012 13:13, Andreas Färber ha scritto:

Quoted 5 lines
Quoted 2 lines

It will be easier to generalize later qdev code and not make special case when adding cpus.

I never heard anyone wanting to generalize reset so far. I don't think it belongs into Object at least. Maybe DeviceState. Anthony? Paolo?

I believe long term we want CPUs to become a DeviceState. For now, I think Andreas's prototype is fine. Methods should not take a superclass argument in general.

Quoted 4 lines

This series is taking much too long to move forward (the QOM "steam" seems to be gone?) and I'm worried that introducing much more basic infrastructure will make review and applying even slower, cf. object_class_foreach_ordered()/_get_list().

Agreed, this series looks more or less good (and mostly mechanical anyway). Is it an RFC or what? :) I wonder if reviewers are put off by the subject.

Paolo

#70 lore raw

Re: [Qemu-devel] [PATCH RFC v4 44/44] qom: Introduce CPU class

Am 13.03.2012 13:20, schrieb Paolo Bonzini:

Quoted 9 lines

Il 13/03/2012 13:13, Andreas Färber ha scritto:

Quoted 5 lines
Quoted 2 lines

It will be easier to generalize later qdev code and not make special case when adding cpus.

I never heard anyone wanting to generalize reset so far. I don't think it belongs into Object at least. Maybe DeviceState. Anthony? Paolo?

I believe long term we want CPUs to become a DeviceState. For now, I think Andreas's prototype is fine.

I have prepared $(qom-obj-twice-y) to allow for:

#ifdef CONFIG_SOFTMMU
.parent = TYPE_DEVICE, // or TYPE_SYS_BUS_DEVICE
#else
.parent = TYPE_OBJECT,
#endif

So far it was not needed. :)

Quoted 2 lines

Methods should not take a superclass
argument in general.

So to clarify, this is pro CPUState?

Quoted 7 lines
Quoted 4 lines

This series is taking much too long to move forward (the QOM "steam" seems to be gone?) and I'm worried that introducing much more basic infrastructure will make review and applying even slower, cf. object_class_foreach_ordered()/_get_list().

Agreed, this series looks more or less good (and mostly mechanical anyway).

Thanks.

Quoted 2 lines

Is it an RFC or what? :) I wonder if reviewers are put off by
the subject.

The implied RFC is, are we okay with reusing "CPUState" this way? Or does someone - last call! - have a better identifier name?

Getting this series merged either means coordinating the PULL with a maintainer so that no merge conflicts arise in-flight, or having the maintainer re-run the commit-creating script himself.

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
maintainer
#71 lore raw

Re: [Qemu-devel] [PATCH RFC v4 44/44] qom: Introduce CPU class

Il 13/03/2012 13:53, Andreas Färber ha scritto:

Quoted 3 lines
Quoted 2 lines
Quoted 2 lines

Methods should not take a superclass
argument in general.

So to clarify, this is pro CPUState?

Yes.

Quoted 9 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines

This series is taking much too long to move forward (the QOM "steam" seems to be gone?) and I'm worried that introducing much more basic infrastructure will make review and applying even slower, cf. object_class_foreach_ordered()/_get_list().

Agreed, this series looks more or less good (and mostly mechanical anyway).

Thanks.

Quoted 8 lines
Quoted 2 lines
Quoted 2 lines

Is it an RFC or what? :) I wonder if reviewers are put off by
the subject.

The implied RFC is, are we okay with reusing "CPUState" this way? Or does someone - last call! - have a better identifier name?

Getting this series merged either means coordinating the PULL with a maintainer so that no merge conflicts arise in-flight, or having the maintainer re-run the commit-creating script himself.

FWIW I like it. :)

Paolo

#72 lore raw

Re: [Qemu-devel] [PATCH RFC v4 44/44] qom: Introduce CPU class

In reply to Paolo Bonzini
Quoted 10 lines · Paolo Bonzini

Il 13/03/2012 13:13, Andreas Färber ha scritto:

Quoted 5 lines
Quoted 2 lines

It will be easier to generalize later qdev code and not make special case when adding cpus.

I never heard anyone wanting to generalize reset so far. I don't think it belongs into Object at least. Maybe DeviceState. Anthony? Paolo?

I believe long term we want CPUs to become a DeviceState. For now, I think Andreas's prototype is fine. Methods should not take a superclass argument in general.

Agreed 100%. Methods should take whatever there class is as the argument.

Quoted 9 lines
Quoted 5 lines

This series is taking much too long to move forward (the QOM "steam" seems to be gone?) and I'm worried that introducing much more basic infrastructure will make review and applying even slower, cf. object_class_foreach_ordered()/_get_list().

Agreed, this series looks more or less good (and mostly mechanical anyway). Is it an RFC or what? :) I wonder if reviewers are put off by the subject.

44 patches is a bit scary. Had I realized it was so straight forward, I would have reviewed it faster.

Anyway, I'm really happy with the whole series. If it weren't an RFC, I'd apply it right now.

Andreas, please send out a new series that's !rfc or a pull request.

Really great work here, btw!

Regards,

Anthony Liguori

Quoted 3 lines

Paolo

#73 lore raw

Re: [Qemu-devel] [PATCH RFC v4 44/44] qom: Introduce CPU class

In reply to Andreas Färber
Quoted 5 lines · Andreas Färber

In SysBusDeviceClass etc. we use the specific object type, too. Obviously my CPU is the first "new" QOM type, so we can go different ways if we want to. As long as it's a CPU-specific mechanism, using the specific type avoids some casts.

Quoted 7 lines
Quoted 3 lines

It will be easier to generalize later qdev code and not make special case when
adding cpus.

I never heard anyone wanting to generalize reset so far. I don't think it belongs into Object at least. Maybe DeviceState. Anthony? Paolo?

We can have a special object for this, let's call it ResetLine for example, with methods ResetLine::connect, ResetLine::assert or something like that. Different ResetLine objects could trigger reset of different sets of subdevices, just like real hardware can have several reset types (for example, STM32 has 3 different reset types).

#74 lore raw

Re: [Qemu-devel] [PATCH RFC v4 44/44] qom: Introduce CPU class

Quoted 15 lines · Igor Mitsyanko
Quoted 5 lines · Andreas Färber

In SysBusDeviceClass etc. we use the specific object type, too. Obviously my CPU is the first "new" QOM type, so we can go different ways if we want to. As long as it's a CPU-specific mechanism, using the specific type avoids some casts.

Quoted 7 lines
Quoted 3 lines

It will be easier to generalize later qdev code and not make special case when
adding cpus.

I never heard anyone wanting to generalize reset so far. I don't think it belongs into Object at least. Maybe DeviceState. Anthony? Paolo?

Quoted 5 lines

We can have a special object for this, let's call it ResetLine for example, with methods ResetLine::connect, ResetLine::assert or something like that. Different ResetLine objects could trigger reset of different sets of subdevices, just like real hardware can have several reset types (for example, STM32 has 3 different reset types).

I've explored a bunch of different models for this. My current thinking is a realized:bool property that when set, would call a realize() virtual method and when unset would call an unrealize() virtual method. The default implementation of [un]realize() would propagate the change to all composition children.

At one point, I modeled this as a Vcc Pin with similar semantics except that instead of relying on a property accessor, the realize function would connect to the device's Vcc pin to the children's Vcc pins via a set of Wire objects (that just propagate Pin state).

This later model is too low level IMHO. I think we should stick with the functional realize property which covers 99% of devices. For the 1%, we can use pins or just have additional properties as appropriate.

Regards,

Anthony Liguori

#75 lore raw

Re: [Qemu-devel] [PATCH RFC v4 44/44] qom: Introduce CPU class

Am 14.03.2012 20:48, schrieb Anthony Liguori:

Quoted 26 lines · Igor Mitsyanko
Quoted 15 lines · Andreas Färber
Quoted 6 lines

In SysBusDeviceClass etc. we use the specific object type, too. Obviously my CPU is the first "new" QOM type, so we can go different ways if we want to. As long as it's a CPU-specific mechanism, using the specific type avoids some casts.

Quoted 7 lines
Quoted 3 lines

It will be easier to generalize later qdev code and not make special case when
adding cpus.

I never heard anyone wanting to generalize reset so far. I don't think it belongs into Object at least. Maybe DeviceState. Anthony? Paolo?

Quoted 9 lines

We can have a special object for this, let's call it ResetLine for example, with
methods ResetLine::connect, ResetLine::assert or something like that. Different
ResetLine objects could trigger reset of different sets of subdevices, just like
real hardware can have several reset types (for example, STM32 has 3 different
reset types).

Quoted 5 lines

I've explored a bunch of different models for this. My current thinking is a realized:bool property that when set, would call a realize() virtual method and when unset would call an unrealize() virtual method. The default implementation of [un]realize() would propagate the change to all composition children.

I've found that model not to work with today's qdev remainders: We often have a dependency tree of initfn and init a.k.a. realize functions, so that we can't clearly separate between the two to do recursive processing. Unless we do a three-stage initialization of Object::initfn, what-is-now-DeviceState::init, Object::realize.

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#76 lore raw

Re: [Qemu-devel] [PATCH RFC v4 44/44] qom: Introduce CPU class

Quoted 33 lines · Andreas Färber

Am 14.03.2012 20:48, schrieb Anthony Liguori:

Quoted 26 lines · Igor Mitsyanko
Quoted 15 lines · Andreas Färber
Quoted 6 lines

In SysBusDeviceClass etc. we use the specific object type, too. Obviously my CPU is the first "new" QOM type, so we can go different ways if we want to. As long as it's a CPU-specific mechanism, using the specific type avoids some casts.

Quoted 7 lines
Quoted 3 lines

It will be easier to generalize later qdev code and not make special case when
adding cpus.

I never heard anyone wanting to generalize reset so far. I don't think it belongs into Object at least. Maybe DeviceState. Anthony? Paolo?

Quoted 9 lines

We can have a special object for this, let's call it ResetLine for example, with
methods ResetLine::connect, ResetLine::assert or something like that. Different
ResetLine objects could trigger reset of different sets of subdevices, just like
real hardware can have several reset types (for example, STM32 has 3 different
reset types).

Quoted 5 lines

I've explored a bunch of different models for this. My current thinking is a realized:bool property that when set, would call a realize() virtual method and when unset would call an unrealize() virtual method. The default implementation of [un]realize() would propagate the change to all composition children.

Quoted 5 lines

I've found that model not to work with today's qdev remainders: We often have a dependency tree of initfn and init a.k.a. realize functions, so that we can't clearly separate between the two to do recursive processing. Unless we do a three-stage initialization of Object::initfn, what-is-now-DeviceState::init, Object::realize.

Yes, there's quite a lot of refactoring to get to a two stage recursive init. This is why realized isn't a part of QOM/qdev today.

Regards,

Anthony Liguori

Quoted 3 lines

Andreas

#77 lore raw

Re: [Qemu-devel] [PATCH RFC v4 44/44] qom: Introduce CPU class

In reply to Igor Mitsyanko

Am 14.03.2012 21:37, schrieb Igor Mitsyanko:

Quoted 11 lines · Andreas Färber
Quoted 4 lines

I never heard anyone wanting to generalize reset so far. I don't think it belongs into Object at least. Maybe DeviceState. Anthony? Paolo?

We can have a special object for this, let's call it ResetLine for example, with methods ResetLine::connect, ResetLine::assert or something like that. Different ResetLine objects could trigger reset of different sets of subdevices, just like real hardware can have several reset types (for example, STM32 has 3 different reset types).

Anthony provided a Reviewed-by, and given that this is a direct conversion of cpu_reset() -> cpu_state_reset() -> CPUState::reset(), I am preparing a PULL for this series tonight. That does not mean that the code must stay like this forever. :)

cpu_reset() only handles the full reset of one CPU, as I understand, and is called both at startup and at machine-level reset.

Anthony's Pin object, as qemu_irq successor, was planned post-4th QOM series, I believe. -- "Small steps, Allie."

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#78 lore raw

Re: [Qemu-devel] [PATCH RFC v4 44/44] qom: Introduce CPU class

Quoted 18 lines · Andreas Färber

Am 14.03.2012 21:37, schrieb Igor Mitsyanko:

Quoted 11 lines · Andreas Färber
Quoted 4 lines

I never heard anyone wanting to generalize reset so far. I don't think it belongs into Object at least. Maybe DeviceState. Anthony? Paolo?

We can have a special object for this, let's call it ResetLine for example, with methods ResetLine::connect, ResetLine::assert or something like that. Different ResetLine objects could trigger reset of different sets of subdevices, just like real hardware can have several reset types (for example, STM32 has 3 different reset types).

Anthony provided a Reviewed-by, and given that this is a direct conversion of cpu_reset() -> cpu_state_reset() -> CPUState::reset(), I am preparing a PULL for this series tonight. That does not mean that the code must stay like this forever. :)

Quoted 5 lines

cpu_reset() only handles the full reset of one CPU, as I understand, and is called both at startup and at machine-level reset.

Anthony's Pin object, as qemu_irq successor, was planned post-4th QOM series, I believe. -- "Small steps, Allie."

Ack.

Regards,

Anthony Liguori

Quoted 3 lines

Andreas

#79 lore raw

v4 cover QOM'ify ARM CPU

In reply to Andreas Färber

Hello,

Since the ARM target lately has been the target with the highest rate of changes, let's convert it first, as a proof of concept. Especially its reset handler can be greatly simplified through QOM.

Patch 1 is a RESEND of object_class_get_list() v2. Needed for virtually every target.

Patch 2 moves the CPUID lookup to ARMCPUClass. Patch 3 integrates legacy CPUARMState into ARMCPU.

Patches 5-17 step by step move CPUID-dependent initializations to CPU-specific code. Patch 6 is a proof of concept for CPUState -> CPU lookup.

(NEW:)
Patch 18 adds CPU properties to manipulate parts of the CPUID (MIDR). Patch 19 uses them to drop CPU classes that differ only by variant and revision. Patch 20 adds a "/cpu" property for -M integratorcp (a single-CPU board for which we have a test image on qemu.org) to allow inspection of CPU properties over QMP.

Available at:
http://repo.or.cz/w/qemu/afaerber.git/shortlog/refs/heads/qom-cpu-arm.v4

Regards,
Andreas

Cc Anthony Liguori <[email protected]>
Cc Peter Maydell <[email protected]>
Cc Paul Brook <[email protected]>
Cc Andrzej Zaborowski <[email protected]>

v3 -> v4:
* Rebased on top of type_init() v2, object_class_get_list() v2, qom-cpu v4.

* Rename cpu-core.h to cpu-qom.h. While the term "ARM core" is quite common, it is less so for other architectures like s390x so use a neutral term.
* Use container_of() for CPUState -> CPU macros (suggested by Anthony).
* Rework arm_env_get_object() -> arm_env_get_cpu(), avoids some casts (suggested by Anthony). Also rename ENV_GET_OBJECT() -> ENV_GET_CPU().
* Sort -cpu ? list.
* Use object_class_get_list() and sort ourselves rather than using object_class_foreach_ordered() with callbacks (suggested by Anthony).
* Drop ARMCPUClass jtag_id since it turned out unneeded in QEMU (Peter+Andrzej).

* Drop experimental "halted" property since that should be in common code.
* Introduce "cpuid-variant" and "cpuid-revision" properties.
* Use CPU properties to drop unneeded pxa270-* classes.
* Move "/cpu" child property to integratorcp machine.

v2 -> v3:
* Rebased against qom-upstream.14 branch (and that against master).

* Rename target-arm/cpu-core.c to cpu.c now that we no longer need VPATH.
* Leave cpu-core.h as is to separate from legacy cpu.h.
* Fix -cpu alias "pxa270": handled in cpu_arm_init().
* Use proper GPL headers.

* Start removing CPUID uses in cpu_reset_model_id() and cpu.h.
* Fully convert cpu_reset_model_id() to ARMCPUInfo or per-model code.

* Experiment with adding properties ("halted").
* For testing, add a "/cpu" child property (HACK).

v1 -> v2:

* Cherry-pick Anthony's object_class_foreach() patch.

* Fix ARMCPUClass type name (arm-cpu-core -> arm-cpu).
* Add documentation.
* Rename ARMCPUDef to ARMCPUInfo.
* Use a C99-style table for initializing the classes through class_data instead of individual class_init functions (suggested by Anthony).
* Prepare reset callback.

* Make ENV_GET_OBJECT() use an inline function for readability.
* Invoke the CPU's reset method from cpu_reset().

* Do feature initialization via table where sensible.
* Add feature flags to ARMCPU as well (suggested by PMM for future tweaking, also simplifies load/save a bit) and initialize them from ARMCPUClass.
* Make feature inference work for ARMCPU as well by not passing the ARMCPUClass. Use function-local macros to avoid the ugliness of deferencing the features pointer.

Andreas Färber (20):
qom: Introduce object_class_get_list()
target-arm: Introduce QOM ARMCPUClass
target-arm: Embed CPUARMState in QOM ARMCPU
target-arm: Prepare model-specific class_init function
target-arm: Overwrite reset handler for ti925t
target-arm: Move CPU feature flags out of CPUState
target-arm: No longer abort on unhandled CPUIDs on reset
target-arm: Store cp15 c0_c1 and c0_c2 in ARMCPUClass
target-arm: Store CTR in ARMCPUClass
target-arm: Store SCTLR in ARMCPUClass
target-arm: Drop JTAG_ID documentation
target-arm: Move the PXA270's iwMMXt reset to pxa270_reset()
target-arm: Store VFP FPSID register in ARMCPUClass
target-arm: Store VFP MVFR0 and MVFR1 in ARMCPUClass
target-arm: Store CLIDR in ARMCPUClass
target-arm: Store CCSIDRs in ARMCPUClass
target-arm: Kill off cpu_reset_model_id()
target-arm: Add cpuid-{variant,revision} properties to CPU
target-arm: Simplify pxa270 CPU classes hw/integratorcp: Add child property for CPU

 Makefile.target       |    1 +
 hw/integratorcp.c     |    3 +
 include/qemu/object.h |   11 +
 qom/object.c          |   17 ++
 target-arm/cpu-qom.h  |   98 ++++++++
 target-arm/cpu.c      |  643 +++++++++++++++++++++++++++++++++++++++++++++++++
 target-arm/cpu.h      |   27 +--
 target-arm/helper.c   |  471 ++++++------------------------------
 target-arm/machine.c  |    6 +-
 9 files changed, 851 insertions(+), 426 deletions(-)
 create mode 100644 target-arm/cpu-qom.h
 create mode 100644 target-arm/cpu.c
Signature · 1 line
1.7.7
#80 lore raw

PATCH RESEND v2 1/20 qom: Introduce object_class_get_list()

This function allows to obtain a singly-linked list of classes, which can be sorted by the caller.

---
 include/qemu/object.h |   11 +++++++++++
 qom/object.c          |   17 +++++++++++++++++
 2 files changed, 28 insertions(+), 0 deletions(-)
include/qemu/object.h +11 -0
index ec2d294..e8fc126 100644
@@ -560,6 +560,17 @@ ObjectClass *object_class_by_name(const char *typename);
 void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque),
                           const char *implements_type, bool include_abstract,
                           void *opaque);
+
+/**
+ * object_class_get_list:
+ * @implements_type: The type to filter for, including its derivatives.
+ * @include_abstract: Whether to include abstract classes.
+ *
+ * Returns: A singly-linked list of the classes in reverse hashtable order.
+ */
+GSList *object_class_get_list(const char *implements_type,
+                              bool include_abstract);
+
 /**
  * object_ref:
  * @obj: the object
qom/object.c +17 -0
index aa037d2..eef0b22 100644
@@ -572,6 +572,23 @@ void object_class_foreach(void (*fn)(ObjectClass *klass, void *opaque),
     g_hash_table_foreach(type_table_get(), object_class_foreach_tramp, &data);
 }
 
+static void object_class_get_list_tramp(ObjectClass *klass, void *opaque)
+{
+    GSList **list = opaque;
+
+    *list = g_slist_prepend(*list, klass);
+}
+
+GSList *object_class_get_list(const char *implements_type,
+                              bool include_abstract)
+{
+    GSList *list = NULL;
+
+    object_class_foreach(object_class_get_list_tramp,
+                         implements_type, include_abstract, &list);
+    return list;
+}
+
 void object_ref(Object *obj)
 {
     obj->ref++;
Signature · 1 line
1.7.7
#81 lore raw

RFC PATCH v4 2/20 target-arm: Introduce QOM ARMCPUClass

In reply to Andreas Färber

Create a CPU subclass, and register classes matching all CPU models except for "pxa270", which is an alias for "pxa270-a0".

Let arm_cpu_list() enumerate CPU subclasses in alphabetical order, except for special value "any".

Replace cpu_arm_find_by_name()'s string -> CPUID lookup by storing the CPUID in the class.
NB: CPUIDs were first introduced by Paul Brook in r1765 (2006).

Cc Anthony Liguori <[email protected]>
Cc Paul Brook <[email protected]>
Cc Peter Maydell <[email protected]>
---
 Makefile.target      |    1 +
 target-arm/cpu-qom.h |   64 +++++++++++++++++
 target-arm/cpu.c     |  193 ++++++++++++++++++++++++++++++++++++++++++++++++++
 target-arm/cpu.h     |    1 -
 target-arm/helper.c  |  108 +++++++++++++---------------
 5 files changed, 308 insertions(+), 59 deletions(-)
 create mode 100644 target-arm/cpu-qom.h
 create mode 100644 target-arm/cpu.c
Makefile.target +1 -0
index cb1532a..c2c4bca 100644
@@ -87,6 +87,7 @@ endif
 libobj-$(TARGET_SPARC64) += vis_helper.o
 libobj-$(CONFIG_NEED_MMU) += mmu.o
 libobj-$(TARGET_ARM) += neon_helper.o iwmmxt_helper.o
+libobj-$(TARGET_ARM) += cpu.o
 ifeq ($(TARGET_BASE_ARCH), sparc)
 libobj-y += fop_helper.o cc_helper.o win_helper.o mmu_helper.o ldst_helper.o
 libobj-y += cpu_init.o
target-arm/cpu-qom.h new file +64 -0

64 lines not on this page · raw message

target-arm/cpu.c new file +193 -0

193 lines not on this page · raw message

target-arm/cpu.h +0 -1
index 26c114b..4cfa09c 100644
@@ -420,7 +420,6 @@ void cpu_arm_set_cp_io(CPUARMState *env, int cpnum,
 #define ARM_CPUID_PXA260      0x69052903
 #define ARM_CPUID_PXA261      0x69052d05
 #define ARM_CPUID_PXA262      0x69052d06
-#define ARM_CPUID_PXA270      0x69054110
 #define ARM_CPUID_PXA270_A0   0x69054110
 #define ARM_CPUID_PXA270_A1   0x69054111
 #define ARM_CPUID_PXA270_B0   0x69054112
target-arm/helper.c +50 -58

150 lines not on this page · raw message

Signature · 1 line
1.7.7
#82 lore raw

Re: [Qemu-devel] [PATCH RFC v4 02/20] target-arm: Introduce QOM ARMCPUClass

Quoted 272 lines · Andreas Färber

Create a CPU subclass, and register classes matching all CPU models except for "pxa270", which is an alias for "pxa270-a0".

Let arm_cpu_list() enumerate CPU subclasses in alphabetical order, except for special value "any".

Replace cpu_arm_find_by_name()'s string -> CPUID lookup by storing the CPUID in the class.
NB: CPUIDs were first introduced by Paul Brook in r1765 (2006).

Cc Anthony Liguori<[email protected]>
Cc Paul Brook<[email protected]>
Cc Peter Maydell<[email protected]>
---
  Makefile.target      |    1 +
  target-arm/cpu-qom.h |   64 +++++++++++++++++
  target-arm/cpu.c     |  193 ++++++++++++++++++++++++++++++++++++++++++++++++++
  target-arm/cpu.h     |    1 -
  target-arm/helper.c  |  108 +++++++++++++---------------
  5 files changed, 308 insertions(+), 59 deletions(-)

create mode 100644 target-arm/cpu-qom.h
create mode 100644 target-arm/cpu.c

Makefile.target +1 -0
index cb1532a..c2c4bca 100644
@@ -87,6 +87,7 @@ endif
  libobj-$(TARGET_SPARC64) += vis_helper.o
  libobj-$(CONFIG_NEED_MMU) += mmu.o
  libobj-$(TARGET_ARM) += neon_helper.o iwmmxt_helper.o
+libobj-$(TARGET_ARM) += cpu.o
  ifeq ($(TARGET_BASE_ARCH), sparc)
  libobj-y += fop_helper.o cc_helper.o win_helper.o mmu_helper.o ldst_helper.o
  libobj-y += cpu_init.o
target-arm/cpu-qom.h new file +64 -0
new file mode 100644
index 0000000..b2917ea
@@ -0,0 +1,64 @@
+/*
+ * QEMU ARM CPU
+ *
+ * Copyright (c) 2012 SUSE LINUX Products GmbH
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see
+ *<http://www.gnu.org/licenses/gpl-2.0.html>
+ */
+#ifndef QEMU_ARM_CPU_QOM_H
+#define QEMU_ARM_CPU_QOM_H
+
+#include "qemu/cpu.h"
+
+#define TYPE_ARM_CPU "arm-cpu"
+
+#define ARM_CPU_CLASS(klass) \
+    OBJECT_CLASS_CHECK(ARMCPUClass, (klass), TYPE_ARM_CPU)
+#define ARM_CPU(obj) \
+    OBJECT_CHECK(ARMCPU, (obj), TYPE_ARM_CPU)
+#define ARM_CPU_GET_CLASS(obj) \
+    OBJECT_GET_CLASS(ARMCPUClass, (obj), TYPE_ARM_CPU)
+
+/**
+ * ARMCPUClass:
+ * @parent_reset: The parent class' reset handler.
+ *
+ * An ARM CPU model.
+ */
+typedef struct ARMCPUClass {
+    /*<  private>*/
+    CPUClass parent_class;
+    /*<  public>*/
+
+    void (*parent_reset)(CPUState *cpu);
+
+    struct {
+        uint32_t c0_cpuid;
+    } cp15;
+} ARMCPUClass;
+
+/**
+ * ARMCPU:
+ *
+ * An ARM CPU core.
+ */
+typedef struct ARMCPU {
+    /*<  private>*/
+    CPUState parent_obj;
+    /*<  public>*/
+} ARMCPU;
+
+
+#endif
target-arm/cpu.c new file +160 -0
new file mode 100644
index 0000000..dabc094
@@ -0,0 +1,193 @@
+/*
+ * QEMU ARM CPU
+ *
+ * Copyright (c) 2012 SUSE LINUX Products GmbH
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see
+ *<http://www.gnu.org/licenses/gpl-2.0.html>
+ */
+
+#include "cpu-qom.h"
+#include "qemu-common.h"
+
+static void arm_cpu_reset(CPUState *c)
+{
+    ARMCPUClass *klass = ARM_CPU_GET_CLASS(c);
+
+    klass->parent_reset(c);
+}
+
+/* CPU models */
+
+typedef struct ARMCPUInfo {
+    const char *name;
+    uint32_t id;
+} ARMCPUInfo;
+
+static const ARMCPUInfo arm_cpus[] = {
+    {
+        .name = "arm926",
+        .id = 0x41069265,
+    },
+    {
+        .name = "arm946",
+        .id = 0x41059461,
+    },
+    {
+        .name = "arm1026",
+        .id = 0x4106a262,
+    },
+    /* What QEMU calls "arm1136-r2" is actually the 1136 r0p2, i.e. an
+     * older core than plain "arm1136". In particular this does not
+     * have the v6K features.
+     */
+    {
+        .name = "arm1136-r2",
+        .id = 0x4107b362,
+    },
+    {
+        .name = "arm1136",
+        .id = 0x4117b363,
+    },
+    {
+        .name = "arm1176",
+        .id = 0x410fb767,
+    },
+    {
+        .name = "arm11mpcore",
+        .id = 0x410fb022,
+    },
+    {
+        .name = "cortex-m3",
+        .id = 0x410fc231,
+    },
+    {
+        .name = "cortex-a8",
+        .id = 0x410fc080,
+    },
+    {
+        .name = "cortex-a9",
+        .id = 0x410fc090,
+    },
+    {
+        .name = "cortex-a15",
+        .id = 0x412fc0f1,
+    },
+    {
+        .name = "ti925t",
+        .id = 0x54029252,
+    },
+    {
+        .name = "sa1100",
+        .id = 0x4401A11B,
+    },
+    {
+        .name = "sa1110",
+        .id = 0x6901B119,
+    },
+    {
+        .name = "pxa250",
+        .id = 0x69052100,
+    },
+    {
+        .name = "pxa255",
+        .id = 0x69052d00,
+    },
+    {
+        .name = "pxa260",
+        .id = 0x69052903,
+    },
+    {
+        .name = "pxa261",
+        .id = 0x69052d05,
+    },
+    {
+        .name = "pxa262",
+        .id = 0x69052d06,
+    },
+    {
+        .name = "pxa270-a0",
+        .id = 0x69054110,
+    },
+    {
+        .name = "pxa270-a1",
+        .id = 0x69054111,
+    },
+    {
+        .name = "pxa270-b0",
+        .id = 0x69054112,
+    },
+    {
+        .name = "pxa270-b1",
+        .id = 0x69054113,
+    },
+    {
+        .name = "pxa270-c0",
+        .id = 0x69054114,
+    },
+    {
+        .name = "pxa270-c5",
+        .id = 0x69054117,
+    },
+    {
+        .name = "any",
+        .id = 0xffffffff,
+    },
+};
+
+static void arm_cpu_class_init(ObjectClass *klass, void *data)
+{
+    ARMCPUClass *k = ARM_CPU_CLASS(klass);
+    CPUClass *cpu_class = CPU_CLASS(klass);
+    const ARMCPUInfo *info = data;
+
+    k->parent_reset = cpu_class->reset;
+    cpu_class->reset = arm_cpu_reset;
+
+    k->cp15.c0_cpuid = info->id;
+}
+

target-arm/cpu.c line 170

Quoted 10 lines
target-arm/cpu.c new file +10 -0
+static void cpu_register(const ARMCPUInfo *info)
+{
+    TypeInfo type = {
+        .name = info->name,
+        .parent = TYPE_ARM_CPU,
+        .instance_size = sizeof(ARMCPU),
+        .class_size = sizeof(ARMCPUClass),
+        .class_init = arm_cpu_class_init,
+        .class_data = (void *)info,
+    };

Are non-initialized members guaranteed to be zero here?

target-arm/cpu.c line 174

Quoted 3 lines
target-arm/cpu.c new file +3 -0
+    type_register_static(&type);
+}
+

Probably should be type_register() here in case these two will actually differ in the future.

If this information is of any help, we've got no problems when emulating ARM-based Exynos boards in QEMU with this whole patchset applied.

Signature · 3 lines
Mitsyanko Igor
ASWG, Moscow R&D center, Samsung Electronics
email: [email protected]
#83 lore raw

Re: [Qemu-devel] [PATCH RFC v4 02/20] target-arm: Introduce QOM ARMCPUClass

Am 13.03.2012 13:31, schrieb Igor Mitsyanko:

Quoted 6 lines · Andreas Färber
Quoted 5 lines
target-arm/cpu.c new file +0 -0
new file mode 100644
index 0000000..dabc094

[...]

Quoted 4 lines
Quoted 4 lines
target-arm/cpu.c new file +4 -0
+static void cpu_register(const ARMCPUInfo *info)
+{
+    TypeInfo type = {
+        .name = info->name,
Quoted 8 lines

target-arm/cpu.c line 170

Quoted 6 lines
target-arm/cpu.c new file +6 -0
+        .parent = TYPE_ARM_CPU,
+        .instance_size = sizeof(ARMCPU),
+        .class_size = sizeof(ARMCPUClass),
+        .class_init = arm_cpu_class_init,
+        .class_data = (void *)info,
+    };

Are non-initialized members guaranteed to be zero here?

I thought so for the C99-style struct initialization... I never ran into crashes while testing. Do we need static to be safe?

Quoted 6 lines

target-arm/cpu.c line 174

Quoted 3 lines
target-arm/cpu.c new file +3 -0
+    type_register_static(&type);
+}
+

Probably should be type_register() here in case these two will actually differ in the future.

My thinking was we don't need it here because the data (esp. strings) are not dynamically allocated. By comparison, I used type_register() for -cpudef in target-i386, I believe.

But I really guess it's a bug that they're just an alias right now! ;)

Quoted 2 lines

If this information is of any help, we've got no problems when emulating ARM-based Exynos boards in QEMU with this whole patchset applied.

Thanks a lot for testing!

Have you thought about how to QOM'ify your boards? Mid-term I'd like to see an "exynos4210" object with the CPUs on it - maybe "cpu[0]" and "cpu[1]" child properties? Or "core[x]"? I had played with the sh7750 a bit on my branch but like the arm926 it's a single-core.

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#84 lore raw

Re: [Qemu-devel] [PATCH RFC v4 02/20] target-arm: Introduce QOM ARMCPUClass

Quoted 10 lines · Andreas Färber
Quoted 7 lines

target-arm/cpu.c line 164

Quoted 4 lines
target-arm/cpu.c new file +4 -0
+static void cpu_register(const ARMCPUInfo *info)
+{
+    TypeInfo type = {
+        .name = info->name,

Are non-initialized members guaranteed to be zero here?

I thought so for the C99-style struct initialization... I never ran into crashes while testing. Do we need static to be safe?

Yes, C99 guarantees in 6.7.8 p19:

The initialization shall occur in initializer list order, each initializer provided for a particular subobject overriding any previously listed initializer for the same subobject; all subobjects that are not initialized explicitly shall be initialized implicitly the same as objects that have static storage duration.

Signature · 2 lines
Eric Blake   [email protected]    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#85 lore raw

Re: [Qemu-devel] [PATCH RFC v4 02/20] target-arm: Introduce QOM ARMCPUClass

Quoted 10 lines · Eric Blake
Quoted 8 lines · Andreas Färber
Quoted 7 lines

target-arm/cpu.c line 164

Quoted 4 lines
target-arm/cpu.c new file +4 -0
+static void cpu_register(const ARMCPUInfo *info)
+{
+    TypeInfo type = {
+        .name = info->name,

Are non-initialized members guaranteed to be zero here?

Quoted 4 lines
Quoted 2 lines

I thought so for the C99-style struct initialization... I never ran into crashes while testing. Do we need static to be safe?

Yes, C99 guarantees in 6.7.8 p19:

Apologies for my ambiguous answer. Yes, C99 guarantees that non-mentioned members are 0-initialized if you have at least one explicit initialization. Therefore, no, you don't need static to be safe.

Signature · 2 lines
Eric Blake   [email protected]    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
maintainer
#86 lore raw

Re: [Qemu-devel] [PATCH RFC v4 02/20] target-arm: Introduce QOM ARMCPUClass

In reply to Andreas Färber

Il 13/03/2012 18:58, Andreas Färber ha scritto:

Quoted 2 lines
Quoted 1 line
Quoted 1 line

Are non-initialized members guaranteed to be zero here?

I thought so for the C99-style struct initialization...

Yes.

Quoted 2 lines

I never ran into
crashes while testing. Do we need static to be safe?

No, I don't think so. It would raise other questions (static seems to imply that the lifetime needs to extend across multiple calls, one could wonder if it is safe to reuse TypeInfos that way; with stack-allocated storage it's more obvious).

Paolo

#87 lore raw

Re: [Qemu-devel] [PATCH RFC v4 02/20] target-arm: Introduce QOM ARMCPUClass

In reply to Andreas Färber
Quoted 4 lines · Andreas Färber

Have you thought about how to QOM'ify your boards? Mid-term I'd like to see an "exynos4210" object with the CPUs on it - maybe "cpu[0]" and "cpu[1]" child properties? Or "core[x]"? I had played with the sh7750 a bit on my branch but like the arm926 it's a single-core.

I think the exynos4210 object should have a single child object cortex-a9 which in turn has child objects for core[0], core[1], gic, scu, and the private timers and watchdogs.

In hardware the A9 is a single block which includes all the cores and all the onboard peripherals; we should model it the same way.

One step in this direction might be to disentangle the GIC so that a9mpcore_priv and friends instantiate a GIC object as a child object rather than subclassing the GIC. I think now that Avi has made sub-page-size memory regions work we can get the M profile NVIC code out of arm_gic.c and have a standalone GIC object everybody instantiates.

-- PMM

#88 lore raw

Re: [Qemu-devel] [PATCH RFC v4 02/20] target-arm: Introduce QOM ARMCPUClass

In reply to Andreas Färber
Quoted 27 lines · Andreas Färber

Am 13.03.2012 13:31, schrieb Igor Mitsyanko:

Quoted 6 lines · Andreas Färber
Quoted 5 lines
target-arm/cpu.c new file +0 -0
new file mode 100644
index 0000000..dabc094

[...]

Quoted 11 lines

target-arm/cpu.c line 170

Quoted 10 lines
target-arm/cpu.c new file +10 -0
+static void cpu_register(const ARMCPUInfo *info)
+{
+    TypeInfo type = {
+        .name = info->name,
+        .parent = TYPE_ARM_CPU,
+        .instance_size = sizeof(ARMCPU),
+        .class_size = sizeof(ARMCPUClass),
+        .class_init = arm_cpu_class_init,
+        .class_data = (void *)info,
+    };

Are non-initialized members guaranteed to be zero here?

I thought so for the C99-style struct initialization... I never ran into crashes while testing. Do we need static to be safe?

Quoted 5 lines

target-arm/cpu.c line 174

Quoted 3 lines
target-arm/cpu.c new file +3 -0
+    type_register_static(&type);
+}
+

Probably should be type_register() here in case these two will actually differ in the future.

Quoted 6 lines

My thinking was we don't need it here because the data (esp. strings) are not dynamically allocated. By comparison, I used type_register() for -cpudef in target-i386, I believe.

But I really guess it's a bug that they're just an alias right now! ;)

Object.h states we need to use type_register_static() only when TypeInfo exists for the lifetime of
Type. As I understand this, TypeInfo must have *static const* storage qualifier when used with type_register_static() and can have automatic storage qualifier when used with type_register(). Maybe in the future type_register_static() will just copy a pointer to string variables of passed
TypeInfo instead of g_strdup() them, then your code wouldn't work as expected.

Quoted 11 lines
Quoted 2 lines

If this information is of any help, we've got no problems when emulating ARM-based Exynos boards in QEMU with this whole patchset applied.

Thanks a lot for testing!

Have you thought about how to QOM'ify your boards? Mid-term I'd like to see an "exynos4210" object with the CPUs on it - maybe "cpu[0]" and "cpu[1]" child properties? Or "core[x]"? I had played with the sh7750 a bit on my branch but like the arm926 it's a single-core.

Andreas

Yes, we've done some work on this, but we are waiting to see how you want to proceed with SoC
QOM type, and if you're going to introduce it at all. Personally I have no idea what members and
methods a general SoC type could have.
And another question, should we somehow exploit a fact that majority of peripheral devices on
SoCs share i/o ports with each other and only a handful of them are actually active at the same
time. Currently we instantiate all SoC devices even if half of them are not used in emulated configuration. Maybe we should dynamically create/destroy devices depending on runtime GPIO configuration, or make all devices a board's child instead of SoC's child. Not sure that it's worth an effort though.

As for CPU's object, Peter's idea with CortexA9 and core1, core2 childs looks good to me.

Signature · 3 lines
Mitsyanko Igor
ASWG, Moscow R&D center, Samsung Electronics
email: [email protected]
#89 lore raw

RFC PATCH v4 3/20 target-arm: Embed CPUARMState in QOM ARMCPU

In reply to Andreas Färber

We g_malloc0()'ed CPUARMState ourself, and exec.c's cpu_copy() runs through cpu_init() as well, so we are at liberty to supply the CPUState any way we see fit. Having CPUARMState as field in the QOM CPU allows both to access env from an ARMCPU object and to access the QOM Object and its ObjectClass from an env pointer, in ARM code for now.

The goal is to convert all CPUs to QOM and to use CPU objects in central places, especially once we have property support for Object. This will then allow to have TCG AREG0 point to target-specific fields where small immediate offsets are desired (as pointed out by rth) while allowing for common fields at known offsets from the base class.

Having the CPUID in ARMCPUClass, we can set it from the instance_init function. Same for cpu_model_str, which is now the QOM class name.

Make cpu_state_reset() call cpu_reset() and move most of its code to arm_cpu_reset().

Cc Anthony Liguori <[email protected]>
Cc Peter Maydell <[email protected]>
Cc Richard Henderson <[email protected]>
---
 target-arm/cpu-qom.h |   12 +++++++
 target-arm/cpu.c     |   82 ++++++++++++++++++++++++++++++++++++++++++++++++++
 target-arm/helper.c  |   75 ++++------------------------------------------
 3 files changed, 100 insertions(+), 69 deletions(-)
target-arm/cpu-qom.h +12 -0
index b2917ea..9e33b6a 100644
@@ -21,6 +21,7 @@
 #define QEMU_ARM_CPU_QOM_H
 
 #include "qemu/cpu.h"
+#include "cpu.h"
 
 #define TYPE_ARM_CPU "arm-cpu"
 
@@ -51,6 +52,7 @@ typedef struct ARMCPUClass {
 
 /**
  * ARMCPU:
+ * @env: Legacy CPU state.
  *
  * An ARM CPU core.
  */
@@ -58,7 +60,17 @@ typedef struct ARMCPU {
     /*< private >*/
     CPUState parent_obj;
     /*< public >*/
+
+    /* TODO Inline this and split off common state */
+    CPUARMState env;
 } ARMCPU;
 
+static inline ARMCPU *arm_env_get_cpu(CPUARMState *env)
+{
+    return ARM_CPU(container_of(env, ARMCPU, env));
+}
+
+#define ENV_GET_CPU(e) CPU(arm_env_get_cpu(e))
+
 
 #endif
target-arm/cpu.c +82 -0

106 lines not on this page · raw message

target-arm/helper.c +6 -69

121 lines not on this page · raw message

Signature · 1 line
1.7.7
maintainer
#90 lore raw

Re: [Qemu-devel] [PATCH RFC v4 03/20] target-arm: Embed CPUARMState in QOM ARMCPU

Il 10/03/2012 17:53, Andreas Färber ha scritto:

Quoted 7 lines

/**
* ARMCPU:
+ * @env: Legacy CPU state.
*
* An ARM CPU core.
*/

target-arm/cpu-qom.h typedef struct ARMCPU { · line 67

Quoted 8 lines
target-arm/cpu-qom.h +3 -0
@@ -58,7 +60,17 @@ typedef struct ARMCPU {
     /*< private >*/
     CPUState parent_obj;
     /*< public >*/
+
+    /* TODO Inline this and split off common state */
+    CPUARMState env;
 } ARMCPU;
 

As usual I don't like "legacy". :) A more interesting distinction is between state that is relevant to the emulation, and state that is relevant to the main loop or the machine. The former is reinitialized after reset and can remain in CPUFooState. The latter is not reinitialized after reset, can move to QOM, and in most cases that's what we access when we use CPUArchState.

Also, I understand that the conversion is not fully mechanical, but perhaps it can be made "more" mechanical than this? Splitting this patch in two would be nice, but I can't say I read it fully.

Paolo

#91 lore raw

Re: [Qemu-devel] [PATCH RFC v4 03/20] target-arm: Embed CPUARMState in QOM ARMCPU

Am 13.03.2012 14:18, schrieb Paolo Bonzini:

Quoted 10 lines

Il 10/03/2012 17:53, Andreas Färber ha scritto:

Quoted 9 lines

/**
* ARMCPU:
+ * @env: Legacy CPU state.
*
* An ARM CPU core.
*/

target-arm/cpu-qom.h +0 -0
@@ -58,7 +60,17 @@ typedef struct ARMCPU {
     /*< private >*/
     CPUState parent_obj;
Quoted 8 lines

target-arm/cpu-qom.h typedef struct ARMCPU { · line 67

Quoted 6 lines
target-arm/cpu-qom.h +3 -0
     /*< public >*/
+
+    /* TODO Inline this and split off common state */
+    CPUARMState env;
 } ARMCPU;
 

As usual I don't like "legacy". :)

Well, it refers to "former CPUState of which some or many fields are going to be extracted". I wouldn't want to write it into documentation as such.
" * @env: CPUARMState" is not telling either.
Better wordings anyone?

Quoted 6 lines

A more interesting distinction is
between state that is relevant to the emulation, and state that is relevant to the main loop or the machine. The former is reinitialized after reset and can remain in CPUFooState. The latter is not reinitialized after reset, can move to QOM, and in most cases that's what we access when we use CPUArchState.

Actually I was planning on keeping CPU*State only for TCG fields.

Whether a field is reset or not should be determined by the reset callback, not by a semi-magic memset() up to a certain field name. That's especially problematic for cp15.

The CPU*State struct stays around for two reasons,
1) allowing an incremental conversion of targets,
2) allowing offset calculations for TCG from the middle of the struct.

Mentioning this, we need to review all my *CPU structs to make sure env is the *first* member and that any fields accessed by offset in its parent CPUState are placed *last*, to minimize the immediates, as previously pointed out by rth. Starts to matter once we move icount into CPUState, as done on qom-cpu-wip branch.

Quoted 3 lines

Also, I understand that the conversion is not fully mechanical, but perhaps it can be made "more" mechanical than this? Splitting this patch in two would be nice, but I can't say I read it fully.

Hm, this patch has been around since v1 and so far nobody requested a particular split... it would be possible to move init and reset code in separate patches if deemed necessary? Peter?

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
maintainer
#92 lore raw

Re: [Qemu-devel] [PATCH RFC v4 03/20] target-arm: Embed CPUARMState in QOM ARMCPU

Il 14/03/2012 23:30, Andreas Färber ha scritto:

Quoted 8 lines
Quoted 1 line

As usual I don't like "legacy". :)

Well, it refers to "former CPUState of which some or many fields are going to be extracted". I wouldn't want to write it into documentation as such.
" * @env: CPUARMState" is not telling either.
Better wordings anyone?

Quoted 8 lines
Quoted 6 lines

A more interesting distinction is
between state that is relevant to the emulation, and state that is relevant to the main loop or the machine. The former is reinitialized after reset and can remain in CPUFooState. The latter is not reinitialized after reset, can move to QOM, and in most cases that's what we access when we use CPUArchState.

Actually I was planning on keeping CPU*State only for TCG fields.

@env: CPUARMState structure (only TCG fields should remain there)

Quoted 3 lines

Whether a field is reset or not should be determined by the reset callback, not by a semi-magic memset() up to a certain field name. That's especially problematic for cp15.

True. My idea was to leave all resettable fields in CPUARMState, and move the others in ARMCPU. This is consistent with "machine state" in CPUARMState and "machine settings + main-loop state" in ARMCPU. However, it may make little sense to you. If so, ignore me. :)

Quoted 7 lines
Quoted 3 lines

Also, I understand that the conversion is not fully mechanical, but perhaps it can be made "more" mechanical than this? Splitting this patch in two would be nice, but I can't say I read it fully.

Hm, this patch has been around since v1 and so far nobody requested a particular split... it would be possible to move init and reset code in separate patches if deemed necessary? Peter?

No problem, now that you posted conversion of everything.

Paolo

#93 lore raw

RFC PATCH v4 4/20 target-arm: Prepare model-specific class_init function

In reply to Andreas Färber

This allows to share initialization between CPU models.

---
 target-arm/cpu.c |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
target-arm/cpu.c +5 -0
index 00b7ecc..1e34cba 100644
@@ -102,6 +102,7 @@ static void arm_cpu_reset(CPUState *c)
 typedef struct ARMCPUInfo {
     const char *name;
     uint32_t id;
+    void (*class_init)(ARMCPUClass *klass, const struct ARMCPUInfo *info);
 } ARMCPUInfo;
 
 static const ARMCPUInfo arm_cpus[] = {
@@ -237,6 +238,10 @@ static void arm_cpu_class_init(ObjectClass *klass, void *data)
     cpu_class->reset = arm_cpu_reset;
 
     k->cp15.c0_cpuid = info->id;
+
+    if (info->class_init != NULL) {
+        (*info->class_init)(k, info);
+    }
 }
 
 static void cpu_register(const ARMCPUInfo *info)
Signature · 1 line
1.7.7
#94 lore raw

RFC PATCH v4 5/20 target-arm: Overwrite reset handler for ti925t

In reply to Andreas Färber

The OMAPCP feature allows to switch between TI915T and TI925T via cp15 c15_ticonfig register. Move reset into ti925t-specific callback.

---
 target-arm/cpu.c    |   18 ++++++++++++++++++
 target-arm/helper.c |    1 -
 2 files changed, 18 insertions(+), 1 deletions(-)
target-arm/cpu.c +18 -0
index 1e34cba..097701f 100644
@@ -105,6 +105,23 @@ typedef struct ARMCPUInfo {
     void (*class_init)(ARMCPUClass *klass, const struct ARMCPUInfo *info);
 } ARMCPUInfo;
 
+static void ti925t_reset(CPUState *c)
+{
+    ARMCPU *cpu = ARM_CPU(c);
+    CPUARMState *env = &cpu->env;
+
+    arm_cpu_reset(c);
+
+    env->cp15.c0_cpuid = ARM_CPUID_TI925T; /* Depends on wiring. */
+}
+
+static void ti925t_class_init(ARMCPUClass *klass, const ARMCPUInfo *info)
+{
+    CPUClass *cpu_class = CPU_CLASS(klass);
+
+    cpu_class->reset = ti925t_reset;
+}
+
 static const ARMCPUInfo arm_cpus[] = {
     {
         .name = "arm926",
@@ -157,6 +174,7 @@ static const ARMCPUInfo arm_cpus[] = {
     {
         .name = "ti925t",
         .id = 0x54029252,
+        .class_init = ti925t_class_init,
     },
     {
         .name = "sa1100",
target-arm/helper.c +0 -1
index 39f3c40..5ebe308 100644
@@ -196,7 +196,6 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)
     case ARM_CPUID_TI925T:
         set_feature(env, ARM_FEATURE_V4T);
         set_feature(env, ARM_FEATURE_OMAPCP);
-        env->cp15.c0_cpuid = ARM_CPUID_TI925T; /* Depends on wiring.  */
         env->cp15.c0_cachetype = 0x5109149;
         env->cp15.c1_sys = 0x00000070;
         env->cp15.c15_i_max = 0x000;
Signature · 1 line
1.7.7
#95 lore raw

RFC PATCH v4 6/20 target-arm: Move CPU feature flags out of CPUState

In reply to Andreas Färber

The internal CPU feature flags were only ever set in cpu_reset_model_id(). Therefore move their initialization into ARMCPUClass. We might want to tweak them in the future though (e.g., -cpu cortex-r4,+fpu), so keep a copy in ARMCPU. This in turn means we need to infer features for both ARMCPUClass and ARMCPU, so move feature inference to arm_infer_features() and use macros to simplify it.

Since cpu.h defines ARMCPUState, which has been incorporated into ARMCPU, and tries to use arm_feature() in cpu_get_tb_cpu_state(), move arm_feature() to cpu-core.h and add a forward declaration.

---
 target-arm/cpu-qom.h |   12 ++++
 target-arm/cpu.c     |  159 ++++++++++++++++++++++++++++++++++++++++++++++++++
 target-arm/cpu.h     |    9 +--
 target-arm/helper.c  |   95 ------------------------------
 target-arm/machine.c |    6 +-
 5 files changed, 177 insertions(+), 104 deletions(-)
target-arm/cpu-qom.h +12 -0
index 9e33b6a..6c97337 100644
@@ -35,6 +35,7 @@
 /**
  * ARMCPUClass:
  * @parent_reset: The parent class' reset handler.
+ * @features: Internal CPU feature flags.
  *
  * An ARM CPU model.
  */
@@ -48,10 +49,13 @@ typedef struct ARMCPUClass {
     struct {
         uint32_t c0_cpuid;
     } cp15;
+
+    uint32_t features;
 } ARMCPUClass;
 
 /**
  * ARMCPU:
+ * @features: Internal CPU feature flags.
  * @env: Legacy CPU state.
  *
  * An ARM CPU core.
@@ -61,6 +65,8 @@ typedef struct ARMCPU {
     CPUState parent_obj;
     /*< public >*/
 
+    uint32_t features;
+
     /* TODO Inline this and split off common state */
     CPUARMState env;
 } ARMCPU;
@@ -72,5 +78,11 @@ static inline ARMCPU *arm_env_get_cpu(CPUARMState *env)
 
 #define ENV_GET_CPU(e) CPU(arm_env_get_cpu(e))
 
+static inline int arm_feature(CPUARMState *env, int feature)
+{
+    ARMCPU *cpu = arm_env_get_cpu(env);
+    return (cpu->features & (1u << feature)) != 0;
+}
+
 
 #endif
target-arm/cpu.c +159 -0

302 lines not on this page · raw message

target-arm/cpu.h +2 -7
index 4cfa09c..d14fb01 100644
@@ -170,9 +170,6 @@ typedef struct CPUARMState {
     uint32_t teecr;
     uint32_t teehbr;
 
-    /* Internal CPU feature flags.  */
-    uint32_t features;
-
     /* VFP coprocessor state.  */
     struct {
         float64 regs[32];
@@ -385,10 +382,7 @@ enum arm_features {
     ARM_FEATURE_GENERIC_TIMER,
 };
 
-static inline int arm_feature(CPUARMState *env, int feature)
-{
-    return (env->features & (1u << feature)) != 0;
-}
+static inline int arm_feature(CPUARMState *env, int feature);
 
 void arm_cpu_list(FILE *f, fprintf_function cpu_fprintf);
 
@@ -475,6 +469,7 @@ static inline void cpu_clone_regs(CPUARMState *env, target_ulong newsp)
 #endif
 
 #include "cpu-all.h"
+#include "cpu-qom.h"
 
 /* Bit usage in the TB flags field: */
 #define ARM_TBFLAG_THUMB_SHIFT      0
target-arm/helper.c +0 -95

192 lines not on this page · raw message

target-arm/machine.c +4 -2
index f66b8df..19c0c65 100644
@@ -5,6 +5,7 @@ void cpu_save(QEMUFile *f, void *opaque)
 {
     int i;
     CPUARMState *env = (CPUARMState *)opaque;
+    ARMCPU *cpu = arm_env_get_cpu(env);
 
     for (i = 0; i < 16; i++) {
         qemu_put_be32(f, env->regs[i]);
@@ -61,7 +62,7 @@ void cpu_save(QEMUFile *f, void *opaque)
     qemu_put_be32(f, env->cp15.c15_diagnostic);
     qemu_put_be32(f, env->cp15.c15_power_diagnostic);
 
-    qemu_put_be32(f, env->features);
+    qemu_put_be32(f, cpu->features);
 
     if (arm_feature(env, ARM_FEATURE_VFP)) {
         for (i = 0;  i < 16; i++) {
@@ -115,6 +116,7 @@ void cpu_save(QEMUFile *f, void *opaque)
 int cpu_load(QEMUFile *f, void *opaque, int version_id)
 {
     CPUARMState *env = (CPUARMState *)opaque;
+    ARMCPU *cpu = arm_env_get_cpu(env);
     int i;
     uint32_t val;
 
@@ -179,7 +181,7 @@ int cpu_load(QEMUFile *f, void *opaque, int version_id)
     env->cp15.c15_diagnostic = qemu_get_be32(f);
     env->cp15.c15_power_diagnostic = qemu_get_be32(f);
 
-    env->features = qemu_get_be32(f);
+    cpu->features = qemu_get_be32(f);
 
     if (arm_feature(env, ARM_FEATURE_VFP)) {
         for (i = 0;  i < 16; i++) {
Signature · 1 line
1.7.7
#96 lore raw

Re: [Qemu-devel] [PATCH RFC v4 06/20] target-arm: Move CPU feature flags out of CPUState

Quoted 10 lines

The internal CPU feature flags were only ever set in cpu_reset_model_id(). Therefore move their initialization into ARMCPUClass. We might want to tweak them in the future though (e.g., -cpu cortex-r4,+fpu), so keep a copy in ARMCPU. This in turn means we need to infer features for both ARMCPUClass and ARMCPU, so move feature inference to arm_infer_features() and use macros to simplify it.

Since cpu.h defines ARMCPUState, which has been incorporated into ARMCPU, and tries to use arm_feature() in cpu_get_tb_cpu_state(), move arm_feature() to cpu-core.h and add a forward declaration.

I don't like how this has ended up. You've got a confusing mix of decalarative and imperative code to set CPU features.

i.e. some cores set features in ARMCPU.class_init, others use ARMCPU.features. I'd much prefer doing everything in the former, and removing the latter.

Also, you must not assume that the feature bits will fit in a single word. The features code is deliberately structured so that everything outside arm_feature and get_feature use the ARM_FEATURE_* enumeration. This means underlying bitmap implementation can be easily changed/extended. Your patch breaks that, making it inconvenient to expand beyond 32 features, and very hard to go beyond 64. Even just considering currently available ARM variants, we're likely to hit these limits very soon.

Infering of additional features should probably be done in set_feature.

Paul

#97 lore raw

RFC PATCH v4 7/20 target-arm: No longer abort on unhandled CPUIDs on reset

In reply to Andreas Färber

Having moved the reset code for some CPUs to class_init, we can drop some of the cases in the switch.

---
 target-arm/cpu.h    |    2 --
 target-arm/helper.c |    5 -----
 2 files changed, 0 insertions(+), 7 deletions(-)
target-arm/cpu.h +0 -2
index d14fb01..48d42b7 100644
@@ -427,8 +427,6 @@ void cpu_arm_set_cp_io(CPUARMState *env, int cpnum,
 #define ARM_CPUID_CORTEXA8    0x410fc080
 #define ARM_CPUID_CORTEXA9    0x410fc090
 #define ARM_CPUID_CORTEXA15   0x412fc0f1
-#define ARM_CPUID_CORTEXM3    0x410fc231
-#define ARM_CPUID_ANY         0xffffffff
 
 #if defined(CONFIG_USER_ONLY)
 #define TARGET_PAGE_BITS 12
target-arm/helper.c +0 -5
index 0dd6065..59a9812 100644
@@ -136,10 +136,6 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)
         env->cp15.c0_ccsid[2] = 0x711fe07a; /* 4096K L2 unified cache */
         env->cp15.c1_sys = 0x00c50078;
         break;
-    case ARM_CPUID_CORTEXM3:
-        break;
-    case ARM_CPUID_ANY: /* For userspace emulation.  */
-        break;
     case ARM_CPUID_TI915T:
     case ARM_CPUID_TI925T:
         env->cp15.c0_cachetype = 0x5109149;
@@ -172,7 +168,6 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)
         env->cp15.c1_sys = 0x00000070;
         break;
     default:
-        cpu_abort(env, "Bad CPU ID: %x\n", id);
         break;
     }
 }
Signature · 1 line
1.7.7
#98 lore raw

RFC PATCH v4 8/20 target-arm: Store cp15 c0_c1 and c0_c2 in ARMCPUClass

In reply to Andreas Färber

For now set them in the reset function.

---
 target-arm/cpu-qom.h |    2 +
 target-arm/cpu.c     |   63 ++++++++++++++++++++++++++++++++++++++++++++++++++
 target-arm/helper.c  |   51 ----------------------------------------
 3 files changed, 65 insertions(+), 51 deletions(-)
target-arm/cpu-qom.h +2 -0
index 6c97337..0148d18 100644
@@ -48,6 +48,8 @@ typedef struct ARMCPUClass {
 
     struct {
         uint32_t c0_cpuid;
+        uint32_t c0_c1[8];
+        uint32_t c0_c2[8];
     } cp15;
 
     uint32_t features;
target-arm/cpu.c +63 -0

123 lines not on this page · raw message

target-arm/helper.c +0 -51

93 lines not on this page · raw message

Signature · 1 line
1.7.7
#99 lore raw

Re: [Qemu-devel] [PATCH RFC v4 08/20] target-arm: Store cp15 c0_c1 and c0_c2 in ARMCPUClass

Review

Quoted 5 lines

For now set them in the reset function.

(quoted diff) +3 -0
+    /* TODO Move these into arm_cpu_initfn() once no longer zeroed above.*/
+    memcpy(env->cp15.c0_c1, klass->cp15.c0_c1, 8 * sizeof(uint32_t));
+    memcpy(env->cp15.c0_c2, klass->cp15.c0_c2, 8 * sizeof(uint32_t)); +

Why bother copying them into the CPU state? These are readonly, so anything that needs them should be able to use the value straight from the class definitions.

Paul

#100 lore raw

Re: [Qemu-devel] [PATCH RFC v4 08/20] target-arm: Store cp15 c0_c1 and c0_c2 in ARMCPUClass

Quoted 9 lines · Paul Brook
Quoted 5 lines

For now set them in the reset function.

+    /* TODO Move these into arm_cpu_initfn() once no longer zeroed above.*/
+    memcpy(env->cp15.c0_c1, klass->cp15.c0_c1, 8 * sizeof(uint32_t));
+    memcpy(env->cp15.c0_c2, klass->cp15.c0_c2, 8 * sizeof(uint32_t)); +

Why bother copying them into the CPU state?  These are readonly, so anything that needs them should be able to use the value straight from the class definitions.

In my (hugely delayed) cp15 rework attempt these probably go away anyway in favour of having each CPU register a pile of registers along the lines of

    { .name = "ID_PFR0", .cp = 15, .crn = 0, .crm = 1, .opc1 = 0, .opc2 = 0,
      .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0x00001231 },
    { .name = "ID_PFR1", .cp = 15, .crn = 0, .crm = 1, .opc1 = 0, .opc2 = 1,
      .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0x00000011 },

etc.

I'm not sure there's any need to retain the CPUState (or equivalent) fields for them at that point.

-- PMM

#101 lore raw

Re: [Qemu-devel] [PATCH RFC v4 08/20] target-arm: Store cp15 c0_c1 and c0_c2 in ARMCPUClass

Quoted 20 lines · Peter Maydell
Quoted 9 lines · Paul Brook
Quoted 5 lines

For now set them in the reset function.

+    /* TODO Move these into arm_cpu_initfn() once no longer zeroed above.*/
+    memcpy(env->cp15.c0_c1, klass->cp15.c0_c1, 8 * sizeof(uint32_t));
+    memcpy(env->cp15.c0_c2, klass->cp15.c0_c2, 8 * sizeof(uint32_t)); +

Why bother copying them into the CPU state?  These are readonly, so anything that needs them should be able to use the value straight from the class definitions.

In my (hugely delayed) cp15 rework attempt these probably go away anyway in favour of having each CPU register a pile of registers along the lines of

   { .name = "ID_PFR0", .cp = 15, .crn = 0, .crm = 1, .opc1 = 0, .opc2 = 0, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0x00001231 }, { .name = "ID_PFR1", .cp = 15, .crn = 0, .crm = 1, .opc1 = 0, .opc2 = 1, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0x00000011 }, etc.

Quoted 5 lines

I'm not sure there's any need to retain the CPUState (or equivalent) fields for them at that point.

-- PMM

Peter, with the reserved bits in most registers it might make sense to have resetvalue in two
masks -- ones and zeros, so that you can prevent changing of those bits.

Alex.

#102 lore raw

Re: [Qemu-devel] [PATCH RFC v4 08/20] target-arm: Store cp15 c0_c1 and c0_c2 in ARMCPUClass

Quoted 22 lines · Alexey Starikovskiy
Quoted 20 lines · Peter Maydell
Quoted 9 lines · Paul Brook
Quoted 5 lines

For now set them in the reset function.

+    /* TODO Move these into arm_cpu_initfn() once no longer zeroed above.*/
+    memcpy(env->cp15.c0_c1, klass->cp15.c0_c1, 8 * sizeof(uint32_t));
+    memcpy(env->cp15.c0_c2, klass->cp15.c0_c2, 8 * sizeof(uint32_t)); +

Why bother copying them into the CPU state?  These are readonly, so anything that needs them should be able to use the value straight from the class definitions.

In my (hugely delayed) cp15 rework attempt these probably go away anyway in favour of having each CPU register a pile of registers along the lines of

   { .name = "ID_PFR0", .cp = 15, .crn = 0, .crm = 1, .opc1 = 0, .opc2 = 0, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0x00001231 }, { .name = "ID_PFR1", .cp = 15, .crn = 0, .crm = 1, .opc1 = 0, .opc2 = 1, .access = PL1_R, .type = ARM_CP_CONST, .resetvalue = 0x00000011 }, etc.

Quoted 8 lines
Quoted 5 lines

I'm not sure there's any need to retain the CPUState (or equivalent) fields for them at that point.

-- PMM

Peter, with the reserved bits in most registers it might make sense to have resetvalue in two
masks -- ones and zeros, so that you can prevent changing of those bits.

Well, in this case it's totally read only. Mostly QEMU at the moment doesn't enforce selectively read-only bits (we probably should!) so I haven't put in read-only-masks in my conversion so far, but it's an obvious possibility.

(Current status:
http://git.linaro.org/gitweb?p=people/pmaydell/qemu-arm.git;a=shortlog;h=refs/heads/cp15-rework
still TODO:
cp15 crn=0 conversion ;
drop special case of mcrr in favour of explicitly implementing block cache ops registers ;
reset handling of SCTLR still relies on cpu_reset_model_id ; arrangement of define_arm_cp_regs() calls could probably be improved.
I'm also toying with the idea of just having each CPU we support go through and register its own cp15 registers in a big long list (ie no attempt at factoring out "these are registers all v7 cores have", "these are registers for feature X", etc). That sounds kind of weird but it might help in separating out changes to migration state for CPU A from those for CPU B.)

-- PMM

#103 lore raw

RFC PATCH v4 9/20 target-arm: Store CTR in ARMCPUClass

In reply to Andreas Färber
---
 target-arm/cpu-qom.h |    1 +
 target-arm/cpu.c     |   18 ++++++++++++++++++
 target-arm/helper.c  |   12 ------------
 3 files changed, 19 insertions(+), 12 deletions(-)
target-arm/cpu-qom.h +1 -0
index 0148d18..722d164 100644
@@ -48,6 +48,7 @@ typedef struct ARMCPUClass {
 
     struct {
         uint32_t c0_cpuid;
+        uint32_t c0_cachetype;
         uint32_t c0_c1[8];
         uint32_t c0_c2[8];
     } cp15;
target-arm/cpu.c +18 -0
index 74be400..c7cf46d 100644
@@ -46,6 +46,7 @@ static void arm_cpu_reset(CPUState *c)
     env->cp15.c15_config_base_address = tmp;
 
     /* TODO Move these into arm_cpu_initfn() once no longer zeroed above. */
+    env->cp15.c0_cachetype = klass->cp15.c0_cachetype;
     memcpy(env->cp15.c0_c1, klass->cp15.c0_c1, 8 * sizeof(uint32_t));
     memcpy(env->cp15.c0_c2, klass->cp15.c0_c2, 8 * sizeof(uint32_t));
 
@@ -169,6 +170,7 @@ static inline void unset_class_feature(ARMCPUClass *klass, int feature)
 typedef struct ARMCPUInfo {
     const char *name;
     uint32_t id;
+    uint32_t cp15_c0_cachetype;
     uint32_t cp15_c0_c1[8];
     uint32_t cp15_c0_c2[8];
     uint32_t features;
@@ -188,6 +190,7 @@ static void arm1136_r0_class_init(ARMCPUClass *k, const ARMCPUInfo *info)
      * for 1136_r2 (in particular r0p2 does not actually implement most
      * of the ID registers).
      */
+    k->cp15.c0_cachetype = r1_class->cp15.c0_cachetype;
     memcpy(k->cp15.c0_c1, r1_class->cp15.c0_c1, 8 * sizeof(uint32_t));
     memcpy(k->cp15.c0_c2, r1_class->cp15.c0_c2, 8 * sizeof(uint32_t));
 }
@@ -216,12 +219,16 @@ static void sa11xx_class_init(ARMCPUClass *k, const ARMCPUInfo *info)
 
 static void pxa25x_class_init(ARMCPUClass *k, const ARMCPUInfo *info)
 {
+    k->cp15.c0_cachetype = 0xd172172;
+
     set_class_feature(k, ARM_FEATURE_V5);
     set_class_feature(k, ARM_FEATURE_XSCALE);
 }
 
 static void pxa270_class_init(ARMCPUClass *k, const ARMCPUInfo *info)
 {
+    k->cp15.c0_cachetype = 0xd172172;
+
     set_class_feature(k, ARM_FEATURE_V5);
     set_class_feature(k, ARM_FEATURE_XSCALE);
     set_class_feature(k, ARM_FEATURE_IWMMXT);
@@ -231,18 +238,21 @@ static const ARMCPUInfo arm_cpus[] = {
     {
         .name = "arm926",
         .id = 0x41069265,
+        .cp15_c0_cachetype = 0x1dd20d2,
         .features = ARM_FEATURE(V5) |
                     ARM_FEATURE(VFP),
     },
     {
         .name = "arm946",
         .id = 0x41059461,
+        .cp15_c0_cachetype = 0x0f004006,
         .features = ARM_FEATURE(V5) |
                     ARM_FEATURE(MPU),
     },
     {
         .name = "arm1026",
         .id = 0x4106a262,
+        .cp15_c0_cachetype = 0x1dd20d2,
         .features = ARM_FEATURE(V5) |
                     ARM_FEATURE(VFP) |
                     ARM_FEATURE(AUXCR),
@@ -259,6 +269,7 @@ static const ARMCPUInfo arm_cpus[] = {
     {
         .name = "arm1136",
         .id = 0x4117b363,
+        .cp15_c0_cachetype = 0x1dd20d2,
         .cp15_c0_c1 = {
             0x111, 0x1, 0x2, 0x3,
             0x01130003, 0x10030302, 0x01222110, 0
@@ -273,6 +284,7 @@ static const ARMCPUInfo arm_cpus[] = {
     {
         .name = "arm1176",
         .id = 0x410fb767,
+        .cp15_c0_cachetype = 0x1dd20d2,
         .cp15_c0_c1 = {
             0x111, 0x11, 0x33, 0,
             0x01130003, 0x10030302, 0x01222100, 0
@@ -288,6 +300,7 @@ static const ARMCPUInfo arm_cpus[] = {
     {
         .name = "arm11mpcore",
         .id = 0x410fb022,
+        .cp15_c0_cachetype = 0x1dd20d2,
         .cp15_c0_c1 = {
             0x111, 0x1, 0, 0x2,
             0x01100103, 0x10020302, 0x01222000, 0
@@ -309,6 +322,7 @@ static const ARMCPUInfo arm_cpus[] = {
     {
         .name = "cortex-a8",
         .id = 0x410fc080,
+        .cp15_c0_cachetype = 0x82048004,
         .cp15_c0_c1 = {
             0x1031, 0x11, 0x400, 0,
             0x31100003, 0x20000000, 0x01202000, 0x11
@@ -325,6 +339,7 @@ static const ARMCPUInfo arm_cpus[] = {
     {
         .name = "cortex-a9",
         .id = 0x410fc090,
+        .cp15_c0_cachetype = 0x80038003,
         .cp15_c0_c1 = {
             0x1031, 0x11, 0x000, 0,
             0x00100103, 0x20000000, 0x01230000, 0x00002111
@@ -347,6 +362,7 @@ static const ARMCPUInfo arm_cpus[] = {
     {
         .name = "cortex-a15",
         .id = 0x412fc0f1,
+        .cp15_c0_cachetype = 0x8444c004,
         .cp15_c0_c1 = {
             0x00001131, 0x00011011, 0x02010555, 0x00000000,
             0x10201105, 0x20000000, 0x01240000, 0x02102211
@@ -367,6 +383,7 @@ static const ARMCPUInfo arm_cpus[] = {
     {
         .name = "ti925t",
         .id = 0x54029252,
+        .cp15_c0_cachetype = 0x5109149,
         .features = ARM_FEATURE(V4T) |
                     ARM_FEATURE(OMAPCP),
         .class_init = ti925t_class_init,
@@ -473,6 +490,7 @@ static void arm_cpu_class_init(ObjectClass *klass, void *data)
     cpu_class->reset = arm_cpu_reset;
 
     k->cp15.c0_cpuid = info->id;
+    k->cp15.c0_cachetype = info->cp15_c0_cachetype;
     memcpy(k->cp15.c0_c1, info->cp15_c0_c1, 8 * sizeof(uint32_t));
     memcpy(k->cp15.c0_c2, info->cp15_c0_c2, 8 * sizeof(uint32_t));
     k->features = info->features;
target-arm/helper.c +0 -12
index c0cfa17..14ed890 100644
@@ -10,16 +10,13 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)
     switch (id) {
     case ARM_CPUID_ARM926:
         env->vfp.xregs[ARM_VFP_FPSID] = 0x41011090;
-        env->cp15.c0_cachetype = 0x1dd20d2;
         env->cp15.c1_sys = 0x00090078;
         break;
     case ARM_CPUID_ARM946:
-        env->cp15.c0_cachetype = 0x0f004006;
         env->cp15.c1_sys = 0x00000078;
         break;
     case ARM_CPUID_ARM1026:
         env->vfp.xregs[ARM_VFP_FPSID] = 0x410110a0;
-        env->cp15.c0_cachetype = 0x1dd20d2;
         env->cp15.c1_sys = 0x00090078;
         break;
     case ARM_CPUID_ARM1136:
@@ -37,27 +34,23 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)
         env->vfp.xregs[ARM_VFP_FPSID] = 0x410120b4;
         env->vfp.xregs[ARM_VFP_MVFR0] = 0x11111111;
         env->vfp.xregs[ARM_VFP_MVFR1] = 0x00000000;
-        env->cp15.c0_cachetype = 0x1dd20d2;
         env->cp15.c1_sys = 0x00050078;
         break;
     case ARM_CPUID_ARM1176:
         env->vfp.xregs[ARM_VFP_FPSID] = 0x410120b5;
         env->vfp.xregs[ARM_VFP_MVFR0] = 0x11111111;
         env->vfp.xregs[ARM_VFP_MVFR1] = 0x00000000;
-        env->cp15.c0_cachetype = 0x1dd20d2;
         env->cp15.c1_sys = 0x00050078;
         break;
     case ARM_CPUID_ARM11MPCORE:
         env->vfp.xregs[ARM_VFP_FPSID] = 0x410120b4;
         env->vfp.xregs[ARM_VFP_MVFR0] = 0x11111111;
         env->vfp.xregs[ARM_VFP_MVFR1] = 0x00000000;
-        env->cp15.c0_cachetype = 0x1dd20d2;
         break;
     case ARM_CPUID_CORTEXA8:
         env->vfp.xregs[ARM_VFP_FPSID] = 0x410330c0;
         env->vfp.xregs[ARM_VFP_MVFR0] = 0x11110222;
         env->vfp.xregs[ARM_VFP_MVFR1] = 0x00011100;
-        env->cp15.c0_cachetype = 0x82048004;
         env->cp15.c0_clid = (1 << 27) | (2 << 24) | 3;
         env->cp15.c0_ccsid[0] = 0xe007e01a; /* 16k L1 dcache. */
         env->cp15.c0_ccsid[1] = 0x2007e01a; /* 16k L1 icache. */
@@ -68,7 +61,6 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)
         env->vfp.xregs[ARM_VFP_FPSID] = 0x41033090;
         env->vfp.xregs[ARM_VFP_MVFR0] = 0x11110222;
         env->vfp.xregs[ARM_VFP_MVFR1] = 0x01111111;
-        env->cp15.c0_cachetype = 0x80038003;
         env->cp15.c0_clid = (1 << 27) | (1 << 24) | 3;
         env->cp15.c0_ccsid[0] = 0xe00fe015; /* 16k L1 dcache. */
         env->cp15.c0_ccsid[1] = 0x200fe015; /* 16k L1 icache. */
@@ -78,7 +70,6 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)
         env->vfp.xregs[ARM_VFP_FPSID] = 0x410430f0;
         env->vfp.xregs[ARM_VFP_MVFR0] = 0x10110222;
         env->vfp.xregs[ARM_VFP_MVFR1] = 0x11111111;
-        env->cp15.c0_cachetype = 0x8444c004;
         env->cp15.c0_clid = 0x0a200023;
         env->cp15.c0_ccsid[0] = 0x701fe00a; /* 32K L1 dcache */
         env->cp15.c0_ccsid[1] = 0x201fe00a; /* 32K L1 icache */
@@ -87,7 +78,6 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)
         break;
     case ARM_CPUID_TI915T:
     case ARM_CPUID_TI925T:
-        env->cp15.c0_cachetype = 0x5109149;
         env->cp15.c1_sys = 0x00000070;
         env->cp15.c15_i_max = 0x000;
         env->cp15.c15_i_min = 0xff0;
@@ -98,7 +88,6 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)
     case ARM_CPUID_PXA261:
     case ARM_CPUID_PXA262:
         /* JTAG_ID is ((id << 28) | 0x09265013) */
-        env->cp15.c0_cachetype = 0xd172172;
         env->cp15.c1_sys = 0x00000078;
         break;
     case ARM_CPUID_PXA270_A0:
@@ -109,7 +98,6 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)
     case ARM_CPUID_PXA270_C5:
         /* JTAG_ID is ((id << 28) | 0x09265013) */
         env->iwmmxt.cregs[ARM_IWMMXT_wCID] = 0x69051000 | 'Q';
-        env->cp15.c0_cachetype = 0xd172172;
         env->cp15.c1_sys = 0x00000078;
         break;
     case ARM_CPUID_SA1100:
Signature · 1 line
1.7.7
#104 lore raw

RFC PATCH v4 10/20 target-arm: Store SCTLR in ARMCPUClass

In reply to Andreas Färber
---
 target-arm/cpu-qom.h |    1 +
 target-arm/cpu.c     |   19 +++++++++++++++++++
 target-arm/cpu.h     |    3 ---
 target-arm/helper.c  |   17 -----------------
 4 files changed, 20 insertions(+), 20 deletions(-)
target-arm/cpu-qom.h +1 -0
index 722d164..3832986 100644
@@ -51,6 +51,7 @@ typedef struct ARMCPUClass {
         uint32_t c0_cachetype;
         uint32_t c0_c1[8];
         uint32_t c0_c2[8];
+        uint32_t c1_sys;
     } cp15;
 
     uint32_t features;
target-arm/cpu.c +19 -0
index c7cf46d..2f3190a 100644
@@ -50,6 +50,9 @@ static void arm_cpu_reset(CPUState *c)
     memcpy(env->cp15.c0_c1, klass->cp15.c0_c1, 8 * sizeof(uint32_t));
     memcpy(env->cp15.c0_c2, klass->cp15.c0_c2, 8 * sizeof(uint32_t));
 
+    /* Genuine reset */
+    env->cp15.c1_sys = klass->cp15.c1_sys;
+
 #if defined(CONFIG_USER_ONLY)
     env->uncached_cpsr = ARM_CPU_MODE_USR;
     /* For user mode we must enable access to coprocessors */
@@ -173,6 +176,7 @@ typedef struct ARMCPUInfo {
     uint32_t cp15_c0_cachetype;
     uint32_t cp15_c0_c1[8];
     uint32_t cp15_c0_c2[8];
+    uint32_t cp15_c1_sys;
     uint32_t features;
     void (*class_init)(ARMCPUClass *klass, const struct ARMCPUInfo *info);
 } ARMCPUInfo;
@@ -193,6 +197,7 @@ static void arm1136_r0_class_init(ARMCPUClass *k, const ARMCPUInfo *info)
     k->cp15.c0_cachetype = r1_class->cp15.c0_cachetype;
     memcpy(k->cp15.c0_c1, r1_class->cp15.c0_c1, 8 * sizeof(uint32_t));
     memcpy(k->cp15.c0_c2, r1_class->cp15.c0_c2, 8 * sizeof(uint32_t));
+    k->cp15.c1_sys = r1_class->cp15.c1_sys;
 }
 
 static void ti925t_reset(CPUState *c)
@@ -214,12 +219,15 @@ static void ti925t_class_init(ARMCPUClass *klass, const ARMCPUInfo *info)
 
 static void sa11xx_class_init(ARMCPUClass *k, const ARMCPUInfo *info)
 {
+    k->cp15.c1_sys = 0x00000070;
+
     set_class_feature(k, ARM_FEATURE_STRONGARM);
 }
 
 static void pxa25x_class_init(ARMCPUClass *k, const ARMCPUInfo *info)
 {
     k->cp15.c0_cachetype = 0xd172172;
+    k->cp15.c1_sys = 0x00000078;
 
     set_class_feature(k, ARM_FEATURE_V5);
     set_class_feature(k, ARM_FEATURE_XSCALE);
@@ -228,6 +236,7 @@ static void pxa25x_class_init(ARMCPUClass *k, const ARMCPUInfo *info)
 static void pxa270_class_init(ARMCPUClass *k, const ARMCPUInfo *info)
 {
     k->cp15.c0_cachetype = 0xd172172;
+    k->cp15.c1_sys = 0x00000078;
 
     set_class_feature(k, ARM_FEATURE_V5);
     set_class_feature(k, ARM_FEATURE_XSCALE);
@@ -239,6 +248,7 @@ static const ARMCPUInfo arm_cpus[] = {
         .name = "arm926",
         .id = 0x41069265,
         .cp15_c0_cachetype = 0x1dd20d2,
+        .cp15_c1_sys = 0x00090078,
         .features = ARM_FEATURE(V5) |
                     ARM_FEATURE(VFP),
     },
@@ -246,6 +256,7 @@ static const ARMCPUInfo arm_cpus[] = {
         .name = "arm946",
         .id = 0x41059461,
         .cp15_c0_cachetype = 0x0f004006,
+        .cp15_c1_sys = 0x00000078,
         .features = ARM_FEATURE(V5) |
                     ARM_FEATURE(MPU),
     },
@@ -253,6 +264,7 @@ static const ARMCPUInfo arm_cpus[] = {
         .name = "arm1026",
         .id = 0x4106a262,
         .cp15_c0_cachetype = 0x1dd20d2,
+        .cp15_c1_sys = 0x00090078,
         .features = ARM_FEATURE(V5) |
                     ARM_FEATURE(VFP) |
                     ARM_FEATURE(AUXCR),
@@ -278,6 +290,7 @@ static const ARMCPUInfo arm_cpus[] = {
             0x00140011, 0x12002111, 0x11231111, 0x01102131,
             0x141, 0, 0, 0
         },
+        .cp15_c1_sys = 0x00050078,
         .features = ARM_FEATURE(V6) |
                     ARM_FEATURE(VFP),
     },
@@ -293,6 +306,7 @@ static const ARMCPUInfo arm_cpus[] = {
             0x0140011, 0x12002111, 0x11231121, 0x01102131,
             0x01141, 0, 0, 0
         },
+        .cp15_c1_sys = 0x00050078,
         .features = ARM_FEATURE(V6K) |
                     ARM_FEATURE(VFP) |
                     ARM_FEATURE(VAPA),
@@ -331,6 +345,7 @@ static const ARMCPUInfo arm_cpus[] = {
             0x00101111, 0x12112111, 0x21232031, 0x11112131,
             0x00111142, 0, 0, 0
         },
+        .cp15_c1_sys = 0x00c50078,
         .features = ARM_FEATURE(V7) |
                     ARM_FEATURE(VFP3) |
                     ARM_FEATURE(NEON) |
@@ -348,6 +363,7 @@ static const ARMCPUInfo arm_cpus[] = {
             0x00101111, 0x13112111, 0x21232041, 0x11112131,
             0x00111142, 0, 0, 0
         },
+        .cp15_c1_sys = 0x00c50078,
         .features = ARM_FEATURE(V7) |
                     ARM_FEATURE(VFP3) |
                     ARM_FEATURE(VFP_FP16) |
@@ -371,6 +387,7 @@ static const ARMCPUInfo arm_cpus[] = {
             0x02101110, 0x13112111, 0x21232041, 0x11112131,
             0x10011142, 0, 0, 0
         },
+        .cp15_c1_sys = 0x00c50078,
         .features = ARM_FEATURE(V7) |
                     ARM_FEATURE(VFP4) |
                     ARM_FEATURE(VFP_FP16) |
@@ -384,6 +401,7 @@ static const ARMCPUInfo arm_cpus[] = {
         .name = "ti925t",
         .id = 0x54029252,
         .cp15_c0_cachetype = 0x5109149,
+        .cp15_c1_sys = 0x00000070,
         .features = ARM_FEATURE(V4T) |
                     ARM_FEATURE(OMAPCP),
         .class_init = ti925t_class_init,
@@ -493,6 +511,7 @@ static void arm_cpu_class_init(ObjectClass *klass, void *data)
     k->cp15.c0_cachetype = info->cp15_c0_cachetype;
     memcpy(k->cp15.c0_c1, info->cp15_c0_c1, 8 * sizeof(uint32_t));
     memcpy(k->cp15.c0_c2, info->cp15_c0_c2, 8 * sizeof(uint32_t));
+    k->cp15.c1_sys = info->cp15_c1_sys;
     k->features = info->features;
 
     if (info->class_init != NULL) {
target-arm/cpu.h +0 -3
index 48d42b7..66e62e2 100644
@@ -404,11 +404,8 @@ void cpu_arm_set_cp_io(CPUARMState *env, int cpnum,
 
 #define ARM_CPUID_ARM1026     0x4106a262
 #define ARM_CPUID_ARM926      0x41069265
-#define ARM_CPUID_ARM946      0x41059461
 #define ARM_CPUID_TI915T      0x54029152
 #define ARM_CPUID_TI925T      0x54029252
-#define ARM_CPUID_SA1100      0x4401A11B
-#define ARM_CPUID_SA1110      0x6901B119
 #define ARM_CPUID_PXA250      0x69052100
 #define ARM_CPUID_PXA255      0x69052d00
 #define ARM_CPUID_PXA260      0x69052903
target-arm/helper.c +0 -17
index 14ed890..548d8cf 100644
@@ -10,14 +10,9 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)
     switch (id) {
     case ARM_CPUID_ARM926:
         env->vfp.xregs[ARM_VFP_FPSID] = 0x41011090;
-        env->cp15.c1_sys = 0x00090078;
-        break;
-    case ARM_CPUID_ARM946:
-        env->cp15.c1_sys = 0x00000078;
         break;
     case ARM_CPUID_ARM1026:
         env->vfp.xregs[ARM_VFP_FPSID] = 0x410110a0;
-        env->cp15.c1_sys = 0x00090078;
         break;
     case ARM_CPUID_ARM1136:
         /* This is the 1136 r1, which is a v6K core */
@@ -34,13 +29,11 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)
         env->vfp.xregs[ARM_VFP_FPSID] = 0x410120b4;
         env->vfp.xregs[ARM_VFP_MVFR0] = 0x11111111;
         env->vfp.xregs[ARM_VFP_MVFR1] = 0x00000000;
-        env->cp15.c1_sys = 0x00050078;
         break;
     case ARM_CPUID_ARM1176:
         env->vfp.xregs[ARM_VFP_FPSID] = 0x410120b5;
         env->vfp.xregs[ARM_VFP_MVFR0] = 0x11111111;
         env->vfp.xregs[ARM_VFP_MVFR1] = 0x00000000;
-        env->cp15.c1_sys = 0x00050078;
         break;
     case ARM_CPUID_ARM11MPCORE:
         env->vfp.xregs[ARM_VFP_FPSID] = 0x410120b4;
@@ -55,7 +48,6 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)
         env->cp15.c0_ccsid[0] = 0xe007e01a; /* 16k L1 dcache. */
         env->cp15.c0_ccsid[1] = 0x2007e01a; /* 16k L1 icache. */
         env->cp15.c0_ccsid[2] = 0xf0000000; /* No L2 icache. */
-        env->cp15.c1_sys = 0x00c50078;
         break;
     case ARM_CPUID_CORTEXA9:
         env->vfp.xregs[ARM_VFP_FPSID] = 0x41033090;
@@ -64,7 +56,6 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)
         env->cp15.c0_clid = (1 << 27) | (1 << 24) | 3;
         env->cp15.c0_ccsid[0] = 0xe00fe015; /* 16k L1 dcache. */
         env->cp15.c0_ccsid[1] = 0x200fe015; /* 16k L1 icache. */
-        env->cp15.c1_sys = 0x00c50078;
         break;
     case ARM_CPUID_CORTEXA15:
         env->vfp.xregs[ARM_VFP_FPSID] = 0x410430f0;
@@ -74,11 +65,9 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)
         env->cp15.c0_ccsid[0] = 0x701fe00a; /* 32K L1 dcache */
         env->cp15.c0_ccsid[1] = 0x201fe00a; /* 32K L1 icache */
         env->cp15.c0_ccsid[2] = 0x711fe07a; /* 4096K L2 unified cache */
-        env->cp15.c1_sys = 0x00c50078;
         break;
     case ARM_CPUID_TI915T:
     case ARM_CPUID_TI925T:
-        env->cp15.c1_sys = 0x00000070;
         env->cp15.c15_i_max = 0x000;
         env->cp15.c15_i_min = 0xff0;
         break;
@@ -88,7 +77,6 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)
     case ARM_CPUID_PXA261:
     case ARM_CPUID_PXA262:
         /* JTAG_ID is ((id << 28) | 0x09265013) */
-        env->cp15.c1_sys = 0x00000078;
         break;
     case ARM_CPUID_PXA270_A0:
     case ARM_CPUID_PXA270_A1:
@@ -98,11 +86,6 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)
     case ARM_CPUID_PXA270_C5:
         /* JTAG_ID is ((id << 28) | 0x09265013) */
         env->iwmmxt.cregs[ARM_IWMMXT_wCID] = 0x69051000 | 'Q';
-        env->cp15.c1_sys = 0x00000078;
-        break;
-    case ARM_CPUID_SA1100:
-    case ARM_CPUID_SA1110:
-        env->cp15.c1_sys = 0x00000070;
         break;
     default:
         break;
Signature · 1 line
1.7.7
#105 lore raw

RFC PATCH v4 11/20 target-arm: Drop JTAG_ID documentation

In reply to Andreas Färber

None of the machines in QEMU offer a JTAG debug interface, so this info was unused. Further, the PXA250 ID contradicts the February 2002 Developer's Manual, which has it as 0xn9264013 with n the MIDR Revision.

Cc Peter Maydell <[email protected]>
Cc Andrzej Zaborowski <[email protected]>
---
 target-arm/cpu.h    |    5 -----
 target-arm/helper.c |    8 --------
 2 files changed, 0 insertions(+), 13 deletions(-)
target-arm/cpu.h +0 -5
index 66e62e2..d7e73d8 100644
@@ -406,11 +406,6 @@ void cpu_arm_set_cp_io(CPUARMState *env, int cpnum,
 #define ARM_CPUID_ARM926      0x41069265
 #define ARM_CPUID_TI915T      0x54029152
 #define ARM_CPUID_TI925T      0x54029252
-#define ARM_CPUID_PXA250      0x69052100
-#define ARM_CPUID_PXA255      0x69052d00
-#define ARM_CPUID_PXA260      0x69052903
-#define ARM_CPUID_PXA261      0x69052d05
-#define ARM_CPUID_PXA262      0x69052d06
 #define ARM_CPUID_PXA270_A0   0x69054110
 #define ARM_CPUID_PXA270_A1   0x69054111
 #define ARM_CPUID_PXA270_B0   0x69054112
target-arm/helper.c +0 -8
index 548d8cf..46e9dc5 100644
@@ -71,20 +71,12 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)
         env->cp15.c15_i_max = 0x000;
         env->cp15.c15_i_min = 0xff0;
         break;
-    case ARM_CPUID_PXA250:
-    case ARM_CPUID_PXA255:
-    case ARM_CPUID_PXA260:
-    case ARM_CPUID_PXA261:
-    case ARM_CPUID_PXA262:
-        /* JTAG_ID is ((id << 28) | 0x09265013) */
-        break;
     case ARM_CPUID_PXA270_A0:
     case ARM_CPUID_PXA270_A1:
     case ARM_CPUID_PXA270_B0:
     case ARM_CPUID_PXA270_B1:
     case ARM_CPUID_PXA270_C0:
     case ARM_CPUID_PXA270_C5:
-        /* JTAG_ID is ((id << 28) | 0x09265013) */
         env->iwmmxt.cregs[ARM_IWMMXT_wCID] = 0x69051000 | 'Q';
         break;
     default:
Signature · 1 line
1.7.7
#106 lore raw

RFC PATCH v4 12/20 target-arm: Move the PXA270's iwMMXt reset to pxa270_reset()

In reply to Andreas Färber

No other emulated CPU uses this at this time.

Cc Peter Maydell <[email protected]>
Cc Andrzej Zaborowski <[email protected]>
---
 target-arm/cpu.c    |   14 ++++++++++++++
 target-arm/cpu.h    |    6 ------
 target-arm/helper.c |    8 --------
 3 files changed, 14 insertions(+), 14 deletions(-)
target-arm/cpu.c +14 -0
index 2f3190a..1614be4 100644
@@ -233,8 +233,22 @@ static void pxa25x_class_init(ARMCPUClass *k, const ARMCPUInfo *info)
     set_class_feature(k, ARM_FEATURE_XSCALE);
 }
 
+static void pxa270_reset(CPUState *c)
+{
+    ARMCPU *cpu = ARM_CPU(c);
+    CPUARMState *env = &cpu->env;
+
+    arm_cpu_reset(c);
+
+    env->iwmmxt.cregs[ARM_IWMMXT_wCID] = 0x69051000 | 'Q';
+}
+
 static void pxa270_class_init(ARMCPUClass *k, const ARMCPUInfo *info)
 {
+    CPUClass *cpu_class = CPU_CLASS(k);
+
+    cpu_class->reset = pxa270_reset;
+
     k->cp15.c0_cachetype = 0xd172172;
     k->cp15.c1_sys = 0x00000078;
 
target-arm/cpu.h +0 -6
index d7e73d8..d135221 100644
@@ -406,12 +406,6 @@ void cpu_arm_set_cp_io(CPUARMState *env, int cpnum,
 #define ARM_CPUID_ARM926      0x41069265
 #define ARM_CPUID_TI915T      0x54029152
 #define ARM_CPUID_TI925T      0x54029252
-#define ARM_CPUID_PXA270_A0   0x69054110
-#define ARM_CPUID_PXA270_A1   0x69054111
-#define ARM_CPUID_PXA270_B0   0x69054112
-#define ARM_CPUID_PXA270_B1   0x69054113
-#define ARM_CPUID_PXA270_C0   0x69054114
-#define ARM_CPUID_PXA270_C5   0x69054117
 #define ARM_CPUID_ARM1136     0x4117b363
 #define ARM_CPUID_ARM1136_R2  0x4107b362
 #define ARM_CPUID_ARM1176     0x410fb767
target-arm/helper.c +0 -8
index 46e9dc5..421ce98 100644
@@ -71,14 +71,6 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)
         env->cp15.c15_i_max = 0x000;
         env->cp15.c15_i_min = 0xff0;
         break;
-    case ARM_CPUID_PXA270_A0:
-    case ARM_CPUID_PXA270_A1:
-    case ARM_CPUID_PXA270_B0:
-    case ARM_CPUID_PXA270_B1:
-    case ARM_CPUID_PXA270_C0:
-    case ARM_CPUID_PXA270_C5:
-        env->iwmmxt.cregs[ARM_IWMMXT_wCID] = 0x69051000 | 'Q';
-        break;
     default:
         break;
     }
Signature · 1 line
1.7.7
#107 lore raw

RFC PATCH v4 13/20 target-arm: Store VFP FPSID register in ARMCPUClass

In reply to Andreas Färber
---
 target-arm/cpu-qom.h |    3 +++
 target-arm/cpu.c     |   11 +++++++++++
 target-arm/cpu.h     |    1 -
 target-arm/helper.c  |   12 ------------
 4 files changed, 14 insertions(+), 13 deletions(-)
target-arm/cpu-qom.h +3 -0
index 3832986..6cb7891 100644
@@ -53,6 +53,9 @@ typedef struct ARMCPUClass {
         uint32_t c0_c2[8];
         uint32_t c1_sys;
     } cp15;
+    struct {
+        uint32_t fpsid;
+    } vfp;
 
     uint32_t features;
 } ARMCPUClass;
target-arm/cpu.c +11 -0
index 1614be4..ad4a90a 100644
@@ -52,6 +52,7 @@ static void arm_cpu_reset(CPUState *c)
 
     /* Genuine reset */
     env->cp15.c1_sys = klass->cp15.c1_sys;
+    env->vfp.xregs[ARM_VFP_FPSID] = klass->vfp.fpsid;
 
 #if defined(CONFIG_USER_ONLY)
     env->uncached_cpsr = ARM_CPU_MODE_USR;
@@ -177,6 +178,7 @@ typedef struct ARMCPUInfo {
     uint32_t cp15_c0_c1[8];
     uint32_t cp15_c0_c2[8];
     uint32_t cp15_c1_sys;
+    uint32_t vfp_fpsid;
     uint32_t features;
     void (*class_init)(ARMCPUClass *klass, const struct ARMCPUInfo *info);
 } ARMCPUInfo;
@@ -263,6 +265,7 @@ static const ARMCPUInfo arm_cpus[] = {
         .id = 0x41069265,
         .cp15_c0_cachetype = 0x1dd20d2,
         .cp15_c1_sys = 0x00090078,
+        .vfp_fpsid = 0x41011090,
         .features = ARM_FEATURE(V5) |
                     ARM_FEATURE(VFP),
     },
@@ -279,6 +282,7 @@ static const ARMCPUInfo arm_cpus[] = {
         .id = 0x4106a262,
         .cp15_c0_cachetype = 0x1dd20d2,
         .cp15_c1_sys = 0x00090078,
+        .vfp_fpsid = 0x410110a0,
         .features = ARM_FEATURE(V5) |
                     ARM_FEATURE(VFP) |
                     ARM_FEATURE(AUXCR),
@@ -305,6 +309,7 @@ static const ARMCPUInfo arm_cpus[] = {
             0x141, 0, 0, 0
         },
         .cp15_c1_sys = 0x00050078,
+        .vfp_fpsid = 0x410120b4,
         .features = ARM_FEATURE(V6) |
                     ARM_FEATURE(VFP),
     },
@@ -321,6 +326,7 @@ static const ARMCPUInfo arm_cpus[] = {
             0x01141, 0, 0, 0
         },
         .cp15_c1_sys = 0x00050078,
+        .vfp_fpsid = 0x410120b5,
         .features = ARM_FEATURE(V6K) |
                     ARM_FEATURE(VFP) |
                     ARM_FEATURE(VAPA),
@@ -337,6 +343,7 @@ static const ARMCPUInfo arm_cpus[] = {
             0x00100011, 0x12002111, 0x11221011, 0x01102131,
             0x141, 0, 0, 0
         },
+        .vfp_fpsid = 0x410120b4,
         .features = ARM_FEATURE(V6K) |
                     ARM_FEATURE(VFP) |
                     ARM_FEATURE(VAPA),
@@ -360,6 +367,7 @@ static const ARMCPUInfo arm_cpus[] = {
             0x00111142, 0, 0, 0
         },
         .cp15_c1_sys = 0x00c50078,
+        .vfp_fpsid = 0x410330c0,
         .features = ARM_FEATURE(V7) |
                     ARM_FEATURE(VFP3) |
                     ARM_FEATURE(NEON) |
@@ -378,6 +386,7 @@ static const ARMCPUInfo arm_cpus[] = {
             0x00111142, 0, 0, 0
         },
         .cp15_c1_sys = 0x00c50078,
+        .vfp_fpsid = 0x41033090,
         .features = ARM_FEATURE(V7) |
                     ARM_FEATURE(VFP3) |
                     ARM_FEATURE(VFP_FP16) |
@@ -402,6 +411,7 @@ static const ARMCPUInfo arm_cpus[] = {
             0x10011142, 0, 0, 0
         },
         .cp15_c1_sys = 0x00c50078,
+        .vfp_fpsid = 0x410430f0,
         .features = ARM_FEATURE(V7) |
                     ARM_FEATURE(VFP4) |
                     ARM_FEATURE(VFP_FP16) |
@@ -526,6 +536,7 @@ static void arm_cpu_class_init(ObjectClass *klass, void *data)
     memcpy(k->cp15.c0_c1, info->cp15_c0_c1, 8 * sizeof(uint32_t));
     memcpy(k->cp15.c0_c2, info->cp15_c0_c2, 8 * sizeof(uint32_t));
     k->cp15.c1_sys = info->cp15_c1_sys;
+    k->vfp.fpsid = info->vfp_fpsid;
     k->features = info->features;
 
     if (info->class_init != NULL) {
target-arm/cpu.h +0 -1
index d135221..e0d711f 100644
@@ -403,7 +403,6 @@ void cpu_arm_set_cp_io(CPUARMState *env, int cpnum,
 #define ARM_CPUID(env) (env->cp15.c0_cpuid)
 
 #define ARM_CPUID_ARM1026     0x4106a262
-#define ARM_CPUID_ARM926      0x41069265
 #define ARM_CPUID_TI915T      0x54029152
 #define ARM_CPUID_TI925T      0x54029252
 #define ARM_CPUID_ARM1136     0x4117b363
target-arm/helper.c +0 -12
index 421ce98..6ea656c 100644
@@ -8,12 +8,6 @@
 static void cpu_reset_model_id(CPUARMState *env, uint32_t id)
 {
     switch (id) {
-    case ARM_CPUID_ARM926:
-        env->vfp.xregs[ARM_VFP_FPSID] = 0x41011090;
-        break;
-    case ARM_CPUID_ARM1026:
-        env->vfp.xregs[ARM_VFP_FPSID] = 0x410110a0;
-        break;
     case ARM_CPUID_ARM1136:
         /* This is the 1136 r1, which is a v6K core */
         /* Fall through */
@@ -26,22 +20,18 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)
          * for 1136_r2 (in particular r0p2 does not actually implement most
          * of the ID registers).
          */
-        env->vfp.xregs[ARM_VFP_FPSID] = 0x410120b4;
         env->vfp.xregs[ARM_VFP_MVFR0] = 0x11111111;
         env->vfp.xregs[ARM_VFP_MVFR1] = 0x00000000;
         break;
     case ARM_CPUID_ARM1176:
-        env->vfp.xregs[ARM_VFP_FPSID] = 0x410120b5;
         env->vfp.xregs[ARM_VFP_MVFR0] = 0x11111111;
         env->vfp.xregs[ARM_VFP_MVFR1] = 0x00000000;
         break;
     case ARM_CPUID_ARM11MPCORE:
-        env->vfp.xregs[ARM_VFP_FPSID] = 0x410120b4;
         env->vfp.xregs[ARM_VFP_MVFR0] = 0x11111111;
         env->vfp.xregs[ARM_VFP_MVFR1] = 0x00000000;
         break;
     case ARM_CPUID_CORTEXA8:
-        env->vfp.xregs[ARM_VFP_FPSID] = 0x410330c0;
         env->vfp.xregs[ARM_VFP_MVFR0] = 0x11110222;
         env->vfp.xregs[ARM_VFP_MVFR1] = 0x00011100;
         env->cp15.c0_clid = (1 << 27) | (2 << 24) | 3;
@@ -50,7 +40,6 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)
         env->cp15.c0_ccsid[2] = 0xf0000000; /* No L2 icache. */
         break;
     case ARM_CPUID_CORTEXA9:
-        env->vfp.xregs[ARM_VFP_FPSID] = 0x41033090;
         env->vfp.xregs[ARM_VFP_MVFR0] = 0x11110222;
         env->vfp.xregs[ARM_VFP_MVFR1] = 0x01111111;
         env->cp15.c0_clid = (1 << 27) | (1 << 24) | 3;
@@ -58,7 +47,6 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)
         env->cp15.c0_ccsid[1] = 0x200fe015; /* 16k L1 icache. */
         break;
     case ARM_CPUID_CORTEXA15:
-        env->vfp.xregs[ARM_VFP_FPSID] = 0x410430f0;
         env->vfp.xregs[ARM_VFP_MVFR0] = 0x10110222;
         env->vfp.xregs[ARM_VFP_MVFR1] = 0x11111111;
         env->cp15.c0_clid = 0x0a200023;
Signature · 1 line
1.7.7
#108 lore raw

RFC PATCH v4 14/20 target-arm: Store VFP MVFR0 and MVFR1 in ARMCPUClass

In reply to Andreas Färber
---
 target-arm/cpu-qom.h |    1 +
 target-arm/cpu.c     |   11 +++++++++++
 target-arm/helper.c  |   29 -----------------------------
 3 files changed, 12 insertions(+), 29 deletions(-)
target-arm/cpu-qom.h +1 -0
index 6cb7891..cd711fa 100644
@@ -55,6 +55,7 @@ typedef struct ARMCPUClass {
     } cp15;
     struct {
         uint32_t fpsid;
+        uint32_t mvfr[2];
     } vfp;
 
     uint32_t features;
target-arm/cpu.c +11 -0
index ad4a90a..850aff1 100644
@@ -49,6 +49,8 @@ static void arm_cpu_reset(CPUState *c)
     env->cp15.c0_cachetype = klass->cp15.c0_cachetype;
     memcpy(env->cp15.c0_c1, klass->cp15.c0_c1, 8 * sizeof(uint32_t));
     memcpy(env->cp15.c0_c2, klass->cp15.c0_c2, 8 * sizeof(uint32_t));
+    env->vfp.xregs[ARM_VFP_MVFR0] = klass->vfp.mvfr[0];
+    env->vfp.xregs[ARM_VFP_MVFR1] = klass->vfp.mvfr[1];
 
     /* Genuine reset */
     env->cp15.c1_sys = klass->cp15.c1_sys;
@@ -179,6 +181,7 @@ typedef struct ARMCPUInfo {
     uint32_t cp15_c0_c2[8];
     uint32_t cp15_c1_sys;
     uint32_t vfp_fpsid;
+    uint32_t vfp_mvfr[2];
     uint32_t features;
     void (*class_init)(ARMCPUClass *klass, const struct ARMCPUInfo *info);
 } ARMCPUInfo;
@@ -310,6 +313,7 @@ static const ARMCPUInfo arm_cpus[] = {
         },
         .cp15_c1_sys = 0x00050078,
         .vfp_fpsid = 0x410120b4,
+        .vfp_mvfr = { 0x11111111, 0x00000000 },
         .features = ARM_FEATURE(V6) |
                     ARM_FEATURE(VFP),
     },
@@ -327,6 +331,7 @@ static const ARMCPUInfo arm_cpus[] = {
         },
         .cp15_c1_sys = 0x00050078,
         .vfp_fpsid = 0x410120b5,
+        .vfp_mvfr = { 0x11111111, 0x00000000 },
         .features = ARM_FEATURE(V6K) |
                     ARM_FEATURE(VFP) |
                     ARM_FEATURE(VAPA),
@@ -344,6 +349,7 @@ static const ARMCPUInfo arm_cpus[] = {
             0x141, 0, 0, 0
         },
         .vfp_fpsid = 0x410120b4,
+        .vfp_mvfr = { 0x11111111, 0x00000000 },
         .features = ARM_FEATURE(V6K) |
                     ARM_FEATURE(VFP) |
                     ARM_FEATURE(VAPA),
@@ -368,6 +374,7 @@ static const ARMCPUInfo arm_cpus[] = {
         },
         .cp15_c1_sys = 0x00c50078,
         .vfp_fpsid = 0x410330c0,
+        .vfp_mvfr = { 0x11110222, 0x00011100 },
         .features = ARM_FEATURE(V7) |
                     ARM_FEATURE(VFP3) |
                     ARM_FEATURE(NEON) |
@@ -387,6 +394,7 @@ static const ARMCPUInfo arm_cpus[] = {
         },
         .cp15_c1_sys = 0x00c50078,
         .vfp_fpsid = 0x41033090,
+        .vfp_mvfr = { 0x11110222, 0x01111111 },
         .features = ARM_FEATURE(V7) |
                     ARM_FEATURE(VFP3) |
                     ARM_FEATURE(VFP_FP16) |
@@ -412,6 +420,7 @@ static const ARMCPUInfo arm_cpus[] = {
         },
         .cp15_c1_sys = 0x00c50078,
         .vfp_fpsid = 0x410430f0,
+        .vfp_mvfr = { 0x10110222, 0x11111111 },
         .features = ARM_FEATURE(V7) |
                     ARM_FEATURE(VFP4) |
                     ARM_FEATURE(VFP_FP16) |
@@ -537,6 +546,8 @@ static void arm_cpu_class_init(ObjectClass *klass, void *data)
     memcpy(k->cp15.c0_c2, info->cp15_c0_c2, 8 * sizeof(uint32_t));
     k->cp15.c1_sys = info->cp15_c1_sys;
     k->vfp.fpsid = info->vfp_fpsid;
+    k->vfp.mvfr[0] = info->vfp_mvfr[0];
+    k->vfp.mvfr[1] = info->vfp_mvfr[1];
     k->features = info->features;
 
     if (info->class_init != NULL) {
target-arm/helper.c +0 -29
index 6ea656c..1f5043c 100644
@@ -8,47 +8,18 @@
 static void cpu_reset_model_id(CPUARMState *env, uint32_t id)
 {
     switch (id) {
-    case ARM_CPUID_ARM1136:
-        /* This is the 1136 r1, which is a v6K core */
-        /* Fall through */
-    case ARM_CPUID_ARM1136_R2:
-        /* What qemu calls "arm1136_r2" is actually the 1136 r0p2, ie an
-         * older core than plain "arm1136". In particular this does not
-         * have the v6K features.
-         */
-        /* These ID register values are correct for 1136 but may be wrong
-         * for 1136_r2 (in particular r0p2 does not actually implement most
-         * of the ID registers).
-         */
-        env->vfp.xregs[ARM_VFP_MVFR0] = 0x11111111;
-        env->vfp.xregs[ARM_VFP_MVFR1] = 0x00000000;
-        break;
-    case ARM_CPUID_ARM1176:
-        env->vfp.xregs[ARM_VFP_MVFR0] = 0x11111111;
-        env->vfp.xregs[ARM_VFP_MVFR1] = 0x00000000;
-        break;
-    case ARM_CPUID_ARM11MPCORE:
-        env->vfp.xregs[ARM_VFP_MVFR0] = 0x11111111;
-        env->vfp.xregs[ARM_VFP_MVFR1] = 0x00000000;
-        break;
     case ARM_CPUID_CORTEXA8:
-        env->vfp.xregs[ARM_VFP_MVFR0] = 0x11110222;
-        env->vfp.xregs[ARM_VFP_MVFR1] = 0x00011100;
         env->cp15.c0_clid = (1 << 27) | (2 << 24) | 3;
         env->cp15.c0_ccsid[0] = 0xe007e01a; /* 16k L1 dcache. */
         env->cp15.c0_ccsid[1] = 0x2007e01a; /* 16k L1 icache. */
         env->cp15.c0_ccsid[2] = 0xf0000000; /* No L2 icache. */
         break;
     case ARM_CPUID_CORTEXA9:
-        env->vfp.xregs[ARM_VFP_MVFR0] = 0x11110222;
-        env->vfp.xregs[ARM_VFP_MVFR1] = 0x01111111;
         env->cp15.c0_clid = (1 << 27) | (1 << 24) | 3;
         env->cp15.c0_ccsid[0] = 0xe00fe015; /* 16k L1 dcache. */
         env->cp15.c0_ccsid[1] = 0x200fe015; /* 16k L1 icache. */
         break;
     case ARM_CPUID_CORTEXA15:
-        env->vfp.xregs[ARM_VFP_MVFR0] = 0x10110222;
-        env->vfp.xregs[ARM_VFP_MVFR1] = 0x11111111;
         env->cp15.c0_clid = 0x0a200023;
         env->cp15.c0_ccsid[0] = 0x701fe00a; /* 32K L1 dcache */
         env->cp15.c0_ccsid[1] = 0x201fe00a; /* 32K L1 icache */
Signature · 1 line
1.7.7
#109 lore raw

RFC PATCH v4 15/20 target-arm: Store CLIDR in ARMCPUClass

In reply to Andreas Färber
---
 target-arm/cpu-qom.h |    1 +
 target-arm/cpu.c     |    6 ++++++
 target-arm/helper.c  |    3 ---
 3 files changed, 7 insertions(+), 3 deletions(-)
target-arm/cpu-qom.h +1 -0
index cd711fa..101cdb1 100644
@@ -49,6 +49,7 @@ typedef struct ARMCPUClass {
     struct {
         uint32_t c0_cpuid;
         uint32_t c0_cachetype;
+        uint32_t c0_clid;
         uint32_t c0_c1[8];
         uint32_t c0_c2[8];
         uint32_t c1_sys;
target-arm/cpu.c +6 -0
index 850aff1..1a06c52 100644
@@ -47,6 +47,7 @@ static void arm_cpu_reset(CPUState *c)
 
     /* TODO Move these into arm_cpu_initfn() once no longer zeroed above. */
     env->cp15.c0_cachetype = klass->cp15.c0_cachetype;
+    env->cp15.c0_clid = klass->cp15.c0_clid;
     memcpy(env->cp15.c0_c1, klass->cp15.c0_c1, 8 * sizeof(uint32_t));
     memcpy(env->cp15.c0_c2, klass->cp15.c0_c2, 8 * sizeof(uint32_t));
     env->vfp.xregs[ARM_VFP_MVFR0] = klass->vfp.mvfr[0];
@@ -177,6 +178,7 @@ typedef struct ARMCPUInfo {
     const char *name;
     uint32_t id;
     uint32_t cp15_c0_cachetype;
+    uint32_t cp15_c0_clid;
     uint32_t cp15_c0_c1[8];
     uint32_t cp15_c0_c2[8];
     uint32_t cp15_c1_sys;
@@ -364,6 +366,7 @@ static const ARMCPUInfo arm_cpus[] = {
         .name = "cortex-a8",
         .id = 0x410fc080,
         .cp15_c0_cachetype = 0x82048004,
+        .cp15_c0_clid = (1 << 27) | (2 << 24) | 3,
         .cp15_c0_c1 = {
             0x1031, 0x11, 0x400, 0,
             0x31100003, 0x20000000, 0x01202000, 0x11
@@ -384,6 +387,7 @@ static const ARMCPUInfo arm_cpus[] = {
         .name = "cortex-a9",
         .id = 0x410fc090,
         .cp15_c0_cachetype = 0x80038003,
+        .cp15_c0_clid = (1 << 27) | (1 << 24) | 3,
         .cp15_c0_c1 = {
             0x1031, 0x11, 0x000, 0,
             0x00100103, 0x20000000, 0x01230000, 0x00002111
@@ -410,6 +414,7 @@ static const ARMCPUInfo arm_cpus[] = {
         .name = "cortex-a15",
         .id = 0x412fc0f1,
         .cp15_c0_cachetype = 0x8444c004,
+        .cp15_c0_clid = 0x0a200023,
         .cp15_c0_c1 = {
             0x00001131, 0x00011011, 0x02010555, 0x00000000,
             0x10201105, 0x20000000, 0x01240000, 0x02102211
@@ -542,6 +547,7 @@ static void arm_cpu_class_init(ObjectClass *klass, void *data)
 
     k->cp15.c0_cpuid = info->id;
     k->cp15.c0_cachetype = info->cp15_c0_cachetype;
+    k->cp15.c0_clid = info->cp15_c0_clid;
     memcpy(k->cp15.c0_c1, info->cp15_c0_c1, 8 * sizeof(uint32_t));
     memcpy(k->cp15.c0_c2, info->cp15_c0_c2, 8 * sizeof(uint32_t));
     k->cp15.c1_sys = info->cp15_c1_sys;
target-arm/helper.c +0 -3
index 1f5043c..1e3576c 100644
@@ -9,18 +9,15 @@ static void cpu_reset_model_id(CPUARMState *env, uint32_t id)
 {
     switch (id) {
     case ARM_CPUID_CORTEXA8:
-        env->cp15.c0_clid = (1 << 27) | (2 << 24) | 3;
         env->cp15.c0_ccsid[0] = 0xe007e01a; /* 16k L1 dcache. */
         env->cp15.c0_ccsid[1] = 0x2007e01a; /* 16k L1 icache. */
         env->cp15.c0_ccsid[2] = 0xf0000000; /* No L2 icache. */
         break;
     case ARM_CPUID_CORTEXA9:
-        env->cp15.c0_clid = (1 << 27) | (1 << 24) | 3;
         env->cp15.c0_ccsid[0] = 0xe00fe015; /* 16k L1 dcache. */
         env->cp15.c0_ccsid[1] = 0x200fe015; /* 16k L1 icache. */
         break;
     case ARM_CPUID_CORTEXA15:
-        env->cp15.c0_clid = 0x0a200023;
         env->cp15.c0_ccsid[0] = 0x701fe00a; /* 32K L1 dcache */
         env->cp15.c0_ccsid[1] = 0x201fe00a; /* 32K L1 icache */
         env->cp15.c0_ccsid[2] = 0x711fe07a; /* 4096K L2 unified cache */
Signature · 1 line
1.7.7
#110 lore raw

RFC PATCH v4 16/20 target-arm: Store CCSIDRs in ARMCPUClass

In reply to Andreas Färber
---
 target-arm/cpu-qom.h |    1 +
 target-arm/cpu.c     |   17 +++++++++++++++++
 target-arm/helper.c  |   14 --------------
 3 files changed, 18 insertions(+), 14 deletions(-)
target-arm/cpu-qom.h +1 -0
index 101cdb1..cf79ed6 100644
@@ -49,6 +49,7 @@ typedef struct ARMCPUClass {
     struct {
         uint32_t c0_cpuid;
         uint32_t c0_cachetype;
+        uint32_t c0_ccsid[16];
         uint32_t c0_clid;
         uint32_t c0_c1[8];
         uint32_t c0_c2[8];
target-arm/cpu.c +17 -0
index 1a06c52..9f571a1 100644
@@ -47,6 +47,7 @@ static void arm_cpu_reset(CPUState *c)
 
     /* TODO Move these into arm_cpu_initfn() once no longer zeroed above. */
     env->cp15.c0_cachetype = klass->cp15.c0_cachetype;
+    memcpy(env->cp15.c0_ccsid, klass->cp15.c0_ccsid, 16 * sizeof(uint32_t));
     env->cp15.c0_clid = klass->cp15.c0_clid;
     memcpy(env->cp15.c0_c1, klass->cp15.c0_c1, 8 * sizeof(uint32_t));
     memcpy(env->cp15.c0_c2, klass->cp15.c0_c2, 8 * sizeof(uint32_t));
@@ -178,6 +179,7 @@ typedef struct ARMCPUInfo {
     const char *name;
     uint32_t id;
     uint32_t cp15_c0_cachetype;
+    uint32_t cp15_c0_ccsid[16];
     uint32_t cp15_c0_clid;
     uint32_t cp15_c0_c1[8];
     uint32_t cp15_c0_c2[8];
@@ -366,6 +368,11 @@ static const ARMCPUInfo arm_cpus[] = {
         .name = "cortex-a8",
         .id = 0x410fc080,
         .cp15_c0_cachetype = 0x82048004,
+        .cp15_c0_ccsid = {
+            0xe007e01a, /* 16k L1 dcache. */
+            0x2007e01a, /* 16k L1 icache. */
+            0xf0000000, /* No L2 icache. */
+        },
         .cp15_c0_clid = (1 << 27) | (2 << 24) | 3,
         .cp15_c0_c1 = {
             0x1031, 0x11, 0x400, 0,
@@ -387,6 +394,10 @@ static const ARMCPUInfo arm_cpus[] = {
         .name = "cortex-a9",
         .id = 0x410fc090,
         .cp15_c0_cachetype = 0x80038003,
+        .cp15_c0_ccsid = {
+            0xe00fe015, /* 16k L1 dcache. */
+            0x200fe015, /* 16k L1 icache. */
+        },
         .cp15_c0_clid = (1 << 27) | (1 << 24) | 3,
         .cp15_c0_c1 = {
             0x1031, 0x11, 0x000, 0,
@@ -414,6 +425,11 @@ static const ARMCPUInfo arm_cpus[] = {
         .name = "cortex-a15",
         .id = 0x412fc0f1,
         .cp15_c0_cachetype = 0x8444c004,
+        .cp15_c0_ccsid = {
+            0x701fe00a, /* 32K L1 dcache */
+            0x201fe00a, /* 32K L1 icache */
+            0x711fe07a, /* 4096K L2 unified cache */
+        },
         .cp15_c0_clid = 0x0a200023,
         .cp15_c0_c1 = {
             0x00001131, 0x00011011, 0x02010555, 0x00000000,
@@ -547,6 +563,7 @@ static void arm_cpu_class_init(ObjectClass *klass, void *data)
 
     k->cp15.c0_cpuid = info->id;
     k->cp15.c0_cachetype = info->cp15_c0_cachetype;
+    memcpy(k->cp15.c0_ccsid, info->cp15_c0_ccsid, 16 * sizeof(uint32_t));
     k->cp15.c0_clid = info->cp15_c0_clid;
     memcpy(k->cp15.c0_c1, info->cp15_c0_c1, 8 * sizeof(uint32_t));
     memcpy(k->cp15.c0_c2, info->cp15_c0_c2, 8 * sizeof(uint32_t));
target-arm/helper.c +0 -14
index 1e3576c..ba8a4ae 100644
@@ -8,20 +8,6 @@
 static void cpu_reset_model_id(CPUARMState *env, uint32_t id)
 {
     switch (id) {
-    case ARM_CPUID_CORTEXA8:
-        env->cp15.c0_ccsid[0] = 0xe007e01a; /* 16k L1 dcache. */
-        env->cp15.c0_ccsid[1] = 0x2007e01a; /* 16k L1 icache. */
-        env->cp15.c0_ccsid[2] = 0xf0000000; /* No L2 icache. */
-        break;
-    case ARM_CPUID_CORTEXA9:
-        env->cp15.c0_ccsid[0] = 0xe00fe015; /* 16k L1 dcache. */
-        env->cp15.c0_ccsid[1] = 0x200fe015; /* 16k L1 icache. */
-        break;
-    case ARM_CPUID_CORTEXA15:
-        env->cp15.c0_ccsid[0] = 0x701fe00a; /* 32K L1 dcache */
-        env->cp15.c0_ccsid[1] = 0x201fe00a; /* 32K L1 icache */
-        env->cp15.c0_ccsid[2] = 0x711fe07a; /* 4096K L2 unified cache */
-        break;
     case ARM_CPUID_TI915T:
     case ARM_CPUID_TI925T:
         env->cp15.c15_i_max = 0x000;
Signature · 1 line
1.7.7
#111 lore raw

RFC PATCH v4 17/20 target-arm: Kill off cpu_reset_model_id()

In reply to Andreas Färber

Move last remaining TI925T bits to ti925t_reset().

This reduces cpu_state_reset() to triviality and lets us reset the CPU directly from arm_cpu_initfn().

---
 target-arm/cpu.c    |    4 ++++
 target-arm/helper.c |   20 --------------------
 2 files changed, 4 insertions(+), 20 deletions(-)
target-arm/cpu.c +4 -0
index 9f571a1..8917a20 100644
@@ -217,6 +217,8 @@ static void ti925t_reset(CPUState *c)
     arm_cpu_reset(c);
 
     env->cp15.c0_cpuid = ARM_CPUID_TI925T; /* Depends on wiring. */
+    env->cp15.c15_i_max = 0x000;
+    env->cp15.c15_i_min = 0xff0;
 }
 
 static void ti925t_class_init(ARMCPUClass *klass, const ARMCPUInfo *info)
@@ -550,6 +552,8 @@ static void arm_cpu_initfn(Object *obj)
 
     cpu->env.cpu_model_str = object_get_typename(obj);
     cpu->env.cp15.c0_cpuid = cpu_class->cp15.c0_cpuid;
+
+    cpu_reset(CPU(cpu));
 }
 
 static void arm_cpu_class_init(ObjectClass *klass, void *data)
target-arm/helper.c +0 -20
index ba8a4ae..2d6331d 100644
@@ -5,28 +5,9 @@
 #include "sysemu.h"
 #include "cpu-qom.h"
 
-static void cpu_reset_model_id(CPUARMState *env, uint32_t id)
-{
-    switch (id) {
-    case ARM_CPUID_TI915T:
-    case ARM_CPUID_TI925T:
-        env->cp15.c15_i_max = 0x000;
-        env->cp15.c15_i_min = 0xff0;
-        break;
-    default:
-        break;
-    }
-}
-
 void cpu_state_reset(CPUARMState *env)
 {
-    uint32_t id;
-
     cpu_reset(ENV_GET_CPU(env));
-
-    id = env->cp15.c0_cpuid;
-    if (id)
-        cpu_reset_model_id(env, id);
 }
 
 static int vfp_gdb_get_reg(CPUARMState *env, uint8_t *buf, int reg)
@@ -105,7 +86,6 @@ CPUARMState *cpu_arm_init(const char *cpu_model)
         arm_translate_init();
     }
 
-    cpu_state_reset(env);
     if (arm_feature(env, ARM_FEATURE_NEON)) {
         gdb_register_coprocessor(env, vfp_gdb_get_reg, vfp_gdb_set_reg,
                                  51, "arm-neon.xml", 0);
Signature · 1 line
1.7.7
#112 lore raw

RFC PATCH v4 18/20 target-arm: Add cpuid-{variant, revision} properties to CPU

In reply to Andreas Färber

Allow to inspect and manipulate MIDR variant and revision fields.

---
 target-arm/cpu.c |   48 ++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 48 insertions(+), 0 deletions(-)
target-arm/cpu.c +48 -0
index 8917a20..ad33742 100644
@@ -20,6 +20,7 @@
 
 #include "cpu-qom.h"
 #include "qemu-common.h"
+#include "qapi/qapi-visit-core.h"
 #if !defined(CONFIG_USER_ONLY)
 #include "hw/loader.h"
 #endif
@@ -173,6 +174,46 @@ static inline void unset_class_feature(ARMCPUClass *klass, int feature)
     klass->features &= ~(1u << feature);
 }
 
+static void arm_cpuid_variant_get(Object *obj, Visitor *v, void *opaque,
+                                  const char *name, Error **errp)
+{
+    ARMCPU *cpu = ARM_CPU(obj);
+    int64_t value = (cpu->env.cp15.c0_cpuid >> 20) & 0xf;
+
+    visit_type_int(v, &value, name, errp);
+}
+
+static void arm_cpuid_variant_set(Object *obj, Visitor *v, void *opaque,
+                                  const char *name, Error **errp)
+{
+    ARMCPU *cpu = ARM_CPU(obj);
+    int64_t value;
+
+    visit_type_int(v, &value, name, errp);
+    cpu->env.cp15.c0_cpuid &= ~(0xf << 20);
+    cpu->env.cp15.c0_cpuid |= (value << 20) & 0xf;
+}
+
+static void arm_cpuid_revision_get(Object *obj, Visitor *v, void *opaque,
+                                   const char *name, Error **errp)
+{
+    ARMCPU *cpu = ARM_CPU(obj);
+    int64_t value = cpu->env.cp15.c0_cpuid & 0xf;
+
+    visit_type_int(v, &value, name, errp);
+}
+
+static void arm_cpuid_revision_set(Object *obj, Visitor *v, void *opaque,
+                                   const char *name, Error **errp)
+{
+    ARMCPU *cpu = ARM_CPU(obj);
+    int64_t value;
+
+    visit_type_int(v, &value, name, errp);
+    cpu->env.cp15.c0_cpuid &= ~0xf;
+    cpu->env.cp15.c0_cpuid |= value & 0xf;
+}
+
 /* CPU models */
 
 typedef struct ARMCPUInfo {
@@ -554,6 +595,13 @@ static void arm_cpu_initfn(Object *obj)
     cpu->env.cp15.c0_cpuid = cpu_class->cp15.c0_cpuid;
 
     cpu_reset(CPU(cpu));
+
+    object_property_add(obj, "cpuid-variant", "uint4",
+                        arm_cpuid_variant_get,
+                        arm_cpuid_variant_set, NULL, NULL, NULL);
+    object_property_add(obj, "cpuid-revision", "uint4",
+                        arm_cpuid_revision_get,
+                        arm_cpuid_revision_set, NULL, NULL, NULL);
 }
 
 static void arm_cpu_class_init(ObjectClass *klass, void *data)
Signature · 1 line
1.7.7
#113 lore raw

RFC PATCH v4 19/20 target-arm: Simplify pxa270 CPU classes

In reply to Andreas Färber

Instead of having classes per CPUID value, keep just one pxa270 class and use pxa270-a1 etc. as aliases that override default CPU properties.

Cc Paul Brook <[email protected]>
Cc Peter Maydell <[email protected]>
---
 target-arm/cpu.c    |   27 +--------------------------
 target-arm/helper.c |   29 ++++++++++++++++++++++++-----
 2 files changed, 25 insertions(+), 31 deletions(-)
target-arm/cpu.c +1 -26
index ad33742..da5bb6e 100644
@@ -539,36 +539,11 @@ static const ARMCPUInfo arm_cpus[] = {
         .class_init = pxa25x_class_init,
     },
     {
-        .name = "pxa270-a0",
+        .name = "pxa270",
         .id = 0x69054110,
         .class_init = pxa270_class_init,
     },
     {
-        .name = "pxa270-a1",
-        .id = 0x69054111,
-        .class_init = pxa270_class_init,
-    },
-    {
-        .name = "pxa270-b0",
-        .id = 0x69054112,
-        .class_init = pxa270_class_init,
-    },
-    {
-        .name = "pxa270-b1",
-        .id = 0x69054113,
-        .class_init = pxa270_class_init,
-    },
-    {
-        .name = "pxa270-c0",
-        .id = 0x69054114,
-        .class_init = pxa270_class_init,
-    },
-    {
-        .name = "pxa270-c5",
-        .id = 0x69054117,
-        .class_init = pxa270_class_init,
-    },
-    {
         .name = "any",
         .id = 0xffffffff,
         .features = ARM_FEATURE(V7) |
target-arm/helper.c +24 -5
index 2d6331d..f66f500 100644
@@ -64,22 +64,41 @@ static int vfp_gdb_set_reg(CPUARMState *env, uint8_t *buf, int reg)
 
 CPUARMState *cpu_arm_init(const char *cpu_model)
 {
+    const char *cpu_typename = cpu_model;
     ObjectClass *klass;
     ARMCPU *cpu;
     CPUARMState *env;
     static int inited = 0;
 
-    /* One legacy alias to check */
-    if (strcmp(cpu_model, "pxa270") == 0) {
-        cpu_model = "pxa270-a0";
+    /* Map legacy aliases to base class */
+    if (strcmp(cpu_model, "pxa270-a0") == 0 ||
+        strcmp(cpu_model, "pxa270-a1") == 0 ||
+        strcmp(cpu_model, "pxa270-b0") == 0 ||
+        strcmp(cpu_model, "pxa270-b1") == 0 ||
+        strcmp(cpu_model, "pxa270-c0") == 0 ||
+        strcmp(cpu_model, "pxa270-c5") == 0) {
+        cpu_typename = "pxa270";
     }
 
-    klass = object_class_by_name(cpu_model);
+    klass = object_class_by_name(cpu_typename);
     if (klass == NULL) {
         return NULL;
     }
-    cpu = ARM_CPU(object_new(cpu_model));
+    cpu = ARM_CPU(object_new(cpu_typename));
     env = &cpu->env;
+    env->cpu_model_str = cpu_model;
+    /* Set properties on base object */
+    if (strcmp(cpu_model, "pxa270-a1") == 0) {
+        object_property_set_int(OBJECT(cpu), 0x1, "cpuid-revision", NULL);
+    } else if (strcmp(cpu_model, "pxa270-b0") == 0) {
+        object_property_set_int(OBJECT(cpu), 0x2, "cpuid-revision", NULL);
+    } else if (strcmp(cpu_model, "pxa270-b1") == 0) {
+        object_property_set_int(OBJECT(cpu), 0x3, "cpuid-revision", NULL);
+    } else if (strcmp(cpu_model, "pxa270-c0") == 0) {
+        object_property_set_int(OBJECT(cpu), 0x4, "cpuid-revision", NULL);
+    } else if (strcmp(cpu_model, "pxa270-c5") == 0) {
+        object_property_set_int(OBJECT(cpu), 0x7, "cpuid-revision", NULL);
+    }
 
     if (tcg_enabled() && !inited) {
         inited = 1;
Signature · 1 line
1.7.7
#114 lore raw

RFC PATCH v4 20/20 hw/integratorcp: Add child property for CPU

In reply to Andreas Färber

Only one CPU is created on this board, so we can use "/cpu".

---
 hw/integratorcp.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
hw/integratorcp.c +3 -0
index 9bdb9e6..ac3fd7e 100644
@@ -443,6 +443,7 @@ static void integratorcp_init(ram_addr_t ram_size,
                      const char *kernel_filename, const char *kernel_cmdline,
                      const char *initrd_filename, const char *cpu_model)
 {
+    ARMCPU *cpu;
     CPUARMState *env;
     MemoryRegion *address_space_mem = get_system_memory();
     MemoryRegion *ram = g_new(MemoryRegion, 1);
@@ -459,6 +460,8 @@ static void integratorcp_init(ram_addr_t ram_size,
         fprintf(stderr, "Unable to find CPU definition\n");
         exit(1);
     }
+    cpu = arm_env_get_cpu(env);
+    object_property_add_child(object_get_root(), "cpu", OBJECT(cpu), NULL);
     memory_region_init_ram(ram, "integrator.ram", ram_size);
     vmstate_register_ram_global(ram);
     /* ??? On a real system the first 1Mb is mapped as SSRAM or boot flash.  */
Signature · 1 line
1.7.7
#115 lore raw
In reply to Andreas Färber
Quoted 8 lines · Andreas Färber

Hello Anthony,

This series prepares for QOM'ification of CPUs and machines by rearranging constructor calls and Makefile dependency rules. I've separated it out due to complaints about patch series length for conversion of all targets.

Patch 1 is a RESEND that avoids an abort after patch 2.

Quoted 8 lines

Patch 2 rearranges module init for QOM in the system emulators, so that objects can really be used beyond devices.

Patch 3 adds QOM support to the user emulators. As required by Anthony, they are now only built once.

Available at:
http://repo.or.cz/w/qemu/afaerber.git/shortlog/refs/heads/qom-user.v4

Applied. Thanks.

Regards,

Anthony Liguori

Quoted 42 lines

Regards,
Andreas

Cc Anthony Liguori<[email protected]>
Cc Avi Kivity<[email protected]>

v3 -> v4:
* Fix kvmclock abort due to too early kvm_enabled() check.
* Introduce $(universal-obj-y) to build some objects only once.
* Fix GPLv2 license link.

v2 -> v3:
* Rebased against qom-upstream.14 branch (and that against master).

* Build common dependencies for user emulators in libuser/.
* New dependencies needed after moving properties into object.c.
* Add a qemu-user.c with stubs needed for successful linking.

v1 -> v2:

* Don't introduce extra early_init(), just relocate former MODULE_INIT_DEVICE.
* Provide new type_init() macro to be used instead of device_init().

Andreas Färber (3):
kvmclock: Always register type
qom: Register QOM infrastructure early
qom: Add QOM support to user emulators

  Makefile           |    6 +++---
  Makefile.objs      |   23 ++++++++++++++++++-----
  Makefile.target    |    4 ++++
  Makefile.user      |    1 +
  bsd-user/main.c    |    2 ++
  darwin-user/main.c |    3 +++
  hw/kvm/clock.c     |    2 --
  linux-user/main.c  |    2 ++
  qemu-user.c        |   37 +++++++++++++++++++++++++++++++++++++
  vl.c               |    4 ++--
  10 files changed, 72 insertions(+), 12 deletions(-)

create mode 100644 qemu-user.c

#116 lore raw

cover QOM'ify UniCore32 CPU

In reply to Andreas Färber

Hello,

Based on qom-cpu v4 and object_class_get_list() v2, this series converts the UniCore32 CPU to QOM. Code-wise, target-unicore32 is pretty close to target-arm and faces a similar issue of CPU-dependent init code, so let's tackle it next.

Patch 1 adds a UniCore32 CPU guest core (TCG) section to MAINTAINERS, so that the target-unicore32 author gets notified of patches against his code.

Patch 2, based on feedback from Guan Xuetao, changes the license of most target-unicore32 files from GPLv2 to GPLv2+. Anthony had contributed a qemu_malloc() -> g_malloc() substitution that he can't relicense at this time, so leave that as GPLv2 and declare my following patches explicitly as GPLv2+.

Patch 2 embeds CPUUniCore32State into UniCore32CPU. My new cpu-qom.h header can be GPLv2+, but into cpu.c we're moving helper.c code so make it GPLv2 for now.

Patches 4-7 move code out of the uc32_cpu_init() function and into classes.

Regards,
Andreas

Cc Guan Xue-tao <[email protected]>
Cc Anthony Liguori <[email protected]>

Changes from former repo.or.cz qom-cpu[-wip] branch:
* Drop duplicate .instance_init.

Andreas Färber (7):
MAINTAINERS: Add entry for UniCore32
target-unicore32: Relicense to GPLv2+
target-unicore32: QOM'ify CPU
target-unicore32: Store cp0 c0_cachetype in UniCore32CPUClass
target-unicore32: Store cp0 c1_sys in UniCore32CPUClass
target-unicore32: Store feature flags in UniCore32CPUClass
target-unicore32: Store ucf64 fpscr in UniCore32CPUClass

 MAINTAINERS                  |    5 ++
 Makefile.target              |    1 +
 target-unicore32/cpu-qom.h   |   81 ++++++++++++++++++++++++++++++
 target-unicore32/cpu.c       |  112 ++++++++++++++++++++++++++++++++++++++++++
 target-unicore32/cpu.h       |   10 +---
 target-unicore32/helper.c    |   62 ++---------------------
 target-unicore32/helper.h    |    5 +-
 target-unicore32/op_helper.c |    5 +-
 target-unicore32/translate.c |    5 +-
 9 files changed, 213 insertions(+), 73 deletions(-)
 create mode 100644 target-unicore32/cpu-qom.h
 create mode 100644 target-unicore32/cpu.c
Signature · 1 line
1.7.7
#117 lore raw

PATCH 1/7 MAINTAINERS: Add entry for UniCore32

Consider it Odd Fixes for now.

---
 MAINTAINERS |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
MAINTAINERS +5 -0
index f83d07c2..44ff923 100644
@@ -112,6 +112,11 @@ M: Blue Swirl <[email protected]>
 S: Maintained
 F: target-sparc/
 
+UniCore32
+M: Guan Xuetao <[email protected]>
+S: Odd Fixes
+F: target-unicore32/
+
 X86
 M: [email protected]
 S: Odd Fixes
Signature · 1 line
1.7.7
#118 lore raw

Re: [Qemu-devel] [PATCH 1/7] MAINTAINERS: Add entry for UniCore32

Quoted 13 lines · Andreas Färber

Consider it Odd Fixes for now.

---
 MAINTAINERS |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
MAINTAINERS +0 -0
index f83d07c2..44ff923 100644

MAINTAINERS M: Blue Swirl <[email protected]> · line 117

Quoted 6 lines
MAINTAINERS +3 -0
@@ -112,6 +112,11 @@ M: Blue Swirl <[email protected]>
 S: Maintained
 F: target-sparc/
 
+UniCore32
+M: Guan Xuetao <[email protected]>
+S: Odd Fixes

The status can be changed to Maintained.
I will try my best to maintain it.

Guan Xuetao

Quoted 5 lines
MAINTAINERS +2 -0
+F: target-unicore32/
+
 X86
 M: [email protected]
 S: Odd Fixes
#119 lore raw

PATCH 2/7 target-unicore32: Relicense to GPLv2+

In reply to Andreas Färber

Adopt the license text suggested by Guan Xue-tao for all files except helper.c, to which Anthony Liguori (IBM) contributed a g_malloc() call.

---
 target-unicore32/cpu.h       |    5 ++---
 target-unicore32/helper.h    |    5 ++---
 target-unicore32/op_helper.c |    5 ++---
 target-unicore32/translate.c |    5 ++---
 4 files changed, 8 insertions(+), 12 deletions(-)
target-unicore32/cpu.h +2 -3
index a3f8589..9cbee7a 100644
@@ -3,9 +3,8 @@
  *
  * Copyright (C) 2010-2011 GUAN Xue-tao
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
+ * This program is licensed under the terms of the GNU GPL, version 2 or
+ * later. See the COPYING file in the top-level directory.
  */
 #ifndef __CPU_UC32_H__
 #define __CPU_UC32_H__
target-unicore32/helper.h +2 -3
index 615de2a..5aa7de8 100644
@@ -1,9 +1,8 @@
 /*
  * Copyright (C) 2010-2011 GUAN Xue-tao
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
+ * This program is licensed under the terms of the GNU GPL, version 2 or
+ * later. See the COPYING file in the top-level directory.
  */
 #include "def-helper.h"
 
target-unicore32/op_helper.c +2 -3
index 638a020..9fc2b1f 100644
@@ -3,9 +3,8 @@
  *
  * Copyright (C) 2010-2011 GUAN Xue-tao
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
+ * This program is licensed under the terms of the GNU GPL, version 2 or
+ * later. See the COPYING file in the top-level directory.
  */
 #include "cpu.h"
 #include "dyngen-exec.h"
target-unicore32/translate.c +2 -3
index 3b3ba16..c01e636 100644
@@ -3,9 +3,8 @@
  *
  * Copyright (C) 2010-2011 GUAN Xue-tao
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
+ * This program is licensed under the terms of the GNU GPL, version 2 or
+ * later. See the COPYING file in the top-level directory.
  */
 #include <stdarg.h>
 #include <stdlib.h>
Signature · 1 line
1.7.7
#120 lore raw

Re: [Qemu-devel] [PATCH 2/7] target-unicore32: Relicense to GPLv2+

Quoted 8 lines · Andreas Färber

Adopt the license text suggested by Guan Xue-tao for all files except helper.c, to which Anthony Liguori (IBM) contributed a g_malloc() call.

Quoted 5 lines
---
 target-unicore32/cpu.h       |    5 ++---
 target-unicore32/helper.h    |    5 ++---
 target-unicore32/op_helper.c |    5 ++---
 target-unicore32/translate.c |    5 ++---

target-unicore32/helper.c is skipped.

Guan Xuetao

Quoted 66 lines
 4 files changed, 8 insertions(+), 12 deletions(-)
target-unicore32/cpu.h +2 -3
index a3f8589..9cbee7a 100644
@@ -3,9 +3,8 @@
  *
  * Copyright (C) 2010-2011 GUAN Xue-tao
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
+ * This program is licensed under the terms of the GNU GPL, version 2 or
+ * later. See the COPYING file in the top-level directory.
  */
 #ifndef __CPU_UC32_H__
 #define __CPU_UC32_H__
target-unicore32/helper.h +2 -3
index 615de2a..5aa7de8 100644
@@ -1,9 +1,8 @@
 /*
  * Copyright (C) 2010-2011 GUAN Xue-tao
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
+ * This program is licensed under the terms of the GNU GPL, version 2 or
+ * later. See the COPYING file in the top-level directory.
  */
 #include "def-helper.h"
 
target-unicore32/op_helper.c +2 -3
index 638a020..9fc2b1f 100644
@@ -3,9 +3,8 @@
  *
  * Copyright (C) 2010-2011 GUAN Xue-tao
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
+ * This program is licensed under the terms of the GNU GPL, version 2 or
+ * later. See the COPYING file in the top-level directory.
  */
 #include "cpu.h"
 #include "dyngen-exec.h"
target-unicore32/translate.c +2 -3
index 3b3ba16..c01e636 100644
@@ -3,9 +3,8 @@
  *
  * Copyright (C) 2010-2011 GUAN Xue-tao
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
+ * This program is licensed under the terms of the GNU GPL, version 2 or
+ * later. See the COPYING file in the top-level directory.
  */
 #include <stdarg.h>
 #include <stdlib.h>
#121 lore raw

Re: [Qemu-devel] [PATCH 2/7] target-unicore32: Relicense to GPLv2+

Am 14.03.2012 08:53, schrieb Guan Xuetao:

Quoted 14 lines · Andreas Färber
Quoted 8 lines

Adopt the license text suggested by Guan Xue-tao for all files except helper.c, to which Anthony Liguori (IBM) contributed a g_malloc() call.

Quoted 5 lines
---
 target-unicore32/cpu.h       |    5 ++---
 target-unicore32/helper.h    |    5 ++---
 target-unicore32/op_helper.c |    5 ++---
 target-unicore32/translate.c |    5 ++---
Quoted 1 line

target-unicore32/helper.c is skipped.

...which is explained in the above commit message and in the cover letter. :)

Whether we can relicense it to GPLv2+ after patch 3/7 (which redoes object instantiation in a way not derived from an IBM contribution) remained an open question. IANAL.

What we can do, similar to Paolo's solution for central files, is to add a notice to helper.c that makes new contributions from, e.g., today on GPLv2+ so we don't need to ask for more people's permission.

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#122 lore raw

Re: [Qemu-devel] [PATCH 2/7] target-unicore32: Relicense to GPLv2+

In reply to Andreas Färber
Quoted 7 lines · Andreas Färber

Adopt the license text suggested by Guan Xue-tao for all files except helper.c, to which Anthony Liguori (IBM) contributed a g_malloc() call.

Ack.

Quoted 75 lines

---
 target-unicore32/cpu.h       |    5 ++---
 target-unicore32/helper.h    |    5 ++---
 target-unicore32/op_helper.c |    5 ++---
 target-unicore32/translate.c |    5 ++---

 4 files changed, 8 insertions(+), 12 deletions(-)
target-unicore32/cpu.h +2 -3
index a3f8589..9cbee7a 100644
@@ -3,9 +3,8 @@
  *
  * Copyright (C) 2010-2011 GUAN Xue-tao
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
+ * This program is licensed under the terms of the GNU GPL, version 2 or
+ * later. See the COPYING file in the top-level directory.
  */
  #ifndef __CPU_UC32_H__
  #define __CPU_UC32_H__
target-unicore32/helper.h +2 -3
index 615de2a..5aa7de8 100644
@@ -1,9 +1,8 @@
  /*
  * Copyright (C) 2010-2011 GUAN Xue-tao
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
+ * This program is licensed under the terms of the GNU GPL, version 2 or
+ * later. See the COPYING file in the top-level directory.
  */
  #include "def-helper.h"
 
target-unicore32/op_helper.c +2 -3
index 638a020..9fc2b1f 100644
@@ -3,9 +3,8 @@
  *
  * Copyright (C) 2010-2011 GUAN Xue-tao
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
+ * This program is licensed under the terms of the GNU GPL, version 2 or
+ * later. See the COPYING file in the top-level directory.
  */
  #include "cpu.h"
  #include "dyngen-exec.h"
target-unicore32/translate.c +2 -4
index 3b3ba16..c01e636 100644
@@ -3,9 +3,8 @@
  *
  * Copyright (C) 2010-2011 GUAN Xue-tao
  *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
+ * This program is licensed under the terms of the GNU GPL, version 2 or
+ * later. See the COPYING file in the top-level directory.
  */
  #include <stdarg.h>
  #include <stdlib.h>
--

1.7.7

#123 lore raw

Re: [Qemu-devel] [PATCH 2/7] target-unicore32: Relicense to GPLv2+

In reply to Andreas Färber

Am 14.03.2012 02:39, schrieb Andreas Färber:

Quoted 8 lines

Adopt the license text suggested by Guan Xue-tao for all files except helper.c, to which Anthony Liguori (IBM) contributed a g_malloc() call.

Quoted 6 lines

---
target-unicore32/cpu.h | 5 ++---
target-unicore32/helper.h | 5 ++---
target-unicore32/op_helper.c | 5 ++---
target-unicore32/translate.c | 5 ++---

4 files changed, 8 insertions(+), 12 deletions(-)

Ack. I don't really think that my contribution here is large enough that my "Acked-by" or "Signed-off-by" is needed, but if it helps...

As far as I know, at least in German law trivial changes don't result in a copyright claim. A global search-and-replace operation which replaces qemu_mallocz by g_malloc0 is trivial and no obstacle for a license change, so helper.c could be changed as well(that's my personal opinion).

Regards,
Stefan W.

#124 lore raw

Re: [Qemu-devel] [PATCH 2/7] target-unicore32: Relicense to GPLv2+

Quoted 20 lines · Stefan Weil

Am 14.03.2012 02:39, schrieb Andreas Färber:

Quoted 8 lines

Adopt the license text suggested by Guan Xue-tao for all files except helper.c, to which Anthony Liguori (IBM) contributed a g_malloc() call.

Quoted 6 lines

---
target-unicore32/cpu.h | 5 ++---
target-unicore32/helper.h | 5 ++---
target-unicore32/op_helper.c | 5 ++---
target-unicore32/translate.c | 5 ++---

4 files changed, 8 insertions(+), 12 deletions(-)

Ack. I don't really think that my contribution here is large enough that my "Acked-by" or "Signed-off-by" is needed, but if it helps...

Quoted 5 lines

As far as I know, at least in German law trivial changes don't result in a copyright claim. A global search-and-replace operation which replaces qemu_mallocz by g_malloc0 is trivial and no obstacle for a license change, so helper.c could be changed as well(that's my personal opinion).

Nack.

I don't really want to get into the business of splitting hairs here. We have no pressing reason to relicense to GPLv2+ so let's do it right and get the appropriate SoBs.

Regards,

Anthony Liguori

Quoted 4 lines

Regards,
Stefan W.

#125 lore raw

PATCH 3/7 target-unicore32: QOM'ify CPU

In reply to Andreas Färber

Embed CPUUniCore32State into UniCore32CPU.

Contributed under GPLv2+.

---
 Makefile.target            |    1 +
 target-unicore32/cpu-qom.h |   72 ++++++++++++++++++++++++++++++++++
 target-unicore32/cpu.c     |   91 ++++++++++++++++++++++++++++++++++++++++++++
 target-unicore32/cpu.h     |    1 +
 target-unicore32/helper.c  |   43 +++-----------------
 5 files changed, 172 insertions(+), 36 deletions(-)
 create mode 100644 target-unicore32/cpu-qom.h
 create mode 100644 target-unicore32/cpu.c
Makefile.target +1 -0
index cbf62c0..7033df0 100644
@@ -94,6 +94,7 @@ libobj-y += cpu_init.o
 endif
 libobj-$(TARGET_SPARC) += int32_helper.o
 libobj-$(TARGET_SPARC64) += int64_helper.o
+libobj-$(TARGET_UNICORE32) += cpu.o
 
 libobj-y += disas.o
 libobj-$(CONFIG_TCI_DIS) += tci-dis.o
target-unicore32/cpu-qom.h new file +72 -0

72 lines not on this page · raw message

target-unicore32/cpu.c new file +91 -0

91 lines not on this page · raw message

target-unicore32/cpu.h +1 -0
index 9cbee7a..1ddd272 100644
@@ -158,6 +158,7 @@ static inline void cpu_set_tls(CPUUniCore32State *env, target_ulong newtls)
 }
 
 #include "cpu-all.h"
+#include "cpu-qom.h"
 #include "exec-all.h"
 
 static inline void cpu_pc_from_tb(CPUUniCore32State *env, TranslationBlock *tb)
target-unicore32/helper.c +7 -36

67 lines not on this page · raw message

Signature · 1 line
1.7.7
#126 lore raw

Re: [Qemu-devel] [PATCH 3/7] target-unicore32: QOM'ify CPU

Quoted 9 lines · Andreas Färber

Embed CPUUniCore32State into UniCore32CPU.

Contributed under GPLv2+.

---
 Makefile.target            |    1 +
 target-unicore32/cpu-qom.h |   72 ++++++++++++++++++++++++++++++++++
 target-unicore32/cpu.c     |   91 ++++++++++++++++++++++++++++++++++++++++++++

I hope the gpl information for cpu.c and cpu-qom.h could be consistent with other files.

Guan Xuetao

Quoted 278 lines
 target-unicore32/cpu.h     |    1 +
 target-unicore32/helper.c  |   43 +++-----------------
 5 files changed, 172 insertions(+), 36 deletions(-)
 create mode 100644 target-unicore32/cpu-qom.h
 create mode 100644 target-unicore32/cpu.c
Makefile.target +1 -0
index cbf62c0..7033df0 100644
@@ -94,6 +94,7 @@ libobj-y += cpu_init.o
 endif
 libobj-$(TARGET_SPARC) += int32_helper.o
 libobj-$(TARGET_SPARC64) += int64_helper.o
+libobj-$(TARGET_UNICORE32) += cpu.o
 
 libobj-y += disas.o
 libobj-$(CONFIG_TCI_DIS) += tci-dis.o
target-unicore32/cpu-qom.h new file +72 -0
new file mode 100644
index 0000000..afe47e8
@@ -0,0 +1,72 @@
+/*
+ * QEMU UniCore32 CPU
+ *
+ * Copyright (c) 2012 SUSE LINUX Products GmbH
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see
+ * <http://www.gnu.org/licenses/gpl-2.0.html>
+ */
+#ifndef QEMU_UC32_CPU_QOM_H
+#define QEMU_UC32_CPU_QOM_H
+
+#include "qemu/cpu.h"
+#include "cpu.h"
+
+#define TYPE_UNICORE32_CPU "unicore32-cpu"
+
+#define UNICORE32_CPU_CLASS(klass) \
+    OBJECT_CLASS_CHECK(UniCore32CPUClass, (klass), TYPE_UNICORE32_CPU)
+#define UNICORE32_CPU(obj) \
+    OBJECT_CHECK(UniCore32CPU, (obj), TYPE_UNICORE32_CPU)
+#define UNICORE32_CPU_GET_CLASS(obj) \
+    OBJECT_GET_CLASS(UniCore32CPUClass, (obj), TYPE_UNICORE32_CPU)
+
+/**
+ * UniCore32CPUClass:
+ *
+ * A UniCore32 CPU model.
+ */
+typedef struct UniCore32CPUClass {
+    /*< private >*/
+    CPUClass parent_class;
+    /*< public >*/
+
+    struct {
+        uint32_t c0_cpuid;
+    } cp0;
+} UniCore32CPUClass;
+
+/**
+ * UniCore32CPU:
+ * @env: Legacy CPU state.
+ *
+ * A UniCore32 CPU.
+ */
+typedef struct UniCore32CPU {
+    /*< private >*/
+    CPUState parent_obj;
+    /*< public >*/
+
+    CPUUniCore32State env;
+} UniCore32CPU;
+
+static inline UniCore32CPU *uc32_env_get_cpu(CPUUniCore32State *env)
+{
+    return UNICORE32_CPU(container_of(env, UniCore32CPU, env));
+}
+
+#define ENV_GET_CPU(e) CPU(uc32_env_get_cpu(e))
+
+
+#endif
target-unicore32/cpu.c new file +91 -0
new file mode 100644
index 0000000..b89a1c6
@@ -0,0 +1,91 @@
+/*
+ * QEMU UniCore32 CPU
+ *
+ * Copyright (c) 2010-2011 GUAN Xue-tao
+ * Copyright (c) 2012 SUSE LINUX Products GmbH
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include "cpu-qom.h"
+#include "qemu-common.h"
+
+/* CPU models */
+
+typedef struct UniCore32CPUInfo {
+    const char *name;
+    uint32_t cp0_c0_cpuid;
+} UniCore32CPUInfo;
+
+static const UniCore32CPUInfo uc32_cpus[] = {
+    {
+        .name = "UniCore-II",
+        .cp0_c0_cpuid = 0x40010863,
+    },
+    {
+        .name = "any",
+        .cp0_c0_cpuid = 0xffffffff,
+    }
+};
+
+static void uc32_cpu_initfn(Object *obj)
+{
+    UniCore32CPU *cpu = UNICORE32_CPU(obj);
+    UniCore32CPUClass *klass = UNICORE32_CPU_GET_CLASS(cpu);
+    CPUUniCore32State *env = &cpu->env;
+
+    memset(env, 0, sizeof(CPUUniCore32State));
+    cpu_exec_init(env);
+    env->cpu_model_str = object_get_typename(obj);
+    env->cp0.c0_cpuid = klass->cp0.c0_cpuid;
+
+    env->uncached_asr = ASR_MODE_USER;
+    env->regs[31] = 0;
+
+    tlb_flush(env, 1);
+}
+
+static void uc32_cpu_class_init(ObjectClass *klass, void *data)
+{
+    UniCore32CPUClass *k = UNICORE32_CPU_CLASS(klass);
+    const UniCore32CPUInfo *info = data;
+
+    k->cp0.c0_cpuid = info->cp0_c0_cpuid;
+}
+
+static void uc32_register_cpu(const UniCore32CPUInfo *info)
+{
+    TypeInfo type = {
+        .name = info->name,
+        .parent = TYPE_UNICORE32_CPU,
+        .instance_size = sizeof(UniCore32CPU),
+        .class_size = sizeof(UniCore32CPUClass),
+        .class_init = uc32_cpu_class_init,
+        .class_data = (void *)info,
+    };
+
+    type_register_static(&type);
+}
+
+static const TypeInfo uc32_cpu_info = {
+    .name = TYPE_UNICORE32_CPU,
+    .parent = TYPE_CPU,
+    .instance_size = sizeof(UniCore32CPU),
+    .instance_init = uc32_cpu_initfn,
+    .abstract = true,
+    .class_size = sizeof(UniCore32CPUClass),
+};
+
+static void uc32_cpu_register_types(void)
+{
+    int i;
+
+    type_register_static(&uc32_cpu_info);
+    for (i = 0; i < ARRAY_SIZE(uc32_cpus); i++) {
+        uc32_register_cpu(&uc32_cpus[i]);
+    }
+}
+
+type_init(uc32_cpu_register_types)
target-unicore32/cpu.h +1 -0
index 9cbee7a..1ddd272 100644
@@ -158,6 +158,7 @@ static inline void cpu_set_tls(CPUUniCore32State *env, target_ulong newtls)
 }
 
 #include "cpu-all.h"
+#include "cpu-qom.h"
 #include "exec-all.h"
 
 static inline void cpu_pc_from_tb(CPUUniCore32State *env, TranslationBlock *tb)
target-unicore32/helper.c +7 -36
index 6af492d..44b7842 100644
@@ -16,43 +16,20 @@ static inline void set_feature(CPUUniCore32State *env, int feature)
     env->features |= feature;
 }
 
-struct uc32_cpu_t {
-    uint32_t id;
-    const char *name;
-};
-
-static const struct uc32_cpu_t uc32_cpu_names[] = {
-    { UC32_CPUID_UCV2, "UniCore-II"},
-    { UC32_CPUID_ANY, "any"},
-    { 0, NULL}
-};
-
-/* return 0 if not found */
-static uint32_t uc32_cpu_find_by_name(const char *name)
-{
-    int i;
-    uint32_t id;
-
-    id = 0;
-    for (i = 0; uc32_cpu_names[i].name; i++) {
-        if (strcmp(name, uc32_cpu_names[i].name) == 0) {
-            id = uc32_cpu_names[i].id;
-            break;
-        }
-    }
-    return id;
-}
-
 CPUUniCore32State *uc32_cpu_init(const char *cpu_model)
 {
+    UniCore32CPU *cpu;
     CPUUniCore32State *env;
     uint32_t id;
     static int inited = 1;
 
-    env = g_malloc0(sizeof(CPUUniCore32State));
-    cpu_exec_init(env);
+    if (object_class_by_name(cpu_model) == NULL) {
+        return NULL;
+    }
+    cpu = UNICORE32_CPU(object_new(cpu_model));
+    env = &cpu->env;
 
-    id = uc32_cpu_find_by_name(cpu_model);
+    id = env->cp0.c0_cpuid;
     switch (id) {
     case UC32_CPUID_UCV2:
         set_feature(env, UC32_HWCAP_CMOV);
@@ -69,17 +46,11 @@ CPUUniCore32State *uc32_cpu_init(const char *cpu_model)
         cpu_abort(env, "Bad CPU ID: %x\n", id);
     }
 
-    env->cpu_model_str = cpu_model;
-    env->cp0.c0_cpuid = id;
-    env->uncached_asr = ASR_MODE_USER;
-    env->regs[31] = 0;
-
     if (inited) {
         inited = 0;
         uc32_translate_init();
     }
 
-    tlb_flush(env, 1);
     qemu_init_vcpu(env);
     return env;
 }
#127 lore raw

Re: [Qemu-devel] [PATCH 3/7] target-unicore32: QOM'ify CPU

Am 14.03.2012 08:56, schrieb Guan Xuetao:

Quoted 5 lines · Andreas Färber
Quoted 4 lines

Embed CPUUniCore32State into UniCore32CPU.

Contributed under GPLv2+.

Quoted 7 lines
Quoted 5 lines
---
 Makefile.target            |    1 +
 target-unicore32/cpu-qom.h |   72 ++++++++++++++++++++++++++++++++++
 target-unicore32/cpu.c     |   91 ++++++++++++++++++++++++++++++++++++++++++++

I hope the gpl information for cpu.c and cpu-qom.h could be consistent with other files.

Copy&paste from other cpu-qom.h files. :) I can change it to match the rest of target-unicore32.

But speaking of matching licenses, your previous text has "as published by the Free Software Foundation", which I think is a bit safer in theory (no company X can publish a "GPL" v4 of their own and change it to their liking) and would make the change smaller. For example:

* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
+ * published by the Free Software Foundation, or (at your option) any
+ * later version. See the COPYING file in the top-level directory.

What do you think?

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#128 lore raw

Re: [Qemu-devel] [PATCH 3/7] target-unicore32: QOM'ify CPU

Quoted 28 lines · Andreas Färber

Am 14.03.2012 08:56, schrieb Guan Xuetao:

Quoted 5 lines · Andreas Färber
Quoted 4 lines

Embed CPUUniCore32State into UniCore32CPU.

Contributed under GPLv2+.

Quoted 7 lines
Quoted 5 lines
---
 Makefile.target            |    1 +
 target-unicore32/cpu-qom.h |   72 ++++++++++++++++++++++++++++++++++
 target-unicore32/cpu.c     |   91 ++++++++++++++++++++++++++++++++++++++++++++

I hope the gpl information for cpu.c and cpu-qom.h could be consistent with other files.

Copy&paste from other cpu-qom.h files. :) I can change it to match the rest of target-unicore32.

But speaking of matching licenses, your previous text has "as published by the Free Software Foundation", which I think is a bit safer in theory (no company X can publish a "GPL" v4 of their own and change it to their liking) and would make the change smaller. For example:

* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
+ * published by the Free Software Foundation, or (at your option) any
+ * later version. See the COPYING file in the top-level directory.

Quoted 4 lines

What do you think?

Andreas

GPLv2+ is ok.

Thanks and Regards

Guan Xuetao

#129 lore raw

PATCH 4/7 target-unicore32: Store cp0 c0_cachetype in UniCore32CPUClass

In reply to Andreas Färber

Contributed under GPLv2+.

---
 target-unicore32/cpu-qom.h |    1 +
 target-unicore32/cpu.c     |    4 ++++
 target-unicore32/helper.c  |    1 -
 3 files changed, 5 insertions(+), 1 deletions(-)
target-unicore32/cpu-qom.h +1 -0
index afe47e8..f3592d0 100644
@@ -44,6 +44,7 @@ typedef struct UniCore32CPUClass {
 
     struct {
         uint32_t c0_cpuid;
+        uint32_t c0_cachetype;
     } cp0;
 } UniCore32CPUClass;
 
target-unicore32/cpu.c +4 -0
index b89a1c6..c17b880 100644
@@ -17,12 +17,14 @@
 typedef struct UniCore32CPUInfo {
     const char *name;
     uint32_t cp0_c0_cpuid;
+    uint32_t cp0_c0_cachetype;
 } UniCore32CPUInfo;
 
 static const UniCore32CPUInfo uc32_cpus[] = {
     {
         .name = "UniCore-II",
         .cp0_c0_cpuid = 0x40010863,
+        .cp0_c0_cachetype = 0x1dd20d2,
     },
     {
         .name = "any",
@@ -40,6 +42,7 @@ static void uc32_cpu_initfn(Object *obj)
     cpu_exec_init(env);
     env->cpu_model_str = object_get_typename(obj);
     env->cp0.c0_cpuid = klass->cp0.c0_cpuid;
+    env->cp0.c0_cachetype = klass->cp0.c0_cachetype;
 
     env->uncached_asr = ASR_MODE_USER;
     env->regs[31] = 0;
@@ -53,6 +56,7 @@ static void uc32_cpu_class_init(ObjectClass *klass, void *data)
     const UniCore32CPUInfo *info = data;
 
     k->cp0.c0_cpuid = info->cp0_c0_cpuid;
+    k->cp0.c0_cachetype = info->cp0_c0_cachetype;
 }
 
 static void uc32_register_cpu(const UniCore32CPUInfo *info)
target-unicore32/helper.c +0 -1
index 44b7842..5e5e34d 100644
@@ -35,7 +35,6 @@ CPUUniCore32State *uc32_cpu_init(const char *cpu_model)
         set_feature(env, UC32_HWCAP_CMOV);
         set_feature(env, UC32_HWCAP_UCF64);
         env->ucf64.xregs[UC32_UCF64_FPSCR] = 0;
-        env->cp0.c0_cachetype = 0x1dd20d2;
         env->cp0.c1_sys = 0x00090078;
         break;
     case UC32_CPUID_ANY: /* For userspace emulation.  */
Signature · 1 line
1.7.7
#130 lore raw

PATCH 5/7 target-unicore32: Store cp0 c1_sys in UniCore32CPUClass

In reply to Andreas Färber

Contributed under GPLv2+.

---
 target-unicore32/cpu-qom.h |    1 +
 target-unicore32/cpu.c     |    4 ++++
 target-unicore32/helper.c  |    1 -
 3 files changed, 5 insertions(+), 1 deletions(-)
target-unicore32/cpu-qom.h +1 -0
index f3592d0..4d730f0 100644
@@ -45,6 +45,7 @@ typedef struct UniCore32CPUClass {
     struct {
         uint32_t c0_cpuid;
         uint32_t c0_cachetype;
+        uint32_t c1_sys;
     } cp0;
 } UniCore32CPUClass;
 
target-unicore32/cpu.c +4 -0
index c17b880..fa5c280 100644
@@ -18,6 +18,7 @@ typedef struct UniCore32CPUInfo {
     const char *name;
     uint32_t cp0_c0_cpuid;
     uint32_t cp0_c0_cachetype;
+    uint32_t cp0_c1_sys;
 } UniCore32CPUInfo;
 
 static const UniCore32CPUInfo uc32_cpus[] = {
@@ -25,6 +26,7 @@ static const UniCore32CPUInfo uc32_cpus[] = {
         .name = "UniCore-II",
         .cp0_c0_cpuid = 0x40010863,
         .cp0_c0_cachetype = 0x1dd20d2,
+        .cp0_c1_sys = 0x00090078,
     },
     {
         .name = "any",
@@ -43,6 +45,7 @@ static void uc32_cpu_initfn(Object *obj)
     env->cpu_model_str = object_get_typename(obj);
     env->cp0.c0_cpuid = klass->cp0.c0_cpuid;
     env->cp0.c0_cachetype = klass->cp0.c0_cachetype;
+    env->cp0.c1_sys = klass->cp0.c1_sys;
 
     env->uncached_asr = ASR_MODE_USER;
     env->regs[31] = 0;
@@ -57,6 +60,7 @@ static void uc32_cpu_class_init(ObjectClass *klass, void *data)
 
     k->cp0.c0_cpuid = info->cp0_c0_cpuid;
     k->cp0.c0_cachetype = info->cp0_c0_cachetype;
+    k->cp0.c1_sys = info->cp0_c1_sys;
 }
 
 static void uc32_register_cpu(const UniCore32CPUInfo *info)
target-unicore32/helper.c +0 -1
index 5e5e34d..ba9318b 100644
@@ -35,7 +35,6 @@ CPUUniCore32State *uc32_cpu_init(const char *cpu_model)
         set_feature(env, UC32_HWCAP_CMOV);
         set_feature(env, UC32_HWCAP_UCF64);
         env->ucf64.xregs[UC32_UCF64_FPSCR] = 0;
-        env->cp0.c1_sys = 0x00090078;
         break;
     case UC32_CPUID_ANY: /* For userspace emulation.  */
         set_feature(env, UC32_HWCAP_CMOV);
Signature · 1 line
1.7.7
#131 lore raw

PATCH 6/7 target-unicore32: Store feature flags in UniCore32CPUClass

In reply to Andreas Färber

Contributed under GPLv2+.

---
 target-unicore32/cpu-qom.h |    3 +++
 target-unicore32/cpu.c     |    9 +++++++++
 target-unicore32/helper.c  |    9 ---------
 3 files changed, 12 insertions(+), 9 deletions(-)
target-unicore32/cpu-qom.h +3 -0
index 4d730f0..c8178a5 100644
@@ -34,6 +34,7 @@
 
 /**
  * UniCore32CPUClass:
+ * @features: Internal CPU feature flags.
  *
  * A UniCore32 CPU model.
  */
@@ -47,6 +48,8 @@ typedef struct UniCore32CPUClass {
         uint32_t c0_cachetype;
         uint32_t c1_sys;
     } cp0;
+
+    uint32_t features;
 } UniCore32CPUClass;
 
 /**
target-unicore32/cpu.c +9 -0
index fa5c280..d4b47d6 100644
@@ -19,18 +19,25 @@ typedef struct UniCore32CPUInfo {
     uint32_t cp0_c0_cpuid;
     uint32_t cp0_c0_cachetype;
     uint32_t cp0_c1_sys;
+    uint32_t features;
 } UniCore32CPUInfo;
 
+#define UC32_FEATURE(feature) (1u << feature)
+
 static const UniCore32CPUInfo uc32_cpus[] = {
     {
         .name = "UniCore-II",
         .cp0_c0_cpuid = 0x40010863,
         .cp0_c0_cachetype = 0x1dd20d2,
         .cp0_c1_sys = 0x00090078,
+        .features = UC32_FEATURE(UC32_HWCAP_CMOV) |
+                    UC32_FEATURE(UC32_HWCAP_UCF64),
     },
     {
         .name = "any",
         .cp0_c0_cpuid = 0xffffffff,
+        .features = UC32_FEATURE(UC32_HWCAP_CMOV) |
+                    UC32_FEATURE(UC32_HWCAP_UCF64),
     }
 };
 
@@ -46,6 +53,7 @@ static void uc32_cpu_initfn(Object *obj)
     env->cp0.c0_cpuid = klass->cp0.c0_cpuid;
     env->cp0.c0_cachetype = klass->cp0.c0_cachetype;
     env->cp0.c1_sys = klass->cp0.c1_sys;
+    env->features = klass->features;
 
     env->uncached_asr = ASR_MODE_USER;
     env->regs[31] = 0;
@@ -61,6 +69,7 @@ static void uc32_cpu_class_init(ObjectClass *klass, void *data)
     k->cp0.c0_cpuid = info->cp0_c0_cpuid;
     k->cp0.c0_cachetype = info->cp0_c0_cachetype;
     k->cp0.c1_sys = info->cp0_c1_sys;
+    k->features = info->features;
 }
 
 static void uc32_register_cpu(const UniCore32CPUInfo *info)
target-unicore32/helper.c +0 -9
index ba9318b..fb6713c 100644
@@ -11,11 +11,6 @@
 #include "helper.h"
 #include "host-utils.h"
 
-static inline void set_feature(CPUUniCore32State *env, int feature)
-{
-    env->features |= feature;
-}
-
 CPUUniCore32State *uc32_cpu_init(const char *cpu_model)
 {
     UniCore32CPU *cpu;
@@ -32,13 +27,9 @@ CPUUniCore32State *uc32_cpu_init(const char *cpu_model)
     id = env->cp0.c0_cpuid;
     switch (id) {
     case UC32_CPUID_UCV2:
-        set_feature(env, UC32_HWCAP_CMOV);
-        set_feature(env, UC32_HWCAP_UCF64);
         env->ucf64.xregs[UC32_UCF64_FPSCR] = 0;
         break;
     case UC32_CPUID_ANY: /* For userspace emulation.  */
-        set_feature(env, UC32_HWCAP_CMOV);
-        set_feature(env, UC32_HWCAP_UCF64);
         break;
     default:
         cpu_abort(env, "Bad CPU ID: %x\n", id);
Signature · 1 line
1.7.7
#132 lore raw

PATCH 7/7 target-unicore32: Store ucf64 fpscr in UniCore32CPUClass

In reply to Andreas Färber

This removes the remaining CPUID dependency.

Contributed under GPLv2+.

---
 target-unicore32/cpu-qom.h |    4 ++++
 target-unicore32/cpu.c     |    4 ++++
 target-unicore32/cpu.h     |    4 ----
 target-unicore32/helper.c  |   12 ------------
 4 files changed, 8 insertions(+), 16 deletions(-)
target-unicore32/cpu-qom.h +4 -0
index c8178a5..594df73 100644
@@ -49,6 +49,10 @@ typedef struct UniCore32CPUClass {
         uint32_t c1_sys;
     } cp0;
 
+    struct {
+        uint32_t fpscr;
+    } ucf64;
+
     uint32_t features;
 } UniCore32CPUClass;
 
target-unicore32/cpu.c +4 -0
index d4b47d6..6966186 100644
@@ -19,6 +19,7 @@ typedef struct UniCore32CPUInfo {
     uint32_t cp0_c0_cpuid;
     uint32_t cp0_c0_cachetype;
     uint32_t cp0_c1_sys;
+    uint32_t ucf64_fpscr;
     uint32_t features;
 } UniCore32CPUInfo;
 
@@ -30,6 +31,7 @@ static const UniCore32CPUInfo uc32_cpus[] = {
         .cp0_c0_cpuid = 0x40010863,
         .cp0_c0_cachetype = 0x1dd20d2,
         .cp0_c1_sys = 0x00090078,
+        .ucf64_fpscr = 0,
         .features = UC32_FEATURE(UC32_HWCAP_CMOV) |
                     UC32_FEATURE(UC32_HWCAP_UCF64),
     },
@@ -53,6 +55,7 @@ static void uc32_cpu_initfn(Object *obj)
     env->cp0.c0_cpuid = klass->cp0.c0_cpuid;
     env->cp0.c0_cachetype = klass->cp0.c0_cachetype;
     env->cp0.c1_sys = klass->cp0.c1_sys;
+    env->ucf64.xregs[UC32_UCF64_FPSCR] = klass->ucf64.fpscr;
     env->features = klass->features;
 
     env->uncached_asr = ASR_MODE_USER;
@@ -69,6 +72,7 @@ static void uc32_cpu_class_init(ObjectClass *klass, void *data)
     k->cp0.c0_cpuid = info->cp0_c0_cpuid;
     k->cp0.c0_cachetype = info->cp0_c0_cachetype;
     k->cp0.c1_sys = info->cp0_c1_sys;
+    k->ucf64.fpscr = info->ucf64_fpscr;
     k->features = info->features;
 }
 
target-unicore32/cpu.h +0 -4
index 1ddd272..81d9e54 100644
@@ -118,10 +118,6 @@ void cpu_asr_write(CPUUniCore32State *env1, target_ulong val, target_ulong mask)
 #define UC32_HWCAP_CMOV                 4 /* 1 << 2 */
 #define UC32_HWCAP_UCF64                8 /* 1 << 3 */
 
-#define UC32_CPUID(env)                 (env->cp0.c0_cpuid)
-#define UC32_CPUID_UCV2                 0x40010863
-#define UC32_CPUID_ANY                  0xffffffff
-
 #define cpu_init                        uc32_cpu_init
 #define cpu_exec                        uc32_cpu_exec
 #define cpu_signal_handler              uc32_cpu_signal_handler
target-unicore32/helper.c +0 -12
index fb6713c..39ab488 100644
@@ -15,7 +15,6 @@ CPUUniCore32State *uc32_cpu_init(const char *cpu_model)
 {
     UniCore32CPU *cpu;
     CPUUniCore32State *env;
-    uint32_t id;
     static int inited = 1;
 
     if (object_class_by_name(cpu_model) == NULL) {
@@ -24,17 +23,6 @@ CPUUniCore32State *uc32_cpu_init(const char *cpu_model)
     cpu = UNICORE32_CPU(object_new(cpu_model));
     env = &cpu->env;
 
-    id = env->cp0.c0_cpuid;
-    switch (id) {
-    case UC32_CPUID_UCV2:
-        env->ucf64.xregs[UC32_UCF64_FPSCR] = 0;
-        break;
-    case UC32_CPUID_ANY: /* For userspace emulation.  */
-        break;
-    default:
-        cpu_abort(env, "Bad CPU ID: %x\n", id);
-    }
-
     if (inited) {
         inited = 0;
         uc32_translate_init();
Signature · 1 line
1.7.7
#133 lore raw

Re: [Qemu-devel] [PATCH 0/7] QOM'ify UniCore32 CPU

In reply to Andreas Färber
Quoted 15 lines · Andreas Färber

Hello,

Based on qom-cpu v4 and object_class_get_list() v2, this series converts the UniCore32 CPU to QOM. Code-wise, target-unicore32 is pretty close to target-arm and faces a similar issue of CPU-dependent init code, so let's tackle it next.

Patch 1 adds a UniCore32 CPU guest core (TCG) section to MAINTAINERS, so that the target-unicore32 author gets notified of patches against his code.

Patch 2, based on feedback from Guan Xuetao, changes the license of most target-unicore32 files from GPLv2 to GPLv2+. Anthony had contributed a qemu_malloc() -> g_malloc() substitution that he can't relicense at this time, so leave that as GPLv2 and declare my following patches explicitly as GPLv2+.

Quoted 7 lines

Patch 2 embeds CPUUniCore32State into UniCore32CPU. My new cpu-qom.h header can be GPLv2+, but into cpu.c we're moving helper.c code so make it GPLv2 for now.

Patches 4-7 move code out of the uc32_cpu_init() function and into classes.

Regards,
Andreas

Thanks for your help, and I'm sorry for my procrastination. I pulled the latest qemu code, but these patches seems to rely on the former qom-cpu v4 series.
Could you tell me where I can pull the testable branch/tree?

BTW: are there some robots to test qemu automatically? Then, I can put binary files (from simple helloworld to complicated spec benchmark) into it, perhaps write a script for running, and receive the result daily or weekly.

Thanks and Regards

Guan Xuetao

Quoted 28 lines
Cc Guan Xue-tao <[email protected]>
Cc Anthony Liguori <[email protected]>

Changes from former repo.or.cz qom-cpu[-wip] branch:
* Drop duplicate .instance_init.

Andreas Färber (7):
MAINTAINERS: Add entry for UniCore32
target-unicore32: Relicense to GPLv2+
target-unicore32: QOM'ify CPU
target-unicore32: Store cp0 c0_cachetype in UniCore32CPUClass
target-unicore32: Store cp0 c1_sys in UniCore32CPUClass
target-unicore32: Store feature flags in UniCore32CPUClass
target-unicore32: Store ucf64 fpscr in UniCore32CPUClass

 MAINTAINERS                  |    5 ++
 Makefile.target              |    1 +
 target-unicore32/cpu-qom.h   |   81 ++++++++++++++++++++++++++++++
 target-unicore32/cpu.c       |  112 ++++++++++++++++++++++++++++++++++++++++++
 target-unicore32/cpu.h       |   10 +---
 target-unicore32/helper.c    |   62 ++---------------------
 target-unicore32/helper.h    |    5 +-
 target-unicore32/op_helper.c |    5 +-
 target-unicore32/translate.c |    5 +-
 9 files changed, 213 insertions(+), 73 deletions(-)
 create mode 100644 target-unicore32/cpu-qom.h
 create mode 100644 target-unicore32/cpu.c
#134 lore raw

Re: [Qemu-devel] [PATCH 0/7] QOM'ify UniCore32 CPU

Am 14.03.2012 08:32, schrieb Guan Xuetao:

Quoted 14 lines · Andreas Färber
Quoted 13 lines

Based on qom-cpu v4 and object_class_get_list() v2, this series converts the UniCore32 CPU to QOM. Code-wise, target-unicore32 is pretty close to target-arm and faces a similar issue of CPU-dependent init code, so let's tackle it next.

Patch 1 adds a UniCore32 CPU guest core (TCG) section to MAINTAINERS, so that the target-unicore32 author gets notified of patches against his code.

Patch 2, based on feedback from Guan Xuetao, changes the license of most target-unicore32 files from GPLv2 to GPLv2+. Anthony had contributed a qemu_malloc() -> g_malloc() substitution that he can't relicense at this time, so leave that as GPLv2 and declare my following patches explicitly as GPLv2+.

Quoted 7 lines
Quoted 4 lines

Patch 2 embeds CPUUniCore32State into UniCore32CPU. My new cpu-qom.h header can be GPLv2+, but into cpu.c we're moving helper.c code so make it GPLv2 for now.

Patches 4-7 move code out of the uc32_cpu_init() function and into classes.

I pulled the latest qemu code, but these patches seems to rely on the former qom-cpu v4 series.

That series has been applied in the meantime, so unicore32 should no longer depend on other series.

Quoted 1 line

Could you tell me where I can pull the testable branch/tree?

Sorry, repo.or.cz was having problems at the time of posting, this v1 series is now available at:
git://repo.or.cz/qemu/afaerber.git qom-cpu-unicore32.v1

http://repo.or.cz/w/qemu/afaerber.git/shortlog/refs/heads/qom-cpu-unicore32.v1

I've added links to the Wiki for my work-in-progress branches on GitHub:
http://wiki.qemu.org/Features/QOM/CPU

Today I've reworked the preceding ARM series and rebased onto v5; I still need to revisit the table-driven class initialization before sending out a v2. MAINTAINERS and licenses are already adjusted.

Regards,
Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#135 lore raw

Re: [Qemu-devel] [PATCH 0/7] QOM'ify UniCore32 CPU

In reply to Andreas Färber
Quoted 7 lines · Andreas Färber

Hello,

Based on qom-cpu v4 and object_class_get_list() v2, this series converts the UniCore32 CPU to QOM. Code-wise, target-unicore32 is pretty close to target-arm and faces a similar issue of CPU-dependent init code, so let's tackle it next.

Quoted 7 lines

Patch 1 adds a UniCore32 CPU guest core (TCG) section to MAINTAINERS, so that the target-unicore32 author gets notified of patches against his code.

Patch 2, based on feedback from Guan Xuetao, changes the license of most target-unicore32 files from GPLv2 to GPLv2+. Anthony had contributed a qemu_malloc() -> g_malloc() substitution that he can't relicense at this time, so leave that as GPLv2 and declare my following patches explicitly as GPLv2+.

Perhaps g_malloc() patch could be partially reverted and a new GPLv2+ patch applied which uses g_new()?

Quoted 40 lines

Patch 2 embeds CPUUniCore32State into UniCore32CPU. My new cpu-qom.h header can be GPLv2+, but into cpu.c we're moving helper.c code so make it GPLv2 for now.

Patches 4-7 move code out of the uc32_cpu_init() function and into classes.

Regards,
Andreas

Cc Guan Xue-tao <[email protected]>
Cc Anthony Liguori <[email protected]>

Changes from former repo.or.cz qom-cpu[-wip] branch:
* Drop duplicate .instance_init.

Andreas Färber (7):
 MAINTAINERS: Add entry for UniCore32
 target-unicore32: Relicense to GPLv2+
 target-unicore32: QOM'ify CPU
 target-unicore32: Store cp0 c0_cachetype in UniCore32CPUClass
 target-unicore32: Store cp0 c1_sys in UniCore32CPUClass
 target-unicore32: Store feature flags in UniCore32CPUClass
 target-unicore32: Store ucf64 fpscr in UniCore32CPUClass

 MAINTAINERS                  |    5 ++
 Makefile.target              |    1 +
 target-unicore32/cpu-qom.h   |   81 ++++++++++++++++++++++++++++++ target-unicore32/cpu.c       |  112 ++++++++++++++++++++++++++++++++++++++++++ target-unicore32/cpu.h       |   10 +--- target-unicore32/helper.c    |   62 ++--------------------- target-unicore32/helper.h    |    5 +- target-unicore32/op_helper.c |    5 +- target-unicore32/translate.c |    5 +-

 9 files changed, 213 insertions(+), 73 deletions(-)

 create mode 100644 target-unicore32/cpu-qom.h
 create mode 100644 target-unicore32/cpu.c

--
1.7.7

#136 lore raw

Re: [Qemu-devel] [PATCH 0/7] QOM'ify UniCore32 CPU

Quoted 11 lines · Blue Swirl
Quoted 10 lines · Andreas Färber

Hello,

Based on qom-cpu v4 and object_class_get_list() v2, this series converts the UniCore32 CPU to QOM. Code-wise, target-unicore32 is pretty close to target-arm and faces a similar issue of CPU-dependent init code, so let's tackle it next.

Patch 1 adds a UniCore32 CPU guest core (TCG) section to MAINTAINERS, so that the target-unicore32 author gets notified of patches against his code.

Quoted 7 lines
Quoted 4 lines

Patch 2, based on feedback from Guan Xuetao, changes the license of most target-unicore32 files from GPLv2 to GPLv2+. Anthony had contributed a qemu_malloc() -> g_malloc() substitution that he can't relicense at this time, so leave that as GPLv2 and declare my following patches explicitly as GPLv2+.

Perhaps g_malloc() patch could be partially reverted and a new GPLv2+ patch applied which uses g_new()?

This is a bad idea IMHO. We need clear rules about changing licenses. I personally will not sign off on anything involving reverting code that cannot be relicensed.

Copyright law is just too complex when it comes to derivative works. Just have some patience and let's collect the necessary SoBs.

Regards,

Anthony Liguori

#137 lore raw

cover QOM'ify SuperH CPU and SH7750 SoC

In reply to Andreas Färber

Hello,

Based on qom-cpu v4 and object_class_get_list() v2, this series converts the SuperH CPU to QOM.

The SH7750 SoC code invited to do some cleanups, making use of the SuperHCPU, so I've QOM'ified the SoC and added the CPU as a link<SuperHCPU> for now.

I'm not so happy about the link construct, so it may need to be redone as a SysBus device with qdev properties - long-term I'd like to have a "system-on-chip" type derived from TYPE_DEVICE. Deriving it from TYPE_SYS_BUS_DEVICE might make for a better v2.

Patch 1 does the actual CPU QOM'ification, introducing SuperHCPU.

Patch 2 is a bugfix noticed during QOM'ification.

Patches 3-11 start using QOM SuperHCPU in place of CPUSH4State.

Patch 12 QOM'ifies the SH7750 SoC. Optional.

Available at:
http://repo.or.cz/w/qemu/afaerber.git/shortlog/refs/heads/qom-cpu-sh4.v1

Regards,
Andreas

Cc Aurélien Jarno <[email protected]>

Andreas Färber (12):
target-sh4: QOM'ify CPU
target-sh4: Do not reset features on reset
hw/sh7750: Use SuperHCPU
target-sh4: Make cpu_sh4_invalidate_tlb() take SuperHCPU
target-sh4: Make increment_urc() take SuperHCPU
target-sh4: Make find_*tlb_entry() take SuperHCPU
target-sh4: Make cpu_sh4_{read,write}_mmaped_{i,u}tlb_addr() take CPU
target-sh4: Make get_{physical,mmu}_address() take SuperHCPU
target-sh4: Make copy_utlb_entry_itlb() take SuperHCPU
target-sh4: Make update_itlb_use() take SuperHCPU
target-sh4: Make itlb_replacement() use SuperHCPU hw/sh7750: QOM'ify SH7750 SoC

 Makefile.target        |    1 +
 hw/r2d.c               |    9 ++-
 hw/sh.h                |    6 +-
 hw/sh7750.c            |   95 ++++++++++++++++---------
 hw/shix.c              |    8 ++-
 target-sh4/cpu-qom.h   |   81 +++++++++++++++++++++
 target-sh4/cpu.c       |  162 +++++++++++++++++++++++++++++++++++++++++
 target-sh4/cpu.h       |   24 +++---
 target-sh4/helper.c    |  188 +++++++++++++++++++++++++-----------------------
 target-sh4/translate.c |  122 ++++++++++---------------------
 10 files changed, 474 insertions(+), 222 deletions(-)
 create mode 100644 target-sh4/cpu-qom.h
 create mode 100644 target-sh4/cpu.c
Signature · 1 line
1.7.7
#138 lore raw

PATCH 1/12 target-sh4: QOM'ify CPU

Embed CPUSH4State into SuperHCPU. Let cpu_state_reset() call cpu_reset(). Let sh4_cpu_list() enumerate CPU classes alphabetically.

---
 Makefile.target        |    1 +
 target-sh4/cpu-qom.h   |   78 +++++++++++++++++++++++
 target-sh4/cpu.c       |  161 ++++++++++++++++++++++++++++++++++++++++++++++++
 target-sh4/cpu.h       |    1 +
 target-sh4/translate.c |  119 +++++++++++------------------------
 5 files changed, 278 insertions(+), 82 deletions(-)
 create mode 100644 target-sh4/cpu-qom.h
 create mode 100644 target-sh4/cpu.c
Makefile.target +1 -0
index 7033df0..c48a849 100644
@@ -88,6 +88,7 @@ libobj-$(TARGET_SPARC64) += vis_helper.o
 libobj-$(CONFIG_NEED_MMU) += mmu.o
 libobj-$(TARGET_ARM) += neon_helper.o iwmmxt_helper.o
 libobj-$(TARGET_ARM) += cpu.o
+libobj-$(TARGET_SH4) += cpu.o
 ifeq ($(TARGET_BASE_ARCH), sparc)
 libobj-y += fop_helper.o cc_helper.o win_helper.o mmu_helper.o ldst_helper.o
 libobj-y += cpu_init.o
target-sh4/cpu-qom.h new file +78 -0

78 lines not on this page · raw message

target-sh4/cpu.c new file +161 -0

161 lines not on this page · raw message

target-sh4/cpu.h +1 -0
index 965536d..ec5e6cf 100644
@@ -255,6 +255,7 @@ static inline void cpu_clone_regs(CPUSH4State *env, target_ulong newsp)
 #endif
 
 #include "cpu-all.h"
+#include "cpu-qom.h"
 
 /* Memory access type */
 enum {
target-sh4/translate.c +37 -82

144 lines not on this page · raw message

Signature · 1 line
1.7.7
#139 lore raw

PATCH 2/12 target-sh4: Do not reset features on reset

In reply to Andreas Färber

Move them out of CPUSH4State so that they are not zero'ed on reset.

---
 hw/sh7750.c            |    5 +++--
 target-sh4/cpu-qom.h   |    3 +++
 target-sh4/cpu.c       |    3 ++-
 target-sh4/cpu.h       |    3 ---
 target-sh4/translate.c |    3 ++-
 5 files changed, 10 insertions(+), 7 deletions(-)
hw/sh7750.c +3 -2
index e712928..c7e653c 100644
@@ -77,10 +77,11 @@ typedef struct SH7750State {
     struct intc_desc intc;
 } SH7750State;
 
-static inline int has_bcr3_and_bcr4(SH7750State * s)
+static inline int has_bcr3_and_bcr4(SH7750State *s)
 {
-	return (s->cpu->features & SH_FEATURE_BCR3_AND_BCR4);
+    return sh_env_get_cpu(s->cpu)->features & SH_FEATURE_BCR3_AND_BCR4;
 }
+
 /**********************************************************************
  I/O ports
 **********************************************************************/
target-sh4/cpu-qom.h +3 -0
index 1441328..c8cc63e 100644
@@ -55,6 +55,7 @@ typedef struct SuperHCPUClass {
 
 /**
  * SuperHCPU:
+ * @features: CPU feature flags, see #sh_features.
  * @env: Legacy CPU state.
  *
  * A SuperH CPU.
@@ -64,6 +65,8 @@ typedef struct SuperHCPU {
     CPUState parent_obj;
     /*< public >*/
 
+    uint32_t features;
+
     CPUSH4State env;
 } SuperHCPU;
 
target-sh4/cpu.c +2 -1
index 68034b6..d1bd156 100644
@@ -94,6 +94,8 @@ static void superh_cpu_initfn(Object *obj)
     SuperHCPUClass *klass = SUPERH_CPU_GET_CLASS(cpu);
     CPUSH4State *env = &cpu->env;
 
+    cpu->features = klass->features;
+
     memset(env, 0, sizeof(CPUSH4State));
     env->cpu_model_str = object_get_typename(obj);
     cpu_exec_init(env);
@@ -102,7 +104,6 @@ static void superh_cpu_initfn(Object *obj)
     env->pvr = klass->pvr;
     env->prr = klass->prr;
     env->cvr = klass->cvr;
-    env->features = klass->features;
 
     env->movcal_backup_tail = &(env->movcal_backup);
 
target-sh4/cpu.h +0 -3
index ec5e6cf..ee8ba5e 100644
@@ -157,9 +157,6 @@ typedef struct CPUSH4State {
     /* float point status register */
     float_status fp_status;
 
-    /* The features that we should emulate. See sh_features above.  */
-    uint32_t features;
-
     /* Those belong to the specific unit (SH7750) but are handled here */
     uint32_t mmucr;		/* MMU control register */
     uint32_t pteh;		/* page table entry high register */
target-sh4/translate.c +2 -1
index 71434d0..d43cd8c 100644
@@ -1876,6 +1876,7 @@ static inline void
 gen_intermediate_code_internal(CPUSH4State * env, TranslationBlock * tb,
                                int search_pc)
 {
+    SuperHCPU *cpu = sh_env_get_cpu(env);
     DisasContext ctx;
     target_ulong pc_start;
     static uint16_t *gen_opc_end;
@@ -1897,7 +1898,7 @@ gen_intermediate_code_internal(CPUSH4State * env, TranslationBlock * tb,
     ctx.delayed_pc = -1; /* use delayed pc from env pointer */
     ctx.tb = tb;
     ctx.singlestep_enabled = env->singlestep_enabled;
-    ctx.features = env->features;
+    ctx.features = cpu->features;
     ctx.has_movcal = (tb->flags & TB_FLAG_PENDING_MOVCA);
 
     ii = -1;
Signature · 1 line
1.7.7
#140 lore raw

PATCH 3/12 hw/sh7750: Use SuperHCPU

In reply to Andreas Färber

In place of CPUSH4State use SuperHCPU for SH7750State::cpu field.

Fix tab indentation on those lines and add braces.

---
 hw/sh7750.c |   69 ++++++++++++++++++++++++++++++-----------------------------
 1 files changed, 35 insertions(+), 34 deletions(-)
hw/sh7750.c +35 -34
index c7e653c..23950aa 100644
@@ -44,7 +44,7 @@ typedef struct SH7750State {
     MemoryRegion iomem_ffc;
     MemoryRegion mmct_iomem;
     /* CPU */
-    CPUSH4State *cpu;
+    SuperHCPU *cpu;
     /* Peripheral frequency in Hz */
     uint32_t periph_freq;
     /* SDRAM controller */
@@ -79,7 +79,7 @@ typedef struct SH7750State {
 
 static inline int has_bcr3_and_bcr4(SH7750State *s)
 {
-    return sh_env_get_cpu(s->cpu)->features & SH_FEATURE_BCR3_AND_BCR4;
+    return s->cpu->features & SH_FEATURE_BCR3_AND_BCR4;
 }
 
 /**********************************************************************
@@ -271,29 +271,29 @@ static uint32_t sh7750_mem_readl(void *opaque, target_phys_addr_t addr)
         ignore_access("long read", addr);
         return 0;
     case SH7750_MMUCR_A7:
-	return s->cpu->mmucr;
+        return s->cpu->env.mmucr;
     case SH7750_PTEH_A7:
-	return s->cpu->pteh;
+        return s->cpu->env.pteh;
     case SH7750_PTEL_A7:
-	return s->cpu->ptel;
+        return s->cpu->env.ptel;
     case SH7750_TTB_A7:
-	return s->cpu->ttb;
+        return s->cpu->env.ttb;
     case SH7750_TEA_A7:
-	return s->cpu->tea;
+        return s->cpu->env.tea;
     case SH7750_TRA_A7:
-	return s->cpu->tra;
+        return s->cpu->env.tra;
     case SH7750_EXPEVT_A7:
-	return s->cpu->expevt;
+        return s->cpu->env.expevt;
     case SH7750_INTEVT_A7:
-	return s->cpu->intevt;
+        return s->cpu->env.intevt;
     case SH7750_CCR_A7:
 	return s->ccr;
     case 0x1f000030:		/* Processor version */
-	return s->cpu->pvr;
+        return s->cpu->env.pvr;
     case 0x1f000040:		/* Cache version */
-	return s->cpu->cvr;
+        return s->cpu->env.cvr;
     case 0x1f000044:		/* Processor revision */
-	return s->cpu->prr;
+        return s->cpu->env.prr;
     default:
 	error_access("long read", addr);
         abort();
@@ -406,36 +406,37 @@ static void sh7750_mem_writel(void *opaque, target_phys_addr_t addr,
 	return;
     case SH7750_MMUCR_A7:
         if (mem_value & MMUCR_TI) {
-            cpu_sh4_invalidate_tlb(s->cpu);
+            cpu_sh4_invalidate_tlb(&s->cpu->env);
         }
-        s->cpu->mmucr = mem_value & ~MMUCR_TI;
+        s->cpu->env.mmucr = mem_value & ~MMUCR_TI;
         return;
     case SH7750_PTEH_A7:
         /* If asid changes, clear all registered tlb entries. */
-	if ((s->cpu->pteh & 0xff) != (mem_value & 0xff))
-	    tlb_flush(s->cpu, 1);
-	s->cpu->pteh = mem_value;
+        if ((s->cpu->env.pteh & 0xff) != (mem_value & 0xff)) {
+            tlb_flush(&s->cpu->env, 1);
+        }
+        s->cpu->env.pteh = mem_value;
 	return;
     case SH7750_PTEL_A7:
-	s->cpu->ptel = mem_value;
+        s->cpu->env.ptel = mem_value;
 	return;
     case SH7750_PTEA_A7:
-	s->cpu->ptea = mem_value & 0x0000000f;
+        s->cpu->env.ptea = mem_value & 0x0000000f;
 	return;
     case SH7750_TTB_A7:
-	s->cpu->ttb = mem_value;
+        s->cpu->env.ttb = mem_value;
 	return;
     case SH7750_TEA_A7:
-	s->cpu->tea = mem_value;
+        s->cpu->env.tea = mem_value;
 	return;
     case SH7750_TRA_A7:
-	s->cpu->tra = mem_value & 0x000007ff;
+        s->cpu->env.tra = mem_value & 0x000007ff;
 	return;
     case SH7750_EXPEVT_A7:
-	s->cpu->expevt = mem_value & 0x000007ff;
+        s->cpu->env.expevt = mem_value & 0x000007ff;
 	return;
     case SH7750_INTEVT_A7:
-	s->cpu->intevt = mem_value & 0x000007ff;
+        s->cpu->env.intevt = mem_value & 0x000007ff;
 	return;
     case SH7750_CCR_A7:
 	s->ccr = mem_value;
@@ -648,20 +649,20 @@ static uint64_t sh7750_mmct_read(void *opaque, target_phys_addr_t addr,
         /* do nothing */
 	break;
     case MM_ITLB_ADDR:
-        ret = cpu_sh4_read_mmaped_itlb_addr(s->cpu, addr);
+        ret = cpu_sh4_read_mmaped_itlb_addr(&s->cpu->env, addr);
         break;
     case MM_ITLB_DATA:
-        ret = cpu_sh4_read_mmaped_itlb_data(s->cpu, addr);
+        ret = cpu_sh4_read_mmaped_itlb_data(&s->cpu->env, addr);
         break;
     case MM_OCACHE_ADDR:
     case MM_OCACHE_DATA:
         /* do nothing */
 	break;
     case MM_UTLB_ADDR:
-        ret = cpu_sh4_read_mmaped_utlb_addr(s->cpu, addr);
+        ret = cpu_sh4_read_mmaped_utlb_addr(&s->cpu->env, addr);
         break;
     case MM_UTLB_DATA:
-        ret = cpu_sh4_read_mmaped_utlb_data(s->cpu, addr);
+        ret = cpu_sh4_read_mmaped_utlb_data(&s->cpu->env, addr);
         break;
     default:
         abort();
@@ -691,10 +692,10 @@ static void sh7750_mmct_write(void *opaque, target_phys_addr_t addr,
         /* do nothing */
 	break;
     case MM_ITLB_ADDR:
-        cpu_sh4_write_mmaped_itlb_addr(s->cpu, addr, mem_value);
+        cpu_sh4_write_mmaped_itlb_addr(&s->cpu->env, addr, mem_value);
         break;
     case MM_ITLB_DATA:
-        cpu_sh4_write_mmaped_itlb_data(s->cpu, addr, mem_value);
+        cpu_sh4_write_mmaped_itlb_data(&s->cpu->env, addr, mem_value);
         abort();
 	break;
     case MM_OCACHE_ADDR:
@@ -702,10 +703,10 @@ static void sh7750_mmct_write(void *opaque, target_phys_addr_t addr,
         /* do nothing */
 	break;
     case MM_UTLB_ADDR:
-        cpu_sh4_write_mmaped_utlb_addr(s->cpu, addr, mem_value);
+        cpu_sh4_write_mmaped_utlb_addr(&s->cpu->env, addr, mem_value);
 	break;
     case MM_UTLB_DATA:
-        cpu_sh4_write_mmaped_utlb_data(s->cpu, addr, mem_value);
+        cpu_sh4_write_mmaped_utlb_data(&s->cpu->env, addr, mem_value);
 	break;
     default:
         abort();
@@ -724,7 +725,7 @@ SH7750State *sh7750_init(CPUSH4State * cpu, MemoryRegion *sysmem)
     SH7750State *s;
 
     s = g_malloc0(sizeof(SH7750State));
-    s->cpu = cpu;
+    s->cpu = sh_env_get_cpu(cpu);
     s->periph_freq = 60000000;	/* 60MHz */
     memory_region_init_io(&s->iomem, &sh7750_mem_ops, s,
                           "memory", 0x1fc01000);
Signature · 1 line
1.7.7
#141 lore raw

PATCH 4/12 target-sh4: Make cpu_sh4_invalidate_tlb() take SuperHCPU

In reply to Andreas Färber

Change argument type from CPUSH4State to SuperHCPU. This simplifies the SH7750 SoC as its only caller.

---
 hw/sh7750.c         |    2 +-
 target-sh4/cpu.h    |    4 +++-
 target-sh4/helper.c |    8 ++++----
 3 files changed, 8 insertions(+), 6 deletions(-)
hw/sh7750.c +1 -1
index 23950aa..ca7839e 100644
@@ -406,7 +406,7 @@ static void sh7750_mem_writel(void *opaque, target_phys_addr_t addr,
 	return;
     case SH7750_MMUCR_A7:
         if (mem_value & MMUCR_TI) {
-            cpu_sh4_invalidate_tlb(&s->cpu->env);
+            cpu_sh4_invalidate_tlb(s->cpu);
         }
         s->cpu->env.mmucr = mem_value & ~MMUCR_TI;
         return;
target-sh4/cpu.h +3 -1
index ee8ba5e..32e59e7 100644
@@ -186,6 +186,8 @@ typedef struct CPUSH4State {
     memory_content **movcal_backup_tail;
 } CPUSH4State;
 
+typedef struct SuperHCPU SuperHCPU;
+
 CPUSH4State *cpu_sh4_init(const char *cpu_model);
 int cpu_sh4_exec(CPUSH4State * s);
 int cpu_sh4_signal_handler(int host_signum, void *pinfo,
@@ -197,7 +199,7 @@ void do_interrupt(CPUSH4State * env);
 
 void sh4_cpu_list(FILE *f, fprintf_function cpu_fprintf);
 #if !defined(CONFIG_USER_ONLY)
-void cpu_sh4_invalidate_tlb(CPUSH4State *s);
+void cpu_sh4_invalidate_tlb(SuperHCPU *cpu);
 uint32_t cpu_sh4_read_mmaped_itlb_addr(CPUSH4State *s,
                                        target_phys_addr_t addr);
 void cpu_sh4_write_mmaped_itlb_addr(CPUSH4State *s, target_phys_addr_t addr,
target-sh4/helper.c +4 -4
index 5c57380..655faaa 100644
@@ -555,22 +555,22 @@ void cpu_load_tlb(CPUSH4State * env)
     entry->tc   = (uint8_t)cpu_ptea_tc(env->ptea);
 }
 
- void cpu_sh4_invalidate_tlb(CPUSH4State *s)
+void cpu_sh4_invalidate_tlb(SuperHCPU *cpu)
 {
     int i;
 
     /* UTLB */
     for (i = 0; i < UTLB_SIZE; i++) {
-        tlb_t * entry = &s->utlb[i];
+        tlb_t *entry = &cpu->env.utlb[i];
         entry->v = 0;
     }
     /* ITLB */
     for (i = 0; i < ITLB_SIZE; i++) {
-        tlb_t * entry = &s->itlb[i];
+        tlb_t *entry = &cpu->env.itlb[i];
         entry->v = 0;
     }
 
-    tlb_flush(s, 1);
+    tlb_flush(&cpu->env, 1);
 }
 
 uint32_t cpu_sh4_read_mmaped_itlb_addr(CPUSH4State *s,
Signature · 1 line
1.7.7
#142 lore raw

PATCH 5/12 target-sh4: Make increment_urc() take SuperHCPU

In reply to Andreas Färber
---
 target-sh4/helper.c |   23 ++++++++++++-----------
 1 files changed, 12 insertions(+), 11 deletions(-)
target-sh4/helper.c +12 -11
index 655faaa..2d5a4e4 100644
@@ -269,17 +269,18 @@ static int find_tlb_entry(CPUSH4State * env, target_ulong address,
     return match;
 }
 
-static void increment_urc(CPUSH4State * env)
+static void increment_urc(SuperHCPU *cpu)
 {
     uint8_t urb, urc;
 
     /* Increment URC */
-    urb = ((env->mmucr) >> 18) & 0x3f;
-    urc = ((env->mmucr) >> 10) & 0x3f;
+    urb = ((cpu->env.mmucr) >> 18) & 0x3f;
+    urc = ((cpu->env.mmucr) >> 10) & 0x3f;
     urc++;
-    if ((urb > 0 && urc > urb) || urc > (UTLB_SIZE - 1))
+    if ((urb > 0 && urc > urb) || urc > (UTLB_SIZE - 1)) {
 	urc = 0;
-    env->mmucr = (env->mmucr & 0xffff03ff) | (urc << 10);
+    }
+    cpu->env.mmucr = (cpu->env.mmucr & 0xffff03ff) | (urc << 10);
 }
 
 /* Copy and utlb entry into itlb
@@ -324,7 +325,7 @@ static int find_itlb_entry(CPUSH4State * env, target_ulong address,
 static int find_utlb_entry(CPUSH4State * env, target_ulong address, int use_asid)
 {
     /* per utlb access */
-    increment_urc(env);
+    increment_urc(sh_env_get_cpu(env));
 
     /* Return entry */
     return find_tlb_entry(env, address, env->utlb, UTLB_SIZE, use_asid);
@@ -660,7 +661,7 @@ uint32_t cpu_sh4_read_mmaped_utlb_addr(CPUSH4State *s,
     int index = (addr & 0x00003f00) >> 8;
     tlb_t * entry = &s->utlb[index];
 
-    increment_urc(s); /* per utlb access */
+    increment_urc(sh_env_get_cpu(s)); /* per utlb access */
 
     return (entry->vpn  << 10) |
            (entry->v    <<  8) |
@@ -702,7 +703,7 @@ void cpu_sh4_write_mmaped_utlb_addr(CPUSH4State *s, target_phys_addr_t addr,
 		entry->d = d;
 	        utlb_match_entry = entry;
 	    }
-	    increment_urc(s); /* per utlb access */
+            increment_urc(sh_env_get_cpu(s)); /* per utlb access */
 	}
 
 	/* search ITLB */
@@ -735,7 +736,7 @@ void cpu_sh4_write_mmaped_utlb_addr(CPUSH4State *s, target_phys_addr_t addr,
 	entry->vpn = vpn;
 	entry->d = d;
 	entry->v = v;
-	increment_urc(s);
+        increment_urc(sh_env_get_cpu(s));
     }
 }
 
@@ -746,7 +747,7 @@ uint32_t cpu_sh4_read_mmaped_utlb_data(CPUSH4State *s,
     int index = (addr & 0x00003f00) >> 8;
     tlb_t * entry = &s->utlb[index];
 
-    increment_urc(s); /* per utlb access */
+    increment_urc(sh_env_get_cpu(s)); /* per utlb access */
 
     if (array == 0) {
         /* ITLB Data Array 1 */
@@ -773,7 +774,7 @@ void cpu_sh4_write_mmaped_utlb_data(CPUSH4State *s, target_phys_addr_t addr,
     int index = (addr & 0x00003f00) >> 8;
     tlb_t * entry = &s->utlb[index];
 
-    increment_urc(s); /* per utlb access */
+    increment_urc(sh_env_get_cpu(s)); /* per utlb access */
 
     if (array == 0) {
         /* UTLB Data Array 1 */
Signature · 1 line
1.7.7
#143 lore raw

PATCH 6/12 target-sh4: Make find_*tlb_entry() take SuperHCPU

In reply to Andreas Färber
---
 target-sh4/helper.c |   29 +++++++++++++++--------------
 1 files changed, 15 insertions(+), 14 deletions(-)
target-sh4/helper.c +15 -14
index 2d5a4e4..d2186ed 100644
@@ -243,15 +243,15 @@ static int itlb_replacement(CPUSH4State * env)
 /* Find the corresponding entry in the right TLB
    Return entry, MMU_DTLB_MISS or MMU_DTLB_MULTIPLE
 */
-static int find_tlb_entry(CPUSH4State * env, target_ulong address,
-			  tlb_t * entries, uint8_t nbtlb, int use_asid)
+static int find_tlb_entry(SuperHCPU *cpu, target_ulong address,
+                          tlb_t *entries, uint8_t nbtlb, int use_asid)
 {
     int match = MMU_DTLB_MISS;
     uint32_t start, end;
     uint8_t asid;
     int i;
 
-    asid = env->pteh & 0xff;
+    asid = cpu->env.pteh & 0xff;
 
     for (i = 0; i < nbtlb; i++) {
 	if (!entries[i].v)
@@ -304,31 +304,31 @@ static int copy_utlb_entry_itlb(CPUSH4State *env, int utlb)
 /* Find itlb entry
    Return entry, MMU_ITLB_MISS, MMU_ITLB_MULTIPLE or MMU_DTLB_MULTIPLE
 */
-static int find_itlb_entry(CPUSH4State * env, target_ulong address,
+static int find_itlb_entry(SuperHCPU *cpu, target_ulong address,
                            int use_asid)
 {
     int e;
 
-    e = find_tlb_entry(env, address, env->itlb, ITLB_SIZE, use_asid);
+    e = find_tlb_entry(cpu, address, cpu->env.itlb, ITLB_SIZE, use_asid);
     if (e == MMU_DTLB_MULTIPLE) {
 	e = MMU_ITLB_MULTIPLE;
     } else if (e == MMU_DTLB_MISS) {
 	e = MMU_ITLB_MISS;
     } else if (e >= 0) {
-	update_itlb_use(env, e);
+        update_itlb_use(&cpu->env, e);
     }
     return e;
 }
 
 /* Find utlb entry
    Return entry, MMU_DTLB_MISS, MMU_DTLB_MULTIPLE */
-static int find_utlb_entry(CPUSH4State * env, target_ulong address, int use_asid)
+static int find_utlb_entry(SuperHCPU *cpu, target_ulong address, int use_asid)
 {
     /* per utlb access */
-    increment_urc(sh_env_get_cpu(env));
+    increment_urc(cpu);
 
     /* Return entry */
-    return find_tlb_entry(env, address, env->utlb, UTLB_SIZE, use_asid);
+    return find_tlb_entry(cpu, address, cpu->env.utlb, UTLB_SIZE, use_asid);
 }
 
 /* Match address against MMU
@@ -348,7 +348,7 @@ static int get_mmu_address(CPUSH4State * env, target_ulong * physical,
     use_asid = (env->mmucr & MMUCR_SV) == 0 || (env->sr & SR_MD) == 0;
 
     if (rw == 2) {
-        n = find_itlb_entry(env, address, use_asid);
+        n = find_itlb_entry(sh_env_get_cpu(env), address, use_asid);
 	if (n >= 0) {
 	    matching = &env->itlb[n];
 	    if (!(env->sr & SR_MD) && !(matching->pr & 2))
@@ -356,7 +356,7 @@ static int get_mmu_address(CPUSH4State * env, target_ulong * physical,
 	    else
 		*prot = PAGE_EXEC;
         } else {
-            n = find_utlb_entry(env, address, use_asid);
+            n = find_utlb_entry(sh_env_get_cpu(env), address, use_asid);
             if (n >= 0) {
                 n = copy_utlb_entry_itlb(env, n);
                 matching = &env->itlb[n];
@@ -375,7 +375,7 @@ static int get_mmu_address(CPUSH4State * env, target_ulong * physical,
             }
 	}
     } else {
-	n = find_utlb_entry(env, address, use_asid);
+        n = find_utlb_entry(sh_env_get_cpu(env), address, use_asid);
 	if (n >= 0) {
 	    matching = &env->utlb[n];
             if (!(env->sr & SR_MD) && !(matching->pr & 2)) {
@@ -801,6 +801,7 @@ void cpu_sh4_write_mmaped_utlb_data(CPUSH4State *s, target_phys_addr_t addr,
 
 int cpu_sh4_is_cached(CPUSH4State * env, target_ulong addr)
 {
+    SuperHCPU *cpu = sh_env_get_cpu(env);
     int n;
     int use_asid = (env->mmucr & MMUCR_SV) == 0 || (env->sr & SR_MD) == 0;
 
@@ -832,11 +833,11 @@ int cpu_sh4_is_cached(CPUSH4State * env, target_ulong addr)
         return 1;
 
     /* check TLB */
-    n = find_tlb_entry(env, addr, env->itlb, ITLB_SIZE, use_asid);
+    n = find_tlb_entry(cpu, addr, env->itlb, ITLB_SIZE, use_asid);
     if (n >= 0)
         return env->itlb[n].c;
 
-    n = find_tlb_entry(env, addr, env->utlb, UTLB_SIZE, use_asid);
+    n = find_tlb_entry(cpu, addr, env->utlb, UTLB_SIZE, use_asid);
     if (n >= 0)
         return env->utlb[n].c;
 
Signature · 1 line
1.7.7
#144 lore raw

PATCH 7/12 target-sh4: Make cpu_sh4_{read, write}_mmaped_{i, u}tlb_addr() take CPU

In reply to Andreas Färber

Change argument type to SuperHCPU and update the SH7750 SoC.

---
 hw/sh7750.c         |   16 ++++++------
 target-sh4/cpu.h    |   16 ++++++------
 target-sh4/helper.c |   63 ++++++++++++++++++++++++++-------------------------
 3 files changed, 48 insertions(+), 47 deletions(-)
hw/sh7750.c +8 -8
index ca7839e..c3cea9f 100644
@@ -649,20 +649,20 @@ static uint64_t sh7750_mmct_read(void *opaque, target_phys_addr_t addr,
         /* do nothing */
 	break;
     case MM_ITLB_ADDR:
-        ret = cpu_sh4_read_mmaped_itlb_addr(&s->cpu->env, addr);
+        ret = cpu_sh4_read_mmaped_itlb_addr(s->cpu, addr);
         break;
     case MM_ITLB_DATA:
-        ret = cpu_sh4_read_mmaped_itlb_data(&s->cpu->env, addr);
+        ret = cpu_sh4_read_mmaped_itlb_data(s->cpu, addr);
         break;
     case MM_OCACHE_ADDR:
     case MM_OCACHE_DATA:
         /* do nothing */
 	break;
     case MM_UTLB_ADDR:
-        ret = cpu_sh4_read_mmaped_utlb_addr(&s->cpu->env, addr);
+        ret = cpu_sh4_read_mmaped_utlb_addr(s->cpu, addr);
         break;
     case MM_UTLB_DATA:
-        ret = cpu_sh4_read_mmaped_utlb_data(&s->cpu->env, addr);
+        ret = cpu_sh4_read_mmaped_utlb_data(s->cpu, addr);
         break;
     default:
         abort();
@@ -692,10 +692,10 @@ static void sh7750_mmct_write(void *opaque, target_phys_addr_t addr,
         /* do nothing */
 	break;
     case MM_ITLB_ADDR:
-        cpu_sh4_write_mmaped_itlb_addr(&s->cpu->env, addr, mem_value);
+        cpu_sh4_write_mmaped_itlb_addr(s->cpu, addr, mem_value);
         break;
     case MM_ITLB_DATA:
-        cpu_sh4_write_mmaped_itlb_data(&s->cpu->env, addr, mem_value);
+        cpu_sh4_write_mmaped_itlb_data(s->cpu, addr, mem_value);
         abort();
 	break;
     case MM_OCACHE_ADDR:
@@ -703,10 +703,10 @@ static void sh7750_mmct_write(void *opaque, target_phys_addr_t addr,
         /* do nothing */
 	break;
     case MM_UTLB_ADDR:
-        cpu_sh4_write_mmaped_utlb_addr(&s->cpu->env, addr, mem_value);
+        cpu_sh4_write_mmaped_utlb_addr(s->cpu, addr, mem_value);
 	break;
     case MM_UTLB_DATA:
-        cpu_sh4_write_mmaped_utlb_data(&s->cpu->env, addr, mem_value);
+        cpu_sh4_write_mmaped_utlb_data(s->cpu, addr, mem_value);
 	break;
     default:
         abort();
target-sh4/cpu.h +8 -8
index 32e59e7..b3abece 100644
@@ -200,21 +200,21 @@ void do_interrupt(CPUSH4State * env);
 void sh4_cpu_list(FILE *f, fprintf_function cpu_fprintf);
 #if !defined(CONFIG_USER_ONLY)
 void cpu_sh4_invalidate_tlb(SuperHCPU *cpu);
-uint32_t cpu_sh4_read_mmaped_itlb_addr(CPUSH4State *s,
+uint32_t cpu_sh4_read_mmaped_itlb_addr(SuperHCPU *cpu,
                                        target_phys_addr_t addr);
-void cpu_sh4_write_mmaped_itlb_addr(CPUSH4State *s, target_phys_addr_t addr,
+void cpu_sh4_write_mmaped_itlb_addr(SuperHCPU *cpu, target_phys_addr_t addr,
                                     uint32_t mem_value);
-uint32_t cpu_sh4_read_mmaped_itlb_data(CPUSH4State *s,
+uint32_t cpu_sh4_read_mmaped_itlb_data(SuperHCPU *cpu,
                                        target_phys_addr_t addr);
-void cpu_sh4_write_mmaped_itlb_data(CPUSH4State *s, target_phys_addr_t addr,
+void cpu_sh4_write_mmaped_itlb_data(SuperHCPU *cpu, target_phys_addr_t addr,
                                     uint32_t mem_value);
-uint32_t cpu_sh4_read_mmaped_utlb_addr(CPUSH4State *s,
+uint32_t cpu_sh4_read_mmaped_utlb_addr(SuperHCPU *cpu,
                                        target_phys_addr_t addr);
-void cpu_sh4_write_mmaped_utlb_addr(CPUSH4State *s, target_phys_addr_t addr,
+void cpu_sh4_write_mmaped_utlb_addr(SuperHCPU *cpu, target_phys_addr_t addr,
                                     uint32_t mem_value);
-uint32_t cpu_sh4_read_mmaped_utlb_data(CPUSH4State *s,
+uint32_t cpu_sh4_read_mmaped_utlb_data(SuperHCPU *cpu,
                                        target_phys_addr_t addr);
-void cpu_sh4_write_mmaped_utlb_data(CPUSH4State *s, target_phys_addr_t addr,
+void cpu_sh4_write_mmaped_utlb_data(SuperHCPU *cpu, target_phys_addr_t addr,
                                     uint32_t mem_value);
 #endif
 
target-sh4/helper.c +32 -31

199 lines not on this page · raw message

Signature · 1 line
1.7.7
#145 lore raw

PATCH 8/12 target-sh4: Make get_{physical, mmu}_address() take SuperHCPU

In reply to Andreas Färber

Simplifies TLB helper code.

---
 target-sh4/helper.c |   49 +++++++++++++++++++++++++------------------------
 1 files changed, 25 insertions(+), 24 deletions(-)
target-sh4/helper.c +25 -24
index 3653ece..d273097 100644
@@ -338,30 +338,32 @@ static int find_utlb_entry(SuperHCPU *cpu, target_ulong address, int use_asid)
    MMU_ITLB_MULTIPLE, MMU_ITLB_VIOLATION,
    MMU_IADDR_ERROR, MMU_DADDR_ERROR_READ, MMU_DADDR_ERROR_WRITE.
 */
-static int get_mmu_address(CPUSH4State * env, target_ulong * physical,
-			   int *prot, target_ulong address,
-			   int rw, int access_type)
+static int get_mmu_address(SuperHCPU *cpu, target_ulong *physical,
+                           int *prot, target_ulong address,
+                           int rw, int access_type)
 {
     int use_asid, n;
     tlb_t *matching = NULL;
 
-    use_asid = (env->mmucr & MMUCR_SV) == 0 || (env->sr & SR_MD) == 0;
+    use_asid = (cpu->env.mmucr & MMUCR_SV) == 0 ||
+               (cpu->env.sr & SR_MD) == 0;
 
     if (rw == 2) {
-        n = find_itlb_entry(sh_env_get_cpu(env), address, use_asid);
+        n = find_itlb_entry(cpu, address, use_asid);
 	if (n >= 0) {
-	    matching = &env->itlb[n];
-	    if (!(env->sr & SR_MD) && !(matching->pr & 2))
+            matching = &cpu->env.itlb[n];
+            if (!(cpu->env.sr & SR_MD) && !(matching->pr & 2)) {
 		n = MMU_ITLB_VIOLATION;
-	    else
+            } else {
 		*prot = PAGE_EXEC;
+            }
         } else {
-            n = find_utlb_entry(sh_env_get_cpu(env), address, use_asid);
+            n = find_utlb_entry(cpu, address, use_asid);
             if (n >= 0) {
-                n = copy_utlb_entry_itlb(env, n);
-                matching = &env->itlb[n];
-                if (!(env->sr & SR_MD) && !(matching->pr & 2)) {
-                      n = MMU_ITLB_VIOLATION;
+                n = copy_utlb_entry_itlb(&cpu->env, n);
+                matching = &cpu->env.itlb[n];
+                if (!(cpu->env.sr & SR_MD) && !(matching->pr & 2)) {
+                    n = MMU_ITLB_VIOLATION;
                 } else {
                     *prot = PAGE_READ | PAGE_EXEC;
                     if ((matching->pr & 1) && matching->d) {
@@ -375,10 +377,10 @@ static int get_mmu_address(CPUSH4State * env, target_ulong * physical,
             }
 	}
     } else {
-        n = find_utlb_entry(sh_env_get_cpu(env), address, use_asid);
+        n = find_utlb_entry(cpu, address, use_asid);
 	if (n >= 0) {
-	    matching = &env->utlb[n];
-            if (!(env->sr & SR_MD) && !(matching->pr & 2)) {
+            matching = &cpu->env.utlb[n];
+            if (!(cpu->env.sr & SR_MD) && !(matching->pr & 2)) {
                 n = (rw == 1) ? MMU_DTLB_VIOLATION_WRITE :
                     MMU_DTLB_VIOLATION_READ;
             } else if ((rw == 1) && !(matching->pr & 1)) {
@@ -404,14 +406,14 @@ static int get_mmu_address(CPUSH4State * env, target_ulong * physical,
     return n;
 }
 
-static int get_physical_address(CPUSH4State * env, target_ulong * physical,
+static int get_physical_address(SuperHCPU *cpu, target_ulong *physical,
                                 int *prot, target_ulong address,
                                 int rw, int access_type)
 {
     /* P1, P2 and P4 areas do not use translation */
     if ((address >= 0x80000000 && address < 0xc0000000) ||
 	address >= 0xe0000000) {
-	if (!(env->sr & SR_MD)
+        if (!(cpu->env.sr & SR_MD)
 	    && (address < 0xe0000000 || address >= 0xe4000000)) {
 	    /* Unauthorized access in user mode (only store queues are available) */
 	    fprintf(stderr, "Unauthorized access\n");
@@ -433,14 +435,14 @@ static int get_physical_address(CPUSH4State * env, target_ulong * physical,
     }
 
     /* If MMU is disabled, return the corresponding physical page */
-    if (!(env->mmucr & MMUCR_AT)) {
+    if (!(cpu->env.mmucr & MMUCR_AT)) {
 	*physical = address & 0x1FFFFFFF;
 	*prot = PAGE_READ | PAGE_WRITE | PAGE_EXEC;
 	return MMU_OK;
     }
 
     /* We need to resort to the MMU */
-    return get_mmu_address(env, physical, prot, address, rw, access_type);
+    return get_mmu_address(cpu, physical, prot, address, rw, access_type);
 }
 
 int cpu_sh4_handle_mmu_fault(CPUSH4State * env, target_ulong address, int rw,
@@ -450,9 +452,8 @@ int cpu_sh4_handle_mmu_fault(CPUSH4State * env, target_ulong address, int rw,
     int prot, ret, access_type;
 
     access_type = ACCESS_INT;
-    ret =
-	get_physical_address(env, &physical, &prot, address, rw,
-			     access_type);
+    ret = get_physical_address(sh_env_get_cpu(env), &physical, &prot, address,
+                               rw, access_type);
 
     if (ret != MMU_OK) {
 	env->tea = address;
@@ -509,7 +510,7 @@ target_phys_addr_t cpu_get_phys_page_debug(CPUSH4State * env, target_ulong addr)
     target_ulong physical;
     int prot;
 
-    get_physical_address(env, &physical, &prot, addr, 0, 0);
+    get_physical_address(sh_env_get_cpu(env), &physical, &prot, addr, 0, 0);
     return physical;
 }
 
Signature · 1 line
1.7.7
#146 lore raw

PATCH 9/12 target-sh4: Make copy_utlb_entry_itlb() take SuperHCPU

In reply to Andreas Färber
---
 target-sh4/helper.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)
target-sh4/helper.c +7 -7
index d273097..ffe79ec 100644
@@ -286,18 +286,18 @@ static void increment_urc(SuperHCPU *cpu)
 /* Copy and utlb entry into itlb
    Return entry
 */
-static int copy_utlb_entry_itlb(CPUSH4State *env, int utlb)
+static int copy_utlb_entry_itlb(SuperHCPU *cpu, int utlb)
 {
     int itlb;
 
     tlb_t * ientry;
-    itlb = itlb_replacement(env);
-    ientry = &env->itlb[itlb];
+    itlb = itlb_replacement(&cpu->env);
+    ientry = &cpu->env.itlb[itlb];
     if (ientry->v) {
-        tlb_flush_page(env, ientry->vpn << 10);
+        tlb_flush_page(&cpu->env, ientry->vpn << 10);
     }
-    *ientry = env->utlb[utlb];
-    update_itlb_use(env, itlb);
+    *ientry = cpu->env.utlb[utlb];
+    update_itlb_use(&cpu->env, itlb);
     return itlb;
 }
 
@@ -360,7 +360,7 @@ static int get_mmu_address(SuperHCPU *cpu, target_ulong *physical,
         } else {
             n = find_utlb_entry(cpu, address, use_asid);
             if (n >= 0) {
-                n = copy_utlb_entry_itlb(&cpu->env, n);
+                n = copy_utlb_entry_itlb(cpu, n);
                 matching = &cpu->env.itlb[n];
                 if (!(cpu->env.sr & SR_MD) && !(matching->pr & 2)) {
                     n = MMU_ITLB_VIOLATION;
Signature · 1 line
1.7.7
#147 lore raw

PATCH 10/12 target-sh4: Make update_itlb_use() take SuperHCPU

In reply to Andreas Färber
---
 target-sh4/helper.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
target-sh4/helper.c +5 -5
index ffe79ec..c5c0593 100644
@@ -202,7 +202,7 @@ void do_interrupt(CPUSH4State * env)
     }
 }
 
-static void update_itlb_use(CPUSH4State * env, int itlbnb)
+static void update_itlb_use(SuperHCPU *cpu, int itlbnb)
 {
     uint8_t or_mask = 0, and_mask = (uint8_t) - 1;
 
@@ -223,8 +223,8 @@ static void update_itlb_use(CPUSH4State * env, int itlbnb)
 	break;
     }
 
-    env->mmucr &= (and_mask << 24) | 0x00ffffff;
-    env->mmucr |= (or_mask << 24);
+    cpu->env.mmucr &= (and_mask << 24) | 0x00ffffff;
+    cpu->env.mmucr |= (or_mask << 24);
 }
 
 static int itlb_replacement(CPUSH4State * env)
@@ -297,7 +297,7 @@ static int copy_utlb_entry_itlb(SuperHCPU *cpu, int utlb)
         tlb_flush_page(&cpu->env, ientry->vpn << 10);
     }
     *ientry = cpu->env.utlb[utlb];
-    update_itlb_use(&cpu->env, itlb);
+    update_itlb_use(cpu, itlb);
     return itlb;
 }
 
@@ -315,7 +315,7 @@ static int find_itlb_entry(SuperHCPU *cpu, target_ulong address,
     } else if (e == MMU_DTLB_MISS) {
 	e = MMU_ITLB_MISS;
     } else if (e >= 0) {
-        update_itlb_use(&cpu->env, e);
+        update_itlb_use(cpu, e);
     }
     return e;
 }
Signature · 1 line
1.7.7
#148 lore raw

PATCH 11/12 target-sh4: Make itlb_replacement() use SuperHCPU

In reply to Andreas Färber
---
 target-sh4/helper.c |   18 +++++++++++-------
 1 files changed, 11 insertions(+), 7 deletions(-)
target-sh4/helper.c +11 -7
index c5c0593..c291eee 100644
@@ -227,17 +227,21 @@ static void update_itlb_use(SuperHCPU *cpu, int itlbnb)
     cpu->env.mmucr |= (or_mask << 24);
 }
 
-static int itlb_replacement(CPUSH4State * env)
+static int itlb_replacement(SuperHCPU *cpu)
 {
-    if ((env->mmucr & 0xe0000000) == 0xe0000000)
+    if ((cpu->env.mmucr & 0xe0000000) == 0xe0000000) {
 	return 0;
-    if ((env->mmucr & 0x98000000) == 0x18000000)
+    }
+    if ((cpu->env.mmucr & 0x98000000) == 0x18000000) {
 	return 1;
-    if ((env->mmucr & 0x54000000) == 0x04000000)
+    }
+    if ((cpu->env.mmucr & 0x54000000) == 0x04000000) {
 	return 2;
-    if ((env->mmucr & 0x2c000000) == 0x00000000)
+    }
+    if ((cpu->env.mmucr & 0x2c000000) == 0x00000000) {
 	return 3;
-    cpu_abort(env, "Unhandled itlb_replacement");
+    }
+    cpu_abort(&cpu->env, "Unhandled itlb_replacement");
 }
 
 /* Find the corresponding entry in the right TLB
@@ -291,7 +295,7 @@ static int copy_utlb_entry_itlb(SuperHCPU *cpu, int utlb)
     int itlb;
 
     tlb_t * ientry;
-    itlb = itlb_replacement(&cpu->env);
+    itlb = itlb_replacement(cpu);
     ientry = &cpu->env.itlb[itlb];
     if (ientry->v) {
         tlb_flush_page(&cpu->env, ientry->vpn << 10);
Signature · 1 line
1.7.7
#149 lore raw

RFC PATCH 12/12 hw/sh7750: QOM'ify SH7750 SoC

In reply to Andreas Färber

For now derive directly from Object. Move CPU-independent initialization to an initfn. Add a "cpu" link<superh-cpu> property and move CPU-dependent init code to sh7750_realize().

Update SHIX and R2D boards accordingly. Add the CPU as /cpu so that it can be set as link target, and add the SoC as /sh7750 to inspect it.

---
 hw/r2d.c    |    9 ++++++++-
 hw/sh.h     |    6 ++++--
 hw/sh7750.c |   43 +++++++++++++++++++++++++++++++++++--------
 hw/shix.c   |    8 +++++++-
 4 files changed, 54 insertions(+), 12 deletions(-)
hw/r2d.c +8 -1
index c55de01..509bc69 100644
@@ -224,6 +224,7 @@ static void r2d_init(ram_addr_t ram_size,
 	      const char *kernel_filename, const char *kernel_cmdline,
 	      const char *initrd_filename, const char *cpu_model)
 {
+    SuperHCPU *cpu;
     CPUSH4State *env;
     ResetData *reset_info;
     struct SH7750State *s;
@@ -243,6 +244,9 @@ static void r2d_init(ram_addr_t ram_size,
         fprintf(stderr, "Unable to find CPU definition\n");
         exit(1);
     }
+    cpu = sh_env_get_cpu(env);
+    object_property_add_child(object_get_root(), "cpu", OBJECT(cpu), NULL);
+
     reset_info = g_malloc0(sizeof(ResetData));
     reset_info->env = env;
     reset_info->vector = env->pc;
@@ -253,7 +257,10 @@ static void r2d_init(ram_addr_t ram_size,
     vmstate_register_ram_global(sdram);
     memory_region_add_subregion(address_space_mem, SDRAM_BASE, sdram);
     /* Register peripherals */
-    s = sh7750_init(env, address_space_mem);
+    s = SH7750(object_new(TYPE_SH7750));
+    object_property_add_child(object_get_root(), "sh7750", OBJECT(s), NULL);
+    object_property_set_link(OBJECT(s), OBJECT(cpu), "cpu", NULL);
+    sh7750_realize(s);
     irq = r2d_fpga_init(address_space_mem, 0x04000000, sh7750_irl(s));
 
     dev = qdev_create(NULL, "sh_pci");
hw/sh.h +4 -2
index 40df18c..b39881e 100644
@@ -8,10 +8,12 @@
 #define P4ADDR(x) ((x) | 0xe0000000)
 
 /* sh7750.c */
-struct SH7750State;
+#define TYPE_SH7750 "sh7750-soc"
+#define SH7750(obj) OBJECT_CHECK(SH7750State, (obj), TYPE_SH7750)
+typedef struct SH7750State SH7750State;
 struct MemoryRegion;
 
-struct SH7750State *sh7750_init(CPUSH4State * cpu, struct MemoryRegion *sysmem);
+void sh7750_realize(SH7750State *s);
 
 typedef struct {
     /* The callback will be triggered if any of the designated lines change */
hw/sh7750.c +35 -8

78 lines not on this page · raw message

hw/shix.c +7 -1
index dd9ce17..66c749a 100644
@@ -43,6 +43,7 @@ static void shix_init(ram_addr_t ram_size,
 	       const char *initrd_filename, const char *cpu_model)
 {
     int ret;
+    SuperHCPU *cpu;
     CPUSH4State *env;
     struct SH7750State *s;
     MemoryRegion *sysmem = get_system_memory();
@@ -54,6 +55,8 @@ static void shix_init(ram_addr_t ram_size,
 
     printf("Initializing CPU\n");
     env = cpu_init(cpu_model);
+    cpu = sh_env_get_cpu(env);
+    object_property_add_child(object_get_root(), "cpu", OBJECT(cpu), NULL);
 
     /* Allocate memory space */
     printf("Allocating ROM\n");
@@ -83,7 +86,10 @@ static void shix_init(ram_addr_t ram_size,
     }
 
     /* Register peripherals */
-    s = sh7750_init(env, sysmem);
+    s = SH7750(object_new(TYPE_SH7750));
+    object_property_add_child(object_get_root(), "sh7750", OBJECT(s), NULL);
+    object_property_set_link(OBJECT(s), OBJECT(cpu), "cpu", NULL);
+    sh7750_realize(s);
     /* XXXXX Check success */
     tc58128_init(s, "shix_linux_nand.bin", NULL);
     fprintf(stderr, "initialization terminated\n");
Signature · 1 line
1.7.7
#150 lore raw

Re: [Qemu-devel] [PATCH 00/12] QOM'ify SuperH CPU and SH7750 SoC

In reply to Andreas Färber
Quoted 8 lines · Andreas Färber

Based on qom-cpu v4 and object_class_get_list() v2, this series converts the SuperH CPU to QOM.

The SH7750 SoC code invited to do some cleanups, making use of the SuperHCPU, so I've QOM'ified the SoC and added the CPU as a link<SuperHCPU> for now.

I'm not so happy about the link construct, so it may need to be redone as a SysBus device with qdev properties

Shouldn't the CPU be a child of the SoC, not a link?

Quoted 3 lines

- long-term I'd like to have a
"system-on-chip" type derived from TYPE_DEVICE. Deriving it from TYPE_SYS_BUS_DEVICE might make for a better v2.

I think TYPE_SYS_BUS_DEVICE should go away in favour of everything being a TYPE_DEVICE.

What do you think a "system-on-chip" type would be needed for? I would have expected that SoCs would basically just be "containers" of devices and directly be TYPE_DEVICEs...

-- PMM

#151 lore raw

Re: [Qemu-devel] [PATCH 00/12] QOM'ify SuperH CPU and SH7750 SoC

Am 14.03.2012 17:06, schrieb Peter Maydell:

Quoted 11 lines · Andreas Färber
Quoted 8 lines

Based on qom-cpu v4 and object_class_get_list() v2, this series converts the SuperH CPU to QOM.

The SH7750 SoC code invited to do some cleanups, making use of the SuperHCPU, so I've QOM'ified the SoC and added the CPU as a link<SuperHCPU> for now.

I'm not so happy about the link construct, so it may need to be redone as a SysBus device with qdev properties

Shouldn't the CPU be a child of the SoC, not a link?

Exactly. Issue was twofold:

1) There is no object_property_set_child(), and using object_property_add_child() in the machine for the SoC seemed wrong. Setting the link target allowed to set the field in the state struct via QOM without reintroducing qdev pointer properties.

2) The SH7750 SoC is expected to have one of three user-selectable CPU cores (SH7750, SH7750R and SH7751 iirc) and this somewhat violates the layering. Making it a SysBus device with a string property to tunnel through the cpu_model is what I'm referring to below for v2.

Quoted 10 lines
Quoted 3 lines

- long-term I'd like to have a
"system-on-chip" type derived from TYPE_DEVICE. Deriving it from TYPE_SYS_BUS_DEVICE might make for a better v2.

I think TYPE_SYS_BUS_DEVICE should go away in favour of everything being a TYPE_DEVICE.

What do you think a "system-on-chip" type would be needed for? I would have expected that SoCs would basically just be "containers" of devices and directly be TYPE_DEVICEs...

I was thinking that SoCs should have a fixed relation to particular CPU core(s). -cpu exynos4210 would then select CPUs+x, we therefore need to type-check it, and only features (NEON) etc. would be tweakable via QOM. As opposed to having a fixed SoC like this one here and trying to fiddle with its internals.

In particular I have decoupling of SoC from machine in mind: for Tegra2 I have tegra2.c defining a "tegra2-soc" type and am preparing an "ac100" machine in tegra2_boards.c that trivially does an object_new(TYPE_TEGRA2) that in turn instantiates all the SoC-level SysBus devices in its initfn.

So, I think CPUs, and SoCs as CPU parent, are a special case of device.

Andreas

Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
#152 lore raw

cover QOM'ify remaining CPUs

In reply to Andreas Färber

Hello,

Based on qom-cpu v4 and object_class_get_list() v2, this series converts the remaining CPUs to QOM. Their only intersection point is Makefile.target.

TODO: Review LGPLv2.1 text differences (bug in German GNU webpage).
TODO: Check that cpu_model_str is set correctly everywhere.

target-i386:

Eduardo Habkost has already pointed out that it might be better to use QOM properties for -cpudef in target-i386, so that we use the same code paths internally as QMP users or machine compatibility code would.

Cc: Eduardo Habkost <[email protected]>
Cc: Igor Mammedov <[email protected]>
Cc: Jan Kiszka <[email protected]>
Cc: Liu Jinsong <[email protected]>
Cc: Lai Jiangshan <[email protected]>
Cc: Vasilis Liaskovitis <[email protected]> (Sorry if I forget someone.)

target-ppc:

As already discussed with Alex, I didn't manage to split out the QOM PowerPCCPU into cpu.c from translate.c #including translate_init.c within a reasonable time, so this becomes an exception in Makefile.target in the follow-up series.

The initfn/uninitfn can be simplified in v2 by putting them in powerpc_cpu_info.

Cc Alexander Graf <[email protected]>
Cc qemu-ppc <[email protected]>

target-xtensa:

Xtensa was problematic in that it used declarative definitions for XtensaConfig whose macros I did not manage to convert to an imperative class_init with reasonable effort. I therefore resorted to a really ugly memcpy(), better ideas or follow-up patches welcome!

Cc Max Filippov <[email protected]>
Cc Anthony Liguori <[email protected]>

target-mips:

Note that MIPSCPU conflicts with an in-flight FPU reset fix from Khansa and Mentor and with ASE DSP series by Jia Liu.

Cc Khansa Butt <[email protected]>
Cc Meador Inge <[email protected]>
Cc Jia Liu <[email protected]>
Cc Aurélien Jarno <[email protected]>

Most conversions were pretty straightforward. Pattern was always:
* Add a new cpu-qom.h header to entangle QOM data and cpu.h #defines
* Add a new cpu.c file implement FooCPU, FooCPUClass
* If available, move list of CPU models into FooCPUInfo cpus[] in cpu.c
* Embed CPUFooState as member of FooCPU
* Define ENV_GET_OBJECT(env) macro
* Make cpu-qom.h globally available through cpu.h (for now)
* Move cpu_foo_init() code into foo_cpu_initfn()
* Change cpu_foo_init() to use object_new() with a CPU type
=> Some parts remain that might be moved into initfn in follow-ups.
* Move cpu_foo_reset() code into foo_cpu_reset()
* Let cpu_foo_reset() just call cpu_reset()
* If implemented, change cpu_foo_list_cpu() to get, sort, print GSList of FooCPUClass => This may change the sometimes arbitrary order in user-visible -cpu ? output.
* If any, fix cpu.h vs. cpu-qom.h circular dependency issues through static inline helpers

Available at:
http://repo.or.cz/w/qemu/afaerber.git/shortlog/refs/heads/qom-cpu-others.v1

Regards,
Andreas

target-alpha:

Cc Richard Henderson <[email protected]>

target-cris:
target-microblaze:

Cc Edgar E. Iglesias <[email protected]>
Cc Peter A. G. Crosthwaite <[email protected]>
Cc John Williams <[email protected]>

target-lm32:

Cc Michael Walle <[email protected]>

target-m68k:

Cc Paul Brook <[email protected]>

target-s390x:

Cc Alexander Graf <[email protected]>
Cc Ulrich Hecht <[email protected]>

target-sparc:

Cc Blue Swirl <[email protected]>

Andreas Färber (12):
target-s390x: QOM'ify CPU
target-mips: QOM'ify CPU
target-m68k: QOM'ify CPU
target-alpha: QOM'ify CPU
target-i386: QOM'ify CPU
target-ppc: QOM'ify CPU
target-ppc: Prepare finalizer for PowerPCCPU
target-cris: QOM'ify CPU
target-lm32: QOM'ify CPU
target-microblaze: QOM'ify CPU
target-sparc: QOM'ify CPU
target-xtensa: QOM'ify CPU

 Makefile.target               |   14 +-
 gdbstub.c                     |   19 +-
 hw/xtensa_pic.c               |   51 +-
 target-alpha/cpu-qom.h        |   74 ++
 target-alpha/cpu.c            |  127 ++++
 target-alpha/cpu.h            |    1 +
 target-alpha/translate.c      |   60 +--
 target-cris/cpu-qom.h         |   73 ++
 target-cris/cpu.c             |  144 ++++
 target-cris/cpu.h             |    2 +
 target-cris/translate.c       |   93 ++--
 target-i386/cpu-qom.h         |   87 +++
 target-i386/cpu.c             | 1598 +++++++++++++++++++++++++++++++++++++++++
 target-i386/cpu.h             |    6 +-
 target-i386/cpuid.c           | 1369 -----------------------------------
 target-i386/helper.c          |  101 +---
 target-lm32/cpu-qom.h         |   77 ++
 target-lm32/cpu.c             |  188 +++++
 target-lm32/cpu.h             |    1 +
 target-lm32/helper.c          |  142 +---
 target-m68k/cpu-qom.h         |   75 ++
 target-m68k/cpu.c             |  161 +++++
 target-m68k/cpu.h             |    1 +
 target-m68k/helper.c          |  158 ++---
 target-microblaze/cpu-qom.h   |   71 ++
 target-microblaze/cpu.c       |  120 +++
 target-microblaze/cpu.h       |    2 +
 target-microblaze/translate.c |   58 +--
 target-mips/cpu-qom.h         |  110 +++
 target-mips/cpu.c             |  806 +++++++++++++++++++++
 target-mips/cpu.h             |    2 +-
 target-mips/translate.c       |  183 ++----
 target-mips/translate_init.c  |  594 ---------------
 target-ppc/cpu-qom.h          |   84 +++
 target-ppc/cpu.h              |   26 +-
 target-ppc/helper.c           |   73 +--
 target-ppc/kvm.c              |   30 +-
 target-ppc/kvm_ppc.h          |    6 -
 target-ppc/translate.c        |    2 +-
 target-ppc/translate_init.c   |  270 ++++++-
 target-s390x/cpu-qom.h        |   71 ++
 target-s390x/cpu.c            |   96 +++
 target-s390x/cpu.h            |    5 +
 target-s390x/helper.c         |   42 +-
 target-sparc/cpu-qom.h        |   95 +++
 target-sparc/cpu.c            |  949 ++++++++++++++++++++++++
 target-sparc/cpu.h            |   29 +-
 target-sparc/cpu_init.c       |  848 ----------------------
 target-sparc/int32_helper.c   |    5 +-
 target-sparc/ldst_helper.c    |   19 +-
 target-sparc/mmu_helper.c     |    4 +-
 target-sparc/translate.c      |    4 +-
 target-sparc/win_helper.c     |    3 +-
 target-xtensa/core-dc232b.c   |    5 +-
 target-xtensa/core-fsf.c      |    5 +-
 target-xtensa/cpu-qom.h       |  186 +++++
 target-xtensa/cpu.c           |   87 +++
 target-xtensa/cpu.h           |  125 +---
 target-xtensa/helper.c        |  151 +++--
 target-xtensa/op_helper.c     |  104 ++-
 target-xtensa/overlay_tool.h  |   28 +-
 target-xtensa/translate.c     |    9 +-
 62 files changed, 6059 insertions(+), 3870 deletions(-)
 create mode 100644 target-alpha/cpu-qom.h
 create mode 100644 target-alpha/cpu.c
 create mode 100644 target-cris/cpu-qom.h
 create mode 100644 target-cris/cpu.c
 create mode 100644 target-i386/cpu-qom.h
 create mode 100644 target-i386/cpu.c
 delete mode 100644 target-i386/cpuid.c
 create mode 100644 target-lm32/cpu-qom.h
 create mode 100644 target-lm32/cpu.c
 create mode 100644 target-m68k/cpu-qom.h
 create mode 100644 target-m68k/cpu.c
 create mode 100644 target-microblaze/cpu-qom.h
 create mode 100644 target-microblaze/cpu.c
 create mode 100644 target-mips/cpu-qom.h
 create mode 100644 target-mips/cpu.c
 delete mode 100644 target-mips/translate_init.c
 create mode 100644 target-ppc/cpu-qom.h
 create mode 100644 target-s390x/cpu-qom.h
 create mode 100644 target-s390x/cpu.c
 create mode 100644 target-sparc/cpu-qom.h
 create mode 100644 target-sparc/cpu.c
 delete mode 100644 target-sparc/cpu_init.c
 create mode 100644 target-xtensa/cpu-qom.h
 create mode 100644 target-xtensa/cpu.c
Signature · 1 line
1.7.7
#153 lore raw

RFC 1/12 target-s390x: QOM'ify CPU

S/390 ignored -cpu, so there's only one S390CPUClass for now. Let cpu_s390x_init() instantiate it.

Embed CPUS390XState into S390CPU. Keep s390x_{tod,cpu}_timer() in helper.c but pass the S390CPU to them. Let cpu_state_reset() call cpu_reset().

---
 Makefile.target        |    1 +
 target-s390x/cpu-qom.h |   71 +++++++++++++++++++++++++++++++++++
 target-s390x/cpu.c     |   96 ++++++++++++++++++++++++++++++++++++++++++++++++
 target-s390x/cpu.h     |    5 ++
 target-s390x/helper.c  |   42 ++++++---------------
 5 files changed, 185 insertions(+), 30 deletions(-)
 create mode 100644 target-s390x/cpu-qom.h
 create mode 100644 target-s390x/cpu.c
Makefile.target +1 -0
index c48a849..737c1e5 100644
@@ -88,6 +88,7 @@ libobj-$(TARGET_SPARC64) += vis_helper.o
 libobj-$(CONFIG_NEED_MMU) += mmu.o
 libobj-$(TARGET_ARM) += neon_helper.o iwmmxt_helper.o
 libobj-$(TARGET_ARM) += cpu.o
+libobj-$(TARGET_S390X) += cpu.o
 libobj-$(TARGET_SH4) += cpu.o
 ifeq ($(TARGET_BASE_ARCH), sparc)
 libobj-y += fop_helper.o cc_helper.o win_helper.o mmu_helper.o ldst_helper.o
target-s390x/cpu-qom.h new file +71 -0

71 lines not on this page · raw message

target-s390x/cpu.c new file +96 -0

96 lines not on this page · raw message

target-s390x/cpu.h +5 -0
index ea849fc..2f3f394 100644
@@ -288,6 +288,9 @@ int cpu_s390x_handle_mmu_fault (CPUS390XState *env, target_ulong address, int rw
 
 
 #ifndef CONFIG_USER_ONLY
+void s390x_tod_timer(void *opaque);
+void s390x_cpu_timer(void *opaque);
+
 int s390_virtio_hypercall(CPUS390XState *env, uint64_t mem, uint64_t hypercall);
 
 #ifdef CONFIG_KVM
@@ -991,4 +994,6 @@ static inline void cpu_pc_from_tb(CPUS390XState *env, TranslationBlock* tb)
     env->psw.addr = tb->pc;
 }
 
+#include "cpu-qom.h"
+
 #endif
target-s390x/helper.c +12 -30

82 lines not on this page · raw message

Signature · 1 line
1.7.7
#154 lore raw

RFC 2/12 target-mips: QOM'ify CPU

In reply to Andreas Färber

MIPS was very close to QOM in referencing a CPU definition from CPUMIPSState. Turn those structs into classes. This moves most of translate_init.c into cpu.c; move the remainder into translate.c so that we no longer #include "translate_init.c" there.

Embed CPUMIPSState into MIPSCPU. Let cpu_state_reset() call cpu_reset(). Let mips_cpu_list() enumerate available CPU classes in alphabetical order.

Cc Hervé Poussineau <[email protected]>
Cc Stefan Weil <[email protected]>
Cc Khansa Butt <[email protected]>
Cc Meador Inge <[email protected]>
Cc Jia Liu <[email protected]>
---
 Makefile.target              |    3 +
 target-mips/cpu-qom.h        |  110 ++++++
 target-mips/cpu.c            |  806 ++++++++++++++++++++++++++++++++++++++++++
 target-mips/cpu.h            |    2 +-
 target-mips/translate.c      |  183 +++-------
 target-mips/translate_init.c |  594 -------------------------------
 6 files changed, 965 insertions(+), 733 deletions(-)
 create mode 100644 target-mips/cpu-qom.h
 create mode 100644 target-mips/cpu.c
 delete mode 100644 target-mips/translate_init.c
Makefile.target +3 -0
index 737c1e5..878807b 100644
@@ -88,6 +88,9 @@ libobj-$(TARGET_SPARC64) += vis_helper.o
 libobj-$(CONFIG_NEED_MMU) += mmu.o
 libobj-$(TARGET_ARM) += neon_helper.o iwmmxt_helper.o
 libobj-$(TARGET_ARM) += cpu.o
+ifeq ($(TARGET_BASE_ARCH), mips)
+libobj-y += cpu.o
+endif
 libobj-$(TARGET_S390X) += cpu.o
 libobj-$(TARGET_SH4) += cpu.o
 ifeq ($(TARGET_BASE_ARCH), sparc)
target-mips/cpu-qom.h new file +110 -0

110 lines not on this page · raw message

target-mips/cpu.c new file +806 -0

806 lines not on this page · raw message

target-mips/cpu.h +1 -1
index 7430aa5..12e9d6f 100644
@@ -478,7 +478,6 @@ struct CPUMIPSState {
     CPUMIPSTLBContext *tlb;
 #endif
 
-    const mips_def_t *cpu_model;
     void *irq[8];
     struct QEMUTimer *timer; /* Internal timer */
 };
@@ -729,6 +728,7 @@ static inline int cpu_has_work(CPUMIPSState *env)
 }
 
 #include "exec-all.h"
+#include "cpu-qom.h"
 
 static inline void cpu_pc_from_tb(CPUMIPSState *env, TranslationBlock *tb)
 {
target-mips/translate.c +45 -138

209 lines not on this page · raw message

target-mips/translate_init.c deleted +0 -594

594 lines not on this page · raw message

Signature · 1 line
1.7.7
#155 lore raw

RFC 3/12 target-m68k: QOM'ify CPU

In reply to Andreas Färber

Embed CPUM68KState in M68kCPU. Let cpu_state_reset() call cpu_reset(). Let m68k_cpu_list() enumerate CPU classes alphabetically, except for "any".

---
 Makefile.target       |    1 +
 target-m68k/cpu-qom.h |   75 +++++++++++++++++++++++
 target-m68k/cpu.c     |  161 +++++++++++++++++++++++++++++++++++++++++++++++++
 target-m68k/cpu.h     |    1 +
 target-m68k/helper.c  |  158 ++++++++++++++++--------------------------------
 5 files changed, 289 insertions(+), 107 deletions(-)
 create mode 100644 target-m68k/cpu-qom.h
 create mode 100644 target-m68k/cpu.c
Makefile.target +1 -0
index 878807b..47854a7 100644
@@ -88,6 +88,7 @@ libobj-$(TARGET_SPARC64) += vis_helper.o
 libobj-$(CONFIG_NEED_MMU) += mmu.o
 libobj-$(TARGET_ARM) += neon_helper.o iwmmxt_helper.o
 libobj-$(TARGET_ARM) += cpu.o
+libobj-$(TARGET_M68K) += cpu.o
 ifeq ($(TARGET_BASE_ARCH), mips)
 libobj-y += cpu.o
 endif
target-m68k/cpu-qom.h new file +75 -0

75 lines not on this page · raw message

target-m68k/cpu.c new file +161 -0

161 lines not on this page · raw message

target-m68k/cpu.h +1 -0
index 6696e30..77db787 100644
@@ -245,6 +245,7 @@ static inline void cpu_clone_regs(CPUM68KState *env, target_ulong newsp)
 #endif
 
 #include "cpu-all.h"
+#include "cpu-qom.h"
 
 static inline void cpu_get_tb_cpu_state(CPUM68KState *env, target_ulong *pc,
                                         target_ulong *cs_base, int *flags)
target-m68k/helper.c +51 -107

198 lines not on this page · raw message

Signature · 1 line
1.7.7
#156 lore raw

RFC 4/12 target-alpha: QOM'ify CPU

In reply to Andreas Färber

Embed CPUAlphaState in AlphaCPU.

---
 Makefile.target          |    1 +
 target-alpha/cpu-qom.h   |   74 +++++++++++++++++++++++++++
 target-alpha/cpu.c       |  127 ++++++++++++++++++++++++++++++++++++++++++++++
 target-alpha/cpu.h       |    1 +
 target-alpha/translate.c |   60 +++-------------------
 5 files changed, 211 insertions(+), 52 deletions(-)
 create mode 100644 target-alpha/cpu-qom.h
 create mode 100644 target-alpha/cpu.c
Makefile.target +1 -0
index 47854a7..74604fd 100644
@@ -87,6 +87,7 @@ endif
 libobj-$(TARGET_SPARC64) += vis_helper.o
 libobj-$(CONFIG_NEED_MMU) += mmu.o
 libobj-$(TARGET_ARM) += neon_helper.o iwmmxt_helper.o
+libobj-$(TARGET_ALPHA) += cpu.o
 libobj-$(TARGET_ARM) += cpu.o
 libobj-$(TARGET_M68K) += cpu.o
 ifeq ($(TARGET_BASE_ARCH), mips)
target-alpha/cpu-qom.h new file +74 -0

74 lines not on this page · raw message

target-alpha/cpu.c new file +127 -0

127 lines not on this page · raw message

target-alpha/cpu.h +1 -0
index 48c0fdc..4126b3d 100644
@@ -293,6 +293,7 @@ struct CPUAlphaState {
 #define cpu_signal_handler cpu_alpha_signal_handler
 
 #include "cpu-all.h"
+#include "cpu-qom.h"
 
 enum {
     FEATURE_ASN    = 0x00000001,
target-alpha/translate.c +8 -52

71 lines not on this page · raw message

Signature · 1 line
1.7.7
Acked-by on v1 4/12
#157 lore raw

Re: [Qemu-devel] [RFC 04/12] target-alpha: QOM'ify CPU

Quoted 12 lines · Andreas Färber

Embed CPUAlphaState in AlphaCPU.

---
 Makefile.target          |    1 +
 target-alpha/cpu-qom.h   |   74 +++++++++++++++++++++++++++
 target-alpha/cpu.c       |  127 ++++++++++++++++++++++++++++++++++++++++++++++
 target-alpha/cpu.h       |    1 +
 target-alpha/translate.c |   60 +++-------------------
 5 files changed, 211 insertions(+), 52 deletions(-)
 create mode 100644 target-alpha/cpu-qom.h
 create mode 100644 target-alpha/cpu.c

Looks plausible. I admit to not having followed QOM at all...

r~

#158 lore raw

RFC 5/12 target-i386: QOM'ify CPU

In reply to Andreas Färber
---
 Makefile.target       |    2 +-
 target-i386/cpu-qom.h |   87 +++
 target-i386/cpu.c     | 1598 +++++++++++++++++++++++++++++++++++++++++++++++++
 target-i386/cpu.h     |    6 +-
 target-i386/cpuid.c   | 1369 ------------------------------------------
 target-i386/helper.c  |  101 +---
 6 files changed, 1697 insertions(+), 1466 deletions(-)
 create mode 100644 target-i386/cpu-qom.h
 create mode 100644 target-i386/cpu.c
 delete mode 100644 target-i386/cpuid.c
Makefile.target +1 -1
index 74604fd..c655091 100644
@@ -82,7 +82,7 @@ libobj-$(CONFIG_TCG_INTERPRETER) += tci.o
 libobj-y += fpu/softfloat.o
 libobj-y += op_helper.o helper.o
 ifeq ($(TARGET_BASE_ARCH), i386)
-libobj-y += cpuid.o
+libobj-y += cpu.o
 endif
 libobj-$(TARGET_SPARC64) += vis_helper.o
 libobj-$(CONFIG_NEED_MMU) += mmu.o
target-i386/cpu-qom.h new file +87 -0

87 lines not on this page · raw message

target-i386/cpu.c new file +1598 -0

1,598 lines not on this page · raw message

target-i386/cpu.h +4 -2
index a1ed3e7..c43d45f 100644
@@ -783,6 +783,8 @@ typedef struct CPUX86State {
     TPRAccess tpr_access_type;
 } CPUX86State;
 
+#include "cpu-qom.h"
+
 CPUX86State *cpu_x86_init(const char *cpu_model);
 int cpu_x86_exec(CPUX86State *s);
 void cpu_x86_close(CPUX86State *s);
@@ -896,11 +898,11 @@ void cpu_x86_frstor(CPUX86State *s, target_ulong ptr, int data32);
 int cpu_x86_signal_handler(int host_signum, void *pinfo,
                            void *puc);
 
-/* cpuid.c */
+/* cpu.c */
+X86CPU *cpu_x86_find_by_name(const char *cpu_model);
 void cpu_x86_cpuid(CPUX86State *env, uint32_t index, uint32_t count,
                    uint32_t *eax, uint32_t *ebx,
                    uint32_t *ecx, uint32_t *edx);
-int cpu_x86_register (CPUX86State *env, const char *cpu_model);
 void cpu_clear_apic_feature(CPUX86State *env);
 void host_cpuid(uint32_t function, uint32_t count,
                 uint32_t *eax, uint32_t *ebx, uint32_t *ecx, uint32_t *edx);
target-i386/cpuid.c deleted +0 -1369

1,286 lines not on this page · raw message

target-i386/helper.c +7 -94

101 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
1.7.7

Part of the diff is not shown here. View the raw message.

#159 lore raw

Re: [Qemu-devel] [RFC 05/12] target-i386: QOM'ify CPU

On Wed, Mar 14, 2012 at 06:53:29PM +0100, Andreas Färber wrote:
[...]

Quoted 29 lines
target-i386/cpu-qom.h new file +29 -0
+/**
+ * X86CPUClass:
+ * @parent_reset: The parent class' reset handler.
+ *
+ * An x86 CPU model or family.
+ */
+typedef struct X86CPUClass {
+    /*< private >*/
+    CPUClass parent_class;
+    /*< public >*/
+
+    void (*parent_reset)(CPUState *cpu);
+
+    uint32_t level;
+    uint32_t vendor1, vendor2, vendor3;
+    int family;
+    int model;
+    int stepping;
+    int tsc_khz;
+    uint32_t features, ext_features, ext2_features, ext3_features;
+    uint32_t kvm_features, svm_features;
+    uint32_t xlevel;
+    char model_id[48];
+    int vendor_override;
+    uint32_t flags;
+    /* Store the results of Centaur's CPUID instructions */
+    uint32_t ext4_features;
+    uint32_t xlevel2;
+} X86CPUClass;

[...]

Quoted 8 lines
target-i386/cpu.c new file +8 -0
+typedef struct X86CPUInfo {
+    const char *name;
+    uint32_t level;
+    uint32_t vendor1, vendor2, vendor3;
+    int family;
+    int model;
+    int stepping;
+    int tsc_khz;

target-i386/cpu.c line 238

Quoted 10 lines
target-i386/cpu.c new file +10 -0
+    uint32_t features, ext_features, ext2_features, ext3_features;
+    uint32_t kvm_features, svm_features;
+    uint32_t xlevel;
+    char model_id[48];
+    int vendor_override;
+    uint32_t flags;
+    /* Store the results of Centaur's CPUID instructions */
+    uint32_t ext4_features;
+    uint32_t xlevel2;
+} X86CPUInfo;

Have you considered eliminating this duplication and using a common struct for both cases? (either by using X86CPUClass for everything, or by embedding a common struct inside X86CPUClass)

This would simplify (or even make unnecessary) the field-by-field copy on x86_cpu_class_init().

[...]

Quoted 26 lines
target-i386/cpu.c new file +26 -0
+static void x86_cpu_class_init(ObjectClass *klass, void *data)
+{
+    X86CPUClass *k = X86_CPU_CLASS(klass);
+    const X86CPUInfo *info = data;
+
+    k->level = info->level;
+    k->vendor1 = info->vendor1;
+    k->vendor2 = info->vendor2;
+    k->vendor3 = info->vendor3;
+    k->family = info->family;
+    k->model = info->model;
+    k->stepping = info->stepping;
+    k->tsc_khz = info->tsc_khz;
+    k->features = info->features;
+    k->ext_features = info->ext_features;
+    k->ext2_features = info->ext2_features;
+    k->ext3_features = info->ext3_features;
+    k->kvm_features = info->kvm_features;
+    k->svm_features = info->svm_features;
+    k->xlevel = info->xlevel;
+    memcpy(k->model_id, info->model_id, 48);
+    k->vendor_override = info->vendor_override;
+    k->flags = info->flags;
+    k->ext4_features = info->ext4_features;
+    k->xlevel2 = info->xlevel2;
+}
Signature · 1 line
Eduardo
#160 lore raw

RFC 6/12 target-ppc: QOM'ify CPU

In reply to Andreas Färber
---
 target-ppc/cpu-qom.h        |   84 ++++++++++++++
 target-ppc/cpu.h            |   25 +----
 target-ppc/helper.c         |   72 ++----------
 target-ppc/kvm.c            |   29 +++--
 target-ppc/kvm_ppc.h        |    6 -
 target-ppc/translate.c      |    2 +-
 target-ppc/translate_init.c |  264 ++++++++++++++++++++++++++++++++++++-------
 7 files changed, 342 insertions(+), 140 deletions(-)
 create mode 100644 target-ppc/cpu-qom.h
target-ppc/cpu-qom.h new file +84 -0
new file mode 100644
index 0000000..9236dcc
@@ -0,0 +1,84 @@
+/*
+ * QEMU PowerPC CPU
+ *
+ * Copyright (c) 2012 SUSE LINUX Products GmbH
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see
+ * <http://www.gnu.org/licenses/lgpl-2.1.html>
+ */
+#ifndef QEMU_PPC_CPU_QOM_H
+#define QEMU_PPC_CPU_QOM_H
+
+#include "qemu/cpu.h"
+#include "cpu.h"
+
+#define TYPE_POWERPC_CPU "powerpc-cpu"
+
+#define POWERPC_CPU_CLASS(klass) \
+    OBJECT_CLASS_CHECK(PowerPCCPUClass, (klass), TYPE_POWERPC_CPU)
+#define POWERPC_CPU(obj) \
+    OBJECT_CHECK(PowerPCCPU, (obj), TYPE_POWERPC_CPU)
+#define POWERPC_CPU_GET_CLASS(obj) \
+    OBJECT_GET_CLASS(PowerPCCPUClass, (obj), TYPE_POWERPC_CPU)
+
+/**
+ * PowerPCCPUClass:
+ * @parent_reset: The parent class' reset handler.
+ *
+ * A PowerPC CPU model.
+ */
+typedef struct PowerPCCPUClass {
+    /*< private >*/
+    CPUClass parent_class;
+    /*< public >*/
+
+    void (*parent_reset)(CPUState *cpu);
+
+    uint32_t pvr;
+    uint32_t svr;
+    uint64_t insns_flags;
+    uint64_t insns_flags2;
+    uint64_t msr_mask;
+    powerpc_mmu_t   mmu_model;
+    powerpc_excp_t  excp_model;
+    powerpc_input_t bus_model;
+    uint32_t flags;
+    int bfd_mach;
+    void (*init_proc)(CPUPPCState *env);
+    int  (*check_pow)(CPUPPCState *env);
+} PowerPCCPUClass;
+
+/**
+ * PowerPCCPU:
+ * @env: Legacy CPU state.
+ *
+ * A PowerPC CPU.
+ */
+typedef struct PowerPCCPU {
+    /*< private >*/
+    CPUState parent_obj;
+    /*< public >*/
+
+    CPUPPCState env;
+} PowerPCCPU;
+
+static inline PowerPCCPU *ppc_env_get_cpu(CPUPPCState *env)
+{
+    return POWERPC_CPU(container_of(env, PowerPCCPU, env));
+}
+
+#define ENV_GET_CPU(e) CPU(ppc_env_get_cpu(e))
+
+
+#endif
target-ppc/cpu.h +5 -20
index ad09cbe..ff28843 100644
@@ -305,7 +305,6 @@ enum powerpc_input_t {
 #define PPC_INPUT(env) (env->bus_model)
 
 /*****************************************************************************/
-typedef struct ppc_def_t ppc_def_t;
 typedef struct opc_handler_t opc_handler_t;
 
 /*****************************************************************************/
@@ -877,22 +876,6 @@ enum {
 /* The whole PowerPC CPU context */
 #define NB_MMU_MODES 3
 
-struct ppc_def_t {
-    const char *name;
-    uint32_t pvr;
-    uint32_t svr;
-    uint64_t insns_flags;
-    uint64_t insns_flags2;
-    uint64_t msr_mask;
-    powerpc_mmu_t   mmu_model;
-    powerpc_excp_t  excp_model;
-    powerpc_input_t bus_model;
-    uint32_t flags;
-    int bfd_mach;
-    void (*init_proc)(CPUPPCState *env);
-    int  (*check_pow)(CPUPPCState *env);
-};
-
 struct CPUPPCState {
     /* First are the most commonly used resources
      * during translated code execution
@@ -1096,6 +1079,8 @@ struct mmu_ctx_t {
 };
 #endif
 
+#include "cpu-qom.h"
+
 /*****************************************************************************/
 CPUPPCState *cpu_ppc_init (const char *cpu_model);
 void ppc_translate_init(void);
@@ -1142,9 +1127,9 @@ void ppc_store_msr (CPUPPCState *env, target_ulong value);
 
 void ppc_cpu_list (FILE *f, fprintf_function cpu_fprintf);
 
-const ppc_def_t *ppc_find_by_pvr(uint32_t pvr);
-const ppc_def_t *cpu_ppc_find_by_name (const char *name);
-int cpu_ppc_register_internal (CPUPPCState *env, const ppc_def_t *def);
+void ppc_cpu_initfn(Object *obj);
+const char *ppc_find_by_pvr(uint32_t pvr);
+PowerPCCPU *cpu_ppc_find_by_name(const char *name);
 
 /* Time-base and decrementer management */
 #ifndef NO_CPU_IO_DEFS
target-ppc/helper.c +9 -63

94 lines not on this page · raw message

target-ppc/kvm.c +18 -11
index aeb3de9..2ee5bc0 100644
@@ -902,19 +902,12 @@ static void alter_insns(uint64_t *word, uint64_t flags, bool on)
     }
 }
 
-const ppc_def_t *kvmppc_host_cpu_def(void)
+static void kvmppc_host_cpu_class_init(ObjectClass *klass, void *data)
 {
-    uint32_t host_pvr = mfpvr();
-    const ppc_def_t *base_spec;
-    ppc_def_t *spec;
+    PowerPCCPUClass *spec = POWERPC_CPU_CLASS(klass);
     uint32_t vmx = kvmppc_get_vmx();
     uint32_t dfp = kvmppc_get_dfp();
 
-    base_spec = ppc_find_by_pvr(host_pvr);
-
-    spec = g_malloc0(sizeof(*spec));
-    memcpy(spec, base_spec, sizeof(*spec));
-
     /* Now fix up the spec with information we can query from the host */
 
     if (vmx != -1) {
@@ -926,8 +919,6 @@ const ppc_def_t *kvmppc_host_cpu_def(void)
         /* Only override when we know what the host supports */
         alter_insns(&spec->insns_flags2, PPC2_DFP, dfp);
     }
-
-    return spec;
 }
 
 bool kvm_arch_stop_on_emulation_error(CPUPPCState *env)
@@ -944,3 +935,19 @@ int kvm_arch_on_sigbus(int code, void *addr)
 {
     return 1;
 }
+
+static void kvmppc_register_types(void)
+{
+    TypeInfo type = {
+        .name = "host",
+        .instance_size = sizeof(PowerPCCPU),
+        .instance_init = ppc_cpu_initfn,
+        .class_size = sizeof(PowerPCCPUClass),
+        .class_init = kvmppc_host_cpu_class_init,
+    };
+    uint32_t host_pvr = mfpvr();
+    type.parent = ppc_find_by_pvr(host_pvr);
+    type_register_static(&type);
+}
+
+type_init(kvmppc_register_types)
target-ppc/kvm_ppc.h +0 -6
index 8f1267c..ce5be6e 100644
@@ -28,7 +28,6 @@ off_t kvmppc_alloc_rma(const char *name, MemoryRegion *sysmem);
 void *kvmppc_create_spapr_tce(uint32_t liobn, uint32_t window_size, int *pfd);
 int kvmppc_remove_spapr_tce(void *table, int pfd, uint32_t window_size);
 #endif /* !CONFIG_USER_ONLY */
-const ppc_def_t *kvmppc_host_cpu_def(void);
 
 #else
 
@@ -90,11 +89,6 @@ static inline int kvmppc_remove_spapr_tce(void *table, int pfd,
 }
 #endif /* !CONFIG_USER_ONLY */
 
-static inline const ppc_def_t *kvmppc_host_cpu_def(void)
-{
-    return NULL;
-}
-
 #endif
 
 #ifndef CONFIG_KVM
target-ppc/translate.c +1 -1
index 3ec59a7..e43160d 100644
@@ -9272,8 +9272,8 @@ GEN_SPEOP_LDST(evstwwe, 0x1C, 2),
 GEN_SPEOP_LDST(evstwwo, 0x1E, 2),
 };
 
-#include "translate_init.c"
 #include "helper_regs.h"
+#include "translate_init.c"
 
 /*****************************************************************************/
 /* Misc PowerPC helpers */
target-ppc/translate_init.c +225 -39

359 lines not on this page · raw message

Signature · 1 line
1.7.7
#161 lore raw

RFC 7/12 target-ppc: Prepare finalizer for PowerPCCPU

In reply to Andreas Färber
---
 target-ppc/cpu.h            |    1 +
 target-ppc/helper.c         |    1 -
 target-ppc/kvm.c            |    1 +
 target-ppc/translate_init.c |    6 ++++++
 4 files changed, 8 insertions(+), 1 deletions(-)
target-ppc/cpu.h +1 -0
index ff28843..3ff2156 100644
@@ -1128,6 +1128,7 @@ void ppc_store_msr (CPUPPCState *env, target_ulong value);
 void ppc_cpu_list (FILE *f, fprintf_function cpu_fprintf);
 
 void ppc_cpu_initfn(Object *obj);
+void ppc_cpu_finalize(Object *obj);
 const char *ppc_find_by_pvr(uint32_t pvr);
 PowerPCCPU *cpu_ppc_find_by_name(const char *name);
 
target-ppc/helper.c +0 -1
index 7d26cb5..1467cf7 100644
@@ -3163,6 +3163,5 @@ CPUPPCState *cpu_ppc_init(const char *cpu_model)
 
 void cpu_ppc_close(CPUPPCState *env)
 {
-    /* Should also remove all opcode tables... */
     object_delete(OBJECT(ppc_env_get_cpu(env)));
 }
target-ppc/kvm.c +1 -0
index 2ee5bc0..8be235b 100644
@@ -942,6 +942,7 @@ static void kvmppc_register_types(void)
         .name = "host",
         .instance_size = sizeof(PowerPCCPU),
         .instance_init = ppc_cpu_initfn,
+        .instance_finalize = ppc_cpu_finalize,
         .class_size = sizeof(PowerPCCPUClass),
         .class_init = kvmppc_host_cpu_class_init,
     };
target-ppc/translate_init.c +6 -0
index 52264c8..c167595 100644
@@ -10212,6 +10212,11 @@ static void ppc_cpu_reset(CPUState *c)
     tlb_flush(env, 1);
 }
 
+void ppc_cpu_finalize(Object *obj)
+{
+    /* Should remove all opcode tables... */
+}
+
 static bool ppc_cpu_usable(const PowerPCCPUInfo *def)
 {
 #if defined(TARGET_PPCEMB)
@@ -10336,6 +10341,7 @@ static void ppc_register_cpu(const PowerPCCPUInfo *info)
         .parent = TYPE_POWERPC_CPU,
         .instance_size = sizeof(PowerPCCPU),
         .instance_init = ppc_cpu_initfn,
+        .instance_finalize = ppc_cpu_finalize,
         .class_size = sizeof(PowerPCCPUClass),
         .class_init = ppc_cpu_class_init,
         .class_data = (void *)info,
Signature · 1 line
1.7.7
#162 lore raw

RFC 8/12 target-cris: QOM'ify CPU

In reply to Andreas Färber

Let cris_cpu_list() enumerate CPU classes sorted by version.

---
 Makefile.target         |    1 +
 target-cris/cpu-qom.h   |   73 ++++++++++++++++++++++++
 target-cris/cpu.c       |  144 +++++++++++++++++++++++++++++++++++++++++++++++
 target-cris/cpu.h       |    2 +
 target-cris/translate.c |   93 ++++++++++++++----------------
 5 files changed, 264 insertions(+), 49 deletions(-)
 create mode 100644 target-cris/cpu-qom.h
 create mode 100644 target-cris/cpu.c
Makefile.target +1 -0
index c655091..3b7a4da 100644
@@ -89,6 +89,7 @@ libobj-$(CONFIG_NEED_MMU) += mmu.o
 libobj-$(TARGET_ARM) += neon_helper.o iwmmxt_helper.o
 libobj-$(TARGET_ALPHA) += cpu.o
 libobj-$(TARGET_ARM) += cpu.o
+libobj-$(TARGET_CRIS) += cpu.o
 libobj-$(TARGET_M68K) += cpu.o
 ifeq ($(TARGET_BASE_ARCH), mips)
 libobj-y += cpu.o
target-cris/cpu-qom.h new file +73 -0

73 lines not on this page · raw message

target-cris/cpu.c new file +144 -0

144 lines not on this page · raw message

target-cris/cpu.h +2 -0
index 31899c2..5449cc4 100644
@@ -169,6 +169,8 @@ typedef struct CPUCRISState {
 	void *load_info;
 } CPUCRISState;
 
+#include "cpu-qom.h"
+
 CPUCRISState *cpu_cris_init(const char *cpu_model);
 int cpu_cris_exec(CPUCRISState *s);
 void cpu_cris_close(CPUCRISState *s);
target-cris/translate.c +44 -49

119 lines not on this page · raw message

Signature · 1 line
1.7.7
#163 lore raw

RFC 9/12 target-lm32: QOM'ify CPU

In reply to Andreas Färber

Let cpu_lm32_list() enumerate CPU classes sorted alphabetically.

---
 Makefile.target       |    1 +
 target-lm32/cpu-qom.h |   77 ++++++++++++++++++++
 target-lm32/cpu.c     |  188 +++++++++++++++++++++++++++++++++++++++++++++++++
 target-lm32/cpu.h     |    1 +
 target-lm32/helper.c  |  142 ++++++++-----------------------------
 5 files changed, 297 insertions(+), 112 deletions(-)
 create mode 100644 target-lm32/cpu-qom.h
 create mode 100644 target-lm32/cpu.c
Makefile.target +1 -0
index 3b7a4da..8c8f4a8 100644
@@ -90,6 +90,7 @@ libobj-$(TARGET_ARM) += neon_helper.o iwmmxt_helper.o
 libobj-$(TARGET_ALPHA) += cpu.o
 libobj-$(TARGET_ARM) += cpu.o
 libobj-$(TARGET_CRIS) += cpu.o
+libobj-$(TARGET_LM32) += cpu.o
 libobj-$(TARGET_M68K) += cpu.o
 ifeq ($(TARGET_BASE_ARCH), mips)
 libobj-y += cpu.o
target-lm32/cpu-qom.h new file +77 -0

77 lines not on this page · raw message

target-lm32/cpu.c new file +188 -0

188 lines not on this page · raw message

target-lm32/cpu.h +1 -0
index 0902a24..c1be305 100644
@@ -184,6 +184,7 @@ typedef struct CPULM32State {
 
 } CPULM32State;
 
+#include "cpu-qom.h"
 
 CPULM32State *cpu_lm32_init(const char *cpu_model);
 void cpu_lm32_list(FILE *f, fprintf_function cpu_fprintf);
target-lm32/helper.c +30 -112

169 lines not on this page · raw message

Signature · 1 line
1.7.7
Acked-by on v1 9/12
#164 lore raw

Re: [Qemu-devel] [RFC 09/12] target-lm32: QOM'ify CPU

Am Mittwoch 14 März 2012, 18:53:33 schrieb Andreas Färber:

Quoted 91 lines

Let cpu_lm32_list() enumerate CPU classes sorted alphabetically.

---
 Makefile.target       |    1 +
 target-lm32/cpu-qom.h |   77 ++++++++++++++++++++
 target-lm32/cpu.c     |  188
+++++++++++++++++++++++++++++++++++++++++++++++++ target-lm32/cpu.h     | 
  1 +
 target-lm32/helper.c  |  142 ++++++++-----------------------------
 5 files changed, 297 insertions(+), 112 deletions(-)
 create mode 100644 target-lm32/cpu-qom.h
 create mode 100644 target-lm32/cpu.c
Makefile.target +1 -0
index 3b7a4da..8c8f4a8 100644
@@ -90,6 +90,7 @@ libobj-$(TARGET_ARM) += neon_helper.o iwmmxt_helper.o
 libobj-$(TARGET_ALPHA) += cpu.o
 libobj-$(TARGET_ARM) += cpu.o
 libobj-$(TARGET_CRIS) += cpu.o
+libobj-$(TARGET_LM32) += cpu.o
 libobj-$(TARGET_M68K) += cpu.o
 ifeq ($(TARGET_BASE_ARCH), mips)
 libobj-y += cpu.o
target-lm32/cpu-qom.h new file +59 -0
new file mode 100644
index 0000000..dc3d434
@@ -0,0 +1,77 @@
+/*
+ * QEMU LatticeMico32 CPU
+ *
+ * Copyright (c) 2012 SUSE LINUX Products GmbH
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see
+ * <http://www.gnu.org/licenses/lgpl-2.1.html>
+ */
+#ifndef QEMU_LM32_CPU_QOM_H
+#define QEMU_LM32_CPU_QOM_H
+
+#include "qemu/cpu.h"
+#include "cpu.h"
+
+#define TYPE_LM32_CPU "lm32-cpu"
+
+#define LM32_CPU_CLASS(klass) \
+    OBJECT_CLASS_CHECK(LM32CPUClass, (klass), TYPE_LM32_CPU)
+#define LM32_CPU(obj) \
+    OBJECT_CHECK(LM32CPU, (obj), TYPE_LM32_CPU)
+#define LM32_CPU_GET_CLASS(obj) \
+    OBJECT_GET_CLASS(LM32CPUClass, (obj), TYPE_LM32_CPU)
+
+/**
+ * LM32CPUClass:
+ * @parent_reset: The parent class' reset handler.
+ *
+ * A LatticeMico32 CPU model.
+ */
+typedef struct LM32CPUClass {
+    /*< private >*/
+    CPUClass parent_class;
+    /*< public >*/
+
+    void (*parent_reset)(CPUState *cpu);
+
+    uint32_t revision;
+    uint8_t num_interrupts;
+    uint8_t num_breakpoints;
+    uint8_t num_watchpoints;
+    uint32_t features;
+} LM32CPUClass;
+
+/**
+ * LM32CPU:
+ * @env: Legacy CPU state.
+ *
+ * A LatticeMico32 CPU.

target-lm32/cpu-qom.h line 69

Quoted 10 lines
target-lm32/cpu-qom.h new file +10 -0
+ */
+typedef struct LM32CPU {
+    /*< private >*/
+    CPUState parent_obj;
+    /*< public >*/
+
+    CPULM32State env;
+} LM32CPU;
+
+static inline LM32CPU *cris_env_get_cpu(CPULM32State *env)

cris? :)

target-lm32/cpu-qom.h line 74

Quoted 5 lines
target-lm32/cpu-qom.h new file +5 -0
+{
+    return LM32_CPU(container_of(env, LM32CPU, env));
+}
+
+#define ENV_GET_CPU(e) CPU(cris_env_get_cpu(e))

ditto

Apart from that:

Quoted 383 lines
target-lm32/cpu-qom.h new file +3 -0
+
+
+#endif
target-lm32/cpu.c new file +188 -0
new file mode 100644
index 0000000..7f5308a
@@ -0,0 +1,188 @@
+/*
+ * QEMU LatticeMico32 CPU
+ *
+ * Copyright (c) 2010 Michael Walle <[email protected]>
+ * Copyright (c) 2012 SUSE LINUX Products GmbH
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, see
+ * <http://www.gnu.org/licenses/lgpl-2.1.html>
+ */
+
+#include "cpu-qom.h"
+#include "qemu-common.h"
+
+static void lm32_cpu_reset(CPUState *c)
+{
+}
+
+/* CPU models */
+
+typedef struct LM32CPUInfo {
+    const char *name;
+    uint32_t revision;
+    uint8_t num_interrupts;
+    uint8_t num_breakpoints;
+    uint8_t num_watchpoints;
+    uint32_t features;
+} LM32CPUInfo;
+
+static const LM32CPUInfo lm32_cpus[] = {
+    {
+        .name = "lm32-basic",
+        .revision = 3,
+        .num_interrupts = 32,
+        .num_breakpoints = 4,
+        .num_watchpoints = 4,
+        .features = (LM32_FEATURE_SHIFT
+                     | LM32_FEATURE_SIGN_EXTEND
+                     | LM32_FEATURE_CYCLE_COUNT),
+    },
+    {
+        .name = "lm32-standard",
+        .revision = 3,
+        .num_interrupts = 32,
+        .num_breakpoints = 4,
+        .num_watchpoints = 4,
+        .features = (LM32_FEATURE_MULTIPLY
+                     | LM32_FEATURE_DIVIDE
+                     | LM32_FEATURE_SHIFT
+                     | LM32_FEATURE_SIGN_EXTEND
+                     | LM32_FEATURE_I_CACHE
+                     | LM32_FEATURE_CYCLE_COUNT),
+    },
+    {
+        .name = "lm32-full",
+        .revision = 3,
+        .num_interrupts = 32,
+        .num_breakpoints = 4,
+        .num_watchpoints = 4,
+        .features = (LM32_FEATURE_MULTIPLY
+                     | LM32_FEATURE_DIVIDE
+                     | LM32_FEATURE_SHIFT
+                     | LM32_FEATURE_SIGN_EXTEND
+                     | LM32_FEATURE_I_CACHE
+                     | LM32_FEATURE_D_CACHE
+                     | LM32_FEATURE_CYCLE_COUNT),
+    }
+};
+
+static uint32_t cfg_by_class(LM32CPUClass *def)
+{
+    uint32_t cfg = 0;
+
+    if (def->features & LM32_FEATURE_MULTIPLY) {
+        cfg |= CFG_M;
+    }
+
+    if (def->features & LM32_FEATURE_DIVIDE) {
+        cfg |= CFG_D;
+    }
+
+    if (def->features & LM32_FEATURE_SHIFT) {
+        cfg |= CFG_S;
+    }
+
+    if (def->features & LM32_FEATURE_SIGN_EXTEND) {
+        cfg |= CFG_X;
+    }
+
+    if (def->features & LM32_FEATURE_I_CACHE) {
+        cfg |= CFG_IC;
+    }
+
+    if (def->features & LM32_FEATURE_D_CACHE) {
+        cfg |= CFG_DC;
+    }
+
+    if (def->features & LM32_FEATURE_CYCLE_COUNT) {
+        cfg |= CFG_CC;
+    }
+
+    cfg |= (def->num_interrupts << CFG_INT_SHIFT);
+    cfg |= (def->num_breakpoints << CFG_BP_SHIFT);
+    cfg |= (def->num_watchpoints << CFG_WP_SHIFT);
+    cfg |= (def->revision << CFG_REV_SHIFT);
+
+    return cfg;
+}
+
+static void lm32_cpu_initfn(Object *obj)
+{
+    LM32CPU *cpu = LM32_CPU(obj);
+    LM32CPUClass *klass = LM32_CPU_GET_CLASS(cpu);
+    CPULM32State *env = &cpu->env;
+
+    memset(env, 0, sizeof(*env));
+    cpu_exec_init(env);
+    env->cpu_model_str = object_get_typename(obj);
+
+    env->features = klass->features;
+    env->num_bps = klass->num_breakpoints;
+    env->num_wps = klass->num_watchpoints;
+    env->cfg = cfg_by_class(klass);
+    env->flags = 0;
+
+    cpu_reset(CPU(cpu));
+}
+
+static void lm32_cpu_class_init(ObjectClass *klass, void *data)
+{
+    CPUClass *cpu_class = CPU_CLASS(klass);
+    LM32CPUClass *k = LM32_CPU_CLASS(klass);
+    const LM32CPUInfo *info = data;
+
+    k->parent_reset = cpu_class->reset;
+    cpu_class->reset = lm32_cpu_reset;
+
+    k->revision = info->revision;
+    k->num_interrupts = info->num_interrupts;
+    k->num_breakpoints = info->num_breakpoints;
+    k->num_watchpoints = info->num_watchpoints;
+    k->features = info->features;
+}
+
+static void cpu_register(const LM32CPUInfo *info)
+{
+    TypeInfo type = {
+        .name = info->name,
+        .parent = TYPE_LM32_CPU,
+        .instance_size = sizeof(LM32CPU),
+        .instance_init = lm32_cpu_initfn,
+        .class_size = sizeof(LM32CPUClass),
+        .class_init = lm32_cpu_class_init,
+        .class_data = (void *)info,
+    };
+
+    type_register_static(&type);
+}
+
+static const TypeInfo lm32_cpu_type_info = {
+    .name = TYPE_LM32_CPU,
+    .parent = TYPE_CPU,
+    .instance_size = sizeof(LM32CPU),
+    .abstract = true,
+    .class_size = sizeof(LM32CPUClass),
+};
+
+static void lm32_cpu_register_types(void)
+{
+    int i;
+
+    type_register_static(&lm32_cpu_type_info);
+    for (i = 0; i < ARRAY_SIZE(lm32_cpus); i++) {
+        cpu_register(&lm32_cpus[i]);
+    }
+}
+
+type_init(lm32_cpu_register_types)
target-lm32/cpu.h +1 -0
index 0902a24..c1be305 100644
@@ -184,6 +184,7 @@ typedef struct CPULM32State {
 
 } CPULM32State;
 
+#include "cpu-qom.h"
 
 CPULM32State *cpu_lm32_init(const char *cpu_model);
 void cpu_lm32_list(FILE *f, fprintf_function cpu_fprintf);
target-lm32/helper.c +30 -112
index 5db8f8d..e89cc0e 100644
@@ -80,139 +80,57 @@ void do_interrupt(CPULM32State *env)
     }
 }
 
-typedef struct {
-    const char *name;
-    uint32_t revision;
-    uint8_t num_interrupts;
-    uint8_t num_breakpoints;
-    uint8_t num_watchpoints;
-    uint32_t features;
-} LM32Def;
+typedef struct LM32CPUListState {
+    fprintf_function cpu_fprintf;
+    FILE *file;
+} LM32CPUListState;
 
-static const LM32Def lm32_defs[] = {
-    {
-        .name = "lm32-basic",
-        .revision = 3,
-        .num_interrupts = 32,
-        .num_breakpoints = 4,
-        .num_watchpoints = 4,
-        .features = (LM32_FEATURE_SHIFT
-                     | LM32_FEATURE_SIGN_EXTEND
-                     | LM32_FEATURE_CYCLE_COUNT),
-    },
-    {
-        .name = "lm32-standard",
-        .revision = 3,
-        .num_interrupts = 32,
-        .num_breakpoints = 4,
-        .num_watchpoints = 4,
-        .features = (LM32_FEATURE_MULTIPLY
-                     | LM32_FEATURE_DIVIDE
-                     | LM32_FEATURE_SHIFT
-                     | LM32_FEATURE_SIGN_EXTEND
-                     | LM32_FEATURE_I_CACHE
-                     | LM32_FEATURE_CYCLE_COUNT),
-    },
-    {
-        .name = "lm32-full",
-        .revision = 3,
-        .num_interrupts = 32,
-        .num_breakpoints = 4,
-        .num_watchpoints = 4,
-        .features = (LM32_FEATURE_MULTIPLY
-                     | LM32_FEATURE_DIVIDE
-                     | LM32_FEATURE_SHIFT
-                     | LM32_FEATURE_SIGN_EXTEND
-                     | LM32_FEATURE_I_CACHE
-                     | LM32_FEATURE_D_CACHE
-                     | LM32_FEATURE_CYCLE_COUNT),
-    }
-};
-
-void cpu_lm32_list(FILE *f, fprintf_function cpu_fprintf)
+/* Sort alphabetically. */
+static gint lm32_cpu_list_compare(gconstpointer a, gconstpointer b)
 {
-    int i;
+    ObjectClass *class_a = OBJECT_CLASS(a);
+    ObjectClass *class_b = OBJECT_CLASS(b);
 
-    cpu_fprintf(f, "Available CPUs:\n");
-    for (i = 0; i < ARRAY_SIZE(lm32_defs); i++) {
-        cpu_fprintf(f, "  %s\n", lm32_defs[i].name);
-    }
+    return strcasecmp(object_class_get_name(class_a),
+                      object_class_get_name(class_b));
 }
 
-static const LM32Def *cpu_lm32_find_by_name(const char *name)
+static void lm32_cpu_list_entry(gpointer data, gpointer user_data)
 {
-    int i;
-
-    for (i = 0; i < ARRAY_SIZE(lm32_defs); i++) {
-        if (strcasecmp(name, lm32_defs[i].name) == 0) {
-            return &lm32_defs[i];
-        }
-    }
+    ObjectClass *klass = data;
+    LM32CPUListState *s = user_data;
 
-    return NULL;
+    (*s->cpu_fprintf)(s->file, "  %s\n",
+                      object_class_get_name(klass));
 }
 
-static uint32_t cfg_by_def(const LM32Def *def)
+void cpu_lm32_list(FILE *f, fprintf_function cpu_fprintf)
 {
-    uint32_t cfg = 0;
-
-    if (def->features & LM32_FEATURE_MULTIPLY) {
-        cfg |= CFG_M;
-    }
+    LM32CPUListState s = {
+        .file = f,
+        .cpu_fprintf = cpu_fprintf,
+    };
+    GSList *list;
 
-    if (def->features & LM32_FEATURE_DIVIDE) {
-        cfg |= CFG_D;
-    }
-
-    if (def->features & LM32_FEATURE_SHIFT) {
-        cfg |= CFG_S;
-    }
-
-    if (def->features & LM32_FEATURE_SIGN_EXTEND) {
-        cfg |= CFG_X;
-    }
-
-    if (def->features & LM32_FEATURE_I_CACHE) {
-        cfg |= CFG_IC;
-    }
-
-    if (def->features & LM32_FEATURE_D_CACHE) {
-        cfg |= CFG_DC;
-    }
-
-    if (def->features & LM32_FEATURE_CYCLE_COUNT) {
-        cfg |= CFG_CC;
-    }
-
-    cfg |= (def->num_interrupts << CFG_INT_SHIFT);
-    cfg |= (def->num_breakpoints << CFG_BP_SHIFT);
-    cfg |= (def->num_watchpoints << CFG_WP_SHIFT);
-    cfg |= (def->revision << CFG_REV_SHIFT);
-
-    return cfg;
+    list = object_class_get_list(TYPE_LM32_CPU, false);
+    list = g_slist_sort(list, lm32_cpu_list_compare);
+    cpu_fprintf(f, "Available CPUs:\n");
+    g_slist_foreach(list, lm32_cpu_list_entry, &s);
+    g_slist_free(list);
 }
 
 CPULM32State *cpu_lm32_init(const char *cpu_model)
 {
+    LM32CPU *cpu;
     CPULM32State *env;
-    const LM32Def *def;
     static int tcg_initialized;
 
-    def = cpu_lm32_find_by_name(cpu_model);
-    if (!def) {
+    if (object_class_by_name(cpu_model) == NULL) {
         return NULL;
     }
+    cpu = LM32_CPU(object_new(cpu_model));
+    env = &cpu->env;
 
-    env = g_malloc0(sizeof(CPULM32State));
-
-    env->features = def->features;
-    env->num_bps = def->num_breakpoints;
-    env->num_wps = def->num_watchpoints;
-    env->cfg = cfg_by_def(def);
-    env->flags = 0;
-
-    cpu_exec_init(env);
-    cpu_state_reset(env);
     qemu_init_vcpu(env);
 
     if (!tcg_initialized) {
Signature · 1 line
Michael
#165 lore raw

RFC 10/12 target-microblaze: QOM'ify CPU

In reply to Andreas Färber

There were no CPU models, so make TYPE_MICROBLAZE_CPU non-abstract.

---
 Makefile.target               |    1 +
 target-microblaze/cpu-qom.h   |   71 ++++++++++++++++++++++++
 target-microblaze/cpu.c       |  120 +++++++++++++++++++++++++++++++++++++++++
 target-microblaze/cpu.h       |    2 +
 target-microblaze/translate.c |   58 ++------------------
 5 files changed, 199 insertions(+), 53 deletions(-)
 create mode 100644 target-microblaze/cpu-qom.h
 create mode 100644 target-microblaze/cpu.c
Makefile.target +1 -0
index 8c8f4a8..82171ca 100644
@@ -92,6 +92,7 @@ libobj-$(TARGET_ARM) += cpu.o
 libobj-$(TARGET_CRIS) += cpu.o
 libobj-$(TARGET_LM32) += cpu.o
 libobj-$(TARGET_M68K) += cpu.o
+libobj-$(TARGET_MICROBLAZE) += cpu.o
 ifeq ($(TARGET_BASE_ARCH), mips)
 libobj-y += cpu.o
 endif
target-microblaze/cpu-qom.h new file +71 -0

71 lines not on this page · raw message

target-microblaze/cpu.c new file +120 -0

120 lines not on this page · raw message

target-microblaze/cpu.h +2 -0
index 3b52421..279c143 100644
@@ -266,6 +266,8 @@ typedef struct CPUMBState {
     CPU_COMMON
 } CPUMBState;
 
+#include "cpu-qom.h"
+
 CPUMBState *cpu_mb_init(const char *cpu_model);
 int cpu_mb_exec(CPUMBState *s);
 void cpu_mb_close(CPUMBState *s);
target-microblaze/translate.c +5 -53

77 lines not on this page · raw message

Signature · 1 line
1.7.7
#166 lore raw

RFC 11/12 target-sparc: QOM'ify CPU

In reply to Andreas Färber

Let sparc_cpu_list() enumerate CPU classes alphabetically.

Introduce sparc_env_get_features() to workaround a circular dependency.

---
 Makefile.target             |    2 +-
 target-sparc/cpu-qom.h      |   95 +++++
 target-sparc/cpu.c          |  949 +++++++++++++++++++++++++++++++++++++++++++
 target-sparc/cpu.h          |   29 +-
 target-sparc/cpu_init.c     |  848 --------------------------------------
 target-sparc/int32_helper.c |    5 +-
 target-sparc/ldst_helper.c  |   19 +-
 target-sparc/mmu_helper.c   |    4 +-
 target-sparc/translate.c    |    4 +-
 target-sparc/win_helper.c   |    3 +-
 10 files changed, 1075 insertions(+), 883 deletions(-)
 create mode 100644 target-sparc/cpu-qom.h
 create mode 100644 target-sparc/cpu.c
 delete mode 100644 target-sparc/cpu_init.c
Makefile.target +1 -1
index 82171ca..1c6ed12 100644
@@ -100,7 +100,7 @@ libobj-$(TARGET_S390X) += cpu.o
 libobj-$(TARGET_SH4) += cpu.o
 ifeq ($(TARGET_BASE_ARCH), sparc)
 libobj-y += fop_helper.o cc_helper.o win_helper.o mmu_helper.o ldst_helper.o
-libobj-y += cpu_init.o
+libobj-y += cpu.o
 endif
 libobj-$(TARGET_SPARC) += int32_helper.o
 libobj-$(TARGET_SPARC64) += int64_helper.o
target-sparc/cpu-qom.h new file +95 -0

95 lines not on this page · raw message

target-sparc/cpu.c new file +949 -0

949 lines not on this page · raw message

target-sparc/cpu.h +8 -21
index 86f9de6..10b05ac 100644
@@ -237,22 +237,6 @@ typedef struct trap_state {
 } trap_state;
 #endif
 
-typedef struct sparc_def_t {
-    const char *name;
-    target_ulong iu_version;
-    uint32_t fpu_version;
-    uint32_t mmu_version;
-    uint32_t mmu_bm;
-    uint32_t mmu_ctpr_mask;
-    uint32_t mmu_cxr_mask;
-    uint32_t mmu_sfsr_mask;
-    uint32_t mmu_trcr_mask;
-    uint32_t mxcc_version;
-    uint32_t features;
-    uint32_t nwindows;
-    uint32_t maxtl;
-} sparc_def_t;
-
 #define CPU_FEATURE_FLOAT        (1 << 0)
 #define CPU_FEATURE_FLOAT128     (1 << 1)
 #define CPU_FEATURE_SWAP         (1 << 2)
@@ -498,7 +482,6 @@ struct CPUSPARCState {
 #define SOFTINT_INTRMASK (0xFFFE)
 #define SOFTINT_REG_MASK (SOFTINT_STIMER|SOFTINT_INTRMASK|SOFTINT_TIMER)
 #endif
-    sparc_def_t *def;
 
     void *irq_manager;
     void (*qemu_irq_ack)(CPUSPARCState *env, void *irq_manager, int intno);
@@ -507,6 +490,7 @@ struct CPUSPARCState {
     uint32_t cache_control;
 };
 
+
 #ifndef NO_CPU_IO_DEFS
 /* cpu_init.c */
 CPUSPARCState *cpu_sparc_init(const char *cpu_model);
@@ -616,10 +600,12 @@ int cpu_sparc_signal_handler(int host_signum, void *pinfo, void *puc);
 #define MMU_MODE1_SUFFIX _kernel
 #endif
 
+static inline uint32_t sparc_env_get_features(CPUSPARCState *env);
+
 #if defined (TARGET_SPARC64)
 static inline int cpu_has_hypervisor(CPUSPARCState *env1)
 {
-    return env1->def->features & CPU_FEATURE_HYPV;
+    return sparc_env_get_features(env1) & CPU_FEATURE_HYPV;
 }
 
 static inline int cpu_hypervisor_mode(CPUSPARCState *env1)
@@ -688,6 +674,7 @@ static inline void cpu_clone_regs(CPUSPARCState *env, target_ulong newsp)
 #endif
 
 #include "cpu-all.h"
+#include "cpu-qom.h"
 
 #ifdef TARGET_SPARC64
 /* sun4u.c */
@@ -714,14 +701,14 @@ static inline void cpu_get_tb_cpu_state(CPUSPARCState *env, target_ulong *pc,
     if (env->pstate & PS_AM) {
         *flags |= TB_FLAG_AM_ENABLED;
     }
-    if ((env->def->features & CPU_FEATURE_FLOAT) && (env->pstate & PS_PEF)
-        && (env->fprs & FPRS_FEF)) {
+    if ((sparc_env_get_features(env) & CPU_FEATURE_FLOAT)
+        && (env->pstate & PS_PEF) && (env->fprs & FPRS_FEF)) {
         *flags |= TB_FLAG_FPU_ENABLED;
     }
 #else
     // FPU enable . Supervisor
     *flags = env->psrs;
-    if ((env->def->features & CPU_FEATURE_FLOAT) && env->psref) {
+    if ((sparc_env_get_features(env) & CPU_FEATURE_FLOAT) && env->psref) {
         *flags |= TB_FLAG_FPU_ENABLED;
     }
 #endif
target-sparc/cpu_init.c deleted +0 -848

848 lines not on this page · raw message

target-sparc/int32_helper.c +4 -1
index 5e33d50..8d454ae 100644
@@ -60,6 +60,9 @@ static const char * const excp_names[0x80] = {
 
 void do_interrupt(CPUSPARCState *env)
 {
+#if !defined(CONFIG_USER_ONLY)
+    SPARCCPU *cpu = sparc_env_get_cpu(env);
+#endif
     int cwp, intno = env->exception_index;
 
 #ifdef DEBUG_PCALL
@@ -102,7 +105,7 @@ void do_interrupt(CPUSPARCState *env)
 #if !defined(CONFIG_USER_ONLY)
     if (env->psret == 0) {
         if (env->exception_index == 0x80 &&
-            env->def->features & CPU_FEATURE_TA0_SHUTDOWN) {
+            cpu->features & CPU_FEATURE_TA0_SHUTDOWN) {
             qemu_system_shutdown_request();
         } else {
             cpu_abort(env, "Trap 0x%02x while interrupts disabled, Error state",
target-sparc/ldst_helper.c +11 -8
index 48d433c..806f45c 100644
@@ -438,6 +438,7 @@ static uint64_t leon3_cache_control_ld(target_ulong addr, int size)
 
 uint64_t helper_ld_asi(target_ulong addr, int asi, int size, int sign)
 {
+    SPARCCPU *cpu = sparc_env_get_cpu(env);
     uint64_t ret = 0;
 #if defined(DEBUG_MXCC) || defined(DEBUG_ASI)
     uint32_t last_addr = addr;
@@ -450,7 +451,7 @@ uint64_t helper_ld_asi(target_ulong addr, int asi, int size, int sign)
         case 0x00:          /* Leon3 Cache Control */
         case 0x08:          /* Leon3 Instruction Cache config */
         case 0x0C:          /* Leon3 Date Cache config */
-            if (env->def->features & CPU_FEATURE_CACHE_CTRL) {
+            if (cpu->features & CPU_FEATURE_CACHE_CTRL) {
                 ret = leon3_cache_control_ld(addr, size);
             }
             break;
@@ -696,6 +697,8 @@ uint64_t helper_ld_asi(target_ulong addr, int asi, int size, int sign)
 
 void helper_st_asi(target_ulong addr, uint64_t val, int asi, int size)
 {
+    SPARCCPU *cpu = sparc_env_get_cpu(env);
+    SPARCCPUClass *klass = SPARC_CPU_GET_CLASS(cpu);
     helper_check_align(addr, size - 1);
     switch (asi) {
     case 2: /* SuperSparc MXCC registers and Leon3 cache control */
@@ -703,7 +706,7 @@ void helper_st_asi(target_ulong addr, uint64_t val, int asi, int size)
         case 0x00:          /* Leon3 Cache Control */
         case 0x08:          /* Leon3 Instruction Cache config */
         case 0x0C:          /* Leon3 Date Cache config */
-            if (env->def->features & CPU_FEATURE_CACHE_CTRL) {
+            if (cpu->features & CPU_FEATURE_CACHE_CTRL) {
                 leon3_cache_control_st(addr, val, size);
             }
             break;
@@ -853,16 +856,16 @@ void helper_st_asi(target_ulong addr, uint64_t val, int asi, int size)
                     (val & 0x00ffffff);
                 /* Mappings generated during no-fault mode or MMU
                    disabled mode are invalid in normal mode */
-                if ((oldreg & (MMU_E | MMU_NF | env->def->mmu_bm)) !=
-                    (env->mmuregs[reg] & (MMU_E | MMU_NF | env->def->mmu_bm))) {
+                if ((oldreg & (MMU_E | MMU_NF | klass->mmu_bm)) !=
+                    (env->mmuregs[reg] & (MMU_E | MMU_NF | klass->mmu_bm))) {
                     tlb_flush(env, 1);
                 }
                 break;
             case 1: /* Context Table Pointer Register */
-                env->mmuregs[reg] = val & env->def->mmu_ctpr_mask;
+                env->mmuregs[reg] = val & klass->mmu_ctpr_mask;
                 break;
             case 2: /* Context Register */
-                env->mmuregs[reg] = val & env->def->mmu_cxr_mask;
+                env->mmuregs[reg] = val & klass->mmu_cxr_mask;
                 if (oldreg != env->mmuregs[reg]) {
                     /* we flush when the MMU context changes because
                        QEMU has no MMU context support */
@@ -873,11 +876,11 @@ void helper_st_asi(target_ulong addr, uint64_t val, int asi, int size)
             case 4: /* Synchronous Fault Address Register */
                 break;
             case 0x10: /* TLB Replacement Control Register */
-                env->mmuregs[reg] = val & env->def->mmu_trcr_mask;
+                env->mmuregs[reg] = val & klass->mmu_trcr_mask;
                 break;
             case 0x13: /* Synchronous Fault Status Register with Read
                           and Clear */
-                env->mmuregs[3] = val & env->def->mmu_sfsr_mask;
+                env->mmuregs[3] = val & klass->mmu_sfsr_mask;
                 break;
             case 0x14: /* Synchronous Fault Address Register */
                 env->mmuregs[4] = val;
target-sparc/mmu_helper.c +3 -1
index 11fb9f5..83b050e 100644
@@ -81,6 +81,8 @@ static int get_physical_address(CPUSPARCState *env, target_phys_addr_t *physical
                                 target_ulong address, int rw, int mmu_idx,
                                 target_ulong *page_size)
 {
+    SPARCCPU *cpu = sparc_env_get_cpu(env);
+    SPARCCPUClass *klass = SPARC_CPU_GET_CLASS(cpu);
     int access_perms = 0;
     target_phys_addr_t pde_ptr;
     uint32_t pde;
@@ -92,7 +94,7 @@ static int get_physical_address(CPUSPARCState *env, target_phys_addr_t *physical
     if ((env->mmuregs[0] & MMU_E) == 0) { /* MMU disabled */
         *page_size = TARGET_PAGE_SIZE;
         /* Boot mode: instruction fetches are taken from PROM */
-        if (rw == 2 && (env->mmuregs[0] & env->def->mmu_bm)) {
+        if (rw == 2 && (env->mmuregs[0] & klass->mmu_bm)) {
             *physical = env->prom_addr | (address & 0x7ffffULL);
             *prot = PAGE_READ | PAGE_EXEC;
             return 0;
target-sparc/translate.c +2 -2
index ef176e9..a737279 100644
@@ -81,7 +81,7 @@ typedef struct DisasContext {
     int singlestep;
     uint32_t cc_op;  /* current CC operation */
     struct TranslationBlock *tb;
-    sparc_def_t *def;
+    SPARCCPU *def;
     TCGv_i32 t32[3];
     int n_t32;
 } DisasContext;
@@ -5247,7 +5247,7 @@ static inline void gen_intermediate_code_internal(TranslationBlock * tb,
     dc->npc = (target_ulong) tb->cs_base;
     dc->cc_op = CC_OP_DYNAMIC;
     dc->mem_idx = cpu_mmu_index(env);
-    dc->def = env->def;
+    dc->def = sparc_env_get_cpu(env);
     dc->fpu_enabled = tb_fpu_enabled(tb->flags);
     dc->address_mask_32bit = tb_am_enabled(tb->flags);
     dc->singlestep = (env->singlestep_enabled || singlestep);
target-sparc/win_helper.c +2 -1
index 3e82eb7..02376fc 100644
@@ -300,10 +300,11 @@ static inline uint64_t *get_gregset(CPUSPARCState *env, uint32_t pstate)
 
 void cpu_change_pstate(CPUSPARCState *env, uint32_t new_pstate)
 {
+    SPARCCPU *cpu = sparc_env_get_cpu(env);
     uint32_t pstate_regs, new_pstate_regs;
     uint64_t *src, *dst;
 
-    if (env->def->features & CPU_FEATURE_GL) {
+    if (cpu->features & CPU_FEATURE_GL) {
         /* PS_AG is not implemented in this case */
         new_pstate &= ~PS_AG;
     }
Signature · 1 line
1.7.7