2014-09-29 08:39:34 +00:00
|
|
|
os-tutorial
|
|
|
|
===========
|
|
|
|
|
2014-10-05 16:22:18 +00:00
|
|
|
How to create an OS from scratch!
|
2014-09-29 09:00:02 +00:00
|
|
|
|
2014-10-05 16:29:07 +00:00
|
|
|
**New lessons will be added about every week, at the same pace that I learn each concept**
|
|
|
|
|
2014-10-05 16:22:18 +00:00
|
|
|
I have always wanted to learn how to make an OS from scratch. In college I was taught
|
2014-09-29 09:00:02 +00:00
|
|
|
how to implement advanced features (pagination, semaphores, memory management, etc)
|
|
|
|
but:
|
|
|
|
|
|
|
|
- I never got to start from my own boot sector
|
|
|
|
- College is hard so I don't remember most of it.
|
2014-10-05 16:26:12 +00:00
|
|
|
- I'm fed up with people who think that reading an already existing kernel, even if small, is
|
|
|
|
a good idea to learn operating systems.
|
2014-09-29 09:00:02 +00:00
|
|
|
|
|
|
|
Inspired by [this document](http://www.cs.bham.ac.uk/~exr/lectures/opsys/10_11/lectures/os-dev.pdf)
|
|
|
|
and the [OSDev wiki](http://wiki.osdev.org/), I'll try to make short step-by-step READMEs and
|
2014-10-05 16:26:12 +00:00
|
|
|
code samples for anybody to follow. Honestly, this tutorial is basically the first document but
|
|
|
|
split into smaller pieces and without the theory.
|
2014-09-29 09:00:02 +00:00
|
|
|
|
2015-03-19 19:19:44 +00:00
|
|
|
Updated: more sources: [the little book about OS development](https://littleosbook.github.io),
|
|
|
|
[JamesM's kernel development tutorials](http://www.jamesmolloy.co.uk/tutorial_html/index.html)
|
|
|
|
|
2014-09-30 08:24:32 +00:00
|
|
|
|
2014-10-05 16:22:18 +00:00
|
|
|
Features
|
|
|
|
--------
|
2014-09-29 09:51:49 +00:00
|
|
|
|
2014-10-05 16:26:12 +00:00
|
|
|
- This course is a code tutorial aimed at people who are comfortable with low level computing. For example,
|
|
|
|
programmers who have curiosity on how an OS works but don't have the time or willpower to start reading the Linux kernel
|
|
|
|
top to bottom.
|
|
|
|
- There is little theory. Yes, this is a feature. Google is your theory lecturer. Once you pass college,
|
2014-10-05 16:27:04 +00:00
|
|
|
excessive theory is worse than no theory because it makes things seem more difficult than they really are.
|
2014-10-05 16:26:12 +00:00
|
|
|
- The lessons are tiny and may take 5-15 minutes to complete. Trust me and trust yourself. You can do it!
|
2014-09-29 09:00:02 +00:00
|
|
|
|
|
|
|
|
|
|
|
How to use this tutorial
|
|
|
|
------------------------
|
|
|
|
|
2014-10-05 16:22:18 +00:00
|
|
|
1. Start with the first folder and go down in order. They build on previous code, so if
|
2014-10-05 16:29:07 +00:00
|
|
|
you jump right to folder 05 and don't know why there is a `mov ah, 0x0e`, it's because you missed lecture 02.
|
|
|
|
Really, just go in order. You can always skip stuff you already know.
|
2014-09-29 09:00:02 +00:00
|
|
|
|
2014-10-05 16:39:45 +00:00
|
|
|
2. Open the README and read the first line, which details the concepts you should be familiar with
|
|
|
|
before reading the code. Google concepts you are not familiar with. The second line states the goals for each lesson.
|
|
|
|
Read them, because they explain why we do what we do. The "why" is as important as the "how".
|
|
|
|
|
|
|
|
3. Read the rest of the README. It is **very concise**.
|
2014-09-29 09:51:49 +00:00
|
|
|
|
2014-10-05 16:39:45 +00:00
|
|
|
4. (Optional) Try to write the code files by yourself after reading the README.
|
2014-10-05 16:22:18 +00:00
|
|
|
|
2014-10-05 16:39:45 +00:00
|
|
|
5. Look at the code examples. They are extremely well commented.
|
2014-10-05 16:22:18 +00:00
|
|
|
|
2014-10-05 16:39:45 +00:00
|
|
|
6. (Optional) Experiment with them and try to break things. The only way to make sure you understood something is
|
|
|
|
trying to break it or replicate it with different commands.
|
2014-09-29 09:00:02 +00:00
|
|
|
|
|
|
|
|
2014-10-05 16:39:45 +00:00
|
|
|
TL;DR: First read the README on each folder, then the code files. If you're brave, try to code them yourself.
|
2014-09-29 09:00:02 +00:00
|
|
|
|
|
|
|
|
2015-03-20 18:27:36 +00:00
|
|
|
Strategy
|
|
|
|
--------
|
|
|
|
|
|
|
|
We will want to do many things with our OS:
|
|
|
|
|
|
|
|
- Boot from scratch, without GRUB - DONE!
|
|
|
|
- Enter 32-bit mode - DONE
|
|
|
|
- Jump from Assembly to C - DONE!
|
|
|
|
- Interrupt handling - DONE!
|
|
|
|
- Screen output and keyboard input - DONE!
|
|
|
|
- A tiny, basic `libc` which grows to suit our needs - DONE!
|
|
|
|
- Memory management
|
|
|
|
- Write a filesystem to store files
|
|
|
|
- Create a very simple shell
|
|
|
|
- User mode
|
|
|
|
- Maybe we will write a simple text editor
|
|
|
|
- Multiple processes and scheduling
|
|
|
|
|
|
|
|
Probably we will go through them in that order, however it's soon to tell.
|
|
|
|
|
|
|
|
If we feel brave enough:
|
|
|
|
|
|
|
|
- A BASIC interpreter, like in the 70s!
|
|
|
|
- A GUI
|
|
|
|
- Networking
|
|
|
|
|
|
|
|
|
|
|
|
|
2014-09-29 09:00:02 +00:00
|
|
|
Contributing
|
|
|
|
------------
|
|
|
|
|
|
|
|
I'm still learning this. For the moment, please restrict your contributions to fixing possible bugs
|
|
|
|
or improving existing documents. I'm not yet ready to accept enhancements.
|