Chinese source code of 30 day self made operating system

Time:2020-2-20

The process of making an operating system by yourself, the reading process will be accompanied by Chinese source code, execution and code writing according to some relevant contents. Welcome to exchange.

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

Run method, intolsetNew one inrunFolder, copy the code in, and then run it according to the system version!cons_**.bat

Generally usedmake runRun code, 27 days to usemake run_full。 You can read directly.

Completion effect

Chinese source code of 30 day self made operating system

content validity

First week (day 1-7)

At first, we should consider how to write a “program that can run as long as it is powered on”. 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 to read the operating system from disk. At this time, even if the computer is powered on, it will not automatically read all the operating systems in. It can only read the 512 bytes of the first disk, so we need to write the rest of the loading program. This program should also be written in assembly language.

Once this step is completed, later programs can be written in C language. We will use C language as soon as possible to learn and develop the program of display screen. At the same time, we can get familiar with C grammar. At this time, we seem to be doing what we want to do, but in fact, we are not free to manipulate C language.

Next, in order to realize the ambition of “moving the mouse”, we need to set the CPU carefully and master the writing method of interrupt handler. From the overall view of the whole book, this part is quite high-level. I also think it’s inappropriate to put it here. But in terms of the book’s organization, these contents must be put here, so I have to ask you to bear with it. Here, the specification of CPU and the complicated specification of computer will bring us all kinds of troubles. And the development language has both C language and assembly language, which causes us more confusion. At this time, we don’t think it’s doing what we want to do at all. It’s like “being manipulated”.

The first week should be over after this painful period.

  • Day 1: getting started from computer structure to assembler

  • Day 2: introduction to assembly language learning and makefile

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

  • Day 4: Practice of C language and screen display

  • Day 5: structure, text display and GDT / IDT initialization

  • Day 6: split compilation and interrupt handling

  • Day 7: FIFO and mouse control

The second week (day 8-14)

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

So now we can start to develop a decent operating system. But this time we have a headache for algorithm. Even if you have mastered the syntax of programming language, if you don’t know a good algorithm, you still can’t develop the operating system you want.

So this week we’re learning algorithms and slowly developing operating systems. But at this stage, we can feel that we will not be limited by technical problems.

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

  • Day 9: memory management

  • Day 10: stack processing

  • Day 11: Production window

  • Day 12: timer (1)

  • Day 13: timer (2)

  • Day 14: high resolution and keyboard input

The third week (day 15-21)

Now our technology is quite powerful, we can develop our own operating system at will. First, multitasking is supported, then command-line windows are developed, and then applications can be developed.

By the end of this week, even if it’s not complete enough, we’ll be able to come up with a piece of software that we can call an operating system.

  • Day 15: multitasking (1)

  • Day 16: multitasking (2)

  • Day 17: command line window

  • Day 18: dir command

  • Day 19: Applications

  • Day 20: API

  • Day 21: protect the operating system

The fourth week (day 22-28)

At this stage, we can add all kinds of functions to the operating system and develop a large number of decent applications.

We have been able to do a good job in this stage, which is probably the most happy period for us. This part of the content to be explained is very few, the author no longer need to painstakingly write those words, can focus on programming (laughter).

By the way, when it comes to words, it’s just in this period that our operating system can display words.

  • Day 22: writing applications in C

  • Day 23: graphics related

  • Day 24: window operation

  • Day 25: add command line window

  • Day 26: speed up window movement

  • Day 27: LDT and Library

  • Day 28: document operation and text display

Two free days (day 29-30)

The remaining two days are used for touch up processing. In these two days, we have to do something that we didn’t have time to do before, but which is both simple and interesting.

  • Day 29: compression and simple applications

  • Day 30: Advanced Applications