SCC_API.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. //
  2. // Copyright 2010 Intel Corporation
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. //
  16. // Project : bareMetal BIOS
  17. // File name : config.h
  18. // Author : mriepen
  19. // Date : 2008-06-24
  20. // Revision : 1.01
  21. //
  22. // Description : Header file for config.c
  23. //
  24. // Revision history:
  25. //
  26. // mri 1.01 2008-06-24
  27. // - Initial implementation
  28. //
  29. // ------------------------------------------------------------------------------------------------
  30. #ifndef __CONFIG_H__
  31. #define __CONFIG_H__
  32. // #########################################################################################
  33. // ____ _ _
  34. // / ___| _ _ _ __ ___ | |__ ___ | |___
  35. // \___ \| | | | '_ ` _ \| '_ \ / _ \| / __|
  36. // ___) | |_| | | | | | | |_) | (_) | \__ \
  37. // |____/ \__, |_| |_| |_|_.__/ \___/|_|___/
  38. // |___/
  39. //
  40. // #########################################################################################
  41. // Define start address of pagetable (PAGE_DIR_BASE should be equal to or above to STACK_TOP setting
  42. // in "../../bootcode/bootImage/defines.h" and needs to be 1025*4KB below the max private address)
  43. // and the number of available private slots... E.g.:
  44. // Private space for 2 cores on 1GB of memory (MCEMU single node): 0x00000000 to 0x29ffffffff (30 slots = 480MB)
  45. // Private space for 8 cores on 1GB of memory (MCEMU multi node): 0x00000000 to 0x05ffffffff ( 6 slots = 96MB)
  46. #define PRIV_SLOTS 6
  47. #define PAGE_DIR_BASE 0x04B00000
  48. // Symbols for MPB malloc
  49. #define MPBADDRBITS 13
  50. #define MPBSIZE (1<<MPBADDRBITS)
  51. #ifdef SHMADD
  52. // 64MB
  53. //#define SHMADDRBITS 26
  54. // 128MB
  55. //#define SHMADDRBITS 27
  56. // 256MB
  57. //#define SHMADDRBITS 28
  58. // 512MB
  59. #define SHMADDRBITS 29
  60. #define SHMSIZE (1<<SHMADDRBITS)
  61. // 960MB
  62. //#define SHMSIZE 0x3C000000
  63. #else
  64. #define SHMADDRBITS 26
  65. #define SHMSIZE (1<<SHMADDRBITS)
  66. #endif
  67. #define NUM_ROWS 4
  68. #define NUM_COLS 6
  69. #define NUM_CORES 2
  70. #define CRB_ADDR(x,y) (CRB_X0_Y0+(0x01000000*x)+(0x01000000*NUM_COLS*y))
  71. #define MPB_ADDR(x,y,z) (MPB_X0_Y0+(0x01000000*x)+(0x01000000*NUM_COLS*y)+(MPBSIZE*z))
  72. #define TID(x,y) ((y<<4)+x)
  73. #define X_TID(tid) (tid&0x0f)
  74. #define Y_TID(tid) (tid>>4)
  75. #define PID(x,y,core) ((NUM_CORES*NUM_COLS*y)+(NUM_CORES*x)+core)
  76. #define X_PID(pid) ((pid/NUM_CORES)-(NUM_COLS*Y_PID(pid)))
  77. #define Y_PID(pid) ((pid/NUM_CORES)/NUM_COLS)
  78. #define Z_PID(pid) (pid%NUM_CORES)
  79. // Symbols for shared memory
  80. #ifdef SHMADD
  81. #define SHM_X0_Y0 0x84000000
  82. #define SHM_X5_Y0 0x85000000
  83. #define SHM_X0_Y2 0x86000000
  84. #define SHM_X5_Y2 0x87000000
  85. #else
  86. #define SHM_X0_Y0 0x80000000
  87. #define SHM_X5_Y0 0x81000000
  88. #define SHM_X0_Y2 0x82000000
  89. #define SHM_X5_Y2 0x83000000
  90. #endif
  91. #define SHM_ADDR SHM_X0_Y0
  92. // Symbols for MPB addresses
  93. #define MPB_X0_Y0 0xc0000000
  94. #define MPB_X1_Y0 0xc1000000
  95. #define MPB_X2_Y0 0xc2000000
  96. #define MPB_X3_Y0 0xc3000000
  97. #define MPB_X4_Y0 0xc4000000
  98. #define MPB_X5_Y0 0xc5000000
  99. #define MPB_X0_Y1 0xc6000000
  100. #define MPB_X1_Y1 0xc7000000
  101. #define MPB_X2_Y1 0xc8000000
  102. #define MPB_X3_Y1 0xc9000000
  103. #define MPB_X4_Y1 0xca000000
  104. #define MPB_X5_Y1 0xcb000000
  105. #define MPB_X0_Y2 0xcc000000
  106. #define MPB_X1_Y2 0xcd000000
  107. #define MPB_X2_Y2 0xce000000
  108. #define MPB_X3_Y2 0xcf000000
  109. #define MPB_X4_Y2 0xd0000000
  110. #define MPB_X5_Y2 0xd1000000
  111. #define MPB_X0_Y3 0xd2000000
  112. #define MPB_X1_Y3 0xd3000000
  113. #define MPB_X2_Y3 0xd4000000
  114. #define MPB_X3_Y3 0xd5000000
  115. #define MPB_X4_Y3 0xd6000000
  116. #define MPB_X5_Y3 0xd7000000
  117. #define MPB_OWN 0xd8000000
  118. // Symbols for CRB addresses
  119. #define CRB_X0_Y0 0xe0000000
  120. #define CRB_X1_Y0 0xe1000000
  121. #define CRB_X2_Y0 0xe2000000
  122. #define CRB_X3_Y0 0xe3000000
  123. #define CRB_X4_Y0 0xe4000000
  124. #define CRB_X5_Y0 0xe5000000
  125. #define CRB_X0_Y1 0xe6000000
  126. #define CRB_X1_Y1 0xe7000000
  127. #define CRB_X2_Y1 0xe8000000
  128. #define CRB_X3_Y1 0xe9000000
  129. #define CRB_X4_Y1 0xea000000
  130. #define CRB_X5_Y1 0xeb000000
  131. #define CRB_X0_Y2 0xec000000
  132. #define CRB_X1_Y2 0xed000000
  133. #define CRB_X2_Y2 0xee000000
  134. #define CRB_X3_Y2 0xef000000
  135. #define CRB_X4_Y2 0xf0000000
  136. #define CRB_X5_Y2 0xf1000000
  137. #define CRB_X0_Y3 0xf2000000
  138. #define CRB_X1_Y3 0xf3000000
  139. #define CRB_X2_Y3 0xf4000000
  140. #define CRB_X3_Y3 0xf5000000
  141. #define CRB_X4_Y3 0xf6000000
  142. #define CRB_X5_Y3 0xf7000000
  143. #define CRB_OWN 0xf8000000
  144. // Symbol for RPC
  145. #define RPC_BASE 0xfb000000
  146. // Symbols for CRB sub-addresses
  147. #define GLCFG0 0x010
  148. #define GLCFG1 0x018
  149. #define L2CFG0 0x020
  150. #define L2CFG1 0x028
  151. #define SENSOR 0x040
  152. #define GCBCFG 0x080
  153. #define MYTILEID 0x100
  154. #define LOCK0 0x200
  155. #define LOCK1 0x400
  156. #define LUT0 0x00800
  157. #define LUT1 0x01000
  158. // Symbols for GLSTATn bit positions and ranges
  159. // of status values (Read only)
  160. #define GLSTAT_RANGE 26:13
  161. #define GLSTAT_XBP3_BIT 26
  162. #define GLSTAT_XBP2_BIT 25
  163. #define GLSTAT_XPM1_BIT 24
  164. #define GLSTAT_XPM0_BIT 23
  165. #define GLSTAT_XIERRNN_BIT 22
  166. #define GLSTAT_XFERRNN_BIT 21
  167. #define GLSTAT_XPRDY_BIT 20
  168. #define GLSTAT_XSMIACTNN_BIT 19
  169. #define GLSTAT_SHDWN_BIT 18
  170. #define GLSTAT_FLUACK_BIT 17
  171. #define GLSTAT_HALT_BIT 16
  172. #define GLSTAT_WRBACK_BIT 15
  173. #define GLSTAT_FLUSH_BIT 14
  174. #define GLSTAT_BRTRMSG_BIT 13
  175. // Symbols for GLCFGn bit positions and ranges
  176. // of configuration and IRQ values (Read-Write)
  177. #define GLCFG_RANGE 12:00
  178. #define GLCFG_XPICD_RANGE 12:11
  179. #define GLCFG_CPUTYP_BIT 10
  180. #define GLCFG_XA20MNN_BIT 09
  181. #define GLCFG_XSMINN _BIT 08
  182. #define GLCFG_XSTPCLKNN_BIT 06
  183. #define GLCFG_XRSNN_BIT 05
  184. #define GLCFG_XIGNNENN_BIT 04
  185. #define GLCFG_XFLSHNN_BIT 03
  186. #define GLCFG_XINIT_BIT 02
  187. #define GLCFG_XINTR_BIT 01
  188. #define GLCFG_XNMI_BIT 00
  189. // Sybols for L2CFGn bit positions and ranges
  190. #define L2CFG_RANGE 13:00
  191. #define L2CFG_STOPL2CCCLK_BIT 13
  192. #define L2CFG_STOPL2ARRAYCLK_BIT 12
  193. #define L2CFG_BLFLOATEN_BIT 11
  194. #define L2CFG_WLSLPEN_BIT 10
  195. #define L2CFG_WTSLPEN_BIT 09
  196. #define L2CFG_FLIPEN_BIT 08
  197. #define L2CFG_DATAECCEN_BIT 07
  198. #define L2CFG_TAGECCEN_BIT 06
  199. #define L2CFG_SLPBYPASS_BIT 05
  200. #define L2CFG_WAYDISABLE_BIT 04
  201. #define L2CFG_BBL2SLPPGM_RANGE 03:00
  202. // Sybols for SENSOR bit positions and ranges
  203. #define SENSOR_EN_BIT 13
  204. #define SENSOR_GATE_PULSE_CNT_RANGE 12:00
  205. // Sybols for GCBCFG bit positions and ranges
  206. #define GCBCFG_RXB_CLKRATIO_RANGE 25:19
  207. #define GCBCFG_TILE_CLKRATIO_RANGE 18:12
  208. #define GCBCFG_TILE_CLKDIV_RANGE 11:08
  209. #define GCBCFG_L2_1_SYNCRESETEN_BIT 07
  210. #define GCBCFG_L2_0_SYNCRESETEN_BIT 06
  211. #define GCBCFG_CORE1_SYNCRESETEN_BIT 05
  212. #define GCBCFG_CORE0_SYNCRESETEN_BIT 04
  213. #define GCBCFG_L2_1_RESET_BIT 03
  214. #define GCBCFG_L2_0_RESET_BIT 02
  215. #define GCBCFG_CORE1_RESET_BIT 01
  216. #define GCBCFG_CORE0_RESET_BIT 00
  217. // Tile-ID (Read Only bits)
  218. #define TID_XPOS_RANGE 10:07
  219. #define TID_YPOS_RANGE 06:03
  220. #define TID_SYS2MIFDESTID 02:00
  221. // Lock registers
  222. #define LOCK_BIT 00
  223. // MPB pointer type
  224. //typedef volatile unsigned char* t_vcharp;
  225. // #########################################################################################
  226. // _____ _ _
  227. // | ___| _ _ __ ___| |_(_) ___ _ __ ___
  228. // | |_ | | | | '_ \ / __| __| |/ _ \| '_ \/ __|
  229. // | _|| |_| | | | | (__| |_| | (_) | | | \__ \
  230. // |_| \__,_|_| |_|\___|\__|_|\___/|_| |_|___/
  231. //
  232. // #########################################################################################
  233. // InitAPI opens the RCKMEM device drivers. This routine needs to be invoked
  234. // once before using any other API functions! The successmessage can be disabled.
  235. //
  236. // Parameter: printMessages (0: No messages / 1: Messages enabled)
  237. // Return value: %
  238. //
  239. void InitAPI(int printMessages);
  240. // SetConfigBit writes a bit to a specified config register using read-modify-write. Only use
  241. // function to access memory locations that are not (!) performance critical (e.g. Tile-ID).
  242. // Use MallocConfigReg() function for performance critical memory locations!
  243. //
  244. // Parameter: ConfigAddr - Address of configuration register...
  245. // BitPos - Bit position within config register to set/reset
  246. // BitValue - Value to write to specified bit...
  247. //
  248. void SetConfigBit(unsigned int ConfigAddr, int BitPos, int BitValue);
  249. // SetConfigReg writes a value to a specified config register using a single write. Only use
  250. // function to access memory locations that are not (!) performance critical (e.g. Tile-ID).
  251. // Use MallocConfigReg() function for performance critical memory locations!
  252. //
  253. // Parameter: ConfigAddr - Address of configuration register...
  254. // RegValue - Value to write to specified register...
  255. //
  256. void SetConfigReg(unsigned int ConfigAddr, int RegValue);
  257. // ReadConfigReg reads a value from a specified config register using a single read. Only use
  258. // function to access memory locations that are not (!) performance critical (e.g. Tile-ID).
  259. // Use MallocConfigReg() function for performance critical memory locations!
  260. //
  261. // Parameter: ConfigAddr - Address of configuration register...
  262. // BitPos - Bit position within config register to set/reset
  263. // BitValue - Value to write to specified bit...
  264. //
  265. int ReadConfigReg(unsigned int ConfigAddr);
  266. // MallocConfigReg performs a memory map operation on ConfigAddr (physical address) and
  267. // returns a virtual address that can be used in the application. Use this function to
  268. // allocate memory locations that you access frequently!
  269. //
  270. // Parameter: ConfigAddr - Physical address of configuration register.
  271. //
  272. // Return value: ConfigRegVirtualAddr - Virtual address of configuration register.
  273. //
  274. int* MallocConfigReg(unsigned int ConfigAddr);
  275. // FreeConfigReg unmaps a memory location that has been mapped with the MallocConfigReg()
  276. // function...
  277. //
  278. // Parameter: ConfigRegVirtualAddr - Virtual address of configuration register.
  279. //
  280. void FreeConfigReg(int* ConfigRegVirtualAddr);
  281. // MPBalloc allocates MPBSIZE bytes of MessagePassing buffer Memory at MPB_ADDR(x,y,core).
  282. //
  283. // Parameter: MPB - Pointer to MPB area (return value, virtal address)
  284. // x,y,core - Position of tile (x,y) and core...
  285. //
  286. //#ifdef SCC
  287. void MPBalloc(t_vcharp *MPB, int x, int y, int core, int isOwnMPB);
  288. void SHMalloc(t_vcharp *SHM);
  289. //#endif
  290. // MPBunalloc unallocates an allocated MPB area.
  291. //
  292. // Parameter: MPB - Pointer to MPB area (virtual address)
  293. //
  294. void MPBunalloc(t_vcharp *MPB);
  295. void SHMunalloc(t_vcharp *SHM);
  296. #ifdef SHMADD_CACHEABLE
  297. int DCMflush();
  298. #endif
  299. #endif