memory.h 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /* Memory.h - Memory mappings and remapping functions declarations */
  2. /* Copyright - Galileo technology. */
  3. #ifndef __INCmemoryh
  4. #define __INCmemoryh
  5. /* includes */
  6. #include "core.h"
  7. /* defines */
  8. #define DONT_MODIFY 0xffffffff
  9. #define PARITY_SUPPORT 0x40000000
  10. #define MINIMUM_MEM_BANK_SIZE 0x10000
  11. #define MINIMUM_DEVICE_WINDOW_SIZE 0x10000
  12. #define MINIMUM_PCI_WINDOW_SIZE 0x10000
  13. #define MINIMUM_ACCESS_WIN_SIZE 0x10000
  14. #define _8BIT 0x00000000
  15. #define _16BIT 0x00100000
  16. #define _32BIT 0x00200000
  17. #define _64BIT 0x00300000
  18. /* typedefs */
  19. typedef struct deviceParam
  20. { /* boundary values */
  21. unsigned int turnOff; /* 0x0 - 0xf */
  22. unsigned int acc2First; /* 0x0 - 0x1f */
  23. unsigned int acc2Next; /* 0x0 - 0x1f */
  24. unsigned int ale2Wr; /* 0x0 - 0xf */
  25. unsigned int wrLow; /* 0x0 - 0xf */
  26. unsigned int wrHigh; /* 0x0 - 0xf */
  27. unsigned int badrSkew; /* 0x0 - 0x2 */
  28. unsigned int DPEn; /* 0x0 - 0x1 */
  29. unsigned int deviceWidth; /* in Bytes */
  30. } DEVICE_PARAM;
  31. typedef enum __memBank{BANK0,BANK1,BANK2,BANK3} MEMORY_BANK;
  32. typedef enum __memDevice{DEVICE0,DEVICE1,DEVICE2,DEVICE3,BOOT_DEVICE} DEVICE;
  33. /*typedef enum __memoryProtectRegion{MEM_REGION0,MEM_REGION1,MEM_REGION2, \
  34. MEM_REGION3,MEM_REGION4,MEM_REGION5, \
  35. MEM_REGION6,MEM_REGION7} \
  36. MEMORY_PROTECT_REGION;*/
  37. /* There are four possible windows that can be defined as protected */
  38. typedef enum _memoryProtectWindow{MEM_WINDOW0,MEM_WINDOW1,MEM_WINDOW2,
  39. MEM_WINDOW3
  40. } MEMORY_PROTECT_WINDOW;
  41. /* When defining a protected window , this paramter indicates whether it
  42. is accessible or not */
  43. typedef enum __memoryAccess{MEM_ACCESS_ALLOWED,MEM_ACCESS_FORBIDEN} \
  44. MEMORY_ACCESS;
  45. typedef enum __memoryWrite{MEM_WRITE_ALLOWED,MEM_WRITE_FORBIDEN} \
  46. MEMORY_ACCESS_WRITE;
  47. typedef enum __memoryCacheProtect{MEM_CACHE_ALLOWED,MEM_CACHE_FORBIDEN} \
  48. MEMORY_CACHE_PROTECT;
  49. typedef enum __memorySnoopType{MEM_NO_SNOOP,MEM_SNOOP_WT,MEM_SNOOP_WB} \
  50. MEMORY_SNOOP_TYPE;
  51. typedef enum __memorySnoopRegion{MEM_SNOOP_REGION0,MEM_SNOOP_REGION1, \
  52. MEM_SNOOP_REGION2,MEM_SNOOP_REGION3} \
  53. MEMORY_SNOOP_REGION;
  54. /* There are 21 memory windows dedicated for the varios interfaces (PCI,
  55. devCS (devices), CS(DDR), interenal registers and SRAM) used by the CPU's
  56. address decoding mechanism. */
  57. typedef enum _memoryWindow {CS_0_WINDOW = BIT0, CS_1_WINDOW = BIT1,
  58. CS_2_WINDOW = BIT2, CS_3_WINDOW = BIT3,
  59. DEVCS_0_WINDOW = BIT4, DEVCS_1_WINDOW = BIT5,
  60. DEVCS_2_WINDOW = BIT6, DEVCS_3_WINDOW = BIT7,
  61. BOOT_CS_WINDOW = BIT8, PCI_0_IO_WINDOW = BIT9,
  62. PCI_0_MEM0_WINDOW = BIT10,
  63. PCI_0_MEM1_WINDOW = BIT11,
  64. PCI_0_MEM2_WINDOW = BIT12,
  65. PCI_0_MEM3_WINDOW = BIT13, PCI_1_IO_WINDOW = BIT14,
  66. PCI_1_MEM0_WINDOW = BIT15, PCI_1_MEM1_WINDOW =BIT16,
  67. PCI_1_MEM2_WINDOW = BIT17, PCI_1_MEM3_WINDOW =BIT18,
  68. INTEGRATED_SRAM_WINDOW = BIT19,
  69. INTERNAL_SPACE_WINDOW = BIT20,
  70. ALL_WINDOWS = 0X1FFFFF
  71. } MEMORY_WINDOW;
  72. typedef enum _memoryWindowStatus {MEM_WINDOW_ENABLED,MEM_WINDOW_DISABLED
  73. } MEMORY_WINDOW_STATUS;
  74. typedef enum _pciMemWindow{PCI_0_IO,PCI_0_MEM0,PCI_0_MEM1,PCI_0_MEM2,PCI_0_MEM3
  75. #ifdef INCLUDE_PCI_1
  76. ,PCI_1_IO,PCI_1_MEM0,PCI_1_MEM1,PCI_1_MEM2,PCI_1_MEM3
  77. #endif /* INCLUDE_PCI_1 */
  78. } PCI_MEM_WINDOW;
  79. /* -------------------------------------------------------------------------------------------------*/
  80. /* functions */
  81. unsigned int memoryGetBankBaseAddress(MEMORY_BANK bank);
  82. unsigned int memoryGetDeviceBaseAddress(DEVICE device);
  83. /* New at MV6436x */
  84. unsigned int MemoryGetPciBaseAddr(PCI_MEM_WINDOW pciWindow);
  85. unsigned int memoryGetBankSize(MEMORY_BANK bank);
  86. unsigned int memoryGetDeviceSize(DEVICE device);
  87. unsigned int memoryGetDeviceWidth(DEVICE device);
  88. /* New at MV6436x */
  89. unsigned int gtMemoryGetPciWindowSize(PCI_MEM_WINDOW pciWindow);
  90. /* when given base Address and size Set new WINDOW for SCS_X. (X = 0,1,2 or 3*/
  91. bool memoryMapBank(MEMORY_BANK bank, unsigned int bankBase,unsigned int bankLength);
  92. /* Set a new base and size for one of the memory banks (CS0 - CS3) */
  93. bool gtMemorySetMemoryBank(MEMORY_BANK bank, unsigned int bankBase,
  94. unsigned int bankSize);
  95. bool memoryMapDeviceSpace(DEVICE device, unsigned int deviceBase,unsigned int deviceLength);
  96. /* Change the Internal Register Base Address to a new given Address. */
  97. bool memoryMapInternalRegistersSpace(unsigned int internalRegBase);
  98. /* returns internal Register Space Base Address. */
  99. unsigned int memoryGetInternalRegistersSpace(void);
  100. /* Returns the integrated SRAM Base Address. */
  101. unsigned int memoryGetInternalSramBaseAddr(void);
  102. /* -------------------------------------------------------------------------------------------------*/
  103. /* Set new base address for the integrated SRAM. */
  104. void memorySetInternalSramBaseAddr(unsigned int sramBaseAddress);
  105. /* -------------------------------------------------------------------------------------------------*/
  106. /* Delete a protection feature to a given space. */
  107. void memoryDisableProtectRegion(MEMORY_PROTECT_WINDOW window);
  108. /* -------------------------------------------------------------------------------------------------*/
  109. /* Writes a new remap value to the remap register */
  110. unsigned int memorySetPciRemapValue(PCI_MEM_WINDOW memoryWindow,
  111. unsigned int remapValueHigh,
  112. unsigned int remapValueLow);
  113. /* -------------------------------------------------------------------------------------------------*/
  114. /* Configurate the protection feature to a given space. */
  115. bool memorySetProtectRegion(MEMORY_PROTECT_WINDOW window,
  116. MEMORY_ACCESS gtMemoryAccess,
  117. MEMORY_ACCESS_WRITE gtMemoryWrite,
  118. MEMORY_CACHE_PROTECT cacheProtection,
  119. unsigned int baseAddress,
  120. unsigned int size);
  121. /* Configurate the protection feature to a given space. */
  122. /*bool memorySetProtectRegion(MEMORY_PROTECT_REGION region,
  123. MEMORY_ACCESS memoryAccess,
  124. MEMORY_ACCESS_WRITE memoryWrite,
  125. MEMORY_CACHE_PROTECT cacheProtection,
  126. unsigned int baseAddress,
  127. unsigned int regionLength); */
  128. /* Configurate the snoop feature to a given space. */
  129. bool memorySetRegionSnoopMode(MEMORY_SNOOP_REGION region,
  130. MEMORY_SNOOP_TYPE snoopType,
  131. unsigned int baseAddress,
  132. unsigned int regionLength);
  133. bool memoryRemapAddress(unsigned int remapReg, unsigned int remapValue);
  134. bool memoryGetDeviceParam(DEVICE_PARAM *deviceParam, DEVICE deviceNum);
  135. bool memorySetDeviceParam(DEVICE_PARAM *deviceParam, DEVICE deviceNum);
  136. /* Set a new base and size for one of the PCI windows. */
  137. bool memorySetPciWindow(PCI_MEM_WINDOW pciWindow, unsigned int pciWindowBase,
  138. unsigned int pciWindowSize);
  139. /* Disable or enable one of the 21 windows dedicated for the CPU's
  140. address decoding mechanism */
  141. void MemoryDisableWindow(MEMORY_WINDOW window);
  142. void MemoryEnableWindow (MEMORY_WINDOW window);
  143. MEMORY_WINDOW_STATUS MemoryGetMemWindowStatus(MEMORY_WINDOW window);
  144. #endif /* __INCmemoryh */