Today's compilation fixes
cover Today's compilation fixes
Comments, anyone?
Blue Swirl (10):
pflash_cfi02: fix incorrect TARGET_FMT_lx/d use
Compile pflash_cfi02 only once
Compile pflash_cfi01 only once
Compile ide/macio only once
Compile openpic only once
Compile prep_pci only once
Compile most PPC devices only once
Compile virtio-serial-bus only once
Compile virtio-net only once
Compile virtio-blk only once
Makefile.objs | 22 ++++ Makefile.target | 27 ++--- default-configs/arm-softmmu.mak | 2 + default-configs/cris-softmmu.mak | 1 + default-configs/microblaze-softmmu.mak | 1 + default-configs/mips-softmmu.mak | 1 + default-configs/mips64-softmmu.mak | 1 + default-configs/mips64el-softmmu.mak | 1 + default-configs/mipsel-softmmu.mak | 1 + default-configs/ppc-softmmu.mak | 14 ++ default-configs/ppc64-softmmu.mak | 14 ++ default-configs/ppcemb-softmmu.mak | 14 ++ hw/etraxfs.c | 2 +- hw/flash.h | 5 +- hw/gumstix.c | 20 +++- hw/heathrow_pic.c | 4 - hw/ide/macio.c | 12 +-- hw/mac_dbdma.c | 4 - hw/mainstone.c | 13 ++- hw/mips_malta.c | 8 +- hw/mips_r4k.c | 11 ++- hw/musicpal.c | 12 ++- hw/omap_sx1.c | 16 ++- hw/openpic.c | 32 ++---- hw/petalogix_s3adsp1800_mmu.c | 2 +- hw/pflash_cfi01.c | 195 +++++++++++++++++++---------- hw/pflash_cfi02.c | 216 ++++++++++++++++++++----------- hw/ppc405_boards.c | 9 +- hw/ppce500_pci.c | 2 - hw/prep_pci.c | 8 -- hw/unin_pci.c | 4 - hw/virtio-blk.c | 6 +- hw/virtio-net.c | 14 +- hw/virtio-serial-bus.c | 16 ++-- sysemu.h | 4 - 35 files changed, 452 insertions(+), 262 deletions(-)
cover *** SUBJECT HERE ***
Quoted 1 line · Blue Swirl
Comments, anyone?
Sorry I'm late.
I don't really like the changes introduced here, because they make devices very very tied to the boards. Hopefully this could be changed one day with qdev, and patches like this make this task more complicated. One example is the openpic page size pointed out downthread.
What about something like this (doesn't change all the places affected by your series, compile-tested only)?
Paolo
Paolo Bonzini (5):
introduce a wrapper to access target properties without macros
openpic: use target_get_page_size
introduce to/from target endianness conversion functions
openpic: use to/from target endianness conversion functions ide/macio: use to/from target endianness conversion functions
Makefile.target | 2 +- arch_init.c | 26 ----------- arch_init.h | 3 - bswap.h | 28 ++++++++++++ hw/ide/macio.c | 4 +- hw/openpic.c | 36 ++++++++------- target.c | 132 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ target.h | 9 ++++ vl.c | 1 + 9 files changed, 192 insertions(+), 49 deletions(-) create mode 100644 target.c create mode 100644 target.h
Quoted 1 line
From
2e4b169850121bc0209bb3412e42218153642d91Mon Sep 17 00:00:00 2001
From: Paolo Bonzini <[email protected]>
Date: Wed, 31 Mar 2010 16:00:15 +0200
Subject: [PATCH 1/5] introduce a wrapper to access target properties without macros
I moved also some functions from arch_init.c there.
--- Makefile.target | 2 +- arch_init.c | 26 ----------------------- arch_init.h | 3 -- target.c | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ target.h | 9 ++++++++ vl.c | 1 + 6 files changed, 73 insertions(+), 30 deletions(-) create mode 100644 target.c create mode 100644 target.h
Makefile.target +1 -1
@@ -44,7 +44,7 @@ all: $(PROGS) ######################################################### # cpu emulator library -libobj-y = exec.o translate-all.o cpu-exec.o translate.o +libobj-y = exec.o translate-all.o cpu-exec.o translate.o target.o libobj-y += tcg/tcg.o libobj-$(CONFIG_SOFTFLOAT) += fpu/softfloat.o libobj-$(CONFIG_NOSOFTFLOAT) += fpu/softfloat-native.o
arch_init.c +0 -26
@@ -482,29 +482,3 @@ void cpudef_init(void)#endif } -int audio_available (void ) -{ -#ifdef HAS_AUDIO -return 1 ; -#else -return 0 ; -#endif -} - -int kvm_available (void ) -{ -#ifdef CONFIG_KVM -return 1 ; -#else -return 0 ; -#endif -} - -int xen_available (void ) -{ -#ifdef CONFIG_XEN -return 1 ; -#else -return 0 ; -#endif -}
arch_init.h +0 -3
@@ -26,8 +26,5 @@ int ram_load(QEMUFile *f, void *opaque, int version_id);void do_acpitable_option (const char *optarg);void do_smbios_option (const char *optarg);void cpudef_init (void ); -int audio_available (void ); -int kvm_available (void ); -int xen_available (void );#endif
target.c new file +62 -0
62 lines not on this page · raw message
target.h new file +9 -0
@@ -0,0 +1,9 @@ +#ifndef TARGET_H +#define TARGET_H + +unsigned long get_target_page_size (void ); +int audio_available (void ); +int kvm_available (void ); +int xen_available (void ); + +#endif
vl.c +1 -0
@@ -160,6 +160,7 @@ int main(int argc, char **argv)#include "qemu-queue.h" #include "cpus.h" #include "arch_init.h" +#include "target.h" //#define DEBUG_NET //#define DEBUG_SLIRP
Signature · 1 line
1.6.6.1
Quoted 1 line
From
415afbdec10b06aac4fea216aa13703e156d1ed7Mon Sep 17 00:00:00 2001
From: Paolo Bonzini <[email protected]>
Date: Wed, 31 Mar 2010 16:09:03 +0200
Subject: [PATCH 2/5] openpic: use target_get_page_size
--- hw/openpic.c | 22 ++++++++++++---------- 1 files changed, 12 insertions(+), 10 deletions(-)
hw/openpic.c +12 -10
@@ -36,6 +36,7 @@#include "ppc_mac.h" #include "pci.h" #include "openpic.h" +#include "target.h" //#define DEBUG_OPENPIC
@@ -141,8 +142,6 @@ enum mpic_ide_bits {#error "Please select which OpenPic implementation is to be emulated"#endif -#define OPENPIC_PAGE_SIZE 4096 -#define BF_WIDTH (_bits_) \ (((_bits_) + (sizeof(uint32_t) * 8) - 1) / (sizeof(uint32_t) * 8))
@@ -243,6 +242,7 @@ typedef struct openpic_t {int irq_ipi0;int irq_tim0;int need_swap; +unsigned long page_size;void (*reset) (void *);void (*irq_raise) (struct openpic_t *,int ,IRQ_src_t *); } openpic_t;
@@ -1233,6 +1233,7 @@ qemu_irq *openpic_init (PCIBus *bus, int *pmem_index, int nb_cpus, opp->dst[i].irqs = irqs[i]; opp->irq_out = irq_out; opp->need_swap =1 ; + opp->page_size =get_target_page_size ();register_savevm ("openpic" ,0 ,2 , openpic_save, openpic_load, opp);qemu_register_reset (openpic_reset, opp);
@@ -1370,7 +1371,7 @@ static void mpic_src_ext_write (void *opaque, target_phys_addr_t addr,if (addr &0xF )return ; - addr -=MPIC_EXT_REG_START & (OPENPIC_PAGE_SIZE -1 ); + addr -=MPIC_EXT_REG_START & (mpp->page_size -1 );if (addr <MPIC_EXT_REG_SIZE ) { idx += (addr &0xFFF0 ) >>5 ;if (addr &0x10 ) {
@@ -1394,7 +1395,7 @@ static uint32_t mpic_src_ext_read (void *opaque, target_phys_addr_t addr)if (addr &0xF )return retval; - addr -=MPIC_EXT_REG_START & (OPENPIC_PAGE_SIZE -1 ); + addr -=MPIC_EXT_REG_START & (mpp->page_size -1 );if (addr <MPIC_EXT_REG_SIZE ) { idx += (addr &0xFFF0 ) >>5 ;if (addr &0x10 ) {
@@ -1420,7 +1421,7 @@ static void mpic_src_int_write (void *opaque, target_phys_addr_t addr,if (addr &0xF )return ; - addr -=MPIC_INT_REG_START & (OPENPIC_PAGE_SIZE -1 ); + addr -=MPIC_INT_REG_START & (mpp->page_size -1 );if (addr <MPIC_INT_REG_SIZE ) { idx += (addr &0xFFF0 ) >>5 ;if (addr &0x10 ) {
@@ -1444,7 +1445,7 @@ static uint32_t mpic_src_int_read (void *opaque, target_phys_addr_t addr)if (addr &0xF )return retval; - addr -=MPIC_INT_REG_START & (OPENPIC_PAGE_SIZE -1 ); + addr -=MPIC_INT_REG_START & (mpp->page_size -1 );if (addr <MPIC_INT_REG_SIZE ) { idx += (addr &0xFFF0 ) >>5 ;if (addr &0x10 ) {
@@ -1470,7 +1471,7 @@ static void mpic_src_msg_write (void *opaque, target_phys_addr_t addr,if (addr &0xF )return ; - addr -=MPIC_MSG_REG_START & (OPENPIC_PAGE_SIZE -1 ); + addr -=MPIC_MSG_REG_START & (mpp->page_size -1 );if (addr <MPIC_MSG_REG_SIZE ) { idx += (addr &0xFFF0 ) >>5 ;if (addr &0x10 ) {
@@ -1494,7 +1495,7 @@ static uint32_t mpic_src_msg_read (void *opaque, target_phys_addr_t addr)if (addr &0xF )return retval; - addr -=MPIC_MSG_REG_START & (OPENPIC_PAGE_SIZE -1 ); + addr -=MPIC_MSG_REG_START & (mpp->page_size -1 );if (addr <MPIC_MSG_REG_SIZE ) { idx += (addr &0xFFF0 ) >>5 ;if (addr &0x10 ) {
@@ -1520,7 +1521,7 @@ static void mpic_src_msi_write (void *opaque, target_phys_addr_t addr,if (addr &0xF )return ; - addr -=MPIC_MSI_REG_START & (OPENPIC_PAGE_SIZE -1 ); + addr -=MPIC_MSI_REG_START & (mpp->page_size -1 );if (addr <MPIC_MSI_REG_SIZE ) { idx += (addr &0xFFF0 ) >>5 ;if (addr &0x10 ) {
@@ -1543,7 +1544,7 @@ static uint32_t mpic_src_msi_read (void *opaque, target_phys_addr_t addr)if (addr &0xF )return retval; - addr -=MPIC_MSI_REG_START & (OPENPIC_PAGE_SIZE -1 ); + addr -=MPIC_MSI_REG_START & (mpp->page_size -1 );if (addr <MPIC_MSI_REG_SIZE ) { idx += (addr &0xFFF0 ) >>5 ;if (addr &0x10 ) {
@@ -1688,6 +1689,7 @@ qemu_irq *mpic_init (target_phys_addr_t base, int nb_cpus, mpp->dst[i].irqs = irqs[i]; mpp->irq_out = irq_out; mpp->need_swap =0 ;/* MPIC has the same endian as target */ + mpp->page_size =get_target_page_size (); mpp->irq_raise = mpic_irq_raise; mpp->reset = mpic_reset;
Signature · 1 line
1.6.6.1
Quoted 1 line
From
329e0cdf6dc67f6334fda3f9099c70e032dae759Mon Sep 17 00:00:00 2001
From: Paolo Bonzini <[email protected]>
Date: Wed, 31 Mar 2010 15:55:55 +0200
Subject: [PATCH 3/5] introduce to/from target endianness conversion functions
--- bswap.h | 28 ++++++++++++++++++++++++ target.c | 70 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 98 insertions(+), 0 deletions(-)
bswap.h +28 -0
@@ -220,4 +220,32 @@ static inline uint32_t qemu_bswap_len(uint32_t value, int len) return bswap32(value) >> (32 - 8 * len); } + +/* conversions to target format. */ +extern uint16_t be_to_target16 (uint16_t ); +extern uint32_t be_to_target32 (uint32_t ); +extern uint64_t be_to_target64 (uint64_t ); +extern uint16_t le_to_target16 (uint16_t ); +extern uint32_t le_to_target32 (uint32_t ); +extern uint64_t le_to_target64 (uint64_t ); +extern void be_to_target16s (uint16_t *); +extern void be_to_target32s (uint32_t *); +extern void be_to_target64s (uint64_t *); +extern void le_to_target16s (uint16_t *); +extern void le_to_target32s (uint32_t *); +extern void le_to_target64s (uint64_t *); + +#define target_to_be16 be_to_target16 +#define target_to_be32 be_to_target32 +#define target_to_be64 be_to_target64 +#define target_to_le16 le_to_target16 +#define target_to_le32 le_to_target32 +#define target_to_le64 le_to_target64 +#define target_to_be16s be_to_target16s +#define target_to_be32s be_to_target32s +#define target_to_be64s be_to_target64s +#define target_to_le16s le_to_target16s +#define target_to_le32s le_to_target32s +#define target_to_le64s le_to_target64s +#endif /* BSWAP_H */
target.c +70 -0
82 lines not on this page · raw message
Signature · 1 line
1.6.6.1
Quoted 1 line
From
8a7a1e0cc770d3f2bf113475a91fc6a3772735c3Mon Sep 17 00:00:00 2001
From: Paolo Bonzini <[email protected]>
Date: Wed, 31 Mar 2010 15:56:13 +0200
Subject: [PATCH 4/5] openpic: use to/from target endianness conversion functions
--- hw/openpic.c | 14 +++++++------- 1 files changed, 7 insertions(+), 7 deletions(-)
hw/openpic.c +7 -7
@@ -241,7 +241,7 @@ typedef struct openpic_t {int max_irq;int irq_ipi0;int irq_tim0; -int need_swap; +int big_endian;unsigned long page_size;void (*reset) (void *);void (*irq_raise) (struct openpic_t *,int ,IRQ_src_t *);
@@ -249,10 +249,10 @@ typedef struct openpic_t {static inline uint32_t openpic_swap32 (openpic_t *opp,uint32_t val) { -if (opp->need_swap) -return bswap32 (val); - -return val; +if (opp->big_endian) +return be_to_target32 (val); +else +return le_to_target32 (val); }static inline void IRQ_setbit (IRQ_queue_t *q,int n_IRQ)
@@ -1232,7 +1232,7 @@ qemu_irq *openpic_init (PCIBus *bus, int *pmem_index, int nb_cpus,for (i =0 ; i < nb_cpus; i++) opp->dst[i].irqs = irqs[i]; opp->irq_out = irq_out; - opp->need_swap =1 ; + opp->big_endian =0 ; opp->page_size =get_target_page_size ();register_savevm ("openpic" ,0 ,2 , openpic_save, openpic_load, opp);
@@ -1688,7 +1688,7 @@ qemu_irq *mpic_init (target_phys_addr_t base, int nb_cpus,for (i =0 ; i < nb_cpus; i++) mpp->dst[i].irqs = irqs[i]; mpp->irq_out = irq_out; - mpp->need_swap =0 ;/* MPIC has the same endian as target */ + mpp->big_endian =1 ; mpp->page_size =get_target_page_size (); mpp->irq_raise = mpic_irq_raise;
Signature · 1 line
1.6.6.1
Quoted 1 line
From
ddf213677cfc6f1475c2ef357751ba91fdd37a42Mon Sep 17 00:00:00 2001
From: Paolo Bonzini <[email protected]>
Date: Wed, 31 Mar 2010 16:18:10 +0200
Subject: [PATCH 5/5] ide/macio: use to/from target endianness conversion functions
--- hw/ide/macio.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
hw/ide/macio.c +2 -2
@@ -225,7 +225,7 @@ static void pmac_ide_writew (void *opaque,MACIOIDEState *d = opaque; addr = (addr &0xFFF ) >>4 ; - val =bswap16 (val); + val =le_to_target16 (val);if (addr ==0 ) {ide_data_writew (&d->bus,0 , val); }
@@ -242,7 +242,7 @@ static uint32_t pmac_ide_readw (void *opaque,target_phys_addr_t addr) }else { retval =0xFFFF ; } - retval =bswap16 (retval); + retval =le_to_target16 (retval);return retval; }
Signature · 1 line
1.6.6.1
[Qemu-devel] Re: [PATCH 0/5] *** SUBJECT HERE ***
Quoted 8 lines · Paolo Bonzini
Quoted 1 line · Blue Swirl
Comments, anyone?
Sorry I'm late.
I don't really like the changes introduced here, because they make devices very very tied to the boards. Hopefully this could be changed one day with qdev, and patches like this make this task more complicated.
The real solution is to insert a byte swapping bus where needed and also make devices use some kind of memory API which goes through any buses (including byte swapping buses) in between the device and memory.
Quoted 4 lines
One example is the openpic page size pointed out downthread.
What about something like this (doesn't change all the places affected by your series, compile-tested only)?
In general (with vmport and maybe virtio as the only exceptions), the devices have no business knowing _any_ CPU properties, like page size or endianness. If there really was a device that really cared about CPU page size, the size should be also known by the board and should be passed down from there via qdev property. Byte swapping should be handled by the bus, bus controller or memory controller.
Your patch does not move things to right direction, instead the byte swapping remains at the device, so I don't think the patch should be applied.
Thank you for the comments.
Re: [Qemu-devel] Re: [PATCH 0/5] *** SUBJECT HERE ***
Quoted 20 lines · Blue Swirl
Quoted 8 lines · Paolo Bonzini
Quoted 1 line · Blue Swirl
Comments, anyone?
Sorry I'm late.
I don't really like the changes introduced here, because they make devices very very tied to the boards. Hopefully this could be changed one day with qdev, and patches like this make this task more complicated.
The real solution is to insert a byte swapping bus where needed and also make devices use some kind of memory API which goes through any buses (including byte swapping buses) in between the device and memory.
Quoted 4 lines
One example is the openpic page size pointed out downthread.
What about something like this (doesn't change all the places affected by your series, compile-tested only)?
Quoted 6 lines
In general (with vmport and maybe virtio as the only exceptions), the devices have no business knowing _any_ CPU properties, like page size or endianness. If there really was a device that really cared about CPU page size, the size should be also known by the board and should be passed down from there via qdev property. Byte swapping should be handled by the bus, bus controller or memory controller.
If the device don't have to know about any CPU properties, it's probably better to remove the wrong dependency on the CPU property, instead of hardcoding values, like for example to 4096 for the page size.
Note also that we are talking about devices that are usually part of the CPU like openpic, that's why there are really tight with the CPU.
Signature · 2 lines
Aurelien Jarno GPG: 1024D/F1BCDB73 [email protected] http://www.aurel32.net
Re: [Qemu-devel] Re: [PATCH 0/5] *** SUBJECT HERE ***
In reply to Blue SwirlQuoted 11 lines
Quoted 4 lines
One example is the openpic page size pointed out downthread.
What about something like this (doesn't change all the places affected by your series, compile-tested only)?
In general (with vmport and maybe virtio as the only exceptions), the devices have no business knowing _any_ CPU properties, like page size or endianness. If there really was a device that really cared about CPU page size, the size should be also known by the board and should be passed down from there via qdev property. Byte swapping should be handled by the bus, bus controller or memory controller.
I agree. Most of the uses of TARGET_PAGE_SIZE are simply an optimization - it's a convenient buffer size for DMA transfers. Other uses are probably incorrect.
None of virtio.c, virtio-{blk,net,serial} or virtio-{pci,syborg} should know about CPU properties. Virtio-s390 might because it's implementing magic CPU instructions.
Paul