MIT6.828 Lab1 part 1th: PC Bootstrap

Source: Internet
Author: User
Tags reserved git clone
Software Setup

In this experiment, we will run the XV6 operating system in the emulator QEMU.
QEMU can be obtained from GitHub, or using a modified QEMU source (toolchain) from MIT

git clone https://github.com/geofft/qemu.git-b 6.828-1.7.0
for./configure  (as long as i386 and x86_64 platforms are available)  
. Configure--DISABLE-KVM--target-list= "I386-softmmu X86_64-softmmu"
then compile and install make && make install

Get XV6 Source code (the full version is hosted on GitHub, not the experimental version)

git clone https://pdos.csail.mit.edu/6.828/2014/jos.git   Lab
then compiles, runs make && make QEMU using QEMU emulation

Exercise 1:
Exercise 1 does not have any substantive content, that is, MIT suggested that we have a general understanding of assembly language, so as to make the latter study more convenient. Physical address space of the PC

The 1th generation PC is based on a 16-bit Intel8088 processor and can only address 1Mb of physical memory. Therefore, the physical address space of the previous PC begins with 0x00000000 ending at 0x0000ffff instead of 0xFFFFFFFF. A 640kb space labeled "Low Memory" can only be used for random access (RAM).

384Kb space from 0x000a0000 onwards to 0X000FFFFF is reserved for hardware addressing such as VGA. The most important part of the 1MB reserved space is the BIOS, which occupies 64Kb space from 0x000f0000 to 0X000FFFFF. The BIOS primarily carries out hardware checks and initialization operations, and finally loads the operating system from the hard disk or CD-ROM and transfers control.

Exercise 2:
Using GdB's ' si ' command, go to the ROM BIOS to track a few instructions and try to guess what it is doing. But there's no need to figure out every detail.
It is mainly a series of operations such as hardware check during BIOS boot.
In the window that runs GDB, the first command to run the BIOS after the PC starts is displayed, as follows:
0XFFFF0:LJMP $0xf000, $0xe05b
This is the first instruction to run, is a jump instruction, jumps to the 0xfe05b address. To know how this address is calculated by the value in the instruction, we need to know that when the PC starts, the CPU runs under real mode, and when it enters the operating system kernel, it will run in protected mode (Protected mode). Real mode is the early CPU, such as the operating mode of the 8088 processor, such processors because there are only 20 address lines, so they can only access 1MB of memory space. But the CPU is also constantly evolving, after the 80286/80386 has 32-bit address bus, access to 4GB of memory space, in order to be able to manage such a large amount of memory space, protection mode was developed. So modern processors are working in protected mode. For backwards compatibility, however, the software that originally ran on a 8088 processor still runs on a modern processor, so modern CPUs run in real mode at startup and run in protected mode when the boot is complete. The BIOS is the software that runs when the PC just starts, so it must work in real mode.

As for the operating principle of these two modes, you can see this link: http://blog.csdn.net/zdwzzu2006/article/details/4030948

Here is a brief introduction to the calculation method of the address, in real mode, the address in the instruction is used

(segment base: offset within paragraph)

In the form of. The values of these two fields are usually stored in registers. The segment base must be placed in the segment register, including CS (code snippet), DS (data segment), SS (stack segment), ES (extension segment). Different segment registers hold the starting address of a different segment of your program.

But since the register in 8088CPU is 16 bits, and CPU address bus is 20 bits, how can we use 16-bit registers to splice 20-bit address?

So we need to use the following method: To move the value of the segment register to the left 4 bits, to form a 20-bit segment base, and then add to the 16-bit segment offset, the real address is obtained. For example, the contents of the middle register of the above instruction is 0xf000, so the real address is 0xf0000<<4+0xe05b = 0xfe05b.
  
  

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.