diff options
author | Alexander Tarasikov <alexander.tarasikov@gmail.com> | 2012-08-25 01:36:54 +0400 |
---|---|---|
committer | Alexander Tarasikov <alexander.tarasikov@gmail.com> | 2012-08-25 01:36:54 +0400 |
commit | 10fab96f7de11533ff70b3bfcb7beb1ba8ad4a82 (patch) | |
tree | 16829703e15c9b000c84c6026ed613bc8e5a9e36 /samsung-ipc/device | |
parent | b11be643a3d129324aea655587a5b9d44932bd2b (diff) | |
parent | 74f505ceb284bf2d286c834b588f5cbf73cf2731 (diff) | |
download | external_libsamsung-ipc-10fab96f7de11533ff70b3bfcb7beb1ba8ad4a82.zip external_libsamsung-ipc-10fab96f7de11533ff70b3bfcb7beb1ba8ad4a82.tar.gz external_libsamsung-ipc-10fab96f7de11533ff70b3bfcb7beb1ba8ad4a82.tar.bz2 |
Merge branch 'morphis-master' into tuna-tracking
Diffstat (limited to 'samsung-ipc/device')
-rw-r--r-- | samsung-ipc/device/aries/aries_ipc.c | 28 | ||||
-rw-r--r-- | samsung-ipc/device/aries/aries_ipc.h | 3 | ||||
-rw-r--r-- | samsung-ipc/device/crespo/crespo_ipc.c | 101 | ||||
-rw-r--r-- | samsung-ipc/device/crespo/crespo_ipc.h | 2 | ||||
-rw-r--r-- | samsung-ipc/device/galaxys2/galaxys2_loader.c | 9 | ||||
-rw-r--r-- | samsung-ipc/device/h1/h1_ipc.c | 4 | ||||
-rw-r--r-- | samsung-ipc/device/maguro/maguro_loader.c | 16 | ||||
-rw-r--r-- | samsung-ipc/device/xmm6260/xmm6260_ipc.c | 17 | ||||
-rw-r--r-- | samsung-ipc/device/xmm6260/xmm6260_ipc.h | 11 |
9 files changed, 120 insertions, 71 deletions
diff --git a/samsung-ipc/device/aries/aries_ipc.c b/samsung-ipc/device/aries/aries_ipc.c index f49754c..3e60134 100644 --- a/samsung-ipc/device/aries/aries_ipc.c +++ b/samsung-ipc/device/aries/aries_ipc.c @@ -137,7 +137,7 @@ int aries_modem_bootstrap(struct ipc_client *client) /* Read the radio.img image. */ ipc_client_log(client, "aries_ipc_bootstrap: reading radio image"); - radio_img_p = ipc_mtd_read(client, "/dev/block/bml12", RADIO_IMG_READ_SIZE, RADIO_IMG_READ_SIZE); + radio_img_p = ipc_client_mtd_read(client, "/dev/block/bml12", RADIO_IMG_READ_SIZE, RADIO_IMG_READ_SIZE); ipc_client_log(client, "aries_ipc_bootstrap: radio image read"); ipc_client_log(client, "aries_ipc_bootstrap: open onedram"); @@ -348,15 +348,17 @@ int aries_modem_bootstrap(struct ipc_client *client) /* nv_data part. */ /* Check if all the nv_data files are ok. */ - nv_data_check(client); + if (nv_data_check(client) < 0) + goto error; /* Check if the MD5 is ok. */ - nv_data_md5_check(client); + if (nv_data_md5_check(client) < 0) + goto error; /* Write nv_data.bin to modem_ctl. */ ipc_client_log(client, "aries_ipc_bootstrap: write nv_data to onedram"); - nv_data_p = ipc_file_read(client, nv_data_path(client), nv_data_size(client), nv_data_chunk_size(client)); + nv_data_p = ipc_client_file_read(client, nv_data_path(client), nv_data_size(client), nv_data_chunk_size(client)); if (nv_data_p == NULL) goto error; data_p = nv_data_p; @@ -831,7 +833,7 @@ int aries_ipc_gprs_deactivate(void *data) return 0; } -int aries_ipc_gprs_get_iface(char **iface) +int aries_ipc_gprs_get_iface(char **iface, int cid) { struct ifreq ifr; int fd; @@ -842,18 +844,20 @@ int aries_ipc_gprs_get_iface(char **iface) fd = socket(AF_PHONET, SOCK_DGRAM, 0); - for(i=0 ; i < 3 ; i++) { - sprintf(ifr.ifr_name, "pdp%d", i); + for(i=GPRS_IFACE_COUNT-1 ; i >= 0 ; i--) { + sprintf(ifr.ifr_name, "%s%d", GPRS_IFACE_PREFIX, i); rc = ioctl(fd, SIOCGIFFLAGS, &ifr); - if(rc >= 0) { - *iface=malloc(strlen(ifr.ifr_name) + 1); - memcpy((void *) *iface, ifr.ifr_name, strlen(ifr.ifr_name) + 1); + if(rc < 0 || ifr.ifr_flags & IFF_UP) { + continue; + } else { + asprintf(iface, "%s%d", GPRS_IFACE_PREFIX, i); return 0; } - } + *iface = NULL; + return -1; } @@ -863,7 +867,7 @@ int aries_ipc_gprs_get_capabilities(struct ipc_client_gprs_capabilities *cap) return -1; cap->port_list = 1; - cap->cid_max = 3; + cap->cid_max = GPRS_IFACE_COUNT; return 0; } diff --git a/samsung-ipc/device/aries/aries_ipc.h b/samsung-ipc/device/aries/aries_ipc.h index 82c7286..7f1420e 100644 --- a/samsung-ipc/device/aries/aries_ipc.h +++ b/samsung-ipc/device/aries/aries_ipc.h @@ -41,6 +41,9 @@ #define MAX_MODEM_DATA_SIZE 0x1000 +#define GPRS_IFACE_PREFIX "pdp" +#define GPRS_IFACE_COUNT 3 + int phonet_iface_ifdown(void); int phonet_iface_ifup(void); diff --git a/samsung-ipc/device/crespo/crespo_ipc.c b/samsung-ipc/device/crespo/crespo_ipc.c index 46c5c05..83e7877 100644 --- a/samsung-ipc/device/crespo/crespo_ipc.c +++ b/samsung-ipc/device/crespo/crespo_ipc.c @@ -76,9 +76,9 @@ int crespo_modem_bootstrap(struct ipc_client *client) /* Read the radio.img image. */ ipc_client_log(client, "crespo_ipc_bootstrap: reading radio image"); - radio_img_p = ipc_mtd_read(client, "/dev/mtd/mtd5ro", RADIO_IMG_SIZE, 0x1000); + radio_img_p = ipc_client_mtd_read(client, "/dev/mtd/mtd5ro", RADIO_IMG_SIZE, 0x1000); if (radio_img_p == NULL) { - radio_img_p = ipc_mtd_read(client, "/dev/mtd5ro", RADIO_IMG_SIZE, 0x1000); + radio_img_p = ipc_client_mtd_read(client, "/dev/mtd5ro", RADIO_IMG_SIZE, 0x1000); if (radio_img_p == NULL) goto error; } @@ -90,7 +90,10 @@ int crespo_modem_bootstrap(struct ipc_client *client) goto error; /* Reset the modem before init to send the first part of modem.img. */ - ioctl(modem_ctl_fd, IOCTL_MODEM_RESET); + rc = ioctl(modem_ctl_fd, IOCTL_MODEM_RESET); + if (rc < 0) + goto error; + usleep(400000); ipc_client_log(client, "crespo_ipc_bootstrap: open s3c2410_serial3"); @@ -120,28 +123,40 @@ int crespo_modem_bootstrap(struct ipc_client *client) usleep(50000); //FIXME /* Get and check bootcore version. */ - read(s3c2410_serial3_fd, &bootcore_version, sizeof(bootcore_version)); + rc = read(s3c2410_serial3_fd, &bootcore_version, sizeof(bootcore_version)); + if (rc < 0) + goto error; + ipc_client_log(client, "crespo_ipc_bootstrap: got bootcore version: 0x%x", bootcore_version); if(bootcore_version != BOOTCORE_VERSION) goto error; /* Get info_size. */ - read(s3c2410_serial3_fd, &info_size, sizeof(info_size)); + rc = read(s3c2410_serial3_fd, &info_size, sizeof(info_size)); + if (rc < 0) + goto error; + ipc_client_log(client, "crespo_ipc_bootstrap: got info_size: 0x%x", info_size); /* Send PSI magic. */ - data=PSI_MAGIC; - write(s3c2410_serial3_fd, &data, sizeof(data)); + data = PSI_MAGIC; + rc = write(s3c2410_serial3_fd, &data, sizeof(data)); + if (rc < 0) + goto error; + ipc_client_log(client, "crespo_ipc_bootstrap: sent PSI_MAGIC (0x%x)", PSI_MAGIC); /* Send PSI data len. */ - data_16=PSI_DATA_LEN; - data_p=(uint8_t *)&data_16; + data_16 = PSI_DATA_LEN; + data_p = (uint8_t *)&data_16; for(i=0 ; i < 2 ; i++) { - write(s3c2410_serial3_fd, data_p, 1); + rc = write(s3c2410_serial3_fd, data_p, 1); + if (rc < 0) + goto error; + data_p++; } ipc_client_log(client, "crespo_ipc_bootstrap: sent PSI_DATA_LEN (0x%x)", PSI_DATA_LEN); @@ -150,49 +165,55 @@ int crespo_modem_bootstrap(struct ipc_client *client) FD_ZERO(&fds); FD_SET(s3c2410_serial3_fd, &fds); - timeout.tv_sec=4; - timeout.tv_usec=0; + timeout.tv_sec = 4; + timeout.tv_usec = 0; - data_p=radio_img_p; + data_p = radio_img_p; ipc_client_log(client, "crespo_ipc_bootstrap: sending the first part of radio.img"); - for(i=0 ; i < PSI_DATA_LEN ; i++) + for (i=0 ; i < PSI_DATA_LEN ; i++) { - if(select(FD_SETSIZE, NULL, &fds, NULL, &timeout) == 0) + if (select(FD_SETSIZE, NULL, &fds, NULL, &timeout) == 0) { ipc_client_log(client, "crespo_ipc_bootstrap: select timeout passed"); goto error; } - write(s3c2410_serial3_fd, data_p, 1); - crc_byte=crc_byte ^ *data_p; + rc = write(s3c2410_serial3_fd, data_p, 1); + if (rc < 0) + goto error; + crc_byte = crc_byte ^ *data_p; data_p++; } ipc_client_log(client, "crespo_ipc_bootstrap: first part of radio.img sent; crc_byte is 0x%x", crc_byte); - if(select(FD_SETSIZE, NULL, &fds, NULL, &timeout) == 0) + if (select(FD_SETSIZE, NULL, &fds, NULL, &timeout) == 0) { ipc_client_log(client, "crespo_ipc_bootstrap: select timeout passed"); goto error; } - write(s3c2410_serial3_fd, &crc_byte, sizeof(crc_byte)); + rc = write(s3c2410_serial3_fd, &crc_byte, sizeof(crc_byte)); + if (rc < 0) + goto error; ipc_client_log(client, "crespo_ipc_bootstrap: crc_byte sent"); data = 0; - for(i = 0 ; data != 0x01 ; i++) + for (i = 0 ; data != 0x01 ; i++) { - if(select(FD_SETSIZE, &fds, NULL, NULL, &timeout) == 0) + if (select(FD_SETSIZE, &fds, NULL, NULL, &timeout) == 0) { ipc_client_log(client, "crespo_ipc_bootstrap: select timeout passed"); goto error; } - read(s3c2410_serial3_fd, &data, sizeof(data)); + rc = read(s3c2410_serial3_fd, &data, sizeof(data)); + if (rc < 0) + goto error; if(i > 50) { @@ -209,22 +230,25 @@ int crespo_modem_bootstrap(struct ipc_client *client) lseek(modem_ctl_fd, 0, SEEK_SET); /* Pointer to the remaining part of radio.img. */ - data_p=radio_img_p + PSI_DATA_LEN; + data_p = radio_img_p + PSI_DATA_LEN; FD_ZERO(&fds); FD_SET(modem_ctl_fd, &fds); block_size = 0x100000; - for(i=0 ; i < (RADIO_IMG_SIZE - PSI_DATA_LEN) / block_size ; i++) + for (i=0 ; i < (RADIO_IMG_SIZE - PSI_DATA_LEN) / block_size ; i++) { - if(select(FD_SETSIZE, NULL, &fds, NULL, &timeout) == 0) + if (select(FD_SETSIZE, NULL, &fds, NULL, &timeout) == 0) { ipc_client_log(client, "crespo_ipc_bootstrap: select timeout passed"); goto error; } - write(modem_ctl_fd, data_p, block_size); + rc = write(modem_ctl_fd, data_p, block_size); + if (rc < 0) + goto error; + data_p += block_size; } @@ -233,29 +257,33 @@ int crespo_modem_bootstrap(struct ipc_client *client) /* nv_data part. */ /* Check if all the nv_data files are ok. */ - nv_data_check(client); + if (nv_data_check(client) < 0) + goto error; /* Check if the MD5 is ok. */ - nv_data_md5_check(client); + if (nv_data_md5_check(client) < 0) + goto error; /* Write nv_data.bin to modem_ctl. */ ipc_client_log(client, "crespo_ipc_bootstrap: write nv_data to modem_ctl"); - nv_data_p = ipc_file_read(client, nv_data_path(client), nv_data_size(client), nv_data_chunk_size(client)); + nv_data_p = ipc_client_file_read(client, nv_data_path(client), nv_data_size(client), nv_data_chunk_size(client)); if (nv_data_p == NULL) goto error; - data_p = nv_data_p; + data_p = nv_data_p; lseek(modem_ctl_fd, RADIO_IMG_SIZE, SEEK_SET); for(i=0 ; i < 2 ; i++) { - write(modem_ctl_fd, data_p, nv_data_size(client) / 2); + rc = write(modem_ctl_fd, data_p, nv_data_size(client) / 2); + if (rc < 0) + goto error; + data_p += nv_data_size(client) / 2; } free(nv_data_p); - close(modem_ctl_fd); rc = 0; @@ -425,9 +453,8 @@ int crespo_ipc_rfs_client_recv(struct ipc_client *client, struct ipc_message_inf return 0; } -int crespo_ipc_open(void *data, unsigned int size, void *io_data) +int crespo_ipc_open(int type, void *io_data) { - int type = *((int *) data); int fd = -1; switch(type) @@ -453,7 +480,7 @@ int crespo_ipc_open(void *data, unsigned int size, void *io_data) return 0; } -int crespo_ipc_close(void *data, unsigned int size, void *io_data) +int crespo_ipc_close(void *io_data) { int fd = -1; @@ -559,9 +586,9 @@ int crespo_ipc_power_off(void *io_data) return 0; } -int crespo_ipc_gprs_get_iface(char **iface) +int crespo_ipc_gprs_get_iface(char **iface, int cid) { - asprintf(iface, GPRS_IFACE); + asprintf(iface, "%s%d", GPRS_IFACE_PREFIX, 0); return 0; } diff --git a/samsung-ipc/device/crespo/crespo_ipc.h b/samsung-ipc/device/crespo/crespo_ipc.h index fc06826..47c8da8 100644 --- a/samsung-ipc/device/crespo/crespo_ipc.h +++ b/samsung-ipc/device/crespo/crespo_ipc.h @@ -28,7 +28,7 @@ #define MAX_MODEM_DATA_SIZE 0x50000 -#define GPRS_IFACE "rmnet0" +#define GPRS_IFACE_PREFIX "rmnet" extern struct ipc_handlers crespo_ipc_default_handlers; diff --git a/samsung-ipc/device/galaxys2/galaxys2_loader.c b/samsung-ipc/device/galaxys2/galaxys2_loader.c index cb44e0a..4647cac 100644 --- a/samsung-ipc/device/galaxys2/galaxys2_loader.c +++ b/samsung-ipc/device/galaxys2/galaxys2_loader.c @@ -435,10 +435,13 @@ static int galaxys2_send_secure_images(struct ipc_client *client, ipc_client_log(client, "sent FIRMWARE image"); } - nv_data_check(client); - nv_data_md5_check(client); + if (nv_data_check(client) < 0) + goto fail; + + if (nv_data_md5_check(client) < 0) + goto fail; - nv_data = ipc_file_read(client, nv_data_path(client), 2 << 20, 1024); + nv_data = ipc_client_file_read(client, nv_data_path(client), 2 << 20, 1024); if (nv_data == NULL) { ipc_client_log(client, "Error: failed to read NVDATA image"); goto fail; diff --git a/samsung-ipc/device/h1/h1_ipc.c b/samsung-ipc/device/h1/h1_ipc.c index 8e20dd2..ca7fd6a 100644 --- a/samsung-ipc/device/h1/h1_ipc.c +++ b/samsung-ipc/device/h1/h1_ipc.c @@ -129,7 +129,7 @@ int h1_ipc_send(struct ipc_client *client, struct ipc_message_info *request) ipc_command_to_str(IPC_COMMAND(request)), ipc_response_type_to_str(request->type)); - ipc_hex_dump(client, frame, frame_length); + ipc_client_hex_dump(client, frame, frame_length); client->handlers->write(frame, frame_length, client->handlers->write_data); @@ -172,7 +172,7 @@ int h1_ipc_recv(struct ipc_client *client, struct ipc_message_info *response) ipc_command_to_str(IPC_COMMAND(response)), ipc_response_type_to_str(response->type)); - ipc_hex_dump(client, data, num_read-1); + ipc_client_hex_dump(client, data, num_read-1); return 0; } diff --git a/samsung-ipc/device/maguro/maguro_loader.c b/samsung-ipc/device/maguro/maguro_loader.c index 1eb7fff..0ee71a0 100644 --- a/samsung-ipc/device/maguro/maguro_loader.c +++ b/samsung-ipc/device/maguro/maguro_loader.c @@ -481,9 +481,14 @@ static int maguro_send_mps_data(struct ipc_client *client, mps_fd = open(I9250_MPS_IMAGE_PATH, O_RDONLY); if (mps_fd < 0) { ipc_client_log(client, "Error: failed to open MPS data"); + goto fail; } else { - read(mps_fd, mps_data, I9250_MPS_LENGTH); + ret = read(mps_fd, mps_data, I9250_MPS_LENGTH); + if (ret < 0) { + ipc_client_log(client, "Error: failed to read MPS data\n"); + goto fail; + } } if ((ret = maguro_boot_cmd(client, io_data, ReqFlashSetAddress, &addr, 4)) < 0) { @@ -535,10 +540,13 @@ static int maguro_send_image_addrs(struct ipc_client *client, ipc_client_log(client, "sent FIRMWARE image"); } - nv_data_check(client); - nv_data_md5_check(client); + if (nv_data_check(client) < 0) + goto fail; + + if (nv_data_md5_check(client) < 0) + goto fail; - nv_data = ipc_file_read(client, nv_data_path(client), 2 << 20, 1024); + nv_data = ipc_client_file_read(client, nv_data_path(client), 2 << 20, 1024); if (nv_data == NULL) { ipc_client_log(client, "Error: failed to read NVDATA image"); goto fail; diff --git a/samsung-ipc/device/xmm6260/xmm6260_ipc.c b/samsung-ipc/device/xmm6260/xmm6260_ipc.c index 7544fd3..205c73b 100644 --- a/samsung-ipc/device/xmm6260/xmm6260_ipc.c +++ b/samsung-ipc/device/xmm6260/xmm6260_ipc.c @@ -242,9 +242,8 @@ int xmm6260_ipc_rfs_client_send(struct ipc_client *client, struct ipc_message_in return rc; } -int xmm6260_ipc_open(void *data, unsigned int size, void *io_data) +int xmm6260_ipc_open(int type, void *io_data) { - int type = *((int *) data); int fd = -1; switch(type) @@ -270,7 +269,7 @@ int xmm6260_ipc_open(void *data, unsigned int size, void *io_data) return 0; } -int xmm6260_ipc_close(void *data, unsigned int size, void *io_data) +int xmm6260_ipc_close(void *io_data) { int fd = -1; @@ -345,10 +344,14 @@ int xmm6260_ipc_power_off(void *io_data) return 0; } -int xmm6260_ipc_gprs_get_iface(char **iface) +int xmm6260_ipc_gprs_get_iface(char **iface, int cid) { - // TODO: depends on CID - asprintf(iface, GPRS_IFACE); + if(cid > GPRS_IFACE_COUNT) { + *iface = NULL; + return -1; + } + + asprintf(iface, "%s%d", GPRS_IFACE_PREFIX, cid - 1); return 0; } @@ -359,7 +362,7 @@ int xmm6260_ipc_gprs_get_capabilities(struct ipc_client_gprs_capabilities *cap) return -1; cap->port_list = 1; - cap->cid_max = 3; + cap->cid_max = GPRS_IFACE_COUNT; return 0; } diff --git a/samsung-ipc/device/xmm6260/xmm6260_ipc.h b/samsung-ipc/device/xmm6260/xmm6260_ipc.h index 14a0cfb..58bd8a2 100644 --- a/samsung-ipc/device/xmm6260/xmm6260_ipc.h +++ b/samsung-ipc/device/xmm6260/xmm6260_ipc.h @@ -26,8 +26,9 @@ #ifndef __XMM6260_IPC_H__ #define __XMM6260_IPC_H__ -#define IPC_MAX_XFER 4096 -#define GPRS_IFACE "rmnet0" +#define IPC_MAX_XFER 4096 +#define GPRS_IFACE_PREFIX "rmnet" +#define GPRS_IFACE_COUNT 3 struct rfs_hdr { uint32_t size; @@ -39,13 +40,13 @@ int xmm6260_ipc_fmt_client_send(struct ipc_client *client, struct ipc_message_in int xmm6260_ipc_fmt_client_recv(struct ipc_client *client, struct ipc_message_info *response); int xmm6260_ipc_rfs_client_recv(struct ipc_client *client, struct ipc_message_info *response); int xmm6260_ipc_rfs_client_send(struct ipc_client *client, struct ipc_message_info *request); -int xmm6260_ipc_open(void *data, unsigned int size, void *io_data); -int xmm6260_ipc_close(void *data, unsigned int size, void *io_data); +int xmm6260_ipc_open(int type, void *io_data); +int xmm6260_ipc_close(void *io_data); int xmm6260_ipc_read(void *data, unsigned int size, void *io_data); int xmm6260_ipc_write(void *data, unsigned int size, void *io_data); int xmm6260_ipc_power_on(void *io_data); int xmm6260_ipc_power_off(void *io_data); -int xmm6260_ipc_gprs_get_iface(char **iface); +int xmm6260_ipc_gprs_get_iface(char **iface, int cid); int xmm6260_ipc_gprs_get_capabilities(struct ipc_client_gprs_capabilities *cap); void *xmm6260_ipc_common_data_create(void); int xmm6260_ipc_common_data_destroy(void *io_data); |