| #ifndef UPDATE_H |
| #define UPDATE_H |
| |
| #define _GNU_SOURCE |
| #include <stdio.h> |
| //#include <asprintf.h> |
| #include <stdlib.h> |
| #include <sys/types.h> |
| #include <sys/stat.h> |
| #include <fcntl.h> |
| #include <sys/reboot.h> |
| //#include "zxic_upgrade.h" |
| #include "zxic_log.h" |
| #include "fota_common.h" |
| |
| |
| |
| #define MAX_PATH 256 |
| |
| |
| |
| typedef enum { |
| ZTE_DUA_UNKNOWN = -1, //δ֪״̬ |
| ZTE_DUA_VERIFY_SUCCESS = 0, |
| ZTE_DUA_VERIFY_FAIL, |
| ZTE_DUA_SYSTEM_UPDATE_SUCCESS, |
| ZTE_DUA_SYSTEM_UPDATE_FAIL, |
| ZTE_DUA_RECOVERY_UPDATE_SUCCESS, |
| ZTE_DUA_RECOVERY_UPDATE_FAIL, |
| ZTE_DUA_NO_NEED_UPDATE, |
| ZTE_DUA_NEED_UPDATE |
| } ZTE_update_status_s_type; |
| |
| typedef struct { |
| int delta_file_desc; // delta file description |
| unsigned int delta_data_offset; // delta offset in file |
| unsigned int delta_file_size; // delta file size |
| unsigned int mtd_totalsize; // mtd device total size |
| unsigned int mtd_pageperblock; // mtd device page per block |
| unsigned int mtd_blocksize; // mtd device block size |
| unsigned int mtd_pagesize; // mtd device page size |
| unsigned int mtd_oobsize; // mtd device oob size |
| //unsigned char *bbm_buf; // bad block manager buf |
| int parti_file_desc; // partition update file description |
| //unsigned char * parti_update_buf; // partition update buf |
| //UPDATE_PROCESS_type process_callback; // update process callback |
| } update_info_t; |
| |
| |
| |
| |
| #ifdef _IS_MIN |
| |
| |
| #define upi_print(ModID,...) do { \ |
| printf(__VA_ARGS__); \ |
| } while(0) |
| |
| |
| #else |
| |
| #define upi_print(ModID,...) do { \ |
| printf(__VA_ARGS__); \ |
| char buffer_log[512] = {0}; \ |
| snprintf(buffer_log, 510, __VA_ARGS__); \ |
| upi_fwrite(ModID,buffer_log); \ |
| } while(0) |
| |
| |
| #endif |
| |
| |
| |
| #define upi_log(fmt, args...) \ |
| do {upi_print(FOTAUPI, "[%s][fota_upi] [%s-%d]: " fmt"\n", upi_get_time_us(),__FUNCTION__, __LINE__, ## args);} while (0) |
| #define upi_err(fmt, args...) \ |
| do {upi_print(FOTAUPI, "[%s][fota_upi] [%s-%d]: " fmt"\n", upi_get_time_us(),__FUNCTION__, __LINE__, ## args);} while (0) |
| #if 0 |
| #define lib_log(fmt, args...) \ |
| do {upi_print(FOTAUPI, "" fmt"\n", ## args);} while (0) |
| #endif |
| |
| #if 0 |
| static inline void* update_malloc(int size) |
| { |
| void *ptr = NULL; |
| ptr = malloc(size); |
| return ptr; |
| } |
| |
| static inline void update_free(void *ptr) |
| { |
| free(ptr); |
| } |
| |
| static inline void* update_realloc(void *ptr, int size) |
| { |
| return realloc(ptr, size); |
| } |
| #endif |
| #endif /*UPDATE_H*/ |