1 | /* |
---|
2 | * RTEMS multi-tasking support |
---|
3 | */ |
---|
4 | |
---|
5 | #ifdef HAVE_CONFIG_H |
---|
6 | #include "config.h" |
---|
7 | #endif |
---|
8 | |
---|
9 | #include <rpc/rpc.h> |
---|
10 | #include <rtems.h> |
---|
11 | #include <stdlib.h> |
---|
12 | #ifdef __rtems__ |
---|
13 | /* XXX in rpc.h in old .. not new */ |
---|
14 | #include <rpc/rpc_rtems.h> |
---|
15 | #endif |
---|
16 | |
---|
17 | /* |
---|
18 | * RPC variables for single-thread |
---|
19 | */ |
---|
20 | static struct _rtems_rpc_task_variables rpc_default = { |
---|
21 | -1, /* svc_maxfd */ |
---|
22 | {{0}}, /* svc_svc_fdset */ |
---|
23 | NULL, /* svc_xports */ |
---|
24 | 0, /* svc_xportssize */ |
---|
25 | 0, /* svc__svc_fdsetsize */ |
---|
26 | 0, /* svc__svc_fdset */ |
---|
27 | NULL, /* svc_svc_head */ |
---|
28 | 0, /* clnt_perror_buf */ |
---|
29 | 0, /* clnt_raw_private */ |
---|
30 | 0, /* call_rpc_private */ |
---|
31 | 0, /* svc_raw_private */ |
---|
32 | |
---|
33 | 0, /* svc_simple_proglst */ |
---|
34 | 0, /* svc_simple_pl */ |
---|
35 | 0, /* svc_simple_transp */ |
---|
36 | |
---|
37 | 0, /* rpcdname_default_domain */ |
---|
38 | 0 /* svc_auths_Auths */ |
---|
39 | }; |
---|
40 | |
---|
41 | /* |
---|
42 | * RPC values for initializing a new per-task set of variables |
---|
43 | */ |
---|
44 | static const struct _rtems_rpc_task_variables rpc_init = { |
---|
45 | -1, /* svc_maxfd */ |
---|
46 | {{0}}, /* svc_svc_fdset */ |
---|
47 | NULL, /* svc_xports */ |
---|
48 | 0, /* svc_xportssize */ |
---|
49 | 0, /* svc__svc_fdsetsize */ |
---|
50 | 0, /* svc__svc_fdset */ |
---|
51 | NULL, /* svc_svc_head */ |
---|
52 | 0, /* clnt_perror_buf */ |
---|
53 | 0, /* clnt_raw_private */ |
---|
54 | 0, /* call_rpc_private */ |
---|
55 | 0, /* svc_raw_private */ |
---|
56 | |
---|
57 | 0, /* svc_simple_proglst */ |
---|
58 | 0, /* svc_simple_pl */ |
---|
59 | 0, /* svc_simple_transp */ |
---|
60 | |
---|
61 | 0, /* rpcdname_default_domain */ |
---|
62 | 0 /* svc_auths_Auths */ |
---|
63 | }; |
---|
64 | |
---|
65 | /* |
---|
66 | * Per-task pointer to RPC data |
---|
67 | */ |
---|
68 | struct _rtems_rpc_task_variables *rtems_rpc_task_variables = &rpc_default; |
---|
69 | |
---|
70 | /* |
---|
71 | * Set up per-task RPC variables |
---|
72 | */ |
---|
73 | int rtems_rpc_task_init (void) |
---|
74 | { |
---|
75 | rtems_status_code sc; |
---|
76 | struct _rtems_rpc_task_variables *tvp; |
---|
77 | |
---|
78 | if (rtems_rpc_task_variables == &rpc_default) { |
---|
79 | tvp = malloc (sizeof *tvp); |
---|
80 | if (tvp == NULL) |
---|
81 | return RTEMS_NO_MEMORY; |
---|
82 | /* |
---|
83 | * FIXME: Should have destructor which cleans up |
---|
84 | * all RPC stuff: |
---|
85 | * - Close all files |
---|
86 | * - Go through and free linked list elements |
---|
87 | * - Free other allocated memory (e.g. clnt_perror_buf) |
---|
88 | */ |
---|
89 | sc = rtems_task_variable_add ( |
---|
90 | RTEMS_SELF, (void *)&rtems_rpc_task_variables, NULL); |
---|
91 | if (sc != RTEMS_SUCCESSFUL) { |
---|
92 | free (tvp); |
---|
93 | return sc; |
---|
94 | } |
---|
95 | *tvp = rpc_init; |
---|
96 | rtems_rpc_task_variables = tvp; |
---|
97 | } |
---|
98 | return RTEMS_SUCCESSFUL; |
---|
99 | } |
---|