Changeset 63a3276 in mainline
- Timestamp:
- 2019-08-06T19:20:35Z (5 years ago)
- Children:
- 3f05ef7
- Parents:
- 72c8f77
- git-author:
- Michal Koutný <xm.koutny+hos@…> (2015-06-17 23:02:03)
- git-committer:
- Matthieu Riolo <matthieu.riolo@…> (2019-08-06 19:20:35)
- Location:
- uspace
- Files:
-
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/generic/loc.c
r72c8f77 r63a3276 329 329 async_exch_t *exch; 330 330 331 if ( flags & IPC_FLAG_BLOCKING)331 if ((flags & IPC_FLAG_BLOCKING) || flags & IPC_FLAG_AUTOSTART) 332 332 exch = loc_exchange_begin_blocking(INTERFACE_LOC_CONSUMER); 333 333 else { -
uspace/srv/devman/driver.c
r72c8f77 r63a3276 186 186 187 187 return drv_cnt; 188 } 189 190 /** Get name of unit that represents the driver 191 * 192 * @param[in] drv 193 * @param[out] unit_name_ptr should be free'd after use, not touched on fail 194 * 195 * @return EOK on success 196 * @return ENOMEM 197 */ 198 errno_t driver_unit_name(driver_t *drv, char **unit_name_ptr) 199 { 200 char *unit_name = NULL; 201 asprintf(&unit_name, "%s%c%s", drv->name, UNIT_NAME_SEPARATOR, 202 UNIT_SVC_TYPE_NAME); 203 204 if (unit_name == NULL) { 205 return ENOMEM; 206 } else { 207 *unit_name_ptr = unit_name; 208 return EOK; 209 } 188 210 } 189 211 … … 320 342 321 343 char *unit_name = NULL; 322 asprintf(&unit_name, "%s%c%s", drv->name, UNIT_NAME_SEPARATOR, 323 UNIT_SVC_TYPE_NAME); 324 if (unit_name == NULL) { 344 if (driver_unit_name(drv, &unit_name) != EOK) { 325 345 return false; 326 346 } … … 333 353 int flags = 0; 334 354 rc = sysman_unit_start(unit_name, flags); 355 free(unit_name); 335 356 336 357 if (rc != EOK) { … … 338 359 "Request to start driver `%s' failed: %s.", 339 360 drv->name, str_error(rc)); 340 free(unit_name);341 361 return false; 342 362 } 343 363 344 364 drv->state = DRIVER_STARTING; 345 free(unit_name);346 365 return true; 347 366 } -
uspace/srv/devman/driver.h
r72c8f77 r63a3276 42 42 extern bool get_driver_info(const char *, const char *, driver_t *); 43 43 extern int lookup_available_drivers(driver_list_t *, const char *); 44 extern int driver_unit_name(driver_t *, char **); 44 45 45 46 extern driver_t *find_best_match_driver(driver_list_t *, dev_node_t *); -
uspace/srv/devman/drv_conn.c
r72c8f77 r63a3276 36 36 37 37 #include <assert.h> 38 #include <async.h> 39 #include <errno.h> 40 #include <fibril_synch.h> 41 #include <io/log.h> 42 #include <ipc/devman.h> 43 #include <ipc/driver.h> 38 44 #include <ipc/services.h> 45 #include <loc.h> 39 46 #include <ns.h> 40 #include < async.h>47 #include <stdbool.h> 41 48 #include <stdio.h> 42 #include <errno.h>43 #include <str_error.h>44 #include <stdbool.h>45 #include <fibril_synch.h>46 49 #include <stdlib.h> 47 50 #include <str.h> 48 #include <io/log.h> 49 #include <ipc/devman.h> 50 #include <loc.h> 51 #include <str_error.h> 52 #include <sysman/broker.h> 51 53 52 54 #include "client_conn.h" … … 67 69 driver_t *driver = NULL; 68 70 char *drv_name = NULL; 71 char *unit_name = NULL; 69 72 70 73 log_msg(LOG_DEFAULT, LVL_DEBUG, "devman_driver_register"); … … 104 107 } 105 108 109 /* Notify sysman about started driver */ 110 rc = driver_unit_name(driver, &unit_name); 111 if (rc != EOK) { 112 fibril_mutex_unlock(&driver->driver_mutex); 113 async_answer_0(callid, rc); 114 return NULL; 115 } 116 sysman_main_exposee_added(unit_name, call->in_task_id); 117 free(unit_name); 118 106 119 switch (driver->state) { 107 120 case DRIVER_NOT_STARTED: -
uspace/srv/hid/compositor/compositor.c
r72c8f77 r63a3276 2267 2267 if (!list_empty(&viewport_list)) 2268 2268 input_activate(input); 2269 2270 2269 ret: 2271 2270 fibril_mutex_unlock(&discovery_mtx); … … 2285 2284 bg_color = PIXEL(255, 69, 51, 103); 2286 2285 2287 /* Register compositor server. */ 2288 async_set_fallback_port_handler(client_connection, NULL); 2289 2290 errno_t rc = loc_server_register(NAME); 2286 /* Establish input bidirectional connection. */ 2287 errno_t rc = input_connect(input_svc); 2288 if (rc != EOK) { 2289 printf("%s: Failed to connect to input service.\n", NAME); 2290 return rc; 2291 } 2292 2293 rc = loc_register_cat_change_cb(category_change_cb, NULL); 2294 if (rc != EOK) { 2295 printf("%s: Failed to register category change callback\n", NAME); 2296 input_disconnect(); 2297 return rc; 2298 } 2299 2300 discover_viewports(); 2301 2302 comp_restrict_pointers(); 2303 comp_damage(0, 0, UINT32_MAX, UINT32_MAX); 2304 2305 /* Finally, register compositor server. */ 2306 async_set_fallback_port_handler(client_connection); 2307 2308 rc = loc_server_register(NAME); 2291 2309 if (rc != EOK) { 2292 2310 printf("%s: Unable to register server (%s)\n", NAME, str_error(rc)); 2293 return -1;2294 } 2295 2311 return rc; 2312 } 2313 2296 2314 server_name = name; 2297 2298 char svc[LOC_NAME_MAXLEN + 1]; 2299 snprintf(svc, LOC_NAME_MAXLEN, "%s/%s", NAMESPACE, server_name); 2300 2301 service_id_t service_id; 2302 rc = loc_service_register(svc, &service_id); 2303 if (rc != EOK) { 2304 printf("%s: Unable to register service %s\n", NAME, svc); 2305 return rc; 2306 } 2307 2315 2308 2316 /* Prepare window registrator (entrypoint for clients). */ 2309 2317 char winreg[LOC_NAME_MAXLEN + 1]; … … 2311 2319 if (loc_service_register(winreg, &winreg_id) != EOK) { 2312 2320 printf("%s: Unable to register service %s\n", NAME, winreg); 2313 return -1;2314 }2315 2316 /* Establish input bidirectional connection. */2317 rc = input_connect(input_svc);2318 if (rc != EOK) {2319 printf("%s: Failed to connect to input service.\n", NAME);2320 2321 return rc; 2321 2322 } 2322 2323 rc = loc_register_cat_change_cb(category_change_cb, NULL);2324 if (rc != EOK) {2325 printf("%s: Failed to register category change callback\n", NAME);2326 input_disconnect();2327 return rc;2328 }2329 2330 discover_viewports();2331 2332 comp_restrict_pointers();2333 comp_damage(0, 0, UINT32_MAX, UINT32_MAX);2334 2323 2335 2324 return EOK; -
uspace/srv/locsrv/locsrv.c
r72c8f77 r63a3276 64 64 } cb_sess_t; 65 65 66 typedef enum { 67 NAME_TO_START, 68 NAME_TO_EXPOSE 69 } unit_name_t; 70 66 71 LIST_INITIALIZE(services_list); 67 72 LIST_INITIALIZE(namespaces_list); … … 335 340 } 336 341 337 static int loc_service_request_start(const char *ns_name, const char *name) 342 /** Derive unit name from service name according to purpose 343 * 344 * All services in 'device' namespace are considered to be drivers and 345 * devman is thus requested to start. Otherwise name of unit is made 346 * from fully qualified name of service (namespace separator is changed 347 * for usage in unit name. 348 */ 349 static int loc_service_unit_name(const char *ns_name, const char *name, 350 unit_name_t name_type, char **unit_name_ptr) 338 351 { 339 352 char *service_name = NULL; 340 341 /* 342 * All services in 'device' namespace are considered to be drivers and 343 * devman is thus requested to start. Otherwise name of unit is made 344 * from fully qualified name of service (namespace separator is changed 345 * for usage in unit name. 346 */ 347 if (str_cmp(ns_name, LOC_DEVICE_NAMESPACE) == 0) { 353 if (name_type == NAME_TO_START && 354 str_cmp(ns_name, LOC_DEVICE_NAMESPACE) == 0) { 348 355 asprintf(&service_name, "%s", SERVICE_NAME_DEVMAN); 349 356 } else if (str_cmp(ns_name, "") == 0) { … … 365 372 } 366 373 367 int rc = sysman_unit_start(unit_name, IPC_FLAG_BLOCKING); 374 *unit_name_ptr = unit_name; 375 return EOK; 376 } 377 378 static int loc_service_request_start(const char *ns_name, const char *name) 379 { 380 char *unit_name; 381 int rc = loc_service_unit_name(ns_name, name, NAME_TO_START, &unit_name); 382 if (rc != EOK) { 383 return rc; 384 } 385 386 rc = sysman_unit_start(unit_name, IPC_FLAG_BLOCKING); 368 387 free(unit_name); 369 free(service_name);370 388 return rc; 371 389 } … … 555 573 return; 556 574 } 575 576 /* Notify sysman about new exposee */ 577 char *unit_name = NULL; 578 rc = loc_service_unit_name(namespace->name, service->name, 579 NAME_TO_EXPOSE, &unit_name); 580 if (rc != EOK) { 581 loc_namespace_destroy(namespace); 582 fibril_mutex_unlock(&services_list_mutex); 583 free(service->name); 584 free(service); 585 free(unit_name); 586 async_answer_0(iid, rc); 587 return; 588 } 589 590 if (str_cmp(namespace->name, LOC_DEVICE_NAMESPACE) == 0) { 591 sysman_exposee_added(unit_name); 592 } else { 593 sysman_main_exposee_added(unit_name, icall->in_task_id); 594 } 595 free(unit_name); 557 596 558 597 /* Get unique service ID */ … … 837 876 } 838 877 839 if ( flags & IPC_FLAG_BLOCKING) {878 if ((flags & IPC_FLAG_BLOCKING) || flags & IPC_FLAG_AUTOSTART) { 840 879 fibril_condvar_wait(&services_list_cv, 841 880 &services_list_mutex); -
uspace/srv/sysman/connection_broker.c
r72c8f77 r63a3276 29 29 #include <errno.h> 30 30 #include <ipc/sysman.h> 31 #include <stdlib.h> 31 32 33 #include "configuration.h" 32 34 #include "connection_broker.h" 33 35 #include "log.h" 36 #include "sysman.h" 34 37 35 38 static void sysman_broker_register(ipc_callid_t iid, ipc_call_t *icall) … … 54 57 static void sysman_main_exposee_added(ipc_callid_t iid, ipc_call_t *icall) 55 58 { 56 sysman_log(LVL_DEBUG2, "%s", __func__); 57 async_answer_0(iid, ENOTSUP); 58 // TODO implement 59 char *unit_name = NULL; 60 sysarg_t retval; 61 62 int rc = async_data_write_accept((void **) &unit_name, true, 63 0, 0, 0, NULL); 64 if (rc != EOK) { 65 retval = rc; 66 goto finish; 67 } 68 69 unit_t *unit = configuration_find_unit_by_name(unit_name); 70 if (unit == NULL) { 71 //sysman_log(LVL_NOTE, "Unit '%s' not found.", unit_name); 72 retval = ENOENT; 73 goto finish; 74 } 75 76 // TODO propagate caller task ID 77 sysman_raise_event(&sysman_event_unit_exposee_created, unit); 78 79 retval = EOK; 80 81 finish: 82 async_answer_0(iid, retval); 83 free(unit_name); 59 84 } 60 85 61 86 static void sysman_exposee_added(ipc_callid_t iid, ipc_call_t *icall) 62 87 { 63 sysman_log(LVL_DEBUG2, "%s", __func__); 64 async_answer_0(iid, ENOTSUP); 65 // TODO implement 88 char *exposee = NULL; 89 sysarg_t retval; 90 91 /* Just accept data and further not supported. */ 92 int rc = async_data_write_accept((void **) &exposee, true, 93 0, 0, 0, NULL); 94 if (rc != EOK) { 95 retval = rc; 96 goto finish; 97 } 98 99 //sysman_log(LVL_DEBUG2, "%s(%s)", __func__, exposee); 100 101 retval = ENOTSUP; 102 103 finish: 104 async_answer_0(iid, retval); 105 free(exposee); 66 106 } 67 107 -
uspace/srv/sysman/connection_ctl.c
r72c8f77 r63a3276 84 84 85 85 if (!(flags & IPC_FLAG_BLOCKING)) { 86 retval = sysman_ queue_job(unit, STATE_STARTED, NULL, NULL);86 retval = sysman_run_job(unit, STATE_STARTED, NULL, NULL); 87 87 goto answer; 88 88 } … … 93 93 goto answer; 94 94 } 95 retval = sysman_ queue_job(unit, STATE_STARTED, &answer_callback,95 retval = sysman_run_job(unit, STATE_STARTED, &answer_callback, 96 96 iid_ptr); 97 97 if (retval != EOK) { -
uspace/srv/sysman/job.c
r72c8f77 r63a3276 487 487 } 488 488 if (rc != EOK) { 489 //TODO here is 'rc' value "lost" (not propagated further) 489 490 sysman_log(LVL_DEBUG, "%s(%p), %s -> %i, error: %i", 490 491 __func__, job, unit_name(u), job->target_state, rc); -
uspace/srv/sysman/unit.h
r72c8f77 r63a3276 73 73 link_t bfs_link; 74 74 75 /** Seen tag for BFS traverse, must be reset before each BFS */ 76 bool bfs_tag; 75 /** Auxiliary job created during BFS traverse, its presence serves also 76 * as BFS tag */ 77 job_t *bfs_job; 77 78 79 /** Job assigned to unit in transitional state */ 78 80 job_t *job; 79 81 -
uspace/srv/sysman/units/unit_svc.c
r72c8f77 r63a3276 93 93 } 94 94 95 unit->state = STATE_STARTING; 96 95 97 /* 96 98 * This is temporary workaround, until proper reporting from brokers 97 99 * about exposees will work. We assume the service succesfully starts 98 * in a moment. 100 * in a moment. Applies to naming service only. 99 101 */ 100 unit->state = STATE_STARTING; 101 async_usleep(20000); 102 unit->state = STATE_STARTED; 102 // TODO this is even hack in the workaround, exposees doesn't work properly 103 if (true || str_cmp(unit->name, "devman.svc") == 0 || 104 str_cmp(unit->name, "logger.svc") == 0 || 105 str_cmp(unit->name, "irc.svc") == 0) { 106 async_usleep(100000); 107 unit->state = STATE_STARTED; 108 } 103 109 104 110 /* 105 111 * Workaround to see log output even after devman starts (and overrides 106 * kernel's frame buffer. It's here since devman is started as a 107 * service (however not all services are devman...). 112 * kernel's frame buffer. 108 113 */ 109 if (console_kcon()) { 110 sysman_log(LVL_DEBUG2, "%s: Kconsole grabbed.", __func__); 111 } else { 112 sysman_log(LVL_DEBUG2, "%s: no kconsole.", __func__); 114 if (str_cmp(unit->name, "devman.svc") == 0) { 115 async_usleep(100000); 116 if (console_kcon()) { 117 sysman_log(LVL_DEBUG2, "%s: Kconsole grabbed.", __func__); 118 } else { 119 sysman_log(LVL_DEBUG2, "%s: no kconsole.", __func__); 120 } 113 121 } 114 122 … … 118 126 static void unit_svc_exposee_created(unit_t *unit) 119 127 { 120 // TODO implement 128 assert(CAST_SVC(unit)); 129 assert(unit->state == STATE_STOPPED || unit->state == STATE_STARTING || unit->state==STATE_STARTED); 130 131 unit->state = STATE_STARTED; 132 unit_notify_state(unit); 121 133 } 122 134 -
uspace/srv/vfs/vfs.h
r72c8f77 r63a3276 176 176 extern void vfs_exchange_release(async_exch_t *); 177 177 178 extern fs_handle_t fs_name_to_handle( unsigned int instance, const char *, bool);178 extern fs_handle_t fs_name_to_handle(const char *, unsigned int instance, bool); 179 179 extern vfs_info_t *fs_handle_to_info(fs_handle_t); 180 extern errno_t vfs_get_fstypes(vfs_fstypes_t*);180 extern errno_t fs_unit_name(const char *, unsigned int, char **); 181 181 182 182 extern errno_t vfs_lookup_internal(vfs_node_t *, char *, int, vfs_lookup_res_t *); -
uspace/srv/vfs/vfs_ops.c
r72c8f77 r63a3276 136 136 fibril_mutex_lock(&fs_list_lock); 137 137 while (true) { 138 fs_handle = fs_name_to_handle( instance, fsname, false);138 fs_handle = fs_name_to_handle(fsname, instance, false); 139 139 if (!fs_handle) { 140 140 if ((flags & IPC_FLAG_AUTOSTART)) { … … 220 220 char *unit_name = NULL; 221 221 222 assert(instance == 0); 223 /* 224 * Unit name is made simply by considering service of the same name as 225 * given FS name. 226 * TODO instance identifier is not implemented. 227 */ 228 asprintf(&unit_name, "%s%c%s", fs_name, UNIT_NAME_SEPARATOR, 229 UNIT_SVC_TYPE_NAME); 230 if (unit_name == NULL) { 231 return ENOMEM; 232 } 233 234 int rc = sysman_unit_start(unit_name, IPC_FLAG_BLOCKING); 222 errno_t rc = fs_unit_name(fs_name, instance, &unit_name); 223 if (rc != EOK) { 224 return rc; 225 } 226 227 rc = sysman_unit_start(unit_name, IPC_FLAG_BLOCKING); 235 228 236 229 free(unit_name); … … 246 239 247 240 fibril_mutex_lock(&fs_list_lock); 248 fs_handle = fs_name_to_handle( 0, fs_name, false);241 fs_handle = fs_name_to_handle(fs_name, 0, false); 249 242 fibril_mutex_unlock(&fs_list_lock); 250 243 -
uspace/srv/vfs/vfs_register.c
r72c8f77 r63a3276 36 36 */ 37 37 38 #include <ipc/services.h> 38 #include <adt/list.h> 39 #include <as.h> 40 #include <assert.h> 39 41 #include <async.h> 42 #include <atomic.h> 43 #include <ctype.h> 44 #include <errno.h> 40 45 #include <fibril.h> 41 46 #include <fibril_synch.h> 42 #include <errno.h> 47 #include <ipc/services.h> 48 #include <stdbool.h> 43 49 #include <stdio.h> 44 50 #include <stdlib.h> 45 51 #include <str.h> 46 #include <ctype.h> 47 #include <stdbool.h> 48 #include <adt/list.h> 49 #include <as.h> 50 #include <assert.h> 51 #include <stdatomic.h> 52 #include <vfs/vfs.h> 52 #include <sysman/broker.h> 53 53 #include "vfs.h" 54 54 … … 149 149 * Check for duplicit registrations. 150 150 */ 151 if (fs_name_to_handle(fs_info->vfs_info. instance,152 fs_info->vfs_info. name, false)) {151 if (fs_name_to_handle(fs_info->vfs_info.name, 152 fs_info->vfs_info.instance, false)) { 153 153 /* 154 154 * We already register a fs like this. … … 161 161 } 162 162 163 /* Notify sysman about started FS server */ 164 char *unit_name = NULL; 165 rc = fs_unit_name(fs_info->vfs_info.name, fs_info->vfs_info.instance, 166 &unit_name); 167 if (rc != EOK) { 168 dprintf("Unknow unit name for FS server.\n"); 169 fibril_mutex_unlock(&fs_list_lock); 170 free(fs_info); 171 async_answer_0(rid, rc); 172 return; 173 } 174 sysman_main_exposee_added(unit_name, request->in_task_id); 175 free(unit_name); 176 163 177 /* 164 178 * Add fs_info to the list of registered FS's. … … 288 302 * 289 303 * @param name File system name. 304 * @param instance 290 305 * @param lock If true, the function will lock and unlock the 291 306 * fs_list_lock. … … 294 309 * 295 310 */ 296 fs_handle_t fs_name_to_handle( unsigned int instance, const char *name, bool lock)311 fs_handle_t fs_name_to_handle(const char *name, unsigned int instance, bool lock) 297 312 { 298 313 int handle = 0; … … 393 408 } 394 409 410 /** Get name of unit that represents the filesystem server 411 * 412 * Unit name is made simply by considering service of the same name as 413 * given FS name. 414 * TODO instance identifier is not implemented. 415 * 416 * @param[in] fs_name 417 * @param[in] instance 418 * @param[out] unit_name_ptr should be free'd after use, not touched on fail 419 * 420 * @return EOK on success 421 * @return ENOMEM 422 */ 423 errno_t fs_unit_name(const char *fs_name, unsigned int instance, 424 char **unit_name_ptr) 425 { 426 assert(instance == 0); 427 428 char *unit_name = NULL; 429 asprintf(&unit_name, "%s%c%s", fs_name, UNIT_NAME_SEPARATOR, 430 UNIT_SVC_TYPE_NAME); 431 432 if (unit_name == NULL) { 433 return ENOMEM; 434 } else { 435 *unit_name_ptr = unit_name; 436 return EOK; 437 } 438 } 439 395 440 /** 396 441 * @}
Note:
See TracChangeset
for help on using the changeset viewer.