annotate kernel/syscall.c3 @ 410:6aa9743ed362 tip

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