KVM PowerPC support
I believe all comments from the first series have been addressed (thanks for the quick review!). I was able to drop the first patch entirely, but realized I should move/rename the 4xx SDRAM controller code, so that change is new.
Summary:
These patches implement KVM support for the PowerPC Bamboo board, a system built around the 440EP SoC. In the KVM model, the KVM kernel module is responsible for all instruction execution, so it doesn't matter that TCG doesn't emulate the 440 core.
We've only tested KVM and Bamboo with the -kernel option. I have no idea what it would take to run a firmware like u-boot inside the VM, but it's basically the same problem as running u-boot inside a 405 VM.
-Hollis
PATCH 1/8 Move PPC4xx SDRAM controller emulation from ppc405_uc.c to ppc4xx_devs.c
The SDRAM controller is shared across almost all 405 and 440 embedded processors, with some slight differences such as the sizes supported for each memory bank.
Code movement only; no functional changes.
---
I think all device emulation should move from ppc405_uc.c to ppc4xx_devs.c, since it is shared between all 4xx SoCs (405 and 440). At the moment, the SDRAM controller is the only piece I have code for, so I'm only moving it.
(I can only guess "uc" means "microcontroller"; the file should be renamed as well.)
--- hw/ppc405.h | 5 - hw/ppc405_uc.c | 341 ------------------------------------------------------ hw/ppc4xx.h | 5 + hw/ppc4xx_devs.c | 341 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 346 insertions(+), 346 deletions(-)
hw/ppc405.h +0 -5
@@ -66,11 +66,6 @@ void ppc4xx_pob_init (CPUState *env);/* OPB arbitrer */ void ppc4xx_opba_init (CPUState *env,ppc4xx_mmio_t *mmio,target_phys_addr_t offset); -/* SDRAM controller */ -void ppc405_sdram_init (CPUState *env,qemu_irq irq,int nbanks, -target_phys_addr_t *ram_bases, -target_phys_addr_t *ram_sizes, -int do_init);/* Peripheral controller */ void ppc405_ebc_init (CPUState *env);/* DMA controller */
hw/ppc405_uc.c +0 -341
347 lines not on this page · raw message
hw/ppc4xx.h +5 -0
@@ -48,6 +48,11 @@ enum {qemu_irq *ppcuic_init (CPUState *env,qemu_irq *irqs,uint32_t dcr_base,int has_ssr,int has_vr); +void ppc405_sdram_init (CPUState *env,qemu_irq irq,int nbanks, +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], target_phys_addr_t config_space, target_phys_addr_t int_ack,
hw/ppc4xx_devs.c +341 -0
344 lines not on this page · raw message
Signature · 1 line
1.5.6.5
Aurelien Jarno
AppliedRe: [Qemu-devel] [PATCH 1/8] Move PPC4xx SDRAM controller
Quoted 7 lines · Hollis Blanchard
The SDRAM controller is shared across almost all 405 and 440 embedded processors, with some slight differences such as the sizes supported for each memory bank.
Code movement only; no functional changes.
Signed-off-by Hollis Blanchard <[email protected]>
Thanks, applied.
Quoted 753 lines
---
I think all device emulation should move fromppc405_uc.ctoppc4xx_devs.c, since it is shared between all 4xx SoCs (405 and 440). At the moment, the SDRAM controller is the only piece I have code for, so I'm only moving it.(I can only guess "uc" means "microcontroller"; the file should be renamed as well.)
--- hw/ppc405.h | 5 - hw/ppc405_uc.c | 341 ------------------------------------------------------ hw/ppc4xx.h | 5 + hw/ppc4xx_devs.c | 341 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 346 insertions(+), 346 deletions(-)hw/ppc405.h +0
-5@@ -66,11 +66,6 @@ void ppc4xx_pob_init (CPUState *env);/* OPB arbitrer */ void ppc4xx_opba_init (CPUState *env,ppc4xx_mmio_t *mmio,target_phys_addr_t offset); -/* SDRAM controller */ -void ppc405_sdram_init (CPUState *env,qemu_irq irq,int nbanks, -target_phys_addr_t *ram_bases, -target_phys_addr_t *ram_sizes, -int do_init);/* Peripheral controller */ void ppc405_ebc_init (CPUState *env);/* DMA controller */ hw/ppc405_uc.c +0
-341@@ -401,347 +401,6 @@ void ppc4xx_opba_init (CPUState *env, ppc4xx_mmio_t *mmio,/* XXX: TODO */ /*****************************************************************************/ -/* SDRAM controller */ -typedef struct ppc4xx_sdram_t ppc4xx_sdram_t ; -struct ppc4xx_sdram_t { -uint32_t addr; -int nbanks; -target_phys_addr_t ram_bases[4 ]; -target_phys_addr_t ram_sizes[4 ]; -uint32_t besr0; -uint32_t besr1; -uint32_t bear; -uint32_t cfg; -uint32_t status; -uint32_t rtr; -uint32_t pmit; -uint32_t bcr[4 ]; -uint32_t tr; -uint32_t ecccfg; -uint32_t eccesr; -qemu_irq irq; -}; - -enum { -SDRAM0_CFGADDR =0x010 , -SDRAM0_CFGDATA =0x011 , -}; - -/* XXX: TOFIX: some patches have made this code become inconsistent: -* there are type inconsistencies, mixing target_phys_addr_t, target_ulong -* and uint32_t -*/ -static uint32_t sdram_bcr (target_phys_addr_t ram_base, -target_phys_addr_t ram_size) -{ -uint32_t bcr; - -switch (ram_size) { -case (4 *1024 *1024 ): - bcr =0x00000000 ; -break ; -case (8 *1024 *1024 ): - bcr =0x00020000 ; -break ; -case (16 *1024 *1024 ): - bcr =0x00040000 ; -break ; -case (32 *1024 *1024 ): - bcr =0x00060000 ; -break ; -case (64 *1024 *1024 ): - bcr =0x00080000 ; -break ; -case (128 *1024 *1024 ): - bcr =0x000A0000 ; -break ; -case (256 *1024 *1024 ): - bcr =0x000C0000 ; -break ; -default : -printf ("%s: invalid RAM size " PADDRX "\n" , __func__, ram_size); -return 0x00000000 ; - } - bcr |= ram_base &0xFF800000 ; - bcr |=1 ; - -return bcr; -} - -static always_inline target_phys_addr_t sdram_base (uint32_t bcr) -{ -return bcr &0xFF800000 ; -} - -static target_ulong sdram_size (uint32_t bcr) -{ -target_ulong size; -int sh; - - sh = (bcr >>17 ) &0x7 ; -if (sh =7 ) - size =-1 ; -else - size = (4 *1024 *1024 ) << sh; - -return size; -} - -static void sdram_set_bcr (uint32_t *bcrp,uint32_t bcr,int enabled) -{ -if (*bcrp &0x00000001 ) { -/* Unmap RAM */ -#ifdef DEBUG_SDRAM -printf ("%s: unmap RAM area " PADDRX " " ADDRX "\n" , - __func__,sdram_base (*bcrp),sdram_size (*bcrp)); -#endif -cpu_register_physical_memory (sdram_base (*bcrp),sdram_size (*bcrp), -IO_MEM_UNASSIGNED ); - } - *bcrp = bcr &0xFFDEE001 ; -if (enabled && (bcr &0x00000001 )) { -#ifdef DEBUG_SDRAM -printf ("%s: Map RAM area " PADDRX " " ADDRX "\n" , - __func__,sdram_base (bcr),sdram_size (bcr)); -#endif -cpu_register_physical_memory (sdram_base (bcr),sdram_size (bcr), -sdram_base (bcr) |IO_MEM_RAM ); - } -} - -static void sdram_map_bcr (ppc4xx_sdram_t *sdram) -{ -int i; - -for (i =0 ; i < sdram->nbanks; i++) { -if (sdram->ram_sizes[i] !=0 ) { -sdram_set_bcr (&sdram->bcr[i], -sdram_bcr (sdram->ram_bases[i], sdram->ram_sizes[i]), -1 ); - }else { -sdram_set_bcr (&sdram->bcr[i],0x00000000 ,0 ); - } - } -} - -static void sdram_unmap_bcr (ppc4xx_sdram_t *sdram) -{ -int i; - -for (i =0 ; i < sdram->nbanks; i++) { -#ifdef DEBUG_SDRAM -printf ("%s: Unmap RAM area " PADDRX " " ADDRX "\n" , - __func__,sdram_base (sdram->bcr[i]),sdram_size (sdram->bcr[i])); -#endif -cpu_register_physical_memory (sdram_base (sdram->bcr[i]), -sdram_size (sdram->bcr[i]), -IO_MEM_UNASSIGNED ); - } -} - -static target_ulong dcr_read_sdram (void *opaque,int dcrn) -{ -ppc4xx_sdram_t *sdram; -target_ulong ret; - - sdram = opaque; -switch (dcrn) { -case SDRAM0_CFGADDR : - ret = sdram->addr; -break ; -case SDRAM0_CFGDATA : -switch (sdram->addr) { -case 0x00 :/* SDRAM_BESR0 */ - ret = sdram->besr0; -break ; -case 0x08 :/* SDRAM_BESR1 */ - ret = sdram->besr1; -break ; -case 0x10 :/* SDRAM_BEAR */ - ret = sdram->bear; -break ; -case 0x20 :/* SDRAM_CFG */ - ret = sdram->cfg; -break ; -case 0x24 :/* SDRAM_STATUS */ - ret = sdram->status; -break ; -case 0x30 :/* SDRAM_RTR */ - ret = sdram->rtr; -break ; -case 0x34 :/* SDRAM_PMIT */ - ret = sdram->pmit; -break ; -case 0x40 :/* SDRAM_B0CR */ - ret = sdram->bcr[0 ]; -break ; -case 0x44 :/* SDRAM_B1CR */ - ret = sdram->bcr[1 ]; -break ; -case 0x48 :/* SDRAM_B2CR */ - ret = sdram->bcr[2 ]; -break ; -case 0x4C :/* SDRAM_B3CR */ - ret = sdram->bcr[3 ]; -break ; -case 0x80 :/* SDRAM_TR */ - ret =-1 ;/* ? */ -break ; -case 0x94 :/* SDRAM_ECCCFG */ - ret = sdram->ecccfg; -break ; -case 0x98 :/* SDRAM_ECCESR */ - ret = sdram->eccesr; -break ; -default :/* Error */ - ret =-1 ; -break ; - } -break ; -default : -/* Avoid gcc warning */ - ret =0x00000000 ; -break ; - } - -return ret; -} - -static void dcr_write_sdram (void *opaque,int dcrn,target_ulong val) -{ -ppc4xx_sdram_t *sdram; - - sdram = opaque; -switch (dcrn) { -case SDRAM0_CFGADDR : - sdram->addr = val; -break ; -case SDRAM0_CFGDATA : -switch (sdram->addr) { -case 0x00 :/* SDRAM_BESR0 */ - sdram->besr0 &= ~val; -break ; -case 0x08 :/* SDRAM_BESR1 */ - sdram->besr1 &= ~val; -break ; -case 0x10 :/* SDRAM_BEAR */ - sdram->bear = val; -break ; -case 0x20 :/* SDRAM_CFG */ - val &=0xFFE00000 ; -if (!(sdram->cfg &0x80000000 ) && (val &0x80000000 )) { -#ifdef DEBUG_SDRAM -printf ("%s: enable SDRAM controller\n" , __func__); -#endif -/* validate all RAM mappings */ -sdram_map_bcr (sdram); - sdram->status &= ~0x80000000 ; - }else if ((sdram->cfg &0x80000000 ) && !(val &0x80000000 )) { -#ifdef DEBUG_SDRAM -printf ("%s: disable SDRAM controller\n" , __func__); -#endif -/* invalidate all RAM mappings */ -sdram_unmap_bcr (sdram); - sdram->status |=0x80000000 ; - } -if (!(sdram->cfg &0x40000000 ) && (val &0x40000000 )) - sdram->status |=0x40000000 ; -else if ((sdram->cfg &0x40000000 ) && !(val &0x40000000 )) - sdram->status &= ~0x40000000 ; - sdram->cfg = val; -break ; -case 0x24 :/* SDRAM_STATUS */ -/* Read-only register */ -break ; -case 0x30 :/* SDRAM_RTR */ - sdram->rtr = val &0x3FF80000 ; -break ; -case 0x34 :/* SDRAM_PMIT */ - sdram->pmit = (val &0xF8000000 ) |0x07C00000 ; -break ; -case 0x40 :/* SDRAM_B0CR */ -sdram_set_bcr (&sdram->bcr[0 ], val, sdram->cfg &0x80000000 ); -break ; -case 0x44 :/* SDRAM_B1CR */ -sdram_set_bcr (&sdram->bcr[1 ], val, sdram->cfg &0x80000000 ); -break ; -case 0x48 :/* SDRAM_B2CR */ -sdram_set_bcr (&sdram->bcr[2 ], val, sdram->cfg &0x80000000 ); -break ; -case 0x4C :/* SDRAM_B3CR */ -sdram_set_bcr (&sdram->bcr[3 ], val, sdram->cfg &0x80000000 ); -break ; -case 0x80 :/* SDRAM_TR */ - sdram->tr = val &0x018FC01F ; -break ; -case 0x94 :/* SDRAM_ECCCFG */ - sdram->ecccfg = val &0x00F00000 ; -break ; -case 0x98 :/* SDRAM_ECCESR */ - val &=0xFFF0F000 ; -if (sdram->eccesr =0 && val !=0 ) -qemu_irq_raise (sdram->irq); -else if (sdram->eccesr !=0 && val =0 ) -qemu_irq_lower (sdram->irq); - sdram->eccesr = val; -break ; -default :/* Error */ -break ; - } -break ; - } -} - -static void sdram_reset (void *opaque) -{ -ppc4xx_sdram_t *sdram; - - sdram = opaque; - sdram->addr =0x00000000 ; - sdram->bear =0x00000000 ; - sdram->besr0 =0x00000000 ;/* No error */ - sdram->besr1 =0x00000000 ;/* No error */ - sdram->cfg =0x00000000 ; - sdram->ecccfg =0x00000000 ;/* No ECC */ - sdram->eccesr =0x00000000 ;/* No error */ - sdram->pmit =0x07C00000 ; - sdram->rtr =0x05F00000 ; - sdram->tr =0x00854009 ; -/* We pre-initialize RAM banks */ - sdram->status =0x00000000 ; - sdram->cfg =0x00800000 ; -sdram_unmap_bcr (sdram); -} - -void ppc405_sdram_init (CPUState *env,qemu_irq irq,int nbanks, -target_phys_addr_t *ram_bases, -target_phys_addr_t *ram_sizes, -int do_init) -{ -ppc4xx_sdram_t *sdram; - - sdram =qemu_mallocz (sizeof (ppc4xx_sdram_t)); -if (sdram !=NULL ) { - sdram->irq = irq; - sdram->nbanks = nbanks; -memset (sdram->ram_bases,0 ,4 *sizeof (target_phys_addr_t)); -memcpy (sdram->ram_bases, ram_bases, - nbanks *sizeof (target_phys_addr_t)); -memset (sdram->ram_sizes,0 ,4 *sizeof (target_phys_addr_t)); -memcpy (sdram->ram_sizes, ram_sizes, - nbanks *sizeof (target_phys_addr_t)); -sdram_reset (sdram); -qemu_register_reset (&sdram_reset, sdram); -ppc_dcr_register (env,SDRAM0_CFGADDR , - sdram, &dcr_read_sdram, &dcr_write_sdram); -ppc_dcr_register (env,SDRAM0_CFGDATA , - sdram, &dcr_read_sdram, &dcr_write_sdram); -if (do_init) -sdram_map_bcr (sdram); - } -} - -/*****************************************************************************/ /* Peripheral controller */ typedef struct ppc4xx_ebc_t ppc4xx_ebc_t ;struct ppc4xx_ebc_t {hw/ppc4xx.h +5
-0@@ -48,6 +48,11 @@ enum {qemu_irq *ppcuic_init (CPUState *env,qemu_irq *irqs,uint32_t dcr_base,int has_ssr,int has_vr); +void ppc405_sdram_init (CPUState *env,qemu_irq irq,int nbanks, +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], target_phys_addr_t config_space, target_phys_addr_t int_ack,hw/ppc4xx_devs.c +341
-0@@ -532,3 +532,344 @@ qemu_irq *ppcuic_init (CPUState *env, qemu_irq *irqs,return qemu_allocate_irqs (&ppcuic_set_irq, uic,UIC_MAX_IRQ ); } + +/*****************************************************************************/ +/* SDRAM controller */ +typedef struct ppc4xx_sdram_t ppc4xx_sdram_t ; +struct ppc4xx_sdram_t { +uint32_t addr; +int nbanks; +target_phys_addr_t ram_bases[4 ]; +target_phys_addr_t ram_sizes[4 ]; +uint32_t besr0; +uint32_t besr1; +uint32_t bear; +uint32_t cfg; +uint32_t status; +uint32_t rtr; +uint32_t pmit; +uint32_t bcr[4 ]; +uint32_t tr; +uint32_t ecccfg; +uint32_t eccesr; +qemu_irq irq; +}; + +enum { +SDRAM0_CFGADDR =0x010 , +SDRAM0_CFGDATA =0x011 , +}; + +/* XXX: TOFIX: some patches have made this code become inconsistent: +* there are type inconsistencies, mixing target_phys_addr_t, target_ulong +* and uint32_t +*/ +static uint32_t sdram_bcr (target_phys_addr_t ram_base, +target_phys_addr_t ram_size) +{ +uint32_t bcr; + +switch (ram_size) { +case (4 *1024 *1024 ): + bcr =0x00000000 ; +break ; +case (8 *1024 *1024 ): + bcr =0x00020000 ; +break ; +case (16 *1024 *1024 ): + bcr =0x00040000 ; +break ; +case (32 *1024 *1024 ): + bcr =0x00060000 ; +break ; +case (64 *1024 *1024 ): + bcr =0x00080000 ; +break ; +case (128 *1024 *1024 ): + bcr =0x000A0000 ; +break ; +case (256 *1024 *1024 ): + bcr =0x000C0000 ; +break ; +default : +printf ("%s: invalid RAM size " PADDRX "\n" , __func__, ram_size); +return 0x00000000 ; + } + bcr |= ram_base &0xFF800000 ; + bcr |=1 ; + +return bcr; +} + +static always_inline target_phys_addr_t sdram_base (uint32_t bcr) +{ +return bcr &0xFF800000 ; +} + +static target_ulong sdram_size (uint32_t bcr) +{ +target_ulong size; +int sh; + + sh = (bcr >>17 ) &0x7 ; +if (sh =7 ) + size =-1 ; +else + size = (4 *1024 *1024 ) << sh; + +return size; +} + +static void sdram_set_bcr (uint32_t *bcrp,uint32_t bcr,int enabled) +{ +if (*bcrp &0x00000001 ) { +/* Unmap RAM */ +#ifdef DEBUG_SDRAM +printf ("%s: unmap RAM area " PADDRX " " ADDRX "\n" , + __func__,sdram_base (*bcrp),sdram_size (*bcrp)); +#endif +cpu_register_physical_memory (sdram_base (*bcrp),sdram_size (*bcrp), +IO_MEM_UNASSIGNED ); + } + *bcrp = bcr &0xFFDEE001 ; +if (enabled && (bcr &0x00000001 )) { +#ifdef DEBUG_SDRAM +printf ("%s: Map RAM area " PADDRX " " ADDRX "\n" , + __func__,sdram_base (bcr),sdram_size (bcr)); +#endif +cpu_register_physical_memory (sdram_base (bcr),sdram_size (bcr), +sdram_base (bcr) |IO_MEM_RAM ); + } +} + +static void sdram_map_bcr (ppc4xx_sdram_t *sdram) +{ +int i; + +for (i =0 ; i < sdram->nbanks; i++) { +if (sdram->ram_sizes[i] !=0 ) { +sdram_set_bcr (&sdram->bcr[i], +sdram_bcr (sdram->ram_bases[i], sdram->ram_sizes[i]), +1 ); + }else { +sdram_set_bcr (&sdram->bcr[i],0x00000000 ,0 ); + } + } +} + +static void sdram_unmap_bcr (ppc4xx_sdram_t *sdram) +{ +int i; + +for (i =0 ; i < sdram->nbanks; i++) { +#ifdef DEBUG_SDRAM +printf ("%s: Unmap RAM area " PADDRX " " ADDRX "\n" , + __func__,sdram_base (sdram->bcr[i]),sdram_size (sdram->bcr[i])); +#endif +cpu_register_physical_memory (sdram_base (sdram->bcr[i]), +sdram_size (sdram->bcr[i]), +IO_MEM_UNASSIGNED ); + } +} + +static target_ulong dcr_read_sdram (void *opaque,int dcrn) +{ +ppc4xx_sdram_t *sdram; +target_ulong ret; + + sdram = opaque; +switch (dcrn) { +case SDRAM0_CFGADDR : + ret = sdram->addr; +break ; +case SDRAM0_CFGDATA : +switch (sdram->addr) { +case 0x00 :/* SDRAM_BESR0 */ + ret = sdram->besr0; +break ; +case 0x08 :/* SDRAM_BESR1 */ + ret = sdram->besr1; +break ; +case 0x10 :/* SDRAM_BEAR */ + ret = sdram->bear; +break ; +case 0x20 :/* SDRAM_CFG */ + ret = sdram->cfg; +break ; +case 0x24 :/* SDRAM_STATUS */ + ret = sdram->status; +break ; +case 0x30 :/* SDRAM_RTR */ + ret = sdram->rtr; +break ; +case 0x34 :/* SDRAM_PMIT */ + ret = sdram->pmit; +break ; +case 0x40 :/* SDRAM_B0CR */ + ret = sdram->bcr[0 ]; +break ; +case 0x44 :/* SDRAM_B1CR */ + ret = sdram->bcr[1 ]; +break ; +case 0x48 :/* SDRAM_B2CR */ + ret = sdram->bcr[2 ]; +break ; +case 0x4C :/* SDRAM_B3CR */ + ret = sdram->bcr[3 ]; +break ; +case 0x80 :/* SDRAM_TR */ + ret =-1 ;/* ? */ +break ; +case 0x94 :/* SDRAM_ECCCFG */ + ret = sdram->ecccfg; +break ; +case 0x98 :/* SDRAM_ECCESR */ + ret = sdram->eccesr; +break ; +default :/* Error */ + ret =-1 ; +break ; + } +break ; +default : +/* Avoid gcc warning */ + ret =0x00000000 ; +break ; + } + +return ret; +} + +static void dcr_write_sdram (void *opaque,int dcrn,target_ulong val) +{ +ppc4xx_sdram_t *sdram; + + sdram = opaque; +switch (dcrn) { +case SDRAM0_CFGADDR : + sdram->addr = val; +break ; +case SDRAM0_CFGDATA : +switch (sdram->addr) { +case 0x00 :/* SDRAM_BESR0 */ + sdram->besr0 &= ~val; +break ; +case 0x08 :/* SDRAM_BESR1 */ + sdram->besr1 &= ~val; +break ; +case 0x10 :/* SDRAM_BEAR */ + sdram->bear = val; +break ; +case 0x20 :/* SDRAM_CFG */ + val &=0xFFE00000 ; +if (!(sdram->cfg &0x80000000 ) && (val &0x80000000 )) { +#ifdef DEBUG_SDRAM +printf ("%s: enable SDRAM controller\n" , __func__); +#endif +/* validate all RAM mappings */ +sdram_map_bcr (sdram); + sdram->status &= ~0x80000000 ; + }else if ((sdram->cfg &0x80000000 ) && !(val &0x80000000 )) { +#ifdef DEBUG_SDRAM +printf ("%s: disable SDRAM controller\n" , __func__); +#endif +/* invalidate all RAM mappings */ +sdram_unmap_bcr (sdram); + sdram->status |=0x80000000 ; + } +if (!(sdram->cfg &0x40000000 ) && (val &0x40000000 )) + sdram->status |=0x40000000 ; +else if ((sdram->cfg &0x40000000 ) && !(val &0x40000000 )) + sdram->status &= ~0x40000000 ; + sdram->cfg = val; +break ; +case 0x24 :/* SDRAM_STATUS */ +/* Read-only register */ +break ; +case 0x30 :/* SDRAM_RTR */ + sdram->rtr = val &0x3FF80000 ; +break ; +case 0x34 :/* SDRAM_PMIT */ + sdram->pmit = (val &0xF8000000 ) |0x07C00000 ; +break ; +case 0x40 :/* SDRAM_B0CR */ +sdram_set_bcr (&sdram->bcr[0 ], val, sdram->cfg &0x80000000 ); +break ; +case 0x44 :/* SDRAM_B1CR */ +sdram_set_bcr (&sdram->bcr[1 ], val, sdram->cfg &0x80000000 ); +break ; +case 0x48 :/* SDRAM_B2CR */ +sdram_set_bcr (&sdram->bcr[2 ], val, sdram->cfg &0x80000000 ); +break ; +case 0x4C :/* SDRAM_B3CR */ +sdram_set_bcr (&sdram->bcr[3 ], val, sdram->cfg &0x80000000 ); +break ; +case 0x80 :/* SDRAM_TR */ + sdram->tr = val &0x018FC01F ; +break ; +case 0x94 :/* SDRAM_ECCCFG */ + sdram->ecccfg = val &0x00F00000 ; +break ; +case 0x98 :/* SDRAM_ECCESR */ + val &=0xFFF0F000 ; +if (sdram->eccesr =0 && val !=0 ) +qemu_irq_raise (sdram->irq); +else if (sdram->eccesr !=0 && val =0 ) +qemu_irq_lower (sdram->irq); + sdram->eccesr = val; +break ; +default :/* Error */ +break ; + } +break ; + } +} + +static void sdram_reset (void *opaque) +{ +ppc4xx_sdram_t *sdram; + + sdram = opaque; + sdram->addr =0x00000000 ; + sdram->bear =0x00000000 ; + sdram->besr0 =0x00000000 ;/* No error */ + sdram->besr1 =0x00000000 ;/* No error */ + sdram->cfg =0x00000000 ; + sdram->ecccfg =0x00000000 ;/* No ECC */ + sdram->eccesr =0x00000000 ;/* No error */ + sdram->pmit =0x07C00000 ; + sdram->rtr =0x05F00000 ; + sdram->tr =0x00854009 ; +/* We pre-initialize RAM banks */ + sdram->status =0x00000000 ; + sdram->cfg =0x00800000 ; +sdram_unmap_bcr (sdram); +} + +void ppc405_sdram_init (CPUState *env,qemu_irq irq,int nbanks, +target_phys_addr_t *ram_bases, +target_phys_addr_t *ram_sizes, +int do_init) +{ +ppc4xx_sdram_t *sdram; + + sdram =qemu_mallocz (sizeof (ppc4xx_sdram_t)); +if (sdram !=NULL ) { + sdram->irq = irq; + sdram->nbanks = nbanks; +memset (sdram->ram_bases,0 ,4 *sizeof (target_phys_addr_t)); +memcpy (sdram->ram_bases, ram_bases, + nbanks *sizeof (target_phys_addr_t)); +memset (sdram->ram_sizes,0 ,4 *sizeof (target_phys_addr_t)); +memcpy (sdram->ram_sizes, ram_sizes, + nbanks *sizeof (target_phys_addr_t)); +sdram_reset (sdram); +qemu_register_reset (&sdram_reset, sdram); +ppc_dcr_register (env,SDRAM0_CFGADDR , + sdram, &dcr_read_sdram, &dcr_write_sdram); +ppc_dcr_register (env,SDRAM0_CFGDATA , + sdram, &dcr_read_sdram, &dcr_write_sdram); +if (do_init) +sdram_map_bcr (sdram); + } +}Signature · 1 line
1.5.6.5
Signature · 4 lines
.''`. Aurelien Jarno | GPG: 1024D/F1BCDB73 : :' : Debian developer | Electrical Engineer `. `' [email protected] | [email protected] `- people.debian.org/~aurel32 | www.aurel32.net
PATCH 2/8 Rename ppc405_sdram_init() to ppc4xx_sdram_init()
In reply to Hollis BlanchardThe SDRAM controller is shared across almost all 405 and 440 embedded processors, with some slight differences such as the sizes supported for each memory bank.
Rename only; no functional changes.
--- hw/ppc405_uc.c | 4 ++-- hw/ppc4xx.h | 2 +- hw/ppc4xx_devs.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)
hw/ppc405_uc.c +2 -2
@@ -2230,7 +2230,7 @@ CPUState *ppc405cr_init (target_phys_addr_t ram_bases[4], pic =ppcuic_init (env, irqs,0x0C0 ,0 ,1 ); *picp = pic;/* SDRAM controller */ -ppc405_sdram_init (env, pic[14 ],1 , ram_bases, ram_sizes, do_init); +ppc4xx_sdram_init (env, pic[14 ],1 , ram_bases, ram_sizes, do_init); offset =0 ;for (i =0 ; i <4 ; i++) offset += ram_sizes[i];
@@ -2588,7 +2588,7 @@ CPUState *ppc405ep_init (target_phys_addr_t ram_bases[2], *picp = pic;/* SDRAM controller */ /* XXX 405EP has no ECC interrupt */ -ppc405_sdram_init (env, pic[17 ],2 , ram_bases, ram_sizes, do_init); +ppc4xx_sdram_init (env, pic[17 ],2 , ram_bases, ram_sizes, do_init); offset =0 ;for (i =0 ; i <2 ; i++) offset += ram_sizes[i];
hw/ppc4xx.h +1 -1
@@ -48,7 +48,7 @@ enum {qemu_irq *ppcuic_init (CPUState *env,qemu_irq *irqs,uint32_t dcr_base,int has_ssr,int has_vr); -void ppc405_sdram_init (CPUState *env,qemu_irq irq,int nbanks, +void ppc4xx_sdram_init (CPUState *env,qemu_irq irq,int nbanks,target_phys_addr_t *ram_bases,target_phys_addr_t *ram_sizes,int do_init);
hw/ppc4xx_devs.c +1 -1
@@ -846,7 +846,7 @@ static void sdram_reset (void *opaque)sdram_unmap_bcr (sdram); } -void ppc405_sdram_init (CPUState *env,qemu_irq irq,int nbanks, +void ppc4xx_sdram_init (CPUState *env,qemu_irq irq,int nbanks,target_phys_addr_t *ram_bases,target_phys_addr_t *ram_sizes,int do_init)
Signature · 1 line
1.5.6.5
Aurelien Jarno
AppliedRe: [Qemu-devel] [PATCH 2/8] Rename ppc405_sdram_init() to
Quoted 7 lines · Hollis Blanchard
The SDRAM controller is shared across almost all 405 and 440 embedded processors, with some slight differences such as the sizes supported for each memory bank.
Rename only; no functional changes.
Signed-off-by Hollis Blanchard <[email protected]>
Thanks, applied.
Quoted 60 lines
--- hw/ppc405_uc.c | 4 ++-- hw/ppc4xx.h | 2 +- hw/ppc4xx_devs.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-)hw/ppc405_uc.c +2
-2@@ -2230,7 +2230,7 @@ CPUState *ppc405cr_init (target_phys_addr_t ram_bases[4], pic =ppcuic_init (env, irqs,0x0C0 ,0 ,1 ); *picp = pic;/* SDRAM controller */ -ppc405_sdram_init (env, pic[14 ],1 , ram_bases, ram_sizes, do_init); +ppc4xx_sdram_init (env, pic[14 ],1 , ram_bases, ram_sizes, do_init); offset =0 ;for (i =0 ; i <4 ; i++) offset += ram_sizes[i];@@ -2588,7 +2588,7 @@ CPUState *ppc405ep_init (target_phys_addr_t ram_bases[2], *picp = pic;/* SDRAM controller */ /* XXX 405EP has no ECC interrupt */ -ppc405_sdram_init (env, pic[17 ],2 , ram_bases, ram_sizes, do_init); +ppc4xx_sdram_init (env, pic[17 ],2 , ram_bases, ram_sizes, do_init); offset =0 ;for (i =0 ; i <2 ; i++) offset += ram_sizes[i];hw/ppc4xx.h +1
-1@@ -48,7 +48,7 @@ enum {qemu_irq *ppcuic_init (CPUState *env,qemu_irq *irqs,uint32_t dcr_base,int has_ssr,int has_vr); -void ppc405_sdram_init (CPUState *env,qemu_irq irq,int nbanks, +void ppc4xx_sdram_init (CPUState *env,qemu_irq irq,int nbanks,target_phys_addr_t *ram_bases,target_phys_addr_t *ram_sizes,int do_init);hw/ppc4xx_devs.c +1
-1@@ -846,7 +846,7 @@ static void sdram_reset (void *opaque)sdram_unmap_bcr (sdram); } -void ppc405_sdram_init (CPUState *env,qemu_irq irq,int nbanks, +void ppc4xx_sdram_init (CPUState *env,qemu_irq irq,int nbanks,target_phys_addr_t *ram_bases,target_phys_addr_t *ram_sizes,int do_init)Signature · 1 line
1.5.6.5
Signature · 4 lines
.''`. Aurelien Jarno | GPG: 1024D/F1BCDB73 : :' : Debian developer | Electrical Engineer `. `' [email protected] | [email protected] `- people.debian.org/~aurel32 | www.aurel32.net
PATCH 3/8 Create a helper function to allow more flexible RAM allocation for PPC 4xx
In reply to Hollis BlanchardThe 4xx SDRAM controller supports a small number of banks, and each bank must be one of a small set of sizes. The number of banks and the supported sizes varies by SoC.
This function uses the user-specified RAM size to fill in the "ram_bases" and "ram_sizes" arrays required by ppc4xx_sdram_init().
--- hw/ppc4xx.h | 5 +++++ hw/ppc4xx_devs.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 0 deletions(-)
hw/ppc4xx.h +5 -0
@@ -48,6 +48,11 @@ enum {qemu_irq *ppcuic_init (CPUState *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, +target_phys_addr_t ram_bases[], +target_phys_addr_t ram_sizes[], +const unsigned int sdram_bank_sizes[]); + void ppc4xx_sdram_init (CPUState *env, qemu_irq irq, int nbanks, target_phys_addr_t *ram_bases, target_phys_addr_t *ram_sizes,
hw/ppc4xx_devs.c +42 -0
45 lines not on this page · raw message
Signature · 1 line
1.5.6.5
Aurelien Jarno
AppliedRe: [Qemu-devel] [PATCH 3/8] Create a helper function to allow more flexible RAM allocation for PPC
Quoted 8 lines · Hollis Blanchard
The 4xx SDRAM controller supports a small number of banks, and each bank must be one of a small set of sizes. The number of banks and the supported sizes varies by SoC.
This function uses the user-specified RAM size to fill in the "
ram_bases" and "ram_sizes" arrays required byppc4xx_sdram_init().Signed-off-by Hollis Blanchard <[email protected]>
Applied, thanks.
Quoted 77 lines
--- hw/ppc4xx.h | 5 +++++ hw/ppc4xx_devs.c | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 0 deletions(-)hw/ppc4xx.h +5
-0@@ -48,6 +48,11 @@ enum {qemu_irq *ppcuic_init (CPUState *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, +target_phys_addr_t ram_bases[], +target_phys_addr_t ram_sizes[], +const unsigned int sdram_bank_sizes[]); + void ppc4xx_sdram_init (CPUState *env, qemu_irq irq, int nbanks, target_phys_addr_t *ram_bases, target_phys_addr_t *ram_sizes,hw/ppc4xx_devs.c +42
-0@@ -873,3 +873,45 @@ void ppc4xx_sdram_init (CPUState *env, qemu_irq irq, int nbanks,sdram_map_bcr (sdram); } } + +/* Fill in consecutive SDRAM banks with 'ram_size' bytes of memory. +* +* sdram_bank_sizes[] must be 0-terminated. +* +* The 4xx SDRAM controller supports a small number of banks, and each bank +* must be one of a small set of sizes. The number of banks and the supported +* sizes varies by SoC. */ +ram_addr_t ppc4xx_sdram_adjust (ram_addr_t ram_size,int nr_banks, +target_phys_addr_t ram_bases[], +target_phys_addr_t ram_sizes[], +const unsigned int sdram_bank_sizes[]) +{ +ram_addr_t ram_end =0 ; +int i; +int j; + +for (i =0 ; i < nr_banks; i++) { +for (j =0 ; sdram_bank_sizes[j] !=0 ; j++) { +unsigned int bank_size = sdram_bank_sizes[j]; + +if (bank_size <= ram_size) { + ram_bases[i] = ram_end; + ram_sizes[i] = bank_size; + ram_end += bank_size; + ram_size -= bank_size; +break ; + } + } + +if (!ram_size) { +/* No need to use the remaining banks. */ +break ; + } + } + +if (ram_size) +printf ("Truncating memory to %d MiB to fit SDRAM controller limits.\n" , + (int )(ram_end >>20 )); + +return ram_end; +}Signature · 1 line
1.5.6.5
Signature · 4 lines
.''`. Aurelien Jarno | GPG: 1024D/F1BCDB73 : :' : Debian developer | Electrical Engineer `. `' [email protected] | [email protected] `- people.debian.org/~aurel32 | www.aurel32.net
PATCH 4/8 kvm: sync vcpu state during initialization
In reply to Hollis BlanchardCurrently on x86, qemu initializes CPUState but KVM ignores it and does its own vcpu initialization. However, PowerPC KVM needs to be able to set the initial register state to support the -kernel and -append options.
--- kvm-all.c | 15 +++++++++++++++ kvm.h | 1 + vl.c | 11 +++++++++++ 3 files changed, 27 insertions(+), 0 deletions(-)
kvm-all.c +15 -0
@@ -141,6 +141,21 @@ err:return ret; } +int kvm_sync_vcpus (void ) +{ +CPUState *env; + +for (env = first_cpu; env !=NULL ; env = env->next_cpu) { +int ret; + + ret =kvm_arch_put_registers (env); +if (ret) +return ret; + } + +return 0 ; +} +/* * dirty pages logging control */
kvm.h +1 -0
@@ -31,6 +31,7 @@ struct kvm_run;int kvm_init (int smp_cpus);int kvm_init_vcpu (CPUState *env); +int kvm_sync_vcpus (void );int kvm_cpu_exec (CPUState *env);
vl.c +11 -0
@@ -5456,6 +5456,17 @@ int main(int argc, char **argv, char **envp) machine->init (ram_size, vga_ram_size, boot_devices, ds, kernel_filename, kernel_cmdline, initrd_filename, cpu_model); +/* Set KVM's vcpu state to qemu's initial CPUState. */ +if (kvm_enabled ()) { +int ret; + + ret =kvm_sync_vcpus (); +if (ret <0 ) { +fprintf (stderr,"failed to initialize vcpus\n" ); +exit (1 ); + } + } +/* init USB devices */ if (usb_enabled) {for (i =0 ; i < usb_devices_index; i++) {
Signature · 1 line
1.5.6.5
Anthony Liguori
AppliedRe: [Qemu-devel] [PATCH 4/8] kvm: sync vcpu state during initialization
Quoted 6 lines · Hollis Blanchard
Currently on x86, qemu initializes CPUState but KVM ignores it and does its own vcpu initialization. However, PowerPC KVM needs to be able to set the initial register state to support the -kernel and -append options.
Signed-off-by Hollis Blanchard <[email protected]>
Applied. Thanks.
Regards,
Anthony Liguori
PATCH 5/8 Implement device tree support needed for Bamboo emulation
In reply to Hollis BlanchardTo implement the -kernel, -initrd, and -append options, 4xx board emulation must load the guest kernel as if firmware had loaded it. Where u-boot would be the firmware, we must load the flat device tree into memory and set key fields such as /chosen/bootargs.
This patch introduces a dependency on libfdt for flat device tree support.
--- Makefile.target | 4 ++ configure | 18 +++++++++ device_tree.c | 114 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ device_tree.h | 26 ++++++++++++ libfdt_env.h | 41 ++++++++++++++++++++ 5 files changed, 203 insertions(+), 0 deletions(-) create mode 100644 device_tree.c create mode 100644 device_tree.h create mode 100644 libfdt_env.h
Makefile.target +4 -0
@@ -655,6 +655,10 @@ OBJS+= heathrow_pic.o grackle_pci.o ppc_oldworld.o OBJS+= unin_pci.o ppc_chrp.o # PowerPC 4xx boards OBJS+= pflash_cfi02.o ppc4xx_devs.o ppc4xx_pci.o ppc405_uc.o ppc405_boards.o +ifdef FDT_LIBS +OBJS+= device_tree.o +LIBS+= $(FDT_LIBS) +endif # virtio support OBJS+= virtio.o virtio-blk.o virtio-balloon.o endif
configure +18 -0
@@ -119,6 +119,7 @@ kvm="yes" kerneldir="" aix="no" blobs="yes" +fdt="yes" # OS specific targetos=`uname -s`
@@ -966,6 +967,18 @@ if $cc $ARCH_CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then iovec=yes fi +########################################## +# fdt probe +if test "$fdt" = "yes" ; then + fdt=no + cat > $TMPC << EOF +int main(void) { return 0; } +EOF + if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $TMPC -lfdt 2> /dev/null ; then + fdt=yes + fi +fi + # Check if tools are available to build documentation. if [ -x "`which texi2html 2>/dev/null`" ] && \ [ -x "`which pod2man 2>/dev/null`" ]; then
@@ -1061,6 +1074,7 @@ echo "vde support $vde" echo "AIO support $aio" echo "Install blobs $blobs" echo "KVM support $kvm" +echo "fdt support $kvm" if test $sdl_too_old = "yes"; then echo "-> Your SDL version is too old - please upgrade to have SDL support"
@@ -1350,6 +1364,10 @@ fi if test "$iovec" = "yes" ; then echo "#define HAVE_IOVEC 1" >> $config_h fi +if test "$fdt" = "yes" ; then + echo "#define HAVE_FDT 1" >> $config_h + echo "FDT_LIBS=-lfdt" >> $config_mak +fi # XXX: suppress that if [ "$bsd" = "yes" ] ; then
device_tree.c new file +114 -0
114 lines not on this page · raw message
device_tree.h new file +26 -0
@@ -0,0 +1,26 @@ +/* +* Header with function prototypes to help device tree manipulation using +* libfdt. It also provides functions to read entries from device tree proc +* interface. +* +* Copyright 2008 IBM Corporation. +* Authors: Jerone Young <[email protected]> +* Hollis Blanchard <[email protected]> +* +* This work is licensed under the GNU GPL license version 2 or later. +* +*/ + +#ifndef __DEVICE_TREE_H__ +#define __DEVICE_TREE_H__ + +void *load_device_tree (const char *filename_path,void *load_addr); + +int qemu_devtree_setprop (void *fdt,const char *node_path, +const char *property,uint32_t *val_array,int size); +int qemu_devtree_setprop_cell (void *fdt,const char *node_path, +const char *property,uint32_t val); +int qemu_devtree_setprop_string (void *fdt,const char *node_path, +const char *property,const char *string); + +#endif /* __DEVICE_TREE_H__ */
libfdt_env.h new file +41 -0
41 lines not on this page · raw message
Signature · 1 line
1.5.6.5
Re: [Qemu-devel] [PATCH 5/8] Implement device tree support needed for Bamboo emulation
Quoted 66 lines · Hollis Blanchard
To implement the -kernel, -initrd, and -append options, 4xx board emulation must load the guest kernel as if firmware had loaded it. Where u-boot would be the firmware, we must load the flat device tree into memory and set key fields such as /chosen/bootargs.
This patch introduces a dependency on libfdt for flat device tree support.
Signed-off-by Hollis Blanchard <[email protected]>--- Makefile.target | 4 ++ configure | 18 +++++++++ device_tree.c | 114 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ device_tree.h | 26 ++++++++++++ libfdt_env.h | 41 ++++++++++++++++++++ 5 files changed, 203 insertions(+), 0 deletions(-) create mode 100644 device_tree.c create mode 100644 device_tree.h create mode 100644 libfdt_env.hMakefile.target +4
-0@@ -655,6 +655,10 @@ OBJS+= heathrow_pic.o grackle_pci.o ppc_oldworld.o OBJS+= unin_pci.o ppc_chrp.o # PowerPC 4xx boards OBJS+= pflash_cfi02.o ppc4xx_devs.o ppc4xx_pci.o ppc405_uc.o ppc405_boards.o +ifdef FDT_LIBS +OBJS+= device_tree.o +LIBS+= $(FDT_LIBS) +endif # virtio support OBJS+= virtio.o virtio-blk.o virtio-balloon.o endifconfigure +13
-0@@ -119,6 +119,7 @@ kvm="yes" kerneldir="" aix="no" blobs="yes" +fdt="yes" # OS specific targetos=`uname -s`@@ -966,6 +967,18 @@ if $cc $ARCH_CFLAGS -o $TMPE $TMPC > /dev/null 2> /dev/null ; then iovec=yes fi +########################################## +# fdt probe +if test "$fdt" = "yes" ; then + fdt=no + cat > $TMPC << EOF +int main(void) { return 0; } +EOF + if $cc $ARCH_CFLAGS -o $TMPE ${OS_CFLAGS} $TMPC -lfdt 2> /dev/null ; then + fdt=yes + fi +fi + # Check if tools are available to build documentation. if [ -x "`which texi2html 2>/dev/null`" ] && \ [ -x "`which pod2man 2>/dev/null`" ]; then
configure echo "vde support $vde" · line 1077
Quoted 4 lines
configure +1
-0@@ -1061,6 +1074,7 @@ echo "vde support $vde" echo "AIO support $aio" echo "Install blobs $blobs" echo "KVM support $kvm" +echo "fdt support $kvm"
This looks wrong, should probably be $fdt.
Quoted 218 lines
configure +4
-0if test $sdl_too_old = "yes"; then echo "-> Your SDL version is too old - please upgrade to have SDL support"@@ -1350,6 +1364,10 @@ fi if test "$iovec" = "yes" ; then echo "#define HAVE_IOVEC 1" >> $config_h fi +if test "$fdt" = "yes" ; then + echo "#define HAVE_FDT 1" >> $config_h + echo "FDT_LIBS=-lfdt" >> $config_mak +fi # XXX: suppress that if [ "$bsd" = "yes" ] ; thendevice_tree.c new file +114
-0@@ -0,0 +1,114 @@ +/* +* Functions to help device tree manipulation using libfdt. +* It also provides functions to read entries from device tree proc +* interface. +* +* Copyright 2008 IBM Corporation. +* Authors: Jerone Young <[email protected]> +* Hollis Blanchard <[email protected]> +* +* This work is licensed under the GNU GPL license version 2 or later. +* +*/ + +#include <stdio.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <fcntl.h> +#include <unistd.h> +#include <stdlib.h> + +#include "config.h" +#include "qemu-common.h" +#include "sysemu.h" +#include "device_tree.h" + +#include <libfdt.h> + +void *load_device_tree (const char *filename_path,void *load_addr) +{ +int dt_file_size; +int dt_file_load_size; +int new_dt_size; +int ret; +void *dt_file =NULL ; +void *fdt; + + dt_file_size =get_image_size (filename_path); +if (dt_file_size <0 ) { +printf ("Unable to get size of device tree file '%s'\n" , + filename_path); + goto fail; + } + +/* First allocate space in qemu for device tree */ + dt_file =qemu_mallocz (dt_file_size); +if (dt_file =NULL ) { +printf ("Unable to allocate memory in qemu for device tree\n" ); + goto fail; + } + + dt_file_load_size =load_image (filename_path, dt_file); + +/* Second we place new copy of 2x size in guest memory +* This give us enough room for manipulation. +*/ + new_dt_size = dt_file_size *2 ; + + fdt = load_addr; + ret =fdt_open_into (dt_file, fdt, new_dt_size); +if (ret) { +printf ("Unable to copy device tree in memory\n" ); + goto fail; + } + +/* Check sanity of device tree */ +if (fdt_check_header (fdt)) { +printf ("Device tree file loaded into memory is invalid: %s\n" , + filename_path); + goto fail; + } +/* free qemu memory with old device tree */ +qemu_free (dt_file); +return fdt; + +fail: +qemu_free (dt_file); +return NULL ; +} + +int qemu_devtree_setprop (void *fdt,const char *node_path, +const char *property,uint32_t *val_array,int size) +{ +int offset; + + offset =fdt_path_offset (fdt, node_path); +if (offset <0 ) +return offset; + +return fdt_setprop (fdt, offset, property, val_array, size); +} + +int qemu_devtree_setprop_cell (void *fdt,const char *node_path, +const char *property,uint32_t val) +{ +int offset; + + offset =fdt_path_offset (fdt, node_path); +if (offset <0 ) +return offset; + +return fdt_setprop_cell (fdt, offset, property, val); +} + +int qemu_devtree_setprop_string (void *fdt,const char *node_path, +const char *property,const char *string) +{ +int offset; + + offset =fdt_path_offset (fdt, node_path); +if (offset <0 ) +return offset; + +return fdt_setprop_string (fdt, offset, property, string); +}device_tree.h new file +26
-0@@ -0,0 +1,26 @@ +/* +* Header with function prototypes to help device tree manipulation using +* libfdt. It also provides functions to read entries from device tree proc +* interface. +* +* Copyright 2008 IBM Corporation. +* Authors: Jerone Young <[email protected]> +* Hollis Blanchard <[email protected]> +* +* This work is licensed under the GNU GPL license version 2 or later. +* +*/ + +#ifndef __DEVICE_TREE_H__ +#define __DEVICE_TREE_H__ + +void *load_device_tree (const char *filename_path,void *load_addr); + +int qemu_devtree_setprop (void *fdt,const char *node_path, +const char *property,uint32_t *val_array,int size); +int qemu_devtree_setprop_cell (void *fdt,const char *node_path, +const char *property,uint32_t val); +int qemu_devtree_setprop_string (void *fdt,const char *node_path, +const char *property,const char *string); + +#endif /* __DEVICE_TREE_H__ */ libfdt_env.h new file +41
-0@@ -0,0 +1,41 @@ +/* +* 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 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, write to the Free Software +* Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +* +* Copyright IBM Corp. 2008 +* Authors: Hollis Blanchard <[email protected]> +* +*/ + +#ifndef _LIBFDT_ENV_H +#define _LIBFDT_ENV_H + +#include <stddef.h> +#include <stdint.h> +#include <string.h> +#include <endian.h> +#include <byteswap.h> + +#if __BYTE_ORDER = __BIG_ENDIAN +#define fdt32_to_cpu (x) (x) +#define cpu_to_fdt32 (x) (x) +#define fdt64_to_cpu (x) (x) +#define cpu_to_fdt64 (x) (x) +#else +#define fdt32_to_cpu (x) (bswap_32((x))) +#define cpu_to_fdt32 (x) (bswap_32((x))) +#define fdt64_to_cpu (x) (bswap_64((x))) +#define cpu_to_fdt64 (x) (bswap_64((x))) +#endif + +#endif /* _LIBFDT_ENV_H */ Signature · 1 line
1.5.6.5
Signature · 4 lines
.''`. Aurelien Jarno | GPG: 1024D/F1BCDB73 : :' : Debian developer | Electrical Engineer `. `' [email protected] | [email protected] `- people.debian.org/~aurel32 | www.aurel32.net
PATCH 6/8 Enable KVM for ppcemb.
In reply to Hollis BlanchardImplement hooks called by generic KVM code.
Also add code that will copy the host's CPU and timebase frequencies to the guest, which is necessary on KVM because the guest can directly access the timebase.
--- Makefile.target | 3 + configure | 6 ++ target-ppc/helper.c | 5 + target-ppc/kvm.c | 204 ++++++++++++++++++++++++++++++++++++++++++++++++++ target-ppc/kvm_ppc.c | 110 +++++++++++++++++++++++++++ target-ppc/kvm_ppc.h | 15 ++++ 6 files changed, 343 insertions(+), 0 deletions(-) create mode 100644 target-ppc/kvm.c create mode 100644 target-ppc/kvm_ppc.c create mode 100644 target-ppc/kvm_ppc.h
Makefile.target +3 -0
@@ -659,6 +659,9 @@ ifdef FDT_LIBS OBJS+= device_tree.o LIBS+= $(FDT_LIBS) endif +ifdef CONFIG_KVM +OBJS+= kvm_ppc.o +endif # virtio support OBJS+= virtio.o virtio-blk.o virtio-balloon.o endif
configure +6 -0
@@ -1491,6 +1491,7 @@ gdb_xml_files="" # Make sure the target and host cpus are compatible if test "$kvm" = "yes" -a ! \( "$target_cpu" = "$cpu" -o \ + \( "$target_cpu" = "ppcemb" -a "$cpu" = "powerpc" \) -o \ \( "$target_cpu" = "x86_64" -a "$cpu" = "i386" \) -o \ \( "$target_cpu" = "i386" -a "$cpu" = "x86_64" \) \) ; then kvm="no"
@@ -1585,6 +1586,11 @@ case "$target_cpu" in echo "#define TARGET_ARCH \"ppcemb\"" >> $config_h echo "#define TARGET_PPC 1" >> $config_h echo "#define TARGET_PPCEMB 1" >> $config_h + if test "$kvm" = "yes" ; then + echo "CONFIG_KVM=yes" >> $config_mak + echo "KVM_CFLAGS=$kvm_cflags" >> $config_mak + echo "#define CONFIG_KVM 1" >> $config_h + fi ;; ppc64) echo "TARGET_ARCH=ppc64" >> $config_mak
target-ppc/helper.c +5 -0
@@ -29,6 +29,7 @@#include "exec-all.h" #include "helper_regs.h" #include "qemu-common.h" +#include "kvm.h" //#define DEBUG_MMU //#define DEBUG_BATS
@@ -2920,6 +2921,10 @@ CPUPPCState *cpu_ppc_init (const char *cpu_model) env->cpu_model_str = cpu_model;cpu_ppc_register_internal (env, def);cpu_ppc_reset (env); + +if (kvm_enabled ()) +kvm_init_vcpu (env); +return env; }
target-ppc/kvm.c new file +204 -0
204 lines not on this page · raw message
target-ppc/kvm_ppc.c new file +110 -0
110 lines not on this page · raw message
target-ppc/kvm_ppc.h new file +15 -0
@@ -0,0 +1,15 @@ +/* +* Copyright 2008 IBM Corporation. +* Authors: Hollis Blanchard <[email protected]> +* +* This work is licensed under the GNU GPL license version 2 or later. +* +*/ + +#ifndef __KVM_PPC_H__ +#define __KVM_PPC_H__ + +void kvmppc_init (void ); +void kvmppc_fdt_update (void *fdt); + +#endif /* __KVM_PPC_H__ */
Signature · 1 line
1.5.6.5
Re: [Qemu-devel] [PATCH 6/8] Enable KVM for ppcemb.
Quoted 8 lines · Hollis Blanchard
Implement hooks called by generic KVM code.
Also add code that will copy the host's CPU and timebase frequencies to the guest, which is necessary on KVM because the guest can directly access the timebase.
Signed-off-by Hollis Blanchard <[email protected]>
Regards,
Anthony Liguori
PATCH 7/8 PowerPC 440EP SoC emulation
In reply to Hollis BlanchardWire up the system-on-chip devices present on 440EP chips.
This patch is a little unusual in that qemu doesn't actually emulate the 440 core, but we use this board code with KVM (which does). If/when 440 core emulation is supported, the kvm_enabled() hack can be removed.
--- Makefile.target | 1 + hw/ppc440.c | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ hw/ppc440.h | 20 +++++++++++ 3 files changed, 124 insertions(+), 0 deletions(-) create mode 100644 hw/ppc440.c create mode 100644 hw/ppc440.h
Makefile.target +1 -0
@@ -655,6 +655,7 @@ OBJS+= heathrow_pic.o grackle_pci.o ppc_oldworld.o OBJS+= unin_pci.o ppc_chrp.o # PowerPC 4xx boards OBJS+= pflash_cfi02.o ppc4xx_devs.o ppc4xx_pci.o ppc405_uc.o ppc405_boards.o +OBJS+= ppc440.o ifdef FDT_LIBS OBJS+= device_tree.o LIBS+= $(FDT_LIBS)
hw/ppc440.c new file +103 -0
103 lines not on this page · raw message
hw/ppc440.h new file +20 -0
@@ -0,0 +1,20 @@ +/* +* Qemu PowerPC 440 board emualtion +* +* Copyright 2007 IBM Corporation. +* Authors: Jerone Young <[email protected]> +* Christian Ehrhardt <[email protected]> +* +* This work is licensed under the GNU GPL licence version 2 or later +* +*/ + +#ifndef QEMU_PPC440_H +#define QEMU_PPC440_H + +#include "hw.h" + +CPUState *ppc440ep_init (ram_addr_t *ram_size,PCIBus **pcip, +const unsigned int pci_irq_nrs[4 ],int do_init); + +#endif
Signature · 1 line
1.5.6.5
PATCH 8/8 IBM PowerPC 440EP Bamboo reference board emulation
In reply to Hollis BlanchardSince most IO devices are integrated into the 440EP chip, "Bamboo support" mostly entails implementing the -kernel, -initrd, and -append options.
These options are implemented by loading the guest as if u-boot had done it, i.e. loading a flat device tree, updating it to hold initrd addresses, ram size, and command line, and passing the FDT address in r3.
Since we use it with KVM, we enable the virtio block driver and include hooks necessary for KVM support.
--- Makefile | 2 +- Makefile.target | 2 +- hw/boards.h | 1 + hw/ppc440_bamboo.c | 190 ++++++++++++++++++++++++++++++++++++++++ pc-bios/bamboo.dtb | Bin 0 -> 3163 bytes pc-bios/bamboo.dts | 234 ++++++++++++++++++++++++++++++++++++++++++++++++++ target-ppc/machine.c | 1 + 7 files changed, 428 insertions(+), 2 deletions(-) create mode 100644 hw/ppc440_bamboo.c create mode 100644 pc-bios/bamboo.dtb create mode 100644 pc-bios/bamboo.dts
Makefile +1 -1
@@ -222,7 +222,7 @@ common de-ch es fo fr-ca hu ja mk nl-be pt sl tr ifdef INSTALL_BLOBS BLOBS=bios.bin vgabios.bin vgabios-cirrus.bin ppc_rom.bin \ video.x openbios-sparc32 openbios-sparc64 pxe-ne2k_pci.bin \ -pxe-rtl8139.bin pxe-pcnet.bin pxe-e1000.bin +pxe-rtl8139.bin pxe-pcnet.bin pxe-e1000.bin bamboo.dtb else BLOBS endif
Makefile.target +1 -1
@@ -655,7 +655,7 @@ OBJS+= heathrow_pic.o grackle_pci.o ppc_oldworld.o OBJS+= unin_pci.o ppc_chrp.o # PowerPC 4xx boards OBJS+= pflash_cfi02.o ppc4xx_devs.o ppc4xx_pci.o ppc405_uc.o ppc405_boards.o -OBJS+= ppc440.o +OBJS+= ppc440.o ppc440_bamboo.o ifdef FDT_LIBS OBJS+= device_tree.o LIBS+= $(FDT_LIBS)
hw/boards.h +1 -0
@@ -38,6 +38,7 @@ extern QEMUMachine core99_machine;extern QEMUMachine heathrow_machine;extern QEMUMachine ref405ep_machine;extern QEMUMachine taihu_machine; +extern QEMUMachine bamboo_machine;/* mips_r4k.c */ extern QEMUMachine mips_machine;
hw/ppc440_bamboo.c new file +190 -0
190 lines not on this page · raw message
pc-bios/bamboo.dtb new file binary +0 -0
zAnQWs)y1Oyrb<A4PC#>cQf54dnWuYyD0c90w%rSVeD)r2fZUÀvc@{beD6Kd8><G z*zav)eKh*I8mvKX^N6#^*<XYpv7qxJS#%~2sj64e87s((wjS4jB@T369E)r{Jb&&b zo6DWpuSLh!f<Dq_c(Sw2Y{%eoBqyFT#%b$!?ytdjz=0WQ45Gh=QFub<@wCYD^!#1@ zu410QZ;a<-pF271+O>Ut=b>l5QoG8ONt6!E-pyX^5+O^koji#s;a)Pi;)9>o>Qz zTR-qpcTPXz6z;LhIk;hUGzbs%?Fq!z{)P&E^6|R>u4c@Yb!2loj(qpX3&#ùB1w z%e+PRXx^ML&tnyD)^?dU;|cHNhHi>|t06s)rG~HpE}oBM;d^J1Js&{M-|hpqO+8~{ zfJ3l~A9;}9BA?s;2OrY<S3d525k4l1ba<R4NmHfRvSR&swudx@a##}dVU}AyvX| z_W1?jpsg4oJewNZnq4Md{Jv_eu6xpGMC1Cb*|5+Oz+$-{mcJd$!}&uLnfN7i;mGeX zudtB8c#ZLMZ3A0>48aFhò8=7SSR&3RQ1?ukrJ3-ake^n7wn{AUFn5@P#Wp7XH- zO!9vF-GRoy82B~^<}IgR8fOir-x~Z1rT$#<5FXG6pIhp_o&5Rj$6jFiVxw&x9k%Bd zEzMrM(AYYwY|l3~IpcD!^f<4~L|n-g_TbAc)Oz=!Pbh8AbdEF{o-a6$EB&NP@6QZ z)Mk|&8!KmdY*MB3tib=#C^ah9WmrU|nbfL@+Oy+z6O-Zn-A-w!l=^hE1l;0Zn#&P zkEdp$k5rvxWv(lPnCo^(qj{*$;5<QR>fyD&S$~g0C1WAO$oI~YbKJJdYs1!VW)@P zVjN9kP+#>6rkFCx7ZxYeDdD(9Hk&-G}*^5bE~e@K~mP!C=DgeX~}YgRbfm#cXCxK i$|Q^M*T}1WIZ&8I1$uSYn+BETUDa_utr4dltA7BYxVh&5
literal 0
HcmV?d00001
pc-bios/bamboo.dts new file +234 -0
234 lines not on this page · raw message
target-ppc/machine.c +1 -0
@@ -8,6 +8,7 @@ void register_machines(void)qemu_register_machine (&prep_machine);qemu_register_machine (&ref405ep_machine);qemu_register_machine (&taihu_machine); +qemu_register_machine (&bamboo_machine); }void cpu_save (QEMUFile *f,void *opaque)
Signature · 1 line
1.5.6.5
Re: [Qemu-devel] [PATCH 8/8] IBM PowerPC 440EP Bamboo reference board emulation
Quoted 1 line · Hollis Blanchard
+ * Qemu PowerPC 440 board emulation
Is this emulating an actual board, or something you invented. I'm guessing the latter, inwhich case you should say which one.
Paul