4 QEMU's Tiny Code Generator (TCG) provides the ability to emulate a
5 number of CPU architectures on any supported host platform. Both
6 :ref:`System Emulation` and :ref:`User Mode Emulation` are supported
7 depending on the guest architecture.
9 .. list-table:: Supported Guest Architectures for Emulation
13 * - Architecture (qemu name)
20 - Legacy 64 bit RISC ISA developed by DEC
21 * - Arm (arm, aarch64)
22 - :ref:`Yes<ARM-System-emulator>`
24 - Wide range of features, see :ref:`Arm Emulation` for details
26 - :ref:`Yes<AVR-System-emulator>`
28 - 8 bit micro controller, often used in maker projects
32 - Embedded RISC chip developed by AXIS
36 - Family of DSPs by Qualcomm
40 - A legacy RISC system used in HP's old minicomputers
41 * - x86 (i386, x86_64)
42 - :ref:`Yes<QEMU-PC-System-emulator>`
44 - The ubiquitous desktop PC CPU architecture, 32 and 64 bit.
48 - A MIPS-like 64bit RISC architecture developed in China
50 - :ref:`Yes<ColdFire-System-emulator>`
52 - Motorola 68000 variants and ColdFire
56 - RISC based soft-core by Xilinx
58 - :ref:`Yes<MIPS-System-emulator>`
60 - Venerable RISC architecture originally out of Stanford University
64 - 32 bit embedded soft-core by Altera
66 - :ref:`Yes<OpenRISC-System-emulator>`
68 - Open source RISC architecture developed by the OpenRISC community
69 * - Power (ppc, ppc64)
70 - :ref:`Yes<PowerPC-System-emulator>`
72 - A general purpose RISC architecture now managed by IBM
74 - :ref:`Yes<RISC-V-System-emulator>`
76 - An open standard RISC ISA maintained by RISC-V International
78 - :ref:`Yes<RX-System-emulator>`
80 - A 32 bit micro controller developed by Renesas
82 - :ref:`Yes<s390x-System-emulator>`
84 - A 64 bit CPU found in IBM's System Z mainframes
88 - A 32 bit RISC embedded CPU developed by Hitachi
89 * - SPARC (sparc, sparc64)
90 - :ref:`Yes<Sparc32-System-emulator>`
92 - A RISC ISA originally developed by Sun Microsystems
96 - A 32 bit RISC/uController/DSP developed by Infineon
98 - :ref:`Yes<Xtensa-System-emulator>`
100 - A configurable 32 bit soft core now owned by Cadence
102 A number of features are only available when running under
103 emulation including :ref:`Record/Replay<replay>` and :ref:`TCG Plugins`.
110 Semihosting is a feature defined by the owner of the architecture to
111 allow programs to interact with a debugging host system. On real
112 hardware this is usually provided by an In-circuit emulator (ICE)
113 hooked directly to the board. QEMU's implementation allows for
114 semihosting calls to be passed to the host system or via the
117 Generally semihosting makes it easier to bring up low level code before a
118 more fully functional operating system has been enabled. On QEMU it
119 also allows for embedded micro-controller code which typically doesn't
120 have a full libc to be run as "bare-metal" code under QEMU's user-mode
121 emulation. It is also useful for writing test cases and indeed a
122 number of compiler suites as well as QEMU itself use semihosting calls
123 to exit test code while reporting the success state.
125 Semihosting is only available using TCG emulation. This is because the
126 instructions to trigger a semihosting call are typically reserved
127 causing most hypervisors to trap and fault on them.
130 Semihosting inherently bypasses any isolation there may be between
131 the guest and the host. As a result a program using semihosting can
132 happily trash your host system. Some semihosting calls (e.g.
133 ``SYS_READC``) can block execution indefinitely. You should only
134 ever run trusted code with semihosting enabled.
139 Semihosting calls can be re-directed to a (potentially remote) gdb
140 during debugging via the :ref:`gdbstub<GDB usage>`. Output to the
141 semihosting console is configured as a ``chardev`` so can be
142 redirected to a file, pipe or socket like any other ``chardev``
148 Most targets offer similar semihosting implementations with some
149 minor changes to define the appropriate instruction to encode the
150 semihosting call and which registers hold the parameters. They tend to
151 presents a simple POSIX-like API which allows your program to read and
152 write files, access the console and some other basic interactions.
154 For full details of the ABI for a particular target, and the set of
155 calls it provides, you should consult the semihosting specification
156 for that architecture.
159 QEMU makes an implementation decision to implement all file
160 access in ``O_BINARY`` mode. The user-visible effect of this is
161 regardless of the text/binary mode the program sets QEMU will
162 always select a binary mode ensuring no line-terminator conversion
163 is performed on input or output. This is because gdb semihosting
164 support doesn't make the distinction between the modes and
165 magically processing line endings can be confusing.
167 .. list-table:: Guest Architectures supporting Semihosting
175 - System and User-mode
176 - https://github.com/ARM-software/abi-aa/blob/main/semihosting/semihosting.rst
179 - https://sourceware.org/git/?p=newlib-cygwin.git;a=blob;f=libgloss/m68k/m68k-semi.txt;hb=HEAD
182 - Unified Hosting Interface (MD01069)
185 - https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=blob;f=libgloss/nios2/nios2-semi.txt;hb=HEAD
187 - System and User-mode
188 - https://github.com/riscv/riscv-semihosting-spec/blob/main/riscv-semihosting-spec.adoc
191 - Tensilica ISS SIMCALL