annotate kernel/syscall.c3 @ 407:9eb1fc6aad6c

Minor improvements
author Windel Bouwman
date Fri, 20 Feb 2015 15:47:54 +0100
parents 0fb6633c42f6
children ad6be5454067
rev   line source
283
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
1 module syscall;
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
2
292
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 283
diff changeset
3 /*
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 283
diff changeset
4 This module handles all the system calls from user space.
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 283
diff changeset
5 */
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 283
diff changeset
6
301
6753763d3bec merge codegen into ppci package
Windel Bouwman
parents: 300
diff changeset
7 import arch;
6753763d3bec merge codegen into ppci package
Windel Bouwman
parents: 300
diff changeset
8 import scheduler;
6753763d3bec merge codegen into ppci package
Windel Bouwman
parents: 300
diff changeset
9 import process;
6753763d3bec merge codegen into ppci package
Windel Bouwman
parents: 300
diff changeset
10
292
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 283
diff changeset
11
393
6ae782a085e0 Added init program
Windel Bouwman
parents: 359
diff changeset
12 /* System call numbers:
6ae782a085e0 Added init program
Windel Bouwman
parents: 359
diff changeset
13 */
301
6753763d3bec merge codegen into ppci package
Windel Bouwman
parents: 300
diff changeset
14 const int SendMsg = 1;
6753763d3bec merge codegen into ppci package
Windel Bouwman
parents: 300
diff changeset
15 const int ReceiveMsg = 2;
6753763d3bec merge codegen into ppci package
Windel Bouwman
parents: 300
diff changeset
16 const int Reboot = 3;
300
Windel Bouwman
parents: 292
diff changeset
17
283
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
18
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
19 // System call handlers. System calls are made from user space.
305
0615b5308710 Updated docs
Windel Bouwman
parents: 301
diff changeset
20 function void handle_system_call(int callId, int a, int b)
292
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 283
diff changeset
21 {
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 283
diff changeset
22 // Main entry, check what to do here
393
6ae782a085e0 Added init program
Windel Bouwman
parents: 359
diff changeset
23 if (callId == SendMsg)
301
6753763d3bec merge codegen into ppci package
Windel Bouwman
parents: 300
diff changeset
24 {
6753763d3bec merge codegen into ppci package
Windel Bouwman
parents: 300
diff changeset
25 handle_send_msg();
308
2e7f55319858 Merged analyse into codegenerator
Windel Bouwman
parents: 305
diff changeset
26 var process.process_t* proc;
2e7f55319858 Merged analyse into codegenerator
Windel Bouwman
parents: 305
diff changeset
27 proc = process.byId(a);
301
6753763d3bec merge codegen into ppci package
Windel Bouwman
parents: 300
diff changeset
28 // proc.setMessage();
6753763d3bec merge codegen into ppci package
Windel Bouwman
parents: 300
diff changeset
29 // scheduler.current.setState(Sleep);
6753763d3bec merge codegen into ppci package
Windel Bouwman
parents: 300
diff changeset
30 }
6753763d3bec merge codegen into ppci package
Windel Bouwman
parents: 300
diff changeset
31 else
292
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 283
diff changeset
32 {
301
6753763d3bec merge codegen into ppci package
Windel Bouwman
parents: 300
diff changeset
33 if (callId == 2)
6753763d3bec merge codegen into ppci package
Windel Bouwman
parents: 300
diff changeset
34 {
6753763d3bec merge codegen into ppci package
Windel Bouwman
parents: 300
diff changeset
35 handle_recv_msg();
6753763d3bec merge codegen into ppci package
Windel Bouwman
parents: 300
diff changeset
36 }
6753763d3bec merge codegen into ppci package
Windel Bouwman
parents: 300
diff changeset
37 else
6753763d3bec merge codegen into ppci package
Windel Bouwman
parents: 300
diff changeset
38 {
6753763d3bec merge codegen into ppci package
Windel Bouwman
parents: 300
diff changeset
39 if (callId == 3)
292
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 283
diff changeset
40 {
308
2e7f55319858 Merged analyse into codegenerator
Windel Bouwman
parents: 305
diff changeset
41 //arch.reboot();
292
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 283
diff changeset
42 }
301
6753763d3bec merge codegen into ppci package
Windel Bouwman
parents: 300
diff changeset
43 else
6753763d3bec merge codegen into ppci package
Windel Bouwman
parents: 300
diff changeset
44 {
6753763d3bec merge codegen into ppci package
Windel Bouwman
parents: 300
diff changeset
45 return 2;
6753763d3bec merge codegen into ppci package
Windel Bouwman
parents: 300
diff changeset
46 }
6753763d3bec merge codegen into ppci package
Windel Bouwman
parents: 300
diff changeset
47 }
292
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 283
diff changeset
48 }
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 283
diff changeset
49
301
6753763d3bec merge codegen into ppci package
Windel Bouwman
parents: 300
diff changeset
50 return 0;
283
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
51 }
c9781c73e7e2 Added first kernel files
Windel Bouwman
parents:
diff changeset
52
292
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 283
diff changeset
53 // Handle send message syscall
301
6753763d3bec merge codegen into ppci package
Windel Bouwman
parents: 300
diff changeset
54 function void handle_send_msg()
292
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 283
diff changeset
55 {
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 283
diff changeset
56 }
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 283
diff changeset
57
301
6753763d3bec merge codegen into ppci package
Windel Bouwman
parents: 300
diff changeset
58 function void handle_recv_msg()
292
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 283
diff changeset
59 {
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 283
diff changeset
60 // Block until we have a message
301
6753763d3bec merge codegen into ppci package
Windel Bouwman
parents: 300
diff changeset
61 //currentProc->setState(Sleep);
308
2e7f55319858 Merged analyse into codegenerator
Windel Bouwman
parents: 305
diff changeset
62 //scheduler.executeNext();
292
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 283
diff changeset
63 }
534b94b40aa8 Fixup reorganize
Windel Bouwman
parents: 283
diff changeset
64