Rev 2471 | Rev 2479 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2471 | Rev 2476 | ||
---|---|---|---|
Line 53... | Line 53... | ||
53 | #define NAME "NS" |
53 | #define NAME "NS" |
54 | 54 | ||
55 | #define NS_HASH_TABLE_CHAINS 20 |
55 | #define NS_HASH_TABLE_CHAINS 20 |
56 | 56 | ||
57 | static int register_service(ipcarg_t service, ipcarg_t phone, ipc_call_t *call); |
57 | static int register_service(ipcarg_t service, ipcarg_t phone, ipc_call_t *call); |
58 | static int connect_to_service(ipcarg_t service, ipc_call_t *call, ipc_callid_t callid); |
58 | static int connect_to_service(ipcarg_t service, ipc_call_t *call, |
- | 59 | ipc_callid_t callid); |
|
59 | 60 | ||
60 | /* Static functions implementing NS hash table operations. */ |
61 | /* Static functions implementing NS hash table operations. */ |
61 | static hash_index_t ns_hash(unsigned long *key); |
62 | static hash_index_t ns_hash(unsigned long *key); |
62 | static int ns_compare(unsigned long *key, hash_count_t keys, link_t *item); |
63 | static int ns_compare(unsigned long *key, hash_count_t keys, link_t *item); |
63 | static void ns_remove(link_t *item); |
64 | static void ns_remove(link_t *item); |
Line 81... | Line 82... | ||
81 | } hashed_service_t; |
82 | } hashed_service_t; |
82 | 83 | ||
83 | static void *clockaddr = NULL; |
84 | static void *clockaddr = NULL; |
84 | static void *klogaddr = NULL; |
85 | static void *klogaddr = NULL; |
85 | 86 | ||
86 | static void get_as_area(ipc_callid_t callid, ipc_call_t *call, char *name, void **addr) |
87 | static void get_as_area(ipc_callid_t callid, ipc_call_t *call, char *name, |
- | 88 | void **addr) |
|
87 | { |
89 | { |
88 | void *ph_addr; |
90 | void *ph_addr; |
89 | 91 | ||
90 | if (!*addr) { |
92 | if (!*addr) { |
91 | ph_addr = (void *) sysinfo_value(name); |
93 | ph_addr = (void *) sysinfo_value(name); |
Line 104... | Line 106... | ||
104 | ipc_call_t call; |
106 | ipc_call_t call; |
105 | ipc_callid_t callid; |
107 | ipc_callid_t callid; |
106 | 108 | ||
107 | ipcarg_t retval; |
109 | ipcarg_t retval; |
108 | 110 | ||
109 | if (!hash_table_create(&ns_hash_table, NS_HASH_TABLE_CHAINS, 3, &ns_hash_table_ops)) { |
111 | if (!hash_table_create(&ns_hash_table, NS_HASH_TABLE_CHAINS, 3, |
- | 112 | &ns_hash_table_ops)) { |
|
110 | return ENOMEM; |
113 | return ENOMEM; |
111 | } |
114 | } |
112 | 115 | ||
113 | while (1) { |
116 | while (1) { |
114 | callid = ipc_wait_for_call(&call); |
117 | callid = ipc_wait_for_call(&call); |
Line 132... | Line 135... | ||
132 | break; |
135 | break; |
133 | case IPC_M_CONNECT_TO_ME: |
136 | case IPC_M_CONNECT_TO_ME: |
134 | /* |
137 | /* |
135 | * Server requests service registration. |
138 | * Server requests service registration. |
136 | */ |
139 | */ |
137 | retval = register_service(IPC_GET_ARG1(call), IPC_GET_ARG3(call), &call); |
140 | retval = register_service(IPC_GET_ARG1(call), |
- | 141 | IPC_GET_ARG3(call), &call); |
|
138 | break; |
142 | break; |
139 | case IPC_M_CONNECT_ME_TO: |
143 | case IPC_M_CONNECT_ME_TO: |
140 | /* |
144 | /* |
141 | * Client requests to be connected to a service. |
145 | * Client requests to be connected to a service. |
142 | */ |
146 | */ |
143 | retval = connect_to_service(IPC_GET_ARG1(call), &call, callid); |
147 | retval = connect_to_service(IPC_GET_ARG1(call), &call, |
- | 148 | callid); |
|
144 | break; |
149 | break; |
145 | default: |
150 | default: |
146 | retval = ENOENT; |
151 | retval = ENOENT; |
147 | break; |
152 | break; |
148 | } |
153 | } |
149 | if (! (callid & IPC_CALLID_NOTIFICATION)) { |
154 | if (!(callid & IPC_CALLID_NOTIFICATION)) { |
150 | ipc_answer_fast(callid, retval, 0, 0); |
155 | ipc_answer_fast(callid, retval, 0, 0); |
151 | } |
156 | } |
152 | } |
157 | } |
153 | } |
158 | } |
154 | 159 | ||
Line 160... | Line 165... | ||
160 | * |
165 | * |
161 | * @return Zero on success or a value from @ref errno.h. |
166 | * @return Zero on success or a value from @ref errno.h. |
162 | */ |
167 | */ |
163 | int register_service(ipcarg_t service, ipcarg_t phone, ipc_call_t *call) |
168 | int register_service(ipcarg_t service, ipcarg_t phone, ipc_call_t *call) |
164 | { |
169 | { |
165 | unsigned long keys[3] = { service, call->in_phone_hash, 0 }; |
170 | unsigned long keys[3] = { |
- | 171 | service, |
|
- | 172 | call->in_phone_hash, |
|
- | 173 | 0 |
|
- | 174 | }; |
|
166 | hashed_service_t *hs; |
175 | hashed_service_t *hs; |
167 | 176 | ||
168 | if (hash_table_find(&ns_hash_table, keys)) { |
177 | if (hash_table_find(&ns_hash_table, keys)) { |
169 | return EEXISTS; |
178 | return EEXISTS; |
170 | } |
179 | } |