2 * Copyright 2013 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 * Managing the reference counter of a slave
25 SLAVE_EVENT_DEACTIVATE, /* deactivate callback, can return REACTIVATE, DEFAULT */
26 SLAVE_EVENT_DELETE, /* Callbacks for this event type, must has not to do something with slave object.
27 use this only for just notice the state of slave */
28 SLAVE_EVENT_FAULT, /* Critical fault */
33 SLAVE_NEED_TO_REACTIVATE
38 * Launch the slave but not yet receives "hello" packet
40 SLAVE_REQUEST_TO_LAUNCH,
44 * Terminate the slave but not yet receives dead signal
46 SLAVE_REQUEST_TO_TERMINATE,
50 * No slave process exists, just slave object created
56 * State change request is sent,
58 SLAVE_REQUEST_TO_PAUSE,
59 SLAVE_REQUEST_TO_RESUME,
63 * Request an action for disconnecting to master from the provider side.
64 * This flag should be treated as an activated state.
66 SLAVE_REQUEST_TO_DISCONNECT,
70 * SLAVE_ACTIVATED = { SLAVE_PAUSED, SLAVE_RESUMED }
75 SLAVE_ERROR = 0xFF /* Explicitly define the size of this enum type */
79 PROVIDER_CTRL_DEFAULT = 0x00, /*!< Set default control operation */
80 PROVIDER_CTRL_MANUAL_TERMINATION = 0x01, /*!< Terminate process manually */
81 PROVIDER_CTRL_MANUAL_REACTIVATION = 0x02, /*!< Reactivate process manually */
84 extern struct slave_node *slave_ref(struct slave_node *slave);
85 extern struct slave_node *slave_unref(struct slave_node *slave);
86 extern const int const slave_refcnt(struct slave_node *slave);
90 * Create a new slave object or destroy it
93 * \param[in] is_secured
99 extern struct slave_node *slave_create(const char *name, int is_secured, const char *abi, const char *pkgname, int network, const char *hw_acceleration);
106 extern void slave_destroy(struct slave_node *slave);
110 * Launch or terminate a slave
114 extern int slave_activate(struct slave_node *slave);
117 * To check the slave's activation state
119 extern const int const slave_is_activated(struct slave_node *slave);
120 extern int slave_activated(struct slave_node *slave);
122 extern int slave_give_more_ttl(struct slave_node *slave);
123 extern int slave_freeze_ttl(struct slave_node *slave);
124 extern int slave_thaw_ttl(struct slave_node *slave);
125 extern int slave_expired_ttl(struct slave_node *slave);
129 * To mangage the unexpected termination of a slave
130 * After this function call, the slave object can be deleted
132 extern struct slave_node *slave_deactivated_by_fault(struct slave_node *slave) __attribute__((warn_unused_result));
136 * After this function, the slave object can be deleted
138 extern struct slave_node *slave_deactivated(struct slave_node *slave) __attribute__((warn_unused_result));
140 extern int slave_event_callback_add(struct slave_node *slave, enum slave_event event, int (*cb)(struct slave_node *, void *), void *data);
141 extern int slave_event_callback_del(struct slave_node *slave, enum slave_event event, int (*cb)(struct slave_node *, void *), void *data);
143 extern int slave_set_data(struct slave_node *slave, const char *tag, void *data);
144 extern void *slave_del_data(struct slave_node *slave, const char *tag);
145 extern void *slave_data(struct slave_node *slave, const char *tag);
147 extern struct slave_node *slave_find_by_pid(pid_t pid);
148 extern struct slave_node *slave_find_by_name(const char *name);
149 extern struct slave_node *slave_find_by_pkgname(const char *pkgname);
150 extern struct slave_node *slave_find_by_rpc_handle(int handle);
152 extern void slave_dead_handler(struct slave_node *slave);
153 extern const int const slave_is_secured(const struct slave_node *slave);
154 extern const char * const slave_name(const struct slave_node *slave);
155 extern const pid_t const slave_pid(const struct slave_node *slave);
156 extern const char * const slave_abi(const struct slave_node *slave);
157 extern int slave_set_pid(struct slave_node *slave, pid_t pid);
161 * Used for making decision of destroying a slave or not
162 * Used for balancing load of the slave.
164 extern void slave_load_package(struct slave_node *slave);
165 extern void slave_unload_package(struct slave_node *slave);
166 extern int const slave_loaded_package(struct slave_node *slave);
167 extern struct slave_node *slave_find_available(const char *slave_pkgname, const char *abi, int secured, int network, const char *hw_acceleration);
169 extern double const slave_ttl(const struct slave_node *slave);
173 * Used for making decision of activating a slave or not
175 extern void slave_load_instance(struct slave_node *slave);
179 * After this function call, the slave object can be deleted.
181 extern struct slave_node *slave_unload_instance(struct slave_node *slave) __attribute__((warn_unused_result));
183 extern int const slave_loaded_instance(struct slave_node *slave);
185 extern int slave_resume(struct slave_node *slave);
186 extern int slave_pause(struct slave_node *slave);
188 extern const char *slave_pkgname(const struct slave_node *slave);
189 extern enum slave_state slave_state(const struct slave_node *slave);
190 extern const char *slave_state_string(const struct slave_node *slave);
192 extern const void *slave_list(void);
193 extern int const slave_fault_count(const struct slave_node *slave);
195 extern int slave_need_to_reactivate_instances(struct slave_node *slave);
196 extern void slave_set_reactivate_instances(struct slave_node *slave, int reactivate);
198 extern void slave_set_reactivation(struct slave_node *slave, int flag);
199 extern int slave_need_to_reactivate(struct slave_node *slave);
201 extern int slave_network(const struct slave_node *slave);
202 extern void slave_set_network(struct slave_node *slave, int network);
204 extern int slave_deactivate_all(int reactivate, int reactivate_instances, int no_timer);
205 extern int slave_activate_all(void);
207 extern void slave_set_control_option(struct slave_node *slave, int ctrl);
208 extern int slave_control_option(struct slave_node *slave);
210 extern char *slave_package_name(const char *abi, const char *lbid);
212 extern int slave_priority(struct slave_node *slave);
213 extern int slave_set_priority(struct slave_node *slave, int priority);