transfer.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. #ifndef __M_TRANSFER_H
  2. #define __M_TRANSFER_H
  3. #define MAX_PARTITION_NAME_LEN 32
  4. #define ROUND_TO_PAGE(x,y) (((x) + (y)) & (~(y)))
  5. #define PARTITION_NAME_SIZE MAX_PARTITION_NAME_LEN
  6. #define MAX_EXT_SIG_LEN (2*1024*1024)
  7. #define STATUS_OK 0
  8. #define STATUS_INVALID_PARAMETERS (-100)
  9. #define STATUS_TOO_LARGE (-101)
  10. #define STATUS_USB_ERR (-102)
  11. #define STATUS_EMMC_ERR (-103)
  12. #define STATUS_NAND_ERR (-104)
  13. #define STATUS_THREAD (-105)
  14. #define STATUS_UNKNOWN_SPARSE_CHUNK_TYPE (-106)
  15. #define STATUS_SPARSE_INCOMPLETE (100)
  16. #define FAIL(code) (((status_t)(code)) < 0)
  17. typedef unsigned char uint8;
  18. typedef unsigned int uint32;
  19. typedef unsigned long long uint64;
  20. #define LOGI _dprintf
  21. #define LOGE _dprintf
  22. typedef struct partition_info_struct
  23. {
  24. uint8 name[PARTITION_NAME_SIZE];
  25. uint64 base_addr;
  26. uint64 max_size;
  27. int part_id;
  28. }partition_info_struct_t;
  29. typedef struct download_data_context {
  30. bool first_run;
  31. uint64 bytes_written;
  32. uint64 length_to_write;
  33. partition_info_struct_t *part_info;
  34. } download_data_context_t;
  35. static inline void init_download_data_context(download_data_context_t* data_ctx, uint64 data_length, partition_info_struct_t* part_info)
  36. {
  37. data_ctx->first_run = 1;
  38. data_ctx->bytes_written = 0;
  39. data_ctx->length_to_write = data_length;
  40. data_ctx->part_info = part_info;
  41. }
  42. status_t download_data(uint64 data_length, partition_info_struct_t* part_info);
  43. uint8* get_global_cache1();
  44. #endif