annotate kernel/src/syscall.c3 @ 381:6df89163e114

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