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