Learning minix with bochs-creating a test environment

Source: Internet
Author: User
Operating system design and implementation (version 2) is an excellent teaching material for studying the Operating System. This book is based on the minix operating system as an example, so we need a test environment that can run Minix. you can install it directly in a partition of the PC, but here I recommend using bochs.

Bochs is an open source software used to simulate the PC, can be obtained from the http://bochs.sourceforge.net, the latest version is 2.3.5. The difference between bochs and other x86 Virtual Machine software is to explain the execution of commands, so it can provide a good debugging function, which provides great convenience for us to learn the underlying software such as the operating system.

First download the bochs Windows Installer and I installed it to D:/minix/Bochs-2.3.5. The bochs official website also has an assembled mini-xhard drive image downloaded with the file name minix204.zip. After the download, decompress it to the installation directory of bochs, and then modify run. bat under the directory of minix204 to the following format:

CD & quot; D:/minix/Bochs-2.3.5/minix204 & quot"

../Bochs-Q-F Minix. bxrc

However, after I click to run this batch file, only a bunch of error messages are displayed in the command line window. The configuration file that comes with this minix image is too old, it is somewhat incompatible with the new bochs, so you must modify the configuration script first. There are detailed instructions under the doc directory under the installation directory. You need to modify the configuration script as follows:

Change "romimage: file = $ bxshare/BIOS-bochs-Latest, address = 0xf0000" to "romimage: file = $ bxshare/BIOS-bochs-Legacy, address = 0xf0000"

Change "vgaromimage: $ bxshare/VGABIOS-elpin-2.40" to "vgaromimage: file = $ bxshare/VGABIOS-elpin-2.40"

Change "IPs: 1000000" to "CPU: Count = 1, IPS = 1000000"

After completing the preceding modification, you can run it again and enter Minix. The minix source code is stored in the/usr/src directory of the virtual system. You can use the built-in compiler to compile the operating system code, in this way, the compilation and debugging environment of minix is formed.

 

Now let's talk about the bochs debugging process. We can create a rundbg first. BAT, and then run. copy the content in BAT and copy ".. /bochs-Q-F Minix. change bxrc to ".. /bochsdbg-Q-F Minix. bxrc ". When rundbg. bat is enabled, the following content is displayed at the end of the pop-up command line window:

(0) [0xfffffff0] f000: fff0 (unk. ctxt): JMP f000: e05b; ea5be000f0

<Bochs: 1>

The first line indicates that at this time the CPU instruction pointer stays at 0xffff0 (real address mode), this is the address of the BIOS-ROM, the machine will start to run from here.

The second line is the debugging command input line. The bochs debugging command is very similar to GDB. You can use break to set breakpoints, use the S command to run in one step, and use P to print variable values. You can enter the HELP command to list the Debugging commands. If you want to use a specific command, just enter "HELP command name. Because the BIOS copies the Boot Code of the boot device to 0x7c00, set the breakpoint first:

<Bochs: 1> VB 0x0000: 0x7c00

Next, run to the breakpoint:

<Bochs: 2> C

Bochs stops running at 0x7c00. At this time, you can see that the virtual machine window will display some information about the video card and hard disk, which is the output after the BIOS runs the self-check. After that, run the minix boot code, which is located in the src/boot directory.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.