dedicated kthread interface and enablement of lrud auto-recycler
[lunaix-os.git] / README.md
index e8910787ba830d22d0e8ef34070ad8cd41a53df7..c4a4ea9579fd3f61f0c310e746abc6bfffa76814 100644 (file)
--- a/README.md
+++ b/README.md
 </p>
 
 <p align="center">
 </p>
 
 <p align="center">
-  <a href="#lunaixos-project">简体中文</a> | <a href="docs/README_en.md">English</a>
+  <a href="docs/README.cn.md">简体中文</a> | <a href="#the-lunaixos-project">English</a>
 </p>
 
 </p>
 
-# The LunaixOS Project
-
-LunaixOS - 一个简单的,详细的,POSIX兼容的(但愿!),带有浓重个人风格的操作系统。开发过程以视频教程形式在Bilibili呈现:[《从零开始自制操作系统系列》](https://space.bilibili.com/12995787/channel/collectiondetail?sid=196337)。
-
-## 1. 一些实用资源
-
-如果有意研读LunaixOS的内核代码和其中的设计,或欲开始属于自己的OS开发之道,以下资料可能会对此有用。
-
-+ [最新的LunaixOS源代码分析教程](docs/tutorial/0-教程介绍和环境搭建.md)
-+ [内核虚拟内存的详细布局](docs/img/lunaix-os-mem.png)
-+ [LunaixOS启动流程概览](docs/img/boot_sequence.jpeg)
-+ LunaixOS总体架构概览(WIP)
-+ [作者修改的QEMU](https://github.com/Minep/qemu) (添加了一些额外用于调试的功能)
-
-## 2. 当前进度以及支持的功能
-
-Lunaix内核具有支持多种不同的指令集架构的能力,目前支持如下:
-
-+ x86_32
-+ x86_64
-
-Lunaix全部特性一览:
-
-+ 使用Multiboot进行引导启动
-  + Multiboot 1
-  + Multiboot 2 (WIP)
-+ APIC/IOAPIC作为中断管理器和计时器
-+ ACPI
-+ 虚拟内存
-  + 架构中性设计
-  + 按需分页
-  + Copy-on-Write
-+ 内存管理
-+ 进程模型
-+ 61个常见的Linux/POSIX系统调用([附录1](#appendix1))
-+ 用户/内核态隔离
-+ 信号机制
-+ PCI 3.0
-+ PCIe 1.1 (WIP)
-+ 块设备驱动
+# The Lunaix Project
+
+The Lunaix kernel (or soon-to-be LunaixOS) is a hobby kernel, written entirely from scratch. Designed to be POSIX-compliance, performance critical and modern, with some independent thoughts being applied in architectural design.
+
+This project is based solely on first principles. Meaning that it does neither copy-pasting nor recycling other os projects/tutorials. However, this doesn't necessarily imply superiority; In fact, Lunaix starts out as a mean to challenge my understanding in OS theory and also a platform for experimenting some advanced (and cool) kernel features. If you are a kernel hobbyist who want some new perspectives or just simply get fatigued on those recycled content, then you have came to the right place!
+
+
+| ![showcase_lunaix-over-serial.png](docs/img/showcase_lunaix-over-serial.png) |
+|:--:|
+| *Lunaix over serial* (`console=/dev/ttyS0`) |
+
+| ![showcase_lunaix-over-serial.png](docs/img/showcase_lunaix-over-vga-text.png) |
+|:--:|
+| *Lunaix over VGA text mode* (`console=/dev/ttyVCON0`) |
+
+> By the way, do you know there is an online video course  by the author on the design of lunaix? [Check it out](https://space.bilibili.com/12995787/channel/collectiondetail?sid=196337) (although it is in Chinese!)
+
+## Features
+
+In a nutshell, Lunaix is a multi-architectural general purpose kernel, and she is:
+
++ fully-preemptive
++ modular design with configurable components at compile-time and extendable subsystems
++ high-performance by utilising advanced caching techniques and infrastructure.
++ fault-tolerance with sophisticated builtin error handling and tracing techniques.
++ robust in nature with techniques such as proactive deadlock detection and driver isolation mechanism.
+
+The author has put a significant amount of time on devising better abstractions, advance kernel features and various optimisation techniques. To give a better understanding (and appreciation) of the works being done, the following non-exhaust list has been compiled with features that are currently supported in lunaix:
+
++ Multi-ISA
+  + x86_32
+  + x86_64
+  + Aarch64 (W.I.P)
++ Boot protocol
+  + abstraction for different protocol
+  + configurable kernel boot-time parameters
++ Platform resource management and definition
+  + ACPI
+  + Devicetree
++ Memory management
+  + architecture-neutral abstraction
+  + on-demand paging
+  + copy-on-write and page sharing
+  + compound page support
+  + explicit huge page support (sorry, not THP!)
+  + reverse mapping indexing (rmap)
+  + memory compaction (W.I.P)
+  + slab-alike object allocator
+  + highmem support
+  + remote address space accessing
++ Multi-tasking
+  + Protection level and process image isolation
+  + Native threading support (no more lightweight process nonsense)
+  + Signal mechanism
+  + Kernel level multi-tasking (i.e. kernel threads)
+  + Round-robin scheduling (for now)
+  + Preemptive kernel design
+  + taskfs: file system interface to process and threads
++ File system
+  + virtual file system framework
+  + ...with POSIX compliant interfaces
+  + file system mounting mechanism
+  + page cache for file IO
+  + node cache for vfs structure representation.
+  + ext2 (rev.0, rev.1)
+  + iso9660 (rock-ridge)
+  + twifs: file system interface to kernel states.
++ Device management and interrupt handling
+  + architecture-neutral design
+  + generalised driver framework
+  + generalised irq framework
+  + driver modularisation design
+  + support asynchronous device model
+  + devfs: file system interface to device subsystem
++ Block I/O (blkio)
+  + generalised block IO interface and encapsulation
+  + blkio packets caching
+  + asynchronous blkio operation in nature
++ Serial I/O
+  + POSIX-compliant serial port model
+  + serial device driver framework (part of driver framework)
++ Caching Infrastructure
+  + primitive: generic sparse associative array (spatial data)
+  + LRU replacement policy and pooling
+  + kernel daemon for scheduled cache eviction
++ Error handling and detection
+  + stack back-tracing with symbol resolution
+  + nested exception unfolding
+  + CPU state dumping
+  + Deadlock/hung-up detection
+
+For the device drivers that are currently support see below:
+
++ Arhcitecture Neutral
+  + UART 16650-compatible driver
   + Serial ATA AHCI
   + Serial ATA AHCI
-    + ATA设备
-    + ATAPI封装的SCSI协议
-+ 文件系统(POSIX.1-2008, section 5 & 10)
-  + 虚拟文件系统
-  + 内核态文件系统(twifs, Lunaix自己的sysfs)
-  + 设备文件系统(devfs, Lunaix自己的udev)
-  + 进程文件系统(procfs)
-  + ISO9660
-    + ECMA-119
-    + IEEE P1282(Rock Ridge拓展)
-+ 远程GDB串口调试 (COM1@9600Bd)
-+ 用户程序加载与执行
-+ 通用设备抽象层
-  + 架构中性的设备支持位于:`lunaix-os/hal`
-    + 16550 UART
-    + ACPI (不完全实现)
-  + 架构耦合的设备支持位于:`lunaix-os/arch/<ARCH>/hal`
-    + x86
-      + APIC/IOAPIC 组合
-      + MC146818 RTC
-      + i8042 PS/2
-      + RNG(使用`rdrand`)
-+ 通用图形设备抽象层 (Draft)
-  + 参考:`lunaix-os/hal/gfxa`
-+ 虚拟终端设备接口(POSIX.1-2008, section 11)
-  + 参考:`lunaix-os/hal/term`
-+ 线程模型
-  + 用户线程支持(pthread系列)
-  + 内核线程支持(抢占式内核设计)
-
-## 3. 目录结构
-
-|                                           |                              |
-| ----------------------------------------- | ---------------------------- |
-| [lunaix-os](lunaix-os/)                   | LunaixOS源代码               |
-| [slides](slides/)                         | 视频中所用的幻灯片和补充材料 |
-| [reference-material](reference-material/) | 标准,技术文档和参考文献     |
-
-## 4. 编译与构建
-
-**!如果想要立刻构建并运行,请参考4.6!**
-
-构建该项目需要满足以下条件:
-
-+ gcc 工具链
+  + PCI 3.0
+  + PCIe 1.1
+  + Standard VGA
++ Intel x86
+  + RTC (Intel PCH)
+  + IOAPIC irq controller
+  + APIC Timer
+  + Legacy i8042 keyboard controller
++ ARM
+  + GICv3
+  + PL011 (W.I.P)
+
+## Project Structure
+
+| Path | Description |
+|-----|------|
+| [lunaix-os](../lunaix-os/) | LunaixOS source code |
+| [slides](../slides/) | Slides used in my videos |
+| [reference-material](../reference-material/)| References |
+
+## Compile and Build
+
+Building lunaix is simple, no more bloated dependencies to install, basic `build-essentials` installation plus a python are sufficient.
+
++ gcc (recommend v12+)
++ binutils
 + make
 + make
-+ xorriso
-+ grub-mkrescue
++ python (recommend v3.11+)
 
 
-### 4.1 使用 GNU CC 工具链
+And also one should have environment variable `ARCH=<arch>` exported, where `<arch>` is one of the supported arhcitecture (`x86_32`, `x86_64`, `aarch64`).
 
 
-正如同大多数OS一样,LunaixOS 是一个混合了 C 和汇编的产物。这就意味着你得要使用一些标准的C编译器来构建Lunaix。在这里,我推荐使用 GNU CC 工具链来进行构建。因为Lunaix 在编写时使用了大量的GNU CC 相关编译器属性修饰 (`__attribute__`) 。假若使用其他工具链,如LLVM,我对此就不能做出任何保证了。
+For cross compilation, also export `CX_PREFIX` to the gcc prefix for the corresponding `<arch>`.
 
 
-如果你使用的是基于 x86 指令集的Linux系统,不论是64位还是32位,**其本机自带的gcc就足以编译Lunaix**。 当然了,如果说你的平台是其他非x86的,你也可以指定使用某个针对x86_32的gcc套件来进行交叉编译——在`make`时通过`CX_PREFIX`变量来指定gcc套件的前缀。如下例所示,我们可以在任意平台上,如risc-v,单独使用一个面向x86_32的gcc来进行交叉编译:
+The following `make` actions are then available to use.
 
 
-```
-make CX_PREFIX=i686-linux-gnu- all
-```
-
-### 4.2 Docker镜像
-
-对于开发环境,本项目也提供了Docker镜像封装。开箱即用,无需配置,非常适合懒人或惜时者。详细使用方法请转到:[Lunaix OSDK项目](https://github.com/Minep/os-devkit)。
+| Make command | Usage |
+| ---- | ---- |
+| `make all`               | Build the kernel bin |
+| `make rootfs`            | Build the stock rootfs |
+| `make clean`             | clean |
+| `make config`            | menuconfig |
 
 
-### 4.3 构建选项
+A successful build will give `build/bin/kernel.bin`.
 
 
+**Please note: this is the kernel, not a bootable image, it require a bootloader to boot and specify the rootfs.**
 
 
-假若条件满足,那么可以直接执行`make all`进行构建,完成后可在生成的`build`目录下找到可引导的iso。
+## Get Started
 
 
-本项目支持的make命令:
-| 命令                     | 用途                                            |
-| ------------------------ | ----------------------------------------------- |
-| `make all`               | 等价于 `make image` |
-| `make image`             | 构建ISO镜像,可直接启动,使用ISO9660文件系统         |
-| `make kernel`            | 构建内核ELF镜像,无法直接启动,需要引导程序        |
-| `make clean`             | 删除构建缓存,用于重新构建               |
-| `make config`            | 配置Lunaix                                   |
+If you are impatient, or just want something to run and don't want to went through tedious process of configuring rootfs and tweak kernel parameters. You can use the `live_debug.sh` provided in the lunaix root directory to quickly bring up the system with default parameters (also used by the author for debugging).
 
 
-与make命令配套的环境变量,Lunaix的makefile会自动检测这些环境变量,以更改构建行为
+Following the steps:
 
 
-+ `MODE={debug|release}` 使用debug模式构建(-Og)或者release模式(-O2)
-+ `ARCH=<isa>` 为指定的指令集架构编译Lunaix。 所使用的配置选项均为选定架构默认,该环境变量
-  存在的目的就是方便用户进行快速编译,而无需钻研Lunaix的种种配置项。
+1. Select an architecture `<arch>`
+2. Check the compilation prerequisites and presence of `qemu-system-<arch>`
+3. Optionally export `CX_PREFIX` if you are building for another architecture.
+4. Run `make ARCH=<arch> rootfs` to build stock rootfs image, require support of `dd`,`mkfs.ext2`, `mount -o loop`, `mktemp`.
+5. Run `ARCH=<arch> live_debug.sh` to boot in QEMU with gdb hooked (one should see a gdb session)
+6. telnet to `localhost:12345`, this is QEMU emulated serial port
+7. type `c` in the active gdb session and commence emulation.
+8. Congrats, enjoy your lunaix!
+(or submit an issue)
 
 
-### 4.4 Lunaix的功能配置
 
 
-Lunaix是一个可配置的内核,允许用户在编译前选择应当包含或移除的功能。
+## Booting the kernel
 
 
-使用`make config`来进行基于命令行的交互配置。呈现方式采用Shell的形式,所有的配置项按照类似于文件树的形式组织,如单个配置项为一个“文件”,多个配置项组成的配置组为一个目录,呈现形式为方括号`[]`包裹起来的项目。在提示符中输入`usage`并回车可以查看具体的使用方法。
+Since lunaix is a kernel, much like linux. It requires additional setup to do the magic. And, as in "much like linux", methods to make linux kernel boot can also apply to lunaix without or with little translation, as we will discuss below.
 
 
-一个最常用的配置可能就是`architecture_support/arch`了,也就是配置Lunaix所面向的指令集。比如,编译一个在x86_64平台上运行的Lunaix,在提示符中输入(**注意等号两侧的空格,这是不能省略的**):
+The bootloader part is generic, any bootloader, for example GRUB will work (not tested for UEFI, but I expect this would be an exception), or booting up in QEMU using `-kernel` option
 
 
-```
-/architecture_support/arch = x86_64
-```
+The kernel command line, is however, a bit differentiated.
+The syntax is similar, both takes form of space-separated array of `<key>=<val>` pairs or boolean `<flag>`.
 
 
-之后输入`exit`保存并推出。而后正常编译。
+Currently, lunaix support the following options
 
 
+| Option | Default Value | Optional | Usage |
+| ------ | ----          |  -----   | ----  |
+| console | `/dev/ttyS0`   | No | Specify the system console device, path within lunaix's devfs |
+| rootfs | `/dev/block/sda` | No | Specify the device contain rootfs image, path within lunaix's devfs |
+| init | `/init` | Yes | Path within rootfs of the `init` |
 
 
-### 4.5 设置内核启动参数
 
 
-在 make 的时候通过`CMDLINE`变量可以设置内核启动参数列表。该列表可以包含多个参数,通过一个或多个空格来分割。每个参数可以为键值对 `<key>=<val>` 或者是开关标志位 `<flag>`。目前 Lunaix 支持以下参数:
+## Submit an Issue
 
 
-+ `console=<dev>` 设置系统终端的输入输出设备(tty设备)。其中 `<dev>` 是设备文件路径 (注意,这里的设备文件路径是针对Lunaix,而非Linux)。关于LunaixOS设备文件系统的介绍可参考 Lunaix Wiki(WIP)
+If one ran into bug, one can submit an issue by filling up the following template
 
 
-如果`CMDLINE`未指定,则将会载入默认参数:
-
-```
-console=/dev/ttyFB0
 ```
 ```
+1. Describe the problem
+    "How does it look like, anything descriptive: visual, sonic, emotional experience"
 
 
-其中,`/dev/ttyFB0` 指向基于VGA文本模式的tty设备,也就是平时启动QEMU时看到的黑色窗口。
-
-当然,读者也可以使用 `/dev/ttyS0` 来作为默认tty设备,来验证 Lunaix 的灵活性与兼容性。该路径指向第一个串口设备。可以通过telnet协议在`12345`端口上进行访问——端口号可以自行修改QEMU启动参数(位于:`makeinc/qemu.mkinc`)来变更。
-
-**注意:** 根据操作系统和键盘布局的不同,telnet客户端对一些关键键位的映射(如退格,回车)可能有所差别(如某些版本的Linux会将退格键映射为`0x7f`,也就是ASCII的`<DEL>`字符,而非我们熟知`0x08`)。如果读者想要通过串口方式把玩Lunaix,请修改`usr/init/init.c`里面的终端初始化代码,将`VERASE`设置为正确的映射(修改方式可以参考 POSIX termios 的使用方式。由于Lunaix的终端接口的实现是完全兼容POSIX的,读者可以直接去查阅Linux自带的帮助`man termios`,无需作任何的转换)
+2. Steps to reproduce
+    "How you ran into this mess?"
 
 
-### 4.6 测试与体验 Lunaix
+3. Expected behaviour
+    "What do you intended/expected to achieve/to be"
 
 
-用户可以使用脚本`live_debug.sh` 来快速运行Lunaix。 该脚本自动按照默认的选项构建Lunaix,而后调用 `scripts/qemu.py` 根据配置文件生成QEMU启动参数
-(配置文件位于`scripts/qemus/`)
+4. Lunaix's panic trace (if applicable)
 
 
-由于该脚本的主要用途是方便作者进行调试,所以在QEMU窗口打开后还需要进行以下动作:
-
-1. 使用telnet连接到`localhost:12345`,这里是Lunaix进行标准输入输出所使用的UART映射(QEMU为guest提供UART实现,并将其利用telnet协议重定向到宿主机)
-2. 在GDB窗口中输入`c`然后回车,此时Lunaix开始运行。这样做的目的是允许在QEMU进行模拟前,事先打好感兴趣的断点。
-
-该脚本的运行需要设置 `ARCH=<isa>` 环境变量,其值需要与编译时制定的值一致。
-
-## 5. 运行,分支以及 Issue
-
-### 5.1 代码稳定性
-
-主分支一般是稳定的。因为在大多数情况下,我都会尽量保证本机运行无误后,push到该分支中。至于其他的分支,则是作为标记或者是开发中的功能。前者标记用分支一般会很快删掉;后者开发分支不能保证稳定性,这些分支的代码有可能没有经过测试,但可以作为Lunaix当前开发进度的参考。
-
-该系统是经过虚拟机和真机测试。如果发现在使用`make all`之后,虚拟机中运行报错,则一般是编译器优化问题。这个问题笔者一般很快就会修复,如果你使用别的版本的gcc(笔者版本11.2),出现了此问题,欢迎提issue。请参考[附录3:Issue的提交](#appendix3)
-
-## 6. 调试 Lunaix 内核
-
-除了[附录4:串口GDB远程调试](#appendix4)描述的一种用于实机调试的方式以外。LunaixOS还提供了LunaDBG调试套件。这是一个GDB客户端插件,包含了对GDB原生命令集的一些扩充,主要用于改善与简化内核调试的过程。目前包含以下几个命令:
-
-+ `vmrs [pid]` 列举进程`<pid>`的内存区域图(Memory Regions),如果`<pid>`未指定,则默认为正在运行的进程(smp=1)。
-+ `proc [pid]` 打印进程`<pid>`的进程控制块状态,如果`<pid>`未指定,则默认为正在运行的进程(smp=1)。
-+ `sched <threads | procs> [-l]` 查看调度器信息,接受两个参数:
-  + `threads` 打印所有依然在调度器中有注册的线程
-  + `procs` 打印所有依然在调度器中有注册的进程
-  + 可选开关 `-l` 决定是否以长列表打印(更详细的信息)
-
-该插件可以通过运行以下命令来进行安装:
-
-```shell
-./scripts/gdb/install_lunadbg
+5. Other clues that you think might be helpful
 ```
 
 ```
 
-## 7. 参考教程
 
 
-#### 没有!!
+## Limitations
+
+The development process is still in motion, any limitation can be categorised as a feature yet to be. However, some features that the author considered to be the most urgent and wish the matters to be discussed.
 
 
-本教程以及该操作系统的所有的架构设计与实现**均为原创**。
+Lunaix is under impression of uniprocessor and not capable of running in SMP environment. This is major held back of being a modern operating system. It has the highest priority among all other tasks
 
 
-对此,作者可以保证,该项目是做到了三个 “没有”:
+Lunaix do not have a mature (or even, an infant) user space ecosystem, mainly because the lack of a proper and sophisticated libc. Efforts need to be done for porting one to the target. However, given the author's tight schedule, this task is unfortunately still beyond the horizon.
 
 
-+ **没有** 参考任何现行的,关于操作系统开发的,教程或书籍。
-+ **没有** 参考任何开源内核的源代码(包括Linux)
-+ **没有** 基于任何开源内核的二次开发行为。
+## Acknowledgement
 
 
-为了制作LunaixOS,作者耗费大量时间和精力钻研技术文档,手册,理论书籍以及现行工业标准,从而尽量保证了知识的一手性。(这样一来,读者和听众们也算是拿到了二手的知识,而不是三手,四手,甚至n手的知识)。
+Albeit one must realise that the author has mentioned it in the very beginning, the author would like to emphaise **again** on the nature of this project.
 
 
-大部分的文档和标准可以在上述的[reference-material](reference-material/)中找到。
+As a personal challenge, this project is independently developed by the author single-handly, which means:
 
 
-当然,您也可以参考以下列表来了解现阶段的LunaixOS都使用了哪些资料(本列表会随着开发进度更新):
++ No reference to existing tutorials, books, online courses or any open source project that might provide any example, hint or working prototype on the design and implementation of kernel, subsystems or anythings that can be contributed towards a working prototype.
++ The author has no prior knowledge on Linux kernel through out 90% of the project time.
++ All knowledge on the kernel design is coming from the basic textbook on operating system theory, that is, *Modern Operating System* by Tanenbaum.
++ All knowledge on the system programming is coming from the basic textbook, that is, *Computer System - A Programmer's Perspective Third Edition*
++ All knowledge on the generic framework design and driver development are ingested from various technical specifications gathered across the Internet.
 
 
-#### 手册,标准,技术文档
+## References
 
 
-+ [Intel 64 and IA-32 Architecture Software Developer's Manual (Full Volume Bundle)](https://www.intel.com/content/www/us/en/developer/articles/technical/intel-sdm.html)
-+ [ACPI Specification (version 6.4)](https://uefi.org/sites/default/files/resources/ACPI_Spec_6_4_Jan22.pdf)
++ Intel 64 and IA-32 Architecture Software Developer's Manual (Full Volume Bundle)
++ ACPI Specification (version 6.4)
++ Devicetree Specification
++ ARM® Generic Interrupt Controller (v3)
++ Arm® Architecture Reference Manual (Profile-A)
++ Procedure Call Standard for the Arm® 64-bit Architecture (AArch64)
 + IBM PC/AT Technical Reference
 + IBM VGA/XGA Technical Reference
 + 82093AA I/O Advanced Programmable Controller (IOAPIC) (Datasheet)
 + IBM PC/AT Technical Reference
 + IBM VGA/XGA Technical Reference
 + 82093AA I/O Advanced Programmable Controller (IOAPIC) (Datasheet)
@@ -234,32 +243,20 @@ console=/dev/ttyFB0
 + Serial ATA: High Speed Serialized AT Attachment, Revision 3.2
 + SCSI Command Reference Manual
 + ATA/ATAPI Command Set - 3 (ACS-3)
 + Serial ATA: High Speed Serialized AT Attachment, Revision 3.2
 + SCSI Command Reference Manual
 + ATA/ATAPI Command Set - 3 (ACS-3)
-+ [ECMA-119 (ISO9660)](https://www.ecma-international.org/publications-and-standards/standards/ecma-119/)
++ ECMA-119 (ISO9660)
 + Rock Ridge Interchange Protocol (RRIP: IEEE P1282)
 + System Use Sharing Protocol (SUSP: IEEE P1281)
 + Tool Interface Standard (TIS) Portable Formats Specification (Version 1.1)
 + Rock Ridge Interchange Protocol (RRIP: IEEE P1282)
 + System Use Sharing Protocol (SUSP: IEEE P1281)
 + Tool Interface Standard (TIS) Portable Formats Specification (Version 1.1)
-
-**免责声明:PCI相关的标准最终解释权归PCI-SIG所有。此处提供的副本仅供个人学习使用。任何商用目的须向PCI-SIG购买。**
-
-#### 理论书籍
-
-+ *Computer System - A Programmer's Perspective Third Edition (CS:APP)* (Bryant, R & O'Hallaron, D)
++ *Computer System - A Programmer's Perspective Third Edition* (Bryant, R & O'Hallaron, D), a.k.a. CS:APP
 + *Modern Operating System* (Tanenbaum, A)
 + *Modern Operating System* (Tanenbaum, A)
++ Free VGA, http://www.osdever.net/FreeVGA/home.htm 
++ GNU CC & LD online documentation.
++ PCI Lookup, https://www.pcilookup.com/
++ Linux man pages
 
 
-#### 网站
-
-+ [OSDev](https://wiki.osdev.org/Main_Page) - 杂七杂八的参考,很多过来人的经验。作者主要用于上古资料查询以及收集;技术文献,手册,标准的粗略总结;以及开发环境/工具链的搭建。当然,上面的内容假设了x86_32架构的生态,对于其他的ISA支持,该网站便失去了其价值了。
-+ [FreeVGA](http://www.osdever.net/FreeVGA/home.htm) - 98年的资源!关于VGA编程技术的宝藏网站。
-+ GNU CC 和 GNU LD 的官方文档。
-+ [PCI Lookup](https://www.pcilookup.com/) - PCI设备编号查询
-
-#### 其他
-
-+ Linux Manual - 用于查询*nix API的一些具体行为。
-
-## 附录1:实现的 POSIX 系统接口 <a id="appendix1"></a>
+## Appendix 1: Supported System Call<a id="appendix1"></a>
 
 
-LunaixOS 提供对以下POSIX的系统接口的实现。内核定义的系统调用号可以参考 [LunaixOS系统调用表](docs/lunaix-syscall-table.md) 。
+**Unix/Linux/POSIX**
 
 1. `sleep(3)`
 1. `wait(2)`
 
 1. `sleep(3)`
 1. `wait(2)`
@@ -274,7 +271,7 @@ LunaixOS 提供对以下POSIX的系统接口的实现。内核定义的系统调
 1. `_exit(2)`
 1. `sigreturn(2)`
 1. `sigprocmask(2)`
 1. `_exit(2)`
 1. `sigreturn(2)`
 1. `sigprocmask(2)`
-1. `sigaction(2)`
+1. `signal(2)`
 1. `kill(2)`
 1. `sigpending(2)`
 1. `sigsuspend(2)`
 1. `kill(2)`
 1. `sigpending(2)`
 1. `sigsuspend(2)`
@@ -287,11 +284,11 @@ LunaixOS 提供对以下POSIX的系统接口的实现。内核定义的系统调
 2. `readdir(2)`
 2. `readlink(2)`
 2. `readlinkat(2)`
 2. `readdir(2)`
 2. `readlink(2)`
 2. `readlinkat(2)`
-2. `rmdir(2)`
-2. `unlink(2)`
-2. `unlinkat(2)`
-2. `link(2)`
-2. `fsync(2)`
+2. `rmdir(2)`
+2. `unlink(2)`
+2. `unlinkat(2)`
+2. `link(2)`
+2. `fsync(2)`
 2. `dup(2)`
 2. `dup2(2)`
 2. `symlink(2)`
 2. `dup(2)`
 2. `dup2(2)`
 2. `symlink(2)`
@@ -300,7 +297,7 @@ LunaixOS 提供对以下POSIX的系统接口的实现。内核定义的系统调
 2. `getcwd(2)`
 2. `rename(2)`※
 2. `mount(2)`
 2. `getcwd(2)`
 2. `rename(2)`※
 2. `mount(2)`
-2. `unmount` (a.k.a `umount(2)`)
+2. `unmount` (a.k.a `umount(2)`)
 2. `getxattr(2)`※
 2. `setxattr(2)`※
 2. `fgetxattr(2)`※
 2. `getxattr(2)`※
 2. `setxattr(2)`※
 2. `fgetxattr(2)`※
@@ -322,28 +319,43 @@ LunaixOS 提供对以下POSIX的系统接口的实现。内核定义的系统调
 4. `pthread_kill`
 4. `pthread_detach`
 4. `pthread_sigmask`
 4. `pthread_kill`
 4. `pthread_detach`
 4. `pthread_sigmask`
+4. `getuid`
+4. `getgid`
+4. `geteuid`
+4. `getegid`
+4. `getgroups`
+4. `setuid`
+4. `setgid`
+4. `seteuid`
+4. `setegid`
+4. `setgroups`
+4. `chroot`
+4. `fchmodat`
+4. `fchownat`
+4. `faccessat`
 
 
+**LunaixOS**
 
 
-( **※**:该系统调用暂未经过测试 )
+1. `yield`
+2. `geterrno`
+3. `realpathat`
 
 
-## 附录2:Issue的提交<a id="appendix3"></a>
+( **※**:Indicate syscall is not tested )
 
 
-假若Lunaix的运行出现任何问题,还请按照以下的描述,在Issue里面提供详细的信息。
+## Appendix 2: Debugging with GDB remotely via UART
 
 
-+ 可用于复现问题的描述和指引(如Lunaix运行平台的软硬件配置)
-+ 错误症状描述
-+ LunaixOS在panic时打印的调试信息(如无法复制,可以截图)
+**(((( Broken after a refactoring years ago, need rework ))))**
 
 
-## 附录3:串口GDB远程调试<a id="appendix4"></a>
+The LunaixOS kernel comes with a built-in GDB debugging server, which runs on COM1@9600Bd. However, LunaixOS must be in debug mode before involving GDB.
 
 
-**(该功能正在重构,目前不可用)**
+One could trigger the debug mode by writing a byte sequence `0x40` `0x63` `0x6D` `0x63`, to the same serial port. A text "DEBUG MODE" with magenta-coloured background shall be present at the bottom of the screen.
 
 
-LunaixOS内核集成了最基本的GDB远程调试服务器。可通过串口COM1在9600波特率上与之建立链接。但是,在将GDB与内核链接起来之前,还需要让内核处在调试模式下。
+Note that, whenever the text appears, the LunaixOS always halt all activities other than the debugging server, which means no scheduling and no external interrupt servicing. Users are now recommended to attach their GDB and drive the kernel with the debugging workflow.
 
 
-要进入调试模式,需要往串口(波特率如上)写入字节串 `0x40` `0x63` `0x6D` `0x63`。此时,如果屏幕底部出现一条品红色背景的`DEBUG` 字样,那么就说明LunaixOS已处在调试模式下。
+Currently, LunaixOS implements the required minimal server-side command subset required by GDB Remote Protocol, namely, `g`, `G`, `p`, `P`, `Q`, `S`, `k`, `?`, `m`, `M`, `X`. Which should be enough to cover most debugging activities.
 
 
-注意,在这个时候,LunaixOS会开始在`COM1`上监听GDB协议信息,并且暂停一切的活动(如调度,以及对外部中断的一切响应)。用户此时需要将GDB与其挂载,并使用GDB的工作流来指示内核下一步的动作。
+When debugging is finished, one shall disconnect with `kill` command. This command will not force LunaixOS to power down the computer, instead it just resume the execution (identical behavior as `c` command). However, disconnecting does not means exiting of debug mode. The debug mode is still actived and any subsequent GDB attaching request shall remain the highest priority amongst all other activity. One shall deactivate the debug mode by writing byte sequence `0x40` `0x79` `0x61` `0x79` to the port, after GDB detached.
 
 
-在目前,为了防止代码过于臃肿,LunaixOS实现的是GDB远程协议要求的最小服务端命令子集:`g`, `G`, `p`, `P`, `Q`, `S`, `k`, `?`, `m`, `M`, `X`。足以满足大部分的调试需求。
+### Limitations
 
 
-当结束调试的时候,请使用GDB的`kill`指令进行连接的断开。注意,这个指令会使得LunaixOS恢复所有暂停的活动,进入正常的运行序列,但并不会退出调试模式。GDB的挂载请求依然在LunaixOS中享有最高优先权。如果需要退出调试模式,需要往串口写入字节串:`0x40` `0x79` `0x61` `0x79`。
+Currently, one should avoid the use of `info stack`, `bt` or any other command that involves stack unwinding or stack backtracing. As it will somehow corrupt the stack layout and result in undefined behaviour. This issue should be addressed in future releases.