Environment configuration of an operating system

Source: Internet
Author: User

When I recently visited the forum, I found that some netizens were discussing a book about the implementation of an operating system. The author of this book was Yu Yuan, who looked at his book and admired it very much. When I started to learn about the operating system, I had been searching for a book on highly practical operating systems, but I had not found a good book around the library, most of which were theoretical, what is process and memory management .... This makes a person who is new to the operating system feel like a castle in the air. I just went back without reading a few pages.

Different from this book, he gave me the feeling that I could implement an operating system on my own, making me feel that the operating system is at your fingertips. I agree with what I have said. I have introduced excellent foreign theoretical knowledge in China, emphasizing my profound understanding of the theory and finally presenting it in the form of scores. Foreign countries summarize incisive theories through continuous practice, so that future generations can grasp the practice process more systematically.

The first chapter of this book tells you how to write a program that is directly called by the BIOS for execution, that is, the bare metal running program. Do you think of a single chip microcomputer, however, this is much more interesting than single-chip microcomputer. Through this book, you can learn a lot of knowledge. You can associate many things you have learned or touched with and learn more about them. First of all, let's talk about the process of installing the operating system. I believe everyone has done it. It's just a matter of inserting a CD and clicking twice. This is its surface, are you familiar with this process? When the power is turned on, some self-check programs are executed, and the CPU control is in the BIOS. At this time, the CPU is no different from the single-chip microcomputer. Before installing the operating system, we must first set the bios so that it can be started from the disc, which is to tell the BIOS to read the program in the disc. Here, I would like to mention that we know that the memory is composed of Ram and Rom during class, and you should understand that Rom is used to put BIOS programs. What is the process of BIOS reading the CD? The BIOS detects the No. 0 sector of the floppy disk, which stores a boot. Here we will talk about the structure of the floppy disk. We may not have seen the floppy disk because it has been eliminated, I replaced it with a CD. In fact, this era is almost a USB flash drive. I was lucky to have seen my cousin use a floppy disk when I was in elementary school .. The principle is the same.
Now, I think you should have heard about the structure of these things, but you have not noticed that you are familiar with the terms such as head, track, and sector. Flip the book, and the sector is 512 bytes. Boot format: the code and the end mark of 0xaa55. In the code, the content of the floppy disk is loaded into the memory. Obviously, what you need to know is BIOS interruption and how to read disk content. When talking about programming, you must involve the language. The compilation you have learned can be used. Let's talk so much about it. paste some code for everyone ..

% Ifdef _ debug _
Org 0100 H
% Else
Org 07c00h
% Endif
MoV ax, CS
MoV ds, ax
MoV es, ax
Call dispstr
JMP $
Dispstr:
MoV ax, bootmessage
MoV bp, ax
MoV CX, 16
MoV ax, 01301 H
MoV BX, 000ch
MoV DL, 0
Int 10 h
RET
Bootmessage: DB "Hello, OS world! "
Times 510-($-$) db 0

DW 0xaa55

The first sample code in this book, which has not been carefully compiled, can be carefully reviewed. Now many people may learn advanced languages, such as C, C ++, and Java, but I still like some original things. I forgot the term. The above is the guiding sector. Remember this word and pay attention to it later. It is not easy to run this program. The virtual machine bochs, virtual floppy disk, and software for writing floppy disks are what I am doing today to build an operating system development environment.

The environment recommended by the author here is Linux. I have always supported windows. At most, when necessary, open the Virtual Machine and run red hat for necessary development, but later I found that the only thing I did in Windows was hanging on QQ. Most of the time I went to the virtual machine, but I found that searching for information and watching movies was still in windows, the problem is that you have to find the information and upload it to the virtual machine. This way, you can't bear to switch the environment constantly. So we started to abandon windows and enter the dual system era. It was very convenient to install ubuntu. It took several days, it feels great. The installation is also very convenient. There is an installation package in windows, and there will be dual systems after installation. Haha, it's really good.

The editor is required to write code. In Windows, either the integrated development environment or the Si is used. In ubuntu, I accept the author's suggestion and try Emacs, so the compiler will not need to talk about it, everyone in GCC understands that there is also an assembly compiler NASM, which is now learning from the author's experience, so try to use the recommended compiler. After learning it, choose according to your preferences. Finally, it is important to debug the bochs of our operating system. It is a little troublesome to install it. The last simulator was installed for a long time.

1. sudo apt-Get install Emacs

2. For sudo apt-Get install build-essential NASM, you must remember to install build-essential. Otherwise, you will not be able to install bochs if the components are missing.

3. Install bochs. I went to the official website to download the source code,

Decompress the package and enter the directory./configure -- enable-debugger -- enable-disasm, which should be understood by everyone.

However, the process may be tortuous. Many errors may occur when you execute this command. You are always prompted that the file package is missing. At this time, you have to install these packages one by one,

It is nothing more than using the command: sudo apt-Get install *****

Then make, I have been entangled for a long time in the appeal process. However, it is a bit of patience to solve Baidu errors one by one.

The last step is make install .. there will be no problem here. Wait until the installation is complete.

The software is almost installed. Let's make a floppy disk. There is a tool bximage in bochs to generate a floppy disk image.

Run the command: dd If = boot. bin of = A. img bs = 512 COUNT = 1 Conv = notrunc

Write a file to the floppy disk to get a boot floppy disk and run it immediately.

# How much memory the emulated machine will have
Megs: 32

# Filename of ROM images
Romimage: file =/usr/share/bochs/BIOS-bochs-Latest
Vgaromimage: file =/usr/share/vgabios. Bin

# What disk images will be used
Floppya: Running 44 = Xing. IMG, status = inserted

# Choose the boot disk.
Boot: floppy

# Where do we send log messages?
Log: bochsout.txt

# Disable the mouse
Mouse: enabled = 0

# Enable key mapping, using us layout as default.
Keyboard_mapping: enabled = 1, map =/usr/share/bochs/keymaps/x11-pc-us.map

Bochs runs through this configuration file... Run .. Happy !!!

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.