yuezonghe | 824eb0c | 2024-06-27 02:32:26 -0700 | [diff] [blame^] | 1 | #ifndef UPDATE_H |
| 2 | #define UPDATE_H |
| 3 | |
| 4 | #define _GNU_SOURCE |
| 5 | #include <stdio.h> |
| 6 | //#include <asprintf.h> |
| 7 | #include <stdlib.h> |
| 8 | #include <sys/types.h> |
| 9 | #include <sys/stat.h> |
| 10 | #include <fcntl.h> |
| 11 | #include <sys/reboot.h> |
| 12 | //#include "zxic_upgrade.h" |
| 13 | #include "zxic_log.h" |
| 14 | #include "fota_common.h" |
| 15 | |
| 16 | |
| 17 | |
| 18 | #define MAX_PATH 256 |
| 19 | |
| 20 | |
| 21 | |
| 22 | typedef enum { |
| 23 | ZTE_DUA_UNKNOWN = -1, //δ֪״̬ |
| 24 | ZTE_DUA_VERIFY_SUCCESS = 0, |
| 25 | ZTE_DUA_VERIFY_FAIL, |
| 26 | ZTE_DUA_SYSTEM_UPDATE_SUCCESS, |
| 27 | ZTE_DUA_SYSTEM_UPDATE_FAIL, |
| 28 | ZTE_DUA_RECOVERY_UPDATE_SUCCESS, |
| 29 | ZTE_DUA_RECOVERY_UPDATE_FAIL, |
| 30 | ZTE_DUA_NO_NEED_UPDATE, |
| 31 | ZTE_DUA_NEED_UPDATE |
| 32 | } ZTE_update_status_s_type; |
| 33 | |
| 34 | typedef struct { |
| 35 | int delta_file_desc; // delta file description |
| 36 | unsigned int delta_data_offset; // delta offset in file |
| 37 | unsigned int delta_file_size; // delta file size |
| 38 | unsigned int mtd_totalsize; // mtd device total size |
| 39 | unsigned int mtd_pageperblock; // mtd device page per block |
| 40 | unsigned int mtd_blocksize; // mtd device block size |
| 41 | unsigned int mtd_pagesize; // mtd device page size |
| 42 | unsigned int mtd_oobsize; // mtd device oob size |
| 43 | //unsigned char *bbm_buf; // bad block manager buf |
| 44 | int parti_file_desc; // partition update file description |
| 45 | //unsigned char * parti_update_buf; // partition update buf |
| 46 | //UPDATE_PROCESS_type process_callback; // update process callback |
| 47 | } update_info_t; |
| 48 | |
| 49 | |
| 50 | |
| 51 | |
| 52 | #ifdef _IS_MIN |
| 53 | |
| 54 | |
| 55 | #define upi_print(ModID,...) do { \ |
| 56 | printf(__VA_ARGS__); \ |
| 57 | } while(0) |
| 58 | |
| 59 | |
| 60 | #else |
| 61 | |
| 62 | #define upi_print(ModID,...) do { \ |
| 63 | printf(__VA_ARGS__); \ |
| 64 | char buffer_log[512] = {0}; \ |
| 65 | snprintf(buffer_log, 510, __VA_ARGS__); \ |
| 66 | upi_fwrite(ModID,buffer_log); \ |
| 67 | } while(0) |
| 68 | |
| 69 | |
| 70 | #endif |
| 71 | |
| 72 | |
| 73 | |
| 74 | #define upi_log(fmt, args...) \ |
| 75 | do {upi_print(FOTAUPI, "[%s][fota_upi] [%s-%d]: " fmt"\n", upi_get_time_us(),__FUNCTION__, __LINE__, ## args);} while (0) |
| 76 | #define upi_err(fmt, args...) \ |
| 77 | do {upi_print(FOTAUPI, "[%s][fota_upi] [%s-%d]: " fmt"\n", upi_get_time_us(),__FUNCTION__, __LINE__, ## args);} while (0) |
| 78 | #if 0 |
| 79 | #define lib_log(fmt, args...) \ |
| 80 | do {upi_print(FOTAUPI, "" fmt"\n", ## args);} while (0) |
| 81 | #endif |
| 82 | |
| 83 | #if 0 |
| 84 | static inline void* update_malloc(int size) |
| 85 | { |
| 86 | void *ptr = NULL; |
| 87 | ptr = malloc(size); |
| 88 | return ptr; |
| 89 | } |
| 90 | |
| 91 | static inline void update_free(void *ptr) |
| 92 | { |
| 93 | free(ptr); |
| 94 | } |
| 95 | |
| 96 | static inline void* update_realloc(void *ptr, int size) |
| 97 | { |
| 98 | return realloc(ptr, size); |
| 99 | } |
| 100 | #endif |
| 101 | #endif /*UPDATE_H*/ |