os-tutorial-cn卷首語

os-tutorial

從頭創(chuàng)造一個操作系統(tǒng)卸夕!

這個教程完全是從@cfenollosa fork來的,這個教程將復(fù)雜的系統(tǒng)編寫任務(wù)分解為很多簡單步驟搀缠,在每一個小步驟中穿插著需要讀者自學(xué)的簡單知識點(diǎn)缰泡,幾乎每一節(jié)課都有一點(diǎn)點(diǎn)積累,然后突然就在其中某個時刻完成了一個階段性的目標(biāo)弱左,這是讓人驚嘆的教育手段窄陡,至少我本人佩服至極,所以在我第二次學(xué)習(xí)這個教程的過程中拆火,順便將教程做了粗糙的翻譯跳夭,修正了個別bug,以作為@cfenollosa倉庫的中文概覽们镜,如果能幫后來者節(jié)省一些時間币叹,我將深感欣慰!

@cfenollosa的教程其實(shí)也是大量參考了別的英文的教程模狭,os-dev是前面十幾節(jié)課的參考書籍颈抚,可惜這本書沒有寫完
,但即使只是一本沒有寫完的書籍也絕對是神作嚼鹉,從BIOS到屏幕打印的接口贩汉,總是從初學(xué)者的角度娓娓道來,至少是本人見過最好的操作系統(tǒng)入門書籍锚赤。各位剛開始時匹舞,一定要細(xì)細(xì)的讀os-dev這本書,然后嘗試跟著本倉庫的節(jié)奏寫程序宴树,出現(xiàn)任何問題策菜,請對照倉庫中現(xiàn)成的程序修改。

以下是@cfenollosa原文:

How to create an OS from scratch!

I have always wanted to learn how to make an OS from scratch. In college I was taught 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.
  • 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.

Inspired by this document and the OSDev wiki, I'll try to make short step-by-step READMEs and code samples for anybody to follow. Honestly, this tutorial is basically the first document but split into smaller pieces and without the theory.

Updated: more sources: the little book about OS development, JamesM's kernel development tutorials

Features

  • 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, excessive theory is worse than no theory because it makes things seem more difficult than they really are.
  • The lessons are tiny and may take 5-15 minutes to complete. Trust me and trust yourself. You can do it!

How to use this tutorial

  1. Start with the first folder and go down in order. They build on previous code, so if 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.

  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.

  4. (Optional) Try to write the code files by yourself after reading the README.

  5. Look at the code examples. They are extremely well commented.

  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.

TL;DR: First read the README on each folder, then the code files. If you're brave, try to code them yourself.

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

Contributing

This is a personal learning project, and even though it hasn't been updated for a long time, I still have hopes to get into it at some point.

I'm thankful to all those who have pointed out bugs and submitted pull requests. I will need some time to review everything and I cannot guarantee that at this moment.

Please feel free to fork this repo. If many of you are interested in continuing the project, let me know and I'll link the "main fork" from here.

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個濱河市又憨,隨后出現(xiàn)的幾起案子翠霍,更是在濱河造成了極大的恐慌,老刑警劉巖蠢莺,帶你破解...
    沈念sama閱讀 206,214評論 6 481
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件寒匙,死亡現(xiàn)場離奇詭異,居然都是意外死亡躏将,警方通過查閱死者的電腦和手機(jī)锄弱,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 88,307評論 2 382
  • 文/潘曉璐 我一進(jìn)店門,熙熙樓的掌柜王于貴愁眉苦臉地迎上來祸憋,“玉大人会宪,你說我怎么就攤上這事◎强” “怎么了掸鹅?”我有些...
    開封第一講書人閱讀 152,543評論 0 341
  • 文/不壞的土叔 我叫張陵,是天一觀的道長拦赠。 經(jīng)常有香客問我巍沙,道長,這世上最難降的妖魔是什么荷鼠? 我笑而不...
    開封第一講書人閱讀 55,221評論 1 279
  • 正文 為了忘掉前任句携,我火速辦了婚禮,結(jié)果婚禮上允乐,老公的妹妹穿的比我還像新娘矮嫉。我一直安慰自己,他們只是感情好牍疏,可當(dāng)我...
    茶點(diǎn)故事閱讀 64,224評論 5 371
  • 文/花漫 我一把揭開白布敞临。 她就那樣靜靜地躺著,像睡著了一般麸澜。 火紅的嫁衣襯著肌膚如雪挺尿。 梳的紋絲不亂的頭發(fā)上,一...
    開封第一講書人閱讀 49,007評論 1 284
  • 那天炊邦,我揣著相機(jī)與錄音编矾,去河邊找鬼。 笑死馁害,一個胖子當(dāng)著我的面吹牛窄俏,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播碘菜,決...
    沈念sama閱讀 38,313評論 3 399
  • 文/蒼蘭香墨 我猛地睜開眼凹蜈,長吁一口氣:“原來是場噩夢啊……” “哼限寞!你這毒婦竟也來了?” 一聲冷哼從身側(cè)響起仰坦,我...
    開封第一講書人閱讀 36,956評論 0 259
  • 序言:老撾萬榮一對情侶失蹤履植,失蹤者是張志新(化名)和其女友劉穎,沒想到半個月后悄晃,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體玫霎,經(jīng)...
    沈念sama閱讀 43,441評論 1 300
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 35,925評論 2 323
  • 正文 我和宋清朗相戀三年妈橄,在試婚紗的時候發(fā)現(xiàn)自己被綠了庶近。 大學(xué)時的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 38,018評論 1 333
  • 序言:一個原本活蹦亂跳的男人離奇死亡眷蚓,死狀恐怖鼻种,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情沙热,我是刑警寧澤普舆,帶...
    沈念sama閱讀 33,685評論 4 322
  • 正文 年R本政府宣布,位于F島的核電站校读,受9級特大地震影響,放射性物質(zhì)發(fā)生泄漏祖能。R本人自食惡果不足惜歉秫,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 39,234評論 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望养铸。 院中可真熱鬧雁芙,春花似錦、人聲如沸钞螟。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,240評論 0 19
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽鳞滨。三九已至洞焙,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間拯啦,已是汗流浹背澡匪。 一陣腳步聲響...
    開封第一講書人閱讀 31,464評論 1 261
  • 我被黑心中介騙來泰國打工, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留褒链,地道東北人唁情。 一個月前我還...
    沈念sama閱讀 45,467評論 2 352
  • 正文 我出身青樓,卻偏偏與公主長得像甫匹,于是被迫代替她去往敵國和親甸鸟。 傳聞我的和親對象是個殘疾皇子惦费,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 42,762評論 2 345

推薦閱讀更多精彩內(nèi)容