memory.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /* sd2snes - SD card based universal cartridge for the SNES
  2. Copyright (C) 2009-2010 Maximilian Rehkopf <otakon@gmx.net>
  3. AVR firmware portion
  4. Inspired by and based on code from sd2iec, written by Ingo Korb et al.
  5. See sdcard.c|h, config.h.
  6. FAT file system access based on code by ChaN, Jim Brain, Ingo Korb,
  7. see ff.c|h.
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; version 2 of the License only.
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. GNU General Public License for more details.
  15. You should have received a copy of the GNU General Public License
  16. along with this program; if not, write to the Free Software
  17. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  18. memory.h: RAM operations
  19. */
  20. #ifndef MEMORY_H
  21. #define MEMORY_H
  22. #include <arm/NXP/LPC17xx/LPC17xx.h>
  23. #include "smc.h"
  24. #define MASK_BITS (0x000000)
  25. #define SRAM_ROM_ADDR ((0x000000L) & ~MASK_BITS)
  26. #define SRAM_SAVE_ADDR ((0x600000L) & ~MASK_BITS)
  27. #define SRAM_MENU_ADDR ((0x500000L) & ~MASK_BITS)
  28. #define SRAM_DIR_ADDR ((0x510000L) & ~MASK_BITS)
  29. #define SRAM_DB_ADDR ((0x580000L) & ~MASK_BITS)
  30. #define SRAM_SPC_DATA_ADDR ((0x7D0000L) & ~MASK_BITS)
  31. #define SRAM_SPC_HEADER_ADDR ((0x7E0000L) & ~MASK_BITS)
  32. #define SRAM_MENU_SAVE_ADDR ((0x7F0000L) & ~MASK_BITS)
  33. #define SRAM_CMD_ADDR ((0x7F1000L) & ~MASK_BITS)
  34. #define SRAM_PARAM_ADDR ((0x7F1004L) & ~MASK_BITS)
  35. #define SRAM_STATUS_ADDR ((0x7F1100L) & ~MASK_BITS)
  36. #define SRAM_SYSINFO_ADDR ((0x7F1200L) & ~MASK_BITS)
  37. #define SRAM_LASTGAME_ADDR ((0x7F1420L) & ~MASK_BITS)
  38. #define SRAM_SCRATCHPAD ((0x7FFF00L) & ~MASK_BITS)
  39. #define SRAM_DIRID ((0x7FFFF0L) & ~MASK_BITS)
  40. #define SRAM_RELIABILITY_SCORE (0x100)
  41. #define LOADROM_WITH_SRAM (1)
  42. #define LOADROM_WITH_RESET (2)
  43. uint32_t load_rom(uint8_t* filename, uint32_t base_addr, uint8_t flags);
  44. uint32_t load_spc(uint8_t* filename, uint32_t spc_data_addr, uint32_t spc_header_addr);
  45. uint32_t load_sram(uint8_t* filename, uint32_t base_addr);
  46. uint32_t load_sram_offload(uint8_t* filename, uint32_t base_addr);
  47. uint32_t load_sram_rle(uint8_t* filename, uint32_t base_addr);
  48. uint32_t load_bootrle(uint32_t base_addr);
  49. void load_dspx(const uint8_t* filename, uint8_t st0010);
  50. void sram_hexdump(uint32_t addr, uint32_t len);
  51. uint8_t sram_readbyte(uint32_t addr);
  52. uint16_t sram_readshort(uint32_t addr);
  53. uint32_t sram_readlong(uint32_t addr);
  54. void sram_writebyte(uint8_t val, uint32_t addr);
  55. void sram_writeshort(uint16_t val, uint32_t addr);
  56. void sram_writelong(uint32_t val, uint32_t addr);
  57. void sram_readblock(void* buf, uint32_t addr, uint16_t size);
  58. void sram_readlongblock(uint32_t* buf, uint32_t addr, uint16_t count);
  59. void sram_writeblock(void* buf, uint32_t addr, uint16_t size);
  60. void save_sram(uint8_t* filename, uint32_t sram_size, uint32_t base_addr);
  61. uint32_t calc_sram_crc(uint32_t base_addr, uint32_t size);
  62. uint8_t sram_reliable(void);
  63. void sram_memset(uint32_t base_addr, uint32_t len, uint8_t val);
  64. uint64_t sram_gettime(uint32_t base_addr);
  65. #endif