xflash_layout.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // XFLASH memory layout
  2. #pragma once
  3. #include <stdint.h>
  4. #include "bootapp.h" // for RAMSIZE
  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_reason; // uses values from dump_crash_source
  19. uint16_t sp; // SP closest to the crash location
  20. };
  21. struct dump_data_t
  22. {
  23. // contiguous region containing all addressable ranges
  24. uint8_t regs[RAMSTART];
  25. uint8_t sram[RAMSIZE];
  26. };
  27. struct dump_t
  28. {
  29. struct dump_header_t header;
  30. // data is page aligned (no real space waste, due to the larger
  31. // alignment required for the whole dump)
  32. struct dump_data_t __attribute__((aligned(256))) data;
  33. };
  34. // dump offset must be aligned to lower 4kb sector boundary
  35. #define DUMP_OFFSET ((XFLASH_SIZE - sizeof(dump_t)) & ~0xFFFul)
  36. #define DUMP_SIZE (XFLASH_SIZE - DUMP_OFFSET) // effective dump size area
  37. #define LANG_SIZE DUMP_OFFSET // available language space
  38. #endif