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