feat: proper IPC-based boot — init loads servers from storage via IPC, VirtIO GPU driver
Complete microkernel boot pipeline: adapter loads only init + storage + display from disk. Init bootstraps all other servers by reading binaries from the storage server via IPC, parsing ELF, creating processes, mapping pages, and spawning threads. New syscalls: - CreateEndpoint: userspace endpoint creation with full capability grant - DebugPutchar: debug output to UART from userspace - MapPage: cross-process page mapping (init loads binaries into children) - SpawnThreadIn: spawn thread in another process via capability Key fixes: - Per-process L1 page tables for VPN[2]=0 (prevents cross-process corruption) - Separate kernel_pt from page_tables[0] (init pid=0 overwrote kernel PT ref) - Thread Running state set in switch_to_next (syscalls rejected without it) - Pending IPC results applied during context switch - SIE disabled during boot (timer can't preempt into unready processes) - User heap VA starts at 0x40000 (avoids shared buffer at 0x30000) - RequestPages maps at user VAs via per-process heap allocator VirtIO GPU: - Adapter probes for GPU device, initializes resource/scanout/backing - Display server writes to mapped framebuffer, flushes via GPU virtqueue - 640x480 BGRA framebuffer with transfer-to-host and resource-flush Storage server: - Userspace VirtIO block driver using pre-mapped MMIO and DMA pages - FAT16 filesystem reader serving file-read requests via IPC - Shared buffer protocol: init writes filename, storage writes file data Echo app for IPC testing (adapter-loaded echo proved the pipeline end-to-end).
This commit is contained in:
@@ -105,6 +105,14 @@ impl<P: Platform> Kernel<P> {
|
||||
self.pending_results[thread.raw() as usize].as_ref()
|
||||
}
|
||||
|
||||
pub fn take_pending_result(&mut self, thread: ThreadId) -> Option<SyscallResult> {
|
||||
self.pending_results[thread.raw() as usize].take()
|
||||
}
|
||||
|
||||
pub fn set_thread_running(&mut self, tid: ThreadId, core: types::id::CoreId) -> Result<(), domain::error::KernelError> {
|
||||
self.threads.get_mut(tid)?.set_running(core)
|
||||
}
|
||||
|
||||
pub fn free_page_count(&self) -> usize {
|
||||
self.page_pool.free_count()
|
||||
}
|
||||
@@ -136,6 +144,30 @@ impl<P: Platform> Kernel<P> {
|
||||
self.scheduler.next(core)
|
||||
}
|
||||
|
||||
pub fn create_process_internal(&mut self) -> Option<ProcessId> {
|
||||
let pid = self.processes.create(CapabilityTable::new(), None).ok()?;
|
||||
self.process_memory[pid.raw() as usize] =
|
||||
Some(domain::memory::process_memory::ProcessMemory::new(pid, 1024));
|
||||
Some(pid)
|
||||
}
|
||||
|
||||
pub fn spawn_thread_internal(
|
||||
&mut self,
|
||||
pid: ProcessId,
|
||||
) -> Option<ThreadId> {
|
||||
use domain::scheduler::Scheduler;
|
||||
let tid = self.threads.spawn(
|
||||
pid,
|
||||
Priority::DEFAULT,
|
||||
TimeSlice::DEFAULT,
|
||||
None,
|
||||
).ok()?;
|
||||
let _ = self.processes.get_mut(pid).map(|p| p.add_thread(tid));
|
||||
let core = self.platform.core_id();
|
||||
self.scheduler.add(tid, Priority::DEFAULT, core);
|
||||
Some(tid)
|
||||
}
|
||||
|
||||
pub fn create_endpoint(&mut self) -> Result<types::id::EndpointId, KernelError> {
|
||||
self.endpoints.create().ok_or(KernelError::NoFreeSlot)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user