Mercurial > lcfOS
view kernel/syscall.c3 @ 300:158068af716c
yafm
author | Windel Bouwman |
---|---|
date | Tue, 03 Dec 2013 18:00:22 +0100 |
parents | 534b94b40aa8 |
children | 6753763d3bec |
line wrap: on
line source
module syscall; /* This module handles all the system calls from user space. */ /* enum { SendMsg = 1, ReceiveMsg = 2, } syscall_t; */ type int syscall_t; // System call handlers. System calls are made from user space. function void handle_system_call(int callId, int a, int b, int c, int d) { // Main entry, check what to do here switch(callId) { case SendMsg: handle_send_msg(); proc = process.byId(a); if (not proc) { panic(); } proc.setMessage(); // scheduler.current.setState(Sleep); break; case ReceiveMsg: break; case Reboot: arch.reboot(); break; default: return NO_SUCH_CALL; } return OK; } // Handle send message syscall func void handle_send_msg() { p = process.byId(msg.to_id); scheduler.attempt(p); } func handle_recv_msg() { // Block until we have a message currentProc->setState(Sleep); scheduler.executeNext(); } func handle_reboot() { reboot(); }