Files
opencoreC/servers/init/main.cpp
T

38 lines
1.2 KiB
C++

#include "ipc.hpp"
#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. 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!");
}
// 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)...");
// 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] Rendezvous IPC Call failed.");
}
puts("[INIT-SERVER] Root Init Server running. Entering worker loop.");
while (true) {
sys_yield();
}
}