2
0

spz.h 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  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. int err; /* Error code to return */
  25. bool eoi; /* Reached end of input */
  26. bool cleanup; /* Call inflateEnd() */
  27. bool esp_updated; /* ESP OTA update performed */
  28. bool fpga_updated; /* FPGA initialization performed */
  29. };
  30. int spz_read_data(spz_stream *spz, void *buf, size_t len);