WS63 SDK 文档 7021f4f@fbb_ws63
ws63 和 ws63e 解决方案的 SDK 文档
载入中...
搜索中...
未找到
upg_patch.c 文件参考
#include <stdint.h>
#include <stddef.h>
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
#include "securec.h"
#include "common_def.h"
#include "upg_patch_info.h"
#include "upg_alloc.h"
#include "upg_debug.h"
#include "upg_porting.h"
#include "errcode.h"
#include "LzmaDec.h"
#include "upg_common_porting.h"
#include "upg_common.h"
#include "upg_config.h"
#include "upg_patch.h"
upg_patch.c 的引用(Include)关系图:

宏定义

#define Z_OK   SZ_OK
 
#define ZIP_STREAM_END   99
 
#define WORD_WIDTH   4
 
#define PATCH_KNVD_STR   "KNVD"
 
#define PATCH_KNVD_STR_LEN   4
 
#define PAGE_STATUS_BIT_SEARCH_START   1
 
#define PAGE_STATUS_BIT_SEARCH_END   5
 
#define PAGE_STATUS_BIT_SEARCH_INC   2
 

函数

STATIC void fota_patch_free (void *mem)
 
STATIC void * fota_patch_alloc (size_t size)
 
STATIC void * lzma_malloc (ISzAllocPtr p, size_t size)
 
STATIC void lzma_free (ISzAllocPtr p, void *address)
 
STATIC errcode_t fota_pkg_flash_read_image (patch *desc, uint32_t length, int32_t location, uint8_t *dest)
 
STATIC errcode_t fota_pkg_flash_prep_page_contents_for_write (patch *desc, uint32_t image_page_no, uint8_t *page_contents)
 
STATIC errcode_t fota_pkg_plaintext_flash_cache_init (patch *desc)
 
STATIC bool read_diff_data_from_ram (const uint8_t *addr, uint8_t *data, uint32_t length)
 
STATIC bool read_diff_data_to_ram (uint32_t offsets, uint8_t *data, uint32_t length, patch_state_t *state)
 
STATIC errcode_t zip_init_helper (zip_context_t *z, patch_state_t *state)
 
STATIC zip_context_tzip_init (patch_state_t *state)
 
STATIC int32_t zip_mem_read (patch_state_t *state, int32_t *error, zip_context_t *z, unsigned char *dest, int32_t len)
 
STATIC void zip_end (patch_state_t *state, zip_context_t *z)
 
STATIC void read_image_block (patch_state_t *state, uint32_t size, int32_t location, uint8_t *dest)
 
void write_image_block (patch_state_t *state, uint32_t size, int32_t location, const uint8_t *source)
 
STATIC bool fota_buffers_has_contents (patch_state_t *state)
 
STATIC void read_page_buffer (patch_state_t *state, uint8_t *dest)
 
STATIC void replace_page_buffer (patch_state_t *state, uint8_t *source)
 
STATIC uint8_t read_page_status (patch_state_t *state, int32_t page_no)
 
STATIC void write_page_status (patch_state_t *state, int32_t page_no, uint8_t val)
 
STATIC void erase_fota_buffers (patch_state_t *state)
 
STATIC void erase_image_flash_page (patch_state_t *state, int32_t image_page)
 
STATIC unsigned char page_write_type (const patch_state_t *state, int32_t first, int32_t last)
 
STATIC void write_flash_page_skip_done (patch_state_t *state)
 
STATIC void write_byte (patch_state_t *state, int32_t dest_offset, unsigned char val)
 
STATIC unsigned char read_byte (patch_state_t *state, int32_t dest_offset)
 
STATIC void finish_write (patch_state_t *state)
 
STATIC bool apply_patch_get_control_block_sanity_check (const apply_patch_state_t *aps, patch_state_t *state)
 Sanity check the diff after obtaining a control block.
 
STATIC bool apply_patch_get_control_block (apply_patch_state_t *aps, patch_state_t *state)
 Fetch the control block from the diff.
 
STATIC void apply_patch_delta_chunk_bottom_up (apply_patch_state_t *aps, patch_state_t *state)
 Apply a delta chunk for a bottom up patch
 
STATIC void apply_patch_delta_chunk_top_down (apply_patch_state_t *aps, patch_state_t *state)
 Apply a delta chunk for a top down patch
 
STATIC bool apply_patch_delta_chunk (apply_patch_state_t *aps, patch_state_t *state, int32_t *cctotal)
 Process the code deltas within the diff for a section of the image.
 
STATIC bool apply_patch_deltas (apply_patch_state_t *aps, patch_state_t *state)
 Process the code deltas within the diff for a section of code.
 
STATIC void apply_patch_extra_chunk_bottom_up (apply_patch_state_t *aps, patch_state_t *state)
 Apply an extra chunk for a bottom up patch
 
STATIC void apply_patch_extra_chunk_top_down (apply_patch_state_t *aps, patch_state_t *state)
 Apply an extra chunk for a top down patch
 
STATIC bool apply_patch_extra_chunk (apply_patch_state_t *aps, patch_state_t *state)
 Process the code extras within the diff for a section of code.
 
STATIC bool apply_patch_extras (apply_patch_state_t *aps, patch_state_t *state)
 Process the code extras within the diff for a section of code.
 
STATIC void apply_patch (patch_state_t *state)
 
STATIC void erase_redundant_pages (patch_state_t *state)
 
STATIC void process_patch_init (patch_state_t *state, patch *desc, process_patch_state_t *pps)
 
STATIC void process_patch_recover_page (patch_state_t *state, process_patch_state_t *pps, uint32_t page_no, int32_t page_status, int32_t status_bit)
 
STATIC void process_patch_check_page_buffer_recovery (patch_state_t *state, process_patch_state_t *pps)
 
STATIC void process_patch_perform_recovery (patch_state_t *state, process_patch_state_t *pps)
 
errcode_t process_patch (patch *desc)
 Process the patch provided.
 
STATIC void fota_pkg_task_code_diff_cleanup_actions (patch *patch_desc)
 
STATIC void init_patch_description_with_task_info (const upg_image_header_t *image, patch *patch_desc)
 
errcode_t fota_pkg_task_apply_code_diff (const upg_image_header_t *image)
 Apply a FOTA core task for an image.
 

宏定义说明

◆ PAGE_STATUS_BIT_SEARCH_END

#define PAGE_STATUS_BIT_SEARCH_END   5

◆ PAGE_STATUS_BIT_SEARCH_INC

#define PAGE_STATUS_BIT_SEARCH_INC   2

◆ PAGE_STATUS_BIT_SEARCH_START

#define PAGE_STATUS_BIT_SEARCH_START   1

◆ PATCH_KNVD_STR

#define PATCH_KNVD_STR   "KNVD"

◆ PATCH_KNVD_STR_LEN

#define PATCH_KNVD_STR_LEN   4

◆ WORD_WIDTH

#define WORD_WIDTH   4

◆ Z_OK

#define Z_OK   SZ_OK

◆ ZIP_STREAM_END

#define ZIP_STREAM_END   99

函数说明

◆ apply_patch()

STATIC void apply_patch ( patch_state_t state)

◆ apply_patch_delta_chunk()

STATIC bool apply_patch_delta_chunk ( apply_patch_state_t aps,
patch_state_t state,
int32_t *  cctotal 
)

Process the code deltas within the diff for a section of the image.

参数
apsapply_patch(...) function state.
statefota patching state.
返回
true if processing should be continue onto the next chunk or false if processing should stop.

◆ apply_patch_delta_chunk_bottom_up()

STATIC void apply_patch_delta_chunk_bottom_up ( apply_patch_state_t aps,
patch_state_t state 
)

Apply a delta chunk for a bottom up patch

参数
apsapply_patch(...) function state.
statefota patching state.

◆ apply_patch_delta_chunk_top_down()

STATIC void apply_patch_delta_chunk_top_down ( apply_patch_state_t aps,
patch_state_t state 
)

Apply a delta chunk for a top down patch

参数
apsapply_patch(...) function state.
statefota patching state.

◆ apply_patch_deltas()

STATIC bool apply_patch_deltas ( apply_patch_state_t aps,
patch_state_t state 
)

Process the code deltas within the diff for a section of code.

参数
apsapply_patch(...) function state.
statefota patching state.
返回
true if processing should be continued or false if processing should stop.

◆ apply_patch_extra_chunk()

STATIC bool apply_patch_extra_chunk ( apply_patch_state_t aps,
patch_state_t state 
)

Process the code extras within the diff for a section of code.

参数
apsapply_patch(...) function state.
statefota patching state.
返回
true if processing should be continued or false if processing should stop.

◆ apply_patch_extra_chunk_bottom_up()

STATIC void apply_patch_extra_chunk_bottom_up ( apply_patch_state_t aps,
patch_state_t state 
)

Apply an extra chunk for a bottom up patch

参数
apsapply_patch(...) function state.
statefota patching state.

◆ apply_patch_extra_chunk_top_down()

STATIC void apply_patch_extra_chunk_top_down ( apply_patch_state_t aps,
patch_state_t state 
)

Apply an extra chunk for a top down patch

参数
apsapply_patch(...) function state.
statefota patching state.

◆ apply_patch_extras()

STATIC bool apply_patch_extras ( apply_patch_state_t aps,
patch_state_t state 
)

Process the code extras within the diff for a section of code.

参数
apsapply_patch(...) function state.
statefota patching state.
返回
true if processing should be continued or false if processing should stop.

◆ apply_patch_get_control_block()

STATIC bool apply_patch_get_control_block ( apply_patch_state_t aps,
patch_state_t state 
)

Fetch the control block from the diff.

参数
apsapply_patch(...) function state.
statefota patching state.
返回
true if processing should proceed with this control block or false if processing should stop.

◆ apply_patch_get_control_block_sanity_check()

STATIC bool apply_patch_get_control_block_sanity_check ( const apply_patch_state_t aps,
patch_state_t state 
)

Sanity check the diff after obtaining a control block.

参数
apsapply_patch(...) function state.
statefota patching state.
返回
true if processing should proceed with this control block or false if processing should stop.

◆ erase_fota_buffers()

STATIC void erase_fota_buffers ( patch_state_t state)

◆ erase_image_flash_page()

STATIC void erase_image_flash_page ( patch_state_t state,
int32_t  image_page 
)

◆ erase_redundant_pages()

STATIC void erase_redundant_pages ( patch_state_t state)

◆ finish_write()

STATIC void finish_write ( patch_state_t state)

◆ fota_buffers_has_contents()

STATIC bool fota_buffers_has_contents ( patch_state_t state)

◆ fota_patch_alloc()

STATIC void * fota_patch_alloc ( size_t  size)

◆ fota_patch_free()

STATIC void fota_patch_free ( void *  mem)

◆ fota_pkg_flash_prep_page_contents_for_write()

STATIC errcode_t fota_pkg_flash_prep_page_contents_for_write ( patch desc,
uint32_t  image_page_no,
uint8_t *  page_contents 
)

◆ fota_pkg_flash_read_image()

STATIC errcode_t fota_pkg_flash_read_image ( patch desc,
uint32_t  length,
int32_t  location,
uint8_t *  dest 
)

◆ fota_pkg_plaintext_flash_cache_init()

STATIC errcode_t fota_pkg_plaintext_flash_cache_init ( patch desc)

◆ fota_pkg_task_apply_code_diff()

errcode_t fota_pkg_task_apply_code_diff ( const upg_image_header_t image)

Apply a FOTA core task for an image.

参数
taskThe FOTA code task header in SCPU RAM.
返回
errcode_t ERRCODE_SUCC or an error code.

◆ fota_pkg_task_code_diff_cleanup_actions()

STATIC void fota_pkg_task_code_diff_cleanup_actions ( patch patch_desc)

◆ init_patch_description_with_task_info()

STATIC void init_patch_description_with_task_info ( const upg_image_header_t image,
patch patch_desc 
)

◆ lzma_free()

STATIC void lzma_free ( ISzAllocPtr  p,
void *  address 
)

◆ lzma_malloc()

STATIC void * lzma_malloc ( ISzAllocPtr  p,
size_t  size 
)

◆ page_write_type()

STATIC unsigned char page_write_type ( const patch_state_t state,
int32_t  first,
int32_t  last 
)

◆ process_patch()

errcode_t process_patch ( patch desc)

Process the patch provided.

参数
descThe patch description to apply.
返回
errcode_t ERRCODE_SUCC or an error code.

◆ process_patch_check_page_buffer_recovery()

STATIC void process_patch_check_page_buffer_recovery ( patch_state_t state,
process_patch_state_t pps 
)

◆ process_patch_init()

STATIC void process_patch_init ( patch_state_t state,
patch desc,
process_patch_state_t pps 
)

◆ process_patch_perform_recovery()

STATIC void process_patch_perform_recovery ( patch_state_t state,
process_patch_state_t pps 
)

◆ process_patch_recover_page()

STATIC void process_patch_recover_page ( patch_state_t state,
process_patch_state_t pps,
uint32_t  page_no,
int32_t  page_status,
int32_t  status_bit 
)

◆ read_byte()

STATIC unsigned char read_byte ( patch_state_t state,
int32_t  dest_offset 
)

◆ read_diff_data_from_ram()

STATIC bool read_diff_data_from_ram ( const uint8_t *  addr,
uint8_t *  data,
uint32_t  length 
)

◆ read_diff_data_to_ram()

STATIC bool read_diff_data_to_ram ( uint32_t  offsets,
uint8_t *  data,
uint32_t  length,
patch_state_t state 
)

◆ read_image_block()

STATIC void read_image_block ( patch_state_t state,
uint32_t  size,
int32_t  location,
uint8_t *  dest 
)

◆ read_page_buffer()

STATIC void read_page_buffer ( patch_state_t state,
uint8_t *  dest 
)

◆ read_page_status()

STATIC uint8_t read_page_status ( patch_state_t state,
int32_t  page_no 
)

◆ replace_page_buffer()

STATIC void replace_page_buffer ( patch_state_t state,
uint8_t *  source 
)

◆ write_byte()

STATIC void write_byte ( patch_state_t state,
int32_t  dest_offset,
unsigned char  val 
)

◆ write_flash_page_skip_done()

STATIC void write_flash_page_skip_done ( patch_state_t state)

◆ write_image_block()

void write_image_block ( patch_state_t state,
uint32_t  size,
int32_t  location,
const uint8_t *  source 
)

◆ write_page_status()

STATIC void write_page_status ( patch_state_t state,
int32_t  page_no,
uint8_t  val 
)

◆ zip_end()

STATIC void zip_end ( patch_state_t state,
zip_context_t z 
)

◆ zip_init()

STATIC zip_context_t * zip_init ( patch_state_t state)

◆ zip_init_helper()

STATIC errcode_t zip_init_helper ( zip_context_t z,
patch_state_t state 
)

◆ zip_mem_read()

STATIC int32_t zip_mem_read ( patch_state_t state,
int32_t *  error,
zip_context_t z,
unsigned char *  dest,
int32_t  len 
)