spz.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. #pragma once
  2. #include "common.h"
  3. #include "fw.h"
  4. #include <zlib.h>
  5. struct spz_stream;
  6. typedef struct spz_stream spz_stream;
  7. #define SPZ_NBUF 4
  8. struct spz_stream {
  9. z_stream zs;
  10. read_func_t read_data; /* Read input data */
  11. token_t token; /* Read input token */
  12. uint8_t *optr; /* Output data pointer into obuf */
  13. /* Note: available output data ends at zs->next_out */
  14. union {
  15. uint8_t *bufs[SPZ_NBUF];
  16. struct {
  17. uint8_t *ibuf; /* Input buffer if compressed */
  18. uint8_t *obuf; /* Output buffer */
  19. uint8_t *dbuf; /* Block data buffer */
  20. uint8_t *vbuf; /* Readback/verify buffer */
  21. };
  22. };
  23. struct fw_header header; /* Header of currently processed chunk */
  24. struct fw_header vmatch; /* Matched firmware version string */
  25. int err; /* Error code to return */
  26. bool eoi; /* Reached end of input */
  27. bool cleanup; /* Call inflateEnd() */
  28. bool esp_updated; /* ESP OTA update performed */
  29. bool fpga_updated; /* FPGA initialization performed */
  30. };
  31. int spz_read_data(spz_stream *spz, void *buf, size_t len);