xflash_layout.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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 0x55525547ul
  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. uint32_t pc; // PC nearby the crash location
  20. uint16_t sp; // SP nearby the crash location
  21. };
  22. struct dump_data_t
  23. {
  24. // contiguous region containing all addressable ranges
  25. uint8_t regs[RAMSTART];
  26. uint8_t sram[RAMSIZE];
  27. };
  28. struct dump_t
  29. {
  30. struct dump_header_t header;
  31. // data is page aligned (no real space waste, due to the larger
  32. // alignment required for the whole dump)
  33. struct dump_data_t __attribute__((aligned(256))) data;
  34. };
  35. // dump offset must be aligned to lower 4kb sector boundary
  36. #define DUMP_OFFSET ((XFLASH_SIZE - sizeof(dump_t)) & ~0xFFFul)
  37. #define DUMP_SIZE (XFLASH_SIZE - DUMP_OFFSET) // effective dump size area
  38. #define LANG_SIZE DUMP_OFFSET // available language space
  39. #endif