source: mainline/uspace/srv/devman/loc.c@ c1b2084

Last change on this file since c1b2084 was 5559712, checked in by Matthieu Riolo <matthieu.riolo@…>, 6 years ago

sysman: Naive autostart instrumentation of locsrv

  • Add IPC_FLAG_AUTOSTART flag.
  • libsysman: sysman's broker and control API.
  • Simple implementation of service unit, exposee verification is missing.
  • Simple mapping of exposee to unit name in locsrv.
  • Temporary debug prints in locsrv.

Conflicts:

boot/Makefile.common
boot/arch/amd64/Makefile.inc
uspace/lib/c/include/ipc/services.h
uspace/srv/locsrv/locsrv.c

  • Property mode set to 100644
File size: 3.1 KB
Line 
1/*
2 * Copyright (c) 2010 Lenka Trochtova
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup devman
30 * @{
31 */
32
33#include <ipc/services.h>
34#include <loc.h>
35#include <stdio.h>
36
37#include "devman.h"
38#include "fun.h"
39#include "loc.h"
40
41/** Create loc path and name for the function. */
42void loc_register_tree_function(fun_node_t *fun, dev_tree_t *tree)
43{
44 char *loc_pathname = NULL;
45 char *loc_name = NULL;
46
47 assert(fibril_rwlock_is_locked(&tree->rwlock));
48
49 asprintf(&loc_name, "%s", fun->pathname);
50 if (loc_name == NULL)
51 return;
52
53 replace_char(loc_name, '/', LOC_SEPARATOR);
54
55 asprintf(&loc_pathname, "%s/%s", LOC_DEVICE_NAMESPACE,
56 loc_name);
57 if (loc_pathname == NULL) {
58 free(loc_name);
59 return;
60 }
61
62 loc_service_register(loc_pathname, &fun->service_id);
63
64 tree_add_loc_function(tree, fun);
65
66 free(loc_name);
67 free(loc_pathname);
68}
69
70errno_t loc_unregister_tree_function(fun_node_t *fun, dev_tree_t *tree)
71{
72 errno_t rc = loc_service_unregister(fun->service_id);
73 tree_rem_loc_function(tree, fun);
74 return rc;
75}
76
77fun_node_t *find_loc_tree_function(dev_tree_t *tree, service_id_t service_id)
78{
79 fun_node_t *fun = NULL;
80
81 fibril_rwlock_read_lock(&tree->rwlock);
82 ht_link_t *link = hash_table_find(&tree->loc_functions, &service_id);
83 if (link != NULL) {
84 fun = hash_table_get_inst(link, fun_node_t, loc_fun);
85 fun_add_ref(fun);
86 }
87 fibril_rwlock_read_unlock(&tree->rwlock);
88
89 return fun;
90}
91
92void tree_add_loc_function(dev_tree_t *tree, fun_node_t *fun)
93{
94 assert(fibril_rwlock_is_write_locked(&tree->rwlock));
95
96 hash_table_insert(&tree->loc_functions, &fun->loc_fun);
97}
98
99void tree_rem_loc_function(dev_tree_t *tree, fun_node_t *fun)
100{
101 assert(fibril_rwlock_is_write_locked(&tree->rwlock));
102
103 hash_table_remove(&tree->loc_functions, &fun->service_id);
104}
105
106/** @}
107 */
Note: See TracBrowser for help on using the repository browser.