4 * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Kyoungyoup Park <gynaru.park@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.
28 #include <sys/ioctl.h>
30 #include <netinet/in.h>
31 #include <arpa/inet.h>
34 #include <linux/types.h>
35 #include <sys/types.h>
36 #include <sys/socket.h>
37 #include <linux/netlink.h>
49 #define MODEM_IMAGE_PATH "/opt/modem/modem.bin"
50 #define NV_DIR_PATH "/csa/nv"
51 #define NV_FILE_PATH NV_DIR_PATH"/nvdata.bin"
54 * AP-CP comunication devices
56 /* To track CP bootup */
57 #define VNET_CH_PATH_BOOT0 "/dev/umts_boot0"
59 /* Control communication channel */
60 #define VNET_CH_PATH_IPC0 "/dev/umts_ipc0"
62 #define IOCTL_MODEM_STATUS _IO('o', 0x27)
64 void vnet_start_cp_ramdump()
67 ret = system("/usr/bin/xmm6262-boot -o u &");
68 dbg("system(/usr/bin/xmm6262-boot -o u &) ret[%d]", ret);
71 void vnet_start_cp_reset()
74 ret = system("/usr/bin/xmm6262-boot &");
75 dbg("system(/usr/bin/xmm6262-boot &) ret[%d]", ret);
78 enum vnet_cp_state vnet_get_cp_state(int fd)
80 enum vnet_cp_state state = VNET_CP_STATE_UNKNOWN;
84 state = ioctl(fd, IOCTL_MODEM_STATUS);
87 case VNET_CP_STATE_OFFLINE:
88 dbg("CP State: OFFLINE");
91 case VNET_CP_STATE_CRASH_RESET:
92 dbg("CP State: CRASH RESET");
95 case VNET_CP_STATE_CRASH_EXIT:
96 dbg("CP State: CRASH EXIT");
99 case VNET_CP_STATE_BOOTING:
100 dbg("CP State: BOOT");
103 case VNET_CP_STATE_ONLINE:
104 dbg("CP State: ONLINE");
107 case VNET_CP_STATE_NV_REBUILDING:
108 dbg("CP State: NV REBUILD");
111 case VNET_CP_STATE_LOADER_DONE:
112 dbg("CP State: LOADER DONE");
115 case VNET_CP_STATE_UNKNOWN:
117 dbg("CP State: UNKNOWN State - [%d]", state);
126 enum vnet_cp_state state;
129 const char * str = NULL;
133 /* Opening device to track CP state */
134 fd = open(VNET_CH_PATH_BOOT0, O_RDWR);
136 str = strerror_r(errno, buf, 256);
137 err("Failed to Open [%s] Error: [%s]", VNET_CH_PATH_BOOT0, str);
141 /* Track the state of CP */
142 state = vnet_get_cp_state(fd);
145 dbg("CP State: [%d]", state);
146 if (state != VNET_CP_STATE_ONLINE) {
147 err("CP is NOT yet Online!!!");
151 /* Opening AP-CP Control communication device */
152 fd = open(VNET_CH_PATH_IPC0, O_RDWR);
154 str = strerror_r(errno, buf, 256);
155 err("Failed to Open [%s] Error: [%s]", VNET_CH_PATH_IPC0, str);