memimg.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. ** This file is part of fsusb_picdem
  3. **
  4. ** fsusb_picdem is free software; you can redistribute it and/or
  5. ** modify it under the terms of the GNU General Public License as
  6. ** published by the Free Software Foundation; either version 2 of the
  7. ** License, or (at your option) any later version.
  8. **
  9. ** fsusb_picdem is distributed in the hope that it will be useful, but
  10. ** WITHOUT ANY WARRANTY; without even the implied warranty of
  11. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. ** General Public License for more details.
  13. **
  14. ** You should have received a copy of the GNU General Public License
  15. ** along with fsusb_picdem; if not, write to the Free Software
  16. ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  17. ** 02110-1301, USA
  18. */
  19. #ifndef __MEMIMG_H__
  20. #define __MEMIMG_H__
  21. #include "rjlhex.h"
  22. /*
  23. * 18fx455
  24. *
  25. * EEPROM: 0x00 - 0xff (special, currently unsupported)
  26. *
  27. * Program memory: 0x0000 - 0x5fff
  28. *
  29. * ID: 0x200000 - 0x200007
  30. *
  31. * Config: 0x300000 - 0x30000d (byte-writable)
  32. *
  33. * Devid: 0x3ffffe - 0x3fffff (read-only)
  34. */
  35. /*
  36. * 18fx550 (default)
  37. *
  38. * EEPROM: 0x00 - 0xff (special, currently unsupported)
  39. *
  40. * Program memory: 0x0000 - 0x7fff
  41. *
  42. * ID: 0x200000 - 0x200007
  43. *
  44. * Config: 0x300000 - 0x30000d (byte-writable)
  45. *
  46. * Devid: 0x3ffffe - 0x3fffff (read-only)
  47. */
  48. #ifndef DEV_18FX455
  49. #define DEV_18FX550
  50. #endif /* DEV_18FX455 */
  51. #define MI_EEPROM_BASE 0x00
  52. #define MI_EEPROM_TOP 0xff
  53. #define MI_PROGRAM_BASE 0x0000
  54. #ifdef DEV_18FX455
  55. #define MI_PROGRAM_TOP 0x5fff
  56. #endif /* DEV_18FX455 */
  57. #ifdef DEV_18FX550
  58. #define MI_PROGRAM_TOP 0x7fff
  59. #endif /* DEV_18FX550 */
  60. #define MI_ID_BASE 0x200000
  61. #define MI_ID_TOP 0x200007
  62. #define MI_CONFIG_BASE 0x300000
  63. #define MI_CONFIG_TOP 0x30000d
  64. #define MI_DEVID_BASE 0x3ffffe
  65. #define MI_DEVID_TOP 0x3fffff
  66. typedef unsigned char mi_byte_t;
  67. typedef struct _mi_patch {
  68. unsigned long base;
  69. unsigned long top;
  70. mi_byte_t *contents;
  71. char *mask;
  72. } mi_patch;
  73. typedef struct _mi_image {
  74. mi_patch *program;
  75. mi_patch *id;
  76. mi_patch *config;
  77. mi_patch *devid;
  78. mi_patch *eeprom;
  79. } mi_image;
  80. mi_image *mi_load_hexfile(char *filename);
  81. #endif /* __MEMIMG_H__ */