xflash_layout.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // XFLASH memory layout
  2. #pragma once
  3. #include <stdint.h>
  4. #include "config.h"
  5. #define XFLASH_SIZE 0x40000ul // size of XFLASH
  6. #define SRAM_SIZE 0x2000u // size of SRAM
  7. #define SRAM_START 0x200u // start of SRAM
  8. #define LANG_OFFSET 0x0 // offset for language data
  9. #ifndef XFLASH_DUMP
  10. #define LANG_SIZE XFLASH_SIZE
  11. #else
  12. #define DUMP_MAGIC 0x47555255ul
  13. struct dump_header_t
  14. {
  15. // start with a magic value to indicate the presence of a dump, so that clearing
  16. // a single page is sufficient for resetting the state
  17. uint32_t magic;
  18. uint8_t regs_present; // true when the lower segment containing registers is present
  19. uint8_t crash; // true if triggered by EMERGENCY_DUMP
  20. };
  21. struct dump_data_t
  22. {
  23. // contiguous region containing all addressable ranges
  24. uint8_t regs[SRAM_START];
  25. uint8_t sram[SRAM_SIZE];
  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