logo资料库

怎样设计一个操作系统.pdf

第1页 / 共36页
第2页 / 共36页
第3页 / 共36页
第4页 / 共36页
第5页 / 共36页
第6页 / 共36页
第7页 / 共36页
第8页 / 共36页
资料共36页,剩余部分请下载后查看
Introduction
Introduction about the x86 architecture and about our OS
Setup the development environment
First boot with GRUB
Backbone of the OS and C++ runtime
Base classes for managing x86 architecture
GDT
IDT and interrupts
Theory: physical and virtual memory
Memory management: physical and virtual
Table of Contents Introduction Introduction about the x86 architecture and about our OS Setup the development environment First boot with GRUB Backbone of the OS and C++ runtime Base classes for managing x86 architecture GDT IDT and interrupts Theory: physical and virtual memory Memory management: physical and virtual Process management and multitasking External program execution: ELF files Userland and syscalls Modular drivers Some basics modules: console, keyboard IDE Hard disks DOS Partitions EXT2 read-only filesystems Standard C library (libC) UNIX basic tools: sh, cat Lua interpreter 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.8 1.9 1.10 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.18 1.19 1.20 1.21 2
Introduction How to Make a Computer Operating System Online book about how to write a computer operating system in C/C++ from scratch. Caution: This repository is a remake of my old course. It was written several years ago as one of my first projects when I was in High School, I'm still refactoring some parts. The original course was in French and I'm not an English native. I'm going to continue and improve this course in my free-time. Book: An online version is available at http://samypesse.gitbooks.io/how-to-create-an- operating-system/ (PDF, Mobi and ePub). It was generated using GitBook. Source Code: All the system source code will be stored in the src directory. Each step will contain links to the different related files. Contributions: This course is open to contributions, feel free to signal errors with issues or directly correct the errors with pull-requests. Questions: Feel free to ask any questions by adding issues or commenting sections. You can follow me on Twitter @SamyPesse or GitHub. What kind of OS are we building? The goal is to build a very simple UNIX-based operating system in C++, not just a "proof-of- concept". The OS should be able to boot, start a userland shell, and be extensible. 3
Introduction 4
Introduction about the x86 architecture and about our OS Chapter 1: Introduction to the x86 architecture and about our OS What is the x86 architecture? The term x86 denotes a family of backward compatible instruction set architectures based on the Intel 8086 CPU. The x86 architecture is the most common instruction set architecture since its introduction in 1981 for the IBM PC. A large amount of software, including operating systems (OS's) such as DOS, Windows, Linux, BSD, Solaris and Mac OS X, function with x86-based hardware. In this course we are not going to design an operating system for the x86-64 architecture but for x86-32, thanks to backward compatibility, our OS will be compatible with our newer PCs (but take caution if you want to test it on your real machine). Our Operating System The goal is to build a very simple UNIX-based operating system in C++, but the goal is not to just build a "proof-of-concept". The OS should be able to boot, start a userland shell and be extensible. The OS will be built for the x86 architecture, running on 32 bits, and compatible with IBM PCs. Specifications: Code in C++ x86, 32 bit architecture Boot with Grub Kind of modular system for drivers Kind of UNIX style Multitasking ELF executable in userland Modules (accessible in userland using /dev/...) : IDE disks DOS partitions Clock EXT2 (read only) Boch VBE Userland : 5
Introduction about the x86 architecture and about our OS API Posix LibC "Can" run a shell or some executables (e.g., lua) 6
Setup the development environment Chapter 2: Setup the development environment The first step is to setup a good and viable development environment. Using Vagrant and Virtualbox, you'll be able to compile and test your OS from all the OSs (Linux, Windows or Mac). Install Vagrant Vagrant is free and open-source software for creating and configuring virtual development environments. It can be considered a wrapper around VirtualBox. Vagrant will help us create a clean virtual development environment on whatever system you are using. The first step is to download and install Vagrant for your system at http://www.vagrantup.com/. Install Virtualbox Oracle VM VirtualBox is a virtualization software package for x86 and AMD64/Intel64- based computers. Vagrant needs Virtualbox to work, Download and install for your system at https://www.virtualbox.org/wiki/Downloads. Start and test your development environment Once Vagrant and Virtualbox are installed, you need to download the ubuntu lucid32 image for Vagrant: vagrant box add lucid32 http://files.vagrantup.com/lucid32.box Once the lucid32 image is ready, we need to define our development environment using a Vagrantfile, create a file named Vagrantfile. This file defines what prerequisites our environment needs: nasm, make, build-essential, grub and qemu. Start your box using: vagrant up You can now access your box by using ssh to connect to the virtual box using: 7
Setup the development environment vagrant ssh The directory containing the Vagrantfile will be mounted by default in the /vagrant directory of the guest VM (in this case, Ubuntu Lucid32): cd /vagrant Build and test our operating system The file Makefile defines some basics rules for building the kernel, the user libc and some userland programs. Build: make all Test our operating system with qemu: make run The documentation for qemu is available at QEMU Emulator Documentation. You can exit the emulator using: Ctrl-a. 8
分享到:
收藏