WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
upg_patch_info.h
浏览该文件的文档.
1/*
2 * Copyright (c) HiSilicon (Shanghai) Technologies Co., Ltd. 2022-2023. All rights reserved.
3 * @brief FOTA patch application library
4 */
5
6#ifndef UPG_PATCH_INFO_H
7#define UPG_PATCH_INFO_H
8
9#include <stdint.h>
10#include <stdbool.h>
11#include "errcode.h"
12#include "upg_patch.h"
13#include "LzmaDec.h"
14#include "upg_common_porting.h"
15
16#ifdef __cplusplus
17#if __cplusplus
18extern "C" {
19#endif
20#endif
21
22#define upg_compile_assert(expr) typedef char upg_comp_assert[(expr) ? 1 : 0]
23
24#define uapi_max(a, b) (((a) > (b)) ? (a) : (b))
25#define uapi_min(a, b) (((a) < (b)) ? (a) : (b))
26
27#define DECOMPRESSION_SIZE 1024
28
29#define PAGE_WRITE_PARTIAL_START (1<<1)
30#define PAGE_WRITE_STANDARD (1<<3)
31#define PAGE_WRITE_PARTIAL_END (1<<5)
32#define PAGE_WRITE_SIGNATURE_MASK 0xC0 /* Top 2 bits used for signature handling 1100 0000 */
33#define PAGE_WRITE_SIGNATURE_B 0x80 /* Signature page has been written to flash double buffer */
34#define PAGE_WRITE_SIGNATURE_W 0x40 /* Signature page has been written to flash image */
35
36#define HN_LZMA_SIZEOF_IMGSIZE 3
37
42
43typedef struct patch_state {
44 /* patch description */
46 /* patch contents moved into RAM */
47 /* Error code */
49 /* patch operating state */
50 ISzAlloc lzma_alloc;
51 uint8_t *local_buffer;
57
58#pragma pack(push, 4)
59typedef struct control_block {
60 uint32_t magic;
61 uint32_t copy;
62 uint32_t extra;
63 int32_t seek;
64} control_block_t; // or could use attribute__((__packed)) instead of this pragma pack stuff
65
66#pragma pack(pop)
68
69typedef struct zip_context {
70 /* The compression context */
71 CLzmaDec *dec;
72 /* an offset into the source (why the hell this isn't stored within the context is beyond me) */
73 int32_t offset;
74 /* the compressed data */
75 unsigned char *cdata;
78 size_t cdata_len;
80
81/* Code style related process_patch(...) recovery state */
86
87/* Code style related apply_patch(...) state */
100
101void write_image_block(patch_state_t *state, uint32_t size, int32_t location, const uint8_t *source);
103
104#ifdef __cplusplus
105#if __cplusplus
106}
107#endif
108#endif
109
110#endif /* UPG_PATCH_INFO_H */
111
uint32_t errcode_t
Definition of error code.
Definition errcode.h:30
Definition upg_patch_info.h:88
int32_t chunk_size
Definition upg_patch_info.h:98
int32_t cerror
Definition upg_patch_info.h:92
int32_t chunk_start
Definition upg_patch_info.h:97
control_block_t cb
Definition upg_patch_info.h:91
int32_t blockcount
Definition upg_patch_info.h:96
uint32_t lenread
Definition upg_patch_info.h:93
unsigned char * unpackedbuf
Definition upg_patch_info.h:90
int32_t oldpos
Definition upg_patch_info.h:94
zip_context_t * zcontext
Definition upg_patch_info.h:89
int32_t newpos
Definition upg_patch_info.h:95
Definition upg_patch_info.h:59
int32_t seek
Definition upg_patch_info.h:63
uint32_t extra
Definition upg_patch_info.h:62
uint32_t copy
Definition upg_patch_info.h:61
uint32_t magic
Definition upg_patch_info.h:60
Definition upg_patch_info.h:38
uint8_t page_buffer[UPG_FLASH_PAGE_SIZE]
Definition upg_patch_info.h:39
uint8_t page_status[(0x800000/UPG_FLASH_PAGE_SIZE)]
Definition upg_patch_info.h:40
Definition upg_patch.h:95
Definition upg_patch_info.h:43
errcode_t err_code
Definition upg_patch_info.h:48
bool done_skipping
Definition upg_patch_info.h:55
patch * desc
Definition upg_patch_info.h:45
int32_t page_last_written
Definition upg_patch_info.h:54
ISzAlloc lzma_alloc
Definition upg_patch_info.h:50
int32_t local_buffer_page
Definition upg_patch_info.h:52
int32_t page_first_written
Definition upg_patch_info.h:53
uint8_t * local_buffer
Definition upg_patch_info.h:51
Definition upg_patch_info.h:82
bool recovery_found
Definition upg_patch_info.h:84
uint8_t * recovery_buffer
Definition upg_patch_info.h:83
Definition upg_patch_info.h:69
int32_t offset
Definition upg_patch_info.h:73
CLzmaDec * dec
Definition upg_patch_info.h:71
unsigned char * cdata
Definition upg_patch_info.h:75
size_t unpacked_so_far
Definition upg_patch_info.h:77
size_t cdata_len
Definition upg_patch_info.h:78
size_t unpacked_len
Definition upg_patch_info.h:76
#define UPG_FLASH_PAGE_SIZE
Definition upg_common_porting.h:39
#define FLASH_PAGES
Definition upg_patch.h:23
struct control_block control_block_t
void write_image_block(patch_state_t *state, uint32_t size, int32_t location, const uint8_t *source)
Definition upg_patch.c:312
struct process_patch_state process_patch_state_t
struct zip_context zip_context_t
struct fota_buffers fota_buffers_t
struct apply_patch_state apply_patch_state_t
#define upg_compile_assert(expr)
Definition upg_patch_info.h:22
struct patch_state patch_state_t
void fota_patch_report_mem(void)