feat(boot+shell): add bootable disk image, unified scheduler and interactive user-space shell

- Implement Limine v8 boot protocol requests in dedicated PT_LOAD RW segment
- Configure IOPL=3 and SSE in arch setup for Ring 3 drivers and libc
- Unify scheduler context switching via switch_to and preempt_tick
- Support dual-source keyboard/serial input in sys_key_read
- Add automated 'make image' and 'make run' targets for instant QEMU launch
- Complete interactive UNIX-like shell (osh) with built-in commands & ramdisk
This commit is contained in:
RarDog
2026-09-02 19:47:57 +03:00
parent ca3555bd09
commit eed05c1eca
17 changed files with 452 additions and 217 deletions
+21 -12
View File
@@ -18,25 +18,28 @@ core::arch::global_asm!(include_str!("../asm/context.S"));
core::arch::global_asm!(include_str!("../asm/syscall_entry.S"));
core::arch::global_asm!(include_str!("../asm/ring3_enter.S"));
core::arch::global_asm!(include_str!("../asm/timer_isr.S"));
core::arch::global_asm!(include_str!("../asm/keyboard_isr.S"));
#[no_mangle]
pub extern "C" fn _start() -> ! {
// 1. Validate Limine Base Revision
if BASE_REVISION.revision != 3 {
loop { core::hint::spin_loop(); }
}
// 2. Early Serial Initialization
// 1. Early Serial Initialization
drivers::serial::SerialPort::init();
kprintln!("\n=======================================================");
kprintln!(" opencoreC Microkernel v0.1.0 (x86_64)");
kprintln!("=======================================================");
// 2. Validate Limine Base Revision
unsafe {
if limine_base_revision[2] != 0 {
kprintln!("[WARN] Limine Base Revision 3 not supported by bootloader.");
}
}
// 3. Obtain Limine responses
let hhdm_offset = get_hhdm_offset().expect("Limine HHDM response missing");
let memmap_resp = MEMMAP_REQUEST.response;
let kernel_addr_resp = KERNEL_ADDRESS_REQUEST.response;
let memmap_resp = unsafe { MEMMAP_REQUEST.response };
let kernel_addr_resp = unsafe { KERNEL_ADDRESS_REQUEST.response };
kprintln!("[BOOT] Limine HHDM Base Virtual Address: {:#018x}", hhdm_offset);
if !kernel_addr_resp.is_null() {
@@ -47,9 +50,14 @@ pub extern "C" fn _start() -> ! {
);
}
}
unsafe {
kprintln!("[DBG] MEMMAP resp ptr: {:#018x}", MEMMAP_REQUEST.response as u64);
kprintln!("[DBG] MODULE resp ptr: {:#018x}", MODULE_REQUEST.response as u64);
kprintln!("[DBG] SMP resp ptr: {:#018x}", SMP_REQUEST.response as u64);
}
// 4. Initialize Architecture (GDT, IDT, Syscall MSRs)
kprintln!("[BOOT] Initializing GDT, IDT, and Fast-Path Syscall MSRs...");
// 4. Initialize Architecture (GDT, IDT, Syscall MSRs, SMP)
kprintln!("[BOOT] Initializing GDT, IDT, Fast-Path Syscall MSRs & SMP...");
unsafe {
arch::init();
}
@@ -65,6 +73,7 @@ pub extern "C" fn _start() -> ! {
kprintln!("[BOOT] Configuring PIT 8254 timer for Preemptive Multi-Tasking...");
unsafe {
drivers::timer::init(100);
drivers::keyboard::init();
}
// 7. Initialize IPC & Capability System
@@ -88,6 +97,7 @@ pub extern "C" fn _start() -> ! {
let name = match i {
0 => "init_server",
1 => "uart_driver",
2 => "sh",
_ => "user_server",
};
@@ -118,8 +128,7 @@ pub extern "C" fn _start() -> ! {
}
}
kprintln!("[KERNEL] Entering idle loop.\n");
// Idle loop: wait for interrupts and let threads execute
loop {
unsafe {
core::arch::asm!("sti; hlt");