diff options
author | Paul Kocialkowski <contact@paulk.fr> | 2012-07-05 17:54:25 +0200 |
---|---|---|
committer | Paul Kocialkowski <contact@paulk.fr> | 2012-07-05 19:14:37 +0200 |
commit | 84cd42f10be74c0a60545c2035876e3beca644a3 (patch) | |
tree | b78334b1d9ba9ce2ff6d5ac65cd4b2c6b0130bd9 /samsung-ipc/device/xmm6260 | |
parent | 2eea520884474f4eefcf03815d52dfaac9e03cce (diff) | |
download | external_libsamsung-ipc-84cd42f10be74c0a60545c2035876e3beca644a3.zip external_libsamsung-ipc-84cd42f10be74c0a60545c2035876e3beca644a3.tar.gz external_libsamsung-ipc-84cd42f10be74c0a60545c2035876e3beca644a3.tar.bz2 |
XMM6260: Split code into galaxys2, maguro and xmm2620 (shared code) devices
* Moved maguro and galaxys2 loaders to proper folders
* Renamed i9100 to galaxys2 and i9250 to maguro
* Device-specific ops, handlers, gprs_specs and nv_data_specs on XMM2620 devices
though most data/functions are still shared in xmm2620_ipc
* Removed radio_parts from modemctl_io_data
* Moved CRC calculate function to xmm2620_loader
* Moved io_helpers functions to xmm2620_loader
* Listed include headers in each file instead of using common.h
* Prefixed remaining xmm2620 files
Signed-off-by: Paul Kocialkowski <contact@paulk.fr>
Diffstat (limited to 'samsung-ipc/device/xmm6260')
-rw-r--r-- | samsung-ipc/device/xmm6260/common.h | 48 | ||||
-rw-r--r-- | samsung-ipc/device/xmm6260/xmm6260_ipc.c | 72 | ||||
-rw-r--r-- | samsung-ipc/device/xmm6260/xmm6260_ipc.h | 26 | ||||
-rw-r--r-- | samsung-ipc/device/xmm6260/xmm6260_loader.c (renamed from samsung-ipc/device/xmm6260/io_helpers.c) | 48 | ||||
-rw-r--r-- | samsung-ipc/device/xmm6260/xmm6260_loader.h (renamed from samsung-ipc/device/xmm6260/io_helpers.h) | 57 | ||||
-rw-r--r-- | samsung-ipc/device/xmm6260/xmm6260_modemctl.c (renamed from samsung-ipc/device/xmm6260/modemctl.c) | 41 | ||||
-rw-r--r-- | samsung-ipc/device/xmm6260/xmm6260_modemctl.h (renamed from samsung-ipc/device/xmm6260/modemctl.h) | 61 |
7 files changed, 152 insertions, 201 deletions
diff --git a/samsung-ipc/device/xmm6260/common.h b/samsung-ipc/device/xmm6260/common.h deleted file mode 100644 index db8c8c7..0000000 --- a/samsung-ipc/device/xmm6260/common.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - * common.h: common system headers includes and config defines - * This file is part of: - * - * Firmware loader for Samsung I9100 and I9250 - * Copyright (C) 2012 Alexander Tarasikov <alexander.tarasikov@gmail.com> - * - * based on the incomplete C++ implementation which is - * Copyright (C) 2012 Sergey Gridasov <grindars@gmail.com> - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef __COMMON_H__ -#define __COMMON_H__ - -#include <stdio.h> -#include <stdlib.h> -#include <stdbool.h> -#include <string.h> - -#include <getopt.h> -#include <unistd.h> -#include <fcntl.h> -#include <errno.h> -#include <sys/ioctl.h> - -//for timeval -#include <sys/time.h> - -//for mmap -#include <sys/mman.h> -#include <sys/stat.h> - -#define ARRAY_SIZE(x) (sizeof(x) / sizeof(x[0])) - -#endif //__COMMON_H__ diff --git a/samsung-ipc/device/xmm6260/xmm6260_ipc.c b/samsung-ipc/device/xmm6260/xmm6260_ipc.c index 0e17af5..7c84003 100644 --- a/samsung-ipc/device/xmm6260/xmm6260_ipc.c +++ b/samsung-ipc/device/xmm6260/xmm6260_ipc.c @@ -39,22 +39,14 @@ #include <radio.h> -#include "xmm6260_ipc.h" #include "ipc_private.h" -#include "modemctl_common.h" - -int i9100_modem_bootstrap(struct ipc_client *client) -{ - return i9100_boot_modem(client); -} - -int i9250_modem_bootstrap(struct ipc_client *client) -{ - return i9250_boot_modem(client); -} +#include "xmm6260_ipc.h" +#include "xmm6260_loader.h" +#include "xmm6260_modemctl.h" +#include "modem_prj.h" -int xmm6260_ipc_send(struct ipc_client *client, struct ipc_message_info *request) +int xmm6260_ipc_fmt_client_send(struct ipc_client *client, struct ipc_message_info *request) { struct ipc_header *hdr; unsigned char *frame; @@ -92,7 +84,7 @@ int xmm6260_ipc_send(struct ipc_client *client, struct ipc_message_info *request return 0; } -int xmm6260_ipc_recv(struct ipc_client *client, struct ipc_message_info *response) +int xmm6260_ipc_fmt_client_recv(struct ipc_client *client, struct ipc_message_info *response) { unsigned char buf[IPC_MAX_XFER] = {}; unsigned char *data; @@ -143,7 +135,7 @@ int xmm6260_ipc_recv(struct ipc_client *client, struct ipc_message_info *respons return 0; } -int xmm6260_rfs_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) { unsigned char buf[IPC_MAX_XFER] = {}; struct rfs_hdr header; @@ -213,7 +205,7 @@ int xmm6260_rfs_recv(struct ipc_client *client, struct ipc_message_info *respons return 0; } -int xmm6260_rfs_send(struct ipc_client *client, struct ipc_message_info *request) +int xmm6260_ipc_rfs_client_send(struct ipc_client *client, struct ipc_message_info *request) { struct rfs_hdr *header = NULL; char *data = NULL; @@ -347,7 +339,7 @@ int xmm6260_ipc_power_off(void *io_data) int xmm6260_ipc_gprs_get_iface(char **iface) { // TODO: depends on CID - asprintf(iface, "rmnet0"); + asprintf(iface, GPRS_IFACE); return 0; } @@ -416,50 +408,4 @@ int xmm6260_ipc_common_data_get_fd(void *io_data) return (int) *(common_data); } -struct ipc_ops xmm6260_i9100_fmt_ops = { - .send = xmm6260_ipc_send, - .recv = xmm6260_ipc_recv, - .bootstrap = i9100_modem_bootstrap, -}; - -struct ipc_ops xmm6260_i9250_fmt_ops = { - .send = xmm6260_ipc_send, - .recv = xmm6260_ipc_recv, - .bootstrap = i9250_modem_bootstrap, -}; - -struct ipc_ops xmm6260_rfs_ops = { - .send = xmm6260_rfs_send, - .recv = xmm6260_rfs_recv, - .bootstrap = NULL, -}; - -struct ipc_handlers xmm6260_default_handlers = { - .read = xmm6260_ipc_read, - .write = xmm6260_ipc_write, - .open = xmm6260_ipc_open, - .close = xmm6260_ipc_close, - .power_on = xmm6260_ipc_power_on, - .power_off = xmm6260_ipc_power_off, - .common_data = NULL, - .common_data_create = xmm6260_ipc_common_data_create, - .common_data_destroy = xmm6260_ipc_common_data_destroy, - .common_data_set_fd = xmm6260_ipc_common_data_set_fd, - .common_data_get_fd = xmm6260_ipc_common_data_get_fd, -}; - -struct ipc_gprs_specs xmm6260_gprs_specs = { - .gprs_get_iface = xmm6260_ipc_gprs_get_iface, - .gprs_get_capabilities = xmm6260_ipc_gprs_get_capabilities, -}; - - -struct ipc_nv_data_specs xmm6260_nv_data_specs = { - .nv_data_path = "/factory/nv_data.bin", - .nv_data_md5_path = "/factory/nv_data.bin.md5", - .nv_state_path = "/factory/.nv_state", - .nv_data_bak_path = "/factory/.nv_data.bak", - .nv_data_md5_bak_path = "/factory/.nv_data.bak.md5", -}; - // vim:ts=4:sw=4:expandtab diff --git a/samsung-ipc/device/xmm6260/xmm6260_ipc.h b/samsung-ipc/device/xmm6260/xmm6260_ipc.h index 06c8387..14a0cfb 100644 --- a/samsung-ipc/device/xmm6260/xmm6260_ipc.h +++ b/samsung-ipc/device/xmm6260/xmm6260_ipc.h @@ -2,9 +2,12 @@ * This file is part of libsamsung-ipc. * * Copyright (C) 2012 Alexander Tarasikov <alexander.tarasikov@gmail.com> + * Copyright (C) 2011 Paul Kocialkowski <contact@paulk.fr> * based on crespo IPC code which is: * * Copyright (C) 2011 Paul Kocialkowski <contact@paulk.fr> + * Joerie de Gram <j.de.gram@gmail.com> + * Simon Busch <morphis@gravedo.de> * * libsamsung-ipc is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -18,15 +21,13 @@ * * You should have received a copy of the GNU General Public License * along with libsamsung-ipc. If not, see <http://www.gnu.org/licenses/>. - * */ #ifndef __XMM6260_IPC_H__ #define __XMM6260_IPC_H__ -#define IPC_MAX_XFER 4096 - -extern struct ipc_handlers xmm6260_ipc_default_handlers; +#define IPC_MAX_XFER 4096 +#define GPRS_IFACE "rmnet0" struct rfs_hdr { uint32_t size; @@ -34,6 +35,23 @@ struct rfs_hdr { uint8_t id; } __attribute__ ((packed)); +int xmm6260_ipc_fmt_client_send(struct ipc_client *client, struct ipc_message_info *request); +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_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_capabilities(struct ipc_client_gprs_capabilities *cap); +void *xmm6260_ipc_common_data_create(void); +int xmm6260_ipc_common_data_destroy(void *io_data); +int xmm6260_ipc_common_data_set_fd(void *io_data, int fd); +int xmm6260_ipc_common_data_get_fd(void *io_data); + #endif // vim:ts=4:sw=4:expandtab diff --git a/samsung-ipc/device/xmm6260/io_helpers.c b/samsung-ipc/device/xmm6260/xmm6260_loader.c index 0a38266..3c78891 100644 --- a/samsung-ipc/device/xmm6260/io_helpers.c +++ b/samsung-ipc/device/xmm6260/xmm6260_loader.c @@ -1,9 +1,7 @@ /* - * io_helpers.c - I/O helper functions for the firmware loader - * This file is part of: - * - * Firmware loader for Samsung I9100 and I9250 + * XMM6260 Firmware loader functions * Copyright (C) 2012 Alexander Tarasikov <alexander.tarasikov@gmail.com> + * Copyright (C) 2012 Paul Kocialkowski <contact@paulk.fr> * * based on the incomplete C++ implementation which is * Copyright (C) 2012 Sergey Gridasov <grindars@gmail.com> @@ -22,9 +20,45 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#include "io_helpers.h" +#include <stdio.h> +#include <stdlib.h> +#include <stdbool.h> +#include <string.h> + +#include <getopt.h> +#include <unistd.h> +#include <fcntl.h> +#include <errno.h> +#include <sys/ioctl.h> + +//for timeval +#include <sys/time.h> + +//for mmap +#include <sys/mman.h> +#include <sys/stat.h> + +#include "ipc_private.h" + +#include "xmm6260_loader.h" +#include "xmm6260_modemctl.h" +#include "modem_prj.h" + +unsigned char xmm6260_crc_calculate(void* data, size_t offset, size_t length) +{ + unsigned char crc = 0; + unsigned char *ptr = (unsigned char*)(data + offset); -#define DEFAULT_TIMEOUT 50 + while (length--) { + crc ^= *ptr++; + } + + return crc; +} + +/* + * io helper functions + */ int expect(int fd, unsigned timeout) { int ret = 0; @@ -76,5 +110,3 @@ int expect_data(int fd, void *data, size_t size) { return ret; } - -// vim:ts=4:sw=4:expandtab diff --git a/samsung-ipc/device/xmm6260/io_helpers.h b/samsung-ipc/device/xmm6260/xmm6260_loader.h index f2ef717..b022645 100644 --- a/samsung-ipc/device/xmm6260/io_helpers.h +++ b/samsung-ipc/device/xmm6260/xmm6260_loader.h @@ -1,6 +1,7 @@ /* - * Firmware loader for Samsung I9100 and I9250 + * XMM6260 Firmware loader functions * Copyright (C) 2012 Alexander Tarasikov <alexander.tarasikov@gmail.com> + * Copyright (C) 2012 Paul Kocialkowski <contact@paulk.fr> * * based on the incomplete C++ implementation which is * Copyright (C) 2012 Sergey Gridasov <grindars@gmail.com> @@ -19,10 +20,54 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef __IO_HELPERS_H__ -#define __IO_HELPERS_H__ +#ifndef __XMM6260_LOADER_H__ +#define __XMM6260_LOADER_H__ -#include "common.h" +#define RADIO_MAP_SIZE (16 << 20) +#define DEFAULT_TIMEOUT 50 + +/* + * Offset and length to describe a part of XMM6260 firmware + */ +struct xmm6260_radio_part { + size_t offset; + size_t length; +}; + +/* + * Components of the Samsung XMM6260 firmware + */ +enum xmm6260_image { + PSI, + EBL, + SECURE_IMAGE, + FIRMWARE, + NVDATA, +}; + +/* + * Bootloader control interface definitions + */ +enum xmm6260_boot_cmd { + SetPortConf, + + ReqSecStart, + ReqSecEnd, + ReqForceHwReset, + + ReqFlashSetAddress, + ReqFlashWriteBlock, +}; + +/* + * @brief Calculate the checksum for the XMM6260 bootloader protocol + * + * @param data [in] the data to calculate the checksum for + * @param offset [in] number of bytes to skip + * @param length [in] length of data in bytes + * @return checksum value + */ +unsigned char xmm6260_crc_calculate(void* data, size_t offset, size_t length); /* * @brief Waits for fd to become available for reading @@ -56,6 +101,4 @@ int expect_read(int fd, void *buf, size_t size); */ int expect_data(int fd, void *data, size_t size); -#endif //__IO_HELPERS_H__ - -// vim:ts=4:sw=4:expandtab +#endif diff --git a/samsung-ipc/device/xmm6260/modemctl.c b/samsung-ipc/device/xmm6260/xmm6260_modemctl.c index 489f9fe..a6f1fb6 100644 --- a/samsung-ipc/device/xmm6260/modemctl.c +++ b/samsung-ipc/device/xmm6260/xmm6260_modemctl.c @@ -1,6 +1,7 @@ /* - * Firmware loader for Samsung I9100 and I9250 + * XMM6260 Modem Control functions * Copyright (C) 2012 Alexander Tarasikov <alexander.tarasikov@gmail.com> + * Copyright (C) 2012 Paul Kocialkowski <contact@paulk.fr> * * based on the incomplete C++ implementation which is * Copyright (C) 2012 Sergey Gridasov <grindars@gmail.com> @@ -19,12 +20,34 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -//modemctl shared code -#include "modemctl_common.h" +#include <stdio.h> +#include <stdlib.h> +#include <stdbool.h> +#include <string.h> + +#include <getopt.h> +#include <unistd.h> +#include <fcntl.h> +#include <errno.h> +#include <sys/ioctl.h> + +//for timeval +#include <sys/time.h> + +//for mmap +#include <sys/mman.h> +#include <sys/stat.h> + +#include "ipc_private.h" + +#include "xmm6260_loader.h" +#include "xmm6260_modemctl.h" +#include "modem_prj.h" /* * modemctl generic functions */ + int modemctl_link_set_active(struct ipc_client *client, struct modemctl_io_data *io_data, bool enabled) { unsigned status = enabled; @@ -155,16 +178,4 @@ int modemctl_modem_boot_power(struct ipc_client *client, return -1; } -unsigned char calculateCRC(void* data, size_t offset, size_t length) -{ - unsigned char crc = 0; - unsigned char *ptr = (unsigned char*)(data + offset); - - while (length--) { - crc ^= *ptr++; - } - - return crc; -} - // vim:ts=4:sw=4:expandtab diff --git a/samsung-ipc/device/xmm6260/modemctl.h b/samsung-ipc/device/xmm6260/xmm6260_modemctl.h index 87c9555..d71a13a 100644 --- a/samsung-ipc/device/xmm6260/modemctl.h +++ b/samsung-ipc/device/xmm6260/xmm6260_modemctl.h @@ -1,6 +1,7 @@ /* - * Firmware loader for Samsung I9100 and I9250 + * XMM6260 Modem Control functions * Copyright (C) 2012 Alexander Tarasikov <alexander.tarasikov@gmail.com> + * Copyright (C) 2012 Paul Kocialkowski <contact@paulk.fr> * * based on the incomplete C++ implementation which is * Copyright (C) 2012 Sergey Gridasov <grindars@gmail.com> @@ -19,17 +20,11 @@ * along with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef __MODEMCTL_COMMON_H__ -#define __MODEMCTL_COMMON_H__ +#ifndef __XMM6260_MODEMCTL_H__ +#define __XMM6260_MODEMCTL_H__ #include <radio.h> -#include "common.h" -#include "io_helpers.h" - -//Samsung IOCTLs -#include "modem_prj.h" - #define MODEM_DEVICE(x) ("/dev/" #x) #define LINK_PM MODEM_DEVICE(link_pm) #define MODEM_DEV MODEM_DEVICE(modem_br) @@ -40,39 +35,6 @@ #define LINK_POLL_DELAY_US (50 * 1000) #define LINK_TIMEOUT_MS 2000 -#define RADIO_MAP_SIZE (16 << 20) - -struct xmm6260_radio_part { - size_t offset; - size_t length; -}; - -/* - * Components of the Samsung XMM6260 firmware - */ -enum xmm6260_image { - PSI, - EBL, - SECURE_IMAGE, - FIRMWARE, - NVDATA, -}; - -/* - * Bootloader control interface definitions - */ - -enum xmm6260_boot_cmd { - SetPortConf, - - ReqSecStart, - ReqSecEnd, - ReqForceHwReset, - - ReqFlashSetAddress, - ReqFlashWriteBlock, -}; - struct modemctl_io_data { int link_fd; int boot_fd; @@ -80,9 +42,6 @@ struct modemctl_io_data { int radio_fd; char *radio_data; struct stat radio_stat; - - struct xmm6260_radio_part *radio_parts; - int radio_parts_count; }; /* @@ -159,16 +118,6 @@ int modemctl_modem_power(struct ipc_client *client, int modemctl_modem_boot_power(struct ipc_client *client, struct modemctl_io_data *io_data, bool enabled); -/* - * @brief Calculate the checksum for the XMM6260 bootloader protocol - * - * @param data [in] the data to calculate the checksum for - * @param offset [in] number of bytes to skip - * @param length [in] length of data in bytes - * @return checksum value - */ -unsigned char calculateCRC(void* data, size_t offset, size_t length); - -#endif //__MODEMCTL_COMMON_H__ +#endif // vim:ts=4:sw=4:expandtab |