Chinese Source Code of “30 Days Homemade Operating System”

Time:2019-8-16

The process of making an operating system by oneself, the process of reading will not only sinicize the source code, but also execute the code according to some relevant content. Welcome to exchange.

GitHub address: https://github.com/yourtion/30dayMakeOS

Running method, intolsetCreate a new one in ChinarunFolder, copy the code in and run according to the system version!cons_**.bat

Usually usedmake runRun the code and start using it 27 days latermake run_full。 You can read books directly.

Completion effect

Chinese Source Code of

content validity

Week 1 (Day 1-7)

The first thing to consider is how to write a program that can run on a single power supply. This part is difficult to write in C language, so it is mainly written in assembly language.

After that, the next step is to write a program that reads the operating system from disk. At this time, even if the computer power is turned on, it will not automatically read all the operating system in, it can only read the first 512 bytes of content on the disk, so we have to write the rest of the load program. This program should also be written in assembly language.

Once this step is completed, subsequent programs can be written in C language. We will use C language as soon as possible to learn how to develop the display screen program. At the same time, we can gradually become familiar with C language grammar. At this time, we seem to be doing what we want to do, but in fact, we have not yet freely manipulated the C language.

Next, in order to realize the ambition of “mobile mouse”, we need to set CPU carefully and master the writing of interrupt processing program. Overall, this part of the book is quite high level. I also think it is not appropriate to put it here, but from the point of view of the book, these contents must be put here, so please bear with it. Here, CPU specifications and complex computer specifications will bring us a variety of troubles. Moreover, the development language has both C language and assembly language, which has caused us more confusion. At this time, we will not feel at all that this is doing what we want to do, how it looks like “being pushed around”.

Through this painful period, the first week should be over.

  • Day 1: Introduction to Computer Architecture and Assembly Programming

  • Day 2: Assembly Language Learning and Makefile Introduction

  • Day 3: Enter 32-bit mode and import C language

  • Day 4: Practice of C Language and Screen Display

  • Day 5: Structures, Text Display and GDT/IDT Initialization

  • Day 6: Split Compilation and Interrupt Processing

  • 7th day: FIFO and mouse control

Second week (8th to 14th day)

A week’s hard work is still meaningful. Looking back, we will find that we have achieved a lot. At this time, we have basically mastered the C language grammar, and even the level of assembly language can meet the requirements of this book.

So now we can start developing decent operating systems. But this time we’re going to have a headache with algorithms. Even if you have mastered the grammar of the programming language, if you don’t know the good algorithm, you can’t develop the operating system you want.

So this week we are slowly developing the operating system while learning algorithms. But at this stage, we can feel that there will be no more technical constraints.

  • Day 8: Mouse control and 32-bit mode switching

  • Day 9: Memory management

  • Day 10: Overlay Processing

  • Day 11: Production Window

  • Day 12: Timer (1)

  • Day 13: Timer (2)

  • Day 14: High resolution and keyboard input

Week 3 (15-21)

Now our technology is quite powerful, we can develop our own operating system at will. First, support multiple tasks, then develop command-line windows, and then start developing applications.

By the end of the week, even if it’s not complete enough, we may have come up with a software that we can call an operating system.

  • Day 15: Multitask (1)

  • Day 16: Multitask (2)

  • Seventeenth day: Command line window

  • Day 18: Dir Order

  • Day 19: Applications

  • Day 20: API

  • Day 21: Protecting Operating Systems

Week 4 (22-28)

At this stage, we can add various functions to the operating system as much as we can, and we can also develop a large number of decent applications.

We’ve done a good job at this stage, and it’s probably our happiest time. This part of the content to be explained is very little, the author no longer need to painstakingly write those text instructions, can focus on programming (laughter).

By the way, when it comes to words, it is precisely in this period that our operating system can display words.

  • Day 22: Writing Applications in C Language

  • Day 23: Graphics Processing Related

  • Day 24: Window operation

  • Day 25: Add command line window

  • Day 26: Speed up window movement

  • 27 days: LDT and Library

  • Day 28: File operation and text display

Free gift for two days (29-30 days)

The remaining two days are used for polishing. These two days we’ll do something that we haven’t had time to do before, but it’s simple and interesting to do.

  • Day 29: Compression and Simple Applications

  • Day 30: Advanced Applications