Compare commits

..
Author SHA1 Message Date
osy 8c47277f40 slirp: update for iOS resolv fix
We cannot access /etc/resolv.conf on iOS so libslirp is modified to use
libresolv instead.
2020-10-18 22:23:15 -07:00
osy 796e701657 meson: option to build as shared library
On iOS, we cannot fork() new processes, so the best way to load QEMU into an
app is through a shared library. We add a new configure option
`--enable-shared-lib` that will build the bulk of QEMU into a shared lib.
The usual executables will then link to the library.
2020-10-18 22:23:04 -07:00
osy 53c64c6ab6 block: check availablity for preadv/pwritev on mac
macOS 11/iOS 14 added preadv/pwritev APIs. Due to weak linking, configure
will succeed with CONFIG_PREADV even when targeting a lower OS version. We
therefore need to check at run time if we can actually use these APIs.
2020-10-18 22:16:31 -07:00
osy bae2c497d8 tcg: support JIT on Apple Silicon
https://developer.apple.com/documentation/apple_silicon/porting_just-in-time_compilers_to_apple_silicon

For < iOS 14, reverse engineered functions from libsystem_pthread.dylib is
implemented to handle APRR supported SoCs.

The following rules apply for JIT write protect:
  * JIT write-protect is enabled before tcg_qemu_tb_exec()
  * JIT write-protect is disabled after tcg_qemu_tb_exec() returns
  * JIT write-protect is disabled inside do_tb_phys_invalidate() but if it
    is called inside of tcg_qemu_tb_exec() then write-protect will be
    enabled again before returning.
  * JIT write-protect is disabled by cpu_loop_exit() for interrupt handling.
  * JIT write-protect is disabled everywhere else.
2020-10-18 22:16:31 -07:00
osy 6cf2150013 tcg: mirror mapping RWX pages for iOS optional
This allows jailbroken devices with entitlements to switch the option off.
2020-10-18 22:16:31 -07:00
osy e461c3762a tcg: implement mirror mapped JIT for iOS
On iOS, we cannot allocate RWX pages without special entitlements. As a
workaround, we can allocate a RX region and then mirror map it to a separate
RX region. Then we can write to one region and execute from the other one.

We also define `tcg_mirror_ptr_rw` and `tcg_code_ptr_rw` to return a pointer
to RW memory. The difference between the RW and RX regions is stored in the
TCG context.

To ensure cache coherency, we flush the data cache in the RW mapping and
then invalidate the instruction cache in the RX mapping (where applicable).
Because data cache flush is OS defined on some architectures, we do not
provide implementations for non iOS platforms (ARM/x86).
2020-10-18 22:16:31 -07:00
osy e9a5636866 tcg: add const hints for code pointers
We will introduce mirror mapping for JIT segment with separate RX and RW
access. Adding 'const' hints will make it easier to identify read-only
accesses and allow us to easier catch bugs at compile time in the future.
2020-10-18 22:16:31 -07:00
osy 7ab2f9224d coroutine: add libucontext as external library
iOS does not support ucontext natively for aarch64 and the sigaltstack is
also unsupported (even worse, it fails silently, see:
https://openradar.appspot.com/13002712 )

As a workaround we include a library implementation of ucontext and add it
as a build option.
2020-10-18 22:16:31 -07:00
osy 262ba2d621 qemu: add support for iOS host
This introduces support for building for iOS hosts. When the correct Xcode
toolchain is used, iOS host will be detected automatically.

block: disable features not supported by iOS sandbox
slirp: disable SMB features for iOS
target: disable system() calls for iOS
tcg: use sys_icache_invalidate() instead of GCC builtin for iOS
tests: disable tests on iOS which uses system()
2020-10-18 22:15:05 -07:00
osy 6994bb30cd configure: cross-compiling without cross_prefix
The iOS toolchain does not use the host prefix naming convention. We add a
new option `--enable-cross-compile` that forces cross-compile even without
a cross_prefix.
2020-10-18 22:15:04 -07:00
osy a4cd0204bf configure: option to disable host block devices
Some hosts (iOS) have a sandboxed filesystem and do not provide low-level
APIs for interfacing with host block devices.
2020-10-18 22:15:04 -07:00
205 changed files with 3061 additions and 4666 deletions

No files matched your search

+9 -12
View File
@@ -9,11 +9,11 @@ freebsd_12_task:
install_script:
- ASSUME_ALWAYS_YES=yes pkg bootstrap -f ;
- pkg install -y bash curl cyrus-sasl git glib gmake gnutls gsed
nettle perl5 pixman pkgconf png usbredir ninja
nettle perl5 pixman pkgconf png usbredir
script:
- mkdir build
- cd build
- ../configure --enable-werror || { cat config.log meson-logs/meson-log.txt; exit 1; }
- ../configure --enable-werror || { cat config.log; exit 1; }
- gmake -j$(sysctl -n hw.ncpu)
- gmake -j$(sysctl -n hw.ncpu) check V=1
@@ -21,13 +21,13 @@ macos_task:
osx_instance:
image: catalina-base
install_script:
- brew install pkg-config python gnu-sed glib pixman make sdl2 bash ninja
- brew install pkg-config python gnu-sed glib pixman make sdl2 bash
script:
- mkdir build
- cd build
- ../configure --python=/usr/local/bin/python3 --enable-werror
--extra-cflags='-Wno-error=deprecated-declarations'
|| { cat config.log meson-logs/meson-log.txt; exit 1; }
|| { cat config.log; exit 1; }
- gmake -j$(sysctl -n hw.ncpu)
- gmake check V=1
@@ -36,12 +36,12 @@ macos_xcode_task:
# this is an alias for the latest Xcode
image: catalina-xcode
install_script:
- brew install pkg-config gnu-sed glib pixman make sdl2 bash ninja
- brew install pkg-config gnu-sed glib pixman make sdl2 bash
script:
- mkdir build
- cd build
- ../configure --extra-cflags='-Wno-error=deprecated-declarations'
--enable-werror --cc=clang || { cat config.log meson-logs/meson-log.txt; exit 1; }
--enable-werror --cc=clang || { cat config.log; exit 1; }
- gmake -j$(sysctl -n hw.ncpu)
- gmake check V=1
@@ -76,6 +76,7 @@ windows_msys2_task:
((Get-Content -path C:\tools\msys64\etc\\post-install\\07-pacman-key.post -Raw) -replace '--refresh-keys', '--version') | Set-Content -Path C:\tools\msys64\etc\\post-install\\07-pacman-key.post
C:\tools\msys64\usr\bin\bash.exe -lc "sed -i 's/^CheckSpace/#CheckSpace/g' /etc/pacman.conf"
C:\tools\msys64\usr\bin\bash.exe -lc "export"
C:\tools\msys64\usr\bin\bash.exe -lc "grep -rl 'repo.msys2.org/' /etc/pacman.d/mirrorlist.* | xargs sed -i 's/repo.msys2.org\//mirrors.tuna.tsinghua.edu.cn\/msys2\//g'"
C:\tools\msys64\usr\bin\pacman.exe --noconfirm -Sy
echo Y | C:\tools\msys64\usr\bin\pacman.exe --noconfirm -Suu --overwrite=*
taskkill /F /FI "MODULES eq msys-2.0.dll"
@@ -110,11 +111,6 @@ windows_msys2_task:
mingw-w64-x86_64-curl \
mingw-w64-x86_64-gnutls \
"
bitsadmin /transfer msys_download /dynamic /download /priority FOREGROUND `
https://repo.msys2.org/mingw/x86_64/mingw-w64-x86_64-python-sphinx-2.3.1-1-any.pkg.tar.xz `
C:\tools\mingw-w64-x86_64-python-sphinx-2.3.1-1-any.pkg.tar.xz
C:\tools\msys64\usr\bin\bash.exe -lc "pacman --noconfirm -U /c/tools/mingw-w64-x86_64-python-sphinx-2.3.1-1-any.pkg.tar.xz"
del C:\tools\mingw-w64-x86_64-python-sphinx-2.3.1-1-any.pkg.tar.xz
C:\tools\msys64\usr\bin\bash.exe -lc "rm -rf /var/cache/pacman/pkg/*"
cd C:\tools\msys64
echo "Start archive"
@@ -127,7 +123,8 @@ windows_msys2_task:
script:
- C:\tools\msys64\usr\bin\bash.exe -lc "mkdir build"
- C:\tools\msys64\usr\bin\bash.exe -lc "cd build && ../configure --python=python3"
- C:\tools\msys64\usr\bin\bash.exe -lc "cd build && ../configure
--python=python3 --ninja=ninja"
- C:\tools\msys64\usr\bin\bash.exe -lc "cd build && make -j8"
test_script:
- C:\tools\msys64\usr\bin\bash.exe -lc "cd build && make V=1 check"
+3 -3
View File
@@ -32,7 +32,7 @@ include:
../configure --enable-werror $CONFIGURE_ARGS --target-list="$TARGETS" ;
else
../configure --enable-werror $CONFIGURE_ARGS ;
fi || { cat config.log meson-logs/meson-log.txt && exit 1; }
fi
- make -j"$JOBS"
- if test -n "$MAKE_CHECK_ARGS";
then
@@ -229,7 +229,7 @@ build-tcg-disabled:
script:
- mkdir build
- cd build
- ../configure --disable-tcg --audio-drv-list="" || { cat config.log meson-logs/meson-log.txt && exit 1; }
- ../configure --disable-tcg --audio-drv-list=""
- make -j"$JOBS"
- make check-unit
- make check-qapi-schema
@@ -322,7 +322,7 @@ build-tci:
- mkdir build
- cd build
- ../configure --enable-tcg-interpreter
--target-list="$(for tg in $TARGETS; do echo -n ${tg}'-softmmu '; done)" || { cat config.log meson-logs/meson-log.txt && exit 1; }
--target-list="$(for tg in $TARGETS; do echo -n ${tg}'-softmmu '; done)"
- make -j"$JOBS"
- make run-tcg-tests-x86_64-softmmu
- make tests/qtest/boot-serial-test tests/qtest/cdrom-test tests/qtest/pxe-test
+4 -1
View File
@@ -51,7 +51,7 @@
url = https://git.qemu.org/git/edk2.git
[submodule "slirp"]
path = slirp
url = https://git.qemu.org/git/libslirp.git
url = https://github.com/utmapp/libslirp.git
[submodule "roms/opensbi"]
path = roms/opensbi
url = https://git.qemu.org/git/opensbi.git
@@ -64,3 +64,6 @@
[submodule "roms/vbootrom"]
path = roms/vbootrom
url = https://git.qemu.org/git/vbootrom.git
[submodule "libucontext"]
path = libucontext
url = https://github.com/utmapp/libucontext.git
+4 -17
View File
@@ -49,7 +49,6 @@ addons:
- libvdeplug-dev
- libvte-2.91-dev
- libzstd-dev
- ninja-build
- sparse
- uuid-dev
- gcovr
@@ -95,7 +94,7 @@ before_install:
# Configure step - may be overridden
before_script:
- mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
- ${SRC_DIR}/configure ${BASE_CONFIG} ${CONFIG} || { cat config.log meson-logs/meson-log.txt && exit 1; }
- ${SRC_DIR}/configure ${BASE_CONFIG} ${CONFIG} || { cat config.log && exit 1; }
# Main build & test - rarely overridden - controlled by TEST_CMD
script:
@@ -178,7 +177,6 @@ jobs:
addons:
apt:
packages:
- ninja-build
- python3-sphinx
- perl
@@ -199,7 +197,7 @@ jobs:
compiler: clang
before_script:
- mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
- ${SRC_DIR}/configure ${CONFIG} --extra-cflags="-fsanitize=undefined -Werror" || { cat config.log meson-logs/meson-log.txt && exit 1; }
- ${SRC_DIR}/configure ${CONFIG} --extra-cflags="-fsanitize=undefined -Werror" || { cat config.log && exit 1; }
- name: "Clang (other-softmmu)"
@@ -213,10 +211,6 @@ jobs:
# gprof/gcov are GCC features
- name: "GCC gprof/gcov"
dist: bionic
addons:
apt:
packages:
- ninja-build
env:
- CONFIG="--enable-gprof --enable-gcov --disable-libssh
--target-list=${MAIN_SOFTMMU_TARGETS}"
@@ -287,7 +281,6 @@ jobs:
- liburcu-dev
- libusb-1.0-0-dev
- libvte-2.91-dev
- ninja-build
- sparse
- uuid-dev
language: generic
@@ -298,7 +291,7 @@ jobs:
- TEST_CMD=""
before_script:
- mkdir -p ${BUILD_DIR} && cd ${BUILD_DIR}
- ${SRC_DIR}/configure ${CONFIG} --extra-cflags="-g3 -O0 -fsanitize=thread" || { cat config.log meson-logs/meson-log.txt && exit 1; }
- ${SRC_DIR}/configure ${CONFIG} --extra-cflags="-g3 -O0 -fsanitize=thread" || { cat config.log && exit 1; }
# Run check-tcg against linux-user
@@ -353,7 +346,6 @@ jobs:
- libusb-1.0-0-dev
- libvdeplug-dev
- libvte-2.91-dev
- ninja-build
# Tests dependencies
- genisoimage
env:
@@ -387,7 +379,6 @@ jobs:
- libusb-1.0-0-dev
- libvdeplug-dev
- libvte-2.91-dev
- ninja-build
# Tests dependencies
- genisoimage
env:
@@ -420,7 +411,6 @@ jobs:
- libusb-1.0-0-dev
- libvdeplug-dev
- libvte-2.91-dev
- ninja-build
# Tests dependencies
- genisoimage
env:
@@ -460,7 +450,6 @@ jobs:
- libzstd-dev
- nettle-dev
- xfslibs-dev
- ninja-build
# Tests dependencies
- genisoimage
env:
@@ -474,7 +463,6 @@ jobs:
apt_packages:
- libgcrypt20-dev
- libgnutls28-dev
- ninja-build
env:
- CONFIG="--disable-containers --disable-system"
@@ -505,7 +493,6 @@ jobs:
- libusb-1.0-0-dev
- libvdeplug-dev
- libvte-2.91-dev
- ninja-build
env:
- TEST_CMD="make check-unit"
- CONFIG="--disable-containers --disable-tcg --enable-kvm
@@ -530,7 +517,7 @@ jobs:
- ls -l ${SRC_DIR}/qemu-${QEMU_VERSION}.tar.bz2
- tar -xf ${SRC_DIR}/qemu-${QEMU_VERSION}.tar.bz2 && cd qemu-${QEMU_VERSION}
- mkdir -p release-build && cd release-build
- ../configure ${BASE_CONFIG} ${CONFIG} || { cat config.log meson-logs/meson-log.txt && exit 1; }
- ../configure ${BASE_CONFIG} ${CONFIG} || { cat config.log && exit 1; }
- make install
allow_failures:
- env: UNRELIABLE=true
+17 -17
View File
@@ -220,11 +220,11 @@ F: hw/microblaze/
F: disas/microblaze.c
MIPS TCG CPUs
M: Philippe Mathieu-Daudé <[email protected]>
M: Aleksandar Markovic <[email protected]>
R: Aurelien Jarno <[email protected]>
R: Jiaxun Yang <[email protected]>
R: Aleksandar Rikalo <[email protected]>
S: Odd Fixes
S: Maintained
F: target/mips/
F: default-configs/*mips*
F: disas/*mips*
@@ -237,6 +237,8 @@ F: include/hw/intc/mips_gic.h
F: include/hw/mips/
F: include/hw/misc/mips_*
F: include/hw/timer/mips_gictimer.h
F: tests/acceptance/linux_ssh_mips_malta.py
F: tests/acceptance/machine_mips_malta.py
F: tests/tcg/mips/
K: ^Subject:.*(?i)mips
@@ -384,6 +386,7 @@ F: target/arm/kvm.c
MIPS KVM CPUs
M: Huacai Chen <[email protected]>
M: Aleksandar Markovic <[email protected]>
S: Odd Fixes
F: target/mips/kvm.c
@@ -1120,9 +1123,10 @@ F: hw/display/jazz_led.c
F: hw/dma/rc4030.c
Malta
M: Aleksandar Markovic <[email protected]>
M: Philippe Mathieu-Daudé <[email protected]>
R: Aurelien Jarno <[email protected]>
S: Odd Fixes
S: Maintained
F: hw/isa/piix4.c
F: hw/acpi/piix4.c
F: hw/mips/malta.c
@@ -1132,12 +1136,14 @@ F: tests/acceptance/linux_ssh_mips_malta.py
F: tests/acceptance/machine_mips_malta.py
Mipssim
M: Aleksandar Markovic <[email protected]>
R: Aleksandar Rikalo <[email protected]>
S: Orphaned
S: Odd Fixes
F: hw/mips/mipssim.c
F: hw/net/mipsnet.c
R4000
M: Aleksandar Markovic <[email protected]>
R: Aurelien Jarno <[email protected]>
R: Aleksandar Rikalo <[email protected]>
S: Obsolete
@@ -1146,6 +1152,7 @@ F: hw/mips/r4k.c
Fuloong 2E
M: Huacai Chen <[email protected]>
M: Philippe Mathieu-Daudé <[email protected]>
M: Aleksandar Markovic <[email protected]>
R: Jiaxun Yang <[email protected]>
S: Odd Fixes
F: hw/mips/fuloong2e.c
@@ -1160,9 +1167,9 @@ S: Maintained
F: hw/intc/loongson_liointc.c
Boston
M: Paul Burton <paulburton@kernel.org>
M: Paul Burton <pburton@wavecomp.com>
R: Aleksandar Rikalo <[email protected]>
S: Odd Fixes
S: Maintained
F: hw/core/loader-fit.c
F: hw/mips/boston.c
F: hw/pci-host/xilinx-pcie.c
@@ -2373,18 +2380,11 @@ S: Maintained
F: include/sysemu/cryptodev*.h
F: backends/cryptodev*.c
Python library
M: John Snow <[email protected]>
M: Cleber Rosa <[email protected]>
R: Eduardo Habkost <[email protected]>
S: Maintained
F: python/
T: git https://gitlab.com/jsnow/qemu.git python
Python scripts
M: Eduardo Habkost <[email protected]>
M: Cleber Rosa <[email protected]>
S: Odd fixes
F: python/qemu/*py
F: scripts/*.py
F: tests/*.py
@@ -2823,12 +2823,12 @@ F: tcg/i386/
F: disas/i386.c
MIPS TCG target
M: Philippe Mathieu-Daudé <[email protected]>
M: Aleksandar Markovic <[email protected]>
R: Aurelien Jarno <[email protected]>
R: Huacai Chen <[email protected]>
R: Jiaxun Yang <[email protected]>
R: Aleksandar Rikalo <[email protected]>
S: Odd Fixes
S: Maintained
F: tcg/mips/
PPC TCG target
@@ -3169,7 +3169,7 @@ S: Odd Fixes
F: scripts/git-submodule.sh
UI translations
S: Orphaned
M: Aleksandar Markovic <[email protected]>
F: po/*.po
Sphinx documentation configuration and build machinery
+53 -82
View File
@@ -14,8 +14,6 @@ SRC_PATH=.
# we have explicit rules for everything
MAKEFLAGS += -rR
SHELL = /usr/bin/env bash -o pipefail
# Usage: $(call quiet-command,command and args,"NAME","args to print")
# This will run "command and args", and either:
# if V=1 just print the whole command and args
@@ -30,21 +28,13 @@ UNCHECKED_GOALS := %clean TAGS cscope ctags dist \
help check-help print-% \
docker docker-% vm-help vm-test vm-build-%
all:
.PHONY: all clean distclean recurse-all dist msi FORCE
# Don't try to regenerate Makefile or configure
# We don't generate any of them
Makefile: ;
configure: ;
# All following code might depend on configuration variables
ifneq ($(wildcard config-host.mak),)
# Put the all: rule here so that config-host.mak can contain dependencies.
all:
include config-host.mak
git-submodule-update:
.git-submodule-status: git-submodule-update config-host.mak
Makefile: .git-submodule-status
.PHONY: git-submodule-update
@@ -72,7 +62,28 @@ git-submodule-update:
endif
endif
# 0. ensure the build tree is okay
export NINJA=./ninjatool
# Running meson regenerates both build.ninja and ninjatool, and that is
# enough to prime the rest of the build.
ninjatool: build.ninja
Makefile.ninja: build.ninja ninjatool
./ninjatool -t ninja2make --omit clean dist uninstall cscope TAGS ctags < $< > $@
-include Makefile.ninja
${ninja-targets-c_COMPILER} ${ninja-targets-cpp_COMPILER}: .var.command += -MP
# If MESON is empty, the rule will be re-evaluated after Makefiles are
# reread (and MESON won't be empty anymore).
ifneq ($(MESON),)
Makefile.mtest: build.ninja scripts/mtest2make.py
$(MESON) introspect --targets --tests --benchmarks | $(PYTHON) scripts/mtest2make.py > $@
-include Makefile.mtest
endif
Makefile: .git-submodule-status
.git-submodule-status: git-submodule-update config-host.mak
# Check that we're not trying to do an out-of-tree build from
# a tree that's been used for an in-tree build.
@@ -84,21 +95,6 @@ seems to have been used for an in-tree build. You can fix this by running \
endif
endif
# force a rerun of configure if config-host.mak is too old or corrupted
ifeq ($(MESON),)
.PHONY: config-host.mak
x := $(shell rm -rf meson-private meson-info meson-logs)
endif
ifeq ($(NINJA),)
.PHONY: config-host.mak
x := $(shell rm -rf meson-private meson-info meson-logs)
endif
ifeq ($(wildcard build.ninja),)
.PHONY: config-host.mak
x := $(shell rm -rf meson-private meson-info meson-logs)
endif
# 1. ensure config-host.mak is up-to-date
config-host.mak: $(SRC_PATH)/configure $(SRC_PATH)/pc-bios $(SRC_PATH)/VERSION
@echo $@ is out-of-date, running configure
@if test -f meson-private/coredata.dat; then \
@@ -107,46 +103,6 @@ config-host.mak: $(SRC_PATH)/configure $(SRC_PATH)/pc-bios $(SRC_PATH)/VERSION
./config.status; \
fi
# 2. ensure generated build files are up-to-date
ifneq ($(NINJA),)
# A separate rule is needed for Makefile dependencies to avoid -n
export NINJA
Makefile.ninja: build.ninja
$(quiet-@){ echo 'ninja-targets = \'; $(NINJA) -t targets all | sed 's/:.*//; $$!s/$$/ \\/'; } > $@
-include Makefile.ninja
endif
ifneq ($(MESON),)
# The dependency on config-host.mak ensures that meson has run
Makefile.mtest: build.ninja scripts/mtest2make.py config-host.mak
$(MESON) introspect --targets --tests --benchmarks | $(PYTHON) scripts/mtest2make.py > $@
-include Makefile.mtest
endif
# 3. Rules to bridge to other makefiles
ifneq ($(NINJA),)
NINJAFLAGS = $(if $V,-v,) \
$(filter-out -j, $(lastword -j1 $(filter -l% -j%, $(MAKEFLAGS)))) \
$(subst -k, -k0, $(filter -n -k,$(MAKEFLAGS)))
ninja-cmd-goals = $(or $(MAKECMDGOALS), all)
ninja-cmd-goals += $(foreach t, $(.tests), $(.test.deps.$t))
makefile-targets := build.ninja ctags TAGS cscope dist clean uninstall
ninja-targets := $(filter-out $(makefile-targets), $(ninja-targets))
.PHONY: $(ninja-targets) run-ninja
$(ninja-targets): run-ninja
# Use "| cat" to give Ninja a more "make-y" output. Use "+" to bypass the
# --output-sync line.
run-ninja: config-host.mak
ifneq ($(filter $(ninja-targets), $(ninja-cmd-goals)),)
+@$(NINJA) $(NINJAFLAGS) $(sort $(filter $(ninja-targets), $(ninja-cmd-goals))) | cat
endif
endif
# Force configure to re-run if the API symbols are updated
ifeq ($(CONFIG_PLUGIN),y)
config-host.mak: $(SRC_PATH)/plugins/qemu-plugins.symbols
@@ -156,21 +112,37 @@ plugins:
$(call quiet-command,\
$(MAKE) $(SUBDIR_MAKEFLAGS) -C contrib/plugins V="$(V)", \
"BUILD", "example plugins")
endif # $(CONFIG_PLUGIN)
endif
else # config-host.mak does not exist
else
config-host.mak:
ifneq ($(filter-out $(UNCHECKED_GOALS),$(MAKECMDGOALS)),$(if $(MAKECMDGOALS),,fail))
@echo "Please call configure before running make!"
@exit 1
endif
endif # config-host.mak does not exist
endif
# Only needed in case Makefile.ninja does not exist.
.PHONY: ninja-clean ninja-distclean clean-ctlist
clean-ctlist:
ninja-clean::
ninja-distclean::
build.ninja: config-host.mak
# Don't try to regenerate Makefile or configure
# We don't generate any of them
Makefile: ;
configure: ;
.PHONY: all clean distclean install \
recurse-all dist msi FORCE
SUBDIR_MAKEFLAGS=$(if $(V),,--no-print-directory --quiet)
include $(SRC_PATH)/tests/Makefile.include
all: recurse-all
Makefile:
ROM_DIRS = $(addprefix pc-bios/, $(ROMS))
ROM_DIRS_RULES=$(foreach t, all clean, $(addsuffix /$(t), $(ROM_DIRS)))
@@ -185,9 +157,8 @@ recurse-clean: $(addsuffix /clean, $(ROM_DIRS))
######################################################################
clean: recurse-clean
-@test -f build.ninja && $(quiet-@)$(NINJA) $(NINJAFLAGS) -t clean || :
-@test -f build.ninja && $(NINJA) $(NINJAFLAGS) clean-ctlist || :
clean: recurse-clean ninja-clean clean-ctlist
if test -f ninjatool; then ./ninjatool $(if $(V),-v,) -t clean; fi
# avoid old build problems by removing potentially incorrect old files
rm -f config.mak op-i386.h opc-i386.h gen-op-i386.h op-arm.h opc-arm.h gen-op-arm.h
find . \( -name '*.so' -o -name '*.dll' -o -name '*.[oda]' \) -type f \
@@ -204,8 +175,8 @@ dist: qemu-$(VERSION).tar.bz2
qemu-%.tar.bz2:
$(SRC_PATH)/scripts/make-release "$(SRC_PATH)" "$(patsubst qemu-%.tar.bz2,%,$@)"
distclean: clean
-@test -f build.ninja && $(quiet-@)$(NINJA) $(NINJAFLAGS) -t clean -g || :
distclean: clean ninja-distclean
-test -f ninjatool && ./ninjatool $(if $(V),-v,) -t clean -g
rm -f config-host.mak config-host.h*
rm -f tests/tcg/config-*.mak
rm -f config-all-disas.mak config.status
@@ -214,7 +185,7 @@ distclean: clean
rm -f qemu-plugins-ld.symbols qemu-plugins-ld64.symbols
rm -f *-config-target.h *-config-devices.mak *-config-devices.h
rm -rf meson-private meson-logs meson-info compile_commands.json
rm -f Makefile.ninja Makefile.mtest
rm -f Makefile.ninja ninjatool ninjatool.stamp Makefile.mtest
rm -f config.log
rm -f linux-headers/asm
rm -Rf .sdk
@@ -223,19 +194,19 @@ find-src-path = find "$(SRC_PATH)/" -path "$(SRC_PATH)/meson" -prune -o -name "*
.PHONY: ctags
ctags:
rm -f "$(SRC_PATH)/"tags
$(find-src-path) -exec ctags -f "$(SRC_PATH)/"tags --append {} +
rm -f tags
$(find-src-path) -exec ctags --append {} +
.PHONY: TAGS
TAGS:
rm -f "$(SRC_PATH)/"TAGS
$(find-src-path) -exec etags -f "$(SRC_PATH)/"TAGS --append {} +
rm -f TAGS
$(find-src-path) -exec etags --append {} +
.PHONY: cscope
cscope:
rm -f "$(SRC_PATH)"/cscope.*
$(find-src-path) -print | sed -e 's,^\./,,' > "$(SRC_PATH)/cscope.files"
cscope -b -i"$(SRC_PATH)/cscope.files" -f"$(SRC_PATH)"/cscope.out
cscope -b -i"$(SRC_PATH)/cscope.files"
# Needed by "meson install"
export DESTDIR
+1 -1
View File
@@ -7,7 +7,7 @@
#include "qemu/osdep.h"
#include "sysemu/xen.h"
#include "qapi/qapi-commands-migration.h"
#include "qapi/qapi-commands-misc.h"
bool xen_allowed;
+2
View File
@@ -64,6 +64,8 @@ void cpu_reloading_memory_map(void)
void cpu_loop_exit(CPUState *cpu)
{
/* Unlock JIT write protect if applicable. */
tb_exec_unlock();
/* Undo the setting in cpu_tb_exec. */
cpu->can_do_io = 1;
siglongjmp(cpu->jmp_env, 1);
+3 -1
View File
@@ -175,7 +175,9 @@ static inline tcg_target_ulong cpu_tb_exec(CPUState *cpu, TranslationBlock *itb)
}
#endif /* DEBUG_DISAS */
tb_exec_lock();
ret = tcg_qemu_tb_exec(env, tb_ptr);
tb_exec_unlock();
cpu->can_do_io = 1;
last_tb = (TranslationBlock *)(ret & ~TB_EXIT_MASK);
tb_exit = ret & TB_EXIT_MASK;
@@ -354,7 +356,7 @@ void tb_set_jmp_target(TranslationBlock *tb, int n, uintptr_t addr)
if (TCG_TARGET_HAS_direct_jump) {
uintptr_t offset = tb->jmp_target_arg[n];
uintptr_t tc_ptr = (uintptr_t)tb->tc.ptr;
#if defined(CONFIG_MIRROR_JIT)
#if defined(CONFIG_IOS_JIT)
uintptr_t wr_addr = tc_ptr + offset + tb->code_rw_mirror_diff;
#else
uintptr_t wr_addr = tc_ptr + offset;
+9 -266
View File
@@ -409,21 +409,12 @@ void tlb_flush_all_cpus_synced(CPUState *src_cpu)
tlb_flush_by_mmuidx_all_cpus_synced(src_cpu, ALL_MMUIDX_BITS);
}
static bool tlb_hit_page_mask_anyprot(CPUTLBEntry *tlb_entry,
target_ulong page, target_ulong mask)
{
page &= mask;
mask &= TARGET_PAGE_MASK | TLB_INVALID_MASK;
return (page == (tlb_entry->addr_read & mask) ||
page == (tlb_addr_write(tlb_entry) & mask) ||
page == (tlb_entry->addr_code & mask));
}
static inline bool tlb_hit_page_anyprot(CPUTLBEntry *tlb_entry,
target_ulong page)
{
return tlb_hit_page_mask_anyprot(tlb_entry, page, -1);
return tlb_hit_page(tlb_entry->addr_read, page) ||
tlb_hit_page(tlb_addr_write(tlb_entry), page) ||
tlb_hit_page(tlb_entry->addr_code, page);
}
/**
@@ -436,45 +427,31 @@ static inline bool tlb_entry_is_empty(const CPUTLBEntry *te)
}
/* Called with tlb_c.lock held */
static bool tlb_flush_entry_mask_locked(CPUTLBEntry *tlb_entry,
target_ulong page,
target_ulong mask)
static inline bool tlb_flush_entry_locked(CPUTLBEntry *tlb_entry,
target_ulong page)
{
if (tlb_hit_page_mask_anyprot(tlb_entry, page, mask)) {
if (tlb_hit_page_anyprot(tlb_entry, page)) {
memset(tlb_entry, -1, sizeof(*tlb_entry));
return true;
}
return false;
}
static inline bool tlb_flush_entry_locked(CPUTLBEntry *tlb_entry,
target_ulong page)
{
return tlb_flush_entry_mask_locked(tlb_entry, page, -1);
}
/* Called with tlb_c.lock held */
static void tlb_flush_vtlb_page_mask_locked(CPUArchState *env, int mmu_idx,
target_ulong page,
target_ulong mask)
static inline void tlb_flush_vtlb_page_locked(CPUArchState *env, int mmu_idx,
target_ulong page)
{
CPUTLBDesc *d = &env_tlb(env)->d[mmu_idx];
int k;
assert_cpu_is_self(env_cpu(env));
for (k = 0; k < CPU_VTLB_SIZE; k++) {
if (tlb_flush_entry_mask_locked(&d->vtable[k], page, mask)) {
if (tlb_flush_entry_locked(&d->vtable[k], page)) {
tlb_n_used_entries_dec(env, mmu_idx);
}
}
}
static inline void tlb_flush_vtlb_page_locked(CPUArchState *env, int mmu_idx,
target_ulong page)
{
tlb_flush_vtlb_page_mask_locked(env, mmu_idx, page, -1);
}
static void tlb_flush_page_locked(CPUArchState *env, int midx,
target_ulong page)
{
@@ -689,240 +666,6 @@ void tlb_flush_page_all_cpus_synced(CPUState *src, target_ulong addr)
tlb_flush_page_by_mmuidx_all_cpus_synced(src, addr, ALL_MMUIDX_BITS);
}
static void tlb_flush_page_bits_locked(CPUArchState *env, int midx,
target_ulong page, unsigned bits)
{
CPUTLBDesc *d = &env_tlb(env)->d[midx];
CPUTLBDescFast *f = &env_tlb(env)->f[midx];
target_ulong mask = MAKE_64BIT_MASK(0, bits);
/*
* If @bits is smaller than the tlb size, there may be multiple entries
* within the TLB; otherwise all addresses that match under @mask hit
* the same TLB entry.
*
* TODO: Perhaps allow bits to be a few bits less than the size.
* For now, just flush the entire TLB.
*/
if (mask < f->mask) {
tlb_debug("forcing full flush midx %d ("
TARGET_FMT_lx "/" TARGET_FMT_lx ")\n",
midx, page, mask);
tlb_flush_one_mmuidx_locked(env, midx, get_clock_realtime());
return;
}
/* Check if we need to flush due to large pages. */
if ((page & d->large_page_mask) == d->large_page_addr) {
tlb_debug("forcing full flush midx %d ("
TARGET_FMT_lx "/" TARGET_FMT_lx ")\n",
midx, d->large_page_addr, d->large_page_mask);
tlb_flush_one_mmuidx_locked(env, midx, get_clock_realtime());
return;
}
if (tlb_flush_entry_mask_locked(tlb_entry(env, midx, page), page, mask)) {
tlb_n_used_entries_dec(env, midx);
}
tlb_flush_vtlb_page_mask_locked(env, midx, page, mask);
}
typedef struct {
target_ulong addr;
uint16_t idxmap;
uint16_t bits;
} TLBFlushPageBitsByMMUIdxData;
static void
tlb_flush_page_bits_by_mmuidx_async_0(CPUState *cpu,
TLBFlushPageBitsByMMUIdxData d)
{
CPUArchState *env = cpu->env_ptr;
int mmu_idx;
assert_cpu_is_self(cpu);
tlb_debug("page addr:" TARGET_FMT_lx "/%u mmu_map:0x%x\n",
d.addr, d.bits, d.idxmap);
qemu_spin_lock(&env_tlb(env)->c.lock);
for (mmu_idx = 0; mmu_idx < NB_MMU_MODES; mmu_idx++) {
if ((d.idxmap >> mmu_idx) & 1) {
tlb_flush_page_bits_locked(env, mmu_idx, d.addr, d.bits);
}
}
qemu_spin_unlock(&env_tlb(env)->c.lock);
tb_flush_jmp_cache(cpu, d.addr);
}
static bool encode_pbm_to_runon(run_on_cpu_data *out,
TLBFlushPageBitsByMMUIdxData d)
{
/* We need 6 bits to hold to hold @bits up to 63. */
if (d.idxmap <= MAKE_64BIT_MASK(0, TARGET_PAGE_BITS - 6)) {
*out = RUN_ON_CPU_TARGET_PTR(d.addr | (d.idxmap << 6) | d.bits);
return true;
}
return false;
}
static TLBFlushPageBitsByMMUIdxData
decode_runon_to_pbm(run_on_cpu_data data)
{
target_ulong addr_map_bits = (target_ulong) data.target_ptr;
return (TLBFlushPageBitsByMMUIdxData){
.addr = addr_map_bits & TARGET_PAGE_MASK,
.idxmap = (addr_map_bits & ~TARGET_PAGE_MASK) >> 6,
.bits = addr_map_bits & 0x3f
};
}
static void tlb_flush_page_bits_by_mmuidx_async_1(CPUState *cpu,
run_on_cpu_data runon)
{
tlb_flush_page_bits_by_mmuidx_async_0(cpu, decode_runon_to_pbm(runon));
}
static void tlb_flush_page_bits_by_mmuidx_async_2(CPUState *cpu,
run_on_cpu_data data)
{
TLBFlushPageBitsByMMUIdxData *d = data.host_ptr;
tlb_flush_page_bits_by_mmuidx_async_0(cpu, *d);
g_free(d);
}
void tlb_flush_page_bits_by_mmuidx(CPUState *cpu, target_ulong addr,
uint16_t idxmap, unsigned bits)
{
TLBFlushPageBitsByMMUIdxData d;
run_on_cpu_data runon;
/* If all bits are significant, this devolves to tlb_flush_page. */
if (bits >= TARGET_LONG_BITS) {
tlb_flush_page_by_mmuidx(cpu, addr, idxmap);
return;
}
/* If no page bits are significant, this devolves to tlb_flush. */
if (bits < TARGET_PAGE_BITS) {
tlb_flush_by_mmuidx(cpu, idxmap);
return;
}
/* This should already be page aligned */
d.addr = addr & TARGET_PAGE_MASK;
d.idxmap = idxmap;
d.bits = bits;
if (qemu_cpu_is_self(cpu)) {
tlb_flush_page_bits_by_mmuidx_async_0(cpu, d);
} else if (encode_pbm_to_runon(&runon, d)) {
async_run_on_cpu(cpu, tlb_flush_page_bits_by_mmuidx_async_1, runon);
} else {
TLBFlushPageBitsByMMUIdxData *p
= g_new(TLBFlushPageBitsByMMUIdxData, 1);
/* Otherwise allocate a structure, freed by the worker. */
*p = d;
async_run_on_cpu(cpu, tlb_flush_page_bits_by_mmuidx_async_2,
RUN_ON_CPU_HOST_PTR(p));
}
}
void tlb_flush_page_bits_by_mmuidx_all_cpus(CPUState *src_cpu,
target_ulong addr,
uint16_t idxmap,
unsigned bits)
{
TLBFlushPageBitsByMMUIdxData d;
run_on_cpu_data runon;
/* If all bits are significant, this devolves to tlb_flush_page. */
if (bits >= TARGET_LONG_BITS) {
tlb_flush_page_by_mmuidx_all_cpus(src_cpu, addr, idxmap);
return;
}
/* If no page bits are significant, this devolves to tlb_flush. */
if (bits < TARGET_PAGE_BITS) {
tlb_flush_by_mmuidx_all_cpus(src_cpu, idxmap);
return;
}
/* This should already be page aligned */
d.addr = addr & TARGET_PAGE_MASK;
d.idxmap = idxmap;
d.bits = bits;
if (encode_pbm_to_runon(&runon, d)) {
flush_all_helper(src_cpu, tlb_flush_page_bits_by_mmuidx_async_1, runon);
} else {
CPUState *dst_cpu;
TLBFlushPageBitsByMMUIdxData *p;
/* Allocate a separate data block for each destination cpu. */
CPU_FOREACH(dst_cpu) {
if (dst_cpu != src_cpu) {
p = g_new(TLBFlushPageBitsByMMUIdxData, 1);
*p = d;
async_run_on_cpu(dst_cpu,
tlb_flush_page_bits_by_mmuidx_async_2,
RUN_ON_CPU_HOST_PTR(p));
}
}
}
tlb_flush_page_bits_by_mmuidx_async_0(src_cpu, d);
}
void tlb_flush_page_bits_by_mmuidx_all_cpus_synced(CPUState *src_cpu,
target_ulong addr,
uint16_t idxmap,
unsigned bits)
{
TLBFlushPageBitsByMMUIdxData d;
run_on_cpu_data runon;
/* If all bits are significant, this devolves to tlb_flush_page. */
if (bits >= TARGET_LONG_BITS) {
tlb_flush_page_by_mmuidx_all_cpus_synced(src_cpu, addr, idxmap);
return;
}
/* If no page bits are significant, this devolves to tlb_flush. */
if (bits < TARGET_PAGE_BITS) {
tlb_flush_by_mmuidx_all_cpus_synced(src_cpu, idxmap);
return;
}
/* This should already be page aligned */
d.addr = addr & TARGET_PAGE_MASK;
d.idxmap = idxmap;
d.bits = bits;
if (encode_pbm_to_runon(&runon, d)) {
flush_all_helper(src_cpu, tlb_flush_page_bits_by_mmuidx_async_1, runon);
async_safe_run_on_cpu(src_cpu, tlb_flush_page_bits_by_mmuidx_async_1,
runon);
} else {
CPUState *dst_cpu;
TLBFlushPageBitsByMMUIdxData *p;
/* Allocate a separate data block for each destination cpu. */
CPU_FOREACH(dst_cpu) {
if (dst_cpu != src_cpu) {
p = g_new(TLBFlushPageBitsByMMUIdxData, 1);
*p = d;
async_run_on_cpu(dst_cpu, tlb_flush_page_bits_by_mmuidx_async_2,
RUN_ON_CPU_HOST_PTR(p));
}
}
p = g_new(TLBFlushPageBitsByMMUIdxData, 1);
*p = d;
async_safe_run_on_cpu(src_cpu, tlb_flush_page_bits_by_mmuidx_async_2,
RUN_ON_CPU_HOST_PTR(p));
}
}
/* update the TLBs so that writes to code in the virtual page 'addr'
can be detected */
void tlb_protect_code(ram_addr_t ram_addr)
+13 -17
View File
@@ -39,7 +39,7 @@ struct TCGState {
bool mttcg_enabled;
unsigned long tb_size;
bool mirror_jit;
bool mirror_rwx;
};
typedef struct TCGState TCGState;
@@ -95,11 +95,7 @@ static void tcg_accel_instance_init(Object *obj)
TCGState *s = TCG_STATE(obj);
s->mttcg_enabled = default_mttcg_enabled();
#if defined(CONFIG_MIRROR_JIT) && defined(CONFIG_DEBUG_TCG)
s->mirror_jit = true;
#else
s->mirror_jit = false;
#endif
s->mirror_rwx = false;
}
bool mttcg_enabled;
@@ -108,7 +104,7 @@ static int tcg_init(MachineState *ms)
{
TCGState *s = TCG_STATE(current_accel());
tcg_exec_init(s->tb_size * 1024 * 1024, s->mirror_jit);
tcg_exec_init(s->tb_size * 1024 * 1024, s->mirror_rwx);
mttcg_enabled = s->mttcg_enabled;
cpus_register_accel(&tcg_cpus);
@@ -174,19 +170,19 @@ static void tcg_set_tb_size(Object *obj, Visitor *v,
s->tb_size = value;
}
#ifdef CONFIG_MIRROR_JIT
static bool tcg_get_mirror_jit(Object *obj, Error **errp)
#ifdef CONFIG_IOS_JIT
static bool tcg_get_mirror_rwx(Object *obj, Error **errp)
{
TCGState *s = TCG_STATE(obj);
return s->mirror_jit;
return s->mirror_rwx;
}
static void tcg_set_mirror_jit(Object *obj, bool value, Error **errp)
static void tcg_set_mirror_rwx(Object *obj, bool value, Error **errp)
{
TCGState *s = TCG_STATE(obj);
s->mirror_jit = value;
s->mirror_rwx = value;
}
#endif
@@ -207,11 +203,11 @@ static void tcg_accel_class_init(ObjectClass *oc, void *data)
object_class_property_set_description(oc, "tb-size",
"TCG translation block cache size");
#ifdef CONFIG_MIRROR_JIT
object_class_property_add_bool(oc, "mirror-jit",
tcg_get_mirror_jit, tcg_set_mirror_jit);
object_class_property_set_description(oc, "mirror-jit",
"JIT pages mapped into separate RW and RX regions");
#ifdef CONFIG_IOS_JIT
object_class_property_add_bool(oc, "mirror-rwx",
tcg_get_mirror_rwx, tcg_set_mirror_rwx);
object_class_property_set_description(oc, "mirror-rwx",
"mirror map executable pages for TCG on iOS");
#endif
}
+122 -56
View File
@@ -27,6 +27,9 @@
#include "disas/disas.h"
#include "exec/exec-all.h"
#include "tcg/tcg.h"
#if defined(CONFIG_DARWIN)
#include "tcg/tcg-apple-jit.h"
#endif
#if defined(CONFIG_USER_ONLY)
#include "qemu.h"
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
@@ -59,7 +62,25 @@
#include "sysemu/cpus.h"
#include "sysemu/cpu-timers.h"
#include "sysemu/tcg.h"
#include "qemu/memfd.h"
#if defined(CONFIG_IOS_JIT)
#include <mach/mach.h>
extern kern_return_t mach_vm_remap(vm_map_t target_task,
mach_vm_address_t *target_address,
mach_vm_size_t size,
mach_vm_offset_t mask,
int flags,
vm_map_t src_task,
mach_vm_address_t src_address,
boolean_t copy,
vm_prot_t *cur_protection,
vm_prot_t *max_protection,
vm_inherit_t inheritance
);
#endif
static bool tb_exec_is_locked(void);
static void tb_exec_change(bool locked);
/* #define DEBUG_TB_INVALIDATE */
/* #define DEBUG_TB_FLUSH */
@@ -1027,14 +1048,14 @@ static inline void *split_cross_256mb(void *buf1, size_t size1)
static uint8_t static_code_gen_buffer[DEFAULT_CODE_GEN_BUFFER_SIZE]
__attribute__((aligned(CODE_GEN_ALIGN)));
static inline void *alloc_code_gen_buffer(bool mirror_jit)
static inline void *alloc_code_gen_buffer(bool no_rwx_pages)
{
void *buf = static_code_gen_buffer;
void *end = static_code_gen_buffer + sizeof(static_code_gen_buffer);
size_t size;
/* not applicable */
assert(!mirror_jit);
assert(!no_rwx_pages);
/* page-align the beginning and end of the buffer */
buf = QEMU_ALIGN_PTR_UP(buf, qemu_real_host_page_size);
@@ -1064,45 +1085,33 @@ static inline void *alloc_code_gen_buffer(bool mirror_jit)
return buf;
}
#elif defined(_WIN32)
static inline void *alloc_code_gen_buffer(bool mirror_jit)
static inline void *alloc_code_gen_buffer(bool no_rwx_pages)
{
size_t size = tcg_ctx->code_gen_buffer_size;
assert(!mirror_jit); /* not applicable */
assert(!no_rwx_pages); /* not applicable */
return VirtualAlloc(NULL, size, MEM_RESERVE | MEM_COMMIT,
PAGE_EXECUTE_READWRITE);
}
#else
static inline void *alloc_code_gen_buffer(bool mirror_jit)
static inline void *alloc_code_gen_buffer(bool no_rwx_pages)
{
int prot = PROT_READ | PROT_EXEC;
int flags = 0;
int flags = MAP_PRIVATE | MAP_ANONYMOUS;
size_t size = tcg_ctx->code_gen_buffer_size;
int fd = -1;
void *buf;
#if defined(CONFIG_MIRROR_JIT)
#if defined(CONFIG_LINUX)
if (mirror_jit) {
fd = qemu_memfd_create("tcg-jit", size, false, 0, 0, NULL);
if (fd < 0) {
return NULL;
}
tcg_ctx->code_gen_buffer_fd = fd;
flags |= MAP_SHARED;
} else {
#if defined(CONFIG_DARWIN) /* both iOS and macOS (Apple Silicon) applicable */
if (!no_rwx_pages) {
prot |= PROT_WRITE;
flags |= MAP_ANONYMOUS | MAP_PRIVATE;
flags |= MAP_JIT;
}
#else /* defined(CONFIG_LINUX) */
#error "Mirror JIT unimplemented for this platform."
#endif /* defined(CONFIG_LINUX) */
#else /* defined(CONFIG_MIRROR_JIT) */
assert(!mirror_jit);
#else
/* not applicable */
assert(!no_rwx_pages);
prot |= PROT_WRITE;
flags |= MAP_ANONYMOUS | MAP_PRIVATE;
#endif /* defined(CONFIG_MIRROR_JIT) */
#endif
buf = mmap(NULL, size, prot, flags, fd, 0);
buf = mmap(NULL, size, prot, flags, -1, 0);
if (buf == MAP_FAILED) {
return NULL;
}
@@ -1148,53 +1157,65 @@ static inline void *alloc_code_gen_buffer(bool mirror_jit)
}
#endif /* USE_STATIC_CODE_GEN_BUFFER, WIN32, POSIX */
#if defined(CONFIG_MIRROR_JIT)
#if defined(CONFIG_LINUX)
static inline void *alloc_jit_rw_mirror(void)
#if defined(CONFIG_IOS_JIT)
static inline void *alloc_jit_rw_mirror(void *base, size_t size)
{
int fd = tcg_ctx->code_gen_buffer_fd;
size_t size = tcg_ctx->code_gen_buffer_size;
void *buf;
kern_return_t ret;
mach_vm_address_t mirror;
vm_prot_t cur_prot, max_prot;
assert(fd >= 0);
buf = mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
if (buf == MAP_FAILED) {
mirror = 0;
ret = mach_vm_remap(mach_task_self(),
&mirror,
size,
0,
VM_FLAGS_ANYWHERE | VM_FLAGS_RANDOM_ADDR,
mach_task_self(),
(mach_vm_address_t)base,
false,
&cur_prot,
&max_prot,
VM_INHERIT_NONE
);
if (ret != KERN_SUCCESS) {
return NULL;
}
return buf;
}
#else
#error "Mirror JIT unimplemented for this platform."
#endif /* CONFIG_IOS */
#endif /* CONFIG_MIRROR_JIT */
if (mprotect((void *)mirror, size, PROT_READ | PROT_WRITE) != 0) {
munmap((void *)mirror, size);
return NULL;
}
static inline void code_gen_alloc(size_t tb_size, bool mirror_jit)
return (void *)mirror;
}
#endif /* CONFIG_IOS_JIT */
static inline void code_gen_alloc(size_t tb_size, bool mirror_rwx)
{
tcg_ctx->code_gen_buffer_size = size_code_gen_buffer(tb_size);
tcg_ctx->code_gen_buffer = alloc_code_gen_buffer(mirror_jit);
tcg_ctx->code_gen_buffer = alloc_code_gen_buffer(mirror_rwx);
if (tcg_ctx->code_gen_buffer == NULL) {
fprintf(stderr, "Could not allocate dynamic translator buffer\n");
exit(1);
}
#if defined(CONFIG_MIRROR_JIT)
#if defined(CONFIG_IOS_JIT)
void *mirror;
if (mirror_jit) {
/* For platforms that need a mirror mapping for code execution */
mirror = alloc_jit_rw_mirror();
if (mirror_rwx) {
/* For iOS JIT we need a mirror mapping for code execution */
mirror = alloc_jit_rw_mirror(tcg_ctx->code_gen_buffer,
tcg_ctx->code_gen_buffer_size
);
if (mirror == NULL) {
fprintf(stderr, "Could not remap code buffer mirror\n");
exit(1);
}
} else {
/* If we disable mirror mapping run option */
/* If we have JIT entitlements */
mirror = tcg_ctx->code_gen_buffer;
}
tcg_ctx->code_rw_mirror_diff = mirror - tcg_ctx->code_gen_buffer;
#else
assert(!mirror_jit);
#endif /* CONFIG_MIRROR_JIT */
#endif /* CONFIG_IOS_JIT */
}
static bool tb_cmp(const void *ap, const void *bp)
@@ -1221,15 +1242,16 @@ static void tb_htable_init(void)
/*
* Must be called before using the QEMU cpus. 'tb_size' is the size
* (in bytes) allocated to the translation buffer. Zero means default
* size. mirror_jit separates RX and RW allocations.
* size. mirror_rwx only applicable on iOS.
*/
void tcg_exec_init(unsigned long tb_size, bool mirror_jit)
void tcg_exec_init(unsigned long tb_size, bool mirror_rwx)
{
tcg_allowed = true;
cpu_gen_init();
page_init();
tb_htable_init();
code_gen_alloc(tb_size, mirror_jit);
code_gen_alloc(tb_size, mirror_rwx);
tb_exec_unlock();
#if defined(CONFIG_SOFTMMU)
/* There's no guest base to take into account, so go ahead and
initialize the prologue now. */
@@ -1506,8 +1528,11 @@ static void do_tb_phys_invalidate(TranslationBlock *tb, bool rm_from_page_list)
PageDesc *p;
uint32_t h;
tb_page_addr_t phys_pc;
bool code_gen_locked;
assert_memory_lock();
code_gen_locked = tb_exec_is_locked();
tb_exec_unlock();
/* make sure no further incoming jumps will be chained to this TB */
qemu_spin_lock(&tb->jmp_lock);
@@ -1520,6 +1545,7 @@ static void do_tb_phys_invalidate(TranslationBlock *tb, bool rm_from_page_list)
tb->trace_vcpu_dstate);
if (!(tb->cflags & CF_NOCACHE) &&
!qht_remove(&tb_ctx.htable, tb, h)) {
tb_exec_change(code_gen_locked);
return;
}
@@ -1552,6 +1578,8 @@ static void do_tb_phys_invalidate(TranslationBlock *tb, bool rm_from_page_list)
qatomic_set(&tcg_ctx->tb_phys_invalidate_count,
tcg_ctx->tb_phys_invalidate_count + 1);
tb_exec_change(code_gen_locked);
}
static void tb_phys_invalidate__locked(TranslationBlock *tb)
@@ -1792,7 +1820,7 @@ TranslationBlock *tb_gen_code(CPUState *cpu,
cpu_loop_exit(cpu);
}
#if defined(CONFIG_MIRROR_JIT)
#if defined(CONFIG_IOS_JIT)
tb->code_rw_mirror_diff = tcg_ctx->code_rw_mirror_diff;
#endif
gen_code_buf = tcg_ctx->code_gen_ptr;
@@ -2792,3 +2820,41 @@ void tcg_flush_softmmu_tlb(CPUState *cs)
tlb_flush(cs);
#endif
}
#if defined(CONFIG_DARWIN) && !defined(CONFIG_TCG_INTERPRETER)
static bool tb_exec_is_locked(void)
{
return tcg_ctx->code_gen_locked;
}
static void tb_exec_change(bool locked)
{
#if defined(HAVE_PTHREAD_JIT_PROTECT)
if (__builtin_available(macOS 11, iOS 14, watchOS 7, tvOS 14, *)) {
pthread_jit_write_protect_np(locked);
} else
#endif
if (jit_write_protect_supported()) {
jit_write_protect(locked);
}
tcg_ctx->code_gen_locked = locked;
}
#else /* not needed on non-Darwin platforms */
static bool tb_exec_is_locked(void)
{
return false;
}
static void tb_exec_change(bool locked) {}
#endif
void tb_exec_lock(void)
{
/* assumes sys_icache_invalidate already called */
tb_exec_change(true);
}
void tb_exec_unlock(void)
{
tb_exec_change(false);
}
+2 -2
View File
@@ -106,7 +106,7 @@ static int line_out_init(HWVoiceOut *hw, struct audsettings *as,
out->active = 0;
out->sin.base.sif = &playback_sif.base;
qemu_spice.add_interface(&out->sin.base);
qemu_spice_add_interface (&out->sin.base);
#if SPICE_INTERFACE_PLAYBACK_MAJOR > 1 || SPICE_INTERFACE_PLAYBACK_MINOR >= 3
spice_server_set_playback_rate(&out->sin, settings.freq);
#endif
@@ -215,7 +215,7 @@ static int line_in_init(HWVoiceIn *hw, struct audsettings *as, void *drv_opaque)
in->active = 0;
in->sin.base.sif = &record_sif.base;
qemu_spice.add_interface(&in->sin.base);
qemu_spice_add_interface (&in->sin.base);
#if SPICE_INTERFACE_RECORD_MAJOR > 2 || SPICE_INTERFACE_RECORD_MINOR >= 3
spice_server_set_record_rate(&in->sin, settings.freq);
#endif
+1 -1
View File
@@ -53,7 +53,7 @@
#ifdef CONFIG_BSD
#include <sys/ioctl.h>
#include <sys/queue.h>
#ifndef __DragonFly__
#if !defined(__DragonFly__) && !defined(CONFIG_IOS)
#include <sys/disk.h>
#endif
#endif
+37 -13
View File
@@ -41,7 +41,7 @@
#include "scsi/pr-manager.h"
#include "scsi/constants.h"
#if defined(__APPLE__) && (__MACH__)
#if defined(CONFIG_HOST_BLOCK_DEVICE) && defined(__APPLE__) && (__MACH__)
#include <paths.h>
#include <sys/param.h>
#include <IOKit/IOKitLib.h>
@@ -181,7 +181,16 @@ typedef struct BDRVRawReopenState {
bool check_cache_dropped;
} BDRVRawReopenState;
static int fd_open(BlockDriverState *bs);
static int fd_open(BlockDriverState *bs)
{
BDRVRawState *s = bs->opaque;
/* this is just to ensure s->fd is sane (its called by io ops) */
if (s->fd >= 0)
return 0;
return -EIO;
}
static int64_t raw_getlength(BlockDriverState *bs);
typedef struct RawPosixAIOData {
@@ -252,6 +261,12 @@ static int raw_normalize_devicepath(const char **filename, Error **errp)
}
#endif
#if defined(CONFIG_IOS)
static int probe_logical_blocksize(int fd, unsigned int *sector_size_p)
{
return -ENOTSUP; /* not supported on iOS */
}
#else /* CONFIG_IOS */
/*
* Get logical block size via ioctl. On success store it in @sector_size_p.
*/
@@ -284,6 +299,7 @@ static int probe_logical_blocksize(int fd, unsigned int *sector_size_p)
return success ? 0 : -errno;
}
#endif /* !CONFIG_IOS */
/**
* Get physical block size of @fd.
@@ -1377,12 +1393,24 @@ static bool preadv_present = true;
static ssize_t
qemu_preadv(int fd, const struct iovec *iov, int nr_iov, off_t offset)
{
#ifdef CONFIG_DARWIN /* preadv introduced in macOS 11 */
if (!__builtin_available(macOS 11, iOS 14, watchOS 7, tvOS 14, *)) {
preadv_present = false;
return -ENOSYS;
} else
#endif
return preadv(fd, iov, nr_iov, offset);
}
static ssize_t
qemu_pwritev(int fd, const struct iovec *iov, int nr_iov, off_t offset)
{
#ifdef CONFIG_DARWIN /* pwritev introduced in macOS 11 */
if (!__builtin_available(macOS 11, iOS 14, watchOS 7, tvOS 14, *)) {
preadv_present = false;
return -ENOSYS;
} else
#endif
return pwritev(fd, iov, nr_iov, offset);
}
@@ -2306,7 +2334,7 @@ again:
}
if (size == 0)
#endif
#if defined(__APPLE__) && defined(__MACH__)
#if !defined(CONFIG_IOS) && defined(__APPLE__) && defined(__MACH__)
{
uint64_t sectors = 0;
uint32_t sector_size = 0;
@@ -3247,6 +3275,8 @@ BlockDriver bdrv_file = {
/***********************************************/
/* host device */
#if defined(CONFIG_HOST_BLOCK_DEVICE)
#if defined(__APPLE__) && defined(__MACH__)
static kern_return_t GetBSDPath(io_iterator_t mediaIterator, char *bsdPath,
CFIndex maxPathSize, int flags);
@@ -3539,16 +3569,6 @@ hdev_co_ioctl(BlockDriverState *bs, unsigned long int req, void *buf)
}
#endif /* linux */
static int fd_open(BlockDriverState *bs)
{
BDRVRawState *s = bs->opaque;
/* this is just to ensure s->fd is sane (its called by io ops) */
if (s->fd >= 0)
return 0;
return -EIO;
}
static coroutine_fn int
hdev_co_pdiscard(BlockDriverState *bs, int64_t offset, int bytes)
{
@@ -3872,6 +3892,8 @@ static BlockDriver bdrv_host_cdrom = {
};
#endif /* __FreeBSD__ */
#endif /* CONFIG_HOST_BLOCK_DEVICE */
static void bdrv_file_init(void)
{
/*
@@ -3879,6 +3901,7 @@ static void bdrv_file_init(void)
* registered last will get probed first.
*/
bdrv_register(&bdrv_file);
#if defined(CONFIG_HOST_BLOCK_DEVICE)
bdrv_register(&bdrv_host_device);
#ifdef __linux__
bdrv_register(&bdrv_host_cdrom);
@@ -3886,6 +3909,7 @@ static void bdrv_file_init(void)
#if defined(__FreeBSD__) || defined(__FreeBSD_kernel__)
bdrv_register(&bdrv_host_cdrom);
#endif
#endif /* CONFIG_HOST_BLOCK_DEVICE */
}
block_init(bdrv_file_init);
+1 -1
View File
@@ -110,7 +110,7 @@ static void vmc_register_interface(SpiceChardev *scd)
return;
}
scd->sin.base.sif = &vmc_interface.base;
qemu_spice.add_interface(&scd->sin.base);
qemu_spice_add_interface(&scd->sin.base);
scd->active = true;
trace_spice_vmc_register_interface(scd);
}
Vendored
+194 -39
View File
@@ -234,6 +234,7 @@ cpu=""
iasl="iasl"
interp_prefix="/usr/gnemul/qemu-%M"
static="no"
cross_compile="no"
cross_prefix=""
audio_drv_list=""
block_drv_rw_whitelist=""
@@ -297,13 +298,12 @@ brlapi=""
curl=""
iconv="auto"
curses="auto"
docs="auto"
docs=""
fdt="auto"
netmap="no"
sdl="auto"
sdl_image="auto"
virtfs=""
libudev="auto"
mpath="auto"
vnc="enabled"
sparse="auto"
@@ -448,7 +448,8 @@ meson=""
ninja=""
skip_meson=no
gettext=""
mirror_jit="no"
host_block_device_support="yes"
shared_lib="false"
bogus_os="no"
malloc_trim="auto"
@@ -458,6 +459,11 @@ for opt do
optarg=$(expr "x$opt" : 'x[^=]*=\(.*\)')
case "$opt" in
--cross-prefix=*) cross_prefix="$optarg"
cross_compile="yes"
;;
--enable-cross-compile) cross_compile="yes"
;;
--disable-cross-compile) cross_compile="no"
;;
--cc=*) CC="$optarg"
;;
@@ -539,6 +545,8 @@ QEMU_CFLAGS="-fno-strict-aliasing -fno-common -fwrapv $QEMU_CFLAGS"
QEMU_CFLAGS="-Wundef -Wwrite-strings -Wmissing-prototypes $QEMU_CFLAGS"
QEMU_CFLAGS="-Wstrict-prototypes -Wredundant-decls $QEMU_CFLAGS"
QEMU_CFLAGS="-D_GNU_SOURCE -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE $QEMU_CFLAGS"
QEMU_INCLUDES="-iquote . -iquote ${source_path} -iquote ${source_path}/accel/tcg -iquote ${source_path}/include"
QEMU_INCLUDES="$QEMU_INCLUDES -iquote ${source_path}/disas/libvixl"
# Flags that are needed during configure but later taken care of by Meson
CONFIGURE_CFLAGS="-std=gnu99 -Wall"
@@ -555,6 +563,19 @@ EOF
compile_object
}
check_ios() {
cat > $TMPC <<EOF
#ifdef __APPLE__
#import "TargetConditionals.h"
#if !TARGET_OS_IPHONE
#error TARGET_OS_IPHONE not true
#endif
#endif
int main(void) { return 0; }
EOF
compile_object
}
check_include() {
cat > $TMPC <<EOF
#include <$1>
@@ -597,7 +618,11 @@ elif check_define __DragonFly__ ; then
elif check_define __NetBSD__; then
targetos='NetBSD'
elif check_define __APPLE__; then
targetos='Darwin'
if check_ios ; then
targetos='iOS'
else
targetos='Darwin'
fi
else
# This is a fatal error, but don't report it yet, because we
# might be going to just print the --help text, or it might
@@ -774,6 +799,22 @@ Darwin)
# won't work when we're compiling with gcc as a C compiler.
QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
;;
iOS)
bsd="yes"
darwin="yes"
ios="yes"
if [ "$cpu" = "x86_64" ] ; then
QEMU_CFLAGS="-arch x86_64 $QEMU_CFLAGS"
QEMU_LDFLAGS="-arch x86_64 $QEMU_LDFLAGS"
fi
host_block_device_support="no"
audio_drv_list=""
audio_possible_drivers=""
QEMU_LDFLAGS="-framework CoreFoundation $QEMU_LDFLAGS"
# Disable attempts to use ObjectiveC features in os/object.h since they
# won't work when we're compiling with gcc as a C compiler.
QEMU_CFLAGS="-DOS_OBJECT_USE_OBJC=0 $QEMU_CFLAGS"
;;
SunOS)
solaris="yes"
make="${MAKE-gmake}"
@@ -796,6 +837,7 @@ Linux)
audio_possible_drivers="oss alsa sdl pa"
linux="yes"
linux_user="yes"
QEMU_INCLUDES="-isystem ${source_path}/linux-headers -Ilinux-headers $QEMU_INCLUDES"
;;
esac
@@ -821,6 +863,15 @@ do
fi
done
sphinx_build=
for binary in sphinx-build-3 sphinx-build
do
if has "$binary"
then
sphinx_build=$(command -v "$binary")
break
fi
done
# Check for ancillary tools used in testing
genisoimage=
@@ -868,6 +919,10 @@ for opt do
;;
--cross-prefix=*)
;;
--enable-cross-compile)
;;
--disable-cross-compile)
;;
--cc=*)
;;
--host-cc=*) host_cc="$optarg"
@@ -961,7 +1016,7 @@ for opt do
;;
--with-suffix=*) qemu_suffix="$optarg"
;;
--docdir=*) docdir="$optarg"
--docdir=*) qemu_docdir="$optarg"
;;
--sysconfdir=*) sysconfdir="$optarg"
;;
@@ -995,10 +1050,6 @@ for opt do
;;
--enable-virtfs) virtfs="yes"
;;
--disable-libudev) libudev="disabled"
;;
--enable-libudev) libudev="enabled"
;;
--disable-mpath) mpath="disabled"
;;
--enable-mpath) mpath="enabled"
@@ -1220,9 +1271,9 @@ for opt do
;;
--disable-crypto-afalg) crypto_afalg="no"
;;
--disable-docs) docs="disabled"
--disable-docs) docs="no"
;;
--enable-docs) docs="enabled"
--enable-docs) docs="yes"
;;
--disable-vhost-net) vhost_net="no"
;;
@@ -1514,6 +1565,10 @@ for opt do
;;
--disable-libdaxctl) libdaxctl=no
;;
--enable-shared-lib) shared_lib=true
;;
--disable-shared-lib) shared_lib=false
;;
*)
echo "ERROR: unknown option $opt"
echo "Try '$0 --help' for more information"
@@ -1681,6 +1736,7 @@ Advanced options (experts only):
--efi-aarch64=PATH PATH of efi file to use for aarch64 VMs.
--with-suffix=SUFFIX suffix for QEMU data inside datadir/libdir/sysconfdir/docdir [$qemu_suffix]
--with-pkgversion=VERS use specified string as sub-version of the package
--enable-cross-compile enable cross compiling (set automatically if $cross_prefix is set)
--enable-debug enable common debug build options
--enable-sanitizers enable default sanitizers
--enable-tsan enable thread sanitizer
@@ -1706,7 +1762,7 @@ Advanced options (experts only):
--oss-lib path to OSS library
--cpu=CPU Build for host CPU [$cpu]
--with-coroutine=BACKEND coroutine backend. Supported options:
ucontext, sigaltstack, windows
ucontext, libucontext, sigaltstack, windows
--enable-gcov enable test coverage analysis with gcov
--disable-blobs disable installing provided firmware blobs
--with-vss-sdk=SDK-path enable Windows VSS support in QEMU Guest Agent
@@ -1720,6 +1776,7 @@ Advanced options (experts only):
enable plugins via shared library loading
--disable-containers don't use containers for cross-building
--gdb=GDB-path gdb to use for gdbstub tests [$gdb_bin]
--enable-shared-lib build QEMU as a shared library
Optional features, enabled with --enable-FEATURE and
disabled with --disable-FEATURE, default is enabled if available:
@@ -1756,7 +1813,6 @@ disabled with --disable-FEATURE, default is enabled if available:
vnc-png PNG compression for VNC server
cocoa Cocoa UI (Mac OS X only)
virtfs VirtFS
libudev Use libudev to enumerate host devices
mpath Multipath persistent reservation passthrough
xen xen backend driver support
xen-pci-passthrough PCI passthrough support for Xen
@@ -1861,7 +1917,7 @@ python_version=$($python -c 'import sys; print("%d.%d.%d" % (sys.version_info[0]
python="$python -B"
if test -z "$meson"; then
if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.55.3; then
if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.55.1; then
meson=meson
elif test -e "${source_path}/.git" && test $git_update = 'yes' ; then
meson=git
@@ -1903,7 +1959,7 @@ case "$meson" in
*) meson=$(command -v "$meson") ;;
esac
# Probe for ninja
# Probe for ninja (used for compdb)
if test -z "$ninja"; then
for c in ninja ninja-build samu; do
@@ -1912,9 +1968,6 @@ if test -z "$ninja"; then
break
fi
done
if test -z "$ninja"; then
error_exit "Cannot find Ninja"
fi
fi
# Check that the C compiler works. Doing this here before testing
@@ -2533,7 +2586,7 @@ if test "$xen" != "disabled" ; then
xen_ctrl_version="$(printf '%d%02d%02d' \
$($pkg_config --modversion xencontrol | sed 's/\./ /g') )"
xen=enabled
xen_pc="xencontrol xenstore xenforeignmemory xengnttab"
xen_pc="xencontrol xenstore xenguest xenforeignmemory xengnttab"
xen_pc="$xen_pc xenevtchn xendevicemodel"
if $pkg_config --exists xentoolcore; then
xen_pc="$xen_pc xentoolcore"
@@ -2542,7 +2595,7 @@ if test "$xen" != "disabled" ; then
xen_libs="$($pkg_config --libs $xen_pc)"
else
xen_libs="-lxenstore -lxenctrl"
xen_libs="-lxenstore -lxenctrl -lxenguest"
xen_stable_libs="-lxenforeignmemory -lxengnttab -lxenevtchn"
# First we test whether Xen headers and libraries are available.
@@ -4411,6 +4464,45 @@ if check_include linux/btrfs.h ; then
btrfs=yes
fi
# If we're making warnings fatal, apply this to Sphinx runs as well
sphinx_werror=""
if test "$werror" = "yes"; then
sphinx_werror="-W"
fi
# Check we have a new enough version of sphinx-build
has_sphinx_build() {
# This is a bit awkward but works: create a trivial document and
# try to run it with our configuration file (which enforces a
# version requirement). This will fail if either
# sphinx-build doesn't exist at all or if it is too old.
mkdir -p "$TMPDIR1/sphinx"
touch "$TMPDIR1/sphinx/index.rst"
"$sphinx_build" $sphinx_werror -c "$source_path/docs" \
-b html "$TMPDIR1/sphinx" \
"$TMPDIR1/sphinx/out" >> config.log 2>&1
}
# Check if tools are available to build documentation.
if test "$docs" != "no" ; then
if has_sphinx_build; then
sphinx_ok=yes
else
sphinx_ok=no
fi
if test "$sphinx_ok" = "yes"; then
docs=yes
else
if test "$docs" = "yes" ; then
if has $sphinx_build && test "$sphinx_ok" != "yes"; then
echo "Warning: $sphinx_build exists but it is either too old or uses too old a Python version" >&2
fi
feature_not_found "docs" "Install a Python 3 version of python-sphinx"
fi
docs=no
fi
fi
# Search for bswap_32 function
byteswap_h=no
cat > $TMPC << EOF
@@ -4843,6 +4935,8 @@ if test "$coroutine" = ""; then
coroutine=win32
elif test "$ucontext_works" = "yes"; then
coroutine=ucontext
elif test "$ios" = "yes"; then
coroutine=libucontext
else
coroutine=sigaltstack
fi
@@ -4866,12 +4960,27 @@ else
error_exit "only the 'windows' coroutine backend is valid for Windows"
fi
;;
libucontext)
;;
*)
error_exit "unknown coroutine backend $coroutine"
;;
esac
fi
case $coroutine in
libucontext)
git_submodules="${git_submodules} libucontext"
mkdir -p libucontext
coroutine_impl=ucontext
libucontext="enabled"
;;
*)
coroutine_impl=$coroutine
libucontext="disabled"
;;
esac
if test "$coroutine_pool" = ""; then
coroutine_pool=yes
fi
@@ -5636,6 +5745,22 @@ but not implemented on your system"
fi
fi
##########################################
# check for Apple Silicon JIT function
if [ "$darwin" = "yes" ] ; then
cat > $TMPC << EOF
#include <pthread.h>
int main() { pthread_jit_write_protect_np(0); return 0; }
EOF
if ! compile_prog ""; then
have_pthread_jit_protect='no'
else
have_pthread_jit_protect='yes'
fi
fi
##########################################
# End of CC checks
# After here, no more $cc or $ld runs
@@ -5726,17 +5851,10 @@ if test "$mingw32" = "yes" ; then
done
fi
# Enable mirror mapping if debug_tcg on supported platform
if test "$debug_tcg" = "yes"; then
if test "$linux" = "yes"; then
mirror_jit=yes
fi
fi
qemu_confdir="$sysconfdir/$qemu_suffix"
qemu_moddir="$libdir/$qemu_suffix"
qemu_datadir="$datadir/$qemu_suffix"
qemu_docdir="$docdir/$qemu_suffix"
qemu_localedir="$datadir/locale"
qemu_icondir="$datadir/icons"
qemu_desktopdir="$datadir/applications"
@@ -5935,6 +6053,9 @@ if test "$default_devices" = "yes" ; then
else
echo "CONFIG_MINIKCONF_MODE=--allnoconfig" >> $config_host_mak
fi
if test "$host_block_device_support" = "yes" ; then
echo "CONFIG_HOST_BLOCK_DEVICE=y" >> $config_host_mak
fi
if test "$debug_tcg" = "yes" ; then
echo "CONFIG_DEBUG_TCG=y" >> $config_host_mak
fi
@@ -5984,6 +6105,11 @@ if test "$darwin" = "yes" ; then
echo "CONFIG_DARWIN=y" >> $config_host_mak
fi
if test "$ios" = "yes" ; then
echo "CONFIG_IOS=y" >> $config_host_mak
echo "CONFIG_IOS_JIT=y" >> $config_host_mak
fi
if test "$solaris" = "yes" ; then
echo "CONFIG_SOLARIS=y" >> $config_host_mak
fi
@@ -6054,6 +6180,9 @@ qemu_version=$(head $source_path/VERSION)
echo "PKGVERSION=$pkgversion" >>$config_host_mak
echo "SRC_PATH=$source_path" >> $config_host_mak
echo "TARGET_DIRS=$target_list" >> $config_host_mak
if [ "$docs" = "yes" ] ; then
echo "BUILD_DOCS=yes" >> $config_host_mak
fi
if test "$modules" = "yes"; then
# $shacmd can generate a hash started with digit, which the compiler doesn't
# like as an symbol. So prefix it with an underscore
@@ -6445,7 +6574,7 @@ if test "$rbd" = "yes" ; then
echo "RBD_LIBS=$rbd_libs" >> $config_host_mak
fi
echo "CONFIG_COROUTINE_BACKEND=$coroutine" >> $config_host_mak
echo "CONFIG_COROUTINE_BACKEND=$coroutine_impl" >> $config_host_mak
if test "$coroutine_pool" = "yes" ; then
echo "CONFIG_COROUTINE_POOL=1" >> $config_host_mak
else
@@ -6740,12 +6869,32 @@ if test "$secret_keyring" = "yes" ; then
echo "CONFIG_SECRET_KEYRING=y" >> $config_host_mak
fi
if test "$have_pthread_jit_protect" = "yes" ; then
echo "HAVE_PTHREAD_JIT_PROTECT=y" >> $config_host_mak
fi
if test "$tcg_interpreter" = "yes"; then
QEMU_INCLUDES="-iquote ${source_path}/tcg/tci $QEMU_INCLUDES"
elif test "$ARCH" = "sparc64" ; then
QEMU_INCLUDES="-iquote ${source_path}/tcg/sparc $QEMU_INCLUDES"
elif test "$ARCH" = "s390x" ; then
QEMU_INCLUDES="-iquote ${source_path}/tcg/s390 $QEMU_INCLUDES"
elif test "$ARCH" = "x86_64" || test "$ARCH" = "x32" ; then
QEMU_INCLUDES="-iquote ${source_path}/tcg/i386 $QEMU_INCLUDES"
elif test "$ARCH" = "ppc64" ; then
QEMU_INCLUDES="-iquote ${source_path}/tcg/ppc $QEMU_INCLUDES"
elif test "$ARCH" = "riscv32" || test "$ARCH" = "riscv64" ; then
QEMU_INCLUDES="-I${source_path}/tcg/riscv $QEMU_INCLUDES"
else
QEMU_INCLUDES="-iquote ${source_path}/tcg/${ARCH} $QEMU_INCLUDES"
fi
echo "ROMS=$roms" >> $config_host_mak
echo "MAKE=$make" >> $config_host_mak
echo "PYTHON=$python" >> $config_host_mak
echo "SPHINX_BUILD=$sphinx_build" >> $config_host_mak
echo "GENISOIMAGE=$genisoimage" >> $config_host_mak
echo "MESON=$meson" >> $config_host_mak
echo "NINJA=$ninja" >> $config_host_mak
echo "CC=$cc" >> $config_host_mak
if $iasl -h > /dev/null 2>&1; then
echo "CONFIG_IASL=$iasl" >> $config_host_mak
@@ -6766,6 +6915,7 @@ echo "WINDRES=$windres" >> $config_host_mak
echo "CFLAGS_NOPIE=$CFLAGS_NOPIE" >> $config_host_mak
echo "QEMU_CFLAGS=$QEMU_CFLAGS" >> $config_host_mak
echo "QEMU_CXXFLAGS=$QEMU_CXXFLAGS" >> $config_host_mak
echo "QEMU_INCLUDES=$QEMU_INCLUDES" >> $config_host_mak
echo "GLIB_CFLAGS=$glib_cflags" >> $config_host_mak
echo "GLIB_LIBS=$glib_libs" >> $config_host_mak
echo "QEMU_LDFLAGS=$QEMU_LDFLAGS" >> $config_host_mak
@@ -6852,10 +7002,6 @@ if test "$safe_stack" = "yes"; then
echo "CONFIG_SAFESTACK=y" >> $config_host_mak
fi
if test "$mirror_jit" = "yes"; then
echo "CONFIG_MIRROR_JIT=y" >> $config_host_mak
fi
# If we're using a separate build tree, set it up now.
# DIRS are directories which we simply mkdir in the build tree;
# LINKS are things to symlink back into the source tree
@@ -6960,6 +7106,7 @@ echo "cpp_link_args = [${LDFLAGS:+$(meson_quote $LDFLAGS)}]" >> $cross
echo "[binaries]" >> $cross
echo "c = [$(meson_quote $cc)]" >> $cross
test -n "$cxx" && echo "cpp = [$(meson_quote $cxx)]" >> $cross
test -n "$objcc" && echo "objc = [$(meson_quote $objcc)]" >> $cross
echo "ar = [$(meson_quote $ar)]" >> $cross
echo "nm = [$(meson_quote $nm)]" >> $cross
echo "pkgconfig = [$(meson_quote $pkg_config_exe)]" >> $cross
@@ -6967,9 +7114,13 @@ echo "ranlib = [$(meson_quote $ranlib)]" >> $cross
if has $sdl2_config; then
echo "sdl2-config = [$(meson_quote $sdl2_config)]" >> $cross
fi
echo "strip = [$(meson_quote $strip)]" >> $cross
if test "$shared_lib" = "true"; then
echo "strip = [$(meson_quote $strip), '-x']" >> $cross
else
echo "strip = [$(meson_quote $strip)]" >> $cross
fi
echo "windres = [$(meson_quote $windres)]" >> $cross
if test -n "$cross_prefix"; then
if test "$cross_compile" = "yes"; then
cross_arg="--cross-file config-meson.cross"
echo "[host_machine]" >> $cross
if test "$mingw32" = "yes" ; then
@@ -6978,6 +7129,9 @@ if test -n "$cross_prefix"; then
if test "$linux" = "yes" ; then
echo "system = 'linux'" >> $cross
fi
if test "$darwin" = "yes" ; then
echo "system = 'darwin'" >> $cross
fi
case "$ARCH" in
i386|x86_64)
echo "cpu_family = 'x86'" >> $cross
@@ -7001,7 +7155,7 @@ fi
mv $cross config-meson.cross
rm -rf meson-private meson-info meson-logs
NINJA=$ninja $meson setup \
NINJA=${ninja:-$PWD/ninjatool} $meson setup \
--prefix "$prefix" \
--libdir "$libdir" \
--libexecdir "$libexecdir" \
@@ -7027,14 +7181,15 @@ NINJA=$ninja $meson setup \
-Dvnc=$vnc -Dvnc_sasl=$vnc_sasl -Dvnc_jpeg=$vnc_jpeg -Dvnc_png=$vnc_png \
-Dgettext=$gettext -Dxkbcommon=$xkbcommon -Du2f=$u2f \
-Dcapstone=$capstone -Dslirp=$slirp -Dfdt=$fdt \
-Diconv=$iconv -Dcurses=$curses -Dlibudev=$libudev\
-Ddocs=$docs -Dsphinx_build=$sphinx_build \
-Diconv=$iconv -Dcurses=$curses -Ducontext=$libucontext \
-Dshared-lib=$shared_lib \
$cross_arg \
"$PWD" "$source_path"
if test "$?" -ne 0 ; then
error_exit "meson setup failed"
fi
touch ninjatool.stamp
fi
if test -n "${deprecated_features}"; then
+1
View File
@@ -43,3 +43,4 @@ CONFIG_FSL_IMX7=y
CONFIG_FSL_IMX6UL=y
CONFIG_SEMIHOSTING=y
CONFIG_ALLWINNER_H3=y
CONFIG_ACPI_APEI=y
+1 -1
View File
@@ -241,7 +241,7 @@ texinfo_documents = [
# We use paths starting from qemu_docdir here so that you can run
# sphinx-build from anywhere and the kerneldoc extension can still
# find everything.
kerneldoc_bin = ['perl', os.path.join(qemu_docdir, '../scripts/kernel-doc')]
kerneldoc_bin = os.path.join(qemu_docdir, '../scripts/kernel-doc')
kerneldoc_srctree = os.path.join(qemu_docdir, '..')
hxtool_srctree = os.path.join(qemu_docdir, '..')
qapidoc_srctree = os.path.join(qemu_docdir, '..')
+4 -2
View File
@@ -404,8 +404,10 @@ Built by Meson:
Built by Makefile:
`Makefile.ninja`
A Makefile include that bridges to ninja for the actual build. The
Makefile is mostly a list of targets that Meson included in build.ninja.
A Makefile conversion of the build rules in build.ninja. The conversion
is straightforward and, were it necessary to debug the rules produced
by Meson, it should be enough to look at build.ninja. The conversion
is performed by scripts/ninjatool.py.
`Makefile.mtest`
The Makefile definitions that let "make check" run tests defined in
+40
View File
@@ -0,0 +1,40 @@
===========
iOS Support
===========
To run qemu on the iOS platform, some modifications were required. Most of the
modifications are conditioned on the ``CONFIG_IOS`` and ``CONFIG_IOS_JIT``
configuration variables.
Build support
-------------
For the code to compile, certain changes in the block driver and the slirp
driver had to be made. There is no ``system()`` call, so code requiring it had
to be disabled.
``ucontext`` support is broken on iOS. The implementation from ``libucontext``
is used instead.
Because ``fork()`` is not allowed on iOS apps, the option to build qemu and the
utilities as shared libraries is added. Note that because qemu does not perform
resource cleanup in most cases (open files, allocated memory, etc), it is
advisable that the user implements a proxy layer for syscalls so resources can
be kept track by the app that uses qemu as a shared library.
JIT support
-----------
On iOS, allocating RWX pages require special entitlements not usually granted to
apps. However, it is possible to use `bulletproof JIT`_ with a development
certificate. This means that we need to allocate one chunk of memory with RX
permissions and then mirror map the same memory with RW permissions. We generate
code to the mirror mapping and execute the original mapping.
With ``CONFIG_IOS_JIT`` defined, we store inside the TCG context the difference
between the two mappings. Then, we make sure that any writes to JIT memory is
done to the pointer + the difference (in order to get a pointer to the mirror
mapped space). Additionally, we make sure to flush the data cache before we
invalidate the instruction cache so the changes are seen in both mappings.
.. _bulletproof JIT: https://www.blackhat.com/docs/us-16/materials/us-16-Krstic.pdf
+1 -7
View File
@@ -93,13 +93,7 @@ guest CPU state in case of a guest CPU exception. This is passed
to ``cpu_restore_state()``. Therefore the value should either be 0,
to indicate that the guest CPU state is already synchronized, or
the result of ``GETPC()`` from the top level ``HELPER(foo)``
function, which is a return address into the generated code [#gpc]_.
.. [#gpc] Note that ``GETPC()`` should be used with great care: calling
it in other functions that are *not* the top level
``HELPER(foo)`` will cause unexpected behavior. Instead, the
value of ``GETPC()`` should be read from the helper and passed
if needed to the functions that the helper calls.
function, which is a return address into the generated code.
Function names follow the pattern:
-46
View File
@@ -1,50 +1,4 @@
if get_option('sphinx_build') == ''
sphinx_build = find_program(['sphinx-build-3', 'sphinx-build'],
required: get_option('docs'))
else
sphinx_build = find_program(get_option('sphinx_build'),
required: get_option('docs'))
endif
# Check if tools are available to build documentation.
build_docs = false
if sphinx_build.found()
SPHINX_ARGS = [sphinx_build]
# If we're making warnings fatal, apply this to Sphinx runs as well
if get_option('werror')
SPHINX_ARGS += [ '-W' ]
endif
# This is a bit awkward but works: create a trivial document and
# try to run it with our configuration file (which enforces a
# version requirement). This will fail if sphinx-build is too old.
run_command('mkdir', ['-p', tmpdir / 'sphinx'])
run_command('touch', [tmpdir / 'sphinx/index.rst'])
sphinx_build_test_out = run_command(SPHINX_ARGS + [
'-c', meson.current_source_dir(),
'-b', 'html', tmpdir / 'sphinx',
tmpdir / 'sphinx/out'])
build_docs = (sphinx_build_test_out.returncode() == 0)
if not build_docs
warning('@0@ exists but it is either too old or uses too old a Python version'.format(get_option('sphinx_build')))
if get_option('docs').enabled()
error('Install a Python 3 version of python-sphinx')
endif
endif
endif
if build_docs
SPHINX_ARGS += ['-Dversion=' + meson.project_version(), '-Drelease=' + config_host['PKGVERSION']]
sphinx_extn_depends = [ meson.source_root() / 'docs/sphinx/depfile.py',
meson.source_root() / 'docs/sphinx/hxtool.py',
meson.source_root() / 'docs/sphinx/kerneldoc.py',
meson.source_root() / 'docs/sphinx/kernellog.py',
meson.source_root() / 'docs/sphinx/qapidoc.py',
meson.source_root() / 'docs/sphinx/qmp_lexer.py',
qapi_gen_depends ]
configure_file(output: 'index.html',
input: files('index.html.in'),
configuration: {'VERSION': meson.project_version()},
+1 -1
View File
@@ -67,7 +67,7 @@ class KernelDocDirective(Directive):
def run(self):
env = self.state.document.settings.env
cmd = env.config.kerneldoc_bin + ['-rst', '-enable-lineno']
cmd = [env.config.kerneldoc_bin, '-rst', '-enable-lineno']
filename = env.config.kerneldoc_srctree + '/' + self.arguments[0]
export_file_patterns = []
+2 -8
View File
@@ -48,17 +48,11 @@ across all desired hosts.
``I6400``
MIPS64 Processor (Release 6, 2014)
``Loongson-2E``
MIPS64 Processor (Loongson 2, 2006)
``Loongson-2F``
MIPS64 Processor (Loongson 2, 2008)
``Loongson-3A1000``
MIPS64 Processor (Loongson 3, 2010)
``Loongson-3A4000``
MIPS64 Processor (Loongson 3, 2018)
``Loongson-2E``
MIPS64 Processor (Loongson 2, 2006)
``mips64dspr2``
MIPS64 Processor (Release 2, 2006)
+2
View File
@@ -541,6 +541,8 @@ static int synth_init(FsContext *ctx, Error **errp)
QLIST_INIT(&synth_root.child);
qemu_mutex_init(&synth_mutex);
ctx->export_flags |= V9FS_NO_PERF_WARN;
/* Add "." and ".." entries for root */
v9fs_add_dir_node(&synth_root, synth_root.attr->mode,
"..", synth_root.attr, synth_root.attr->inode);
-6
View File
@@ -21,7 +21,6 @@
#include "hw/virtio/virtio-access.h"
#include "qemu/iov.h"
#include "qemu/module.h"
#include "sysemu/qtest.h"
static void virtio_9p_push_and_notify(V9fsPDU *pdu)
{
@@ -200,11 +199,6 @@ static void virtio_9p_device_realize(DeviceState *dev, Error **errp)
VirtIODevice *vdev = VIRTIO_DEVICE(dev);
V9fsVirtioState *v = VIRTIO_9P(dev);
V9fsState *s = &v->state;
FsDriverEntry *fse = get_fsdev_fsentry(s->fsconf.fsdev_id);
if (qtest_enabled() && fse) {
fse->export_flags |= V9FS_NO_PERF_WARN;
}
if (v9fs_device_realize_common(s, &virtio_9p_transport, errp)) {
return;
-14
View File
@@ -57,20 +57,6 @@ Aml *aml_irq_no_flags(uint8_t irq)
return NULL;
}
Aml *aml_interrupt(AmlConsumerAndProducer con_and_pro,
AmlLevelAndEdge level_and_edge,
AmlActiveHighAndLow high_and_low, AmlShared shared,
uint32_t *irq_list, uint8_t irq_count)
{
return NULL;
}
Aml *aml_memory32_fixed(uint32_t addr, uint32_t size,
AmlReadAndWrite read_and_write)
{
return NULL;
}
Aml *aml_int(const uint64_t val)
{
return NULL;
-1
View File
@@ -26,7 +26,6 @@ config ARM_VIRT
select ACPI_MEMORY_HOTPLUG
select ACPI_HW_REDUCED
select ACPI_NVDIMM
select ACPI_APEI
config CHEETAH
bool
+2 -11
View File
@@ -171,17 +171,8 @@ static void bcm2835_peripherals_realize(DeviceState *dev, Error **errp)
memory_region_add_subregion(&s->peri_mr, ST_OFFSET,
sysbus_mmio_get_region(SYS_BUS_DEVICE(&s->systmr), 0));
sysbus_connect_irq(SYS_BUS_DEVICE(&s->systmr), 0,
qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ,
INTERRUPT_TIMER0));
sysbus_connect_irq(SYS_BUS_DEVICE(&s->systmr), 1,
qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ,
INTERRUPT_TIMER1));
sysbus_connect_irq(SYS_BUS_DEVICE(&s->systmr), 2,
qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ,
INTERRUPT_TIMER2));
sysbus_connect_irq(SYS_BUS_DEVICE(&s->systmr), 3,
qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_GPU_IRQ,
INTERRUPT_TIMER3));
qdev_get_gpio_in_named(DEVICE(&s->ic), BCM2835_IC_ARM_IRQ,
INTERRUPT_ARM_TIMER));
/* UART0 */
qdev_prop_set_chr(DEVICE(&s->uart0), "chardev", serial_hd(0));
-1
View File
@@ -1318,7 +1318,6 @@ static void n8x0_init(MachineState *machine,
g_free(sz);
exit(EXIT_FAILURE);
}
binfo->ram_size = machine->ram_size;
memory_region_add_subregion(get_system_memory(), OMAP2_Q2_BASE,
machine->ram);
+1 -1
View File
@@ -935,7 +935,7 @@ struct StrongARMUARTState {
uint8_t rx_start;
uint8_t rx_len;
uint64_t char_transmit_time; /* time to transmit a char in nanoseconds */
uint64_t char_transmit_time; /* time to transmit a char in ticks*/
bool wait_break_end;
QEMUTimer *rx_timeout_timer;
QEMUTimer *tx_timer;
-15
View File
@@ -23,21 +23,6 @@ void clock_setup_canonical_path(Clock *clk)
clk->canonical_path = object_get_canonical_path(OBJECT(clk));
}
Clock *clock_new(Object *parent, const char *name)
{
Object *obj;
Clock *clk;
obj = object_new(TYPE_CLOCK);
object_property_add_child(parent, name, obj);
object_unref(obj);
clk = CLOCK(obj);
clock_setup_canonical_path(clk);
return clk;
}
void clock_set_callback(Clock *clk, ClockCallback *cb, void *opaque)
{
clk->callback = cb;
-11
View File
@@ -12,7 +12,6 @@
*/
#include "qemu/osdep.h"
#include "qemu/error-report.h"
#include "hw/qdev-clock.h"
#include "hw/qdev-core.h"
#include "qapi/error.h"
@@ -154,11 +153,6 @@ Clock *qdev_get_clock_in(DeviceState *dev, const char *name)
assert(name);
ncl = qdev_get_clocklist(dev, name);
if (!ncl) {
error_report("Can not find clock-in '%s' for device type '%s'",
name, object_get_typename(OBJECT(dev)));
abort();
}
assert(!ncl->output);
return ncl->clock;
@@ -171,11 +165,6 @@ Clock *qdev_get_clock_out(DeviceState *dev, const char *name)
assert(name);
ncl = qdev_get_clocklist(dev, name);
if (!ncl) {
error_report("Can not find clock-out '%s' for device type '%s'",
name, object_get_typename(OBJECT(dev)));
abort();
}
assert(ncl->output);
return ncl->clock;
-1
View File
@@ -83,7 +83,6 @@ static const VMStateDescription microbit_i2c_vmstate = {
.fields = (VMStateField[]) {
VMSTATE_UINT32_ARRAY(regs, MicrobitI2CState, MICROBIT_I2C_NREGS),
VMSTATE_UINT32(read_idx, MicrobitI2CState),
VMSTATE_END_OF_LIST()
},
};
-1
View File
@@ -105,7 +105,6 @@ config MICROVM
select VIRTIO_MMIO
select ACPI_HW_REDUCED
select PCI_EXPRESS_GENERIC_BRIDGE
select USB_XHCI_SYSBUS
config X86_IOMMU
bool
+1 -1
View File
@@ -2477,7 +2477,7 @@ void acpi_build(AcpiBuildTables *tables, MachineState *machine)
acpi_add_table(table_offsets, tables_blob);
acpi_build_madt(tables_blob, tables->linker, x86ms,
ACPI_DEVICE_IF(x86ms->acpi_dev));
ACPI_DEVICE_IF(x86ms->acpi_dev), true);
vmgenid_dev = find_vmgenid_dev();
if (vmgenid_dev) {
+15 -11
View File
@@ -72,7 +72,8 @@ void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid,
}
void acpi_build_madt(GArray *table_data, BIOSLinker *linker,
X86MachineState *x86ms, AcpiDeviceIf *adev)
X86MachineState *x86ms, AcpiDeviceIf *adev,
bool has_pci)
{
MachineClass *mc = MACHINE_GET_CLASS(x86ms);
const CPUArchIdList *apic_ids = mc->possible_cpu_arch_ids(MACHINE(x86ms));
@@ -112,17 +113,20 @@ void acpi_build_madt(GArray *table_data, BIOSLinker *linker,
intsrcovr->flags = cpu_to_le16(0); /* conforms to bus specifications */
}
for (i = 1; i < 16; i++) {
if (!(x86ms->pci_irq_mask & (1 << i))) {
/* No need for a INT source override structure. */
continue;
if (has_pci) {
for (i = 1; i < 16; i++) {
#define ACPI_BUILD_PCI_IRQS ((1<<5) | (1<<9) | (1<<10) | (1<<11))
if (!(ACPI_BUILD_PCI_IRQS & (1 << i))) {
/* No need for a INT source override structure. */
continue;
}
intsrcovr = acpi_data_push(table_data, sizeof *intsrcovr);
intsrcovr->type = ACPI_APIC_XRUPT_OVERRIDE;
intsrcovr->length = sizeof(*intsrcovr);
intsrcovr->source = i;
intsrcovr->gsi = cpu_to_le32(i);
intsrcovr->flags = cpu_to_le16(0xd); /* active high, level triggered */
}
intsrcovr = acpi_data_push(table_data, sizeof *intsrcovr);
intsrcovr->type = ACPI_APIC_XRUPT_OVERRIDE;
intsrcovr->length = sizeof(*intsrcovr);
intsrcovr->source = i;
intsrcovr->gsi = cpu_to_le32(i);
intsrcovr->flags = cpu_to_le16(0xd); /* active high, level triggered */
}
if (x2apic_mode) {
+2 -1
View File
@@ -9,6 +9,7 @@
#define ACPI_BUILD_IOAPIC_ID 0x0
void acpi_build_madt(GArray *table_data, BIOSLinker *linker,
X86MachineState *x86ms, AcpiDeviceIf *adev);
X86MachineState *x86ms, AcpiDeviceIf *adev,
bool has_pci);
#endif
+1 -10
View File
@@ -35,7 +35,6 @@
#include "hw/i386/microvm.h"
#include "hw/pci/pci.h"
#include "hw/pci/pcie_host.h"
#include "hw/usb/xhci.h"
#include "hw/virtio/virtio-mmio.h"
#include "acpi-common.h"
@@ -90,13 +89,6 @@ static void acpi_dsdt_add_virtio(Aml *scope,
}
}
static void acpi_dsdt_add_xhci(Aml *scope, MicrovmMachineState *mms)
{
if (machine_usb(MACHINE(mms))) {
xhci_sysbus_build_aml(scope, MICROVM_XHCI_BASE, MICROVM_XHCI_IRQ);
}
}
static void acpi_dsdt_add_pci(Aml *scope, MicrovmMachineState *mms)
{
if (mms->pcie != ON_OFF_AUTO_ON) {
@@ -131,7 +123,6 @@ build_dsdt_microvm(GArray *table_data, BIOSLinker *linker,
GED_MMIO_IRQ, AML_SYSTEM_MEMORY, GED_MMIO_BASE);
acpi_dsdt_add_power_button(sb_scope);
acpi_dsdt_add_virtio(sb_scope, mms);
acpi_dsdt_add_xhci(sb_scope, mms);
acpi_dsdt_add_pci(sb_scope, mms);
aml_append(dsdt, sb_scope);
@@ -205,7 +196,7 @@ static void acpi_build_microvm(AcpiBuildTables *tables,
acpi_add_table(table_offsets, tables_blob);
acpi_build_madt(tables_blob, tables->linker, X86_MACHINE(machine),
ACPI_DEVICE_IF(x86ms->acpi_dev));
ACPI_DEVICE_IF(x86ms->acpi_dev), false);
xsdt = tables_blob->len;
build_xsdt(tables_blob, tables->linker, table_offsets, NULL, NULL);
-19
View File
@@ -47,7 +47,6 @@
#include "hw/acpi/acpi.h"
#include "hw/acpi/generic_event_device.h"
#include "hw/pci-host/gpex.h"
#include "hw/usb/xhci.h"
#include "cpu.h"
#include "elf.h"
@@ -198,18 +197,6 @@ static void microvm_devices_init(MicrovmMachineState *mms)
x86ms->acpi_dev = HOTPLUG_HANDLER(dev);
}
if (x86_machine_is_acpi_enabled(x86ms) && machine_usb(MACHINE(mms))) {
DeviceState *dev = qdev_new(TYPE_XHCI_SYSBUS);
qdev_prop_set_uint32(dev, "intrs", 1);
qdev_prop_set_uint32(dev, "slots", XHCI_MAXSLOTS);
qdev_prop_set_uint32(dev, "p2", 8);
qdev_prop_set_uint32(dev, "p3", 8);
sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, MICROVM_XHCI_BASE);
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0,
x86ms->gsi[MICROVM_XHCI_IRQ]);
}
if (x86_machine_is_acpi_enabled(x86ms) && mms->pcie == ON_OFF_AUTO_ON) {
/* use topmost 25% of the address space available */
hwaddr phys_size = (hwaddr)1 << X86_CPU(first_cpu)->phys_bits;
@@ -223,12 +210,6 @@ static void microvm_devices_init(MicrovmMachineState *mms)
mms->gpex.ecam.size = PCIE_ECAM_SIZE;
mms->gpex.irq = PCIE_IRQ_BASE;
create_gpex(mms);
x86ms->pci_irq_mask = ((1 << (PCIE_IRQ_BASE + 0)) |
(1 << (PCIE_IRQ_BASE + 1)) |
(1 << (PCIE_IRQ_BASE + 2)) |
(1 << (PCIE_IRQ_BASE + 3)));
} else {
x86ms->pci_irq_mask = 0;
}
if (mms->pic == ON_OFF_AUTO_ON || mms->pic == ON_OFF_AUTO_AUTO) {
+2 -2
View File
@@ -987,7 +987,7 @@ static void xenfv_4_2_machine_options(MachineClass *m)
pc_i440fx_4_2_machine_options(m);
m->desc = "Xen Fully-virtualized PC";
m->max_cpus = HVM_MAX_VCPUS;
m->default_machine_opts = "accel=xen,suppress-vmdesc=on";
m->default_machine_opts = "accel=xen";
}
DEFINE_PC_MACHINE(xenfv_4_2, "xenfv-4.2", pc_xen_hvm_init,
@@ -999,7 +999,7 @@ static void xenfv_3_1_machine_options(MachineClass *m)
m->desc = "Xen Fully-virtualized PC";
m->alias = "xenfv";
m->max_cpus = HVM_MAX_VCPUS;
m->default_machine_opts = "accel=xen,suppress-vmdesc=on";
m->default_machine_opts = "accel=xen";
}
DEFINE_PC_MACHINE(xenfv, "xenfv-3.1", pc_xen_hvm_init,
-1
View File
@@ -1178,7 +1178,6 @@ static void x86_machine_initfn(Object *obj)
x86ms->smm = ON_OFF_AUTO_AUTO;
x86ms->acpi = ON_OFF_AUTO_AUTO;
x86ms->smp_dies = 1;
x86ms->pci_irq_mask = ACPI_BUILD_PCI_IRQS;
}
static void x86_machine_class_init(ObjectClass *oc, void *data)
+1 -1
View File
@@ -24,7 +24,7 @@
#include "hw/xen/xen-bus.h"
#include "hw/xen/xen-x86.h"
#include "qapi/error.h"
#include "qapi/qapi-commands-migration.h"
#include "qapi/qapi-commands-misc.h"
#include "qemu/error-report.h"
#include "qemu/main-loop.h"
#include "qemu/range.h"
+2
View File
@@ -37,6 +37,8 @@
#include "sysemu/block-backend.h"
#include "qemu/error-report.h"
#include "qemu/module.h"
#include <xenguest.h>
#include "qom/object.h"
//#define DEBUG_PLATFORM
+1 -3
View File
@@ -18,7 +18,6 @@
#include "migration/vmstate.h"
#include "qemu/log.h"
#include "qemu/module.h"
#include "trace.h"
#define GPU_IRQS 64
#define ARM_IRQS 8
@@ -52,6 +51,7 @@ static void bcm2835_ic_update(BCM2835ICState *s)
set = (s->gpu_irq_level & s->gpu_irq_enable)
|| (s->arm_irq_level & s->arm_irq_enable);
qemu_set_irq(s->irq, set);
}
static void bcm2835_ic_set_gpu_irq(void *opaque, int irq, int level)
@@ -59,7 +59,6 @@ static void bcm2835_ic_set_gpu_irq(void *opaque, int irq, int level)
BCM2835ICState *s = opaque;
assert(irq >= 0 && irq < 64);
trace_bcm2835_ic_set_gpu_irq(irq, level);
s->gpu_irq_level = deposit64(s->gpu_irq_level, irq, 1, level != 0);
bcm2835_ic_update(s);
}
@@ -69,7 +68,6 @@ static void bcm2835_ic_set_arm_irq(void *opaque, int irq, int level)
BCM2835ICState *s = opaque;
assert(irq >= 0 && irq < 8);
trace_bcm2835_ic_set_cpu_irq(irq, level);
s->arm_irq_level = deposit32(s->arm_irq_level, irq, 1, level != 0);
bcm2835_ic_update(s);
}
+4 -4
View File
@@ -157,22 +157,22 @@ static void bcm2836_control_set_local_irq(void *opaque, int core, int local_irq,
static void bcm2836_control_set_local_irq0(void *opaque, int core, int level)
{
bcm2836_control_set_local_irq(opaque, core, IRQ_CNTPSIRQ, level);
bcm2836_control_set_local_irq(opaque, core, 0, level);
}
static void bcm2836_control_set_local_irq1(void *opaque, int core, int level)
{
bcm2836_control_set_local_irq(opaque, core, IRQ_CNTPNSIRQ, level);
bcm2836_control_set_local_irq(opaque, core, 1, level);
}
static void bcm2836_control_set_local_irq2(void *opaque, int core, int level)
{
bcm2836_control_set_local_irq(opaque, core, IRQ_CNTHPIRQ, level);
bcm2836_control_set_local_irq(opaque, core, 2, level);
}
static void bcm2836_control_set_local_irq3(void *opaque, int core, int level)
{
bcm2836_control_set_local_irq(opaque, core, IRQ_CNTVIRQ, level);
bcm2836_control_set_local_irq(opaque, core, 3, level);
}
static void bcm2836_control_set_gpu_irq(void *opaque, int irq, int level)
-4
View File
@@ -199,7 +199,3 @@ nvic_sysreg_write(uint64_t addr, uint32_t value, unsigned size) "NVIC sysreg wri
heathrow_write(uint64_t addr, unsigned int n, uint64_t value) "0x%"PRIx64" %u: 0x%"PRIx64
heathrow_read(uint64_t addr, unsigned int n, uint64_t value) "0x%"PRIx64" %u: 0x%"PRIx64
heathrow_set_irq(int num, int level) "set_irq: num=0x%02x level=%d"
# bcm2835_ic.c
bcm2835_ic_set_gpu_irq(int irq, int level) "GPU irq #%d level %d"
bcm2835_ic_set_cpu_irq(int irq, int level) "CPU irq #%d level %d"
+4 -17
View File
@@ -30,7 +30,6 @@
#include "hw/mips/cps.h"
#include "hw/mips/cpudevs.h"
#include "hw/pci-host/xilinx-pcie.h"
#include "hw/qdev-clock.h"
#include "hw/qdev-properties.h"
#include "qapi/error.h"
#include "qemu/error-report.h"
@@ -44,10 +43,10 @@
#include <libfdt.h>
#include "qom/object.h"
#define TYPE_BOSTON "mips-boston"
#define TYPE_MIPS_BOSTON "mips-boston"
typedef struct BostonState BostonState;
DECLARE_INSTANCE_CHECKER(BostonState, BOSTON,
TYPE_BOSTON)
TYPE_MIPS_BOSTON)
struct BostonState {
SysBusDevice parent_obj;
@@ -55,7 +54,6 @@ struct BostonState {
MachineState *mach;
MIPSCPSState cps;
SerialMM *uart;
Clock *cpuclk;
CharBackend lcd_display;
char lcd_content[8];
@@ -253,19 +251,10 @@ static const MemoryRegionOps boston_platreg_ops = {
.endianness = DEVICE_NATIVE_ENDIAN,
};
static void mips_boston_instance_init(Object *obj)
{
BostonState *s = BOSTON(obj);
s->cpuclk = qdev_init_clock_out(DEVICE(obj), "cpu-refclk");
clock_set_hz(s->cpuclk, 1000000000); /* 1 GHz */
}
static const TypeInfo boston_device = {
.name = TYPE_BOSTON,
.name = TYPE_MIPS_BOSTON,
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(BostonState),
.instance_init = mips_boston_instance_init,
};
static void boston_register_types(void)
@@ -455,7 +444,7 @@ static void boston_mach_init(MachineState *machine)
exit(1);
}
dev = qdev_new(TYPE_BOSTON);
dev = qdev_new(TYPE_MIPS_BOSTON);
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
s = BOSTON(dev);
@@ -473,8 +462,6 @@ static void boston_mach_init(MachineState *machine)
&error_fatal);
object_property_set_int(OBJECT(&s->cps), "num-vp", machine->smp.cpus,
&error_fatal);
qdev_connect_clock_in(DEVICE(&s->cps), "clk-in",
qdev_get_clock_out(dev, "cpu-refclk"));
sysbus_realize(SYS_BUS_DEVICE(&s->cps), &error_fatal);
sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->cps), 0, 0, 1);
-9
View File
@@ -22,7 +22,6 @@
#include "qemu/module.h"
#include "hw/mips/cps.h"
#include "hw/mips/mips.h"
#include "hw/qdev-clock.h"
#include "hw/qdev-properties.h"
#include "hw/mips/cpudevs.h"
#include "sysemu/kvm.h"
@@ -39,7 +38,6 @@ static void mips_cps_init(Object *obj)
SysBusDevice *sbd = SYS_BUS_DEVICE(obj);
MIPSCPSState *s = MIPS_CPS(obj);
s->clock = qdev_init_clock_in(DEVICE(obj), "clk-in", NULL, NULL);
/*
* Cover entire address space as there do not seem to be any
* constraints for the base address of CPC and GIC.
@@ -74,11 +72,6 @@ static void mips_cps_realize(DeviceState *dev, Error **errp)
bool itu_present = false;
bool saar_present = false;
if (!clock_get(s->clock)) {
error_setg(errp, "CPS input clock is not connected to an output clock");
return;
}
for (i = 0; i < s->num_vp; i++) {
cpu = MIPS_CPU(object_new(s->cpu_type));
@@ -87,8 +80,6 @@ static void mips_cps_realize(DeviceState *dev, Error **errp)
errp)) {
return;
}
/* All cores use the same clock tree */
qdev_connect_clock_in(DEVICE(cpu), "clk-in", s->clock);
if (!qdev_realize_and_unref(DEVICE(cpu), NULL, errp)) {
return;
+8 -10
View File
@@ -23,7 +23,6 @@
#include "qemu/units.h"
#include "qapi/error.h"
#include "cpu.h"
#include "hw/clock.h"
#include "hw/intc/i8259.h"
#include "hw/dma/i8257.h"
#include "hw/isa/superio.h"
@@ -133,7 +132,8 @@ static int64_t load_kernel(CPUMIPSState *env)
if (loaderparams.initrd_filename) {
initrd_size = get_image_size(loaderparams.initrd_filename);
if (initrd_size > 0) {
initrd_offset = ROUND_UP(kernel_high, INITRD_PAGE_SIZE);
initrd_offset = (kernel_high + ~INITRD_PAGE_MASK) &
INITRD_PAGE_MASK;
if (initrd_offset + initrd_size > ram_size) {
error_report("memory too small for initial ram disk '%s'",
loaderparams.initrd_filename);
@@ -298,16 +298,12 @@ static void mips_fuloong2e_init(MachineState *machine)
PCIBus *pci_bus;
ISABus *isa_bus;
I2CBus *smbus;
Clock *cpuclk;
MIPSCPU *cpu;
CPUMIPSState *env;
DeviceState *dev;
cpuclk = clock_new(OBJECT(machine), "cpu-refclk");
clock_set_hz(cpuclk, 533080000); /* ~533 MHz */
/* init CPUs */
cpu = mips_cpu_create_with_clock(machine->cpu_type, cpuclk);
cpu = MIPS_CPU(cpu_create(machine->cpu_type));
env = &cpu->env;
qemu_register_reset(main_cpu_reset, cpu);
@@ -337,8 +333,10 @@ static void mips_fuloong2e_init(MachineState *machine)
kernel_entry = load_kernel(env);
write_bootloader(env, memory_region_get_ram_ptr(bios), kernel_entry);
} else {
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS,
bios_name ?: FULOONG_BIOSNAME);
if (bios_name == NULL) {
bios_name = FULOONG_BIOSNAME;
}
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (filename) {
bios_size = load_image_targphys(filename, 0x1fc00000LL,
BIOS_SIZE);
@@ -348,7 +346,7 @@ static void mips_fuloong2e_init(MachineState *machine)
}
if ((bios_size < 0 || bios_size > BIOS_SIZE) &&
bios_name && !qtest_enabled()) {
!kernel_filename && !qtest_enabled()) {
error_report("Could not load MIPS bios '%s'", bios_name);
exit(1);
}
+6 -17
View File
@@ -24,7 +24,6 @@
#include "qemu/osdep.h"
#include "qemu-common.h"
#include "hw/clock.h"
#include "hw/mips/mips.h"
#include "hw/mips/cpudevs.h"
#include "hw/intc/i8259.h"
@@ -143,7 +142,6 @@ static void mips_jazz_init(MachineState *machine,
MemoryRegion *address_space = get_system_memory();
char *filename;
int bios_size, n;
Clock *cpuclk;
MIPSCPU *cpu;
CPUClass *cc;
CPUMIPSState *env;
@@ -165,25 +163,14 @@ static void mips_jazz_init(MachineState *machine,
MemoryRegion *bios2 = g_new(MemoryRegion, 1);
SysBusESPState *sysbus_esp;
ESPState *esp;
static const struct {
unsigned freq_hz;
unsigned pll_mult;
} ext_clk[] = {
[JAZZ_MAGNUM] = {50000000, 2},
[JAZZ_PICA61] = {33333333, 4},
};
if (machine->ram_size > 256 * MiB) {
error_report("RAM size more than 256Mb is not supported");
exit(EXIT_FAILURE);
}
cpuclk = clock_new(OBJECT(machine), "cpu-refclk");
clock_set_hz(cpuclk, ext_clk[jazz_model].freq_hz
* ext_clk[jazz_model].pll_mult);
/* init CPUs */
cpu = mips_cpu_create_with_clock(machine->cpu_type, cpuclk);
cpu = MIPS_CPU(cpu_create(machine->cpu_type));
env = &cpu->env;
qemu_register_reset(main_cpu_reset, cpu);
@@ -218,7 +205,10 @@ static void mips_jazz_init(MachineState *machine,
memory_region_add_subregion(address_space, 0xfff00000LL, bios2);
/* load the BIOS image. */
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name ?: BIOS_FILENAME);
if (bios_name == NULL) {
bios_name = BIOS_FILENAME;
}
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (filename) {
bios_size = load_image_targphys(filename, 0xfff00000LL,
MAGNUM_BIOS_SIZE);
@@ -226,8 +216,7 @@ static void mips_jazz_init(MachineState *machine,
} else {
bios_size = -1;
}
if ((bios_size < 0 || bios_size > MAGNUM_BIOS_SIZE)
&& bios_name && !qtest_enabled()) {
if ((bios_size < 0 || bios_size > MAGNUM_BIOS_SIZE) && !qtest_enabled()) {
error_report("Could not load MIPS bios '%s'", bios_name);
exit(1);
}
+25 -34
View File
@@ -26,7 +26,6 @@
#include "qemu/units.h"
#include "qemu-common.h"
#include "cpu.h"
#include "hw/clock.h"
#include "hw/southbridge/piix.h"
#include "hw/isa/superio.h"
#include "hw/char/serial.h"
@@ -58,7 +57,6 @@
#include "sysemu/kvm.h"
#include "hw/semihosting/semihost.h"
#include "hw/mips/cps.h"
#include "hw/qdev-clock.h"
#define ENVP_ADDR 0x80002000l
#define ENVP_NB_ENTRIES 16
@@ -96,7 +94,6 @@ OBJECT_DECLARE_SIMPLE_TYPE(MaltaState, MIPS_MALTA)
struct MaltaState {
SysBusDevice parent_obj;
Clock *cpuclk;
MIPSCPSState cps;
qemu_irq i8259[ISA_NUM_IRQS];
};
@@ -578,7 +575,7 @@ static MaltaFPGAState *malta_fpga_init(MemoryRegion *address_space,
memory_region_init_alias(&s->iomem_lo, NULL, "malta-fpga",
&s->iomem, 0, 0x900);
memory_region_init_alias(&s->iomem_hi, NULL, "malta-fpga",
&s->iomem, 0xa00, 0x100000 - 0xa00);
&s->iomem, 0xa00, 0x10000 - 0xa00);
memory_region_add_subregion(address_space, base, &s->iomem_lo);
memory_region_add_subregion(address_space, base + 0xa00, &s->iomem_hi);
@@ -1077,9 +1074,9 @@ static int64_t load_kernel(void)
* the initrd. It takes at most 128kiB for 2GB RAM and 4kiB
* pages.
*/
initrd_offset = ROUND_UP(loaderparams.ram_low_size
- (initrd_size + 128 * KiB),
INITRD_PAGE_SIZE);
initrd_offset = (loaderparams.ram_low_size - initrd_size
- (128 * KiB)
- ~INITRD_PAGE_MASK) & INITRD_PAGE_MASK;
if (kernel_high >= initrd_offset) {
error_report("memory too small for initial ram disk '%s'",
loaderparams.initrd_filename);
@@ -1162,7 +1159,7 @@ static void main_cpu_reset(void *opaque)
}
}
static void create_cpu_without_cps(MachineState *ms, MaltaState *s,
static void create_cpu_without_cps(MachineState *ms,
qemu_irq *cbus_irq, qemu_irq *i8259_irq)
{
CPUMIPSState *env;
@@ -1170,7 +1167,7 @@ static void create_cpu_without_cps(MachineState *ms, MaltaState *s,
int i;
for (i = 0; i < ms->smp.cpus; i++) {
cpu = mips_cpu_create_with_clock(ms->cpu_type, s->cpuclk);
cpu = MIPS_CPU(cpu_create(ms->cpu_type));
/* Init internal devices */
cpu_mips_irq_init_cpu(cpu);
@@ -1192,7 +1189,6 @@ static void create_cps(MachineState *ms, MaltaState *s,
&error_fatal);
object_property_set_int(OBJECT(&s->cps), "num-vp", ms->smp.cpus,
&error_fatal);
qdev_connect_clock_in(DEVICE(&s->cps), "clk-in", s->cpuclk);
sysbus_realize(SYS_BUS_DEVICE(&s->cps), &error_fatal);
sysbus_mmio_map_overlap(SYS_BUS_DEVICE(&s->cps), 0, 0, 1);
@@ -1207,7 +1203,7 @@ static void mips_create_cpu(MachineState *ms, MaltaState *s,
if ((ms->smp.cpus > 1) && cpu_supports_cps_smp(ms->cpu_type)) {
create_cps(ms, s, cbus_irq, i8259_irq);
} else {
create_cpu_without_cps(ms, s, cbus_irq, i8259_irq);
create_cpu_without_cps(ms, cbus_irq, i8259_irq);
}
}
@@ -1235,11 +1231,18 @@ void mips_malta_init(MachineState *machine)
DriveInfo *dinfo;
int fl_idx = 0;
int be;
MaltaState *s;
DeviceState *dev;
s = MIPS_MALTA(qdev_new(TYPE_MIPS_MALTA));
sysbus_realize_and_unref(SYS_BUS_DEVICE(s), &error_fatal);
DeviceState *dev = qdev_new(TYPE_MIPS_MALTA);
MaltaState *s = MIPS_MALTA(dev);
/*
* The whole address space decoded by the GT-64120A doesn't generate
* exception when accessing invalid memory. Create an empty slot to
* emulate this feature.
*/
empty_slot_init("GT64120", 0, 0x20000000);
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
/* create CPU */
mips_create_cpu(machine, s, &cbus_irq, &i8259_irq);
@@ -1332,8 +1335,10 @@ void mips_malta_init(MachineState *machine)
/* Load firmware from flash. */
if (!dinfo) {
/* Load a BIOS image. */
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS,
bios_name ?: BIOS_FILENAME);
if (bios_name == NULL) {
bios_name = BIOS_FILENAME;
}
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (filename) {
bios_size = load_image_targphys(filename, FLASH_ADDRESS,
BIOS_SIZE);
@@ -1342,8 +1347,9 @@ void mips_malta_init(MachineState *machine)
bios_size = -1;
}
if ((bios_size < 0 || bios_size > BIOS_SIZE) &&
bios_name && !qtest_enabled()) {
error_report("Could not load MIPS bios '%s'", bios_name);
!kernel_filename && !qtest_enabled()) {
error_report("Could not load MIPS bios '%s', and no "
"-kernel argument was specified", bios_name);
exit(1);
}
}
@@ -1389,12 +1395,6 @@ void mips_malta_init(MachineState *machine)
/* Northbridge */
pci_bus = gt64120_register(s->i8259);
/*
* The whole address space decoded by the GT-64120A doesn't generate
* exception when accessing invalid memory. Create an empty slot to
* emulate this feature.
*/
empty_slot_init("GT64120", 0, 0x20000000);
/* Southbridge */
dev = piix4_create(pci_bus, &isa_bus, &smbus);
@@ -1421,19 +1421,10 @@ void mips_malta_init(MachineState *machine)
pci_vga_init(pci_bus);
}
static void mips_malta_instance_init(Object *obj)
{
MaltaState *s = MIPS_MALTA(obj);
s->cpuclk = qdev_init_clock_out(DEVICE(obj), "cpu-refclk");
clock_set_hz(s->cpuclk, 320000000); /* 320 MHz */
}
static const TypeInfo mips_malta_device = {
.name = TYPE_MIPS_MALTA,
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(MaltaState),
.instance_init = mips_malta_instance_init,
};
static void mips_malta_machine_init(MachineClass *mc)
+15 -15
View File
@@ -29,7 +29,6 @@
#include "qapi/error.h"
#include "qemu-common.h"
#include "cpu.h"
#include "hw/clock.h"
#include "hw/mips/mips.h"
#include "hw/mips/cpudevs.h"
#include "hw/char/serial.h"
@@ -77,7 +76,11 @@ static int64_t load_kernel(void)
(uint64_t *)&entry, NULL,
(uint64_t *)&kernel_high, NULL, big_endian,
EM_MIPS, 1, 0);
if (kernel_size < 0) {
if (kernel_size >= 0) {
if ((entry & ~0x7fffffffULL) == 0x80000000) {
entry = (int32_t)entry;
}
} else {
error_report("could not load kernel '%s': %s",
loaderparams.kernel_filename,
load_elf_strerror(kernel_size));
@@ -90,7 +93,8 @@ static int64_t load_kernel(void)
if (loaderparams.initrd_filename) {
initrd_size = get_image_size(loaderparams.initrd_filename);
if (initrd_size > 0) {
initrd_offset = ROUND_UP(kernel_high, INITRD_PAGE_SIZE);
initrd_offset = (kernel_high + ~INITRD_PAGE_MASK) &
INITRD_PAGE_MASK;
if (initrd_offset + initrd_size > loaderparams.ram_size) {
error_report("memory too small for initial ram disk '%s'",
loaderparams.initrd_filename);
@@ -146,21 +150,13 @@ mips_mipssim_init(MachineState *machine)
MemoryRegion *address_space_mem = get_system_memory();
MemoryRegion *isa = g_new(MemoryRegion, 1);
MemoryRegion *bios = g_new(MemoryRegion, 1);
Clock *cpuclk;
MIPSCPU *cpu;
CPUMIPSState *env;
ResetData *reset_info;
int bios_size;
cpuclk = clock_new(OBJECT(machine), "cpu-refclk");
#ifdef TARGET_MIPS64
clock_set_hz(cpuclk, 6000000); /* 6 MHz */
#else
clock_set_hz(cpuclk, 12000000); /* 12 MHz */
#endif
/* Init CPUs. */
cpu = mips_cpu_create_with_clock(machine->cpu_type, cpuclk);
cpu = MIPS_CPU(cpu_create(machine->cpu_type));
env = &cpu->env;
reset_info = g_malloc0(sizeof(ResetData));
@@ -177,7 +173,10 @@ mips_mipssim_init(MachineState *machine)
/* Map the BIOS / boot exception handler. */
memory_region_add_subregion(address_space_mem, 0x1fc00000LL, bios);
/* Load a BIOS / boot exception handler image. */
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name ?: BIOS_FILENAME);
if (bios_name == NULL) {
bios_name = BIOS_FILENAME;
}
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (filename) {
bios_size = load_image_targphys(filename, 0x1fc00000LL, BIOS_SIZE);
g_free(filename);
@@ -185,9 +184,10 @@ mips_mipssim_init(MachineState *machine)
bios_size = -1;
}
if ((bios_size < 0 || bios_size > BIOS_SIZE) &&
bios_name && !qtest_enabled()) {
!kernel_filename && !qtest_enabled()) {
/* Bail out if we have neither a kernel image nor boot vector code. */
error_report("Could not load MIPS bios '%s'", bios_name);
error_report("Could not load MIPS bios '%s', and no "
"-kernel argument was specified", bios_name);
exit(1);
} else {
/* We have a boot vector start address. */
+8 -8
View File
@@ -13,7 +13,6 @@
#include "qapi/error.h"
#include "qemu-common.h"
#include "cpu.h"
#include "hw/clock.h"
#include "hw/mips/mips.h"
#include "hw/mips/cpudevs.h"
#include "hw/intc/i8259.h"
@@ -102,7 +101,11 @@ static int64_t load_kernel(void)
(uint64_t *)&entry, NULL,
(uint64_t *)&kernel_high, NULL, big_endian,
EM_MIPS, 1, 0);
if (kernel_size < 0) {
if (kernel_size >= 0) {
if ((entry & ~0x7fffffffULL) == 0x80000000) {
entry = (int32_t)entry;
}
} else {
error_report("could not load kernel '%s': %s",
loaderparams.kernel_filename,
load_elf_strerror(kernel_size));
@@ -115,7 +118,8 @@ static int64_t load_kernel(void)
if (loaderparams.initrd_filename) {
initrd_size = get_image_size(loaderparams.initrd_filename);
if (initrd_size > 0) {
initrd_offset = ROUND_UP(kernel_high, INITRD_PAGE_SIZE);
initrd_offset = (kernel_high + ~INITRD_PAGE_MASK) &
INITRD_PAGE_MASK;
if (initrd_offset + initrd_size > ram_size) {
error_report("memory too small for initial ram disk '%s'",
loaderparams.initrd_filename);
@@ -178,7 +182,6 @@ void mips_r4k_init(MachineState *machine)
MemoryRegion *isa_io = g_new(MemoryRegion, 1);
MemoryRegion *isa_mem = g_new(MemoryRegion, 1);
int bios_size;
Clock *cpuclk;
MIPSCPU *cpu;
CPUMIPSState *env;
ResetData *reset_info;
@@ -189,11 +192,8 @@ void mips_r4k_init(MachineState *machine)
DriveInfo *dinfo;
int be;
cpuclk = clock_new(OBJECT(machine), "cpu-refclk");
clock_set_hz(cpuclk, 200000000); /* 200 MHz */
/* init CPUs */
cpu = mips_cpu_create_with_clock(machine->cpu_type, cpuclk);
cpu = MIPS_CPU(cpu_create(machine->cpu_type));
env = &cpu->env;
reset_info = g_malloc0(sizeof(ResetData));
+4
View File
@@ -109,6 +109,8 @@ static void macio_common_realize(PCIDevice *d, Error **errp)
qdev_prop_set_uint32(DEVICE(&s->escc), "disabled", 0);
qdev_prop_set_uint32(DEVICE(&s->escc), "frequency", ESCC_CLOCK);
qdev_prop_set_uint32(DEVICE(&s->escc), "it_shift", 4);
qdev_prop_set_chr(DEVICE(&s->escc), "chrA", serial_hd(0));
qdev_prop_set_chr(DEVICE(&s->escc), "chrB", serial_hd(1));
qdev_prop_set_uint32(DEVICE(&s->escc), "chnBtype", escc_serial);
qdev_prop_set_uint32(DEVICE(&s->escc), "chnAtype", escc_serial);
if (!qdev_realize(DEVICE(&s->escc), BUS(&s->macio_bus), errp)) {
@@ -456,6 +458,8 @@ static void macio_class_init(ObjectClass *klass, void *data)
k->class_id = PCI_CLASS_OTHERS << 8;
device_class_set_props(dc, macio_properties);
set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
/* Reason: Uses serial_hds in macio_instance_init */
dc->user_creatable = false;
}
static const TypeInfo macio_bus_info = {
+17 -2
View File
@@ -28,6 +28,7 @@
#include "hw/ppc/mac.h"
#include "hw/qdev-properties.h"
#include "hw/pci/pci.h"
#include "hw/intc/heathrow_pic.h"
#include "hw/irq.h"
#include "qapi/error.h"
#include "qemu/module.h"
@@ -40,6 +41,7 @@ struct GrackleState {
PCIHostState parent_obj;
uint32_t ofw_addr;
HeathrowState *pic;
qemu_irq irqs[4];
MemoryRegion pci_mmio;
MemoryRegion pci_hole;
@@ -60,6 +62,15 @@ static void pci_grackle_set_irq(void *opaque, int irq_num, int level)
qemu_set_irq(s->irqs[irq_num], level);
}
static void grackle_init_irqs(GrackleState *s)
{
int i;
for (i = 0; i < ARRAY_SIZE(s->irqs); i++) {
s->irqs[i] = qdev_get_gpio_in(DEVICE(s->pic), 0x15 + i);
}
}
static void grackle_realize(DeviceState *dev, Error **errp)
{
GrackleState *s = GRACKLE_PCI_HOST_BRIDGE(dev);
@@ -74,6 +85,7 @@ static void grackle_realize(DeviceState *dev, Error **errp)
0, 4, TYPE_PCI_BUS);
pci_create_simple(phb->bus, 0, "grackle");
grackle_init_irqs(s);
}
static void grackle_init(Object *obj)
@@ -94,12 +106,15 @@ static void grackle_init(Object *obj)
memory_region_init_io(&phb->data_mem, obj, &pci_host_data_le_ops,
DEVICE(obj), "pci-data-idx", 0x1000);
object_property_add_link(obj, "pic", TYPE_HEATHROW,
(Object **) &s->pic,
qdev_prop_allow_set_link_before_realize,
0);
sysbus_init_mmio(sbd, &phb->conf_mem);
sysbus_init_mmio(sbd, &phb->data_mem);
sysbus_init_mmio(sbd, &s->pci_hole);
sysbus_init_mmio(sbd, &s->pci_io);
qdev_init_gpio_out(DEVICE(obj), s->irqs, ARRAY_SIZE(s->irqs));
}
static void grackle_pci_realize(PCIDevice *d, Error **errp)
+36 -9
View File
@@ -32,6 +32,8 @@
#include "hw/pci-host/uninorth.h"
#include "trace.h"
static const int unin_irq_line[] = { 0x1b, 0x1c, 0x1d, 0x1e };
static int pci_unin_map_irq(PCIDevice *pci_dev, int irq_num)
{
return (irq_num + (pci_dev->devfn >> 3)) & 3;
@@ -41,7 +43,7 @@ static void pci_unin_set_irq(void *opaque, int irq_num, int level)
{
UNINHostState *s = opaque;
trace_unin_set_irq(irq_num, level);
trace_unin_set_irq(unin_irq_line[irq_num], level);
qemu_set_irq(s->irqs[irq_num], level);
}
@@ -110,6 +112,15 @@ static const MemoryRegionOps unin_data_ops = {
.endianness = DEVICE_LITTLE_ENDIAN,
};
static void pci_unin_init_irqs(UNINHostState *s)
{
int i;
for (i = 0; i < ARRAY_SIZE(s->irqs); i++) {
s->irqs[i] = qdev_get_gpio_in(DEVICE(s->pic), unin_irq_line[i]);
}
}
static char *pci_unin_main_ofw_unit_address(const SysBusDevice *dev)
{
UNINHostState *s = UNI_NORTH_PCI_HOST_BRIDGE(dev);
@@ -130,6 +141,7 @@ static void pci_unin_main_realize(DeviceState *dev, Error **errp)
PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS);
pci_create_simple(h->bus, PCI_DEVFN(11, 0), "uni-north-pci");
pci_unin_init_irqs(s);
/* DEC 21154 bridge */
#if 0
@@ -160,12 +172,15 @@ static void pci_unin_main_init(Object *obj)
"unin-pci-hole", &s->pci_mmio,
0x80000000ULL, 0x10000000ULL);
object_property_add_link(obj, "pic", TYPE_OPENPIC,
(Object **) &s->pic,
qdev_prop_allow_set_link_before_realize,
0);
sysbus_init_mmio(sbd, &h->conf_mem);
sysbus_init_mmio(sbd, &h->data_mem);
sysbus_init_mmio(sbd, &s->pci_hole);
sysbus_init_mmio(sbd, &s->pci_io);
qdev_init_gpio_out(DEVICE(obj), s->irqs, ARRAY_SIZE(s->irqs));
}
static void pci_u3_agp_realize(DeviceState *dev, Error **errp)
@@ -181,6 +196,7 @@ static void pci_u3_agp_realize(DeviceState *dev, Error **errp)
PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS);
pci_create_simple(h->bus, PCI_DEVFN(11, 0), "u3-agp");
pci_unin_init_irqs(s);
}
static void pci_u3_agp_init(Object *obj)
@@ -204,12 +220,15 @@ static void pci_u3_agp_init(Object *obj)
"unin-pci-hole", &s->pci_mmio,
0x80000000ULL, 0x70000000ULL);
object_property_add_link(obj, "pic", TYPE_OPENPIC,
(Object **) &s->pic,
qdev_prop_allow_set_link_before_realize,
0);
sysbus_init_mmio(sbd, &h->conf_mem);
sysbus_init_mmio(sbd, &h->data_mem);
sysbus_init_mmio(sbd, &s->pci_hole);
sysbus_init_mmio(sbd, &s->pci_io);
qdev_init_gpio_out(DEVICE(obj), s->irqs, ARRAY_SIZE(s->irqs));
}
static void pci_unin_agp_realize(DeviceState *dev, Error **errp)
@@ -225,6 +244,7 @@ static void pci_unin_agp_realize(DeviceState *dev, Error **errp)
PCI_DEVFN(11, 0), 4, TYPE_PCI_BUS);
pci_create_simple(h->bus, PCI_DEVFN(11, 0), "uni-north-agp");
pci_unin_init_irqs(s);
}
static void pci_unin_agp_init(Object *obj)
@@ -239,10 +259,13 @@ static void pci_unin_agp_init(Object *obj)
memory_region_init_io(&h->data_mem, OBJECT(h), &pci_host_data_le_ops,
obj, "unin-agp-conf-data", 0x1000);
object_property_add_link(obj, "pic", TYPE_OPENPIC,
(Object **) &s->pic,
qdev_prop_allow_set_link_before_realize,
0);
sysbus_init_mmio(sbd, &h->conf_mem);
sysbus_init_mmio(sbd, &h->data_mem);
qdev_init_gpio_out(DEVICE(obj), s->irqs, ARRAY_SIZE(s->irqs));
}
static void pci_unin_internal_realize(DeviceState *dev, Error **errp)
@@ -258,6 +281,7 @@ static void pci_unin_internal_realize(DeviceState *dev, Error **errp)
PCI_DEVFN(14, 0), 4, TYPE_PCI_BUS);
pci_create_simple(h->bus, PCI_DEVFN(14, 0), "uni-north-internal-pci");
pci_unin_init_irqs(s);
}
static void pci_unin_internal_init(Object *obj)
@@ -272,10 +296,13 @@ static void pci_unin_internal_init(Object *obj)
memory_region_init_io(&h->data_mem, OBJECT(h), &pci_host_data_le_ops,
obj, "unin-pci-conf-data", 0x1000);
object_property_add_link(obj, "pic", TYPE_OPENPIC,
(Object **) &s->pic,
qdev_prop_allow_set_link_before_realize,
0);
sysbus_init_mmio(sbd, &h->conf_mem);
sysbus_init_mmio(sbd, &h->data_mem);
qdev_init_gpio_out(DEVICE(obj), s->irqs, ARRAY_SIZE(s->irqs));
}
static void unin_main_pci_host_realize(PCIDevice *d, Error **errp)
+2
View File
@@ -39,8 +39,10 @@
/* SMP is not enabled, for now */
#define MAX_CPUS 1
#define BIOS_SIZE (1 * MiB)
#define NVRAM_SIZE 0x2000
#define PROM_FILENAME "openbios-ppc"
#define PROM_ADDR 0xfff00000
#define KERNEL_LOAD_ADDR 0x01000000
#define KERNEL_GAP 0x00100000
+16 -36
View File
@@ -82,8 +82,6 @@
#define NDRV_VGA_FILENAME "qemu_vga.ndrv"
#define PROM_BASE 0xfff00000
#define PROM_SIZE (1 * MiB)
static void fw_cfg_boot_set(void *opaque, const char *boot_device,
Error **errp)
@@ -102,7 +100,7 @@ static void ppc_core99_reset(void *opaque)
cpu_reset(CPU(cpu));
/* 970 CPUs want to get their initial IP as part of their boot protocol */
cpu->env.nip = PROM_BASE + 0x100;
cpu->env.nip = PROM_ADDR + 0x100;
}
/* PowerPC Mac99 hardware initialisation */
@@ -125,7 +123,6 @@ static void ppc_core99_init(MachineState *machine)
UNINHostState *uninorth_pci;
PCIBus *pci_bus;
PCIDevice *macio;
ESCCState *escc;
bool has_pmu, has_adb;
MACIOIDEState *macio_ide;
BusState *adb_bus;
@@ -156,29 +153,25 @@ static void ppc_core99_init(MachineState *machine)
/* allocate RAM */
memory_region_add_subregion(get_system_memory(), 0, machine->ram);
/* allocate and load firmware ROM */
memory_region_init_rom(bios, NULL, "ppc_core99.bios", PROM_SIZE,
/* allocate and load BIOS */
memory_region_init_rom(bios, NULL, "ppc_core99.bios", BIOS_SIZE,
&error_fatal);
memory_region_add_subregion(get_system_memory(), PROM_BASE, bios);
if (!bios_name) {
if (bios_name == NULL)
bios_name = PROM_FILENAME;
}
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
memory_region_add_subregion(get_system_memory(), PROM_ADDR, bios);
/* Load OpenBIOS (ELF) */
if (filename) {
/* Load OpenBIOS (ELF) */
bios_size = load_elf(filename, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, 1, PPC_ELF_MACHINE, 0, 0);
if (bios_size <= 0) {
/* or load binary ROM image */
bios_size = load_image_targphys(filename, PROM_BASE, PROM_SIZE);
}
g_free(filename);
} else {
bios_size = -1;
}
if (bios_size < 0 || bios_size > PROM_SIZE) {
if (bios_size < 0 || bios_size > BIOS_SIZE) {
error_report("could not load PowerPC bios '%s'", bios_name);
exit(1);
}
@@ -309,6 +302,8 @@ static void ppc_core99_init(MachineState *machine)
/* 970 gets a U3 bus */
/* Uninorth AGP bus */
dev = qdev_new(TYPE_U3_AGP_HOST_BRIDGE);
object_property_set_link(OBJECT(dev), "pic", OBJECT(pic_dev),
&error_abort);
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
uninorth_pci = U3_AGP_HOST_BRIDGE(dev);
s = SYS_BUS_DEVICE(dev);
@@ -321,38 +316,32 @@ static void ppc_core99_init(MachineState *machine)
sysbus_mmio_map(s, 0, 0xf0800000);
sysbus_mmio_map(s, 1, 0xf0c00000);
for (i = 0; i < 4; i++) {
qdev_connect_gpio_out(dev, i, qdev_get_gpio_in(pic_dev, 0x1b + i));
}
machine_arch = ARCH_MAC99_U3;
} else {
/* Use values found on a real PowerMac */
/* Uninorth AGP bus */
dev = qdev_new(TYPE_UNI_NORTH_AGP_HOST_BRIDGE);
object_property_set_link(OBJECT(dev), "pic", OBJECT(pic_dev),
&error_abort);
s = SYS_BUS_DEVICE(dev);
sysbus_realize_and_unref(s, &error_fatal);
sysbus_mmio_map(s, 0, 0xf0800000);
sysbus_mmio_map(s, 1, 0xf0c00000);
for (i = 0; i < 4; i++) {
qdev_connect_gpio_out(dev, i, qdev_get_gpio_in(pic_dev, 0x1b + i));
}
/* Uninorth internal bus */
dev = qdev_new(TYPE_UNI_NORTH_INTERNAL_PCI_HOST_BRIDGE);
object_property_set_link(OBJECT(dev), "pic", OBJECT(pic_dev),
&error_abort);
s = SYS_BUS_DEVICE(dev);
sysbus_realize_and_unref(s, &error_fatal);
sysbus_mmio_map(s, 0, 0xf4800000);
sysbus_mmio_map(s, 1, 0xf4c00000);
for (i = 0; i < 4; i++) {
qdev_connect_gpio_out(dev, i, qdev_get_gpio_in(pic_dev, 0x1b + i));
}
/* Uninorth main bus */
dev = qdev_new(TYPE_UNI_NORTH_PCI_HOST_BRIDGE);
qdev_prop_set_uint32(dev, "ofw-addr", 0xf2000000);
object_property_set_link(OBJECT(dev), "pic", OBJECT(pic_dev),
&error_abort);
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
uninorth_pci = UNI_NORTH_PCI_HOST_BRIDGE(dev);
s = SYS_BUS_DEVICE(dev);
@@ -365,10 +354,6 @@ static void ppc_core99_init(MachineState *machine)
sysbus_mmio_map(s, 0, 0xf2800000);
sysbus_mmio_map(s, 1, 0xf2c00000);
for (i = 0; i < 4; i++) {
qdev_connect_gpio_out(dev, i, qdev_get_gpio_in(pic_dev, 0x1b + i));
}
machine_arch = ARCH_MAC99;
}
@@ -395,11 +380,6 @@ static void ppc_core99_init(MachineState *machine)
qdev_prop_set_bit(dev, "has-adb", has_adb);
object_property_set_link(OBJECT(macio), "pic", OBJECT(pic_dev),
&error_abort);
escc = ESCC(object_resolve_path_component(OBJECT(macio), "escc"));
qdev_prop_set_chr(DEVICE(escc), "chrA", serial_hd(0));
qdev_prop_set_chr(DEVICE(escc), "chrB", serial_hd(1));
pci_realize_and_unref(macio, pci_bus, &error_fatal);
/* We only emulate 2 out of 3 IDE controllers for now */
+31 -49
View File
@@ -59,8 +59,6 @@
#define NDRV_VGA_FILENAME "qemu_vga.ndrv"
#define GRACKLE_BASE 0xfec00000
#define PROM_BASE 0xffc00000
#define PROM_SIZE (4 * MiB)
static void fw_cfg_boot_set(void *opaque, const char *boot_device,
Error **errp)
@@ -83,22 +81,24 @@ static void ppc_heathrow_reset(void *opaque)
static void ppc_heathrow_init(MachineState *machine)
{
ram_addr_t ram_size = machine->ram_size;
const char *kernel_filename = machine->kernel_filename;
const char *kernel_cmdline = machine->kernel_cmdline;
const char *initrd_filename = machine->initrd_filename;
const char *boot_device = machine->boot_order;
MemoryRegion *sysmem = get_system_memory();
PowerPCCPU *cpu = NULL;
CPUPPCState *env = NULL;
char *filename;
int i;
int linux_boot, i;
MemoryRegion *bios = g_new(MemoryRegion, 1);
uint32_t kernel_base, initrd_base, cmdline_base = 0;
int32_t kernel_size, initrd_size;
PCIBus *pci_bus;
PCIDevice *macio;
MACIOIDEState *macio_ide;
ESCCState *escc;
SysBusDevice *s;
DeviceState *dev, *pic_dev;
BusState *adb_bus;
uint64_t bios_addr;
int bios_size;
unsigned int smp_cpus = machine->smp.cpus;
uint16_t ppc_boot_device;
@@ -106,6 +106,8 @@ static void ppc_heathrow_init(MachineState *machine)
void *fw_cfg;
uint64_t tbfreq;
linux_boot = (kernel_filename != NULL);
/* init CPUs */
for (i = 0; i < smp_cpus; i++) {
cpu = POWERPC_CPU(cpu_create(machine->cpu_type));
@@ -123,39 +125,31 @@ static void ppc_heathrow_init(MachineState *machine)
exit(1);
}
memory_region_add_subregion(get_system_memory(), 0, machine->ram);
memory_region_add_subregion(sysmem, 0, machine->ram);
/* allocate and load firmware ROM */
memory_region_init_rom(bios, NULL, "ppc_heathrow.bios", PROM_SIZE,
/* allocate and load BIOS */
memory_region_init_rom(bios, NULL, "ppc_heathrow.bios", BIOS_SIZE,
&error_fatal);
memory_region_add_subregion(get_system_memory(), PROM_BASE, bios);
if (!bios_name) {
if (bios_name == NULL)
bios_name = PROM_FILENAME;
}
filename = qemu_find_file(QEMU_FILE_TYPE_BIOS, bios_name);
if (filename) {
/* Load OpenBIOS (ELF) */
bios_size = load_elf(filename, NULL, NULL, NULL, NULL, &bios_addr,
NULL, NULL, 1, PPC_ELF_MACHINE, 0, 0);
/* Unfortunately, load_elf sign-extends reading elf32 */
bios_addr = (uint32_t)bios_addr;
memory_region_add_subregion(sysmem, PROM_ADDR, bios);
if (bios_size <= 0) {
/* or if could not load ELF try loading a binary ROM image */
bios_size = load_image_targphys(filename, PROM_BASE, PROM_SIZE);
bios_addr = PROM_BASE;
}
/* Load OpenBIOS (ELF) */
if (filename) {
bios_size = load_elf(filename, NULL, 0, NULL, NULL, NULL, NULL, NULL,
1, PPC_ELF_MACHINE, 0, 0);
g_free(filename);
} else {
bios_size = -1;
}
if (bios_size < 0 || bios_addr - PROM_BASE + bios_size > PROM_SIZE) {
if (bios_size < 0 || bios_size > BIOS_SIZE) {
error_report("could not load PowerPC bios '%s'", bios_name);
exit(1);
}
if (machine->kernel_filename) {
if (linux_boot) {
int bswap_needed;
#ifdef BSWAP_NEEDED
@@ -164,32 +158,29 @@ static void ppc_heathrow_init(MachineState *machine)
bswap_needed = 0;
#endif
kernel_base = KERNEL_LOAD_ADDR;
kernel_size = load_elf(machine->kernel_filename, NULL,
kernel_size = load_elf(kernel_filename, NULL,
translate_kernel_address, NULL, NULL, NULL,
NULL, NULL, 1, PPC_ELF_MACHINE, 0, 0);
if (kernel_size < 0)
kernel_size = load_aout(machine->kernel_filename, kernel_base,
kernel_size = load_aout(kernel_filename, kernel_base,
ram_size - kernel_base, bswap_needed,
TARGET_PAGE_SIZE);
if (kernel_size < 0)
kernel_size = load_image_targphys(machine->kernel_filename,
kernel_size = load_image_targphys(kernel_filename,
kernel_base,
ram_size - kernel_base);
if (kernel_size < 0) {
error_report("could not load kernel '%s'",
machine->kernel_filename);
error_report("could not load kernel '%s'", kernel_filename);
exit(1);
}
/* load initrd */
if (machine->initrd_filename) {
initrd_base = TARGET_PAGE_ALIGN(kernel_base + kernel_size +
KERNEL_GAP);
initrd_size = load_image_targphys(machine->initrd_filename,
initrd_base,
if (initrd_filename) {
initrd_base = TARGET_PAGE_ALIGN(kernel_base + kernel_size + KERNEL_GAP);
initrd_size = load_image_targphys(initrd_filename, initrd_base,
ram_size - initrd_base);
if (initrd_size < 0) {
error_report("could not load initial ram disk '%s'",
machine->initrd_filename);
initrd_filename);
exit(1);
}
cmdline_base = TARGET_PAGE_ALIGN(initrd_base + initrd_size);
@@ -261,9 +252,10 @@ static void ppc_heathrow_init(MachineState *machine)
/* Grackle PCI host bridge */
dev = qdev_new(TYPE_GRACKLE_PCI_HOST_BRIDGE);
qdev_prop_set_uint32(dev, "ofw-addr", 0x80000000);
object_property_set_link(OBJECT(dev), "pic", OBJECT(pic_dev),
&error_abort);
s = SYS_BUS_DEVICE(dev);
sysbus_realize_and_unref(s, &error_fatal);
sysbus_mmio_map(s, 0, GRACKLE_BASE);
sysbus_mmio_map(s, 1, GRACKLE_BASE + 0x200000);
/* PCI hole */
@@ -273,10 +265,6 @@ static void ppc_heathrow_init(MachineState *machine)
memory_region_add_subregion(get_system_memory(), 0xfe000000,
sysbus_mmio_get_region(s, 3));
for (i = 0; i < 4; i++) {
qdev_connect_gpio_out(dev, i, qdev_get_gpio_in(pic_dev, 0x15 + i));
}
pci_bus = PCI_HOST_BRIDGE(dev)->bus;
pci_vga_init(pci_bus);
@@ -288,16 +276,11 @@ static void ppc_heathrow_init(MachineState *machine)
ide_drive_get(hd, ARRAY_SIZE(hd));
/* MacIO */
macio = pci_new(PCI_DEVFN(16, 0), TYPE_OLDWORLD_MACIO);
macio = pci_new(-1, TYPE_OLDWORLD_MACIO);
dev = DEVICE(macio);
qdev_prop_set_uint64(dev, "frequency", tbfreq);
object_property_set_link(OBJECT(macio), "pic", OBJECT(pic_dev),
&error_abort);
escc = ESCC(object_resolve_path_component(OBJECT(macio), "escc"));
qdev_prop_set_chr(DEVICE(escc), "chrA", serial_hd(0));
qdev_prop_set_chr(DEVICE(escc), "chrB", serial_hd(1));
pci_realize_and_unref(macio, pci_bus, &error_fatal);
macio_ide = MACIO_IDE(object_resolve_path_component(OBJECT(macio),
@@ -341,10 +324,9 @@ static void ppc_heathrow_init(MachineState *machine)
fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, ARCH_HEATHROW);
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, kernel_base);
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
if (machine->kernel_cmdline) {
if (kernel_cmdline) {
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, cmdline_base);
pstrcpy_targphys("cmdline", cmdline_base, TARGET_PAGE_SIZE,
machine->kernel_cmdline);
pstrcpy_targphys("cmdline", cmdline_base, TARGET_PAGE_SIZE, kernel_cmdline);
} else {
fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0);
}
+1 -9
View File
@@ -28,8 +28,6 @@
#include "qemu-common.h"
#include "cpu.h"
#include "hw/ppc/ppc.h"
#include "hw/qdev-properties.h"
#include "hw/sysbus.h"
#include "ppc405.h"
#include "hw/rtc/m48t59.h"
#include "hw/block/flash.h"
@@ -147,8 +145,6 @@ static void ref405ep_init(MachineState *machine)
char *filename;
ppc4xx_bd_info_t bd;
CPUPPCState *env;
DeviceState *dev;
SysBusDevice *s;
qemu_irq *pic;
MemoryRegion *bios;
MemoryRegion *sram = g_new(MemoryRegion, 1);
@@ -231,11 +227,7 @@ static void ref405ep_init(MachineState *machine)
/* Register FPGA */
ref405ep_fpga_init(sysmem, 0xF0300000);
/* Register NVRAM */
dev = qdev_new("sysbus-m48t08");
qdev_prop_set_int32(dev, "base-year", 1968);
s = SYS_BUS_DEVICE(dev);
sysbus_realize_and_unref(s, &error_fatal);
sysbus_mmio_map(s, 0, 0xF0000000);
m48t59_init(NULL, 0xF0000000, 0, 8192, 1968, 8);
/* Load kernel */
linux_boot = (kernel_filename != NULL);
if (linux_boot) {
+25
View File
@@ -58,6 +58,31 @@ static M48txxInfo m48txx_isa_info[] = {
}
};
Nvram *m48t59_init_isa(ISABus *bus, uint32_t io_base, uint16_t size,
int base_year, int model)
{
ISADevice *isa_dev;
DeviceState *dev;
int i;
for (i = 0; i < ARRAY_SIZE(m48txx_isa_info); i++) {
if (m48txx_isa_info[i].size != size ||
m48txx_isa_info[i].model != model) {
continue;
}
isa_dev = isa_new(m48txx_isa_info[i].bus_name);
dev = DEVICE(isa_dev);
qdev_prop_set_uint32(dev, "iobase", io_base);
qdev_prop_set_int32(dev, "base-year", base_year);
isa_realize_and_unref(isa_dev, bus, &error_fatal);
return NVRAM(dev);
}
assert(false);
return NULL;
}
static uint32_t m48txx_isa_read(Nvram *obj, uint32_t addr)
{
M48txxISAState *d = M48TXX_ISA(obj);
+35
View File
@@ -564,6 +564,41 @@ const MemoryRegionOps m48t59_io_ops = {
.endianness = DEVICE_LITTLE_ENDIAN,
};
/* Initialisation routine */
Nvram *m48t59_init(qemu_irq IRQ, hwaddr mem_base,
uint32_t io_base, uint16_t size, int base_year,
int model)
{
DeviceState *dev;
SysBusDevice *s;
int i;
for (i = 0; i < ARRAY_SIZE(m48txx_sysbus_info); i++) {
if (m48txx_sysbus_info[i].size != size ||
m48txx_sysbus_info[i].model != model) {
continue;
}
dev = qdev_new(m48txx_sysbus_info[i].bus_name);
qdev_prop_set_int32(dev, "base-year", base_year);
s = SYS_BUS_DEVICE(dev);
sysbus_realize_and_unref(s, &error_fatal);
sysbus_connect_irq(s, 0, IRQ);
if (io_base != 0) {
memory_region_add_subregion(get_system_io(), io_base,
sysbus_mmio_get_region(s, 1));
}
if (mem_base != 0) {
sysbus_mmio_map(s, 0, mem_base);
}
return NVRAM(s);
}
assert(false);
return NULL;
}
void m48t59_realize_common(M48t59State *s, Error **errp)
{
s->buffer = g_malloc0(s->size);
+8 -22
View File
@@ -53,8 +53,6 @@
#define SDSC_MAX_CAPACITY (2 * GiB)
#define INVALID_ADDRESS UINT32_MAX
typedef enum {
sd_r0 = 0, /* no response */
sd_r1, /* normal response command */
@@ -577,8 +575,8 @@ static void sd_reset(DeviceState *dev)
sd->wpgrps_size = sect;
sd->wp_groups = bitmap_new(sd->wpgrps_size);
memset(sd->function_group, 0, sizeof(sd->function_group));
sd->erase_start = INVALID_ADDRESS;
sd->erase_end = INVALID_ADDRESS;
sd->erase_start = 0;
sd->erase_end = 0;
sd->size = size;
sd->blk_len = 0x200;
sd->pwd_len = 0;
@@ -666,8 +664,8 @@ static int sd_vmstate_pre_load(void *opaque)
static const VMStateDescription sd_vmstate = {
.name = "sd-card",
.version_id = 2,
.minimum_version_id = 2,
.version_id = 1,
.minimum_version_id = 1,
.pre_load = sd_vmstate_pre_load,
.fields = (VMStateField[]) {
VMSTATE_UINT32(mode, SDState),
@@ -751,12 +749,9 @@ static void sd_erase(SDState *sd)
uint64_t erase_start = sd->erase_start;
uint64_t erase_end = sd->erase_end;
trace_sdcard_erase(sd->erase_start, sd->erase_end);
if (sd->erase_start == INVALID_ADDRESS
|| sd->erase_end == INVALID_ADDRESS) {
trace_sdcard_erase();
if (!sd->erase_start || !sd->erase_end) {
sd->card_status |= ERASE_SEQ_ERROR;
sd->erase_start = INVALID_ADDRESS;
sd->erase_end = INVALID_ADDRESS;
return;
}
@@ -766,21 +761,13 @@ static void sd_erase(SDState *sd)
erase_end *= 512;
}
if (sd->erase_start > sd->size || sd->erase_end > sd->size) {
sd->card_status |= OUT_OF_RANGE;
sd->erase_start = INVALID_ADDRESS;
sd->erase_end = INVALID_ADDRESS;
return;
}
erase_start = sd_addr_to_wpnum(erase_start);
erase_end = sd_addr_to_wpnum(erase_end);
sd->erase_start = INVALID_ADDRESS;
sd->erase_end = INVALID_ADDRESS;
sd->erase_start = 0;
sd->erase_end = 0;
sd->csd[14] |= 0x40;
for (i = erase_start; i <= erase_end; i++) {
assert(i < sd->wpgrps_size);
if (test_bit(i, sd->wp_groups)) {
sd->card_status |= WP_ERASE_SKIP;
}
@@ -795,7 +782,6 @@ static uint32_t sd_wpbits(SDState *sd, uint64_t addr)
wpnum = sd_addr_to_wpnum(addr);
for (i = 0; i < 32; i++, wpnum++, addr += WPGROUP_SIZE) {
assert(wpnum < sd->wpgrps_size);
if (addr < sd->size && test_bit(wpnum, sd->wp_groups)) {
ret |= (1 << i);
}
+6 -35
View File
@@ -1,8 +1,6 @@
/*
* SD Association Host Standard Specification v2.0 controller emulation
*
* Datasheet: PartA2_SD_Host_Controller_Simplified_Specification_Ver2.00.pdf
*
* Copyright (c) 2011 Samsung Electronics Co., Ltd.
* Mitsyanko Igor <i.mitsyanko@samsung.com>
* Peter A.G. Crosthwaite <peter.crosthwaite@petalogix.com>
@@ -218,14 +216,9 @@ static uint8_t sdhci_slotint(SDHCIState *s)
((s->norintsts & SDHC_NIS_REMOVE) && (s->wakcon & SDHC_WKUP_ON_RMV));
}
/* Return true if IRQ was pending and delivered */
static bool sdhci_update_irq(SDHCIState *s)
static inline void sdhci_update_irq(SDHCIState *s)
{
bool pending = sdhci_slotint(s);
qemu_set_irq(s->irq, pending);
return pending;
qemu_set_irq(s->irq, sdhci_slotint(s));
}
static void sdhci_raise_insertion_irq(void *opaque)
@@ -736,12 +729,6 @@ static void sdhci_do_adma(SDHCIState *s)
ADMADescr dscr = {};
int i;
if (s->trnmod & SDHC_TRNS_BLK_CNT_EN && !s->blkcnt) {
/* Stop Multiple Transfer */
sdhci_end_transfer(s);
return;
}
for (i = 0; i < SDHC_ADMA_DESCS_PER_DELAY; ++i) {
s->admaerr &= ~SDHC_ADMAERR_LENGTH_MISMATCH;
@@ -767,6 +754,7 @@ static void sdhci_do_adma(SDHCIState *s)
switch (dscr.attr & SDHC_ADMA_ATTR_ACT_MASK) {
case SDHC_ADMA_ATTR_ACT_TRAN: /* data transfer */
if (s->trnmod & SDHC_TRNS_READ) {
while (length) {
if (s->data_count == 0) {
@@ -837,10 +825,7 @@ static void sdhci_do_adma(SDHCIState *s)
s->norintsts |= SDHC_NIS_DMA;
}
if (sdhci_update_irq(s) && !(dscr.attr & SDHC_ADMA_ATTR_END)) {
/* IRQ delivered, reschedule current transfer */
break;
}
sdhci_update_irq(s);
}
/* ADMA transfer terminates if blkcnt == 0 or by END attribute */
@@ -956,21 +941,11 @@ sdhci_buff_access_is_sequential(SDHCIState *s, unsigned byte_num)
return true;
}
static void sdhci_resume_pending_transfer(SDHCIState *s)
{
timer_del(s->transfer_timer);
sdhci_data_transfer(s);
}
static uint64_t sdhci_read(void *opaque, hwaddr offset, unsigned size)
{
SDHCIState *s = (SDHCIState *)opaque;
uint32_t ret = 0;
if (timer_pending(s->transfer_timer)) {
sdhci_resume_pending_transfer(s);
}
switch (offset & ~0x3) {
case SDHC_SYSAD:
ret = s->sdmasysad;
@@ -1114,10 +1089,6 @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)
uint32_t value = val;
value <<= shift;
if (timer_pending(s->transfer_timer)) {
sdhci_resume_pending_transfer(s);
}
switch (offset & ~0x3) {
case SDHC_SYSAD:
s->sdmasysad = (s->sdmasysad & mask) | value;
@@ -1134,14 +1105,14 @@ sdhci_write(void *opaque, hwaddr offset, uint64_t val, unsigned size)
break;
case SDHC_BLKSIZE:
if (!TRANSFERRING_DATA(s->prnsts)) {
MASKED_WRITE(s->blksize, mask, extract32(value, 0, 12));
MASKED_WRITE(s->blksize, mask, value);
MASKED_WRITE(s->blkcnt, mask >> 16, value >> 16);
}
/* Limit block size to the maximum buffer size */
if (extract32(s->blksize, 0, 12) > s->buf_maxsz) {
qemu_log_mask(LOG_GUEST_ERROR, "%s: Size 0x%x is larger than "
"the maximum buffer 0x%x\n", __func__, s->blksize,
"the maximum buffer 0x%x", __func__, s->blksize,
s->buf_maxsz);
s->blksize = deposit32(s->blksize, 0, 12, s->buf_maxsz);
+1 -1
View File
@@ -46,7 +46,7 @@ sdcard_reset(void) ""
sdcard_set_blocklen(uint16_t length) "0x%03x"
sdcard_inserted(bool readonly) "read_only: %u"
sdcard_ejected(void) ""
sdcard_erase(uint32_t first, uint32_t last) "addr first 0x%" PRIx32" last 0x%" PRIx32
sdcard_erase(void) ""
sdcard_lock(void) ""
sdcard_unlock(void) ""
sdcard_read_block(uint64_t addr, uint32_t len) "addr 0x%" PRIx64 " size 0x%x"
+2 -8
View File
@@ -837,7 +837,7 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef,
{
DeviceState *slavio_intctl;
unsigned int i;
Nvram *nvram;
void *nvram;
qemu_irq *cpu_irqs[MAX_CPUS], slavio_irq[32], slavio_cpu_irq[MAX_CPUS];
qemu_irq fdc_tc;
unsigned long kernel_size;
@@ -966,13 +966,7 @@ static void sun4m_hw_init(const struct sun4m_hwdef *hwdef,
create_unimplemented_device("SUNW,sx", hwdef->sx_base, 0x2000);
}
dev = qdev_new("sysbus-m48t08");
qdev_prop_set_int32(dev, "base-year", 1968);
s = SYS_BUS_DEVICE(dev);
sysbus_realize_and_unref(s, &error_fatal);
sysbus_connect_irq(s, 0, slavio_irq[0]);
sysbus_mmio_map(s, 0, hwdef->nvram_base);
nvram = NVRAM(dev);
nvram = m48t59_init(slavio_irq[0], hwdef->nvram_base, 0, 0x2000, 1968, 8);
slavio_timer_init_all(hwdef->counter_base, slavio_irq[19], slavio_cpu_irq, smp_cpus);
+2 -5
View File
@@ -671,13 +671,10 @@ static void sun4uv_init(MemoryRegion *address_space_mem,
pci_ide_create_devs(pci_dev);
/* Map NVRAM into I/O (ebus) space */
dev = qdev_new("sysbus-m48t59");
qdev_prop_set_int32(dev, "base-year", 1968);
s = SYS_BUS_DEVICE(dev);
sysbus_realize_and_unref(s, &error_fatal);
nvram = m48t59_init(NULL, 0, 0, NVRAM_SIZE, 1968, 59);
s = SYS_BUS_DEVICE(nvram);
memory_region_add_subregion(pci_address_space_io(ebus), 0x2000,
sysbus_mmio_get_region(s, 0));
nvram = NVRAM(dev);
initrd_size = 0;
initrd_addr = 0;
+21 -36
View File
@@ -28,13 +28,20 @@ REG32(COMPARE1, 0x10)
REG32(COMPARE2, 0x14)
REG32(COMPARE3, 0x18)
static void bcm2835_systmr_timer_expire(void *opaque)
static void bcm2835_systmr_update_irq(BCM2835SystemTimerState *s)
{
BCM2835SystemTimerCompare *tmr = opaque;
bool enable = !!s->reg.status;
trace_bcm2835_systmr_timer_expired(tmr->id);
tmr->state->reg.ctrl_status |= 1 << tmr->id;
qemu_set_irq(tmr->irq, 1);
trace_bcm2835_systmr_irq(enable);
qemu_set_irq(s->irq, enable);
}
static void bcm2835_systmr_update_compare(BCM2835SystemTimerState *s,
unsigned timer_index)
{
/* TODO fow now, since neither Linux nor U-boot use these timers. */
qemu_log_mask(LOG_UNIMP, "COMPARE register %u not implemented\n",
timer_index);
}
static uint64_t bcm2835_systmr_read(void *opaque, hwaddr offset,
@@ -45,7 +52,7 @@ static uint64_t bcm2835_systmr_read(void *opaque, hwaddr offset,
switch (offset) {
case A_CTRL_STATUS:
r = s->reg.ctrl_status;
r = s->reg.status;
break;
case A_COMPARE0 ... A_COMPARE3:
r = s->reg.compare[(offset - A_COMPARE0) >> 2];
@@ -68,33 +75,19 @@ static uint64_t bcm2835_systmr_read(void *opaque, hwaddr offset,
}
static void bcm2835_systmr_write(void *opaque, hwaddr offset,
uint64_t value64, unsigned size)
uint64_t value, unsigned size)
{
BCM2835SystemTimerState *s = BCM2835_SYSTIMER(opaque);
int index;
uint32_t value = value64;
uint32_t triggers_delay_us;
uint64_t now;
trace_bcm2835_systmr_write(offset, value);
switch (offset) {
case A_CTRL_STATUS:
s->reg.ctrl_status &= ~value; /* Ack */
for (index = 0; index < ARRAY_SIZE(s->tmr); index++) {
if (extract32(value, index, 1)) {
trace_bcm2835_systmr_irq_ack(index);
qemu_set_irq(s->tmr[index].irq, 0);
}
}
s->reg.status &= ~value; /* Ack */
bcm2835_systmr_update_irq(s);
break;
case A_COMPARE0 ... A_COMPARE3:
index = (offset - A_COMPARE0) >> 2;
s->reg.compare[index] = value;
now = qemu_clock_get_us(QEMU_CLOCK_VIRTUAL);
/* Compare lower 32-bits of the free-running counter. */
triggers_delay_us = value - now;
trace_bcm2835_systmr_run(index, triggers_delay_us);
timer_mod(&s->tmr[index].timer, now + triggers_delay_us);
s->reg.compare[(offset - A_COMPARE0) >> 2] = value;
bcm2835_systmr_update_compare(s, (offset - A_COMPARE0) >> 2);
break;
case A_COUNTER_LOW:
case A_COUNTER_HIGH:
@@ -132,14 +125,7 @@ static void bcm2835_systmr_realize(DeviceState *dev, Error **errp)
memory_region_init_io(&s->iomem, OBJECT(dev), &bcm2835_systmr_ops,
s, "bcm2835-sys-timer", 0x20);
sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem);
for (size_t i = 0; i < ARRAY_SIZE(s->tmr); i++) {
s->tmr[i].id = i;
s->tmr[i].state = s;
sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->tmr[i].irq);
timer_init_us(&s->tmr[i].timer, QEMU_CLOCK_VIRTUAL,
bcm2835_systmr_timer_expire, &s->tmr[i]);
}
sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq);
}
static const VMStateDescription bcm2835_systmr_vmstate = {
@@ -147,9 +133,8 @@ static const VMStateDescription bcm2835_systmr_vmstate = {
.version_id = 1,
.minimum_version_id = 1,
.fields = (VMStateField[]) {
VMSTATE_UINT32(reg.ctrl_status, BCM2835SystemTimerState),
VMSTATE_UINT32_ARRAY(reg.compare, BCM2835SystemTimerState,
BCM2835_SYSTIMER_COUNT),
VMSTATE_UINT32(reg.status, BCM2835SystemTimerState),
VMSTATE_UINT32_ARRAY(reg.compare, BCM2835SystemTimerState, 4),
VMSTATE_END_OF_LIST()
}
};
+2 -4
View File
@@ -77,11 +77,9 @@ nrf51_timer_write(uint8_t timer_id, uint64_t addr, uint32_t value, unsigned size
nrf51_timer_set_count(uint8_t timer_id, uint8_t counter_id, uint32_t value) "timer %u counter %u count 0x%" PRIx32
# bcm2835_systmr.c
bcm2835_systmr_timer_expired(unsigned id) "timer #%u expired"
bcm2835_systmr_irq_ack(unsigned id) "timer #%u acked"
bcm2835_systmr_irq(bool enable) "timer irq state %u"
bcm2835_systmr_read(uint64_t offset, uint64_t data) "timer read: offset 0x%" PRIx64 " data 0x%" PRIx64
bcm2835_systmr_write(uint64_t offset, uint32_t data) "timer write: offset 0x%" PRIx64 " data 0x%" PRIx32
bcm2835_systmr_run(unsigned id, uint64_t delay_us) "timer #%u expiring in %"PRIu64" us"
bcm2835_systmr_write(uint64_t offset, uint64_t data) "timer write: offset 0x%" PRIx64 " data 0x%" PRIx64
# avr_timer16.c
avr_timer16_read(uint8_t addr, uint8_t value) "timer16 read addr:%u value:%u"
+4 -2
View File
@@ -32,6 +32,8 @@ config USB_EHCI_SYSBUS
config USB_XHCI
bool
default y if PCI_DEVICES
depends on PCI
select USB
config USB_XHCI_PCI
@@ -48,8 +50,8 @@ config USB_XHCI_NEC
config USB_XHCI_SYSBUS
bool
default y
select USB_XHCI
default y if USB_XHCI
select USB
config USB_MUSB
bool
+19 -87
View File
@@ -238,24 +238,13 @@ static void dwc2_handle_packet(DWC2State *s, uint32_t devadr, USBDevice *dev,
pid = get_field(hctsiz, TSIZ_SC_MC_PID);
pcnt = get_field(hctsiz, TSIZ_PKTCNT);
len = get_field(hctsiz, TSIZ_XFERSIZE);
if (len > DWC2_MAX_XFER_SIZE) {
qemu_log_mask(LOG_GUEST_ERROR,
"%s: HCTSIZ transfer size too large\n", __func__);
return;
}
assert(len <= DWC2_MAX_XFER_SIZE);
chan = index >> 3;
p = &s->packet[chan];
trace_usb_dwc2_handle_packet(chan, dev, &p->packet, epnum, types[eptype],
dirs[epdir], mps, len, pcnt);
if (mps == 0) {
qemu_log_mask(LOG_GUEST_ERROR,
"%s: Bad HCCHAR_MPS set to zero\n", __func__);
return;
}
if (eptype == USB_ENDPOINT_XFER_CONTROL && pid == TSIZ_SC_MC_PID_SETUP) {
pid = USB_TOKEN_SETUP;
} else {
@@ -674,12 +663,7 @@ static uint64_t dwc2_glbreg_read(void *ptr, hwaddr addr, int index,
DWC2State *s = ptr;
uint32_t val;
if (addr > GINTSTS2) {
qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%"HWADDR_PRIx"\n",
__func__, addr);
return 0;
}
assert(addr <= GINTSTS2);
val = s->glbreg[index];
switch (addr) {
@@ -706,12 +690,7 @@ static void dwc2_glbreg_write(void *ptr, hwaddr addr, int index, uint64_t val,
uint32_t old;
int iflg = 0;
if (addr > GINTSTS2) {
qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%"HWADDR_PRIx"\n",
__func__, addr);
return;
}
assert(addr <= GINTSTS2);
mmio = &s->glbreg[index];
old = *mmio;
@@ -736,34 +715,27 @@ static void dwc2_glbreg_write(void *ptr, hwaddr addr, int index, uint64_t val,
val &= ~GRSTCTL_DMAREQ;
if (!(old & GRSTCTL_TXFFLSH) && (val & GRSTCTL_TXFFLSH)) {
/* TODO - TX fifo flush */
qemu_log_mask(LOG_UNIMP, "%s: Tx FIFO flush not implemented\n",
__func__);
qemu_log_mask(LOG_UNIMP, "Tx FIFO flush not implemented\n");
}
if (!(old & GRSTCTL_RXFFLSH) && (val & GRSTCTL_RXFFLSH)) {
/* TODO - RX fifo flush */
qemu_log_mask(LOG_UNIMP, "%s: Rx FIFO flush not implemented\n",
__func__);
qemu_log_mask(LOG_UNIMP, "Rx FIFO flush not implemented\n");
}
if (!(old & GRSTCTL_IN_TKNQ_FLSH) && (val & GRSTCTL_IN_TKNQ_FLSH)) {
/* TODO - device IN token queue flush */
qemu_log_mask(LOG_UNIMP, "%s: Token queue flush not implemented\n",
__func__);
qemu_log_mask(LOG_UNIMP, "Token queue flush not implemented\n");
}
if (!(old & GRSTCTL_FRMCNTRRST) && (val & GRSTCTL_FRMCNTRRST)) {
/* TODO - host frame counter reset */
qemu_log_mask(LOG_UNIMP,
"%s: Frame counter reset not implemented\n",
__func__);
qemu_log_mask(LOG_UNIMP, "Frame counter reset not implemented\n");
}
if (!(old & GRSTCTL_HSFTRST) && (val & GRSTCTL_HSFTRST)) {
/* TODO - host soft reset */
qemu_log_mask(LOG_UNIMP, "%s: Host soft reset not implemented\n",
__func__);
qemu_log_mask(LOG_UNIMP, "Host soft reset not implemented\n");
}
if (!(old & GRSTCTL_CSFTRST) && (val & GRSTCTL_CSFTRST)) {
/* TODO - core soft reset */
qemu_log_mask(LOG_UNIMP, "%s: Core soft reset not implemented\n",
__func__);
qemu_log_mask(LOG_UNIMP, "Core soft reset not implemented\n");
}
/* don't allow clearing of self-clearing bits */
val |= old & (GRSTCTL_TXFFLSH | GRSTCTL_RXFFLSH |
@@ -802,12 +774,7 @@ static uint64_t dwc2_fszreg_read(void *ptr, hwaddr addr, int index,
DWC2State *s = ptr;
uint32_t val;
if (addr != HPTXFSIZ) {
qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%"HWADDR_PRIx"\n",
__func__, addr);
return 0;
}
assert(addr == HPTXFSIZ);
val = s->fszreg[index];
trace_usb_dwc2_fszreg_read(addr, val);
@@ -822,12 +789,7 @@ static void dwc2_fszreg_write(void *ptr, hwaddr addr, int index, uint64_t val,
uint32_t *mmio;
uint32_t old;
if (addr != HPTXFSIZ) {
qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%"HWADDR_PRIx"\n",
__func__, addr);
return;
}
assert(addr == HPTXFSIZ);
mmio = &s->fszreg[index];
old = *mmio;
@@ -848,12 +810,7 @@ static uint64_t dwc2_hreg0_read(void *ptr, hwaddr addr, int index,
DWC2State *s = ptr;
uint32_t val;
if (addr < HCFG || addr > HPRT0) {
qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%"HWADDR_PRIx"\n",
__func__, addr);
return 0;
}
assert(addr >= HCFG && addr <= HPRT0);
val = s->hreg0[index];
switch (addr) {
@@ -880,12 +837,7 @@ static void dwc2_hreg0_write(void *ptr, hwaddr addr, int index, uint64_t val,
int prst = 0;
int iflg = 0;
if (addr < HCFG || addr > HPRT0) {
qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%"HWADDR_PRIx"\n",
__func__, addr);
return;
}
assert(addr >= HCFG && addr <= HPRT0);
mmio = &s->hreg0[index];
old = *mmio;
@@ -971,12 +923,7 @@ static uint64_t dwc2_hreg1_read(void *ptr, hwaddr addr, int index,
DWC2State *s = ptr;
uint32_t val;
if (addr < HCCHAR(0) || addr > HCDMAB(DWC2_NB_CHAN - 1)) {
qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%"HWADDR_PRIx"\n",
__func__, addr);
return 0;
}
assert(addr >= HCCHAR(0) && addr <= HCDMAB(DWC2_NB_CHAN - 1));
val = s->hreg1[index];
trace_usb_dwc2_hreg1_read(addr, hreg1nm[index & 7], addr >> 5, val);
@@ -994,12 +941,7 @@ static void dwc2_hreg1_write(void *ptr, hwaddr addr, int index, uint64_t val,
int enflg = 0;
int disflg = 0;
if (addr < HCCHAR(0) || addr > HCDMAB(DWC2_NB_CHAN - 1)) {
qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%"HWADDR_PRIx"\n",
__func__, addr);
return;
}
assert(addr >= HCCHAR(0) && addr <= HCDMAB(DWC2_NB_CHAN - 1));
mmio = &s->hreg1[index];
old = *mmio;
@@ -1066,12 +1008,7 @@ static uint64_t dwc2_pcgreg_read(void *ptr, hwaddr addr, int index,
DWC2State *s = ptr;
uint32_t val;
if (addr < PCGCTL || addr > PCGCCTL1) {
qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%"HWADDR_PRIx"\n",
__func__, addr);
return 0;
}
assert(addr >= PCGCTL && addr <= PCGCCTL1);
val = s->pcgreg[index];
trace_usb_dwc2_pcgreg_read(addr, pcgregnm[index], val);
@@ -1086,12 +1023,7 @@ static void dwc2_pcgreg_write(void *ptr, hwaddr addr, int index,
uint32_t *mmio;
uint32_t old;
if (addr < PCGCTL || addr > PCGCCTL1) {
qemu_log_mask(LOG_GUEST_ERROR, "%s: Bad offset 0x%"HWADDR_PRIx"\n",
__func__, addr);
return;
}
assert(addr >= PCGCTL && addr <= PCGCCTL1);
mmio = &s->pcgreg[index];
old = *mmio;
@@ -1176,7 +1108,7 @@ static uint64_t dwc2_hreg2_read(void *ptr, hwaddr addr, unsigned size)
{
/* TODO - implement FIFOs to support slave mode */
trace_usb_dwc2_hreg2_read(addr, addr >> 12, 0);
qemu_log_mask(LOG_UNIMP, "%s: FIFO read not implemented\n", __func__);
qemu_log_mask(LOG_UNIMP, "FIFO read not implemented\n");
return 0;
}
@@ -1187,7 +1119,7 @@ static void dwc2_hreg2_write(void *ptr, hwaddr addr, uint64_t val,
/* TODO - implement FIFOs to support slave mode */
trace_usb_dwc2_hreg2_write(addr, addr >> 12, orig, 0, val);
qemu_log_mask(LOG_UNIMP, "%s: FIFO write not implemented\n", __func__);
qemu_log_mask(LOG_UNIMP, "FIFO write not implemented\n");
}
static const MemoryRegionOps dwc2_mmio_hreg2_ops = {
+17 -18
View File
@@ -1447,25 +1447,24 @@ static int ehci_process_itd(EHCIState *ehci,
dev = ehci_find_device(ehci, devaddr);
if (dev == NULL) {
ehci_trace_guest_bug(ehci, "no device found");
ehci->ipacket.status = USB_RET_NODEV;
ehci->ipacket.actual_length = 0;
} else {
pid = dir ? USB_TOKEN_IN : USB_TOKEN_OUT;
ep = usb_ep_get(dev, pid, endp);
if (ep && ep->type == USB_ENDPOINT_XFER_ISOC) {
usb_packet_setup(&ehci->ipacket, pid, ep, 0, addr, false,
(itd->transact[i] & ITD_XACT_IOC) != 0);
if (usb_packet_map(&ehci->ipacket, &ehci->isgl)) {
qemu_sglist_destroy(&ehci->isgl);
return -1;
}
usb_handle_packet(dev, &ehci->ipacket);
usb_packet_unmap(&ehci->ipacket, &ehci->isgl);
} else {
DPRINTF("ISOCH: attempt to addess non-iso endpoint\n");
ehci->ipacket.status = USB_RET_NAK;
ehci->ipacket.actual_length = 0;
qemu_sglist_destroy(&ehci->isgl);
return -1;
}
pid = dir ? USB_TOKEN_IN : USB_TOKEN_OUT;
ep = usb_ep_get(dev, pid, endp);
if (ep && ep->type == USB_ENDPOINT_XFER_ISOC) {
usb_packet_setup(&ehci->ipacket, pid, ep, 0, addr, false,
(itd->transact[i] & ITD_XACT_IOC) != 0);
if (usb_packet_map(&ehci->ipacket, &ehci->isgl)) {
qemu_sglist_destroy(&ehci->isgl);
return -1;
}
usb_handle_packet(dev, &ehci->ipacket);
usb_packet_unmap(&ehci->ipacket, &ehci->isgl);
} else {
DPRINTF("ISOCH: attempt to addess non-iso endpoint\n");
ehci->ipacket.status = USB_RET_NAK;
ehci->ipacket.actual_length = 0;
}
qemu_sglist_destroy(&ehci->isgl);
+2 -2
View File
@@ -34,8 +34,8 @@ static Property nec_xhci_properties[] = {
xhci.flags, XHCI_FLAG_SS_FIRST, true),
DEFINE_PROP_BIT("force-pcie-endcap", XHCIPciState, xhci.flags,
XHCI_FLAG_FORCE_PCIE_ENDCAP, false),
DEFINE_PROP_UINT32("intrs", XHCIPciState, xhci.numintrs, XHCI_MAXINTRS),
DEFINE_PROP_UINT32("slots", XHCIPciState, xhci.numslots, XHCI_MAXSLOTS),
DEFINE_PROP_UINT32("intrs", XHCIPciState, xhci.numintrs, MAXINTRS),
DEFINE_PROP_UINT32("slots", XHCIPciState, xhci.numslots, MAXSLOTS),
DEFINE_PROP_END_OF_LIST(),
};
+2 -2
View File
@@ -240,8 +240,8 @@ static void qemu_xhci_instance_init(Object *obj)
s->msi = ON_OFF_AUTO_OFF;
s->msix = ON_OFF_AUTO_AUTO;
xhci->numintrs = XHCI_MAXINTRS;
xhci->numslots = XHCI_MAXSLOTS;
xhci->numintrs = MAXINTRS;
xhci->numslots = MAXSLOTS;
xhci_set_flag(xhci, XHCI_FLAG_SS_FIRST);
}
+2 -17
View File
@@ -13,7 +13,6 @@
#include "trace.h"
#include "qapi/error.h"
#include "hcd-xhci-sysbus.h"
#include "hw/acpi/aml-build.h"
#include "hw/irq.h"
static void xhci_sysbus_intr_raise(XHCIState *xhci, int n, bool level)
@@ -69,23 +68,9 @@ static void xhci_sysbus_instance_init(Object *obj)
s->xhci.intr_raise = xhci_sysbus_intr_raise;
}
void xhci_sysbus_build_aml(Aml *scope, uint32_t mmio, unsigned int irq)
{
Aml *dev = aml_device("XHCI");
Aml *crs = aml_resource_template();
aml_append(crs, aml_memory32_fixed(mmio, XHCI_LEN_REGS, AML_READ_WRITE));
aml_append(crs, aml_interrupt(AML_CONSUMER, AML_LEVEL, AML_ACTIVE_HIGH,
AML_EXCLUSIVE, &irq, 1));
aml_append(dev, aml_name_decl("_HID", aml_eisaid("PNP0D10")));
aml_append(dev, aml_name_decl("_CRS", crs));
aml_append(scope, dev);
}
static Property xhci_sysbus_props[] = {
DEFINE_PROP_UINT32("intrs", XHCISysbusState, xhci.numintrs, XHCI_MAXINTRS),
DEFINE_PROP_UINT32("slots", XHCISysbusState, xhci.numslots, XHCI_MAXSLOTS),
DEFINE_PROP_UINT32("intrs", XHCISysbusState, xhci.numintrs, MAXINTRS),
DEFINE_PROP_UINT32("slots", XHCISysbusState, xhci.numslots, MAXSLOTS),
DEFINE_PROP_END_OF_LIST(),
};
+1
View File
@@ -15,6 +15,7 @@
#include "hcd-xhci.h"
#include "hw/sysbus.h"
#define TYPE_XHCI_SYSBUS "sysbus-xhci"
#define XHCI_SYSBUS(obj) \
OBJECT_CHECK(XHCISysbusState, (obj), TYPE_XHCI_SYSBUS)
+18 -16
View File
@@ -46,13 +46,15 @@
#define TRANSFER_LIMIT 256
#define LEN_CAP 0x40
#define LEN_OPER (0x400 + 0x10 * XHCI_MAXPORTS)
#define LEN_RUNTIME ((XHCI_MAXINTRS + 1) * 0x20)
#define LEN_DOORBELL ((XHCI_MAXSLOTS + 1) * 0x20)
#define LEN_OPER (0x400 + 0x10 * MAXPORTS)
#define LEN_RUNTIME ((MAXINTRS + 1) * 0x20)
#define LEN_DOORBELL ((MAXSLOTS + 1) * 0x20)
#define OFF_OPER LEN_CAP
#define OFF_RUNTIME 0x1000
#define OFF_DOORBELL 0x2000
/* must be power of 2 */
#define LEN_REGS 0x4000
#if (OFF_OPER + LEN_OPER) > OFF_RUNTIME
#error Increase OFF_RUNTIME
@@ -60,8 +62,8 @@
#if (OFF_RUNTIME + LEN_RUNTIME) > OFF_DOORBELL
#error Increase OFF_DOORBELL
#endif
#if (OFF_DOORBELL + LEN_DOORBELL) > XHCI_LEN_REGS
# error Increase XHCI_LEN_REGS
#if (OFF_DOORBELL + LEN_DOORBELL) > LEN_REGS
# error Increase LEN_REGS
#endif
/* bit definitions */
@@ -3274,11 +3276,11 @@ static void usb_xhci_init(XHCIState *xhci)
xhci->usbsts = USBSTS_HCH;
if (xhci->numports_2 > XHCI_MAXPORTS_2) {
xhci->numports_2 = XHCI_MAXPORTS_2;
if (xhci->numports_2 > MAXPORTS_2) {
xhci->numports_2 = MAXPORTS_2;
}
if (xhci->numports_3 > XHCI_MAXPORTS_3) {
xhci->numports_3 = XHCI_MAXPORTS_3;
if (xhci->numports_3 > MAXPORTS_3) {
xhci->numports_3 = MAXPORTS_3;
}
usbports = MAX(xhci->numports_2, xhci->numports_3);
xhci->numports = xhci->numports_2 + xhci->numports_3;
@@ -3300,7 +3302,7 @@ static void usb_xhci_init(XHCIState *xhci)
USB_SPEED_MASK_LOW |
USB_SPEED_MASK_FULL |
USB_SPEED_MASK_HIGH;
assert(i < XHCI_MAXPORTS);
assert(i < MAXPORTS);
snprintf(port->name, sizeof(port->name), "usb2 port #%d", i+1);
speedmask |= port->speedmask;
}
@@ -3314,7 +3316,7 @@ static void usb_xhci_init(XHCIState *xhci)
}
port->uport = &xhci->uports[i];
port->speedmask = USB_SPEED_MASK_SUPER;
assert(i < XHCI_MAXPORTS);
assert(i < MAXPORTS);
snprintf(port->name, sizeof(port->name), "usb3 port #%d", i+1);
speedmask |= port->speedmask;
}
@@ -3329,8 +3331,8 @@ static void usb_xhci_realize(DeviceState *dev, Error **errp)
XHCIState *xhci = XHCI(dev);
if (xhci->numintrs > XHCI_MAXINTRS) {
xhci->numintrs = XHCI_MAXINTRS;
if (xhci->numintrs > MAXINTRS) {
xhci->numintrs = MAXINTRS;
}
while (xhci->numintrs & (xhci->numintrs - 1)) { /* ! power of 2 */
xhci->numintrs++;
@@ -3338,8 +3340,8 @@ static void usb_xhci_realize(DeviceState *dev, Error **errp)
if (xhci->numintrs < 1) {
xhci->numintrs = 1;
}
if (xhci->numslots > XHCI_MAXSLOTS) {
xhci->numslots = XHCI_MAXSLOTS;
if (xhci->numslots > MAXSLOTS) {
xhci->numslots = MAXSLOTS;
}
if (xhci->numslots < 1) {
xhci->numslots = 1;
@@ -3353,7 +3355,7 @@ static void usb_xhci_realize(DeviceState *dev, Error **errp)
usb_xhci_init(xhci);
xhci->mfwrap_timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, xhci_mfwrap_timer, xhci);
memory_region_init(&xhci->mem, OBJECT(dev), "xhci", XHCI_LEN_REGS);
memory_region_init(&xhci->mem, OBJECT(dev), "xhci", LEN_REGS);
memory_region_init_io(&xhci->mem_cap, OBJECT(dev), &xhci_cap_ops, xhci,
"capabilities", LEN_CAP);
memory_region_init_io(&xhci->mem_oper, OBJECT(dev), &xhci_oper_ops, xhci,
+16 -6
View File
@@ -24,13 +24,23 @@
#include "qom/object.h"
#include "hw/usb.h"
#include "hw/usb/xhci.h"
#include "sysemu/dma.h"
#define TYPE_XHCI "base-xhci"
#define TYPE_NEC_XHCI "nec-usb-xhci"
#define TYPE_QEMU_XHCI "qemu-xhci"
OBJECT_DECLARE_SIMPLE_TYPE(XHCIState, XHCI)
#define MAXPORTS_2 15
#define MAXPORTS_3 15
#define MAXPORTS (MAXPORTS_2 + MAXPORTS_3)
#define MAXSLOTS 64
#define MAXINTRS 16
/* Very pessimistic, let's hope it's enough for all cases */
#define EV_QUEUE (((3 * 24) + 16) * XHCI_MAXSLOTS)
#define EV_QUEUE (((3 * 24) + 16) * MAXSLOTS)
typedef struct XHCIStreamContext XHCIStreamContext;
typedef struct XHCIEPContext XHCIEPContext;
@@ -207,15 +217,15 @@ typedef struct XHCIState {
uint32_t dcbaap_high;
uint32_t config;
USBPort uports[MAX_CONST(XHCI_MAXPORTS_2, XHCI_MAXPORTS_3)];
XHCIPort ports[XHCI_MAXPORTS];
XHCISlot slots[XHCI_MAXSLOTS];
USBPort uports[MAX_CONST(MAXPORTS_2, MAXPORTS_3)];
XHCIPort ports[MAXPORTS];
XHCISlot slots[MAXSLOTS];
uint32_t numports;
/* Runtime Registers */
int64_t mfindex_start;
QEMUTimer *mfwrap_timer;
XHCIInterrupter intr[XHCI_MAXINTRS];
XHCIInterrupter intr[MAXINTRS];
XHCIRing cmd_ring;
-11
View File
@@ -41,12 +41,6 @@ static void xen_backend_table_add(XenBackendImpl *impl)
g_hash_table_insert(xen_backend_table_get(), (void *)impl->type, impl);
}
static const char **xen_backend_table_keys(unsigned int *count)
{
return (const char **)g_hash_table_get_keys_as_array(
xen_backend_table_get(), count);
}
static const XenBackendImpl *xen_backend_table_lookup(const char *type)
{
return g_hash_table_lookup(xen_backend_table_get(), type);
@@ -76,11 +70,6 @@ void xen_backend_register(const XenBackendInfo *info)
xen_backend_table_add(impl);
}
const char **xen_backend_get_types(unsigned int *count)
{
return xen_backend_table_keys(count);
}
static QLIST_HEAD(, XenBackendInstance) backend_list;
static void xen_backend_list_add(XenBackendInstance *backend)
+8 -32
View File
@@ -430,15 +430,7 @@ static void xen_bus_unrealize(BusState *bus)
trace_xen_bus_unrealize();
if (xenbus->backend_watch) {
unsigned int i;
for (i = 0; i < xenbus->backend_types; i++) {
if (xenbus->backend_watch[i]) {
xen_bus_remove_watch(xenbus, xenbus->backend_watch[i], NULL);
}
}
g_free(xenbus->backend_watch);
xen_bus_remove_watch(xenbus, xenbus->backend_watch, NULL);
xenbus->backend_watch = NULL;
}
@@ -454,11 +446,8 @@ static void xen_bus_unrealize(BusState *bus)
static void xen_bus_realize(BusState *bus, Error **errp)
{
char *key = g_strdup_printf("%u", xen_domid);
XenBus *xenbus = XEN_BUS(bus);
unsigned int domid;
const char **type;
unsigned int i;
Error *local_err = NULL;
trace_xen_bus_realize();
@@ -480,32 +469,19 @@ static void xen_bus_realize(BusState *bus, Error **errp)
module_call_init(MODULE_INIT_XEN_BACKEND);
type = xen_backend_get_types(&xenbus->backend_types);
xenbus->backend_watch = g_new(XenWatch *, xenbus->backend_types);
for (i = 0; i < xenbus->backend_types; i++) {
char *node = g_strdup_printf("backend/%s", type[i]);
xenbus->backend_watch[i] =
xen_bus_add_watch(xenbus, node, key, xen_bus_backend_changed,
&local_err);
if (local_err) {
/* This need not be treated as a hard error so don't propagate */
error_reportf_err(local_err,
"failed to set up '%s' enumeration watch: ",
type[i]);
}
g_free(node);
xenbus->backend_watch =
xen_bus_add_watch(xenbus, "", /* domain root node */
"backend", xen_bus_backend_changed, &local_err);
if (local_err) {
/* This need not be treated as a hard error so don't propagate */
error_reportf_err(local_err,
"failed to set up enumeration watch: ");
}
g_free(type);
g_free(key);
return;
fail:
xen_bus_unrealize(bus);
g_free(key);
}
static void xen_bus_unplug_request(HotplugHandler *hotplug,
+3 -37
View File
@@ -251,25 +251,6 @@ void tlb_flush_by_mmuidx_all_cpus(CPUState *cpu, uint16_t idxmap);
* depend on when the guests translation ends the TB.
*/
void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *cpu, uint16_t idxmap);
/**
* tlb_flush_page_bits_by_mmuidx
* @cpu: CPU whose TLB should be flushed
* @addr: virtual address of page to be flushed
* @idxmap: bitmap of mmu indexes to flush
* @bits: number of significant bits in address
*
* Similar to tlb_flush_page_mask, but with a bitmap of indexes.
*/
void tlb_flush_page_bits_by_mmuidx(CPUState *cpu, target_ulong addr,
uint16_t idxmap, unsigned bits);
/* Similarly, with broadcast and syncing. */
void tlb_flush_page_bits_by_mmuidx_all_cpus(CPUState *cpu, target_ulong addr,
uint16_t idxmap, unsigned bits);
void tlb_flush_page_bits_by_mmuidx_all_cpus_synced
(CPUState *cpu, target_ulong addr, uint16_t idxmap, unsigned bits);
/**
* tlb_set_page_with_attrs:
* @cpu: CPU to add this TLB entry for
@@ -356,23 +337,6 @@ static inline void tlb_flush_by_mmuidx_all_cpus_synced(CPUState *cpu,
uint16_t idxmap)
{
}
static inline void tlb_flush_page_bits_by_mmuidx(CPUState *cpu,
target_ulong addr,
uint16_t idxmap,
unsigned bits)
{
}
static inline void tlb_flush_page_bits_by_mmuidx_all_cpus(CPUState *cpu,
target_ulong addr,
uint16_t idxmap,
unsigned bits)
{
}
static inline void
tlb_flush_page_bits_by_mmuidx_all_cpus_synced(CPUState *cpu, target_ulong addr,
uint16_t idxmap, unsigned bits)
{
}
#endif
/**
* probe_access:
@@ -520,7 +484,7 @@ struct TranslationBlock {
uintptr_t jmp_list_next[2];
uintptr_t jmp_dest[2];
#if defined(CONFIG_MIRROR_JIT)
#if defined(CONFIG_IOS_JIT)
/*
* Store difference to writable mirror
* We need this when patching the jump instructions
@@ -557,6 +521,8 @@ TranslationBlock *tb_htable_lookup(CPUState *cpu, target_ulong pc,
target_ulong cs_base, uint32_t flags,
uint32_t cf_mask);
void tb_set_jmp_target(TranslationBlock *tb, int n, uintptr_t addr);
void tb_exec_lock(void);
void tb_exec_unlock(void);
/* GETPC is the true target of the return instruction that we'll execute. */
#if defined(CONFIG_TCG_INTERPRETER)
-13
View File
@@ -90,19 +90,6 @@ extern const VMStateDescription vmstate_clock;
*/
void clock_setup_canonical_path(Clock *clk);
/**
* clock_new:
* @parent: the clock parent
* @name: the clock object name
*
* Helper function to create a new clock and parent it to @parent. There is no
* need to call clock_setup_canonical_path on the returned clock as it is done
* by this function.
*
* @return the newly created clock
*/
Clock *clock_new(Object *parent, const char *name);
/**
* clock_set_callback:
* @clk: the clock to register the callback into
+1 -4
View File
@@ -41,7 +41,7 @@
* 7 | parallel |
* 8 | rtc | rtc (rtc=on)
* 9 | acpi | acpi (ged)
* 10 | pci lnk | xhci (usb=on)
* 10 | pci lnk |
* 11 | pci lnk |
* 12 | ps2 | pcie
* 13 | fpu | pcie
@@ -60,9 +60,6 @@
#define GED_MMIO_BASE_REGS (GED_MMIO_BASE + 0x200)
#define GED_MMIO_IRQ 9
#define MICROVM_XHCI_BASE 0xfe900000
#define MICROVM_XHCI_IRQ 10
#define PCIE_MMIO_BASE 0xc0000000
#define PCIE_MMIO_SIZE 0x20000000
#define PCIE_ECAM_BASE 0xe0000000
-2
View File
@@ -58,7 +58,6 @@ struct X86MachineState {
/* CPU and apic information: */
bool apic_xrupt_override;
unsigned pci_irq_mask;
unsigned apic_id_limit;
uint16_t boot_cpus;
unsigned smp_dies;
@@ -115,7 +114,6 @@ bool x86_machine_is_acpi_enabled(const X86MachineState *x86ms);
/* Global System Interrupts */
#define GSI_NUM_PINS IOAPIC_NUM_PINS
#define ACPI_BUILD_PCI_IRQS ((1<<5) | (1<<9) | (1<<10) | (1<<11))
typedef struct GSIState {
qemu_irq i8259_irq[ISA_NUM_IRQS];
-2
View File
@@ -21,7 +21,6 @@
#define MIPS_CPS_H
#include "hw/sysbus.h"
#include "hw/clock.h"
#include "hw/misc/mips_cmgcr.h"
#include "hw/intc/mips_gic.h"
#include "hw/misc/mips_cpc.h"
@@ -44,7 +43,6 @@ struct MIPSCPSState {
MIPSGICState gic;
MIPSCPCState cpc;
MIPSITUState itu;
Clock *clock;
};
qemu_irq get_cps_irq(MIPSCPSState *cps, int pin_number);
+1 -3
View File
@@ -2,10 +2,8 @@
#define HW_MIPS_H
/* Definitions for mips board emulation. */
#include "qemu/units.h"
/* Kernels can be configured with 64KB pages */
#define INITRD_PAGE_SIZE (64 * KiB)
#define INITRD_PAGE_MASK (~((1 << 16) - 1))
#include "exec/memory.h"
+2
View File
@@ -26,6 +26,7 @@
#define UNINORTH_H
#include "hw/pci/pci_host.h"
#include "hw/ppc/openpic.h"
#include "qom/object.h"
/* UniNorth version */
@@ -50,6 +51,7 @@ struct UNINHostState {
PCIHostState parent_obj;
uint32_t ofw_addr;
OpenPICState *pic;
qemu_irq irqs[4];
MemoryRegion pci_mmio;
MemoryRegion pci_hole;
+6
View File
@@ -47,4 +47,10 @@ struct NvramClass {
void (*toggle_lock)(Nvram *obj, int lock);
};
Nvram *m48t59_init_isa(ISABus *bus, uint32_t io_base, uint16_t size,
int base_year, int type);
Nvram *m48t59_init(qemu_irq IRQ, hwaddr mem_base,
uint32_t io_base, uint16_t size, int base_year,
int type);
#endif /* HW_M48T59_H */
+4 -13
View File
@@ -11,32 +11,23 @@
#include "hw/sysbus.h"
#include "hw/irq.h"
#include "qemu/timer.h"
#include "qom/object.h"
#define TYPE_BCM2835_SYSTIMER "bcm2835-sys-timer"
OBJECT_DECLARE_SIMPLE_TYPE(BCM2835SystemTimerState, BCM2835_SYSTIMER)
#define BCM2835_SYSTIMER_COUNT 4
typedef struct {
unsigned id;
QEMUTimer timer;
qemu_irq irq;
BCM2835SystemTimerState *state;
} BCM2835SystemTimerCompare;
struct BCM2835SystemTimerState {
/*< private >*/
SysBusDevice parent_obj;
/*< public >*/
MemoryRegion iomem;
qemu_irq irq;
struct {
uint32_t ctrl_status;
uint32_t compare[BCM2835_SYSTIMER_COUNT];
uint32_t status;
uint32_t compare[4];
} reg;
BCM2835SystemTimerCompare tmr[BCM2835_SYSTIMER_COUNT];
};
#endif
-21
View File
@@ -1,21 +0,0 @@
#ifndef HW_USB_XHCI_H
#define HW_USB_XHCI_H
#define TYPE_XHCI "base-xhci"
#define TYPE_NEC_XHCI "nec-usb-xhci"
#define TYPE_QEMU_XHCI "qemu-xhci"
#define TYPE_XHCI_SYSBUS "sysbus-xhci"
#define XHCI_MAXPORTS_2 15
#define XHCI_MAXPORTS_3 15
#define XHCI_MAXPORTS (XHCI_MAXPORTS_2 + XHCI_MAXPORTS_3)
#define XHCI_MAXSLOTS 64
#define XHCI_MAXINTRS 16
/* must be power of 2 */
#define XHCI_LEN_REGS 0x4000
void xhci_sysbus_build_aml(Aml *scope, uint32_t mmio, unsigned int irq);
#endif
-1
View File
@@ -31,7 +31,6 @@ void xen_backend_set_device(XenBackendInstance *backend,
XenDevice *xen_backend_get_device(XenBackendInstance *backend);
void xen_backend_register(const XenBackendInfo *info);
const char **xen_backend_get_types(unsigned int *nr);
void xen_backend_device_create(XenBus *xenbus, const char *type,
const char *name, QDict *opts, Error **errp);
+1 -2
View File
@@ -66,8 +66,7 @@ struct XenBus {
domid_t backend_id;
struct xs_handle *xsh;
XenWatchList *watch_list;
unsigned int backend_types;
XenWatch **backend_watch;
XenWatch *backend_watch;
QLIST_HEAD(, XenDevice) inactive_devices;
};
+1 -1
View File
@@ -11,7 +11,7 @@
#define TYPE_XENBACKEND "xen-backend"
typedef struct XenLegacyDevice XenLegacyDevice;
DECLARE_INSTANCE_CHECKER(XenLegacyDevice, XENBACKEND,
DECLARE_INSTANCE_CHECKER(XenLegacyDevice, XENBACKEND_DEVICE,
TYPE_XENBACKEND)
/* variables */
-12
View File
@@ -158,18 +158,6 @@ int qemu_strtosz_metric(const char *nptr, const char **end, uint64_t *result);
char *size_to_str(uint64_t val);
/**
* freq_to_str:
* @freq_hz: frequency to stringify
*
* Return human readable string for frequency @freq_hz.
* Use SI units like KHz, MHz, and so forth.
*
* The caller is responsible for releasing the value returned
* with g_free() after use.
*/
char *freq_to_str(uint64_t freq_hz);
/* used to print char* safely */
#define STR_OR_NULL(str) ((str) ? (str) : "null")
+85
View File
@@ -0,0 +1,85 @@
/*
* Apple Silicon APRR functions for JIT handling
*
* Copyright (c) 2020 osy
*
* 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/>.
*/
/*
* Credits to: https://siguza.github.io/APRR/
* Reversed from /usr/lib/system/libsystem_pthread.dylib
*/
#ifndef TCG_APPLE_JIT_H
#define TCG_APPLE_JIT_H
#if defined(__aarch64__) && defined(CONFIG_DARWIN)
#define _COMM_PAGE_START_ADDRESS (0x0000000FFFFFC000ULL) /* In TTBR0 */
#define _COMM_PAGE_APRR_SUPPORT (_COMM_PAGE_START_ADDRESS + 0x10C)
#define _COMM_PAGE_APPR_WRITE_ENABLE (_COMM_PAGE_START_ADDRESS + 0x110)
#define _COMM_PAGE_APRR_WRITE_DISABLE (_COMM_PAGE_START_ADDRESS + 0x118)
static __attribute__((__always_inline__)) bool jit_write_protect_supported(void)
{
/* Access shared kernel page at fixed memory location. */
uint8_t aprr_support = *(volatile uint8_t *)_COMM_PAGE_APRR_SUPPORT;
return aprr_support > 0;
}
/* write protect enable = write disable */
static __attribute__((__always_inline__)) void jit_write_protect(int enabled)
{
/* Access shared kernel page at fixed memory location. */
uint8_t aprr_support = *(volatile uint8_t *)_COMM_PAGE_APRR_SUPPORT;
if (aprr_support == 0 || aprr_support > 3) {
return;
} else if (aprr_support == 1) {
__asm__ __volatile__ (
"mov x0, %0\n"
"ldr x0, [x0]\n"
"msr S3_4_c15_c2_7, x0\n"
"isb sy\n"
:: "r" (enabled ? _COMM_PAGE_APRR_WRITE_DISABLE
: _COMM_PAGE_APPR_WRITE_ENABLE)
: "memory", "x0"
);
} else {
__asm__ __volatile__ (
"mov x0, %0\n"
"ldr x0, [x0]\n"
"msr S3_6_c15_c1_5, x0\n"
"isb sy\n"
:: "r" (enabled ? _COMM_PAGE_APRR_WRITE_DISABLE
: _COMM_PAGE_APPR_WRITE_ENABLE)
: "memory", "x0"
);
}
}
#else /* defined(__aarch64__) && defined(CONFIG_DARWIN) */
static __attribute__((__always_inline__)) bool jit_write_protect_supported(void)
{
return false;
}
static __attribute__((__always_inline__)) void jit_write_protect(int enabled)
{
}
#endif
#endif /* define TCG_APPLE_JIT_H */
+5 -3
View File
@@ -627,10 +627,12 @@ struct TCGContext {
size_t code_gen_buffer_size;
void *code_gen_ptr;
void *data_gen_ptr;
#if defined(CONFIG_MIRROR_JIT)
int code_gen_buffer_fd;
#if defined(CONFIG_IOS_JIT)
ptrdiff_t code_rw_mirror_diff;
#endif
#if defined(CONFIG_DARWIN) && !defined(CONFIG_TCG_INTERPRETER)
bool code_gen_locked; /* on Darwin each thread tracks W^X flags */
#endif
/* Threshold to flush the translated code buffer. */
void *code_gen_highwater;
@@ -683,7 +685,7 @@ struct TCGContext {
static inline void *tcg_mirror_ptr_rw(TCGContext *s, const void *rx)
{
#if defined(CONFIG_MIRROR_JIT)
#if defined(CONFIG_IOS_JIT)
return (void *)rx + s->code_rw_mirror_diff;
#else
return (void *)rx;
-44
View File
@@ -1,44 +0,0 @@
/*
* Copyright (C) 2010 Red Hat, Inc.
*
* 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 or
* (at your option) version 3 of the License.
*
* 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/>.
*/
#ifndef QEMU_SPICE_MODULE_H
#define QEMU_SPICE_MODULE_H
#ifdef CONFIG_SPICE
#include <spice.h>
#endif
typedef struct SpiceInfo SpiceInfo;
struct QemuSpiceOps {
void (*init)(void);
void (*display_init)(void);
int (*migrate_info)(const char *h, int p, int t, const char *s);
int (*set_passwd)(const char *passwd,
bool fail_if_connected, bool disconnect_if_connected);
int (*set_pw_expire)(time_t expires);
int (*display_add_client)(int csock, int skipauth, int tls);
#ifdef CONFIG_SPICE
int (*add_interface)(SpiceBaseInstance *sin);
SpiceInfo* (*qmp_query)(Error **errp);
#endif
};
extern int using_spice;
extern struct QemuSpiceOps qemu_spice;
#endif
+41 -1
View File
@@ -19,17 +19,24 @@
#define QEMU_SPICE_H
#include "qapi/error.h"
#include "ui/qemu-spice-module.h"
#ifdef CONFIG_SPICE
#include <spice.h>
#include "qemu/config-file.h"
extern int using_spice;
void qemu_spice_init(void);
void qemu_spice_input_init(void);
void qemu_spice_display_init(void);
int qemu_spice_display_add_client(int csock, int skipauth, int tls);
int qemu_spice_add_interface(SpiceBaseInstance *sin);
bool qemu_spice_have_display_interface(QemuConsole *con);
int qemu_spice_add_display_interface(QXLInstance *qxlin, QemuConsole *con);
int qemu_spice_set_passwd(const char *passwd,
bool fail_if_connected, bool disconnect_if_connected);
int qemu_spice_set_pw_expire(time_t expires);
int qemu_spice_migrate_info(const char *hostname, int port, int tls_port,
const char *subject);
@@ -43,7 +50,40 @@ int qemu_spice_migrate_info(const char *hostname, int port, int tls_port,
#include "qemu/error-report.h"
#define using_spice 0
#define spice_displays 0
static inline int qemu_spice_set_passwd(const char *passwd,
bool fail_if_connected,
bool disconnect_if_connected)
{
return -1;
}
static inline int qemu_spice_set_pw_expire(time_t expires)
{
return -1;
}
static inline int qemu_spice_migrate_info(const char *h, int p, int t,
const char *s)
{
return -1;
}
static inline int qemu_spice_display_add_client(int csock, int skipauth,
int tls)
{
return -1;
}
static inline void qemu_spice_display_init(void)
{
/* This must never be called if CONFIG_SPICE is disabled */
error_report("spice support is disabled");
abort();
}
static inline void qemu_spice_init(void)
{
}
#endif /* CONFIG_SPICE */
Loaded 100 of 205 files, more files were not shown because too many files have changed in this diff. Show more