GXEMUL(1)
๐ NAME ๐
bestie, welcome to GXEMUL(1) โ an experimental framework for full-system machine emulation. That's the whole assignment. ๐ซถโจ
๐ SYNOPSIS ๐
gxemul [machine, other, and general options] [file ...]
gxemul [general options] @configfile
gxemul -H
๐ DESCRIPTION ๐
okay so gxemul is literally a framework for full-system computer architecture emulation. Several processor architectures and machine types have been implemented. It's working well enough to let unmodified "guest" operating systems (e.g. NetBSD) run inside the emulator, as if they were running on real hardware. no cap. ๐ฅ
The emulator emulates (networks of) real machines. The machines may consist of ARM, MIPS, Motorola 88K, PowerPC, and SuperH processors, and various surrounding hardware components such as framebuffers, busses, interrupt controllers, ethernet controllers, disk controllers, and serial port controllers. it's giving full hardware fantasy camp. ๐
๐ง RUNNING GUEST OPERATING SYSTEMS ๐ง
Please read the HTML documentation for more details on how to run specific guest operating systems in the emulator. iykyk, the docs are where the deets live. ๐โจ
๐ RUNNING THE EMULATOR ๐
The emulator can be invoked in the following ways:
- When emulating a complete machine, configuration options can be supplied directly on the command line.
- Options can be read from a configuration file.
The easiest way to use the emulator is to supply settings directly on the command line. lowkey the command line is the main character here. ๐โโ๏ธ
The most important thing you need to supply is the file argument. This is the name of a binary file (an ELF, a.out, COFF/ECOFF, SREC, or a raw binary image) which you wish to run in the emulator. This file might be an operating system kernel, or perhaps a ROM image file. If more than one filename is supplied, all files are loaded into memory, and the entry point (if available) is taken from the last file. periodt. ๐
Apart from the name of a binary file, you must also use the -E and/or -e options to select which emulation mode to use. This is necessary because the emulator cannot in general deduce this from the file being executed. For example, a MIPS-based machine from DEC (a DECstation) is very different from a MIPS-based machine from SGI. Use gxemul -H to get a list of available emulation modes. slay, -H is your bestie for that. ๐ซถ
There are three exceptions to the normal invocation usage mentioned above.
- For DECstation emulation, if you have a bootable DECstation harddisk or CDROM image, then just supplying the diskimage via the
-doption is sufficient. The filename of the kernel can then be skipped, as the emulator runs the bootblocks from the diskimage directly and doesn't need the kernel as a separate file. - If you supply an ISO9660 CDROM disk image, then using the
-joption to indicate a file on the CDROM filesystem to load is sufficient; no additional kernel filename needs to be supplied on the command line. - For Dreamcast emulation, when booting e.g. a NetBSD/dreamcast CDROM image, it is enough to supply the disk image (with the correct ISO partition start offset). Bootblocks will be read directly from the CDROM image, and there is no need to supply the name of an external kernel on the command line.
Gzipped kernels are automatically unzipped, by calling the external gunzip program, both when specifying a gzipped file directly on the command line and when loading such a file using the -j option. not me being obsessed with automatic unzipping. ๐ญโจ
๐ Machine selection options:
-E tโ Try to emulate machine typet. You don't always need this one, bestie, if the-eoption uniquely selects a machine. (Use-Hto get a list of types.) ๐-e stโ Try to emulate machine subtypest. Use this together with-E. (This option is not always needed, if a machine type has no subtypes.) no cap.
๐ฅ Other options:
-C xโ Try to emulate a specific CPU type,x. This overrides the default CPU type for the machine being emulated. (Use-Hto get a list of available CPU types.) ๐ฅ-d [modifiers:]filenameโ Addfilenameas a disk image. By adding one or more modifier characters and then a colon (":") as a prefix tofilename, you can modify the way the disk image is treated. Available modifiers are:bโ Specifies that this is a boot device. ๐ฅพcโ CD-ROM. ๐ฟdโ DISK (this is the default). ๐ฝfโ FLOPPY. ๐งฒgH;S;โ Override the default geometry; useHheads andSsectors-per-track. (The number of cylinders is calculated automatically.) ๐iโ IDE. ๐oOFS;โ Set the base offset for an ISO9660 filesystem on a disk image. The default is0. A suitable offset when booting from Dreamcast ISO9660 filesystem images, which are offset by11702sectors, is23965696. ๐ฏrโ Read-only (don't allow changes to be written to the file). ๐Rโ Don't allow changes to the file, but add a temporary overlay for the disk image to allow guest operating systems to write to the disk. (These changes are lost when the GXemul process exits.) โจsโ SCSI. ๐tโ Tape. ๐ผVโ Add an overlay filename to an already defined disk image. (A ID number must also be specified when this flag is used. See the documentation for an example of how to use overlays.) ๐ซถ0-7โ Force a specific ID number. ๐ข
For SCSI devices, the ID number is the SCSI ID. For IDE harddisks, the ID number has the following meaning:
0โ Primary master. ๐1โ Primary slave. ๐ฅ2โ Secondary master. ๐ฅ3โ Secondary slave. ๐
Unless otherwise specified, filenames ending with ".iso" or ".cdr" are assumed to be CDROM images. Most others are assumed to be disks. Depending on which machine is being emulated, the default for disks can be either SCSI or IDE. Some disk images that are very small are assumed to be floppy disks. (If you are not happy with the way a disk image is detected, then you need to use explicit prefixes to force a specific type.) ๐
For floppies, the gH;S; prefix is ignored. Instead, the number of heads and cylinders are assumed to be 2 and 80, respectively, and the number of sectors per track is calculated automatically. (This works for 720KB, 1.2MB, 1.44MB, and 2.88MB floppies.) ๐ง
-I hzโ Set the main CPU's frequency tohzHz. This option does not work for all emulated machine modes. It affects the way count/compare interrupts are faked to simulate emulated time = real world time. If the guest operating system relies on RTC interrupts instead of count/compare interrupts, then this option has no effect. โฐ
Setting the frequency to zero disables automatic synchronization of emulated time vs real world time, and the count/compare system runs at a fixed rate. ๐ซโณ
-iโ Enable instruction trace, i.e. display disassembly of each instruction as it is being executed. ๐-Jโ Disable instruction combinations in the dynamic translator. ๐ซ๐งฉ-j nโ Set the name of the kernel ton. When booting from an ISO9660 filesystem, the emulator will try to boot using this file. (In some emulation modes, eg. DECstation, this name is passed along to the boot program. Useful names are"bsd"for OpenBSD/pmax,"vmunix"for Ultrix, or"vmsprite"for Sprite.) ๐-L tapdevโ Enable tap networking using device'tapdev', on systems that support it. ๐-M mโ EmulatemMBs of physical RAM. This overrides the default amount of RAM for the selected machine type. ๐ง-Nโ Display the number of executed instructions per second on average, at regular intervals. ๐-n nrโ Set the number of processors in the machine, for SMP experiments. ๐งช
Note 1: The emulator allocates quite a lot of virtual memory for per-CPU translation tables. On 64-bit hosts, this is normally not a problem. On 32-bit hosts, this can use up all available virtual userspace memory. The solution is to either run the emulator on a 64-bit host, or limit the number of emulated CPUs to a reasonably low number. ๐ฌ
Note 2: SMP simulation is not working very well yet; multiple processors are simulated, but synchronization between the processors does not map very well to how real-world SMP systems work. ๐
-Oโ Force a"netboot"(tftp instead of disk), even when a disk image is present (for DECstation, SGI, and ARC emulation). ๐-o argโ Set the boot argument (mostly useful for DEC, ARC, or SGI emulation). Defaultargfor DEC is"-a", for ARC/SGI it is"-aN", and for CATS it is"-A". ๐๏ธ-p pcโ Add a breakpoint.pccan be a symbol, or a numeric value. (Remember to use the"0x"prefix for hexadecimal values.) ๐-Qโ Disable the built-in (software-only) PROM emulation. This option is useful for experimenting with running raw ROM images from real machines. The default behaviour of the emulator is to"fake"certain PROM calls used by guest operating systems (e.g. NetBSD), so that no real PROM image is needed. ๐ซ๐-Rโ Use a random bootstrap cpu, instead of CPU nr0. (This option is only meaningful together with the-noption.) ๐ฒ-rโ Dump register contents for every executed instruction. ๐-Sโ Initialize emulated RAM to random data, instead of zeroes. This option is useful when trying to trigger bugs in a program that occur because the program assumed that uninitialized memory contains zeros. (Use with care.) โ ๏ธ-s flags:filenameโ Gather statistics based on the current emulated program counter value, while the program executes. The statistics is actually just a raw dump of all program counter values in sequence, suitable for post-analysis with separate tools. Output is appended tofilename. ๐
The flags should include one or more of the following type specifiers:
vโ Virtual. This means that the program counter value is used. ๐งpโ Physical. This means that the physical address of where the program is actually running is used. ๐
iโ Instruction call. This kind of statistics gathering is practically only useful during development of the emulator itself. The output is a list of addresses of instruction call functions (ic->f), which after some post-processing can be used as a basis for deciding when to implement instruction combinations. iykyk ๐
The flags may also include the following optional modifiers:
dโ Disabled at startup.oโ Overwrite the file, instead of appending to it.
Statistics gathering can be enabled/disabled at runtime by using the "statistics_enabled = yes" and "statistics_enabled = no" debugger commands. cute, right? ๐
Heads up bestie: when gathering instruction statistics using the-soption, instruction combinations are always disabled โ i.e. an implicit-Jflag is added to the command line. No negotiating. ๐ค
-Tโ Halt if the emulated program attempts to access non-existing memory. ๐-tโ Show a trace tree of all function calls being made. it's giving family tree but for code ๐ณ-Xโ Use X11. This option enables graphical framebuffers. ๐ผ๏ธ-Yn โ Scale down framebuffer windows by n x n times. This option is useful when emulating a very large framebuffer, and the actual display is of lower resolution. If n is negative, then there will be no scaledown, but emulation of certain graphic controllers will be scaled up by-ntimes instead. E.g. Using-2with VGA text mode emulation will result in80x25character cells rendered in a1280x800window, instead of the normal resolution of640x400. math girlie behaviour honestly ๐งฎ-Zn โ Set the number of graphics cards, for emulating a dual-head or tripple-head environment. (Only for DECstation emulation so far.) ๐-zdisp โ Add disp as an X11 display to use for framebuffers.
๐ซถ General options ๐ซถ
-Aโ Disable colorized output. no pretty colours, sad ๐ญ-ccmd โ Add cmd as a command to run before starting the simulation. A similar effect can be achieved by using the-Voption, and entering the commands manually. โจ-Dโ Causes the emulator to skip a call tosrandom(). This leads to somewhat more deterministic behaviour than running without this option. However, if the emulated machine has clocks or timer interrupt sources, or if user interaction is taking place (e.g. keyboard input at irregular intervals), then this option is meaningless. ๐-Gโ Enable colorized output. If the environment variableCLICOLORis set, then this is the default behavior. ๐-Hโ Display a list of available CPU types and machine types. (Most of these don't work. Please read the HTML documentation included in the gxemul distribution for details on which modes that actually work.) ๐-hโ Display a list of all available command line options. the classic cry for help, love that for us ๐ซถ-kn โ Set the size of the dyntrans cache (per emulated CPU) to n MB. The default size is96MB. ๐พ-Kโ Show the debugger prompt instead of exiting, when a simulation ends. ๐-qโ Quiet mode; this suppresses startup messages. shhh bestie ๐คซ-Vโ Start up in the interactive debugger, paused. If this option is used,-qis ignored. This option also sets-K. ๐-vโ Increase verbosity (show more debug messages). This option can be used multiple times. ๐ฃ๏ธ-xโ Open up separate terminal windows for emulated serial ports. The default behaviour is to open up new terminals when using configuration files with more than one machine specified, or if X11 is enabled. When starting up a simple emulation session with settings directly on the command line (or when using configuration files with a single machine specification), and neither-Xnor-xis used, then all output is confined to the terminal thatgxemulstarted in. The default terminal to use is'xterm', but this can be overriden by theXTERMenvironment variable. ๐ฅ๏ธ
๐ฆ Configuration file startup ๐ฆ
@configfile โ Start an emulation based on the contents of configfile. yes the @ is literally part of it, iconic ๐
โจ EXAMPLES โจ
The following command will start NetBSD/pmax on an emulated DECstation 5000/200 (3MAX):
gxemul -e 3max -d nbsd_pmax.img
nbsd_pmax.img should be a raw disk image containing a bootable NetBSD/pmax filesystem. ๐
The following command will start an emulation session based on settings in the configuration file "mysession". The -v option tells gxemul to be verbose. ๐ฃ๏ธ
gxemul -v @mysession
If you have compiled the small Hello World program mentioned in the gxemul documentation, the following command will start up an emulated test machine in "paused" mode:
gxemul -E testmips -V hello_mips
Paused mode means that you enter the interactive single-step debugger directly at startup, instead of launching the Hello World program. she's waiting for you bestie ๐
The paused mode is also what should be used when running "unknown" files for the first time in the emulator. E.g. if you have a binary which you think is some kind of MIPS ROM image, then you can try the following:
gxemul -vv -E baremips -V 0xbfc00000:image.raw
You can then use the single-stepping functionality of the built-in debugger to run the code in the ROM image, to see how it behaves. Based on that, you can deduce what machine type it was actually from (the baremips machine is not a real machine), and perhaps try again with another emulation mode. ๐ต๏ธโโ๏ธ
In general, however, real ROM images require much more emulation detail than GXemul provides, so they can usually not run. ๐ญ
๐ BUGS ๐
There are many bugs. Some of the known bugs are mentioned in the TODO file in the gxemul source distribution, some are marked as TODO in the source code itself. no cap. ๐
gxemul is in general not cycle-accurate; it does not simulate individual pipe-line stages or penalties caused by branch-prediction misses or cache misses, so it cannot be used for accurate simulation of any actual real-world processor. ๐
gxemul is in general not timing-accurate. Many emulation modes try to make the guest operating system's clock run at the same speed as the host clock. However, the number of instructions executed per clock tick can obviously vary, depending on the current CPU load on the host. โฐ
gxemul is in general not guaranteed to be secure; when used as a virtual machine to run untrusted code in the form of a guest OS, the untrusted code may be able to crash the emulator, or due to bugs, take over the host. ๐จ
Bestie. Fr fr. Read that last one again before you run anything sketchy. ๐ซถ
๐ AUTHOR ๐
GXemul is Copyright (C) 2003-2021 Anders Gavare <gavare@gmail.com> ๐
See http://gavare.se/gxemul/ for more information. For other Copyright messages, see the corresponding parts of the source code and/or documentation. ๐ธ
and that's the whole page, bestie โ Debian, MARCH 2021, GXEMUL(1) ๐ โจ go forth and emulate responsibly ๐๐ฆ
๐ฆ where this page comes from
- debian bookworm: gxemul 0.7.0+dfsg-1+b1 ยท BSD-3-Clause
- debian trixie: gxemul 0.7.0+dfsg-2 ยท BSD-3-Clause
- fedora 43: gxemul 0.7.0-12.fc43 ยท LicenseRef-Callaway-BSD
- fedora 44: gxemul 0.7.0-13.fc44 ยท LicenseRef-Callaway-BSD
- nixos 26.05: gxemul 0.7.0
- nixpkgs unstable: gxemul 0.7.0
- ubuntu jammy: gxemul 0.7.0+dfsg-1 ยท BSD-3-Clause
- ubuntu noble: gxemul 0.7.0+dfsg-1 ยท BSD-3-Clause
- ubuntu questing: gxemul 0.7.0+dfsg-2
- ubuntu resolute: gxemul 0.7.0+dfsg-2build1 ยท BSD-3-Clause
- ubuntu stonking: gxemul 0.7.0+dfsg-2build1 ยท BSD-3-Clause
- Copyright (C) 2004-2021 Anders Gavare. All rights reserved
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms