Run bochs under windows

Brief introduction: Bochs is mainly a free and open source PC emulator based on x86 architecture. Learning the linux0.11 kernel is recommended to be carried out on this simulator.

  • Environment setup steps:

1. Download the Linux0.11 system package. The download package of this link already contains the Bochs software.

Click to open the link http://oldlinux.org/Linux.old/bochs/linux-0.11-devel-040329.zip
2. Unzip linux-0.11-devel-040329.zip, the directory structure is as shown below:

 

 

The files actually used here are: Bochs-2.1.1.exe, bochsrc-hd.bxrc, bootimage-0.11, bootimage-0.11-hd, hdc-0.11.img

3. Click Bochs-2.1.1.exe to install.

4. After the installation is complete, copy all the files under linux-0.11-devel-040329 to the root directory under the bochs just installed. The original directory is as follows:

After copying, the directory is:

 

 

5. After the copy is completed, run bochsrc-hd.bxrc, if the installation is successful, you can see the following interface after opening:

 

 

This is already a Linux operating system built on the x86PC simulator. Establish Linux operating platform commands to operate Linux. Due to the need to learn the operating system, we need to compile the operating system and complete simple source code modifications under Linux to achieve the ability to understand the Linux kernel. Next, we mainly demonstrate the modification of Linux kernel source code and the process of kernel compilation. Due to the Linux version, we still need to make adjustments to the code to be able to compile successfully.

 

  • Kernel compilation process:

 

1. Enter the /usr/src/linux directory and type the command cd ../src/linux, as shown in the figure below:

 

 

2. To compile, type the commands make clean and make.

 

 

If an error like the following appears: gcc-cc1: Invalid option "string-insns". This is to remove the -mstring-insns parameter in the Makefile under the Linux directory. In addition, the -mstring-insns parameter in Makefike in each subdirectory fs, lib, kernel and three driver subdirectories (math, blk_drv, chr_drv) under the kernel directory is removed. Here only demonstrate the modification of the Makefile file in the root directory.

3, Yoji renovation: / linux / Makefile, / linux / fs / Makefile, / linux / lib / Makefile,

/linux/kernel/Makefile, /linux/kernel/math/Makefile, /linux/kernel/blk_drv/Makefile, /linux/kernel/chr_drv/Makefile. In the linux directory, type: vi Makefile. As shown below:

 

 

Find the -mstring-insns parameter in the file and delete it and save it.

4. Find the file ar in /usr/local/bin, and rename ar to gar, and type the command: mv ar gar. As shown below:

 

 

5. Go back to the linux directory and retype make clean and make to complete the kernel compilation link.

 

 

The above prompt appears, that is, the surface program is compiled successfully. After compiling, you can start to modify the kernel source code, so as to achieve the purpose of extending the function of the operating system and learning the operating system. Here, we simply modify the source code of the boot item bootsect.s for the Linux operating system to output a personalized string after booting.

6. Enter the /usr/src/linux/boot directory, modify the bootsect.s source code, save and exit.

 

! Print some inane message
mov    ah,#0x03        ! read cursor pos
xor    bh,bh
int    0x10
mov    cx,#47
mov    bx,#0x0007        ! page 0, attribute 7 (normal)
mov    bp,#msg1
mov    ax,#0x1301        ! write string, move cursor
int    0x10
msg1:
.byte 13,10
.ascii "Loading system ...this is create by demon"
.byte 13,10,13,10
.org 508

 

7. After the modification is completed, in the linux directory, retype the make command to complete the compilation.

8. Generate boot image file Image after make is successful. If you need to output this Image file, you can first back up the bootimage-0.11-hd file, and then use the following command to replace bootimage-0.11-hd with the new boot file, type the command: dd bs=8192 if=Image of=/ dev/fd0. As shown below:

9 Click reset to restart the Linux operating system. As shown below:

 

Guess you like

Origin blog.csdn.net/wyyy2088511/article/details/111351584