You've successfully subscribed to The Daily Awesome
Great! Next, complete checkout for full access to The Daily Awesome
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.
Success! Your billing info is updated.
Billing info update failed.

MIT6.828 | Lab 1: Booting a PC

. 4 min read

Introduction

引导PC的lab分为3部分:

  1. 熟悉x86的汇编语言,QWMU x86 模拟器,PC的开机引导程序
  2. 测试 6.828 的内核引导加载程序 (boot loader)/boot/loader/
  3. 深入研究6.828内核的初始模板 JOS /kernel

软件环境

Git

To learn more about Git, take a look at the Git user's manual.

Already familiar with other version control systems, you may find this CS-oriented overview of Git useful.

The URL for the course Git repository is https://pdos.csail.mit.edu/6.828/2018/jos.git.

gcc

QEMU 环境配置

you'll need to install qemu and possibly gcc following the directions on the tools page.

Clone the IAP 6.828 QEMU git repository git clone https://github.com/mit-pdos/6.828-qemu.git qemu

On Linux, you may need to install several libraries. We have successfully built 6.828 QEMU on Debian/Ubuntu 16.04 after installing the following packages: libsdl1.2-dev, libtool-bin, libglib2.0-dev, libz-dev, and libpixman-1-dev.

sudo apt-get install libsdl1.2-dev libtool-bin libglib2.0-dev libz-dev and libpixman-1-dev

Configure the source code (optional arguments are shown in square brackets; replace PFX with a path of your choice)

  1. Linux: ./configure --disable-kvm --disable-werror [--prefix=PFX] [--target-list="i386-softmmu x86_64-softmmu"]
  2. OS X: ./configure --disable-kvm --disable-werror --disable-sdl [--prefix=PFX] [--target-list="i386-softmmu x86_64-softmmu"] The prefix argument specifies where to install QEMU; without it QEMU will install to /usr/local by default. The target-list argument simply slims down the architectures QEMU will build support for.

Run make && make install

libtool --quiet --mode=install install -c -m 0755 qemu-system-x86_64  "/usr/local/bin" 
strip "/usr/local/bin/qemu-system-x86_64" 
MIT6.828 | Lab 1: Booting a PC - Part 1: PC Bootstrap
了解 x86 汇编语言 和 PC 开机引导(bootstrap)过程 QWMU x86 模拟器 started with QEMU and QEMU/GDB debugging 1. Getting Started with x86 assembly汇编语言手册:The PC Assembly Language Book[https://pdos.csail.mit.edu/6.828/2018/readings/pcasm-book.pdf] We do recommend reading the section “The Syntax” in Brennan’s Guide to…
MIT6.828 | Lab 1: Booting a PC - Part 2: The Boot Loader
软盘和硬盘用于PC的软盘和硬盘分为512个字节区域,称为扇区。 扇区是磁盘的最小传输粒度:每个读取或写入操作必须是一个或多个扇区,并在扇区边界上对齐。如果磁盘是可引导的,则第一个扇区称为引导扇区,因为这是引导加载程序代码所在的位置。当BIOS找到可引导的软盘或硬盘时,它将512字节的引导扇区加载到物理地址0x7c00到0x7dff的内存中,然后使用jmp指令将CS:IP设置为0000:7c00,将控制权传递给引导装载机。 与BIOS加载地址一样,这些地址相当随意 - 但它们是针对PC修复和标准化的。 The ability to boot from a CD-ROM came much…
MIT6.828 | Lab 1: Booting a PC - Part 3: The Kernel
开始详细了解最小的JOS内核。与 boot loader 类似,内核也从汇编语言开始,从而使C语言代码能够执行。 1. 虚拟内存解决位置依赖问题 - Using virtual memory to work around position dependence在 Part2 中可以发现内存的加载地址LMA和链接地址VMA差别非常大: [post cid=“535” /] obj/kern/kernel: file format elf32-i386 Sections:Idx Name Size VMA LMA File …