comparison kernel/syscall.c3 @ 292:534b94b40aa8

Fixup reorganize
author Windel Bouwman
date Wed, 27 Nov 2013 08:06:42 +0100
parents c9781c73e7e2
children 158068af716c
comparison
equal deleted inserted replaced
290:7b38782ed496 292:534b94b40aa8
1 module syscall; 1 module syscall;
2 2
3 /*
4 This module handles all the system calls from user space.
5 */
6
7 enum {
8 SendMsg = 1,
9 ReceiveMsg = 2,
10
11 } syscall_t;
3 12
4 // System call handlers. System calls are made from user space. 13 // System call handlers. System calls are made from user space.
14 func void handle_system_call(int callId, int a, int b, int c, int d)
15 {
16 // Main entry, check what to do here
17 switch(callId)
18 {
19 case SendMsg:
20 handle_send_msg();
21 proc = process.byId(a);
22 if (not proc)
23 {
24 panic();
25 }
5 26
6 func void handle_system_call() 27 proc.setMessage();
7 { 28 scheduler.current.setState(Sleep);
29 break;
30 case ReceiveMsg:
31 break;
32 case Reboot:
33 arch.reboot();
34 break;
35 default:
36 return NO_SUCH_CALL;
37 }
38
39 return OK;
8 } 40 }
9 41
42 // Handle send message syscall
43 func void handle_send_msg()
44 {
45 p = process.byId(msg.to_id);
46 scheduler.attempt(p);
47 }
48
49 func handle_recv_msg()
50 {
51 // Block until we have a message
52 currentProc->setState(Sleep);
53 scheduler.executeNext();
54 }
55
56 func handle_reboot()
57 {
58 reboot();
59 }
60