feat(ipc): implement synchronous Rendezvous IPC and multi-thread cooperative scheduler
This commit is contained in:
+20
-15
@@ -2,29 +2,34 @@
|
||||
#include "stdio.h"
|
||||
#include "string.h"
|
||||
|
||||
#define UART_SERVICE_ENDPOINT 2
|
||||
|
||||
extern "C" void _start() {
|
||||
puts("[INIT-SERVER] Userspace Root Init Server Started (Ring 3)!");
|
||||
|
||||
// 1. Instantiate RAII IPC Endpoint for Kernel Control
|
||||
ipc::Endpoint kernel_ctrl(CAP_SELF_TASK);
|
||||
// 1. Communicate with Kernel Control (Endpoint 1)
|
||||
ipc::Endpoint kernel_ctrl(CAP_KERNEL_CONTROL);
|
||||
puts("[INIT-SERVER] Sending Fast-Path IPC Ping to Microkernel (CAP 1)...");
|
||||
auto kping = kernel_ctrl.call(IPC_OP_PING, 777);
|
||||
if (kping.is_ok()) {
|
||||
puts("[INIT-SERVER] Received Pong from Microkernel!");
|
||||
}
|
||||
|
||||
puts("[INIT-SERVER] Sending Fast-Path IPC Ping to Microkernel...");
|
||||
auto ping_res = kernel_ctrl.call(IPC_OP_PING, 100);
|
||||
// 2. Communicate with UART Driver Service (Endpoint 2) via Rendezvous IPC
|
||||
ipc::Endpoint uart_service(UART_SERVICE_ENDPOINT);
|
||||
puts("[INIT-SERVER] Sending Synchronous Rendezvous IPC to UART Driver (Endpoint 2)...");
|
||||
|
||||
if (ping_res.is_ok()) {
|
||||
puts("[INIT-SERVER] Received IPC Ping Response from Microkernel!");
|
||||
// Pack 4 characters 'O', 'K', '!', '\n' into 32-bit arg0
|
||||
uint64_t msg_chars = 'O' | ('K' << 8) | ('!' << 16) | ('\n' << 24);
|
||||
auto uart_res = uart_service.call(IPC_OP_WRITE, msg_chars);
|
||||
|
||||
if (uart_res.is_ok()) {
|
||||
puts("[INIT-SERVER] Rendezvous IPC Call to UART Driver SUCCEEDED!");
|
||||
} else {
|
||||
puts("[INIT-SERVER] IPC Call Failed!");
|
||||
puts("[INIT-SERVER] Rendezvous IPC Call failed.");
|
||||
}
|
||||
|
||||
// 2. Register Server Endpoint
|
||||
puts("[INIT-SERVER] Registering Root Server Capability...");
|
||||
auto reg_res = kernel_ctrl.call(IPC_OP_REGISTER_SERVER, 0x1337BEEF);
|
||||
if (reg_res.is_ok()) {
|
||||
puts("[INIT-SERVER] Server Registered Successfully!");
|
||||
}
|
||||
|
||||
puts("[INIT-SERVER] Root Init Server ready. Entering event loop.");
|
||||
puts("[INIT-SERVER] Root Init Server running. Entering worker loop.");
|
||||
|
||||
while (true) {
|
||||
sys_yield();
|
||||
|
||||
Reference in New Issue
Block a user