Giter Site home page Giter Site logo

samypesse / how-to-make-a-computer-operating-system Goto Github PK

View Code? Open in Web Editor NEW
21.0K 1.6K 3.4K 5.85 MB

How to Make a Computer Operating System in C++

Home Page: https://samypesse.gitbook.io/how-to-create-an-operating-system

License: Apache License 2.0

Makefile 1.38% Ruby 0.69% C++ 20.44% C 74.50% Assembly 2.92% Shell 0.07%

how-to-make-a-computer-operating-system's 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.

Screen

how-to-make-a-computer-operating-system's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

how-to-make-a-computer-operating-system's Issues

Vagrant has erased the root directory and left postinstall.sh

I managed to get the qemu emulator going but couldn't exit it, so I had to quit Terminal (on my mac) and now whenever I open up my vagrant box, all that is in the root folder is a file called "postinstall.sh" I have tried destroying the box, recreating it, removing it and re-downloading lucid32 et.c but the files that I think come with lucid32 (boot, tmp etc) don't appear!

No code in vagrant directory in virtualbox

I managed to get to the "cd /vagrant" step of chapter two but I run into the problem that there is no code there as the tutorial says there should be, therefore I can't run the make commands.

What could be the problem?
When running all commands from the terminal, I am situated in the VagrantOS directory that I made on my hard drive.
I am using Mac OS X 10.9.4 and am using the latest versions of virtual box and vagrant

Chapter 2: "make run" fails

make run fails at chapter 2.

make all completed successfully and when I run make run it fails with the following message:

: command not founde 35:
: No such file or directorydev/loop1
make: *** [run] Error 1

Could you help?

qemu command is not now available to Ubuntu 14.04 LTS

Hey there! I just found some errors, The qemu command is not now qemu it has some many parts now like qemu-system-i386 and stuff.. I changed it to kvm to some users has activated kvm to their PC's but it is not working..

question

hello,I am so interested in your project,and I put it run in my virtual machine,but when "make run",it stops in the "Booting from Hard Disk ",I don't know why.

What does 4ko mean?

In Chapter-8 I read this:

The translation of a linear address to a physical address is done in multiple steps:

The processor use the registry CR3 to know the physical address of the pages directory.
The first 10 bits of the linear address represent an offset (between 0 and 1023), pointing to an entry in the pages directory. This entry contains the physical address of a pages table.
the next 10 bits of the linear address represent an offset, pointing to an entry in the pages table. This entry is pointing to a 4ko page.
The last 12 bits of the linear address represent an offset (between 0 and 4095), which indicates the position in the 4ko page.

Should 4ko be 4kb ๏ผŸ

Chapter 3 - bootdisk/* no such file or directory

I've got to chapter 3 and am trying to run the cp -R bootdisk/* /mnt/ command from inside /vagrant (I have also tried running it from the root directory) but it keeps telling me that the directory doesn't exist.

Running devOS without VM

It works fine without Vagrant, except for this one error:

grub> setup (hda0)
Error 17: Cannot mount selected partition

make all Failure on Debian 8.X

I did make all on the latest release and this happened.

I checked to make sure everything was setup properly and this still happened. Any ideas why? I have none.

Update: Tried it on Ubuntu, still had errors.

A little User Interface

Hey,

I love this repository because my great dream is to write an own tiny Operating system.My question to you is: Can you make a Chapter how to write a tiny little User Interface ? Your Tutorial is awesome thanks for this :)

Regards,
Jan

Close QEMU

Hello there,

I could run make all and make run successfully and I got the GRUB screen, I loaded both options and the SO was loaded correctly, but then, how can I go back to the vagrant console?

I am using Windows 7 as a host.

Thank you.

putc() method problem

In putc() method, line 3

video = (unsigned char *) (real_screen+ 2 * x + 160 * y);

I think should be

video = (unsigned char *) (real_screen+ 2 * x + 160 * (y - 1));

What happened to chapters 9-19?

Dear @SamyPesse,

what happened to chapters 9-19? They used to be in the readme now there is no even indication about them. Please finish the book, this is very good work.

Chapter 9: Process management and multitasking

Chapter 10: External program execution: ELF files

Chapter 11: Userland and syscalls

Chapter 12: Modular drivers

Chapter 13: Some basics modules: console, keyboard

Chapter 14: IDE Hard disks

Chapter 15: DOS Partitions

Chapter 16: EXT2 read-only filesystems

Chapter 17: Standard C library (libC)

Chapter 18: UNIX basic tools: sh, cat

Chapter 19: Lua interpreter

Chapter 2 spelling and how to exit qemu?

Chapter 2 says You can exit the emulator using: <Ctrl-a x>. but the thing inside <> is not rendered because it is not escaped and looks like HTML tag to the markdown renderer so you need to view the raw text to see it otherwise it shows as You can exit the emulator using: ..

Also, what exactly do I need to press to exit qemu? I run the make run command via PuTTY in Windows and it loads fine but I am not able to stop it. I tried pressing Ctrl+A and then X or Ctrl+X and also Ctrl+A+X but it didn't work. What is this combo supposed to mean?

unexplained files, independent src directories for each chapter

I'm currently trying to write my own basic os by [loosely] following this guide and other sources. One issue I repeatedly experience while using this repo is the files and directories in src that haven't been introduced in any of the readme files. I understand what they do, they just don't feel like they belong - yet. I understand that this is a work in progress, but it feels that these extraneous files don't belong in the master branch until they have been explained.

Since the chapters make it feel like the OS is being built incrementally, IMO, it makes more sense if each chapter had its own src directory that only contained the files that have been introduced up to that point.

wow

This is tight....

Typo

Mis-calculation of the number of cytes for the loop-device partition in Chapter 3. PR coming.

qemu installation problem under lucid 32

on doing "sudo apt-get install qemu-kvm", i get the following error :-
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

possibly due to :-
Err http://us.archive.ubuntu.com/ubuntu/ lucid-updates/main qemu-common 0.12.3+noroms-0ubuntu9.19
404 Not Found [IP: 91.189.91.24 80]
Err http://security.ubuntu.com/ubuntu/ lucid-security/main qemu-common 0.12.3+noroms-0ubuntu9.19
404 Not Found [IP: 91.189.88.153 80]
Err http://security.ubuntu.com/ubuntu/ lucid-security/main qemu-kvm 0.12.3+noroms-0ubuntu9.19
404 Not Found [IP: 91.189.88.153 80]

and in the end it prints :-
Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/q/qemu-kvm/qemu-common_0.12.3+noroms-0ubuntu9.19_all.deb 404 Not Found [IP: 91.189.88.153 80]
Failed to fetch http://security.ubuntu.com/ubuntu/pool/main/q/qemu-kvm/qemu-kvm_0.12.3+noroms-0ubuntu9.19_i386.deb 404 Not Found [IP: 91.189.88.153 80]
E: Unable to fetch some archives, maybe run apt-get update or try with --fix-missing?

on trying to build qemu from source i get the following error :-
Disabling libtool due to broken toolchain support
ERROR: pkg-config binary 'pkg-config' not found

regarding the web page

1
The BIOS boot sequence is: RAM detection -> Hardware detection/Initialization -> Boot sequence.

sound like a recursion..

2
consider adding a web-link to the github-issue page

cheers
:)

Encoding::CompatibilityError

I just installed vagrant and virtualbox as instructed chapter 2.
I got stuck at boot up vagrant development environment..
I'm working on Windows 8 (x64). is this issue known one?
if there is anyone know about this problem please let me know how should I do.
but I know that actually it's caused by ruby ;(

C:\Vagrant\SamyPesse>vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Importing base box 'lucid32'...
C:/Vagrant/embedded/gems/gems/childprocess-0.5.3/lib/childprocess/windows/proces
s_builder.rb:43:in join': incompatible character encodings: CP949 and ASCII-8BI T (Encoding::CompatibilityError) from C:/Vagrant/embedded/gems/gems/childprocess-0.5.3/lib/childprocess/w indows/process_builder.rb:43:increate_command_pointer'
from C:/Vagrant/embedded/gems/gems/childprocess-0.5.3/lib/childprocess/w
indows/process_builder.rb:27:in start' from C:/Vagrant/embedded/gems/gems/childprocess-0.5.3/lib/childprocess/w indows/process.rb:68:inlaunch_process'
from C:/Vagrant/embedded/gems/gems/childprocess-0.5.3/lib/childprocess/a
bstract_process.rb:82:in start' from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/util/subpro cess.rb:103:inblock in execute'
from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/util/safe_c
hdir.rb:26:in block (2 levels) in safe_chdir' from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/util/safe_c hdir.rb:25:inchdir'
from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/util/safe_c
hdir.rb:25:in block in safe_chdir' from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/util/safe_c hdir.rb:24:insynchronize'
from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/util/safe_c
hdir.rb:24:in safe_chdir' from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/util/subpro cess.rb:102:inexecute'
from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/util/subpro
cess.rb:22:in execute' from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/plugins/providers/virtu albox/driver/base.rb:371:inblock in raw'
from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/util/busy.r
b:19:in busy' from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/plugins/providers/virtu albox/driver/base.rb:370:inraw'
from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/plugins/providers/virtu
albox/driver/base.rb:309:in block in execute' from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/util/retrya ble.rb:17:inretryable'
from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/plugins/providers/virtu
albox/driver/base.rb:304:in execute' from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/plugins/providers/virtu albox/driver/version_4_3.rb:199:inimport'
from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/plugins/providers/virtu
albox/action/import.rb:15:in call' from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/action/ward en.rb:34:incall'
from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/plugins/providers/virtu
albox/action/customize.rb:40:in call' from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/action/ward en.rb:34:incall'
from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/plugins/providers/virtu
albox/action/check_accessible.rb:18:in call' from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/action/ward en.rb:34:incall'
from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/action/ward
en.rb:95:in block in finalize_action' from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/action/ward en.rb:34:incall'
from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/action/ward
en.rb:34:in call' from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/action/buil der.rb:116:incall'
from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/action/runn
er.rb:66:in block in run' from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/util/busy.r b:19:inbusy'
from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/action/runn
er.rb:66:in run' from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/action/buil tin/call.rb:53:incall'
from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/action/ward
en.rb:34:in call' from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/action/buil tin/config_validate.rb:25:incall'
from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/action/ward
en.rb:34:in call' from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/action/ward en.rb:95:inblock in finalize_action'
from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/action/ward
en.rb:34:in call' from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/action/ward en.rb:34:incall'
from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/action/buil
tin/handle_box.rb:56:in call' from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/action/ward en.rb:34:incall'
from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/action/ward
en.rb:95:in block in finalize_action' from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/action/ward en.rb:34:incall'
from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/action/ward
en.rb:34:in call' from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/action/buil der.rb:116:incall'
from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/action/runn
er.rb:66:in block in run' from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/util/busy.r b:19:inbusy'
from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/action/runn
er.rb:66:in run' from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/action/buil tin/call.rb:53:incall'
from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/action/ward
en.rb:34:in call' from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/plugins/providers/virtu albox/action/check_virtualbox.rb:17:incall'
from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/action/ward
en.rb:34:in call' from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/action/buil der.rb:116:incall'
from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/action/runn
er.rb:66:in block in run' from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/util/busy.r b:19:inbusy'
from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/action/runn
er.rb:66:in run' from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/machine.rb: 196:inaction_raw'
from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/machine.rb:
173:in block in action' from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/environment .rb:434:inlock'
from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/machine.rb:
161:in call' from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/machine.rb: 161:inaction'
from C:/Vagrant/embedded/gems/gems/vagrant-1.6.2/lib/vagrant/batch_actio
n.rb:82:in `block (2 levels) in run'

C:\Vagrant\SamyPesse>

Small Typo

From Chapter 2:

Once the lucid32 image is redy, we need to define our development environment using a Vagrantfile, create a file named Vagrantfile. This file defined that our environment need: nasm, make, build-essential, grub and qemu

Second sentence should be defines not defined to keep tense consistent. Additionally, need should be needs & redy should be ready.

Awesome project!

Don't apologize for your work.

The readme file opens up with apologizing for your 'crap'.

Someone who writes something so ambitious shouldn't apologize for anything. If you think about how many actual OS's have been written in history, it's quite small, and some of the most successful ones have had lots of bugs, which doesn't discount the effort at all.

I would like to see the 'crap' comment removed from readme :).

qemu not found

after installing qemu, make run gives the result as qemu not found

"make emulate" failed

I succesfull ran "make all"
As below

cp start.o ../../lib/crt_c.o
rm *.o
make[2]: Leaving directory /vagrant/sdk/src/libc' make[1]: Leaving directory/vagrant/sdk'
Building Userland
make -C ./userland
make[1]: Entering directory /vagrant/userland' make -C "helloworld" all make[2]: Entering directory/vagrant/userland/helloworld'
make[2]: Nothing to be done for all'. make[2]: Leaving directory/vagrant/userland/helloworld'
make[1]: Leaving directory `/vagrant/userland'

However, when I ran "make emulate"
It failed...
make: *** No rule to make target `emulate'. Stop.

What' the problem?

"make run" fail

Building Kernel
make -C ./kernel
make[1]: Entering directory '/home/yogesh/Development/How-to-Make-a-Computer-Operating-System/src/kernel'
nasm -f elf -o -c arch/x86/start.asm -o arch/x86/start.o
make[1]: nasm: Command not found
Makefile:64: recipe for target 'arch/x86/start.o' failed
make[1]: *** [arch/x86/start.o] Error 127
make[1]: Leaving directory '/home/yogesh/Development/How-to-Make-a-Computer-Operating-System/src/kernel'
Makefile:10: recipe for target 'all' failed
make: *** [all] Error 2

need some help?

Hi this is my first open source project.
After reading the book what exactly can i do?

Translate into Korean

Hi, I want to translate this fantastic project.

Is there any process I have to follow?

'make run' error: could not load PC BIOS 'bios.bin'

Here is the error when I typed 'make run':
This filesystem will be automatically checked every 20 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
cd ./sdk && ./qemu.sh
open /dev/kvm: No such file or directory
Could not initialize KVM, will disable KVM support
qemu: could not load PC BIOS 'bios.bin'
make: *** [run] Error 1

Translate into Portuguese

Hello, I am willing to work on the translation of this book into Portuguese, I saw that there is a person interested, your id is @gubertoli and I would like to join in this effort. (Issue #89 )

But I see that the project is not structured for translation in several languages, it would be interesting to come together to standardize the project so that we can invest more in this project each in its own language.

@SamyPesse how do you think we restructured the book so that it gets translated from other languages and centralized everything in an organization here in GitHub?

Do you plan to invest more in the book? Expand your content? I for example feel like adapting the content to the ARM architecture, what do you think? I think the ideal is to open a new issue to address this.

Hugs.

How to proceed after chapter 3

I have installed grub on the disk and detached the loop device . I can't understand what to do next with the c/c++ functions .

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.