283
|
1 module syscall;
|
|
2
|
292
|
3 /*
|
|
4 This module handles all the system calls from user space.
|
|
5 */
|
|
6
|
301
|
7 import arch;
|
|
8 import scheduler;
|
|
9 import process;
|
|
10
|
292
|
11
|
301
|
12 const int SendMsg = 1;
|
|
13 const int ReceiveMsg = 2;
|
|
14 const int Reboot = 3;
|
300
|
15
|
283
|
16
|
|
17 // System call handlers. System calls are made from user space.
|
305
|
18 function void handle_system_call(int callId, int a, int b)
|
292
|
19 {
|
|
20 // Main entry, check what to do here
|
301
|
21 if (callId == 1)
|
|
22 {
|
|
23 handle_send_msg();
|
|
24 var process:process_t* proc;
|
|
25 proc = process:byId(a);
|
|
26 // proc.setMessage();
|
|
27 // scheduler.current.setState(Sleep);
|
|
28 }
|
|
29 else
|
292
|
30 {
|
301
|
31 if (callId == 2)
|
|
32 {
|
|
33 handle_recv_msg();
|
|
34 }
|
|
35 else
|
|
36 {
|
|
37 if (callId == 3)
|
292
|
38 {
|
301
|
39 //arch:reboot();
|
292
|
40 }
|
301
|
41 else
|
|
42 {
|
|
43 return 2;
|
|
44 }
|
|
45 }
|
292
|
46 }
|
|
47
|
301
|
48 return 0;
|
283
|
49 }
|
|
50
|
292
|
51 // Handle send message syscall
|
301
|
52 function void handle_send_msg()
|
292
|
53 {
|
|
54 }
|
|
55
|
301
|
56 function void handle_recv_msg()
|
292
|
57 {
|
|
58 // Block until we have a message
|
301
|
59 //currentProc->setState(Sleep);
|
|
60 //scheduler:executeNext();
|
292
|
61 }
|
|
62
|