X-Git-Url: https://scm.lunaixsky.com/lunaix-os.git/blobdiff_plain/8c6f505faaa66e18cdca108dca549d4ad806a077..7909fc6dec8d1499c5b9fa331a810a77b08c84a2:/README.md
diff --git a/README.md b/README.md
index b8111ec..310fd75 100644
--- a/README.md
+++ b/README.md
@@ -3,140 +3,210 @@
- ç®ä½ä¸æ | English
+ ç®ä½ä¸æ | English
-# LunaixOS Project
-
-LunaixOS - ä¸ä¸ªç®åçï¼è¯¦ç»çï¼POSIXå
¼å®¹çï¼ä½æ¿ï¼ï¼ï¼å¸¦ææµéä¸ªäººé£æ ¼çæä½ç³»ç»ãå¼åè¿ç¨ä»¥è§é¢æç¨å½¢å¼å¨Bilibiliåç°ï¼[ãä»é¶å¼å§èªå¶æä½ç³»ç»ç³»åã](https://space.bilibili.com/12995787/channel/collectiondetail?sid=196337)ã
-
-## å½åè¿åº¦ä»¥åæ¯æçåè½
-
-该æä½ç³»ç»æ¯æx86æ¶æï¼è¿è¡å¨ä¿æ¤æ¨¡å¼ä¸ï¼éç¨å®å
æ ¸æ¶æï¼ç®åä»
æ¯æåæ ¸å¿ãå
åç»æéç¨ç»å
¸ç3:1ååï¼å³ä½3GiBä¸ºç¨æ·å°å空é´ï¼0x400000 ~ 0xBFFFFFFFï¼ï¼å
æ ¸å°å空é´éæ å°è³é«1GiBï¼0xC0000000 ~ 0xFFFFFFFFï¼ãå
åç详ç»å¸å±å¯åè[LunaixOSå
åå°å¾](docs/img/lunaix-os-mem.png)
-
-å¨ä¸è¿°å表ä¸ï¼åååºç®åææ¯æçæç¨åè½åç¹æ§ãå表项æç
§é¡¹ç®æ¶é´æ³è¿è¡ååºæåã
-
-+ 使ç¨Multibootè¿è¡å¼å¯¼å¯å¨
-+ APIC/IOAPICä½ä¸ºä¸æç®¡çå¨å计æ¶å¨
-+ ACPI
-+ èæå
å
-+ å
å管ç䏿éå页ï¼Demand Pagingï¼
-+ é®çè¾å
¥
-+ å¤è¿ç¨
-+ 50个常è§çLinux/POSIXç³»ç»è°ç¨ï¼[éå½1](#appendix1)ï¼
-+ ç¨æ·æ¨¡å¼
-+ ä¿¡å·æºå¶
-+ PCI 3.0
-+ PCIe 1.1 (WIP)
-+ Serial ATA AHCI
-+ æä»¶ç³»ç»
- + èææä»¶ç³»ç»
- + ISO9660
- + åç
- + Rock Ridgeæå± (WIP)
-+ è¿ç¨GDB串å£è°è¯ (COM1@9600Bd)
-
-å·²ç»æµè¯è¿çç¯å¢ï¼
-
-+ QEMU (>=7.0.0)
-+ Bochsï¼SATAåè½ä¸æ¯æï¼
-+ Virtualbox
-+ Dell G3 3779
-
-## ç®å½ç»æ
-
-| | |
-| ----------------------------------------- | ---------------------------- |
-| [lunaix-os](lunaix-os/) | LunaixOSæºä»£ç |
-| [slides](slides/) | è§é¢ä¸æç¨çå¹»ç¯çåè¡¥å
ææ |
-| [reference-material](reference-material/) | æ åï¼ææ¯ææ¡£ååèæç® |
-
-## ç¼è¯ä¸æå»º
-
-### ç¯å¢æå»º
-
-æå»ºè¯¥é¡¹ç®éè¦æ»¡è¶³ä»¥ä¸æ¡ä»¶ï¼
-
-+ gcc (ç®æ å¹³å°: i686-elf)
+# The Lunaix Project
+
+The Lunaix, LunaixOS, or Lunaix kernel to be exact, is a multi-architectural general purpose kernel written from scratch by the author *independently*. And it is the author's years-long personal endeavor and also a challenge to oneself for writing a functioning kernel **without** any external reference such as existing implementation, tutorial and books (with code) on kernel design.
+
+The overall design is aimed to be modern and POSIX-compliance. In a nutshell, Lunaix 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.
+
+To give a better understanding (and appreciation) of the works, the following list has been compiled with all feature that lunaix currently supported:
+
++ Multi-ISA
+ + x86_32
+ + x86_64
+ + Aarch64 (W.I.P)
++ Boot protocol abstraction
++ Platform resource management and definition
+ + ACPI
+ + Devicetree
++ Memory management
+ + multi-architecture 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
++ Multi-threadingg and multi-tasking
+ + Protection level and memory space isolation
+ + Native threading support (no more lightweight process nonsense)
+ + Signal handling
+ + Kernel-level multi-tasking (i.e. kernel threads)
+ + Round-robin scheduling (for now)
+ + Fully-preemptive kernel design
+ + taskfs: file system interface to process and threads
++ File system
+ + virtual file system framework
+ + ...with POSIX compliant file system interface
+ + mountable file system
+ + 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
+ + architectural decoupled 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 request caching
+ + asynchronous blkio operation in nature
++ Serial I/O
+ + POSIX-compliant serial port model
+ + serial device driver framework (part of driver framework)
++ Caching Infrastructure
+ + primtive: generic sparse associative array
+ + LRU replacement policy and pooling
+ + kernel daemon for periodical 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 driver that is currently support see below:
+
++ Arhcitecture Neutral
+ + UART 16650-compatible driver
+ + Serial ATA AHCI
+ + 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)
+
+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!)
+
+## Project Structure
+
+| | |
+|-----|------|
+| [lunaix-os](../lunaix-os/) | LunaixOS source code |
+| [slides](../slides/) | Slides used in my videos |
+| [reference-material](../reference-material/)| References |
+
+## Compile and Build
+
+You will need following dependencies in order to build Lunaix
+
++ gcc (recommend v12+)
+ binutils
+ make
-+ xorriso
-+ grub-mkrescue
++ python (recommend v3.11+)
-**注æï¼gccä¸è½æ¯æ¬æºèªå¸¦çï¼å¿
é¡»è¦ä»æºç ç¼è¯ï¼å¹¶é
ç½®ç®æ å¹³å°ä¸ºï¼`i686-elf`ï¼ä»¥è¿è¡äº¤åç¼è¯ãé
ç½®è¿ç¨å¯åè[éå½äºï¼ç¼è¯gccä½ä¸ºäº¤åç¼è¯å¨](#appendix2)ã**
+And also one should have environment variable `ARCH=` exported, where `` is one of the supported arhcitecture (`x86_32`, `x86_64`, `arm64`)
-### Dockeréå
+The following `make` actions are available to use.
-对äºå¼åç¯å¢ï¼æ¬é¡¹ç®ä¹æä¾äº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 |
-### æå»ºé项
+A successful build will give `build/bin/kernel.bin`.
-åè¥æ¡ä»¶æ»¡è¶³ï¼é£ä¹å¯ä»¥ç´æ¥æ§è¡`make all`è¿è¡æå»ºï¼å®æåå¯å¨çæç`build`ç®å½ä¸æ¾å°å¯å¼å¯¼çisoã
+**Please note: this is the kernel, not a bootable image, it require a bootloader to boot and specify the rootfs.**
-æ¬é¡¹ç®æ¯æçmakeå½ä»¤ï¼
-| å½ä»¤ | ç¨é |
-| ------------------------ | ----------------------------------------------- |
-| `make all` | æå»ºéåï¼`-O2`ï¼ä½ç¦ç¨CSEç¸å
³çä¼å项 **â»** ï¼ |
-| `make instable` | æå»ºéåï¼`-O2`ï¼å¼å¯CSEç¸å
³ä¼åï¼ |
-| `make all-debug` | æå»ºéåè°è¯ç¨çéåï¼`-Og`ï¼ |
-| `make run` | 使ç¨QEMUè¿è¡buildç®å½ä¸çéå |
-| `make debug-qemu` | æå»ºå¹¶ä½¿ç¨QEMUè¿è¡è°è¯ |
-| `make debug-bochs` | æå»ºå¹¶ä½¿ç¨Bochsè¿è¡è°è¯ |
-| `make debug-qemu-vscode` | ç¨äºvscodeæ´å |
-| `make clean` | å é¤buildç®å½ |
+## Booting the kernel
-**â»ï¼ç±äºå¨`-O2`模å¼ä¸ï¼GCCä¼è¿è¡CSEä¼åï¼è¿å¯¼è´LunaixOSä¼åºç°ä¸äºé叏奿ªã离谱çbugï¼ä»èå½±åå°åºæ¬è¿è¡ãå
·ä½åå æå¾
è°æ¥ã**
+Since lunaix is a kernel, much like linux. It require additional setup to make the magic. And, as it is "much like linux", methods to make linux kernel boot can also apply to lunaix without or with little translation, as we will discuss below.
-## è¿è¡ä»¥åIssue
+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
-è¿è¡è¯¥æä½ç³»ç»éè¦ä¸ä¸ªèæç£çéåï¼å¯ä»¥ä½¿ç¨å¦ä¸å½ä»¤å¿«éå建ä¸ä¸ªï¼
+The kernel command line, is however, a bit differentiated.
+The syntax is similar, both takes form of space-separated array of `=` pairs or boolean ``.
-```bash
-qemu-img create -f vdi machine/disk0.vdi 128M
-```
+Currently, lunaix support the following options
-å¦æä½ æ³è¦ä½¿ç¨å«çç£çéåï¼éè¦ä¿®æ¹`configs/make-debug-tool`
+| 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` |
-æ¾å°è¿ä¸è¡ï¼
+### A quick 'Get Started'
-```
--drive id=disk,file="machine/disk0.vdi",if=none \
-```
+One can use the `live_debug.sh` provided in the lunaix root directory to quickly bring up the system with default parameter (which is used by the author for debugging).
-ç¶åæ`machine/disk0.vdi`æ¿æ¢æä½ çç£çè·¯å¾ã
+Following the steps:
-æå¾å¤åæ³å»å建ä¸ä¸ªèæç£çï¼æ¯å¦[qemu-img](https://qemu-project.gitlab.io/qemu/system/images.html)ã
+1. Select a architecture ``
+2. Check the compilation prerequisites and presence of `qemu-system-`
+3. Run `make ARCH= user` to build the stock user program
+4. Run `make ARCH= rootfs` to build stock rootfs image, require support of `dd`ï¼`mkfs.ext2`, `mount -o loop`, `mktemp`.
+5. Run `ARCH= live_debug.sh` to boot in QEMU with gdb hooked (one should see a gdb session)
+6. telenet to `localhost:12345`, this is QEMU emulated serial port
+7. type `c` in the active gdb session and commence emualtion.
+8. Congrats, enjoy your lunaix!
+(or submit an issue)
-å¨å¤§å¤æ°æ
åµä¸ï¼æé½ä¼å°½éä¿è¯æ¬æºè¿è¡æ 误åï¼pushå°ä»åºä¸ãåæ¶ï¼è¯¥ç³»ç»æ¯ç»è¿èææºåçæºæµè¯ã妿åç°å¨ä½¿ç¨`make all`ä¹åï¼èææºä¸è¿è¡æ¥éï¼åä¸è¬æ¯ç¼è¯å¨ä¼åé®é¢ãè¿ä¸ªé®é¢ç¬è
ä¸è¬å¾å¿«å°±ä¼ä¿®å¤ï¼å¦æä½ 使ç¨å«ççæ¬çgccï¼ç¬è
çæ¬11.2ï¼ï¼åºç°äºæ¤é®é¢ï¼æ¬¢è¿æissueã请åè[éå½3ï¼Issueçæäº¤](#appendix3)
-ä¸é¢ååºä¸äºå¯è½ä¼åºç°çé®é¢ã
+## Submit an Issue
-#### é®é¢#1ï¼ QEMUä¸8042æ§å¶å¨æç¤ºæ¾ä¸å°
+If one ran into bug, one can submit an issue by filling up the following template
-è¿æ¯QEMUé
ç½®ACPIæ¶çä¸ä¸ªbugï¼å¨7.0.0çä¸ä¿®å¤äºã
+```
+1. Describe the problem
+ "How does it look like, anything descriptive: visual, sonic, emotional experience"
+2. Steps to reproduce
+ "How you ran into this mess?"
+3. Expected behaviour
+ "What do you intended/expected to achieve/to be"
+4. Lunaix's panic trace (if applicable)
+5. Other clues that you think might be helpful
+```
-#### é®é¢#2ï¼å¤è¿ç¨è¿è¡æ¶ï¼å¶å°ä¼åºç°General Protectioné误
-è¿å¾å¤§æ¦çæ¯åºç°äºç«ææ¡ä»¶ãè½ç¶æ¯ç¸å½ä¸å¯è½çãä½å¦æåºç°äºï¼è¿æ¯è¯·æissueã
+## Limitations
-#### é®é¢#3ï¼Bochsæ æ³è¿è¡ï¼æç¤ºæ¾ä¸å°AHCIæ§å¶å¨
+The development process is still in motion, any limitation can be categorised as yet to be finished feature. However, some feature that the author considered to be the most urgent and wish the matters to be discussed.
-æ£å¸¸ï¼**å 为Bochs䏿¯æSATA**ã请使ç¨QEMUæVirtualBoxã
+Lunaix is under assumption 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 is do not have a mature 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.
-**没æï¼ï¼** æ¬æç¨ä»¥å该æä½ç³»ç»å为ååï¼æ²¡æåºäºä»»ä½å¸é¢ä¸ç°è¡çæä½ç³»ç»å¼åæç¨ï¼ä¸å¹¶éæ¯åºäºä»»ä½ç弿ºå
æ ¸çäºæ¬¡å¼åã
+## 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 tutorial, books, online course or any open source project that might provide example, hint or working prototype on the design and implementation of kernel, it's various 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 comming from the basic textbook on operating system theory, that is, *Modern Operating System* by Tanenbaum.
++ All knowledge on the system programming is commingg 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 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)
@@ -149,32 +219,18 @@ qemu-img create -f vdi machine/disk0.vdi 128M
+ 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)
-
-**å
责声æï¼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)
-+ ãæ±ç¼è¯è¨ãï¼çç½ï¼ - ç¨äºå
¥é¨Intelè¯æ³çx86æ±ç¼ï¼å¯¹äºAT&Tè¯æ³ï¼æ¨èé
读CS:APPï¼
-+ ~~ãå¾®æºåç䏿¥å£ææ¯ã - ç¨äºå¤§è´äºè§£x86æ¶æçå¾®æºä½ç³»ï¼æ´å ç»è´çäºè§£å¯ä»¥é
读Intel Manualï¼~~ ï¼å·²è¿æ¶ï¼æ¨èé
读CS:APPï¼
-
-#### ç½ç«
++ 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) - æä¸æå
«çåèï¼å¾å¤è¿æ¥äººçç»éªãä½è
主è¦ç¨äºä¸å¤èµææ¥è¯¢ä»¥åæ¶éï¼ææ¯æç®ï¼æåï¼æ åçç²ç¥æ»ç»ï¼ä»¥åå¼åç¯å¢/å·¥å
·é¾çæå»ºã
-+ [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ï¼æ¯æçç³»ç»è°ç¨
+## Appendix 1: Supported System Call
**Unix/Linux/POSIX**
@@ -228,117 +284,40 @@ qemu-img create -f vdi machine/disk0.vdi 128M
2. `mmap(2)`
2. `munmap(2)`
2. `execve(2)`
-
-**LunaixOSèªæ**
+3. `poll(2)` (via `pollctl`)
+3. `epoll_create(2)` (via `pollctl`)
+3. `epoll_ctl(2)` (via `pollctl`)
+3. `epoll_wait(2)` (via `pollctl`)
+4. `pthread_create`
+4. `pthread_self`
+4. `pthread_exit`
+4. `pthread_join`
+4. `pthread_kill`
+4. `pthread_detach`
+4. `pthread_sigmask`
+
+**LunaixOS**
1. `yield`
2. `geterrno`
3. `realpathat`
-4. `syslog`
-
-( **â»**ï¼è¯¥ç³»ç»è°ç¨ææªç»è¿æµè¯ )
-
-## éå½2ï¼ç¼è¯gccä½ä¸ºäº¤åç¼è¯å¨
-
-注æï¼gccéè¦ä»æºç æå»ºï¼å¹¶é
置为交åç¼è¯å¨ï¼å³ç®æ å¹³å°ä¸º`i686-elf`ãä½ å¯ä»¥ä½¿ç¨æ¬é¡¹ç®æä¾ç[èªå¨åèæ¬](slides/c0-workspace/gcc-build.sh)ï¼è¿å°ä¼æ¶µçgccåbinutilsæºç çä¸è½½ï¼é
ç½®åç¼è¯ï¼æ²¡ä»ä¹æ¶é´å»æç£¨èæ¬ï¼ç®ååªç¥éå¨ç¬è
çUbuntuç³»ç»ä¸å¯ä»¥è¿è¡ï¼ã
-
-**æ¨è**æå¨ç¼è¯ã以ä¸ç¼è¯æ¥éª¤æ¬è¿èªï¼
-
-**é¦å
å®è£
æå»ºä¾èµé¡¹ï¼**
-
-```bash
-sudo apt update &&\
- apt install -y \
- build-essential \
- bison\
- flex\
- libgmp3-dev\
- libmpc-dev\
- libmpfr-dev\
- texinfo
-```
-
-**å¼å§ç¼è¯ï¼**
-
-1. è·å[gcc](https://ftp.gnu.org/gnu/gcc/)å[binutils](https://ftp.gnu.org/gnu/binutils)æºç
-2. è§£åï¼å¹¶å¨å级ç®å½ä¸ºgccåbinutilæ°å»ºä¸é¨çbuildæä»¶å¤¹
-
-ç°å¨åè®¾ä½ çç®å½ç»æå¦ä¸ï¼
-
-```
-+ folder
- + gcc-src
- + binutils-src
- + gcc-build
- + binutils-build
-```
-
-3. ç¡®å®gccåbinutilå®è£
çä½ç½®ï¼å¹¶è®¾ç½®ç¯å¢åéï¼`export PREFIX=<å®è£
è·¯å¾>` ç¶å设置PATHï¼ `export PATH="$PREFIX/bin:$PATH"`
-4. è®¾ç½®ç®æ å¹³å°ï¼`export TARGET=i686-elf`
-5. è¿å
¥`binutils-build`è¿è¡é
ç½®
-
-```bash
-../binutils-src/configure --target="$TARGET" --prefix="$PREFIX" \
- --with-sysroot --disable-nls --disable-werror
-```
-
-ç¶å `make && make install`
-
-6. ç¡®ä¿ä¸è¿°ç`binutils`å·²ç»æ£å¸¸å®è£
ï¼æ§è¡ï¼`which i686-elf-as`ï¼åºè¯¥ä¼ç»åºä¸ä¸ªä½äºä½ å®è£
ç®å½ä¸çè·¯å¾ã
-6. è¿å
¥`gcc-build`è¿è¡é
ç½®
-
-```bash
-../gcc-src/configure --target="$TARGET" --prefix="$PREFIX" \
- --disable-nls --enable-languages=c,c++ --without-headers
-```
-
-ç¶åç¼è¯å®è£
ï¼å峿§è½ï¼å¤§çº¦10~20åéï¼ï¼
-
-```bash
-make all-gcc &&\
- make all-target-libgcc &&\
- make install-gcc &&\
- make install-target-libgcc
-```
-
-8. éªè¯å®è£
ï¼æ§è¡`i686-elf-gcc -dumpmachine`ï¼è¾åºåºè¯¥ä¸ºï¼`i686-elf`
-
-**å°æ°ç¼è¯å¥½çGCCæ°¸ä¹
æ·»å å°`PATH`ç¯å¢åé**
-
-è½ç¶è¿æ¯ä¸ä¸ªå¸¸è¯æ§çæä½ï¼ä½èèå°è®¸å¤äººé½ä¼å¿½ç¥è¿ä¸ä¸ªé¢å¤çæ¥éª¤ï¼å¨è¿éç¹æ¤ååºæç¤ºã
-
-è¦æ³å®ç°è¿ä¸ç¹ï¼åªéè¦å¨shellçé
ç½®æä»¶çæ«å°¾æ·»å ï¼`export PATH="<ä¸è¿°çå®è£
è·¯å¾>/bin:$PATH"`ã
-
-è¿ä¸ªé
ç½®æä»¶æ¯åå³äºä½ 使ç¨çshellï¼å¦zshå°±æ¯`${HOME}/.zshrc`ï¼bash忝`${HOME}/.bashrc`ï¼æè
ä½ å«éº»ç¦çï¼æå¾åºåï¼ä½ ä¹å¯ä»¥ç´æ¥ä¿®æ¹å
¨å±ç`/etc/profile`æä»¶ï¼ä¸å³æ°¸é¸ï¼ä½ä¸æ¨èè¿æ ·åï¼ã
-
-è³äºå
¶ä»çæ
åµï¼ç±äºè¿ä¸ªæ¥éª¤å
¶å®å¨ç½ä¸æ¯éå¤å¯æ¥çï¼æä»¥å°±ä¸å¨è¿éèµè¿°äºã
-
-## éå½3ï¼Issueçæäº¤
-
-ç±äºç®åLunaixOS没æä¸ä¸ªå®å强大çå
æ ¸è¿½è¸ªåè½ãåè¥Lunaixçè¿è¡åºç°ä»»ä½é®é¢ï¼è¿è¯·æç
§ä»¥ä¸çæè¿°ï¼å¨Issueé颿ä¾è¯¦ç»çä¿¡æ¯ã
-æå¥½æä¾ï¼
+( **â»**ï¼Indicate syscall is not tested )
-+ å¯ç¨äºå¤ç°é®é¢çæè¿°åæå¼ï¼å¦Lunaixè¿è¡å¹³å°ç软硬件é
ç½®ï¼
-+ é误çç¶æè¿°
-+ ï¼å¦å¯è½ï¼è¿è¡æªå¾
-+ éè¯¯æ¶æ¯ï¼å¦æç»åºï¼
-+ å¯åå¨ç¶æçdump
-+ ï¼å¦å¯è½ï¼æä¾é误åçæ¶ï¼EIPéè¿çæä»¤ï¼ç²¾ç¡®å°å½æ°ï¼ãå¦æä½¿ç¨`make all-debug`ï¼ä¼æä¾`build/kdump.txt`ï¼ä½ å¯ä»¥å¨è¿éé¢å®ä½ãæè
ä¹å¯ä»¥ç´æ¥`objdump`
-+ ï¼å¦å¯è½ï¼èæå
åæ å°ä¿¡æ¯ï¼QEMUä¸å¯ä½¿ç¨`info mem`æ¥çï¼ã
+## Appendix 2: Debugging with GDB remotely via UART
-## éå½4ï¼ä¸²å£GDBè¿ç¨è°è¯
+**(((( Not working yet, need rework ))))**
-LunaixOSå
æ ¸éæäºæåºæ¬çGDBè¿ç¨è°è¯æå¡å¨ãå¯éè¿ä¸²å£COM1å¨9600æ³¢ç¹çä¸ä¸ä¹å»ºç«é¾æ¥ã使¯ï¼å¨å°GDBä¸å
æ ¸é¾æ¥èµ·æ¥ä¹åï¼è¿éè¦è®©å
æ ¸å¤å¨è°è¯æ¨¡å¼ä¸ã
+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.
-è¦è¿å
¥è°è¯æ¨¡å¼ï¼éè¦å¾ä¸²å£ï¼æ³¢ç¹çå¦ä¸ï¼åå
¥åè串 `0x40` `0x63` `0x6D` `0x63`ãæ¤æ¶ï¼å¦æå±å¹åºé¨åºç°ä¸æ¡å红è²èæ¯ç`DEBUG` åæ ·ï¼é£ä¹å°±è¯´æLunaixOSå·²å¤å¨è°è¯æ¨¡å¼ä¸ã
+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ä¼å¼å§å¨`COM1`ä¸çå¬GDBå议信æ¯ï¼å¹¶ä¸æåä¸åçæ´»å¨ï¼å¦è°åº¦ï¼ä»¥å对å¤é¨ä¸æçä¸åååºï¼ãç¨æ·æ¤æ¶éè¦å°GDBä¸å
¶æè½½ï¼å¹¶ä½¿ç¨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.
-å¨ç®åï¼ä¸ºäºé²æ¢ä»£ç è¿äºèè¿ï¼LunaixOSå®ç°çæ¯GDBè¿ç¨åè®®è¦æ±çæå°æå¡ç«¯å½ä»¤åéï¼`g`, `G`, `p`, `P`, `Q`, `S`, `k`, `?`, `m`, `M`, `X`ã足以满足大é¨åçè°è¯éæ±ã
+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.
-å½ç»æè°è¯çæ¶åï¼è¯·ä½¿ç¨GDBç`kill`æä»¤è¿è¡è¿æ¥çæå¼ã注æï¼è¿ä¸ªæä»¤ä¼ä½¿å¾LunaixOSæ¢å¤æææåçæ´»å¨ï¼è¿å
¥æ£å¸¸çè¿è¡åºåï¼ä½å¹¶ä¸ä¼éåºè°è¯æ¨¡å¼ãGDBçæè½½è¯·æ±ä¾ç¶å¨LunaixOSä¸äº«ææé«ä¼å
æã妿éè¦éåºè°è¯æ¨¡å¼ï¼éè¦å¾ä¸²å£åå
¥åè串ï¼`0x40` `0x79` `0x61` `0x79`ã
+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.
-### GDBè°è¯æ³¨æäºé¡¹
+### Limitations
-å¨è°è¯ä¸ï¼è¯·é¿å
使ç¨`info stack`ï¼`bt`æè
任使¶å **æ å±å¼ï¼Stack Unwindingï¼** æè
**æ åæº¯ï¼Stack Backtracingï¼** çæä»¤ãå¦åï¼LunaixOS徿å¯è½ä¼åºç° **ä¸å¯é¢æçè¡ä¸º** ã
+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.