ADD_DEFINITIONS("-DFEATURE_DLOG_DEBUG")
ADD_DEFINITIONS("-DTCORE_LOG_TAG=\"IMCMODEM\"")
+ADD_DEFINITIONS("-DEXPORT_API=__attribute__((visibility(\"default\")))")
MESSAGE(${CMAKE_C_FLAGS})
MESSAGE(${CMAKE_EXE_LINKER_FLAGS})
/*
* tel-plugin-imcmodem
*
- * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Kyoungyoup Park <gynaru.park@samsung.com>
+ * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* limitations under the License.
*/
-#ifndef _CONFIG_H_
-#define _CONFIG_H_
+#ifndef __CONFIG_H__
+#define __CONFIG_H__
#ifdef __cplusplus
extern "C" {
}
#endif /* __cplusplus */
-#endif /* _CONFIG_H_ */
+#endif /* __CONFIG_H__ */
/*
* tel-plugin-imcmodem
*
- * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Kyoungyoup Park <gynaru.park@samsung.com>
+ * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* limitations under the License.
*/
-#ifndef _VNET_H_
-#define _VNET_H_
+#ifndef __VNET_H__
+#define __VNET_H__
#ifdef __cplusplus
extern "C" {
#endif
/* CP states */
-enum vnet_cp_state {
+typedef enum {
VNET_CP_STATE_UNKNOWN = -1,
VNET_CP_STATE_OFFLINE = 0,
VNET_CP_STATE_CRASH_RESET,
VNET_CP_STATE_ONLINE,
VNET_CP_STATE_NV_REBUILDING,
VNET_CP_STATE_LOADER_DONE,
-};
+} VnetCpState;
-void vnet_start_cp_ramdump( void );
-void vnet_start_cp_reset( void );
+void vnet_start_cp_ramdump(void);
+void vnet_start_cp_reset(void);
-enum vnet_cp_state vnet_get_cp_state( int fd );
+VnetCpState vnet_get_cp_state(int fd);
-int vnet_rfs0_open( void );
-int vnet_ipc0_open( void );
+int vnet_rfs0_open(void);
+int vnet_ipc0_open(void);
#ifdef __cplusplus
}
#endif /* __cplusplus */
-#endif /* _VNET_H_ */
+#endif /* __VNET_H__ */
+%define major 3
+%define minor 0
+%define patchlevel 1
+
Name: tel-plugin-imcmodem
-Summary: telephony plugin library for AT communication with IMC modem
-Version: 0.1.4
+Version: %{major}.%{minor}.%{patchlevel}
Release: 1
-Group: System/Libraries
License: Apache-2.0
+Summary: Telephony Plug-in for AT communication with IMC modem (Modem Interface Plug-in)
+Group: System/Libraries
Source0: tel-plugin-imcmodem-%{version}.tar.gz
Source1001: tel-plugin-imcmodem.manifest
-Requires(post): /sbin/ldconfig
-Requires(postun): /sbin/ldconfig
BuildRequires: cmake
BuildRequires: pkgconfig(glib-2.0)
BuildRequires: pkgconfig(dlog)
BuildRequires: pkgconfig(tcore)
+Requires(post): /sbin/ldconfig
+Requires(postun): /sbin/ldconfig
%description
imcmodem plugin for telephony
/*
* tel-plugin-imcmodem
*
- * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Kyoungyoup Park <gynaru.park@samsung.com>
+ * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <server.h>
#include <plugin.h>
#include <storage.h>
-#include <user_request.h>
#include <core_object.h>
#include <hal.h>
#include <at.h>
#include "config.h"
-#define IMC_MODEM_PLUGIN_NAME "imc-plugin.so"
+#define IMC_MODEM_PLUGIN_NAME "imc-plugin.so"
-#define IMC_CMUX_MAX_CHANNELS 7
-#define IMC_CMUX_MAX_BUFFER_SIZE 2048
+#define IMC_CMUX_MAX_CHANNELS 7
+#define IMC_CMUX_MAX_BUFFER_SIZE 2048
/* CP States */
-#define IMC_AT_CPAS_RESULT_READY 0
-#define IMC_AT_CPAS_RESULT_UNAVAIL 1
-#define IMC_AT_CPAS_RESULT_UNKNOWN 2
-#define IMC_AT_CPAS_RESULT_RINGING 3
+#define IMC_AT_CPAS_RESULT_READY 0
+#define IMC_AT_CPAS_RESULT_UNAVAIL 1
+#define IMC_AT_CPAS_RESULT_UNKNOWN 2
+#define IMC_AT_CPAS_RESULT_RINGING 3
#define IMC_AT_CPAS_RESULT_CALL_PROGRESS 4
-#define IMC_AT_CPAS_RESULT_ASLEEP 5
+#define IMC_AT_CPAS_RESULT_ASLEEP 5
/* Maximum Core objects per Logical HAL (indirectly per Channel) */
-#define MAX_CORE_OBJECTS_PER_CHANNEL 3
+#define MAX_CO_PER_CHANNEL 3
/*
* List of supported Core Object types
* Channel 6 - NETWORK & GPS
* Channel 7 - MODEM & PS
*/
-unsigned int
- supported_modules[IMC_CMUX_MAX_CHANNELS+1][MAX_CORE_OBJECTS_PER_CHANNEL] =
+guint supported_modules[IMC_CMUX_MAX_CHANNELS+1][MAX_CO_PER_CHANNEL] =
{
/*
* Channel 0 - CMUX Control Channel
static gboolean _check_cp_poweron(TcoreHal *hal);
static void _send_enable_logging_command(TcoreHal *hal);
-static void _on_confirmation_send_message(TcorePending *pending,
- gboolean result, void *user_data)
+static void _on_confirmation_send_message(TcorePending *p,
+ TelReturn send_status, void *user_data)
{
- dbg("Message send confirmation");
-
- if (result == FALSE) { /* Fail */
- dbg("SEND FAIL");
- } else {
- dbg("SEND OK");
- }
+ dbg("Message send confirmation - [%s]",
+ ((send_status != TEL_RETURN_SUCCESS) ? "FAIL" : "OK"));
}
-static void _assign_objects_to_hal(int channel_id, TcoreHal *hal)
+
+static void _assign_objects_to_hal(guint channel_id, TcoreHal *hal)
{
TcorePlugin *plugin;
gboolean ret;
- int i;
+ guint i;
plugin = tcore_hal_ref_plugin(hal);
- for (i = 0 ; i < MAX_CORE_OBJECTS_PER_CHANNEL ; i++) {
+ for (i = 0 ; i < MAX_CO_PER_CHANNEL ; i++) {
if (supported_modules[channel_id][i] == 0)
continue;
ret = tcore_server_add_cp_mapping_tbl_entry(plugin,
supported_modules[channel_id][i], hal);
if (ret == TRUE) {
- dbg("Core Object Type: [0x%x] - Success");
+ dbg("Core Object Type: [0x%x] - Success",
+ supported_modules[channel_id][i]);
} else {
- err("Core Object Type: [0x%x] - Fail");
+ err("Core Object Type: [0x%x] - Fail",
+ supported_modules[channel_id][i]);
}
}
}
TcorePlugin *plugin;
dbg("MUX Setup - COMPLETE");
- if (user_data == NULL)
- return;
+ tcore_check_return(user_data != NULL);
plugin = tcore_hal_ref_plugin(hal);
/* Load Modem Plug-in */
tcore_server_load_modem_plugin(tcore_plugin_ref_server(plugin),
- plugin, IMC_MODEM_PLUGIN_NAME);
+ plugin, IMC_MODEM_PLUGIN_NAME);
}
-static void _on_cmux_channel_setup(int channel_id, TcoreHal *hal,
- gpointer user_data)
+static void _on_cmux_channel_setup(guint channel_id,
+ TcoreHal *hal, gpointer user_data)
{
TcorePlugin *plugin;
TcoreHal *phy_hal;
if ((hal == NULL) || (user_data == NULL))
return;
- if ((channel_id == 0)
- || (channel_id > IMC_CMUX_MAX_CHANNELS)) {
+ if ((channel_id == 0) || (channel_id > IMC_CMUX_MAX_CHANNELS)) {
err("Control Channel");
return;
}
dbg("HAL Power State: Power ON");
}
-static void _on_response_cmux_init(TcorePending *p, int data_len,
- const void *data, void *user_data)
+static void _on_response_cmux_init(TcorePending *p,
+ guint data_len, const void *data, void *user_data)
{
- const TcoreATResponse *resp = data;
+ const TcoreAtResponse *resp = data;
TcoreHal *hal = user_data;
- TReturn ret;
+ TelReturn ret;
- if ((resp != NULL)
- && resp->success) {
+ if (resp && resp->success) {
dbg("Initialize CMUX - [OK]");
/* Setup Internal CMUX */
ret = tcore_cmux_setup_internal_mux(CMUX_MODE_BASIC,
- IMC_CMUX_MAX_CHANNELS,
- IMC_CMUX_MAX_BUFFER_SIZE, hal,
- _on_cmux_channel_setup, hal,
- _on_cmux_setup_complete, hal);
+ IMC_CMUX_MAX_CHANNELS, IMC_CMUX_MAX_BUFFER_SIZE, hal,
+ _on_cmux_channel_setup, hal, _on_cmux_setup_complete, hal);
} else {
err("Initialize CMUX - [NOK]");
}
}
static void _on_response_enable_logging(TcorePending *p,
- int data_len, const void *data, void *user_data)
+ guint data_len, const void *data, void *user_data)
{
- const TcoreATResponse *resp = data;
+ const TcoreAtResponse *resp = data;
TcoreHal *hal = user_data;
- TReturn ret;
+ TelReturn ret;
- if ((resp != NULL)
- && resp->success) {
+ if (resp && resp->success) {
dbg("Enable CP logging - [OK]");
} else {
err("Enable CP logging - [NOK]");
/* Initialize Internal MUX (CMUX) */
ret = tcore_cmux_init(hal, 0, _on_response_cmux_init, hal);
- if (ret != TCORE_RETURN_SUCCESS) {
+ if (ret != TEL_RETURN_SUCCESS) {
err("Failed to initialize CMUX - Error: [0x%x]", ret);
} else {
dbg("Successfully sent CMUX init to CP");
static void _on_timeout_check_cp_poweron(TcorePending *p, void *user_data)
{
TcoreHal *hal = user_data;
- unsigned int data_len = 0;
+ guint data_len = 0;
char *data = "AT+CPAS";
data_len = sizeof(data);
}
static void _on_response_check_cp_poweron(TcorePending *pending,
- int data_len, const void *data, void *user_data)
+ guint data_len, const void *data, void *user_data)
{
- const TcoreATResponse *resp = data;
+ const TcoreAtResponse *resp = data;
TcoreHal *hal = user_data;
GSList *tokens = NULL;
gboolean bpoweron = FALSE;
int response = 0;
- if ((resp != NULL)
- && resp->success) {
+ if (resp && resp->success) {
dbg("Check CP POWER - [OK]");
/* Parse AT Response */
static void _send_enable_logging_command(TcoreHal *hal)
{
- TcoreATRequest *at_req = NULL;
+ TcoreAtRequest *at_req = NULL;
TcorePending *pending = NULL;
dbg("Sending Trace enabling command for CP logging");
/* Create AT Request */
at_req = tcore_at_request_new("at+xsystrace=1,\"digrf=1;bb_sw=1;3g_sw=1\",\"digrf=0x84\",\"oct=4\";+xsystrace=11;+trace=1",
- NULL, TCORE_AT_NO_RESULT);
+ NULL, TCORE_AT_COMMAND_TYPE_NO_RESULT);
dbg("AT-Command: [%s] Prefix(if any): [%s] Command length: [%d]",
tcore_pending_set_send_callback(pending, _on_confirmation_send_message, NULL);
/* Send command to CP */
- if (tcore_hal_send_request(hal, pending) != TCORE_RETURN_SUCCESS) {
+ if (tcore_hal_send_request(hal, pending) != TEL_RETURN_SUCCESS) {
err("Failed to send Trace logging command");
} else {
dbg("Successfully sent Trace logging command");
static gboolean _check_cp_poweron(TcoreHal *hal)
{
- TcoreATRequest *at_req;
+ TcoreAtRequest *at_req;
TcorePending *pending = NULL;
/* Create Pending request */
pending = tcore_pending_new(NULL, 0);
/* Create AT Request */
- at_req = tcore_at_request_new("AT+CPAS", "+CPAS:", TCORE_AT_SINGLELINE);
+ at_req = tcore_at_request_new("AT+CPAS",
+ "+CPAS:", TCORE_AT_COMMAND_TYPE_SINGLELINE);
dbg("AT-Command: [%s] Prefix(if any): [%s] Command length: [%d]",
- at_req->cmd, at_req->prefix, strlen(at_req->cmd));
+ at_req->cmd, at_req->prefix, strlen(at_req->cmd));
tcore_pending_set_priority(pending, TCORE_PENDING_PRIORITY_DEFAULT);
tcore_pending_set_send_callback(pending, _on_confirmation_send_message, NULL);
/* Send command to CP */
- if (tcore_hal_send_request(hal, pending) != TCORE_RETURN_SUCCESS) {
+ if (tcore_hal_send_request(hal, pending) != TEL_RETURN_SUCCESS) {
err("Failed to send CPAS");
return FALSE;
} else {
gboolean ret;
dbg("Entry");
- if (hal == NULL)
- return;
+ tcore_check_return(hal != NULL);
ret = _check_cp_poweron(hal);
if (ret == TRUE) {
/*
* tel-plugin-imcmodem
*
- * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Kyoungyoup Park <gynaru.park@samsung.com>
+ * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#include <glib.h>
#include <tcore.h>
+#include <util.h>
#include <server.h>
#include <plugin.h>
#include <storage.h>
-#include <user_request.h>
#include <hal.h>
+#include <mux.h>
#include "vnet.h"
#include "config.h"
-#define IMC_HAL_NAME "imcmodem"
-#define IMC_BUFFER_LEN_MAX 4096
+#define IMC_HAL_NAME "imcmodem"
+#define IMC_BUFFER_LEN_MAX 4096
-#define IMC_CP_POWER_ON_TIMEOUT 500
+#define IMC_CP_POWER_ON_TIMEOUT 500
-#define IMC_MAX_CP_POWER_ON_RETRIES 20
+#define IMC_MAX_CP_POWER_ON_RETRIES 20
-#define IMC_DEVICE_NAME_LEN_MAX 16
-#define IMC_DEVICE_NAME_PREFIX "pdp"
+#define IMC_DEVICE_NAME_LEN_MAX 16
+#define IMC_DEVICE_NAME_PREFIX "pdp"
-#define VNET_CH_PATH_BOOT0 "/dev/umts_boot0"
-#define IOCTL_CG_DATA_SEND _IO('o', 0x37)
+#define VNET_CH_PATH_BOOT0 "/dev/umts_boot0"
+#define IOCTL_CG_DATA_SEND _IO('o', 0x37)
-struct vnet_channel {
+typedef struct {
int fd;
guint watch_id;
gboolean on;
-};
+} VnetChannel;
-struct custom_data {
- struct vnet_channel ipc0;
-};
+typedef struct {
+ VnetChannel ipc0;
+} CustomData;
typedef gboolean(*cb_func)(GIOChannel *channel, GIOCondition condition, gpointer data);
static guint _register_gio_watch(TcoreHal *plugin, int fd, void *callback);
static void _deregister_gio_watch(guint watch_id);
-
-/* Utility function to dump the Input/Output bytes (TX/RX Data) */
-static void _util_hex_dump(char *pad, int size, const void *data)
-{
- char buffer[255] = {0, };
- char hex[4] = {0, };
- int i;
- unsigned char *ptr;
-
- if (size <= 0) {
- msg("[%s] NO data", pad);
- return;
- }
-
- ptr = (unsigned char *)data;
-
- snprintf(buffer, 255, "%s%04X: ", pad, 0);
- for (i = 0; i < size; i++) {
- snprintf(hex, 4, "%02X ", ptr[i]);
- strcat(buffer, hex);
-
- if ((i + 1) % 8 == 0) {
- if ((i + 1) % 16 == 0) {
- msg("%s", buffer);
- memset(buffer, 0, 255);
- snprintf(buffer, 255, "%s%04X: ", pad, i + 1);
- } else {
- strcat(buffer, " ");
- }
- }
- }
-
- msg("%s", buffer);
-}
-
static guint _register_gio_watch(TcoreHal *hal, int fd, void *callback)
{
GIOChannel *channel = NULL;
channel = g_io_channel_unix_new(fd);
/* Add to Watch list for IO and HUP events */
- source = g_io_add_watch(channel, G_IO_IN | G_IO_HUP, (GIOFunc) callback, hal);
+ source = g_io_add_watch(channel,
+ G_IO_IN | G_IO_HUP,
+ (GIOFunc) callback, hal);
+
g_io_channel_unref(channel);
channel = NULL;
g_source_remove(watch_id);
}
-static gboolean _ipc0_init(TcoreHal *hal, struct vnet_channel *ch, cb_func recv_message)
+static gboolean _ipc0_init(TcoreHal *hal, VnetChannel *ch, cb_func recv_message)
{
dbg("Entry");
/* Register Channel for IO */
ch->watch_id = _register_gio_watch(hal, ch->fd, recv_message);
+ /* Channel is ON */
ch->on = TRUE;
return ch->on;
}
-static void _ipc0_deinit(struct vnet_channel *ch)
+static void _ipc0_deinit(VnetChannel *ch)
{
- /* Remove and close the Watch ID and 'fd' */
- dbg("Watch ID: [%d]", ch->watch_id);
- if (ch->watch_id > 0)
- _deregister_gio_watch(ch->watch_id);
+ if (ch->on) {
+ dbg("Deinitializing the Channel - Watch ID: [%d] "
+ "fd: [%d]", ch->watch_id, ch->fd);
- dbg("fd: [%d]", ch->fd);
- if (ch->fd > 0)
- close(ch->fd);
+ /* Remove and close the Watch ID and 'fd' */
+ if (ch->watch_id > 0)
+ _deregister_gio_watch(ch->watch_id);
+
+ if (ch->fd > 0)
+ close(ch->fd);
- ch->watch_id = 0;
- ch->fd = 0;
+ ch->watch_id = 0;
+ ch->fd = 0;
- ch->on = FALSE;
+ ch->on = FALSE;
+ }
}
static gboolean _silent_reset(TcoreHal *hal)
{
dbg("[ERROR] Silent Reset");
- /* Set HAL Poer State to OFF (FALSE) */
+ /* Set HAL Power State to OFF (FALSE) */
tcore_hal_set_power_state(hal, FALSE);
/* TODO: Need to handle Silent Reset */
static gboolean _do_exception_operation(TcoreHal *hal, int fd, GIOCondition cond)
{
- enum vnet_cp_state state = VNET_CP_STATE_UNKNOWN;
- struct custom_data *user_data = tcore_hal_ref_user_data(hal);
+ VnetCpState state = VNET_CP_STATE_UNKNOWN;
+ CustomData *user_data = tcore_hal_ref_user_data(hal);
dbg("Entry");
switch (cond) {
}
switch (state) {
- case VNET_CP_STATE_CRASH_EXIT:
- {
+ case VNET_CP_STATE_CRASH_EXIT: {
err("CP Crash: Start ramdump");
_ipc0_deinit(&user_data->ipc0);
}
break;
- case VNET_CP_STATE_CRASH_RESET:
- {
+ case VNET_CP_STATE_CRASH_RESET: {
err("CP Crash Reset");
_ipc0_deinit(&user_data->ipc0);
}
/*
- * if current hal power state is FALSE, 'cp_reset' mean normal power off
+ * if current hal power state is FALSE,
+ * 'cp_reset' mean normal power off
* (it's because of kernel concept)
*/
state = VNET_CP_STATE_OFFLINE;
static gboolean _power_on(gpointer data)
{
- struct custom_data *user_data;
+ CustomData *user_data;
TcoreHal *hal;
gboolean ret;
err("Maximum timeout reached: [%d]", count);
/* Notify server a modem error occured */
- tcore_server_send_notification(server, NULL,
- TNOTI_SERVER_MODEM_ERR,
- 0, NULL);
+ tcore_server_send_server_notification(server,
+ TCORE_SERVER_NOTIFICATION_MODEM_ERR, 0, NULL);
tcore_hal_free(hal);
g_free(user_data);
tcore_server_remove_cp_mapping_tbl_entry(plugin, hal);
}
-static enum tcore_hook_return _on_hal_send(TcoreHal *hal,
- unsigned int data_len, void *data, void *user_data)
+static TcoreHookReturn _on_hal_send(TcoreHal *hal,
+ guint data_len, void *data, void *user_data)
{
msg("\n====== TX data DUMP ======\n");
- _util_hex_dump(" ", data_len, data);
+ tcore_util_hex_dump(" ", data_len, data);
msg("\n====== TX data DUMP ======\n");
return TCORE_HOOK_RETURN_CONTINUE;
}
static void _on_hal_recv(TcoreHal *hal,
- unsigned int data_len, const void *data, void *user_data)
+ guint data_len, const void *data, void *user_data)
{
msg("\n====== RX data DUMP ======\n");
- _util_hex_dump(" ", data_len, data);
+ tcore_util_hex_dump(" ", data_len, data);
msg("\n====== RX data DUMP ======\n");
}
static gboolean _on_recv_ipc_message(GIOChannel *channel,
- GIOCondition condition, gpointer data)
+ GIOCondition condition, gpointer data)
{
TcoreHal *hal = data;
- struct custom_data *custom;
+ CustomData *custom;
char recv_buffer[IMC_BUFFER_LEN_MAX];
int recv_len = 0;
- TReturn ret;
+ TelReturn ret;
custom = tcore_hal_ref_user_data(hal);
return TRUE;
}
-static TReturn _hal_send(TcoreHal *hal, unsigned int data_len, void *data)
+static TelReturn _hal_send(TcoreHal *hal, guint data_len, void *data)
{
int ret;
- struct custom_data *user_data;
+ CustomData *user_data;
if (tcore_hal_get_power_state(hal) == FALSE)
- return TCORE_RETURN_FAILURE;
+ return TEL_RETURN_FAILURE;
user_data = tcore_hal_ref_user_data(hal);
if (!user_data)
- return TCORE_RETURN_FAILURE;
+ return TEL_RETURN_FAILURE;
dbg("write (fd=%d, len=%d)", user_data->ipc0.fd, data_len);
ret = write(user_data->ipc0.fd, (guchar *) data, data_len);
if (ret < 0)
- return TCORE_RETURN_FAILURE;
+ return TEL_RETURN_FAILURE;
- return TCORE_RETURN_SUCCESS;;
+ return TEL_RETURN_SUCCESS;;
}
-static TReturn _hal_setup_netif(CoreObject *co,
- TcoreHalSetupNetifCallback func,
- void *user_data, unsigned int cid,
- gboolean enable)
+static TelReturn _hal_setup_netif(CoreObject *co,
+ TcoreHalSetupNetifCallback func, void *user_data,
+ guint cid, gboolean enable)
{
if (enable == TRUE) {
int fd;
/* Open device to send IOCTL command */
fd = open(VNET_CH_PATH_BOOT0, O_RDWR);
if (fd < 0) {
- err("Failed to Open [%s] Error: [%s]", VNET_CH_PATH_BOOT0, strerror(errno));
- return TCORE_RETURN_FAILURE;
+ err("Failed to Open [%s] Error: [%s]",
+ VNET_CH_PATH_BOOT0, strerror(errno));
+ return TEL_RETURN_FAILURE;
}
/*
* Presently only 2 Contexts are suported
*/
switch (cid) {
- case 1:
- {
+ case 1: {
dbg("Send IOCTL: arg 0x05 (0101) HSIC1, cid: [%d]", cid);
ret = ioctl(fd, IOCTL_CG_DATA_SEND, 0x05);
}
break;
- case 2:
- {
+ case 2: {
dbg("Send IOCTL: arg 0x0A (1010) HSIC2, cid: [%d]", cid);
ret = ioctl(fd, IOCTL_CG_DATA_SEND, 0xA);
}
break;
- default:
- {
- err("More than 2 Contexts are not supported right now!!! cid: [%d]", cid);
+ default: {
+ err("More than 2 Contexts are not supported "
+ "right now!!! cid: [%d]", cid);
}
}
/* TODO - Need to handle Failure case */
if (ret < 0) {
- err("[ERROR] IOCTL_CG_DATA_SEND - FAIL [0x%x]", IOCTL_CG_DATA_SEND);
+ err("[ERROR] IOCTL_CG_DATA_SEND - FAIL [0x%x]",
+ IOCTL_CG_DATA_SEND);
/* Invoke callback function */
if (func)
func(co, ret, NULL, user_data);
- return TCORE_RETURN_FAILURE;
+ return TEL_RETURN_FAILURE;
} else {
- dbg("[OK] IOCTL_CG_DATA_SEND - PASS [0x%x]", IOCTL_CG_DATA_SEND);
+ dbg("[OK] IOCTL_CG_DATA_SEND - PASS [0x%x]",
+ IOCTL_CG_DATA_SEND);
/* Device name */
- snprintf(ifname, IMC_DEVICE_NAME_LEN_MAX, "%s%d", IMC_DEVICE_NAME_PREFIX, (cid - 1));
+ snprintf(ifname, IMC_DEVICE_NAME_LEN_MAX, "%s%d",
+ IMC_DEVICE_NAME_PREFIX, (cid - 1));
dbg("Interface Name: [%s]", ifname);
/* Invoke callback function */
if (func)
func(co, ret, ifname, user_data);
- return TCORE_RETURN_SUCCESS;
+ return TEL_RETURN_SUCCESS;
}
} else {
dbg("DEACTIVATE");
- return TCORE_RETURN_SUCCESS;
+ return TEL_RETURN_SUCCESS;
}
}
/* HAL Operations */
-static struct tcore_hal_operations hal_ops = {
+static TcoreHalOperations hal_ops = {
.power = NULL,
.send = _hal_send,
.setup_netif = _hal_setup_netif,
static gboolean on_init(TcorePlugin *plugin)
{
TcoreHal *hal;
- struct custom_data *data;
+ CustomData *data;
dbg("Init!!!");
- if (plugin == NULL) {
- err("'plugin' is NULL");
- return FALSE;
- }
-
-#if 1 /* TODO - Need to remove this */
- /*
- * CP is NOT coming to ONLINE state,
- * but when it is forceffuly reset using the command -
- * xmm6262-boot
- * it comes back to ONLINE state.
- *
- * We need to look into this aspect
- */
- dbg("====== TRIGGERING CP RESET ======");
- vnet_start_cp_reset();
- dbg("====== CP RESET TRIGGERED ======");
- sleep(2);
-#endif /* TODO - Need to remove this */
+ tcore_check_return_value_assert(plugin != NULL, FALSE);
/* Custom data for Modem Interface Plug-in */
- data = g_try_new0(struct custom_data, 1);
- if (data == NULL) {
- err("Failed to allocate memory for Custom data");
- return FALSE;
- }
+ data = tcore_malloc0(sizeof(CustomData));
dbg("Created custom data memory");
+ /* Intialize for fd to -1 */
+ data->ipc0.fd = -1;
+
/* Create Physical HAL */
- hal = tcore_hal_new(plugin, IMC_HAL_NAME, &hal_ops, TCORE_HAL_MODE_AT);
+ hal = tcore_hal_new(plugin, IMC_HAL_NAME,
+ &hal_ops, TCORE_HAL_MODE_AT);
if (hal == NULL) {
err("Failed to Create Physical HAL");
- g_free(data);
+ tcore_free(data);
return FALSE;
}
dbg("HAL [0x%x] created", hal);
tcore_server_register_modem(tcore_plugin_ref_server(plugin), plugin);
/* Check CP Power ON */
- g_timeout_add_full(G_PRIORITY_HIGH, IMC_CP_POWER_ON_TIMEOUT, _power_on, hal, 0);
+ g_timeout_add_full(G_PRIORITY_HIGH,
+ IMC_CP_POWER_ON_TIMEOUT, _power_on, hal, NULL);
return TRUE;
}
static void on_unload(TcorePlugin *plugin)
{
TcoreHal *hal;
- struct custom_data *user_data;
-
+ CustomData *user_data;
dbg("Unload!!!");
- if (plugin == NULL) {
- err("Modem Interface Plug-in is NULL");
- return;
- }
+ tcore_check_return_assert(plugin != NULL);
/* Unload Modem Plug-in */
tcore_server_unload_modem_plugin(tcore_plugin_ref_server(plugin), plugin);
dbg("CMUX is closed");
user_data = tcore_hal_ref_user_data(hal);
- if (user_data == NULL)
- return;
-
- /* Free HAL */
- tcore_hal_free(hal);
- dbg("Freed HAL");
/* Deinitialize the Physical Channel */
_ipc0_deinit(&user_data->ipc0);
- dbg("Deinitialized the Channel");
/* Free custom data */
- g_free(user_data);
+ tcore_free(user_data);
+
+ /* Free HAL */
+ tcore_hal_free(hal);
+ dbg("Freed HAL");
dbg("Unloaded MODEM Interface Plug-in");
}
/* Modem Interface Plug-in descriptor */
-struct tcore_plugin_define_desc plugin_define_desc = {
+EXPORT_API struct tcore_plugin_define_desc plugin_define_desc = {
.name = "imcmodem",
.priority = TCORE_PLUGIN_PRIORITY_HIGH,
.version = 1,
/*
* tel-plugin-imcmodem
*
- * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact: Kyoungyoup Park <gynaru.park@samsung.com>
+ * Copyright (c) 2013 Samsung Electronics Co. Ltd. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
#define __USE_GNU
#endif
-#define MODEM_IMAGE_PATH "/boot/modem.bin"
-#define NV_DIR_PATH "/csa/nv"
-#define NV_FILE_PATH NV_DIR_PATH"/nvdata.bin"
+/* Modem image */
+#define MODEM_IMAGE_PATH "/boot/modem.bin"
+
+/* NV Data */
+#define NV_DIR_PATH "/csa/nv"
+#define NV_FILE_PATH NV_DIR_PATH"/nvdata.bin"
/*
* AP-CP comunication devices
*/
/* To track CP bootup */
-#define VNET_CH_PATH_BOOT0 "/dev/umts_boot0"
+#define VNET_CH_PATH_BOOT0 "/dev/umts_boot0"
/* Control communication channel */
-#define VNET_CH_PATH_IPC0 "/dev/umts_ipc0"
+#define VNET_CH_PATH_IPC0 "/dev/umts_ipc0"
-#define IOCTL_MODEM_STATUS _IO('o', 0x27)
+#define IOCTL_MODEM_STATUS _IO('o', 0x27)
void vnet_start_cp_ramdump()
{
int ret;
+
ret = system("/usr/bin/xmm6262-boot -o u &");
dbg("system(/usr/bin/xmm6262-boot -o u &) ret[%d]", ret);
}
void vnet_start_cp_reset()
{
int ret;
+
ret = system("/usr/bin/xmm6262-boot &");
dbg("system(/usr/bin/xmm6262-boot &) ret[%d]", ret);
}
-enum vnet_cp_state vnet_get_cp_state(int fd)
+VnetCpState vnet_get_cp_state(int fd)
{
- enum vnet_cp_state state = VNET_CP_STATE_UNKNOWN;
+ VnetCpState state = VNET_CP_STATE_UNKNOWN;
dbg("Entry");
/* Get CP state */
state = ioctl(fd, IOCTL_MODEM_STATUS);
-
switch (state) {
case VNET_CP_STATE_OFFLINE:
dbg("CP State: OFFLINE");
- break;
+ break;
case VNET_CP_STATE_CRASH_RESET:
dbg("CP State: CRASH RESET");
- break;
+ break;
case VNET_CP_STATE_CRASH_EXIT:
dbg("CP State: CRASH EXIT");
- break;
+ break;
case VNET_CP_STATE_BOOTING:
dbg("CP State: BOOT");
- break;
+ break;
case VNET_CP_STATE_ONLINE:
dbg("CP State: ONLINE");
- break;
+ break;
case VNET_CP_STATE_NV_REBUILDING:
dbg("CP State: NV REBUILD");
- break;
+ break;
case VNET_CP_STATE_LOADER_DONE:
dbg("CP State: LOADER DONE");
- break;
+ break;
case VNET_CP_STATE_UNKNOWN:
default:
dbg("CP State: UNKNOWN State - [%d]", state);
- break;
+ break;
}
return state;
int vnet_ipc0_open()
{
- enum vnet_cp_state state;
+ VnetCpState state;
int fd;
dbg("Entry");
/* Opening device to track CP state */
fd = open(VNET_CH_PATH_BOOT0, O_RDWR);
if (fd < 0) {
- err("Failed to Open [%s] Error: [%s]", VNET_CH_PATH_BOOT0, strerror(errno));
+ err("Failed to Open [%s] Error: [%s]",
+ VNET_CH_PATH_BOOT0, strerror(errno));
return -1;
}
/* Opening AP-CP Control communication device */
fd = open(VNET_CH_PATH_IPC0, O_RDWR);
if (fd < 0) {
- err("Failed to Open [%s] Error: [%s]", VNET_CH_PATH_IPC0, strerror(errno));
+ err("Failed to Open [%s] Error: [%s]",
+ VNET_CH_PATH_IPC0, strerror(errno));
return -1;
}
}