-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuio.c
54 lines (43 loc) · 1.05 KB
/
uio.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <muos/error.h>
#include <muos/io.h>
#include <muos/message.h>
typedef union
{
struct Pulse async;
} my_msg_type;
int main (int argc, char *argv[])
{
int chid;
int coid;
my_msg_type msg;
chid = ChannelCreate();
coid = Connect(SELF_PID, chid);
void * zeroPtr = MapPhysical(0, 4096 * 4);
zeroPtr = zeroPtr;
int handler_id = InterruptAttach(coid, 4, NULL);
for (;;) {
int msgid;
int num = MessageReceive(chid, &msgid, &msg, sizeof(msg));
if (msgid != 0) {
MessageReply(msgid, ERROR_NO_SYS, NULL, 0);
}
else {
// Pulse received
switch (msg.async.type) {
case PULSE_TYPE_INTERRUPT:
{
InterruptComplete(handler_id);
break;
}
default:
{
*((char *)NULL) = '\0';
break;
}
}
}
num = num;
}
InterruptDetach(handler_id);
return 0;
}