4 * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Ja-young Gu <jygu@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
21 #ifndef __TCORE_HAL_H__
22 #define __TCORE_HAL_H__
26 typedef void (*TcoreHalReceiveCallback)(TcoreHal *hal, unsigned int data_len, const void *data, void *user_data);
27 typedef enum tcore_hook_return (*TcoreHalSendHook)(TcoreHal *hal, unsigned int data_len, void *data, void *user_data);
28 typedef void (*TcoreHalSetupNetifCallback)(CoreObject *co, int result, const char* devname, void *user_data);
30 enum tcore_hal_recv_data_type {
31 TCORE_HAL_RECV_INDICATION,
32 TCORE_HAL_RECV_RESPONSE,
33 TCORE_HAL_RECV_NOTIFICATION,
34 TCORE_HAL_RECV_UNKNOWN
38 TCORE_HAL_MODE_UNKNOWN,
40 TCORE_HAL_MODE_CUSTOM,
41 TCORE_HAL_MODE_TRANSPARENT
44 struct tcore_hal_operations {
45 TReturn (*power)(TcoreHal *hal, gboolean flag);
46 TReturn (*send)(TcoreHal *hal, unsigned int data_len, void *data);
47 TReturn (*setup_netif)(CoreObject *co,
48 TcoreHalSetupNetifCallback func,
49 void *user_data, unsigned int cid,
53 TcoreHal* tcore_hal_new(TcorePlugin *plugin, const char *name,
54 struct tcore_hal_operations *hops,
55 enum tcore_hal_mode mode);
56 void tcore_hal_free(TcoreHal *hal);
58 TReturn tcore_hal_set_name(TcoreHal *hal, const char *name);
59 char* tcore_hal_get_name(TcoreHal *hal);
61 TcoreAT* tcore_hal_get_at(TcoreHal *hal);
62 enum tcore_hal_mode tcore_hal_get_mode(TcoreHal *hal);
63 TReturn tcore_hal_set_mode(TcoreHal *hal, enum tcore_hal_mode mode);
65 TReturn tcore_hal_set_power(TcoreHal *hal, gboolean flag);
67 TReturn tcore_hal_link_user_data(TcoreHal *hal, void *user_data);
68 void* tcore_hal_ref_user_data(TcoreHal *hal);
70 TReturn tcore_hal_send_data(TcoreHal *hal, unsigned int data_len, void *data);
71 TReturn tcore_hal_send_request(TcoreHal *hal, TcorePending *pending);
72 TReturn tcore_hal_send_force(TcoreHal *hal);
74 TReturn tcore_hal_free_timeout_pending_request(TcoreHal *hal, TcorePending *p,
75 unsigned int data_len, const void *data);
76 TReturn tcore_hal_dispatch_response_data(TcoreHal *hal, int id,
77 unsigned int data_len, const void *data);
79 TReturn tcore_hal_add_recv_callback(TcoreHal *hal,
80 TcoreHalReceiveCallback func, void *user_data);
81 TReturn tcore_hal_remove_recv_callback(TcoreHal *hal,
82 TcoreHalReceiveCallback func);
83 TReturn tcore_hal_emit_recv_callback(TcoreHal *hal,
84 unsigned int data_len, const void *data);
86 TReturn tcore_hal_add_send_hook(TcoreHal *hal, TcoreHalSendHook func,
88 TReturn tcore_hal_remove_send_hook(TcoreHal *hal, TcoreHalSendHook func);
90 TReturn tcore_hal_set_power_state(TcoreHal *hal, gboolean flag);
91 gboolean tcore_hal_get_power_state(TcoreHal *hal);
93 TcoreQueue* tcore_hal_ref_queue(TcoreHal *hal);
94 TcorePlugin* tcore_hal_ref_plugin(TcoreHal *hal);
96 TReturn tcore_hal_setup_netif(TcoreHal *hal, CoreObject *co,
97 TcoreHalSetupNetifCallback func,
98 void *user_data, unsigned int cid,