xflash_layout.h 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // XFLASH memory layout
  2. #pragma once
  3. #include <stdint.h>
  4. #include "bootapp.h"
  5. #include "config.h"
  6. #define XFLASH_SIZE 0x40000ul // size of XFLASH
  7. #define LANG_OFFSET 0x0 // offset for language data
  8. #ifndef XFLASH_DUMP
  9. #define LANG_SIZE XFLASH_SIZE
  10. #else
  11. #define DUMP_MAGIC 0x47555255ul
  12. struct dump_header_t
  13. {
  14. // start with a magic value to indicate the presence of a dump, so that clearing
  15. // a single page is sufficient for resetting the state
  16. uint32_t magic;
  17. uint8_t regs_present; // true when the lower segment containing registers is present
  18. uint8_t crash; // true if triggered by EMERGENCY_DUMP
  19. };
  20. struct dump_data_t
  21. {
  22. // contiguous region containing all addressable ranges
  23. uint8_t regs[RAMSTART];
  24. uint8_t sram[RAMSIZE];
  25. };
  26. struct dump_t
  27. {
  28. struct dump_header_t header;
  29. // data is page aligned (no real space waste, due to the larger
  30. // alignment required for the whole dump)
  31. struct dump_data_t __attribute__((aligned(256))) data;
  32. };
  33. // dump offset must be aligned to lower 4kb sector boundary
  34. #define DUMP_OFFSET ((XFLASH_SIZE - sizeof(dump_t)) & ~0xFFFul)
  35. #define DUMP_SIZE (XFLASH_SIZE - DUMP_OFFSET) // effective dump size area
  36. #define LANG_SIZE DUMP_OFFSET // available language space
  37. #endif