1 /*
2  * Copyright (C) 2015-2017 Alibaba Group Holding Limited
3  */
4 #ifndef NBPATCH_H
5 #define NBPATCH_H
6 #include "xz.h"
7 
8 #define NBPATCH_VERSION  "3.1.0"
9 
10 #define IN_BUF_MAX  1024
11 #define OUT_BUF_MAX 4096
12 
13 #define DIFF_DICT_SIZE (1 << 14)
14 #if defined __LINUX_HOST__
15 #define DIFF_BLOCK_SIZE  (0x400000)
16 #else
17 #define DIFF_BLOCK_SIZE  (0x40000)
18 #endif
19 typedef struct xzReadHandler {
20     unsigned char in_buf [IN_BUF_MAX];
21     size_t avail_size;
22     size_t read_pos;
23 } xzReadHandler;
24 
25 long xz_read(xzReadHandler *handler, struct xz_buf *b,struct xz_dec *s, unsigned long patch, unsigned char *buf, int len);
26 
27 int ota_nbpatch_main(void);
28 int ota_patch_show_percent(int per);
29 int ota_patch_read(unsigned long src, unsigned char *buffer, unsigned long pos, unsigned long size);
30 int ota_patch_write(unsigned long dst, unsigned char *buffer, unsigned long pos, unsigned long size);
31 int ota_patch_new_data(unsigned char *buf, long size);
32 int ota_load_new_data(unsigned long dst, long size);
33 unsigned short ota_patch_crc(void *addr, long len);
34 #endif /* NBPATCH_H_ */
35