Subversion Repositories HelenOS

Rev

Rev 4307 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4307 Rev 4350
1
/*
1
/*
2
 * Copyright (c) 2009 Lukas Mejdrech
2
 * Copyright (c) 2009 Lukas Mejdrech
3
 * All rights reserved.
3
 * All rights reserved.
4
 *
4
 *
5
 * Redistribution and use in source and binary forms, with or without
5
 * Redistribution and use in source and binary forms, with or without
6
 * modification, are permitted provided that the following conditions
6
 * modification, are permitted provided that the following conditions
7
 * are met:
7
 * are met:
8
 *
8
 *
9
 * - Redistributions of source code must retain the above copyright
9
 * - Redistributions of source code must retain the above copyright
10
 *   notice, this list of conditions and the following disclaimer.
10
 *   notice, this list of conditions and the following disclaimer.
11
 * - Redistributions in binary form must reproduce the above copyright
11
 * - Redistributions in binary form must reproduce the above copyright
12
 *   notice, this list of conditions and the following disclaimer in the
12
 *   notice, this list of conditions and the following disclaimer in the
13
 *   documentation and/or other materials provided with the distribution.
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
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.
15
 *   derived from this software without specific prior written permission.
16
 *
16
 *
17
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
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
18
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
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
23
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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
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.
26
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
 */
27
 */
28
 
28
 
29
/** @addtogroup net
29
/** @addtogroup net
30
 *  @{
30
 *  @{
31
 */
31
 */
32
 
32
 
33
/**
-
 
34
 * @file
33
/** @file
-
 
34
 *  Character string to module map.
35
 */
35
 */
36
 
36
 
37
#ifndef __NET_MODULES_MAP_H__
37
#ifndef __NET_MODULES_MAP_H__
38
#define __NET_MODULES_MAP_H__
38
#define __NET_MODULES_MAP_H__
39
 
39
 
40
#include <task.h>
40
#include <task.h>
41
 
41
 
42
#include <ipc/services.h>
42
#include <ipc/services.h>
43
 
43
 
44
#include "../modules.h"
44
#include "../modules.h"
45
 
45
 
46
#include "generic_char_map.h"
46
#include "generic_char_map.h"
47
 
47
 
-
 
48
/** Type definition of the module structure.
-
 
49
 *  @see module_struct
-
 
50
 */
48
typedef struct module_struct    module_t;
51
typedef struct module_struct    module_t;
-
 
52
 
-
 
53
/** Type definition of the module structure pointer.
-
 
54
 *  @see module_struct
-
 
55
 */
49
typedef module_t *              module_ref;
56
typedef module_t *              module_ref;
50
 
57
 
-
 
58
/** Module map.
-
 
59
 *  Sorted by module names.
-
 
60
 *  @see generic_char_map.h
-
 
61
 */
51
GENERIC_CHAR_MAP_DECLARE( modules, module_t )
62
GENERIC_CHAR_MAP_DECLARE( modules, module_t )
52
 
63
 
-
 
64
/** Module structure.
-
 
65
 */
53
struct  module_struct{
66
struct  module_struct{
-
 
67
    /** Module task identifier if running.
-
 
68
     */
54
    task_id_t   task_id;
69
    task_id_t   task_id;
-
 
70
    /** Module service identifier.
-
 
71
     */
55
    services_t  service;
72
    services_t  service;
-
 
73
    /** Module phone if running and connected.
-
 
74
     */
56
    int         phone;
75
    int         phone;
-
 
76
    /** Usage counter.
-
 
77
     */
57
    int         usage;
78
    int         usage;
-
 
79
    /** Module name.
-
 
80
     */
58
    char *      name;
81
    char *      name;
-
 
82
    /** Module full path filename.
-
 
83
     */
59
    char *      filename;
84
    char *      filename;
-
 
85
    /** Connecting function.
-
 
86
     */
60
    connect_module_t *  connect_module;
87
    connect_module_t *  connect_module;
61
};
88
};
62
 
89
 
-
 
90
/** Adds module to the module map.
-
 
91
 *  @param module The module structure added. Output parameter.
-
 
92
 *  @param modules The module map. Input parameter.
-
 
93
 *  @param name The module name. Input parameter.
-
 
94
 *  @param filename The full path filename. Input parameter.
-
 
95
 *  @param service The module service. Input parameter.
-
 
96
 *  @param task_id The module current task identifier. Zero (0) means not running. Input parameter.
-
 
97
 *  @param connect_module The module connecting function. Input parameter.
-
 
98
 *  @returns EOK on success.
-
 
99
 *  @returns ENOMEM if there is not enough memory left.
-
 
100
 */
63
int add_module( module_ref * module, modules_ref modules, char * name, char * filename, services_t service, task_id_t task_id, connect_module_t * connect_module );
101
int add_module( module_ref * module, modules_ref modules, char * name, char * filename, services_t service, task_id_t task_id, connect_module_t * connect_module );
-
 
102
 
-
 
103
/** Searches and returns the specified module.
-
 
104
 *  If the module is not running, the module filaname is spawned.
-
 
105
 *  If the module is not connected, the connect_function is called.
-
 
106
 *  @param modules The module map. Input parameter.
-
 
107
 *  @param name The module name. Input parameter.
-
 
108
 *  @returns The running module found. It does not have to be connected.
-
 
109
 *  @returns NULL if there is no such module.
-
 
110
 */
64
module_ref  get_running_module( modules_ref modules, char * name );
111
module_ref  get_running_module( modules_ref modules, char * name );
-
 
112
 
-
 
113
/** Starts the given module.
-
 
114
 *  @param fname The module full or relative path filename. Input parameter.
-
 
115
 *  @returns The new module task identifier on success.
-
 
116
 *  @returns 0 if there is no such module.
-
 
117
 */
65
task_id_t   spawn( char * fname );
118
task_id_t   spawn( char * fname );
66
 
119
 
67
#endif
120
#endif
68
 
121
 
69
/** @}
122
/** @}
70
 */
123
 */
71
 
124