Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ Then your editor knows how to find the source files and derives syntax highlight

This project is licensed under [MIT License](LICENSE).

## Documentation

For detailed technical documentation, please visit [docs/README.md](docs/README.md).

## Feature

### AMD64
Expand Down
21 changes: 21 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# CoolPotOS 文档

本目录包含CoolPotOS操作系统的详细文档,分为以下两个主要部分:

## 1\. 内核模块 Kernel Modules



内核模块是操作系统内核的扩展部分,运行在与内核相同的地址空间与特权级中,具有完全的内核访问权限。CoolPotOS的内核模块为elf格式的动态链接库,后缀名为\*.km。

* [中文文档](zh_cn/kernel_module.md)
* [English Documentation](en_us/kernel_module.md)

## 2\. 子系统 Subsystems



CoolPotOS内核包含多个子系统,每个子系统负责不同的功能领域,共同协作提供完整的操作系统功能。

* [中文文档](zh_cn/subsystem.md)
* [English Documentation](en_us/subsystem.md)
28 changes: 28 additions & 0 deletions docs/en_us/kernel_module.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# Kernel Modules

## Introduction

Kernel modules are part of the operating system kernel, running in the same address space and privilege level as the kernel, with full kernel access rights.
`CP_Kernel` kernel modules are `elf` format dynamically linked libraries with the extension `*.km`.

> Once a kernel module is loaded into the kernel, it cannot be unloaded and will only take effect at the next system restart.

Current kernel modules:

- `extfs` - ext file system implementation

## Source Code Directory

Located in the project's `module` directory, containing kernel module source code development header files and source code for each kernel module.

* all_include/cp_kernel.h: Common header files for kernel module development, including basic library functions and type encapsulation.
* all_include/fs_subsystem.h: Interface export for the file system subsystem.
* all_include/mem_subsystem.h: Interface export for the memory management subsystem.
* all_include/int_subsystem.h: Interface export for the interrupt and clock subsystem.
* all_include/driver_subsystem.h: Interface export for the device management subsystem.
* all_include/errno.h: Error code definitions.
* all_include/lock.h: Lock types and interface definitions.

## Examples

The source code for the `extfs` kernel module is located in the `module/extfs` directory. Other kernel modules can refer to this project as a template to create new kernel modules in the `module` directory.
90 changes: 90 additions & 0 deletions docs/en_us/subsystem.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# CP_Kernel Subsystems

## Introduction

Currently, the CPOS kernel has the following subsystems:

- Multi-tasking management subsystem
- Memory management subsystem
- Interrupt and clock subsystem
- Device management subsystem
- File system subsystem
- Services and modules (not subsystems, but functional components)

## Process Subsystem (Multi-tasking Management Subsystem)

Its source code is located in the `task` directory, responsible for process/thread creation, suspension, destruction, process signals and communication, and also includes the scheduler implementation.

- eevdf.c: Core implementation of the Earliest Eligible Virtual Deadline First scheduling algorithm.
- futex.c: Implementation of thread suspension/wakeup mechanism.
- ipc.c: Implementation of inter-process communication mechanism.
- prsys.c: Implementation of system calls related to multi-tasking, such as fork, exec, clone, etc.
- signal.c: Implementation of signal mechanism. (TODO: Not yet completed)
- scheduler.c: General encapsulation part of the scheduler, decoupled from specific algorithm implementations.
- poll.c: Implementation of I/O multiplexing mechanism.

## Memory Subsystem (Memory Management Subsystem)

Its source code is located in the `mem` directory, including physical page frame allocation management, memory statistics, kernel heap allocator implementation, and lazy allocator implementation.

- heap/: Kernel heap allocator implementation, the `plalloc` allocator written by `copi143`.
- lazyalloc.c: Lazy allocator implementation.
- frame.c: Physical page frame allocator implementation.
- memstats.c: Memory statistics implementation.
- page.c: Page table management implementation.
- bitmap.c: Bitmap implementation, page frame allocator uses bitmap to manage physical memory.
- hhdm.c: Related to high half direct mapping memory offset acquisition and some virtual-physical address conversion.

## Interrupt and Clock Subsystem

Its source code exists in both `cpu` and `driver` directories and is not an independent subsystem.

- cpu/error_handle.c: Kernel exception handling implementation.
- cpu/idt.c: Interrupt descriptor table initialization and interrupt handler registration.
- cpu/empty_interrupt.c: Debug check for interrupt handlers that do not exist.
- cpu/cpustats.c: High-precision real-time counter implementation (provides the scheduler with a real-time clock source).
- driver/acpi/hpet.c: High Precision Event Timer (HPET) driver, calibrates high-precision real-time counter and `local apic` timer.
- driver/acpi/apic.c: Initialization of the Advanced Programmable Interrupt Controller (including initialization of `local apic` and `I/O apic`).

## Device Subsystem (Device Management Subsystem)

Its source code is located in the `driver` directory, responsible for device registration and management, including common device driver implementations.

- /fs/devfs.c: Device file system implementation, which is a mapping of the device list and also provides some device operation interfaces to user mode and the kernel itself.
- pci/: PCI bus and its associated device driver implementations.
- acpi/: Advanced Configuration and Power Interface (ACPI) related driver implementations, including power management.
- iic/: I2C bus and its associated device driver implementations (TODO: Not yet tested).
- input/: Input device driver implementations, including keyboard and mouse drivers.
- sound/: Built-in sound card driver implementations, currently only includes `PC Speaker` and `sb16` drivers.
- dma.c: DMA controller driver implementation.
- rtc.c: CMOS chip driver implementation, providing real-time clock functionality.
- gop.c: Basic Graphics Output Protocol driver implementation, providing simple graphics output functionality.
- serial.c: Serial port driver implementation, providing serial communication functionality.
- tty.c: Terminal device driver implementation, providing character terminal functionality.
- urandom.c: Random number device driver implementation, providing pseudo-random number generation functionality.
- zero.c: Zero device and null device driver implementations, providing read-zero and write-discard functionality.
- vdisk.c: Device manager implementation, whose operation interfaces and device information are represented by `devfs`.

## File System Subsystem

Its source code is located in the `fs` directory, responsible for file system registration and management, and has built-in implementations of `fatfs` and `iso9660` file systems.

- vfs.c: Virtual file system management, providing file system registration and mounting, and encapsulating file operation interfaces.
- fatfs/: `FAT` file system implementation.
- devfs.c: Device file system implementation, part of the device management subsystem.
- iso9660.c: `ISO9660` file system implementation.
- tmpfs.c: Temporary file system implementation, providing a memory-based file system.
- pipe.c: Pipe implementation, providing a pipe mechanism for inter-process communication.
- modfs.c: Module file system implementation, providing kernel module loading and management functionality.
- partition.c: Partition management implementation, providing functionality for identifying and operating disk partitions, and mounting the identified partitions as virtual block devices to `devfs`.

## Services and Modules

Its source code is located in the `service` and `kmod` directories and is not an independent subsystem but a functional component of the kernel.

- service/killer.c: Kernel service responsible for recycling zombie processes.
- service/syscall.c: Kernel service providing system call interfaces.
- service/sysuser.c: Kernel service providing session and permission management.
- kmod/dlinker.c: Dynamic linker implementation, providing dynamic loading and symbol resolution functionality for kernel modules.
- kmod/module.c: Encapsulates kernel modules loaded by the bootloader and mounts files to `modfs`.
- kmod/interface.c: Provides interfaces for kernel modules to interact with the kernel itself.
4 changes: 4 additions & 0 deletions readme/README-fr-FR.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ Cela permet à votre éditeur de localiser les fichiers sources et d'améliorer

Ce projet est sous [Licence MIT](LICENSE).

## Documentation

Pour une documentation technique détaillée, veuillez consulter [docs/README.md](docs/README.md).

## Fonctionnalités

### AMD64
Expand Down
4 changes: 4 additions & 0 deletions readme/README-ja-JP.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ xmake project -k compile_commands

このプロジェクトは[MITライセンス](LICENSE)の下でライセンスされています。

## ドキュメント

詳細な技術ドキュメントについては、[docs/README.md](docs/README.md)を参照してください。

## Feature

### AMD64
Expand Down
4 changes: 4 additions & 0 deletions readme/README-zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ xmake project -k compile_commands

该项目完全遵循 MIT 协议,任何人都可以免费使用它,另见 [LICENSE](/LICENSE)。

## 文档

详细说明请访问 [docs/README.md](/docs/README.md)。

## 支持功能

### AMD64
Expand Down