-
Notifications
You must be signed in to change notification settings - Fork 33
/
usrv.c
76 lines (58 loc) · 1.02 KB
/
usrv.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* Phoenix-RTOS
*
* Operating system kernel
*
* User server
*
* Copyright 2022 Phoenix Systems
* Authors: Hubert Buczynski
*
* This file is part of Phoenix-RTOS.
*
* %LICENSE%
*/
#include "hal/hal.h"
#include "usrv.h"
#include "log/log.h"
#include "include/ioctl.h"
#include "proc/threads.h"
#include "proc/msg.h"
#include "proc/ports.h"
#define USRV_ID_LOG 0
static struct {
oid_t oid;
} usrv_common;
static void usrv_msgthr(void *arg)
{
msg_t msg;
msg_rid_t rid;
oid_t oid = usrv_common.oid;
for (;;) {
if (proc_recv(oid.port, &msg, &rid) != 0) {
continue;
}
oid.id = msg.oid.id;
switch (oid.id) {
case USRV_ID_LOG:
log_msgHandler(&msg, oid, rid);
break;
default:
msg.o.err = -ENOSYS;
proc_respond(oid.port, &msg, rid);
break;
}
}
}
void _usrv_start(void)
{
/* Create port 0 for /dev/kmsg */
if (proc_portCreate(&usrv_common.oid.port) != 0) {
return;
}
proc_threadCreate(NULL, usrv_msgthr, NULL, 4, 2048, NULL, 0, NULL);
}
void _usrv_init(void)
{
_log_init();
}