Changeset 007e6efa in mainline
- Timestamp:
- 2011-01-28T15:44:39Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 4db1fbf
- Parents:
- ae0300b5
- Location:
- uspace
- Files:
-
- 1 added
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/klog/klog.c
rae0300b5 r007e6efa 37 37 #include <stdio.h> 38 38 #include <ipc/ipc.h> 39 #include <ipc/ns.h> 39 40 #include <async.h> 40 41 #include <ipc/services.h> … … 79 80 int main(int argc, char *argv[]) 80 81 { 81 size_t klog_pages; 82 if (sysinfo_get_value("klog.pages", &klog_pages) != EOK) { 83 printf("%s: Error getting klog address\n", NAME); 84 return -1; 85 } 86 87 size_t klog_size = klog_pages * PAGE_SIZE; 88 klog_length = klog_size / sizeof(wchar_t); 89 90 klog = (wchar_t *) as_get_mappable_page(klog_size); 82 klog = service_klog_share_in(&klog_length); 91 83 if (klog == NULL) { 92 printf("%s: Error allocating memory area\n", NAME); 93 return -1; 94 } 95 96 int res = async_share_in_start_1_0(PHONE_NS, (void *) klog, 97 klog_size, SERVICE_MEM_KLOG); 98 if (res != EOK) { 99 printf("%s: Error initializing memory area\n", NAME); 84 printf("%s: Error accessing to klog\n", NAME); 100 85 return -1; 101 86 } … … 109 94 * Mode "a" would be definitively much better here, but it is 110 95 * not well supported by the FAT driver. 111 *112 96 */ 113 97 log = fopen(LOG_FNAME, "w"); -
uspace/lib/c/Makefile
rae0300b5 r007e6efa 83 83 generic/io/console.c \ 84 84 generic/io/screenbuffer.c \ 85 generic/ipc/ns.c \ 85 86 generic/malloc.c \ 86 87 generic/sysinfo.c \ -
uspace/lib/c/generic/async.c
rae0300b5 r007e6efa 58 58 * int fibril1(void *arg) 59 59 * { 60 * conn = ipc_connect_me_to();60 * conn = async_connect_me_to(); 61 61 * c1 = async_send(conn); 62 62 * c2 = async_send(conn); … … 1235 1235 } 1236 1236 1237 /** Wrapper for making IPC_M_CONNECT_TO_ME calls using the async framework. 1238 * 1239 * Ask through phone for a new connection to some service. 1240 * 1241 * @param phone Phone handle used for contacting the other side. 1242 * @param arg1 User defined argument. 1243 * @param arg2 User defined argument. 1244 * @param arg3 User defined argument. 1245 * @param client_receiver Connection handing routine. 1246 * 1247 * @return New phone handle on success or a negative error code. 1248 * 1249 */ 1250 int async_connect_to_me(int phone, sysarg_t arg1, sysarg_t arg2, 1251 sysarg_t arg3, async_client_conn_t client_receiver) 1252 { 1253 sysarg_t task_hash; 1254 sysarg_t phone_hash; 1255 int rc = async_req_3_5(phone, IPC_M_CONNECT_TO_ME, arg1, arg2, arg3, 1256 NULL, NULL, NULL, &task_hash, &phone_hash); 1257 if (rc != EOK) 1258 return rc; 1259 1260 if (client_receiver != NULL) 1261 async_new_connection(task_hash, phone_hash, 0, NULL, 1262 client_receiver); 1263 1264 return EOK; 1265 } 1266 1237 1267 /** Wrapper for making IPC_M_CONNECT_ME_TO calls using the async framework. 1238 * 1268 * 1239 1269 * Ask through phone for a new connection to some service. 1240 1270 * 1241 * @param phone idPhone handle used for contacting the other side.1242 * @param arg1 1243 * @param arg2 1244 * @param arg3 1245 * 1246 * @return 1247 * /1248 int 1249 async_connect_me_to(int phoneid, sysarg_t arg1, sysarg_t arg2, sysarg_t arg3) 1250 { 1251 int rc; 1271 * @param phone Phone handle used for contacting the other side. 1272 * @param arg1 User defined argument. 1273 * @param arg2 User defined argument. 1274 * @param arg3 User defined argument. 1275 * 1276 * @return New phone handle on success or a negative error code. 1277 * 1278 */ 1279 int async_connect_me_to(int phone, sysarg_t arg1, sysarg_t arg2, 1280 sysarg_t arg3) 1281 { 1252 1282 sysarg_t newphid; 1253 1254 rc = async_req_3_5(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, arg3, NULL, 1255 NULL, NULL, NULL, &newphid); 1256 1257 if (rc != EOK) 1283 int rc = async_req_3_5(phone, IPC_M_CONNECT_ME_TO, arg1, arg2, arg3, 1284 NULL, NULL, NULL, NULL, &newphid); 1285 1286 if (rc != EOK) 1258 1287 return rc; 1259 1288 1260 1289 return newphid; 1261 1290 } 1262 1291 1263 1292 /** Wrapper for making IPC_M_CONNECT_ME_TO calls using the async framework. 1264 * 1293 * 1265 1294 * Ask through phone for a new connection to some service and block until 1266 1295 * success. 1267 1296 * 1268 * @param phoneid 1269 * @param arg1 1270 * @param arg2 1271 * @param arg3 1272 * 1273 * @return 1274 * /1275 int 1276 async_connect_me_to_blocking(int phoneid, sysarg_t arg1, sysarg_t arg2,1297 * @param phoneid Phone handle used for contacting the other side. 1298 * @param arg1 User defined argument. 1299 * @param arg2 User defined argument. 1300 * @param arg3 User defined argument. 1301 * 1302 * @return New phone handle on success or a negative error code. 1303 * 1304 */ 1305 int async_connect_me_to_blocking(int phoneid, sysarg_t arg1, sysarg_t arg2, 1277 1306 sysarg_t arg3) 1278 1307 { 1279 int rc;1280 1308 sysarg_t newphid; 1281 1282 rc = async_req_4_5(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, arg3, 1309 int rc = async_req_4_5(phoneid, IPC_M_CONNECT_ME_TO, arg1, arg2, arg3, 1283 1310 IPC_FLAG_BLOCKING, NULL, NULL, NULL, NULL, &newphid); 1284 1311 1285 if (rc != EOK) 1312 if (rc != EOK) 1286 1313 return rc; 1287 1314 1288 1315 return newphid; 1289 1316 } -
uspace/lib/c/generic/clipboard.c
rae0300b5 r007e6efa 39 39 40 40 #include <clipboard.h> 41 #include <ipc/ns.h> 41 42 #include <ipc/services.h> 42 43 #include <ipc/clipboard.h> … … 54 55 { 55 56 while (clip_phone < 0) 56 clip_phone = ipc_connect_me_to_blocking(PHONE_NS,SERVICE_CLIPBOARD, 0, 0);57 clip_phone = service_connect_blocking(SERVICE_CLIPBOARD, 0, 0); 57 58 } 58 59 -
uspace/lib/c/generic/devmap.c
rae0300b5 r007e6efa 31 31 #include <ipc/ipc.h> 32 32 #include <ipc/services.h> 33 #include <ipc/ns.h> 33 34 #include <ipc/devmap.h> 34 35 #include <devmap.h> … … 50 51 51 52 if (flags & IPC_FLAG_BLOCKING) 52 devmap_phone_driver = ipc_connect_me_to_blocking(PHONE_NS,53 SERVICE_DEVMAP,DEVMAP_DRIVER, 0);53 devmap_phone_driver = service_connect_blocking(SERVICE_DEVMAP, 54 DEVMAP_DRIVER, 0); 54 55 else 55 devmap_phone_driver = ipc_connect_me_to(PHONE_NS,56 SERVICE_DEVMAP,DEVMAP_DRIVER, 0);56 devmap_phone_driver = service_connect(SERVICE_DEVMAP, 57 DEVMAP_DRIVER, 0); 57 58 58 59 return devmap_phone_driver; … … 62 63 63 64 if (flags & IPC_FLAG_BLOCKING) 64 devmap_phone_client = ipc_connect_me_to_blocking(PHONE_NS,65 SERVICE_DEVMAP,DEVMAP_CLIENT, 0);65 devmap_phone_client = service_connect_blocking(SERVICE_DEVMAP, 66 DEVMAP_CLIENT, 0); 66 67 else 67 devmap_phone_client = ipc_connect_me_to(PHONE_NS,68 SERVICE_DEVMAP,DEVMAP_CLIENT, 0);68 devmap_phone_client = service_connect(SERVICE_DEVMAP, 69 DEVMAP_CLIENT, 0); 69 70 70 71 return devmap_phone_client; -
uspace/lib/c/generic/loader.c
rae0300b5 r007e6efa 36 36 #include <ipc/loader.h> 37 37 #include <ipc/services.h> 38 #include <ipc/ns.h> 38 39 #include <libc.h> 39 40 #include <task.h> … … 63 64 loader_t *loader_connect(void) 64 65 { 65 int phone_id = ipc_connect_me_to_blocking(PHONE_NS,SERVICE_LOAD, 0, 0);66 int phone_id = service_connect_blocking(SERVICE_LOAD, 0, 0); 66 67 if (phone_id < 0) 67 68 return NULL; -
uspace/lib/c/generic/vfs/vfs.c
rae0300b5 r007e6efa 45 45 #include <ipc/ipc.h> 46 46 #include <ipc/services.h> 47 #include <ipc/ns.h> 47 48 #include <async.h> 48 49 #include <fibril_synch.h> … … 118 119 static void vfs_connect(void) 119 120 { 120 while (vfs_phone < 0) { 121 vfs_phone = async_connect_me_to_blocking(PHONE_NS, SERVICE_VFS, 122 0, 0); 123 } 121 while (vfs_phone < 0) 122 vfs_phone = service_connect_blocking(SERVICE_VFS, 0, 0); 124 123 125 124 async_session_create(&vfs_session, vfs_phone, 0); -
uspace/lib/c/include/async.h
rae0300b5 r007e6efa 266 266 } 267 267 268 extern int async_connect_to_me(int, sysarg_t, sysarg_t, sysarg_t, 269 async_client_conn_t); 268 270 extern int async_connect_me_to(int, sysarg_t, sysarg_t, sysarg_t); 269 271 extern int async_connect_me_to_blocking(int, sysarg_t, sysarg_t, sysarg_t); -
uspace/lib/c/include/ipc/ns.h
rae0300b5 r007e6efa 36 36 #define LIBIPC_NS_H_ 37 37 38 #include <sys/types.h> 38 39 #include <ipc/ipc.h> 39 40 … … 45 46 } ns_request_t; 46 47 48 extern int service_register(sysarg_t); 49 extern int service_connect(sysarg_t, sysarg_t, sysarg_t); 50 extern int service_connect_blocking(sysarg_t, sysarg_t, sysarg_t); 51 52 extern wchar_t *service_klog_share_in(size_t *); 53 47 54 #endif 48 55 -
uspace/srv/clip/clip.c
rae0300b5 r007e6efa 29 29 #include <stdio.h> 30 30 #include <bool.h> 31 #include <async.h> 31 32 #include <ipc/ipc.h> 32 #include < async.h>33 #include <ipc/ns.h> 33 34 #include <ipc/services.h> 34 35 #include <ipc/clipboard.h> … … 183 184 async_set_client_connection(clip_connection); 184 185 185 if ( ipc_connect_to_me(PHONE_NS, SERVICE_CLIPBOARD, 0, 0, NULL, NULL))186 if (service_register(SERVICE_CLIPBOARD) != EOK) 186 187 return -1; 187 188 -
uspace/srv/devman/main.c
rae0300b5 r007e6efa 586 586 587 587 /* Register device manager at naming service. */ 588 if ( ipc_connect_to_me(PHONE_NS, SERVICE_DEVMAN, 0, 0, NULL, NULL) != 0)588 if (service_register(SERVICE_DEVMAN) != EOK) 589 589 return -1; 590 590 -
uspace/srv/devmap/devmap.c
rae0300b5 r007e6efa 1150 1150 1151 1151 /* Register device mapper at naming service */ 1152 if ( ipc_connect_to_me(PHONE_NS, SERVICE_DEVMAP, 0, 0, NULL, NULL) != 0)1152 if (service_register(SERVICE_DEVMAP) != EOK) 1153 1153 return -1; 1154 1154 -
uspace/srv/fs/devfs/devfs.c
rae0300b5 r007e6efa 42 42 #include <ipc/ipc.h> 43 43 #include <ipc/services.h> 44 #include <ipc/ns.h> 44 45 #include <async.h> 45 46 #include <errno.h> … … 126 127 } 127 128 128 int vfs_phone = ipc_connect_me_to_blocking(PHONE_NS,SERVICE_VFS, 0, 0);129 int vfs_phone = service_connect_blocking(SERVICE_VFS, 0, 0); 129 130 if (vfs_phone < EOK) { 130 131 printf(NAME ": Unable to connect to VFS\n"); -
uspace/srv/fs/fat/fat.c
rae0300b5 r007e6efa 40 40 #include <ipc/ipc.h> 41 41 #include <ipc/services.h> 42 #include <ipc/ns.h> 42 43 #include <async.h> 43 44 #include <errno.h> … … 153 154 goto err; 154 155 155 vfs_phone = ipc_connect_me_to_blocking(PHONE_NS,SERVICE_VFS, 0, 0);156 vfs_phone = service_connect_blocking(SERVICE_VFS, 0, 0); 156 157 if (vfs_phone < EOK) { 157 158 printf(NAME ": failed to connect to VFS\n"); -
uspace/srv/fs/tmpfs/tmpfs.c
rae0300b5 r007e6efa 44 44 #include <ipc/ipc.h> 45 45 #include <ipc/services.h> 46 #include <ipc/ns.h> 46 47 #include <async.h> 47 48 #include <errno.h> … … 157 158 } 158 159 159 int vfs_phone = ipc_connect_me_to_blocking(PHONE_NS,SERVICE_VFS, 0, 0);160 int vfs_phone = service_connect_blocking(SERVICE_VFS, 0, 0); 160 161 if (vfs_phone < EOK) { 161 162 printf(NAME ": Unable to connect to VFS\n"); -
uspace/srv/hid/console/console.c
rae0300b5 r007e6efa 40 40 #include <ipc/fb.h> 41 41 #include <ipc/services.h> 42 #include <ipc/ns.h> 42 43 #include <errno.h> 43 44 #include <ipc/console.h> … … 762 763 763 764 /* Connect to framebuffer driver */ 764 fb_info.phone = ipc_connect_me_to_blocking(PHONE_NS,SERVICE_VIDEO, 0, 0);765 fb_info.phone = service_connect_blocking(SERVICE_VIDEO, 0, 0); 765 766 if (fb_info.phone < 0) { 766 767 printf(NAME ": Failed to connect to video service\n"); … … 838 839 839 840 /* Receive kernel notifications */ 841 async_set_interrupt_received(interrupt_received); 840 842 if (event_subscribe(EVENT_KCONSOLE, 0) != EOK) 841 843 printf(NAME ": Error registering kconsole notifications\n"); 842 843 async_set_interrupt_received(interrupt_received);844 844 845 845 return true; -
uspace/srv/hid/fb/main.c
rae0300b5 r007e6efa 29 29 #include <ipc/ipc.h> 30 30 #include <ipc/services.h> 31 #include <ipc/ns.h> 31 32 #include <sysinfo.h> 32 33 #include <async.h> … … 114 115 return -1; 115 116 116 if ( ipc_connect_to_me(PHONE_NS, SERVICE_VIDEO, 0, 0, NULL, NULL) != 0)117 if (service_register(SERVICE_VIDEO) != EOK) 117 118 return -1; 118 119 -
uspace/srv/hid/kbd/generic/kbd.c
rae0300b5 r007e6efa 223 223 224 224 if (cir_service) { 225 while (cir_phone < 0) { 226 cir_phone = ipc_connect_me_to_blocking(PHONE_NS, cir_service, 227 0, 0); 228 } 225 while (cir_phone < 0) 226 cir_phone = service_connect_blocking(cir_service, 0, 0); 229 227 } 230 228 -
uspace/srv/hw/irc/apic/apic.c
rae0300b5 r007e6efa 108 108 109 109 async_set_client_connection(apic_connection); 110 ipc_connect_to_me(PHONE_NS, SERVICE_APIC, 0, 0, NULL, NULL);110 service_register(SERVICE_APIC); 111 111 112 112 return true; -
uspace/srv/hw/irc/fhc/fhc.c
rae0300b5 r007e6efa 137 137 138 138 async_set_client_connection(fhc_connection); 139 ipc_connect_to_me(PHONE_NS, SERVICE_FHC, 0, 0, NULL, NULL);139 service_register(SERVICE_FHC); 140 140 141 141 return true; -
uspace/srv/hw/irc/i8259/i8259.c
rae0300b5 r007e6efa 150 150 151 151 async_set_client_connection(i8259_connection); 152 ipc_connect_to_me(PHONE_NS, SERVICE_I8259, 0, 0, NULL, NULL);152 service_register(SERVICE_I8259); 153 153 154 154 return true; -
uspace/srv/hw/irc/obio/obio.c
rae0300b5 r007e6efa 138 138 139 139 async_set_client_connection(obio_connection); 140 ipc_connect_to_me(PHONE_NS, SERVICE_OBIO, 0, 0, NULL, NULL);140 service_register(SERVICE_OBIO); 141 141 142 142 return true; -
uspace/srv/hw/netif/ne2000/ne2000.c
rae0300b5 r007e6efa 45 45 #include <ipc/ipc.h> 46 46 #include <ipc/services.h> 47 #include <ipc/ns.h> 47 48 #include <ipc/irc.h> 48 49 #include <net/modules.h> … … 389 390 390 391 if (irc_service) { 391 while (irc_phone < 0) { 392 irc_phone = ipc_connect_me_to_blocking(PHONE_NS, irc_service, 393 0, 0); 394 } 392 while (irc_phone < 0) 393 irc_phone = service_connect_blocking(irc_service, 0, 0); 395 394 } 396 395 -
uspace/srv/loader/main.c
rae0300b5 r007e6efa 95 95 96 96 /** Used to limit number of connections to one. */ 97 static bool connected ;97 static bool connected = false; 98 98 99 99 static void ldr_get_taskid(ipc_callid_t rid, ipc_call_t *request) … … 423 423 int main(int argc, char *argv[]) 424 424 { 425 task_id_t id; 426 int rc; 427 428 connected = false; 429 425 /* Set a handler of incomming connections. */ 426 async_set_client_connection(ldr_connection); 427 430 428 /* Introduce this task to the NS (give it our task ID). */ 431 id = task_get_id();432 rc = async_req_2_0(PHONE_NS, NS_ID_INTRO, LOWER32(id), UPPER32(id));429 task_id_t id = task_get_id(); 430 int rc = async_req_2_0(PHONE_NS, NS_ID_INTRO, LOWER32(id), UPPER32(id)); 433 431 if (rc != EOK) 434 432 return -1; 435 436 /* Set a handler of incomming connections. */437 async_set_client_connection(ldr_connection);438 433 439 434 /* Register at naming service. */ 440 if ( ipc_connect_to_me(PHONE_NS, SERVICE_LOAD, 0, 0, NULL, NULL) != 0)435 if (service_register(SERVICE_LOAD) != EOK) 441 436 return -2; 442 437 443 438 async_manager(); 444 439 -
uspace/srv/ns/clonable.c
rae0300b5 r007e6efa 92 92 93 93 ipc_forward_fast(csr->callid, phone, IPC_GET_ARG2(csr->call), 94 94 IPC_GET_ARG3(csr->call), 0, IPC_FF_NONE); 95 95 96 96 free(csr); … … 127 127 } 128 128 129 link_initialize(&csr->link); 129 130 csr->service = service; 130 131 csr->call = *call; -
uspace/srv/ns/service.c
rae0300b5 r007e6efa 43 43 typedef struct { 44 44 link_t link; 45 sysarg_t service; /**< Number of the service. */45 sysarg_t service; /**< Service ID. */ 46 46 sysarg_t phone; /**< Phone registered with the service. */ 47 47 sysarg_t in_phone_hash; /**< Incoming phone hash. */ … … 56 56 * 57 57 */ 58 static hash_index_t service_hash(unsigned long *key)58 static hash_index_t service_hash(unsigned long key[]) 59 59 { 60 60 assert(key); 61 return ( *key% SERVICE_HASH_TABLE_CHAINS);61 return (key[0] % SERVICE_HASH_TABLE_CHAINS); 62 62 } 63 63 … … 86 86 87 87 if (keys == 2) 88 return ( key[1] == hs->in_phone_hash);88 return ((key[0] == hs->service) && (key[1] == hs->in_phone_hash)); 89 89 else 90 90 return (key[0] == hs->service); … … 195 195 hash_table_insert(&service_hash_table, keys, &hs->link); 196 196 197 return 0;197 return EOK; 198 198 } 199 199 … … 227 227 } 228 228 229 link_initialize(&pr->link); 229 230 pr->service = service; 230 231 pr->callid = callid; -
uspace/srv/ns/task.c
rae0300b5 r007e6efa 43 43 44 44 #define TASK_HASH_TABLE_CHAINS 256 45 #define P2I_HASH_TABLE_CHAINS 256 46 47 static int get_id_by_phone(sysarg_t phone_hash, task_id_t *id); 45 #define P2I_HASH_TABLE_CHAINS 256 48 46 49 47 /* TODO: … … 57 55 typedef struct { 58 56 link_t link; 59 task_id_t id; /**< Task ID. */ 60 bool finished; /**< Task is done. */ 61 bool have_rval; /**< Task returned a value. */ 62 int retval; /**< The return value. */ 57 58 task_id_t id; /**< Task ID. */ 59 bool finished; /**< Task is done. */ 60 bool have_rval; /**< Task returned a value. */ 61 int retval; /**< The return value. */ 63 62 } hashed_task_t; 64 63 … … 71 70 * 72 71 */ 73 static hash_index_t task_hash(unsigned long *key)72 static hash_index_t task_hash(unsigned long key[]) 74 73 { 75 74 assert(key); 76 return (LOWER32( *key) % TASK_HASH_TABLE_CHAINS);75 return (LOWER32(key[0]) % TASK_HASH_TABLE_CHAINS); 77 76 } 78 77 … … 124 123 typedef struct { 125 124 link_t link; 126 sysarg_t phash; /**< Task ID. */127 task_id_t id; /**< Task ID. */125 sysarg_t in_phone_hash; /**< Incoming phone hash. */ 126 task_id_t id; /**< Task ID. */ 128 127 } p2i_entry_t; 129 128 … … 131 130 * 132 131 * @param key Array of keys. 132 * 133 133 * @return Hash index corresponding to key[0]. 134 134 * 135 135 */ 136 static hash_index_t p2i_hash(unsigned long *key)136 static hash_index_t p2i_hash(unsigned long key[]) 137 137 { 138 138 assert(key); 139 return ( *key% TASK_HASH_TABLE_CHAINS);139 return (key[0] % TASK_HASH_TABLE_CHAINS); 140 140 } 141 141 … … 154 154 assert(keys == 1); 155 155 assert(item); 156 157 p2i_entry_t *e = hash_table_get_instance(item, p2i_entry_t, link);158 159 return (key[0] == e ->phash);156 157 p2i_entry_t *entry = hash_table_get_instance(item, p2i_entry_t, link); 158 159 return (key[0] == entry->in_phone_hash); 160 160 } 161 161 … … 197 197 return ENOMEM; 198 198 } 199 199 200 200 if (!hash_table_create(&phone_to_id, P2I_HASH_TABLE_CHAINS, 201 201 1, &p2i_ops)) { … … 205 205 206 206 list_initialize(&pending_wait); 207 208 207 return EOK; 209 208 } … … 238 237 ht->retval); 239 238 } 240 239 241 240 hash_table_remove(&task_hash_table, keys, 2); 242 241 list_remove(cur); … … 250 249 sysarg_t retval; 251 250 task_exit_t texit; 252 251 253 252 unsigned long keys[2] = { 254 253 LOWER32(id), 255 254 UPPER32(id) 256 255 }; 257 256 258 257 link_t *link = hash_table_find(&task_hash_table, keys); 259 258 hashed_task_t *ht = (link != NULL) ? 260 259 hash_table_get_instance(link, hashed_task_t, link) : NULL; 261 260 262 261 if (ht == NULL) { 263 262 /* No such task exists. */ … … 265 264 return; 266 265 } 267 266 268 267 if (!ht->finished) { 269 268 /* Add to pending list */ … … 275 274 } 276 275 276 link_initialize(&pr->link); 277 277 pr->id = id; 278 278 pr->callid = callid; … … 293 293 int ns_task_id_intro(ipc_call_t *call) 294 294 { 295 task_id_t id;296 295 unsigned long keys[2]; 297 link_t *link; 298 p2i_entry_t *e; 299 hashed_task_t *ht; 300 301 id = MERGE_LOUP32(IPC_GET_ARG1(*call), IPC_GET_ARG2(*call)); 302 296 297 task_id_t id = MERGE_LOUP32(IPC_GET_ARG1(*call), IPC_GET_ARG2(*call)); 303 298 keys[0] = call->in_phone_hash; 304 305 link = hash_table_find(&phone_to_id, keys);299 300 link_t *link = hash_table_find(&phone_to_id, keys); 306 301 if (link != NULL) 307 302 return EEXISTS; 308 309 e= (p2i_entry_t *) malloc(sizeof(p2i_entry_t));310 if (e == NULL)303 304 p2i_entry_t *entry = (p2i_entry_t *) malloc(sizeof(p2i_entry_t)); 305 if (entry == NULL) 311 306 return ENOMEM; 312 313 h t = (hashed_task_t *) malloc(sizeof(hashed_task_t));307 308 hashed_task_t *ht = (hashed_task_t *) malloc(sizeof(hashed_task_t)); 314 309 if (ht == NULL) 315 310 return ENOMEM; 316 317 /* Insert to phone-to-id map. */ 318 319 link_initialize(&e->link); 320 e->phash = call->in_phone_hash; 321 e->id = id; 322 hash_table_insert(&phone_to_id, keys, &e->link); 323 324 /* Insert to main table. */ 325 311 312 /* 313 * Insert into the phone-to-id map. 314 */ 315 316 link_initialize(&entry->link); 317 entry->in_phone_hash = call->in_phone_hash; 318 entry->id = id; 319 hash_table_insert(&phone_to_id, keys, &entry->link); 320 321 /* 322 * Insert into the main table. 323 */ 324 326 325 keys[0] = LOWER32(id); 327 326 keys[1] = UPPER32(id); 328 327 329 328 link_initialize(&ht->link); 330 329 ht->id = id; … … 333 332 ht->retval = -1; 334 333 hash_table_insert(&task_hash_table, keys, &ht->link); 335 334 336 335 return EOK; 337 336 } 338 337 338 static int get_id_by_phone(sysarg_t phone_hash, task_id_t *id) 339 { 340 unsigned long keys[1] = {phone_hash}; 341 342 link_t *link = hash_table_find(&phone_to_id, keys); 343 if (link == NULL) 344 return ENOENT; 345 346 p2i_entry_t *entry = hash_table_get_instance(link, p2i_entry_t, link); 347 *id = entry->id; 348 349 return EOK; 350 } 351 339 352 int ns_task_retval(ipc_call_t *call) 340 353 { 341 354 task_id_t id; 342 unsigned long keys[2]; 343 int rc; 344 345 rc = get_id_by_phone(call->in_phone_hash, &id); 355 int rc = get_id_by_phone(call->in_phone_hash, &id); 346 356 if (rc != EOK) 347 357 return rc; 348 349 keys[0] = LOWER32(id); 350 keys[1] = UPPER32(id); 358 359 unsigned long keys[2] = { 360 LOWER32(id), 361 UPPER32(id) 362 }; 351 363 352 364 link_t *link = hash_table_find(&task_hash_table, keys); … … 354 366 hash_table_get_instance(link, hashed_task_t, link) : NULL; 355 367 356 if ((ht == NULL) || ht->finished)368 if ((ht == NULL) || (ht->finished)) 357 369 return EINVAL; 358 370 359 371 ht->finished = true; 360 372 ht->have_rval = true; 361 373 ht->retval = IPC_GET_ARG1(*call); 362 374 363 375 return EOK; 364 376 } … … 367 379 { 368 380 unsigned long keys[2]; 381 369 382 task_id_t id; 370 int rc; 371 372 rc = get_id_by_phone(call->in_phone_hash, &id); 383 int rc = get_id_by_phone(call->in_phone_hash, &id); 373 384 if (rc != EOK) 374 385 return rc; 375 386 376 387 /* Delete from phone-to-id map. */ 377 388 keys[0] = call->in_phone_hash; 378 389 hash_table_remove(&phone_to_id, keys, 1); 379 390 380 391 /* Mark task as finished. */ 381 392 keys[0] = LOWER32(id); 382 393 keys[1] = UPPER32(id); 383 394 384 395 link_t *link = hash_table_find(&task_hash_table, keys); 385 396 hashed_task_t *ht = … … 387 398 if (ht == NULL) 388 399 return EOK; 389 400 390 401 ht->finished = true; 391 392 return EOK; 393 } 394 395 static int get_id_by_phone(sysarg_t phone_hash, task_id_t *id) 396 { 397 unsigned long keys[1]; 398 link_t *link; 399 p2i_entry_t *e; 400 401 keys[0] = phone_hash; 402 link = hash_table_find(&phone_to_id, keys); 403 if (link == NULL) 404 return ENOENT; 405 406 e = hash_table_get_instance(link, p2i_entry_t, link); 407 *id = e->id; 408 402 409 403 return EOK; 410 404 } -
uspace/srv/ns/task.h
rae0300b5 r007e6efa 39 39 extern void process_pending_wait(void); 40 40 41 extern void wait_for_task(task_id_t id, ipc_call_t *call, ipc_callid_t callid);41 extern void wait_for_task(task_id_t, ipc_call_t *, ipc_callid_t); 42 42 43 extern int ns_task_id_intro(ipc_call_t * call);44 extern int ns_task_disconnect(ipc_call_t * call);45 extern int ns_task_retval(ipc_call_t * call);43 extern int ns_task_id_intro(ipc_call_t *); 44 extern int ns_task_disconnect(ipc_call_t *); 45 extern int ns_task_retval(ipc_call_t *); 46 46 47 47 -
uspace/srv/vfs/vfs.c
rae0300b5 r007e6efa 38 38 #include <ipc/ipc.h> 39 39 #include <ipc/services.h> 40 #include <ipc/ns.h> 40 41 #include <async.h> 41 42 #include <errno.h> … … 47 48 #include "vfs.h" 48 49 49 #define NAME "vfs"50 #define NAME "vfs" 50 51 51 52 static void vfs_connection(ipc_callid_t iid, ipc_call_t *icall) … … 172 173 * Register at the naming service. 173 174 */ 174 ipc_connect_to_me(PHONE_NS, SERVICE_VFS, 0, 0, NULL, NULL); 175 if (service_register(SERVICE_VFS) != EOK) { 176 printf("%s: Cannot register VFS service\n", NAME); 177 return EINVAL; 178 } 175 179 176 180 /*
Note:
See TracChangeset
for help on using the changeset viewer.