This code may not look so suitable in many places, and will be refactored sooner or later. New warehouse recover-os. Wait for me to come back to fill in the pit. Refactored version: https://github.com/yiezias/recover-os
This project is based on the AMD64 architecture (or x86_64 architecture) version of the operating system implemented by "Operating System Truth Restore". The main ideas and code are consistent with the original book.
The operating system implemented by "Operating System Truth Restore" runs on a 32-bit x86 architecture processor, but now we have already entered the 64-bit era. So I copy Refer to the code in "Operating System Truth Restore" to implement its 64-bit version.
$ make run can compile and start the bochs emulator.
This operating system has built-in 2048, Snake and other mini games.
Write code with recover:
(The terminal does not implement input and output redirection, and the cat below is different from the cat under Linux)
(Just show the function of writing text files)

2048 mini game:

Greedy snake (the frame drop is serious, so I won’t let the animations go):

The most easy-to-understand related books I have read, detailed and interesting. Even if it seems a bit long-winded, the author still needs to try different ways to let readers understand (where can I find such a friendly book). Among the many operating system-related books, I finally chose this one The only one that can understand Book implementation of operating system.
Mainly the difference between AMD64 and x86 architectures
Under the AMD64 architecture, functions generally use registers to pass parameters, and the function calling convention under x86 has no reference value. But it is easy to understand itself. Write a C function in detail and compile it into assembly and then you will understand it by writing it in GCC. This knowledge is needed in many places during the development process.
Long mode can be understood as 64-bit feature Protected mode, the processor needs to switch from real mode to protected mode and then to long mode.
The most convenient way to obtain information is of course a search engine, but search engines often cannot find the content they want, and the truly authoritative information is still AMD or Intel documents.
This system completely abandons the method of interrupting the implementation of system calls and uses syscall sysret fast system call instruction to implement it. For details, please refer to AMD or Intel documents, and the content is not complicated.
The author's file system doesn't feel very well written. On the one hand, the file system is already quite complicated, but the author often uses nearly hundreds of lines of functions, and some code can be reused, but it needs to be implemented repeatedly, which is very confusing overall. This system file system is equivalent to a major change in the author, but it should not be difficult to understand based on the author's book and code. The file system of this system does not implement directory-level functions, but does not affect the implementation of other functions of the system, so it is omitted.
The author's shell is implemented in the kernel. This system uses the shell as an application, and the init process uses the execv system call to load the root directory shell. Many built-in commands of the author system are also directly implemented as applications in this system. But the code level is similar. There are also special mini-games that can call the operating system interface to implement applications independently, and this system is basically completed.