• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (c) 2019, The Linux Foundation. All rights reserved.
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions are
6  * met:
7  *    * Redistributions of source code must retain the above copyright
8  *      notice, this list of conditions and the following disclaimer.
9  *    * Redistributions in binary form must reproduce the above
10  *      copyright notice, this list of conditions and the following
11  *      disclaimer in the documentation and/or other materials provided
12  *      with the distribution.
13  *    * Neither the name of The Linux Foundation nor the names of its
14  *      contributors may be used to endorse or promote products derived
15  *      from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
18  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
21  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
24  * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
25  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
26  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
27  * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28  */
29 
30 #ifndef MOD_TABLE_H
31 #define MOD_TABLE_H
32 
33 #include "remote64.h"
34 #include "AEEStdDef.h"
35 
36 #ifdef __cplusplus
37 extern "C"
38 {
39 #endif
40 
41 /**
42  * multi-domain support
43  *
44  * multi domain modules return remote_handl64 on open/close, but mod_table
45  * creates uint32 handles as the "remote" facing handle.  These fit nicely
46  * into the transport layer.
47  *
48  */
49 
50 /**
51   * register a static component for invocations
52   * this can be called at any time including from a static constructor
53   *
54   * name, name of the interface to register
55   * pfn, function pointer to the skel invoke function
56   *
57   * for example:
58   *   __attribute__((constructor)) static void my_module_ctor(void) {
59   *      mod_table_register_static("my_module", my_module_skel_invoke);
60   *   }
61   *
62   */
63 int mod_table_register_static(const char* name, int (*pfn)(uint32 sc, remote_arg* pra));
64 
65 /**
66   * same as register_static, but module with user defined handle lifetimes.
67   */
68 int mod_table_register_static1(const char* uri, int (*pfn)(remote_handle64 h,uint32 sc, remote_arg* pra));
69 
70 /**
71   * register a static component for invocations
72   * this can be called at any time including from a static constructor
73   *
74   * overrides will be tried first, then dynamic modules, then regular
75   * static modules.  This api should only be use by system components
76   * that will never be upgradable.
77   *
78   * name, name of the interface to register
79   * pfn, function pointer to the skel invoke function
80   *
81   * for example:
82   *   __attribute__((constructor)) static void my_module_ctor(void) {
83   *      mod_table_register_static("my_module", my_module_skel_invoke);
84   *   }
85   *
86   */
87 int mod_table_register_static_override(const char* name, int(*pfn)(uint32 sc, remote_arg* pra));
88 
89 /**
90   * same as register_static, but module with user defined handle lifetimes.
91   */
92 int mod_table_register_static_override1(const char* uri, int(*pfn)(remote_handle64,uint32 sc, remote_arg* pra));
93 
94 /**
95  * Open a module and get a handle to it
96  *
97  * in_name, name of module to open
98  * handle, Output handle
99  * dlerr, Error String (if an error occurs)
100  * dlerrorLen, Length of error String (if an error occurs)
101  * pdlErr, Error identifier
102  */
103 int mod_table_open(const char* in_name, remote_handle* handle, char* dlerr, int dlerrorLen, int* pdlErr);
104 
105 /**
106  * invoke a handle in the mod table
107  *
108  * handle, handle to invoke
109  * sc, scalars, see remote.h for documentation.
110  * pra, args, see remote.h for documentation.
111  */
112 int mod_table_invoke(remote_handle handle, uint32 sc, remote_arg* pra);
113 
114 /**
115  * Closes a handle in the mod table
116  *
117  * handle, handle to close
118  * errStr, Error String (if an error occurs)
119  * errStrLen, Length of error String (if an error occurs)
120  * pdlErr, Error identifier
121  */
122 int mod_table_close(remote_handle handle, char* errStr, int errStrLen, int* pdlErr);
123 
124 /**
125  * internal use only
126  */
127 int mod_table_register_const_handle(remote_handle handle, const char* in_name, int (*pfn)(uint32 sc, remote_arg* pra));
128 /**
129  * @param remote, the handle we should expect from the transport layer
130  * @param local, the local handle that will be passed to pfn
131  */
132 int mod_table_register_const_handle1(remote_handle remote, remote_handle64 local, const char* uri, int (*pfn)(remote_handle64 h, uint32 sc, remote_arg* pra));
133 
134 #ifdef __cplusplus
135 }
136 #endif
137 
138 #endif // MOD_TABLE_H
139