红联Linux门户
Linux帮助

Thor-os:使用C++编写的操作系统

发布时间:2016-08-25 10:05:17来源:topspeedsnail.com作者:斗大的熊猫
thor-os是我在Github上看到的一个项目,它是使用C++和少量汇编语言编写的64位操作系统。这个项目是主要是为了学习。
thor-os的源代码:https://github.com/wichtounet/thor-os
Thor-os:使用C++编写的操作系统
 
特性:
目前只支持x86_64架构
抢占式多进程
键盘鼠标驱动
ACPI支持
读写ATA硬盘
支持FAT32文件系统
 
这个操作系统重要的内核入口函数(类似Linux内核的start_kernel()函数)kernel.cpp:
 
void kernel_main(){
//Make sure stack is aligned to 16 byte boundary
asm volatile("and rsp, -16");
arch::enable_sse();
gdt::flush_tss();
// Necessary for logging with Qemu
serial::init();
//Starting from here, the logging system can stop saving early logs
logging::finalize();
// Setup interrupts
interrupt::setup_interrupts();
//Compute virtual addresses for paging
paging::early_init();
//Init the virtual allocator
virtual_allocator::init();
//Prepare basic physical allocator for paging init
physical_allocator::early_init();
//Init all the physical
paging::init();
//Finalize physical allocator initialization for kalloc
physical_allocator::init();
//Init dynamic memory allocation
kalloc::init();
//Call global constructors
_init();
//Try to init VESA
if(vesa::enabled() && !vesa::init()){
vesa::disable();
//Unfortunately, we are in long mode, we cannot go back
//to text mode for now
suspend_boot();
}
init_console();
stdio::init_terminals();
//Finalize memory operations (register sysfs values)
paging::finalize();
physical_allocator::finalize();
virtual_allocator::finalize();
kalloc::finalize();
// Asynchronously initialized drivers
acpi::init();
hpet::init();
//Install drivers
timer::install();
keyboard::install_driver();
mouse::install();
disks::detect_disks();
pci::detect_devices();
network::init();
//Init the virtual file system
vfs::init();
//Starting from here, the logging system can output logs to file
//TODO logging::to_file();
//Only install system calls when everything else is ready
install_system_calls();
sysfs::set_constant_value(path("/sys"), path("/version"), "0.1");
sysfs::set_constant_value(path("/sys"), path("/author"), "Baptiste Wicht");
// Initialize the scheduler
scheduler::init();
// Start the secondary kernel processes
network::finalize();
stdio::finalize();
// Start the scheduler
scheduler::start();
}
 
Github上其它操作系统相关的项目有:
How-to-Make-a-Computer-Operating-System(https://github.com/SamyPesse/How-to-Make-a-Computer-Operating-System):教你怎么制作操作系统,过万颗星的项目
linux(https://github.com/torvalds/linux)
redox(https://github.com/redox-os/redox):使用纯Rust编写的操作系统,我只有膜拜的份
osv(https://github.com/cloudius-systems/osv):专为虚拟机开发的操作系统
Harvey OS(https://github.com/Harvey-OS/harvey):分布式操作系统
rt-thread(https://github.com/RT-Thread/rt-thread):China为嵌入式开发的实时操作系统
jsos(https://github.com/charliesome/jsos):使用JavaScript写的操作系统
更多操作系统请自行在Github搜”Operating System”(https://github.com/search?p=2&q=Operating+System&type=Repositories&utf8=%E2%9C%93)
 
本文永久更新地址:http://www.linuxdiyf.com/linux/23602.html