Skip to content

Commit

Permalink
Hardware convenience library
Browse files Browse the repository at this point in the history
The only target dependency for most hardware is sizeof(target_phys_addr_t).
Build these files into a convenience library, and use that instead of
building for every target.

Remove and poison various target specific macros to avoid bogus target
dependencies creeping back in.

Big/Little endian is not handled because devices should not know or care
about this to start with.

Signed-off-by: Paul Brook <[email protected]>
  • Loading branch information
Paul Brook committed May 19, 2009
1 parent 8a637d4 commit 1ad2134
Show file tree
Hide file tree
Showing 18 changed files with 248 additions and 133 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ i386
*-darwin-user
*-linux-user
*-bsd-user
libhw32
libhw64
qemu-doc.html
qemu-tech.html
qemu-doc.info
Expand Down
8 changes: 5 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Makefile for QEMU.

ifneq ($(wildcard config-host.mak),)
# Put the all: rule here so that config-host.mak can contain dependencies.
all: build-all
include config-host.mak
include $(SRC_PATH)/rules.mak
else
Expand Down Expand Up @@ -41,7 +43,7 @@ ifdef CONFIG_WIN32
LIBS+=-lwinmm -lws2_32 -liphlpapi
endif

all: $(TOOLS) $(DOCS) recurse-all
build-all: $(TOOLS) $(DOCS) recurse-all

config-host.mak: configure
ifneq ($(wildcard config-host.mak),)
Expand Down Expand Up @@ -237,14 +239,14 @@ clean:
rm -f *.o *.d *.a $(TOOLS) TAGS cscope.* *.pod *~ */*~
rm -f slirp/*.o slirp/*.d audio/*.o audio/*.d block/*.o block/*.d
$(MAKE) -C tests clean
for d in $(TARGET_DIRS); do \
for d in $(TARGET_DIRS) libhw32 libhw64; do \
$(MAKE) -C $$d $@ || exit 1 ; \
done

distclean: clean
rm -f config-host.mak config-host.h $(DOCS) qemu-options.texi
rm -f qemu-{doc,tech}.{info,aux,cp,dvi,fn,info,ky,log,pg,toc,tp,vr}
for d in $(TARGET_DIRS); do \
for d in $(TARGET_DIRS) libhw32 libhw64; do \
rm -rf $$d || exit 1 ; \
done

Expand Down
36 changes: 36 additions & 0 deletions Makefile.hw
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# Makefile for qemu target independent devices.

include config.mak
include ../config-host.mak
include $(SRC_PATH)/rules.mak

.PHONY: all

VPATH=$(SRC_PATH):$(SRC_PATH)/hw

CFLAGS += $(OS_CFLAGS) $(ARCH_CFLAGS)
LDFLAGS += $(OS_LDFLAGS) $(ARCH_LDFLAGS)

CPPFLAGS += -I. -I$(SRC_PATH) -MMD -MP -MT $@
CPPFLAGS += -D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
CPPFLAGS+=-I$(SRC_PATH)/fpu

OBJS=
OBJS+= virtio.o virtio-pci.o
OBJS+= fw_cfg.o
OBJS+= watchdog.o
OBJS+= nand.o ecc.o

OBJS+= m48t59.o

OBJS+= dma-helpers.o sysbus.o

all: $(HWLIB)

$(HWLIB): $(OBJS)

clean:
rm -f *.o *.d *.a *~

# Include automatically generated dependency files
-include $(wildcard *.d */*.d)
21 changes: 9 additions & 12 deletions Makefile.target
Original file line number Diff line number Diff line change
Expand Up @@ -485,13 +485,11 @@ endif #CONFIG_BSD_USER
# System emulator target
ifndef CONFIG_USER_ONLY

OBJS=vl.o osdep.o monitor.o pci.o loader.o isa_mmio.o machine.o dma-helpers.o \
gdbstub.o gdbstub-xml.o sysbus.o
OBJS=vl.o osdep.o monitor.o pci.o loader.o isa_mmio.o machine.o \
gdbstub.o gdbstub-xml.o
# virtio has to be here due to weird dependency between PCI and virtio-net.
# need to fix this properly
OBJS+=virtio.o virtio-pci.o
OBJS+=virtio-blk.o virtio-balloon.o virtio-net.o virtio-console.o
OBJS+=fw_cfg.o
ifdef CONFIG_KVM
OBJS+=kvm.o kvm-all.o
endif
Expand Down Expand Up @@ -564,7 +562,6 @@ OBJS += rtl8139.o
OBJS += e1000.o

# Generic watchdog support and some watchdog devices
OBJS += watchdog.o
OBJS += wdt_ib700.o wdt_i6300esb.o

ifeq ($(TARGET_BASE_ARCH), i386)
Expand All @@ -581,7 +578,7 @@ CPPFLAGS += -DHAS_AUDIO -DHAS_AUDIO_CHOICE
# shared objects
OBJS+= ppc.o ide.o vga.o $(SOUND_HW) dma.o openpic.o
# PREP target
OBJS+= pckbd.o serial.o i8259.o i8254.o fdc.o m48t59.o mc146818rtc.o
OBJS+= pckbd.o serial.o i8259.o i8254.o fdc.o mc146818rtc.o
OBJS+= prep_pci.o ppc_prep.o
# Mac shared devices
OBJS+= macio.o cuda.o adb.o mac_nvram.o mac_dbdma.o escc.o
Expand Down Expand Up @@ -624,15 +621,15 @@ OBJS+= etraxfs_eth.o
OBJS+= etraxfs_timer.o
OBJS+= etraxfs_ser.o

OBJS+= pflash_cfi02.o nand.o
OBJS+= pflash_cfi02.o
endif
ifeq ($(TARGET_BASE_ARCH), sparc)
ifeq ($(TARGET_ARCH), sparc64)
OBJS+= sun4u.o ide.o pckbd.o vga.o apb_pci.o
OBJS+= fdc.o mc146818rtc.o serial.o m48t59.o
OBJS+= fdc.o mc146818rtc.o serial.o
OBJS+= cirrus_vga.o parallel.o
else
OBJS+= sun4m.o tcx.o iommu.o m48t59.o slavio_intctl.o
OBJS+= sun4m.o tcx.o iommu.o slavio_intctl.o
OBJS+= slavio_timer.o escc.o slavio_misc.o fdc.o sparc32_dma.o
OBJS+= cs4231.o eccmemctl.o sbi.o sun4c_intctl.o
endif
Expand All @@ -648,7 +645,7 @@ OBJS+= arm-semi.o
OBJS+= pxa2xx.o pxa2xx_pic.o pxa2xx_gpio.o pxa2xx_timer.o pxa2xx_dma.o
OBJS+= pxa2xx_lcd.o pxa2xx_mmci.o pxa2xx_pcmcia.o pxa2xx_keypad.o
OBJS+= pflash_cfi01.o gumstix.o
OBJS+= zaurus.o ide.o serial.o nand.o ecc.o spitz.o tosa.o tc6393xb.o
OBJS+= zaurus.o ide.o serial.o spitz.o tosa.o tc6393xb.o
OBJS+= omap1.o omap_lcdc.o omap_dma.o omap_clk.o omap_mmc.o omap_i2c.o
OBJS+= omap2.o omap_dss.o soc_dma.o
OBJS+= omap_sx1.o palm.o tsc210x.o
Expand Down Expand Up @@ -717,8 +714,8 @@ endif
vl.o: qemu-options.h

$(QEMU_PROG): LIBS += $(SDL_LIBS) $(COCOA_LIBS) $(CURSES_LIBS) $(BRLAPI_LIBS) $(VDE_LIBS)
$(QEMU_PROG): ARLIBS=../libqemu_common.a libqemu.a
$(QEMU_PROG): $(OBJS) ../libqemu_common.a libqemu.a
$(QEMU_PROG): ARLIBS=../libqemu_common.a libqemu.a $(HWLIB)
$(QEMU_PROG): $(OBJS) ../libqemu_common.a libqemu.a $(HWLIB)
$(call LINK,$(OBJS))

endif # !CONFIG_USER_ONLY
Expand Down
33 changes: 33 additions & 0 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -1724,6 +1724,7 @@ fi
echo "TOOLS=$tools" >> $config_mak

test -f ${config_h}~ && cmp -s $config_h ${config_h}~ && mv ${config_h}~ $config_h
config_host_mak=${config_mak}

for target in $target_list; do
target_dir="$target"
Expand Down Expand Up @@ -1844,6 +1845,7 @@ case "$target_cpu" in
echo "CONFIG_XEN=yes" >> $config_mak
echo "#define CONFIG_XEN 1" >> $config_h
fi
target_phys_bits=32
;;
x86_64)
echo "TARGET_ARCH=x86_64" >> $config_mak
Expand All @@ -1865,11 +1867,13 @@ case "$target_cpu" in
echo "CONFIG_XEN=yes" >> $config_mak
echo "#define CONFIG_XEN 1" >> $config_h
fi
target_phys_bits=64
;;
alpha)
echo "TARGET_ARCH=alpha" >> $config_mak
echo "#define TARGET_ARCH \"alpha\"" >> $config_h
echo "#define TARGET_ALPHA 1" >> $config_h
target_phys_bits=64
;;
arm|armeb)
echo "TARGET_ARCH=arm" >> $config_mak
Expand All @@ -1878,44 +1882,51 @@ case "$target_cpu" in
bflt="yes"
target_nptl="yes"
gdb_xml_files="arm-core.xml arm-vfp.xml arm-vfp3.xml arm-neon.xml"
target_phys_bits=32
;;
cris)
echo "TARGET_ARCH=cris" >> $config_mak
echo "#define TARGET_ARCH \"cris\"" >> $config_h
echo "#define TARGET_CRIS 1" >> $config_h
target_nptl="yes"
target_phys_bits=32
;;
m68k)
echo "TARGET_ARCH=m68k" >> $config_mak
echo "#define TARGET_ARCH \"m68k\"" >> $config_h
echo "#define TARGET_M68K 1" >> $config_h
bflt="yes"
gdb_xml_files="cf-core.xml cf-fp.xml"
target_phys_bits=32
;;
mips|mipsel)
echo "TARGET_ARCH=mips" >> $config_mak
echo "#define TARGET_ARCH \"mips\"" >> $config_h
echo "#define TARGET_MIPS 1" >> $config_h
echo "#define TARGET_ABI_MIPSO32 1" >> $config_h
target_phys_bits=64
;;
mipsn32|mipsn32el)
echo "TARGET_ARCH=mipsn32" >> $config_mak
echo "#define TARGET_ARCH \"mipsn32\"" >> $config_h
echo "#define TARGET_MIPS 1" >> $config_h
echo "#define TARGET_ABI_MIPSN32 1" >> $config_h
target_phys_bits=64
;;
mips64|mips64el)
echo "TARGET_ARCH=mips64" >> $config_mak
echo "#define TARGET_ARCH \"mips64\"" >> $config_h
echo "#define TARGET_MIPS 1" >> $config_h
echo "#define TARGET_MIPS64 1" >> $config_h
echo "#define TARGET_ABI_MIPSN64 1" >> $config_h
target_phys_bits=64
;;
ppc)
echo "TARGET_ARCH=ppc" >> $config_mak
echo "#define TARGET_ARCH \"ppc\"" >> $config_h
echo "#define TARGET_PPC 1" >> $config_h
gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
target_phys_bits=32
;;
ppcemb)
echo "TARGET_ARCH=ppcemb" >> $config_mak
Expand All @@ -1929,6 +1940,7 @@ case "$target_cpu" in
echo "#define CONFIG_KVM 1" >> $config_h
fi
gdb_xml_files="power-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
target_phys_bits=64
;;
ppc64)
echo "TARGET_ARCH=ppc64" >> $config_mak
Expand All @@ -1937,6 +1949,7 @@ case "$target_cpu" in
echo "#define TARGET_PPC 1" >> $config_h
echo "#define TARGET_PPC64 1" >> $config_h
gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
target_phys_bits=64
;;
ppc64abi32)
echo "TARGET_ARCH=ppc64" >> $config_mak
Expand All @@ -1947,25 +1960,29 @@ case "$target_cpu" in
echo "#define TARGET_PPC64 1" >> $config_h
echo "#define TARGET_ABI32 1" >> $config_h
gdb_xml_files="power64-core.xml power-fpu.xml power-altivec.xml power-spe.xml"
target_phys_bits=64
;;
sh4|sh4eb)
echo "TARGET_ARCH=sh4" >> $config_mak
echo "#define TARGET_ARCH \"sh4\"" >> $config_h
echo "#define TARGET_SH4 1" >> $config_h
bflt="yes"
target_nptl="yes"
target_phys_bits=32
;;
sparc)
echo "TARGET_ARCH=sparc" >> $config_mak
echo "#define TARGET_ARCH \"sparc\"" >> $config_h
echo "#define TARGET_SPARC 1" >> $config_h
target_phys_bits=64
;;
sparc64)
echo "TARGET_ARCH=sparc64" >> $config_mak
echo "#define TARGET_ARCH \"sparc64\"" >> $config_h
echo "#define TARGET_SPARC 1" >> $config_h
echo "#define TARGET_SPARC64 1" >> $config_h
elfload32="yes"
target_phys_bits=64
;;
sparc32plus)
echo "TARGET_ARCH=sparc64" >> $config_mak
Expand All @@ -1975,12 +1992,19 @@ case "$target_cpu" in
echo "#define TARGET_SPARC 1" >> $config_h
echo "#define TARGET_SPARC64 1" >> $config_h
echo "#define TARGET_ABI32 1" >> $config_h
target_phys_bits=64
;;
*)
echo "Unsupported target CPU"
exit 1
;;
esac
if [ $target_phys_bits -lt $hostlongbits ] ; then
target_phys_bits=$hostlongbits
fi
echo "HWLIB=../libhw$target_phys_bits/libqemuhw$target_phys_bits.a" >> $config_mak
echo "#define TARGET_PHYS_ADDR_BITS $target_phys_bits" >> $config_h
echo "subdir-$target: subdir-libhw$target_phys_bits" >> $config_host_mak
if test "$target_bigendian" = "yes" ; then
echo "TARGET_WORDS_BIGENDIAN=yes" >> $config_mak
echo "#define TARGET_WORDS_BIGENDIAN 1" >> $config_h
Expand Down Expand Up @@ -2065,3 +2089,12 @@ if test "$source_path_used" = "yes" ; then
ln -s $source_path/$f $f
done
fi

for hwlib in 32 64; do
d=libhw$hwlib
mkdir -p $d
rm -f $d/Makefile
ln -s $source_path/Makefile.hw $d/Makefile
echo "HWLIB=libqemuhw$hwlib.a" > $d/config.mak
echo "CPPFLAGS=-DTARGET_PHYS_ADDR_BITS=$hwlib" >> $d/config.mak
done
Loading

0 comments on commit 1ad2134

Please sign in to comment.