Alchemical Symbols ⭕
←↑→↓↖↙↗↘↕⏤
unicode=Geometric Shapes
▶ 仅仅个别字不同的时候的对比标识
◆
◉ 着重强调
◆ 1、
◆ 2、
◆ 3、
Miscellaneous Symbols
☞
Dingbats
✍ 重点记忆,个人总结的点,或者知识。
✎✎
⟱
⬢命令集⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢命令集⬢
sudo mkdir /home/asd
sudo mount -t vboxsf 1 /home/asd
ls /home/asd
⬢命令集⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢⬢命令集⬢
章节号 | 内容 |
---|---|
1图片格式(png) | 宽度大于610px,保持高宽比减低为620px |
1-1 | 应用 |
1-1-1 | 方法 |
官方说明文档:http://bochs.sourceforge.net/doc/docbook/user/introduction.html
第1章节 Bochs简介
Bochs is a program that simulates a complete Intel x86 computer. It includes emulation of the Intel x86 CPU, common I/O devices, and a custom BIOS. Bochs can be compiled to emulate many different x86 CPUs, from early 386 to the most recent x86-64 Intel and AMD processors which may even not reached the market yet. Bochs interprets every instruction from power-up to reboot, and has device models for all of the standard PC peripherals: keyboard, mouse, VGA card/monitor, disks, timer chips, network card, etc. Because Bochs simulates the whole PC environment, the software running in the simulation "believes" it is running on a real machine. This approach allows Bochs to run a wide variety of software with no modification, include most popular x86 operating systems: Windows 95/98/NT/2000/XP and Vista, all Linux flavors, all BSD flavors, and more.
Bochs是一个模拟完整Intel x86计算机的程序。它包括对Intel x86 CPU、通用I/O设备和自定义BIOS的模拟。Bochs可以被编译来模拟许多不同的x86处理器,从早期的386到最新的x86-64英特尔和AMD处理器,这些处理器可能还没有上市。Bochs解释从开机到重启的每一条指令,并为所有标准PC外围设备提供设备模型:键盘、鼠标、VGA卡/显示器、磁盘、定时器芯片、网卡等。由于Bochs模拟整个PC环境,因此在模拟中运行的软件“相信”它是在真实的机器上运行的。这种方法允许Bochs在不做任何修改的情况下运行各种各样的软件,包括最流行的x86操作系统:Windows 95/98/NT/2000/XP和Vista,所有Linux版本,所有BSD版本,等等。
Bochs is written in the C++ programming language, and is designed to run on many different host platforms, including x86, PPC, Alpha, Sun, and MIPS. No matter what the host platform is, Bochs still simulates x86 hardware. In other words, it does not depend on the native instructions of the host machine at all. This is both a strength and a weakness, and it's the major difference between Bochs and many other x86 emulation software such as VirtualBox, VMware, etc. Because Bochs uses software simulation for every single x86 instruction, it can simulate a Windows application on an Alpha or Sun workstation. However, the downside of Bochs' approach is simulation performance. To model the processor accurately, Bochs must run many instructions for every simulated x86 instruction, and this makes the simulated machine many times slower than the physical machine. Commercial PC emulators (VMware, Connectix, etc.) can achieve much high emulation speed using a technique called virtualization, but they are neither portable to non-x86 platforms nor open source.
Bochs是用C++编程语言编写的,它被设计为运行在许多不同的主机平台上,包括x86、PPC、Alpha、Sun和MIPS。不管主机平台是什么,Bochs仍然模拟x86硬件。换句话说,它完全不依赖于主机的本机指令。这既是优点也是缺点,也是Bochs与许多其他x86仿真软件(如VirtualBox、VMware等)的主要区别。因为Bochs对每个x86指令都使用软件仿真,所以它可以在Alpha或Sun工作站上模拟Windows应用程序。然而,Bochs方法的缺点是模拟性能。为了精确地模拟处理器,Bochs必须为每个模拟x86指令运行许多指令,这使得模拟机器比物理机器慢很多倍。商用PC模拟器(VMware、Connectix等)使用一种称为虚拟化的技术可以实现非常高的仿真速度,但它们既不能移植到非x86平台,也不能开源。
Bochs Features功能特性
| Feature | Supported? | Description |
| ---------------------------------- | ---------- | ------------------------------------------------------------ |
| configure script | Yes | Bochs uses GNU autoconf to configure Makefiles and headers. Autoconf helps Bochs to compile on a wide variety of platforms. |
| 386,486,Pentium Emulation | Yes | Bochs can be configured to emulate one of several families of Intel hardware. Some Pentium features are incomplete, such as SMM (System Management Mode). |
| P6 and later CPU Emulation | Yes | Bochs can be configured to emulate any P6 family processor including optional MMX and SSEx instructions. |
| x86-64 Extensions Emulation | Yes | Bochs can be configured to emulate x86-64 with many recent Intel and AMD extensions. |
| Command Line Debugger | Yes | Powerful command line debugger (optional) that lets you stop execution and examine registers and memory, set breakpoints, etc. |
| GUI Debugger | Yes | Chourdakis Michael and Bruce Ewing contributed very powerful GUI frontend for Bochs internal debugger. GUI debugger frontend is supported for Win32 and GTK2 hosts. |
| Floating Point | Yes | [Uses software floating point engine based on SoftFloat floating point emulation library.](http://www.jhauser.us/arithmetic/SoftFloat.html) |
| Enhanced BIOS | Yes | [Implements ElTorito, EDD v3.0, basic APM feature, PCIBIOS features and the PCI interrupt routing table. The latest version of the Bochs BIOS has a 32-bit init for ACPI, SMM and SMP. Bochs also known to work with recent SeaBIOS images.](http://www.seabios.org/) |
| VGA | Yes | VGA color graphics emulation in a window. |
| VBE (VESA) Support | Yes | [Currently resolutions up to 2560x1600x32bpp are supported. You must enable VBE with the VGA extension option and use the LGPL'd VGABIOS. For more information see Section 8.19.](http://bochs.sourceforge.net/doc/docbook/user/vesa-notes.html) |
| Cirrus Logic video card | Yes | [Cirrus Logic CL-GD5430 ISA or CL-GD5446 PCI video card support. For more information see Section 8.20.](http://bochs.sourceforge.net/doc/docbook/user/cirrus-notes.html) |
| Floppy disk | Yes | Supports floppy disk images on all platforms: 2.88M 3.5", 1.44M 3.5", 1.2M 5.25", 720K 3.5" and 360K 5.25". On Unix and Windows NT/2000/XP, Bochs can access the physical floppy drive. It is also possible to use a local directory as VFAT media (1.44M only). |
| Multiple ATA channels | Yes | Emulates up to 4 ATA channels. Up to 8 ATA/ATAPI emulated devices can be attached, two per ATA channel. So you can have eight hard disks or seven hard disks and a CD-ROM or four hard disks and four CD-ROMs, or one hard disk and seven CD-ROMs, etc... |
| Hard disk | Yes | Emulates ATA-6/IDE hard drives via image files. Physical hard disk access is supported on some architecture, but NOT recommended, primarily for safety reasons. With LBA48 support, hard disks up to 255TB are supported, on any platform that support large files access. It is also possible to use a local directory as VFAT drive. |
| CD-ROM | Yes | Emulates ATAPI-4/IDE CD-ROM. The CD-ROMs can read from an ISO disk image on any platform. On Windows (NT/2000/XP/Vista), Linux, SunOS, FreeBSD, NetBSD, OpenBSD, Amiga/MorphOS and MacOSX, Bochs can read from the physical CD-ROM drive. The Bochs BIOS supports booting from the first CD-ROM drive. |
| Keyboard | Yes | Emulates a PS/2 keyboard with North American key mappings. Optional keyboard layout remapping files are provided to support localized keyboard in X11 (Belgian, Danish, French, German, Italian, Russian, Slovenian, Spanish, Swedish, U.K.) and SDL/SDL2 (German). |
| Mouse | Yes | Emulates a serial, PS/2, bus or USB mouse with 3 buttons + optional mouse wheel support. There is also a USB tablet emulation available. |
| Sound card | Yes | [Emulates a Sound Blaster 16 card (ISA, no plug&play) or an ES1370 PCI card. The SB16 emulation provides wave input / output, the OPL3 chip, the external MIDI port and volume control for wave and FM. The ES1370 provides wave input / output, the MIDI UART port and volume control for wave output. On Windows, Linux, FreeBSD, MacOS 9, MacOSX and all platforms supported by SDL, the output can be sent to the host computer's sound system. For the SB16, see the developer documentation for details.](http://bochs.sourceforge.net/doc/docbook/development/sb16-emulation-basics.html) |
| Network card | Yes | [Emulates an NE2000 compatible network card (ISA / PCI) or an Intel(R) 82540EM Gigabit Ethernet adapter (PCI). On Windows NT/2000, Linux, FreeBSD, and NetBSD, Bochs will forward packets to and from the operating system so that the guest OS can talk on the physical network. Unfortunately, on some platforms the guest OS can talk to any machine on the network BUT NOT the host machine. On Windows and on systems that allow the TAP or TUN/TAP interface, there is no such limitation. Often the host machine may be configured so the guest OS has access to the internet. On MacOSX, you may download the TUN driver from: http://chrisp.de/en/projects/tunnel.html](http://chrisp.de/en/projects/tunnel.html) |
| Parallel Port | Yes | Parallel port emulation was added by Volker Ruppert for Bochs 1.3. Data that is sent to the parallel port by the guest OS can be saved into a file or sent directly into the parallel port device (Unix only). |
| Serial Port | Yes | The serial port (16550A UART emulation) is usable, on GNU/Linux, NetBSD, OpenBSD, FreeBSD and MacOSX as host and guest. On other OSes the emulation is present, but the connection to hard- or software of the host is not implemented yet. Up to 4 ports are available. |
| Gameport | Yes | Emulates a standard PC gameport. The connection to a real joystick is currently supported on Linux and win32 only. |
| PCI | Yes | Emulates most of the i440FX PCI chipset. The Host-to-PCI bridge (PMC/DBX), the PCI-to-ISA bridge and the PCI IDE controller (PIIX3) are available. For PCI cards there are 5 PCI slots supported. |
| USB | Yes | Four types of host controllers (UHCI, OHCI, EHCI and xHCI) and the devices 'mouse', 'tablet', 'keypad', 'disk', 'cdrom', 'floppy, ''hub' and 'printer' are available. Plugging in and removing devices at runtime is possible. Access to real hardware is not implemented yet. |
| Plugins | Yes | Compiling gui and devices as plugins is supported on Linux, MacOS X, Solaris, Cygwin, MinGW/MSYS, MSVC nmake and the VS2013 IDE (workspace provided). |
| PIC | Yes | Master and slave programmable interrupt controller. |
| CMOS functions | Yes | Real time clock (RTC) and CMOS RAM are available |
| Dynamic Translation/Virtualization | No | [Because Bochs is designed to be portable, it does not attempt to do any dynamic code translation or virtualization. See Section 1.1 for details.](http://bochs.sourceforge.net/doc/docbook/user/introduction.html#WHATISBOCHS) |
| Simulate a Multiprocessor | Yes | Bochs can be configured to simulate up to 254 processor threads. This feature is still experimental, but it can boot several Linux or Windows guests with SMP support. Please note that this does NOT mean that Bochs can run faster on a physical SMP machine. |
| Take advantage of your SMP box | Minimal | At present, Bochs only uses threads in the lowlevel sound output code. The simulation itself uses only one thread, so it will not run any faster on multiprocessor hardware. |
| Copy and Paste | Yes | Depending on the host platform, the text-mode screen text can be exported to the clipboard. Text in the clipboard can also be pasted, through Bochs, to the guest OS, as simulated keystrokes. |
第3章节 安装(Installation)
-
3-1 下载和获得Bochs
官方下载网址:bochs.sourceforge.net
The development versions (sometimes called SVN snapshots) may have some newer bug fixes and new features, but have not been tested as much as the releases.
开发版本(有时称为SVN snapshots)可能有一些较新的错误修复和新功能,但没有像发行版那样经过测试。
Second, you can choose to compile Bochs from source code or install a binary (if one is available for your platform). Binary packages will be quicker to install, and most include a small demo of a guest operating system called DLX Linux to get you started. However, some features can only be enabled if you compile Bochs yourself, for example the Bochs debugger. For multiuser systems, you will probably need system administrator privileges (root) to install a binary package. If you decide to get a binary, download it to your hard disk, uncompress it, then go to the section called Installing a Binary for more information.
但是,部分功能只能通过编译源码安装的方式来开启,比如Bochs debugger。这应该就是很多人选择源码安装的原因所在了。
下载源码包后,网上较多使用如下命令:
sudo tar zxvf bochs-2.6.9.tar.gz
详细使用手册http://www.gnu.org/software/tar/manual/
之前一直疑惑,tar的命令格式不一,后man之后,才大致明白道理为:命令有3种使用格式:
1、 Traditional usage
tar {A|c|d|r|t|u|x}[GnSkUWOmpsMBiajJzZhPlRvwo] [ARG...]
2、 UNIX-style usage
tar -A [OPTIONS] ARCHIVE ARCHIVE
3、 GNU-style usage
tar {--catenate|--concatenate} [OPTIONS] ARCHIVE ARCHIVE
-z, --gzip, --gunzip, --ungzip
Filter the archive through gzip(1).
-x, --extract, --get
Extract files from an archive. Arguments are optional. When given, they
specify names of the archive members to be extracted.
-v, --verbose
Verbosely list files processed.
Device selection and switching
-f, --file=ARCHIVE
Use archive file or device ARCHIVE. If this option is not given, tar
will first examine the environment variable `TAPE'. If it is set, its
value will be used as the archive name. Otherwise, tar will assume the
compiled-in default. The default value can be inspected either using the
--show-defaults option, or at the end of the tar --help output.
An archive name that has a colon in it specifies a file or device on a
remote machine. The part before the colon is taken as the machine name
or IP address, and the part after it as the file or device pathname,
e.g.:
--file=remotehost:/dev/sr0
An optional username can be prefixed to the hostname, placing a @ sign
between them.
By default, the remote host is accessed via the rsh(1) command. Nowadays
it is common to use ssh(1) instead. You can do so by giving the follow‐
ing command line option:
--rsh-command=/usr/bin/ssh
The remote machine should have the rmt(8) command installed. If its
pathname does not match tar's default, you can inform tar about the cor‐
rect pathname using the --rmt-command option.
-
3-2 使用SVN获得源码( Tracking the source code with SVN)
SVN网站http://subversion.apache.org/
-
3-3 二进制安装(Installing a Binary)
区分不同平台的安装方式:
1、windows
2、Linux RPM
user$ su
Password:
root$ ls -l bochs-2.5.x86_64.rpm
-rw-r--r-- 1 user users 2628643 Nov 27 17:20 bochs-2.5.x86_64.rpm
root$ rpm -i bochs-2.5.x86_64.rpm
root$ exit
user$ _
3、 MacOS X DMG
-
3-4 编译安装(Compiling Bochs)
Bochs is written in C++, so you need a C++ compiler on your system. Most platforms have been tested with GNU gcc/g++, but other compilers are known to work too. By now, you should have unpacked your source TAR file or checked out Bochs from SVN. If not, you can return to Downloading Bochs for details. The top level directory of the source code will be referred to as $BOCHS
. ( $BOCHS contains the files bochs.h and main.cc and subdirectories cpu and bios.)
Bochs使用c++写的,所以要编译Bochs,你的电脑上必须要有c++的编译器才行,这也是为什么很多解决办法中都有提及安装c++编译器的事。
The standard compile process has three basic steps: configure, make, and make install. Each step is described in a separate section below. The standard compile process is used on all Unix machines, MacOS X, and Cygwin (win32). There are separate instructions for compiling for Win32 with Microsoft VC++.
标准的编译步骤为3个:
◆ 1、configure
◆ 2、make
◆ 3、make install
3-4-1. 编译安装(Compiling Bochs)—Configure
首先下载一个源码包:
sudo wget https://sourceforge.net/projects/bochs/files/bochs/2.6.9/bochs-2.6.9.tar.gz
然后解压看看内容:
root@pop-os:/home# tar zxvf bochs-2.6.9.tar.gz
root@pop-os:/home/bochs-2.6.9# ls -ilh
total 2.4M
449638 -rwxr-xr-x 1 eqweq users 822K Apr 9 2017 configure
可以看出这个configure是可执行文件。用vim打开看一看:
root@pop-os:/home/bochs-2.6.9# vim configure
There is a script called configure which tests your machine, C/C++ compiler and libraries to discover what settings should work on your system. If you run configure with no arguments after it, defaults will be used for all settings. To change the settings, you can run configure with options that override the defaults. You can get a list of valid configure options by typing configure --help. One useful configure option is --prefix=directory, which sets the directory in which Bochs will be installed. All the possible configure options are documented in a later section.
使用configure --help可以显示合法的设置选项:
root@pop-os:/home/bochs-2.6.9# ./configure --help
`configure' configures this package to adapt to many kinds of systems.
Usage: ./configure [OPTION]... [VAR=VALUE]...
To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE. See below for descriptions of some of the useful variables.
Defaults for the options are specified in brackets.
Configuration:
-h, --help display this help and exit
--help=short display options specific to this package
--help=recursive display the short help of all the included packages
-V, --version display version information and exit
-q, --quiet, --silent do not print `checking ...' messages
--cache-file=FILE cache test results in FILE [disabled]
-C, --config-cache alias for `--cache-file=config.cache'
-n, --no-create do not create output files
--srcdir=DIR find the sources in DIR [configure dir or `..']
Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
[/usr/local]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[PREFIX]
By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc. You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.
For better control, use the options below.
Fine tuning of the installation directories:
--bindir=DIR user executables [EPREFIX/bin]
--sbindir=DIR system admin executables [EPREFIX/sbin]
--libexecdir=DIR program executables [EPREFIX/libexec]
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
--datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
--datadir=DIR read-only architecture-independent data [DATAROOTDIR]
--infodir=DIR info documentation [DATAROOTDIR/info]
--localedir=DIR locale-dependent data [DATAROOTDIR/locale]
--mandir=DIR man documentation [DATAROOTDIR/man]
--docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE]
--htmldir=DIR html documentation [DOCDIR]
--dvidir=DIR dvi documentation [DOCDIR]
--pdfdir=DIR pdf documentation [DOCDIR]
--psdir=DIR ps documentation [DOCDIR]
X features:
--x-includes=DIR X include files are in DIR
--x-libraries=DIR X library files are in DIR
System types:
--build=BUILD configure for building on BUILD [guessed]
--host=HOST cross-compile to build programs to run on HOST [BUILD]
--target=TARGET configure for building compilers for TARGET [HOST]
Optional Features:
--disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-static[=PKGS] build static libraries [default=no]
--enable-shared[=PKGS] build shared libraries [default=yes]
--enable-fast-install[=PKGS]
optimize for fast installation [default=yes]
--disable-libtool-lock avoid locking (might break parallel builds)
--enable-ltdl-install install libltdl
--disable-largefile omit support for large files
--enable-idle-hack use Roland Mainz's idle hack (no)
--enable-plugins enable plugin support (no)
--enable-a20-pin compile in support for A20 pin (yes)
--enable-x86-64 compile in support for x86-64 instructions (no)
--enable-smp compile in support for SMP configurations (no)
--enable-cpu-level select cpu level (3,4,5,6 - default is 6)
--enable-long-phy-address
compile in support for physical address larger than
32 bit (yes, if cpu level >= 5)
--enable-large-ramfile enable large ramfile support (yes)
--enable-repeat-speedups
support repeated IO and mem copy speedups (no)
--enable-fast-function-calls
support for fast function calls (no - gcc on x86 and
MSVC nmake only)
--enable-handlers-chaining
support handlers-chaining emulation speedups (no)
--enable-trace-linking enable trace linking speedups support (no)
--enable-configurable-msrs
support for configurable MSR registers (yes if cpu
level >= 5)
--enable-show-ips show IPS in Bochs status bar / log file (yes)
--enable-cpp use .cpp as C++ suffix (no)
--enable-debugger compile in support for Bochs internal debugger (no)
--enable-disasm compile in support for disassembler (no)
--enable-debugger-gui compile in support for Bochs internal debugger GUI
(yes, if debugger is on)
--enable-gdb-stub enable gdb stub support (no)
--enable-iodebug enable I/O interface to debugger (yes, if debugger
is on)
--enable-all-optimizations
compile in all possible optimizations (no)
--enable-readline use readline library, if available (no)
--enable-instrumentation=instrument-dir
compile in support for instrumentation (no)
--enable-logging enable logging (yes)
--enable-stats enable statistics collection (yes)
--enable-assert-checks enable BX_ASSERT checks (yes, if debugger is on)
--enable-fpu compile in FPU emulation (yes)
--enable-vmx VMX (virtualization extensions) emulation
(--enable-vmx=[no|1|2])
--enable-svm SVM (AMD: secure virtual machine) emulation (no)
--enable-protection-keys
User-Mode Protection Keys support (no)
--enable-3dnow 3DNow! support (no - incomplete)
--enable-alignment-check
alignment check (#AC) support (yes, if cpu level >
3)
--enable-monitor-mwait support for MONITOR/MWAIT instructions (yes, if cpu
level > 5 - experimental)
--enable-perfmon support for limited hardware performance monitoring
emulation (yes, if cpu level > 5 - experimental)
--enable-memtype support for memory type
--enable-avx support for AVX instructions (no)
--enable-evex support for EVEX prefix and AVX-512 extensions (no)
--enable-x86-debugger x86 debugger support (no)
--enable-pci enable i440FX PCI support (yes)
--enable-pcidev enable PCI host device mapping support (no - linux
host only)
--enable-usb enable USB UHCI support (no)
--enable-usb-ohci enable USB OHCI support (no)
--enable-usb-ehci enable USB EHCI support (no)
--enable-usb-xhci enable USB xHCI support (no)
--enable-ne2000 enable NE2000 support (no)
--enable-pnic enable PCI pseudo NIC support (no)
--enable-e1000 enable Intel(R) Gigabit Ethernet support (no)
--enable-raw-serial use raw serial port access (no - incomplete)
--enable-clgd54xx enable CLGD54XX emulation (no)
--enable-voodoo enable 3dfx Voodoo Graphics emulation (no)
--enable-cdrom lowlevel CDROM support (yes)
--enable-sb16 Sound Blaster 16 Support (no)
--enable-es1370 enable ES1370 soundcard support (no)
--enable-gameport enable standard PC gameport support (yes, if
soundcard present)
--enable-busmouse enable Busmouse support (InPort & Standard)
--enable-docbook build the Docbook documentation (yes, if docbook
present)
--enable-xpm enable the check for XPM support (yes)
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-gnu-ld assume the C compiler uses GNU ld [default=no]
--with-pic try to use only PIC/non-PIC objects [default=use
both]
--with-tags[=TAGS] include additional configurations [automatic]
--with-x use the X Window System
--with-x11 use X11 GUI
--with-win32 use Win32 GUI
--with-macos use Macintosh/CodeWarrior environment
--with-carbon compile for MacOS X with Carbon GUI
--with-nogui no native GUI, just use blank stubs
--with-term textmode terminal environment
--with-rfb use RFB protocol, works with VNC viewer
--with-vncsrv use LibVNCServer, works with VNC viewer
--with-amigaos use AmigaOS (or MorphOS) GUI
--with-sdl use SDL libraries
--with-sdl2 use SDL2 libraries
--with-svga use SVGALib libraries
--with-wx use wxWidgets libraries
--with-all-libs compile all guis that Bochs supports
Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L if you have libraries in a
nonstandard directory
LIBS libraries to pass to the linker, e.g. -l
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I if
you have headers in a nonstandard directory
CXX C++ compiler command
CXXFLAGS C++ compiler flags
CPP C preprocessor
CXXCPP C++ preprocessor
F77 Fortran 77 compiler command
FFLAGS Fortran 77 compiler flags
XMKMF Path to xmkmf, Makefile generator for X Window System
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
Report bugs to the package provider.
至此,终于明白了教程中那些“奇奇怪怪”的设置从何而来了。
Among other things, the configure script tries to detect your platform and which compile options to use. If you want to control this, set these environment variables before running configure: CC
, CXX
, CFLAGS
, CXXFLAGS
. Here is an example that sets the environment variables, using bash/ksh[1] syntax:
除此之外,configure脚本会尝试检测您的平台以及要使用的编译选项。如果要控制此情况,请在运行configure:CC、CXX、CFLAGS和CXXFLAGS之前设置这些环境变量。
如何设置?直接在命令行输入就可以。
eqweq@pop-os:/home/bochs-2.6.9$ export CC=egcs
eqweq@pop-os:/home/bochs-2.6.9$ export CXX="$CC"
eqweq@pop-os:/home/bochs-2.6.9$ export CFLAGS="-Wall -O2 -m486 -fomit-frame-pointer -pipe"
eqweq@pop-os:/home/bochs-2.6.9$ export CXXFLAGS="$CFLAGS"
执行完毕,使用env命令查看:
eqweq@pop-os:/home/bochs-2.6.9$ env
SHELL=/bin/bash
SESSION_MANAGER=local/pop-os:@/tmp/.ICE-unix/1568,unix/pop-os:/tmp/.ICE-unix/1568
COLORTERM=truecolor
XDG_CONFIG_DIRS=/etc/xdg/xdg-pop:/etc/xdg
XDG_MENU_PREFIX=gnome-
GNOME_DESKTOP_SESSION_ID=this-is-deprecated
GTK_IM_MODULE=ibus
LANGUAGE=en_US:en
QT4_IM_MODULE=ibus
LC_ADDRESS=en_US.UTF-8
GNOME_SHELL_SESSION_MODE=pop
LC_NAME=en_US.UTF-8
SSH_AUTH_SOCK=/run/user/1000/keyring/ssh
XMODIFIERS=@im=ibus
DESKTOP_SESSION=pop
LC_MONETARY=en_US.UTF-8
SSH_AGENT_PID=1482
GTK_MODULES=gail:atk-bridge
PWD=/home/bochs-2.6.9
LOGNAME=eqweq
XDG_SESSION_DESKTOP=pop
XDG_SESSION_TYPE=x11
GPG_AGENT_INFO=/run/user/1000/gnupg/S.gpg-agent:0:1
CXX=egcs
CXXFLAGS=-Wall -O2 -m486 -fomit-frame-pointer -pipe
XAUTHORITY=/run/user/1000/gdm/Xauthority
GJS_DEBUG_TOPICS=JS ERROR;JS LOG
WINDOWPATH=2
HOME=/home/eqweq
USERNAME=eqweq
IM_CONFIG_PHASE=1
LC_PAPER=en_US.UTF-8
LANG=en_US.UTF-8
LS_COLORS=rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.zst=01;31:*.tzst=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.wim=01;31:*.swm=01;31:*.dwm=01;31:*.esd=01;31:*.jpg=01;35:*.jpeg=01;35:*.mjpg=01;35:*.mjpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:
XDG_CURRENT_DESKTOP=pop:GNOME
VTE_VERSION=5802
GNOME_TERMINAL_SCREEN=/org/gnome/Terminal/screen/808a8304_3514_4ffc_ba4c_e8417a4ba94d
INVOCATION_ID=1f335c3c3216405a890ffc7adeacc28f
MANAGERPID=1312
CLUTTER_IM_MODULE=ibus
GJS_DEBUG_OUTPUT=stderr
LESSCLOSE=/usr/bin/lesspipe %s %s
XDG_SESSION_CLASS=user
TERM=xterm-256color
LC_IDENTIFICATION=en_US.UTF-8
LESSOPEN=| /usr/bin/lesspipe %s
USER=eqweq
GNOME_TERMINAL_SERVICE=:1.127
DISPLAY=:1
SHLVL=1
LC_TELEPHONE=en_US.UTF-8
QT_IM_MODULE=ibus
LC_MEASUREMENT=en_US.UTF-8
PAPERSIZE=letter
XDG_RUNTIME_DIR=/run/user/1000
LC_TIME=en_US.UTF-8
JOURNAL_STREAM=9:30160
XDG_DATA_DIRS=/usr/share/pop:/usr/local/share/:/usr/share/
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
CC=egcs
GDMSESSION=pop
CFLAGS=-Wall -O2 -m486 -fomit-frame-pointer -pipe
DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
LC_NUMERIC=en_US.UTF-8
OLDPWD=/home
_=/usr/bin/env
可见相关环境变量均已经设置好了。
测试完毕,为了不影响正常安装,现在把设置好的环境变量删除。使用unset 命令。
unset CC
unset CXX
unset CFLAGS
unset CXXFLAGS
Once the configure script knows what options are selected, it creates a Makefile in every source code directory, and creates $BOCHS/config.h with all the option values written as preprocessor #defines. Now the sources are ready to compile.
当configure script确定了选择的options之后,将创建一个Makefile,这个Makefile位于Bochs的源码目录之下(不同的目录都有各自的Makefile)。如果configure检查通过,将在源码目录下创建
config.h,此时才能进行编译。
对比./configure前后的文档构成变化。前:
后:
这两个文件确实产生了。config.h文件内容部分如下:
1 /* config.h. Generated from config.h.in by configure. */
2 //
3 // Copyright (C) 2001-2017 The Bochs Project
4 //
5 // This library is free software; you can redistribute it and/or
6 // modify it under the terms of the GNU Lesser General Public
7 // License as published by the Free Software Foundation; either
8 // version 2 of the License, or (at your option) any later version.
9 //
10 // This library is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // Lesser General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public
16 // License along with this library; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 US A
18 //
19
20 //
21 // config.h.in is distributed in the source TAR file. When you run
22 // the configure script, it generates config.h with some changes
23 // according to your build environment. For example, in config.h.in,
24 // SIZEOF_UNSIGNED_CHAR is set to 0. When configure produces config.h
25 // it will change "0" to the detected value for your system.
26 //
27 // config.h contains ONLY preprocessor #defines and a few typedefs.
28 // It must be included by both C and C++ files, so it must not
29 // contain anything language dependent such as a class declaration.
30 //
31
32 #ifndef _BX_CONFIG_H_
33 #define _BX_CONFIG_H_ 1
34
35 ///////////////////////////////////////////////////////////////////
36 // USER CONFIGURABLE OPTIONS : EDIT ONLY OPTIONS IN THIS SECTION //
37 ///////////////////////////////////////////////////////////////////
38
39
40 #if 1
41 // quit_sim is defined in gui/siminterface.h
42 #define BX_EXIT(x) SIM->quit_sim (x)
43 #else
44 // provide the real main and the usual exit.
45 #define BX_EXIT(x) ::exit(x)
.
.
.
使用快捷脚本进行Configure(Configure Shortcut Scripts)
In the Bochs source directory, you will see a series of scripts called .conf.platform
. These scripts run the configure script for you, with a set of options that are appropriate for that platform. It is not necessary to use the shortcut scripts; they are simply there to show you an example that the developers have used. Some of these scripts have been used to build official binary packages.
使用ls -alh查看目录下所有的文件,包括隐藏文件。你将看到很多类似.conf.XXXXXXX
的文件,当你运行对应你操作系统平台的文件的时候,将自动附带一些常规的设置来进行configure。
If you run a shortcut script, you don't need to run configure manually.
如果运行了快捷脚本,就不用再手动的进行输入configure进行设置了。
运行脚本的方式:
sh .conf.linux
eqweq@pop-os:/home/bochs-2.6.9$ ls -alh
total 2.9M
drwxr-xr-x 16 eqweq users 4.0K Nov 24 12:55 .
drwxr-xr-x 4 root root 4.0K Nov 24 06:38 ..
-rw-r--r-- 1 eqweq users 228K Feb 20 2012 aclocal.m4
drwxr-xr-x 2 eqweq users 4.0K Nov 24 08:09 bios
-rw-r--r-- 1 eqweq users 22K Dec 30 2016 bochs.h
-rw-r--r-- 1 eqweq users 59K Apr 2 2017 .bochsrc
drwxr-xr-x 8 eqweq users 4.0K Apr 9 2017 build
drwxr-xr-x 2 eqweq users 4.0K Nov 24 08:09 bx_debug
-rw-r--r-- 1 root root 356 Nov 24 08:09 bxversion.h
-rw-r--r-- 1 eqweq users 335 Nov 10 2001 bxversion.h.in
-rw-r--r-- 1 root root 471 Nov 24 08:09 bxversion.rc
-rw-r--r-- 1 eqweq users 456 May 16 2014 bxversion.rc.in
-rw-r--r-- 1 eqweq users 200K Apr 9 2017 CHANGES
-rwxr-xr-x 1 eqweq users 122 Nov 21 2006 .conf.amigaos
-rw-r--r-- 1 eqweq users 1.1K Dec 31 2016 .conf.everything
-rw-r--r-- 1 eqweq users 114K Mar 25 2017 config.cc
-rwxr-xr-x 1 eqweq users 44K Jun 11 2010 config.guess
-rw-r--r-- 1 root root 28K Nov 24 08:09 config.h
-rw-r--r-- 1 eqweq users 28K Feb 28 2017 config.h.in
-rw-r--r-- 1 root root 160K Nov 24 08:09 config.log
-rwxr-xr-x 1 root root 38K Nov 24 08:09 config.status
-rwxr-xr-x 1 eqweq users 35K Aug 13 2016 config.sub
-rwxr-xr-x 1 eqweq users 822K Apr 9 2017 configure
-rw-r--r-- 1 eqweq users 91K Apr 9 2017 configure.in
-rw-r--r-- 1 root root 32K Nov 24 07:09 .configure.swp
-rwxr-xr-x 1 eqweq users 2.2K Mar 25 2017 .conf.linux
-rwxr-xr-x 1 eqweq users 995 Mar 25 2017 .conf.macos
-rw-r--r-- 1 eqweq users 1.3K Mar 25 2017 .conf.macosx
-rwxr-xr-x 1 eqweq users 363 Oct 26 2012 .conf.nothing
-rwxr-xr-x 1 eqweq users 539 May 3 2011 .conf.sparc
-rwxr-xr-x 1 eqweq users 927 Mar 25 2017 .conf.win32-cygwin
-rwxr-xr-x 1 eqweq users 929 Mar 25 2017 .conf.win32-vcpp
-rw-r--r-- 1 eqweq users 26K Feb 8 2009 COPYING
drwxr-xr-x 6 eqweq users 4.0K Nov 24 08:09 cpu
-rw-r--r-- 1 eqweq users 2.1K Mar 26 2017 cpudb.h
-rw-r--r-- 1 eqweq users 2.3K Apr 3 2011 crc.cc
drwxr-xr-x 2 eqweq users 4.0K Nov 24 08:09 disasm
drwxr-xr-x 4 eqweq users 4.0K Apr 9 2017 doc
drwxr-xr-x 2 eqweq users 4.0K Apr 9 2017 docs-html
-rw-r--r-- 1 eqweq users 1.6K Mar 12 2017 extplugin.h
-rw-r--r-- 1 eqweq users 23K Mar 7 2017 gdbstub.cc
drwxr-xr-x 5 eqweq users 4.0K Nov 24 08:09 gui
drwxr-xr-x 3 eqweq users 4.0K Apr 9 2017 host
-rwxr-xr-x 1 eqweq users 5.5K Mar 8 2002 install-sh
drwxr-xr-x 6 eqweq users 4.0K Apr 9 2017 instrument
drwxr-xr-x 7 eqweq users 4.0K Nov 24 08:09 iodev
-rwxr-xr-x 1 root root 198K Nov 24 08:09 libtool
-rw-r--r-- 1 eqweq users 301 Aug 31 2012 LICENSE
-rw-r--r-- 1 eqweq users 8.9K Jan 3 2015 load32bitOShack.cc
-rw-r--r-- 1 eqweq users 18K Dec 30 2016 logio.cc
-rw-r--r-- 1 eqweq users 13K Dec 18 2013 ltdl-bochs.h
-rw-r--r-- 1 eqweq users 86K Jan 3 2015 ltdl.c
-rw-r--r-- 1 root root 4.6K Nov 24 08:09 ltdlconf.h
-rw-r--r-- 1 eqweq users 4.3K Oct 25 2002 ltdlconf.h.in
-rw-r--r-- 1 eqweq users 177K Feb 8 2009 ltmain.sh
-rw-r--r-- 1 eqweq users 49K Feb 19 2017 main.cc
-rw-r--r-- 1 root root 29K Nov 24 08:09 Makefile
-rw-r--r-- 1 eqweq users 31K Mar 18 2017 Makefile.in
drwxr-xr-x 2 eqweq users 4.0K Nov 24 08:09 memory
drwxr-xr-x 3 eqweq users 4.0K Nov 24 08:09 misc
-rw-r--r-- 1 eqweq users 1.5K Apr 3 2011 msrs.def
-rw-r--r-- 1 eqweq users 11K Dec 6 2016 osdep.cc
-rw-r--r-- 1 eqweq users 9.8K Dec 23 2014 osdep.h
-rw-r--r-- 1 eqweq users 11K Feb 15 2017 param_names.h
-rw-r--r-- 1 eqweq users 3.7K Mar 29 2017 PARAM_TREE.txt
drwxr-xr-x 2 eqweq users 4.0K Apr 9 2017 patches
-rw-r--r-- 1 eqweq users 18K Jan 26 2015 pc_system.cc
-rw-r--r-- 1 eqweq users 6.8K Dec 31 2014 pc_system.h
-rw-r--r-- 1 eqweq users 29K Mar 31 2017 plugin.cc
-rw-r--r-- 1 eqweq users 22K Apr 1 2017 plugin.h
-rw-r--r-- 1 eqweq users 20K Jan 9 2016 qemu-queue.h
-rw-r--r-- 1 eqweq users 3.6K Apr 9 2017 README
-rw-r--r-- 1 eqweq users 19K Feb 6 2008 README-plugins
-rw-r--r-- 1 eqweq users 200 Dec 24 2013 README.rfb
-rw-r--r-- 1 eqweq users 5.4K Dec 24 2013 README-wxWidgets
-rw-r--r-- 1 eqweq users 4.7K Nov 8 2011 TESTFORM.txt
-rw-r--r-- 1 eqweq users 9.8K Mar 22 2017 TODO
-rw-r--r-- 1 eqweq users 3.5K Jan 14 2014 win32_enh_dbg.rc
-rw-r--r-- 1 eqweq users 3.9K Mar 19 2017 win32res.rc
-rw-r--r-- 1 eqweq users 220 Dec 28 2013 wxbochs.rc
其实快捷脚本的原理也很简单,我们可以看看内容是什么:
#!/bin/sh
#
# .conf.linux
#
#which_config=normal
which_config=plugins
CC="gcc"
CXX="c++"
CFLAGS="-Wall -O3 -fomit-frame-pointer -pipe" # for speed
#CFLAGS="-Wall -g -pipe" # for development
CXXFLAGS="$CFLAGS"
export CC
export CXX
export CFLAGS
export CXXFLAGS
case $which_config in
normal)
#######################################################################
# configuration 1 for release binary RPMs
# Include a few standard options, speed optimizations, X11 only.
#######################################################################
./configure --enable-sb16 \
--enable-ne2000 \
--enable-all-optimizations \
--enable-cpu-level=6 \
--enable-x86-64 \
--enable-vmx=2 \
--enable-pci \
--enable-clgd54xx \
--enable-voodoo \
--enable-usb \
--enable-usb-ohci \
--enable-usb-ehci \
--enable-usb-xhci \
--enable-busmouse \
--enable-es1370 \
--enable-e1000 \
--enable-show-ips \
${CONFIGURE_ARGS}
;;
plugins)
#######################################################################
# configuration 2 for release binary RPMs
# Include plugins, every possible gui.
#######################################################################
./configure --enable-sb16 \
--enable-ne2000 \
--enable-all-optimizations \
--enable-cpu-level=6 \
--enable-x86-64 \
--enable-vmx=2 \
--enable-pci \
--enable-clgd54xx \
--enable-voodoo \
--enable-usb \
--enable-usb-ohci \
--enable-usb-ehci \
--enable-usb-xhci \
--enable-busmouse \
--enable-es1370 \
--enable-e1000 \
--enable-plugins \
--enable-show-ips \
--with-all-libs \
${CONFIGURE_ARGS}
;;
esac
如果之前曾经安装过Bochs的话,你可能已经发现了,其实这个脚本文件就是把手动的命令的封装到了文件之中。
这就意味着,个人可以按照脚本格式,修改内部的设置内容,以后再需要安装,直接运行脚本就可以了。
3-4-2. 编译安装(Compiling Bochs)—Make
The make command compiles Bochs. Make is a program used by many software projects that reads the Makefile in each source directory and follows the instructions that it finds there. A Makefile tells which files depend on which other files, what commands to use to compile and link the code, and more. After you have finished the configure step, just type make to build the source code.
The reason that make is so popular is that it is smart about when to compile and when not to compile. If you run make once, it compiles every file. But when you run it again, it checks to see if any source files have been modified; if not, there's nothing to do! For example, the Makefile says that main.o depends on main.cc. Knowing this, it will only compile main.cc if it is newer than main.o.
Of course, make can only do the right thing if the Makefile lists all the dependencies correctly, so human error can sometimes lead make astray. If make refuses to build something that you think it should, or you are getting strange compile errors, try doing make all-clean and then make again. All-clean means to clean up the compiled files in every subdirectory, while make clean means to clean up just the current directory. However, it's important to note that make all-clean leaves the configuration intact. You do not have to run configure again.
如果make出了问题,可以使用:
make clean
make all-clean
清除所有的make设置,但是configure的设置没有改变。
If you're really in the mood for cleaning, make dist-clean erases all the configuration information too. In theory, after a dist-clean your directory should look much like when you first untarred it or checked it out. There's usually some extra stuff lying around, but the Makefile tries at least to erase any files that it created.
如果确实有需要清除configure的一系列动作和影响,就执行:make dist-clean
root@pop-os:/home/bochs-2.6.9# make dist-clean
rm -f *.o
rm -f *.a
rm -f bochs
rm -f bochs.exe
rm -f bximage
rm -f bximage.exe
rm -f bxhub
rm -f bxhub.exe
rm -f niclist
rm -f niclist.exe
rm -f bochs.out
rm -f bochsout.txt
rm -f *.exp *.lib
rm -f bochs.def
rm -f bochs.scpt
rm -f -rf bochs.app
rm -f -rf .libs
rm -f .win32_dll_plugin_target
rm -f config.h config.status config.log config.cache
rm -f .dummy `find . -name '*.dsp' -o -name '*.dsw' -o -name '*.opt' -o -name '.DS_Store'`
rm -f bxversion.h bxversion.rc build/linux/bochs-dlx _rpm_top *.rpm
rm -f build/win32/nsis/Makefile build/win32/nsis/bochs.nsi
rm -f build/macosx/Info.plist build/macosx/script_compiled.rsrc
rm -f libtool
rm -f ltdlconf.h
cd iodev && \
make dist-clean
make[1]: Entering directory '/home/bochs-2.6.9/iodev'
rm -f -rf .libs *.lo *.o *.la *.a *.dll *.exp *.lib
rm -f Makefile makeincl.vc
make[1]: Leaving directory '/home/bochs-2.6.9/iodev'
echo done
done
cd iodev/display && \
make dist-clean
make[1]: Entering directory '/home/bochs-2.6.9/iodev/display'
rm -f -rf .libs *.lo *.o *.la *.a *.dll *.exp *.lib
rm -f Makefile
make[1]: Leaving directory '/home/bochs-2.6.9/iodev/display'
echo done
done
cd iodev/hdimage && \
make dist-clean
make[1]: Entering directory '/home/bochs-2.6.9/iodev/hdimage'
rm -f -rf .libs *.lo *.o *.la *.a *.dll *.exp *.lib
rm -f Makefile
make[1]: Leaving directory '/home/bochs-2.6.9/iodev/hdimage'
echo done
done
cd iodev/usb && \
make dist-clean
make[1]: Entering directory '/home/bochs-2.6.9/iodev/usb'
rm -f -rf .libs *.lo *.o *.la *.a *.dll *.exp *.lib
rm -f Makefile
make[1]: Leaving directory '/home/bochs-2.6.9/iodev/usb'
echo done
done
cd iodev/network && \
make dist-clean
make[1]: Entering directory '/home/bochs-2.6.9/iodev/network'
rm -f -rf .libs slirp/.libs *.lo slirp/*.lo *.o slirp/*.o *.la *.a *.dll *.exp *.lib
rm -f Makefile
make[1]: Leaving directory '/home/bochs-2.6.9/iodev/network'
echo done
done
cd iodev/sound && \
make dist-clean
make[1]: Entering directory '/home/bochs-2.6.9/iodev/sound'
rm -f -rf .libs *.lo *.o *.la *.a *.dll *.exp *.lib
rm -f Makefile
make[1]: Leaving directory '/home/bochs-2.6.9/iodev/sound'
echo done
done
cd bx_debug && \
make dist-clean
make[1]: Entering directory '/home/bochs-2.6.9/bx_debug'
rm -f *.o
rm -f libdebug.a
rm -f Makefile
make[1]: Leaving directory '/home/bochs-2.6.9/bx_debug'
echo done
done
cd bios && \
make dist-clean
make[1]: Entering directory '/home/bochs-2.6.9/bios'
rm -f *.o *.a *.s _rombios*_.c rombios*.txt rombios*.sym
rm -f usage biossums rombios16.bin
rm -f rombios32.bin rombios32.out
rm -f Makefile
make[1]: Leaving directory '/home/bochs-2.6.9/bios'
echo done
done
cd cpu && \
make dist-clean
make[1]: Entering directory '/home/bochs-2.6.9/cpu'
rm -f *.o
rm -f *.a
rm -f decoder/*.o
rm -f Makefile
make[1]: Leaving directory '/home/bochs-2.6.9/cpu'
echo done
done
cd cpu/avx && \
make dist-clean
make[1]: Entering directory '/home/bochs-2.6.9/cpu/avx'
rm -f *.o
rm -f *.a
rm -f Makefile
make[1]: Leaving directory '/home/bochs-2.6.9/cpu/avx'
echo done
done
cd cpu/cpudb && \
make dist-clean
make[1]: Entering directory '/home/bochs-2.6.9/cpu/cpudb'
rm -f amd/*.o
rm -f intel/*.o
rm -f *.a
rm -f Makefile
make[1]: Leaving directory '/home/bochs-2.6.9/cpu/cpudb'
echo done
done
cd cpu/fpu && \
make dist-clean
make[1]: Entering directory '/home/bochs-2.6.9/cpu/fpu'
rm -f *.o
rm -f *.a
rm -f Makefile
make[1]: Leaving directory '/home/bochs-2.6.9/cpu/fpu'
echo done
done
cd memory && \
make dist-clean
make[1]: Entering directory '/home/bochs-2.6.9/memory'
rm -f *.o
rm -f *.a
rm -f Makefile
make[1]: Leaving directory '/home/bochs-2.6.9/memory'
echo done
done
cd gui && \
make dist-clean
make[1]: Entering directory '/home/bochs-2.6.9/gui'
rm -f -rf .libs *.la *.a *.lo *.o *.dll *.exp *.lib
rm -f Makefile
make[1]: Leaving directory '/home/bochs-2.6.9/gui'
echo done
done
cd disasm && \
make dist-clean
make[1]: Entering directory '/home/bochs-2.6.9/disasm'
rm -f *.o
rm -f *.a
rm -f Makefile
make[1]: Leaving directory '/home/bochs-2.6.9/disasm'
echo done
done
cd instrument/stubs && \
make dist-clean
make[1]: Entering directory '/home/bochs-2.6.9/instrument/stubs'
rm -f *.o
rm -f *.a
rm -f Makefile
make[1]: Leaving directory '/home/bochs-2.6.9/instrument/stubs'
echo done
done
cd misc && \
make dist-clean
make[1]: Entering directory '/home/bochs-2.6.9/misc'
rm -f *.o
rm -f make_cmos_image
rm -f Makefile
make[1]: Leaving directory '/home/bochs-2.6.9/misc'
echo done
done
cd doc/docbook && \
make dist-clean
make[1]: Entering directory '/home/bochs-2.6.9/doc/docbook'
# remove generated files
for S in user documentation development; do \
rm -f $S/*.html $S/*.htm $S/*.ps $S/*.pdf $S/*.out; \
done
rm -f bochsdoc.tar.gz
rm -f Makefile
make[1]: Leaving directory '/home/bochs-2.6.9/doc/docbook'
echo done
done
cd host/linux/pcidev && \
make dist-clean
make[1]: Entering directory '/home/bochs-2.6.9/host/linux/pcidev'
rm -f *.o *~ core *.mod.* .*.cmd *.ko
rm -f Makefile
make[1]: Leaving directory '/home/bochs-2.6.9/host/linux/pcidev'
echo done
done
rm -f Makefile
可以看到,很多rm命令也就是删除命令被执行了。而且ls后,也发现经过configure产生的一些文件等都没有了。
3-4-3. 编译安装(Compiling Bochs)— Make Install
Once the program has been built, the next step is typically to run make install to copy the executables, documentation, and other required files into a public place so that all users can use it. By default the files are copied to some directories in /usr/local. The following tables shows the directories and their contents.
程序构建完成后,下一步通常是运行make install,将可执行文件、文档和其他所需文件复制到公共场所,以便所有用户都可以使用它。默认情况下,文件被复制到/usr/local中的一些目录中。下表显示了目录及其内容:
bin | binary executables (bochs, bximage) |
---|---|
lib/bochs/plugins | plugins (if present) |
man/man1 | manpages for installed binaries |
man/man5 | manpage for the config file (bochsrc) |
share/bochs | BIOS images, VGABIOS images, keymaps |
share/doc/bochs | HTML docs, license, readme, changes, bochsrc sample |
3-4-4. 编译安装(Compiling Bochs)— Installing the DLX Linux demo
To download and install the DLX Linux demo distributed with Bochs binary release packages, use these two make commands:
#必须首先configure
make unpack_dlx
#首先Bochs安装好
make install_dlx
The package will be downloaded from the Bochs website and installed at same location as the files of the Bochs base system.
root@pop-os:/home/bochs-2.6.9# make unpack_dlx
rm -f dlxlinux4.tar.gz
wget http://bochs.sourceforge.net/guestos/dlxlinux4.tar.gz
--2019-11-24 15:27:11-- http://bochs.sourceforge.net/guestos/dlxlinux4.tar.gz
Resolving bochs.sourceforge.net (bochs.sourceforge.net)... 216.105.38.10
Connecting to bochs.sourceforge.net (bochs.sourceforge.net)|216.105.38.10|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1504652 (1.4M) [application/x-gzip]
Saving to: ‘dlxlinux4.tar.gz’
dlxlinux4.tar.gz 100%[===================>] 1.43M 5.63KB/s in 4m 5s
2019-11-24 15:31:18 (5.99 KB/s) - ‘dlxlinux4.tar.gz’ saved [1504652/1504652]
test -f dlxlinux4.tar.gz
rm -rf dlxlinux
gunzip -c dlxlinux4.tar.gz | tar -xvf -
dlxlinux/
dlxlinux/testform.txt
dlxlinux/readme.txt
dlxlinux/bochsrc.txt
dlxlinux/hd10meg.img
test -d dlxlinux
(cd dlxlinux; mv bochsrc.txt bochsrc.txt.orig; sed -e "s/1\.1\.2/2.6.9/g" -e 's,/usr/local/bochs/latest,/usr/local/share/bochs,g' < bochsrc.txt.orig > bochsrc.txt; rm -f bochsrc.txt.orig)
可以看到一些自动下载,解压缩的过程。
以dlx开头的文件和包。
第4章节 Configure设置( Configure Options)
This section describes the configure options for Bochs. Perhaps the most important option is --help
, since it gives you a list of all the other options. The configure script will detect your platform and choose the default GUI for your platform. If the default choice is not what you want, use the --with-*
options to override the default. The options in the first table tell which GUI library is the default for each platform. Starting in version 2.0, you can use multiple --with-*
options at once to compile with multiple display libraries, and then choose between them at runtime with the display_library option in the configuration file. Or, you can let the configure script detect which libraries are on your system and use them all, by configuring with --with-all-libs
.
本节介绍BOCH的配置选项。也许最重要的选项是--help,因为它提供了所有其他选项的列表。configure脚本将检测您的平台并为您的平台选择默认GUI。如果默认选项不是您想要的,请使用--with-选项覆盖默认选项。第一个表中的选项指示每个平台的默认GUI库。从2.0版开始,您可以同时使用多个--with-选项编译多个显示库,然后在运行时使用配置文件中的display_library选项在它们之间进行选择。或者,您可以让configure脚本检测系统上的哪些库并全部使用它们,方法是使用--with all libs进行配置。
Defaults by Platform
| Platform | Default GUI | Extra compile flags |
| --------------------------- | -------------- | ------------------------------------------------------------ |
| win32, Cygwin or MinGW/MSYS | --with-win32 | If using nmake method, compile using cl /nologo /MT /W3 /EHs-c- /DNDEBUG /DWIN32 /D_WINDOWS /D_CRT_SECURE_NO_WARNINGS. If using Visual C++ workspace, see the workspace file for compile settings. See [Compiling on Win32 with Microsoft VC++](http://bochs.sourceforge.net/doc/docbook/user/compiling.html#COMPILING-WIN32) for instructions. |
| MacOS X or Darwin | --with-carbon | -fpascal-strings -fno-common -arch ppc -Wno-four-char-constants -Wno-unknown-pragmas -Dmacintosh |
| MacOS 9 or before | --with-macos | none |
| AmigaOS | --with-amigaos | none |
| any other platform | --with-x11 | none |
Configure Options to Select the Display Library (optional)
选择UI显示库的设置选项
| Option | Comments |
| --------------- | ------------------------------------------------------------ |
| --with-x11 | Use X windows user interface. On many operating systems, Bochs will use X windows by default. |
| --with-win32 | Use the native Win32 GUI. This is the default on win32 platforms. |
| --with-carbon | Compile for MacOS X with the Carbon GUI. See the .conf.macosx file for the correct MacOS X compile options. WARNING: This Bochs feature is not maintained yet and may fail. |
| --with-amigaos | Compile for Amiga MorphOS. This code is written by Nicholai Benalal. |
| --with-rfb | Enable support for the RFB protocol to talk to AT&T's [VNC Viewer](http://www.realvnc.com/). Refer to [Section 3.4.9](http://bochs.sourceforge.net/doc/docbook/user/compiling.html#COMPILE-RFB) for details. |
| --with-vncsrv | Enable support for an extended RFB(VNC) GUI using the LibVNCServer library. Refer to [Section 3.4.10](http://bochs.sourceforge.net/doc/docbook/user/compiling.html#COMPILE-VNCSRV) for details. |
| --with-sdl | Enable support for the SDL 1.2.x GUI interface; see [Section 3.4.11](http://bochs.sourceforge.net/doc/docbook/user/compiling.html#COMPILE-SDL). |
| --with-sdl2 | Enable support for the SDL 2.x GUI interface; see [Section 3.4.12](http://bochs.sourceforge.net/doc/docbook/user/compiling.html#COMPILE-SDL2). |
| --with-term | Use text-only gui with curses library. Almost certainly won't work right with the debugger or the textconfig interface. |
| --with-macos | Use Macintosh/CodeWarrior environment. This is for running configure on a platform which supports running configure, so that you may then transfer the configured code over to the real compile environment. WARNING: This Bochs feature is not maintained yet and may fail. |
| --with-wx | Enable support for wxWidgets configuration and display interface; see [Section 3.4.13](http://bochs.sourceforge.net/doc/docbook/user/compiling.html#COMPILE-WX). |
| --with-svga | Use SVGALIB library for Linux. This allows a full-screen text and graphics display without X windows. The SVGALIB port was written by Igor Popik. WARNING: This Bochs feature is not maintained yet and may fail. |
| --with-nogui | No native GUI; just use blank stubs. This is if you don't care about having video output, but are just running tests. |
| --with-all-libs | Automatically detect which libraries are installed on your system and enable them. This option is still experimental; it might enable libraries that are not usable and cause the compile to fail. If you have trouble, just list the `--with-*` options for the specific display libraries that you want. |
The remaining options can generally be used with any GUI. For each option such as --enable-cdrom
, you can also write --disable-cdrom
to explicitly turn it off. The following 3 tables show the general options (.e.g debugger and plugins support), the CPU-related stuff (e.g. cpu level, SMP, x86_64 support) and the devices options (e.g. PCI, USB, Cirrus graphics).
以下的选项均可以配合任何GUI选项使用。
所有的--enable均可以使用--disable来关闭设置。
Configure Options (General)
| Option | Default | Comments |
| ------------------------------------ | --------------------- | ------------------------------------------------------------ |
| --enable-plugins | no | Plugins are shared libraries that can be loaded on demand. Example: the serial device is implemented as a plugin. In Unix, the serial plugin is called libbx_serial.so. When Bochs reads its configuration file, if the serial device is enabled it loads libbx_serial.so. See the Features section for supported platforms. |
| --enable-debugger | no | Compile in support for Bochs internal command-line debugger. This has nothing to do with x86 hardware debug support. It is a more powerful and non-intrusive native debugger. Enabling this will of course slow down the emulation. You only need this option if you know you need it. After you have run **./configure**, you may want to edit `config.h` to customize the debugger further; see [Section 8.14](http://bochs.sourceforge.net/doc/docbook/user/internal-debugger.html) for more information. |
| --enable-debugger-gui | yes if debugger is on | Enable support for the gui frontend of the Bochs debugger. This feature is supported on Windows hosts and on hosts with GTK2 installed. |
| --enable-readline | detected by configure | Compile the debugger with the GNU readline library, which gives command line editing and history. |
| --enable-gdb-stub | no | Enable support for the remote GDB stub. See [Using Bochs and the remote GDB stub](http://bochs.sourceforge.net/doc/docbook/user/debugging-with-gdb.html). NOTE: This feature cannot be used if the Bochs debugger is also enabled. WARNING: This Bochs feature is not maintained yet and may fail. |
| --enable-disasm | yes | Compile in support for built-in disassembler. Bochs has a built-in disassembler, which is useful if you either run the built-in debugger (`--enable-debugger`), or want disassembly of the current instruction when there is a panic in bochs. |
| --enable-docbook | detected | Build the docbook documentation in doc/docbook. The configure script will enable this option automatically if you have a program called docbook2html installed. |
| --enable-instrumentation=`directory` | no | Compile in support for instrumentation. This allows you to collect instrumentation data from bochs as it executes code. You have to create your own instrumentation library and define the instrumentation macros (hooks in bochs) to either call your library functions or not, depending upon whether you want to collect each piece of data. |
| --enable-xpm | yes | Enables the check for the XPM library. This option is only valid if the x display library is enabled (`--with-x11`). |
| --enable-show-ips | yes | Enables logging of measured IPS, see the **ips** parameter of the [cpu option](http://bochs.sourceforge.net/doc/docbook/user/bochsrc.html#BOCHSOPT-CPU-IPS). |
| --enable-logging | yes | By default, Bochs generates logfile output that can be configured with bochsrc options and at runtime. Use `--disable-logging` to turn off this feature completely. |
| --enable-assert-checks | yes if debugger is on | BX_ASSERT event causes a panic on assertion failure if enabled (logging feature must be enabled, too). |
| --enable-cpp | no | Use .cpp as C++ suffix. Renames all the .cc files to .cpp for use with compilers which want that, like older MS C++ compilers. Don't use this option unless you know you need it. |
| --enable-idle-hack | no | Enables Roland Mainz's experimental idle code, which is intended to keep Bochs from always using 100% of CPU time. When Bochs is waiting around for an interrupt, the idle code uses a select() loop and some X11 tricks to wait until user input arrives. This is designed to keep Bochs responsive while still yielding to other processes when Bochs is idle. It only works with X11 or term GUI. |
Configure Options (CPU & Memory)
CPU及Memory设置
| Option | Default | Comments |
| ------------------------------ | --------------------- | ------------------------------------------------------------ |
| --enable-cpu-level={`3,4,5,6`} | 6 | Select which CPU level to emulate. Choices are 3,4,5,6 which mean to target 386, 486, Pentium, or Pentium Pro and later emulation. |
| --enable-smp | no | Compile in support for SMP simulation. This allows you to boot Linux and maybe other OSes in SMP mode, and bochs will simulate all the different CPUs and communication between them. Do not expect this option to speed up your simulation! On the contrary, it has to spend extra time simulating the different CPUs (even if they're mostly idle) and the communication between them. Use it to try out an SMP OS if you don't have an SMP machine, or to debug SMP OS drivers. Refer to [Section 8.9](http://bochs.sourceforge.net/doc/docbook/user/smp.html) for more details on SMP in Bochs. |
| --enable-fpu | yes | If you want to compile Bochs to make use of the FPU emulator written by Stanislav Shwartsman, use this option. |
| --enable-3dnow | no | 3DNow! instruction set support (incomplete) |
| --enable-x86-64 | no | Add support for x86-64 instruction set, written by Peter Tattam and Stanislav Shwartsman. |
| --enable-vmx | no | Intel Virtualization Extensions (VMX) support |
| --enable-svm | no | AMD SVM (Secure Virtual Machine) extensions emulation support |
| --enable-avx | no | AVX instructions support |
| --enable-x86-debugger | no | X86 debugger support. If the software you run in bochs needs to use the x86 hardware debugging facilities such as DR0..DR7, instruction and data breakpoints etc., then you should use this option. Otherwise don't use it, as it will slow down the emulation. |
| --enable-monitor-mwait | no | MONITOR/MWAIT instructions support (still experimental) |
| --enable-alignment-check | yes if cpu level >= 4 | support for alignment check in the CPU and #AC exception |
| --enable-configurable-msrs | no | support for user configurations of emulated MSR registers (see example in msrs.def) |
| --enable-long-phy-address | no | support for guest physical address larger than 32 bit |
| --enable-a20-pin | yes | support for the A20 pin |
| --enable-large-ramfile | yes | support for guest memory larger than the host supports |
| --enable-repeat-speedups | no | enable support repeated I/O and memory copy speedups |
| --enable-fast-function-calls | no | enable support for fast function calls (gcc on x86 only) |
| --enable-handlers-chaining | no | enable support for handlers chaining optimization |
| --enable-all-optimizations | no | Turn on the enables for all speed optimizations that the developers believe are safe to use: --enable-repeat-speedups, --enable-fast-function-calls, --enable-handlers-chaining. |
Configure Options (Devices)
设备
| Option | Default | Comments |
| ------------------- | --------------------- | ------------------------------------------------------------ |
| --enable-cdrom | yes | Enable use of a real CDROM/DVD drive. The cdrom emulation and the portable ISO image file support are always present. You can use this option to compile in support for accessing the media in your workstation's cdrom drive. The supported platforms are Linux, Solaris, FreeBSD, OpenBSD, MacOS X and Windows. For other platforms, a small amount of code specific to your platform must be written. |
| --enable-sb16 | no | Enable Sound Blaster emulation. The available lowlevel sound interfaces are autodetected. See section [Using Sound](http://bochs.sourceforge.net/doc/docbook/user/using-sound.html) for supported platforms and more info. This option also enables the standard PC gameport which is a part of the SB16. If you don't want to use it, you might use `--disable-gameport`. |
| --enable-es1370 | no | Enable ES1370 sound emulation. Just like the SB16 option, the available lowlevel sound interfaces are autodetected and the gameport is turned on. |
| --enable-gameport | no | Enables the standard PC gameport. This option is only necessary if you want to have a gameport, but no SB16 or ES1370 (see above). The connection to a real joystick is currently supported on Linux and win32 only. |
| --enable-ne2000 | no | Enable NE2000 network card support. This requires a low-level component to be written for each OS (supported on FreeBSD, OpenBSD, Linux, and Windows 9x/NT/2K/XP). When enabled and configured, the NE2000 device model can talk to any computer on the network EXCEPT FOR the local host. Exception: Under most circumstances, Bochs can talk to the local host on Windows, and in the ethertap interface for Linux. |
| --enable-pnic | no | Enable PCI pseudo NIC (network card) support. |
| --enable-e1000 | no | Enable Intel(R) 82540EM Gigabit Ethernet adapter support. |
| --enable-clgd54xx | no | Enable Cirrus Logic GD54xx (CL-GD5430 ISA or CL-GD5446 PCI) video card support. For more information see [Section 8.20](http://bochs.sourceforge.net/doc/docbook/user/cirrus-notes.html). |
| --enable-voodoo | no | Enable experimental 3dfx Voodoo Graphics emulation. Currently only the Voodoo1 model is known to work (Voodoo2 is under construction). |
| --enable-iodebug | yes if debugger is on | Dave Poirier has written an experimental interface to the debugger using I/O ports, so that software running in the guest OS can access features of the debugger. You only want this option if you are developing guest OS code for use in Bochs. In other words, most people don't. Also, it should only be used with `--enable-debugger`. See the [developer documentation](http://bochs.sourceforge.net/doc/docbook/development/iodebug.html) for details. |
| --enable-pci | yes | Enable limited i440FX / i430FX PCI support. This is still incomplete, but usable. |
| --enable-pcidev | no | Enable PCI host device mapping support. This requires `--enable-pci` to be set as well as Linux 2.4, 2.6 or 3.x as host. WARNING: This Bochs feature is not maintained yet and may fail. |
| --enable-usb | no | Enable i440FX PCI USB support (UHCI). The host controller with 2-port root hub and 8 USB device types are available. |
| --enable-usb-ohci | no | Enable USB OHCI support. The host controller with 2-port root hub is available (USB device types: same as UHCI). |
| --enable-usb-ehci | no | Enable USB EHCI support. The host controller with 6-port root hub is available (USB device types: same as UHCI). |
| --enable-usb-xhci | no | Enable USB xHCI support. The host controller with 4-port root hub is available (USB device types: same as UHCI). |
| --enable-raw-serial | no | Enable support for the serial port emulation to access to the host's serial port. This feature is partly implemented for Windows hosts only. |
Transcript of Successful Compilation(Linux)
成功编译的案例示范输出(Linux)
user$ ls -l bochs-2.5.tar.gz
-rw-r--r-- 1 user users 4117999 27. Nov 17:14 bochs-2.5.tar.gz
user$ gunzip -c bochs-2.5.tar.gz | tar -xvf -
bochs-2.5/
bochs-2.5/.conf.sparc
bochs-2.5/build/
bochs-2.5/build/macosx/
bochs-2.5/build/macosx/pbdevelopment.plist
bochs-2.5/build/macosx/make-dmg.sh
.
.
.
bochs-2.5/memory/memory.cc
bochs-2.5/memory/misc_mem.cc
bochs-2.5/memory/Makefile.in
user$ cd bochs-2.5
user$ ./configure --enable-cpu-level=6
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
checking if you are configuring for another platform... no
checking for standard CFLAGS on this platform...
checking for gcc... gcc
.
.
.
config.status: creating build/win32/nsis/bochs.nsi
config.status: creating host/linux/pcidev/Makefile
config.status: creating config.h
config.status: creating ltdlconf.h
user$ make
cd iodev && \
make libiodev.a
make[1]: Entering directory `/home/volker/Archiv/test/bochs-2.5/iodev'
g++ -c -I.. -I./.. -I../instrument/stubs -I./../instrument/stubs -g -O2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES devices.cc -o devices.o
g++ -c -I.. -I./.. -I../instrument/stubs -I./../instrument/stubs -g -O2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES virt_timer.cc -o virt_timer.o
g++ -c -I.. -I./.. -I../instrument/stubs -I./../instrument/stubs -g -O2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES slowdown_timer.cc -o slowdown_timer.o
g++ -c -I.. -I./.. -I../instrument/stubs -I./../instrument/stubs -g -O2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES pic.cc -o pic.o
.
.
.
echo done
done
/bin/sh ./libtool --mode=link g++ -o bochs -g -O2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -DBX_SHARE_PATH='"/usr/local/share/bochs"' -export-dynamic logio.o main.o config.o load32bitOShack.o pc_system.o osdep.o plugin.o crc.o \
iodev/libiodev.a cpu/libcpu.a cpu/cpudb/libcpudb.a \
memory/libmemory.a gui/libgui.a \
disasm/libdisasm.a \
fpu/libfpu.a \
-lSM -lICE -lX11 -lXpm -lXrandr \
\
\
\
\
-lm
mkdir .libs
g++ -o bochs -g -O2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES -DBX_SHARE_PATH=\"/usr/local/share/bochs\" logio.o main.o config.o load32bitOShack.o pc_system.o osdep.o plugin.o crc.o -Wl,--export-dynamic iodev/libiodev.a cpu/libcpu.a cpu/cpudb/libcpudb.a memory/libmemory.a gui/libgui.a disasm/libdisasm.a fpu/libfpu.a -lSM -lICE -lX11 -lXpm -lXrandr -lm
gcc -c -I. -I./. -Iinstrument/stubs -I./instrument/stubs -g -O2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES ./misc/bximage.c -o misc/bximage.o
/bin/sh ./libtool --mode=link g++ -o bximage -g -O2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES misc/bximage.o
g++ -o bximage -g -O2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES misc/bximage.o
gcc -c -I. -I./. -Iinstrument/stubs -I./instrument/stubs -g -O2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES ./misc/bxcommit.c -o misc/bxcommit.o
/bin/sh ./libtool --mode=link g++ -o bxcommit -g -O2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES misc/bxcommit.o
g++ -o bxcommit -g -O2 -D_FILE_OFFSET_BITS=64 -D_LARGE_FILES misc/bxcommit.o
user$ su
root# make install
cd iodev && \
make libiodev.a
make[1]: Entering directory `/home/volker/Archiv/test/bochs-2.5/iodev'
.
.
.
for i in CHANGES COPYING README TODO; do if test -f $i; then install -m 644 $i /usr/local/share/doc/bochs; else install -m 644 ./$i /usr/local/share/doc/bochs; fi; done
rm -f /usr/local/share/doc/bochs/README
cat ./build/linux/README.linux-binary ./README > /usr/local/share/doc/bochs/README
install -m 644 ./.bochsrc /usr/local/share/doc/bochs/bochsrc-sample.txt
root# exit
user$ _
Compiling on Win32 with Microsoft VC++
在windows平台下用VC编译,比较复杂,需要在能运行configure脚本的环境下先进行相关处理。
The standard compile uses the configure script, but the Windows platform cannot run the configure script natively. The current solution to this problem is that the Bochs configure script must be run on a different platform that does support shell scripts, with options that cause it to configure for a Win32 platform instead of the native one. Many people have access to a UNIX machine that could run the configure script, or you can use Cygwin or MinGW/MSYS to run the configure script.
Download the Bochs sources on a machine that can run shell scripts. Edit the configure shortcut script .conf.win32-vcpp if you want to adjust the configure options. Then type these commands in the Bochs source directory:
sh .conf.win32-vcpp
make win32_snap
These commands will run the configure step, produce VC++ makefiles and workspace files, and pack it all into a .zip file in the directory above the source directory [4]. The .zip file is all ready to transfer to the target Windows machine to be unzipped and compiled. Or, if you run the sh/make steps in Cygwin, you are already on the target machine so you don't need the .zip file.
When you have the Win32 sources transferred to a Windows machine with VC++, find the workspace file called bochs.sln in the folder "vs2013" and load it in VC++. Choose Project:Set Active Project and be sure that "bochs" is selected. Then choose Build:Build bochs.exe. This will build all the required libraries (iodev, cpu, etc.) and the auxiliary programs bximage.exe, bxhub.exe and niclist.exe.
Using workspaces is easy and intuitive, but there is one caveat. The workspaces come directly out of a ZIP file in build/win32/vs2013ex-workspace.zip, and they are not controlled by the configure script. When you compile with certain configure options (e.g. --with-sdl) you need to link with additional libraries. For now you must add them to the VC++ workspace by hand. In version 2.0, we have improved the situation considerably by adding #if...#endif around every optional file and including nearly every Bochs source file in the workspace. This solves the problem of having to manually add source files to the workspace when you turn on configure options such as --enable-debugger. The problem of adding link libraries remains unresolved.
Tip: To compile with the Bochs debugger enabled, add --enable-debugger to the configure line in .conf.win32-vcpp before running it. No modifications to the workspace are necessary.
An alternative way to compile is to run nmake.exe in an MS-DOS window. Instead of using the workspace files, nmake uses the Bochs makefiles that are generated by configure. The nmake method is currently used to build the release binaries.
The make install doesn't work with nmake yet. Currently it must be run inside of Cygwin or MinGW/MSYS and requires the environment variable INSTDIR to be set.
Compiling on Win32 with Cygwin or MinGW/MSYS
Cygwin is a free Unix-like environment for Windows written by Steve Chamberlain and now maintained by RedHat, Inc. You can download it from www.cygwin.com. Because Cygwin supports the configure script and uses GNU gcc/g++, you can use the standard compile process. The configure script should automatically detect Cygwin and add "-mno-cygwin -DWIN32" to the compiler options. You should get a working Bochs if you just type:
configure
make
Optionally, you can use the configure shortcut script for Cygwin, .conf.win32-cygwin, instead of running configure directly. If this script is close to what you need, just edit the script and then run it. To use the configure shortcut script and compile in Cygwin, the commands are
sh .conf.win32-cygwin
make
To find out the options which are known to work in Cygwin, open the file .conf.win32-cygwin in any text editor/viewer and have a look at the end of that file.
When using gcc 4.7 or newer you need to add the switch -mno-ms-bitfields to the CFLAGS, to make sure that hdimage and network structures are packed as expected.
The command make install installs the Bochs files in the directory structure of your build environment. To install Bochs into any desired folder you need to use the install_win32 target. It requires the environment variable INSTDIR to be set.
其余还有Compiling on MacOS 9 with CodeWarrior、 MacOS X、Amiga/MorphOS等。
Compiling with the wxWidgets interface
编译wxWidgets interface
wxWidgets is a cross-platform C++ user interface library which you can download for free at wxwidgets.org. The wxWidgets port of Bochs provides both a graphical configuration interface for editing bochsrc options (see config_interface option) and a display (see display_library option). It was written by Bryce Denney, Don Becker, Dave Poirier, and Volker Ruppert.
configure --with-wx
make
If you want Bochs to use a wxWidgets installation not in your path (but installed somewhere else), you need to set the WX_CONFIG environment variable to the proper wx-config script, before running configure (example for csh):
setenv WX_CONFIG '/home/compile/wx/bin/wx-config'
编译当中的问题(Compile Problems)
configure阶段(The configure script failed)
The configure script can fail for various reasons. If the error message on the shell doesn't give enough information, it is recommended to review the output file config.log
to find out what exactly happened. The following issues can be fixed by modifying the configure options used:
如果configure阶段出现问题,并且没有足够的错误提示信息,可以查阅当前目录下的config.log文件。
deprecated option (option from previous Bochs version not needed / supported anymore)
去掉选项(一些不必须、不再被支持的老旧Bochs选项)mutually exclusive option (e.g. --enable-debugger and --enable-gdb-stub)
检查并去掉互斥的选项dependent option (e.g. USB support requires PCI support)
检查所有依赖选项(usb需要pci的支持)incomplete option (e.g. --enable-cpu-level requires an argument)
检查是否有不完整选项(--enable-cpu-level需要带参数)development package for library not installed (e.g. for --with-wx)
未安装库的开发包
(比如--with-wx)
If the configure issue cannot be fixed by option changes and / or installing development packages / tools it should be reported in the bochs-developers mailing list or the SF bug tracker for the Bochs project.
Make / compilation failure
In some cases it might be useful to rebuild Bochs completely by calling make dist-clean and running the configure script once again. These steps are recommended if the development sources from SVN are used and one of the build system files (e.g. Makefile or config.h.in) has been changed.
大多数时候解决make问题的方法是:
make dist-clean
./ configure --参数设置
Sometimes it is possible to isolate the failing piece of code by disabling one or more configure options. For example, if the compilation fails somewhere in the cpu/avx* files, it might help to configure without --enable-avx
. The same could be done with other Bochs facilities controlled by configure options.
有时可以通过禁用一个或多个配置选项来隔离失败的代码片段。例如,如果编译在cpu/avx*文件中的某个地方失败,则在不启用avx的情况下进行配置可能会有所帮助。其他由configure选项控制的Bochs设施也可以这样做。
Runtime issues with self-compiled Bochs
After a successful compilation the self-compiled Bochs can fail if at least one library is not installed properly. This can happen if the library consists of a development and a runtime package and the second one is missing. Another problem can appear on build environments like Cygwin and MinGW/MSYS. Applications built there are usually designed to be run inside of the environment. When starting them from the Windows shell, it may cause errors like "missing cygwin1.dll" or similar. In that case, the missing DLL must be copied from e.g. the Cygwin folder to the location of the compiled EXE file.
第5章节 启动配置( Setup)
These are the minimum requirements for running an OS inside of Bochs:
使用Bochs虚拟机运行操作系统的最小需求为:
◆ 1、the Bochs executable
Bochs程序
◆ 2、the BIOS image (usually called BIOS-bochs-latest)
BIOS映像文件
◆ 3、the VGA BIOS image (e.g. VGABIOS-lgpl-latest or VGABIOS-elpin-2.40)
VBA BIOS映像文件
◆ 4、at least one bootable media, either as disk image (floppy, hard disk or CD-ROM) or physical disk (floppy or CD-ROM)
至少1个可引导启动的介质映像文件(软驱、硬盘、光驱等)或者物理介质。
The easiest way to setup Bochs for the first time is to use the example configuration file called bochsrc-sample.txt.Locate that file (location depends on the (host) OS and on the installation facility used) and copy it to a location where Bochs looks for that file
Bochs编译安装完成后,最简单的启动方式就是使用bochsrc-sample.txt文件。找到这个文件,并复制到Bochs需要它出现的位置即可(但是还要进行相关的设置)。
root@pop-os:/# whereis bochsrc-sample.txt
bochsrc-sample: /usr/local/bin/bochsrc-sample.txt
If your keyboard output inside of Bochs is wrong, you may also need a keymap file to remap your keyboard layout to the U.S. layout. A set of keymap files for the X window system and SDL (Linux port) is distributed with Bochs. If your keyboard layout is not supported yet, you can create your own one by following the instructions given in Section 4.4.
如果Bochs内键盘的输出有问题,还需要设置keymap。
A collection of disk images of different operating systems can be found at http://bochs.sourceforge.net/diskimages.html. Some disk images are the size of a floppy disk (1 meg compressed) and others are gigantic (160 meg compressed). If you want to create a disk image yourself, please see Section 8.2.
-
5-2 启动配置( Setup)—ROM images
Just like a real PC, Bochs needs a system BIOS and VGA BIOS to initialize the machine when it powers on or after a hardware reset. Bochs needs to load them from image file into the emulated memory. The Bochs package contains a set of system BIOS and VGA BIOS images.
System and VGA BIOS images
| File | Description |
| -------------------------------- | ------------------------------------------------------------ |
| BIOS-bochs-latest | default ROM BIOS image for Bochs |
| BIOS-bochs-legacy | ROM BIOS image without 32-bit init code (for i386 and ISA graphics card emulation) |
| bios.bin-1.7.5 | SeaBIOS ROM image |
| VGABIOS-elpin-2.40 | legacy VGA BIOS image for Bochs |
| VGABIOS-lgpl-latest | LGPL'd VGA BIOS image for Bochs |
| VGABIOS-lgpl-latest-debug | LGPL'd VGA BIOS image for Bochs with debug output to the logfile |
| VGABIOS-lgpl-latest-cirrus | LGPL'd VGA BIOS image for Bochs with the Cirrus extension enabled |
| VGABIOS-lgpl-latest-cirrus-debug | LGPL'd VGA BIOS image for Bochs with the Cirrus extension enabled and debug output to the logfile |
Bochs must be set up to use system and VGA BIOS like this:
romimage: file=BIOS-bochs-latest, address=0xe0000
vgaromimage: file=VGABIOS-lgpl-latest
We recommend to use the ROM images distributed with Bochs or one of the latest SeaBIOS images. BIOS images designed for real hardware mostly do not work properly.
真正为硬件设计的BIOS不能在Bochs中运行。
Bochs supports optional ROM images to be loaded into the ISA ROM space, typically between C8000 and EFFFF (see Section 4.3.10). The PCI versions of the Bochs network adapter emulation support loading a boot ROM into the PCI ROM space (see Section 4.3.34).
-
5-3 启动配置( Setup)— The configuration file “bochsrc(或者是bochsrc-sample.txt)”
Bochs uses a configuration file called “bochsrc” to know where to look for disk images, how the Bochs emulation layer should work, etc. When you first start up Bochs, it looks around for its configuration file (see Section 5.2), and parses it. Here are a few lines from a sample file:
Bochs使用一个叫做“bochsrc”的配置文件来对运行环境的各项参数进行设定。下面是文件中的部分设置代码:
ata0-master: type=disk, path="30M.sample", cylinders=615, heads=6, spt=17
boot: disk
The format is very strict, so be sure to put the right number of spaces and use lowercase letters. As you can see, most lines have a keyword telling what is being configured, followed by a colon, followed by a few property=value pairs, separated by commas. For very simple options, sometimes just a single value is needed. The source and binary distributions come with a sample bochsrc, so you can just copy the sample file and edit the settings you need to change.
代码设置格式非常严格,空格的数目不能错,字母大小写也要严格遵守规定。
我们剔除配置文件中的注释,看看关键的部分:
cpu: model=pentium, count=1, ips=50000000, reset_on_triple_fault=1, ignore_bad_msrs=1, msrs="msrs.def"
cpu: cpuid_limit_winnt=0
memory: guest=512, host=256
romimage: file=$BXSHARE/BIOS-bochs-latest, options=fastboot
vgaromimage: file=$BXSHARE/VGABIOS-lgpl-latest
mouse: enabled=0
pci: enabled=1, chipset=i440fx
private_colormap: enabled=0
floppya: 1_44=/dev/fd0, status=inserted
ata0: enabled=1, ioaddr1=0x1f0, ioaddr2=0x3f0, irq=14
ata1: enabled=1, ioaddr1=0x170, ioaddr2=0x370, irq=15
ata2: enabled=0, ioaddr1=0x1e8, ioaddr2=0x3e0, irq=11
ata3: enabled=0, ioaddr1=0x168, ioaddr2=0x360, irq=9
ata0-master: type=disk, mode=flat, path="30M.sample"
boot: disk
floppy_bootsig_check: disabled=0
log: bochsout.txt
panic: action=ask
error: action=report
info: action=report
debug: action=ignore, pci=report # report BX_DEBUG from module 'pci'
debugger_log: -
parport1: enabled=1, file="parport.out"
speaker: enabled=1, mode=sound
-
3-1 类的初步—定义一个类并创建对象实例
3-1-1. 导言—用户管理—用户的分类及介绍
-
3-2 类的初步—定义一个类并创建对象实例
3-2-1. 导言—用户管理—用户的分类及介绍
第3章节
-
3-1 类的初步—定义一个类并创建对象实例
3-1-1. 导言—用户管理—用户的分类及介绍
-
3-2 类的初步—定义一个类并创建对象实例
3-2-1. 导言—用户管理—用户的分类及介绍