Changeset 345 for soft/giet_vm/giet_drivers/xcu_driver.c
- Timestamp:
- Jun 25, 2014, 2:19:37 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_drivers/xcu_driver.c
r333 r345 16 16 #include <mapping_info.h> 17 17 #include <utils.h> 18 #include <io.h> 18 19 19 20 #if !defined(X_SIZE) … … 49 50 #endif 50 51 52 /////////////////////////////////////////////////////////////////////////////// 53 // This low level function returns the value contained in register "index" 54 // in the XCU component contained in cluster "cluster_xy" 55 /////////////////////////////////////////////////////////////////////////////// 56 static 57 unsigned int _xcu_get_register( unsigned int cluster_xy, // cluster index 58 unsigned int func, // function index 59 unsigned int index ) // register index 60 { 61 unsigned int vaddr = 62 SEG_XCU_BASE + 63 (cluster_xy * PERI_CLUSTER_INCREMENT) + 64 (XCU_REG(func, index) << 2); 65 66 return ioread32( (void*)vaddr ); 67 } 68 69 /////////////////////////////////////////////////////////////////////////////// 70 // This low level function sets a new value in register "index" 71 // in the XCU component contained in cluster "cluster_xy" 72 /////////////////////////////////////////////////////////////////////////////// 73 static 74 void _xcu_set_register( unsigned int cluster_xy, // cluster index 75 unsigned int func, // func index 76 unsigned int index, // register index 77 unsigned int value ) // value to be written 78 { 79 unsigned int vaddr = 80 SEG_XCU_BASE + 81 (cluster_xy * PERI_CLUSTER_INCREMENT) + 82 (XCU_REG(func, index) << 2); 83 84 iowrite32( (void*)vaddr, value ); 85 } 51 86 52 87 //////////////////////////////////////////////////////////////////////////////// … … 68 103 if (channel >= (NB_PROCS_MAX * IRQ_PER_PROCESSOR)) _exit(); 69 104 70 unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE + 71 (cluster_xy * PERI_CLUSTER_INCREMENT) ); 72 73 unsigned int func; 105 unsigned int func = 0; 74 106 if (irq_type == IRQ_TYPE_PTI) func = XCU_MSK_PTI_ENABLE; 75 107 else if (irq_type == IRQ_TYPE_WTI) func = XCU_MSK_WTI_ENABLE; … … 81 113 } 82 114 83 xcu_address[XCU_REG(func,channel)] = value;115 _xcu_set_register(cluster_xy, func, channel, value); 84 116 85 117 #else … … 110 142 if (channel >= (NB_PROCS_MAX * IRQ_PER_PROCESSOR)) _exit(); 111 143 112 unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE + 113 (cluster_xy * PERI_CLUSTER_INCREMENT) ); 114 115 unsigned int prio = xcu_address[XCU_REG(XCU_PRIO,channel)]; 144 unsigned int prio = _xcu_get_register(cluster_xy, XCU_PRIO, channel); 116 145 unsigned int pti_ok = (prio & 0x00000001); 117 146 unsigned int hwi_ok = (prio & 0x00000002); … … 162 191 if (wti_index >= 32) _exit(); 163 192 164 unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE + 165 (cluster_xy * PERI_CLUSTER_INCREMENT) ); 166 167 xcu_address[XCU_REG(XCU_WTI_REG,wti_index)] = wdata; 193 _xcu_set_register(cluster_xy, XCU_WTI_REG, wti_index, wdata); 168 194 169 195 #else … … 191 217 if (wti_index >= 32) _exit(); 192 218 193 unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE + 194 (cluster_xy * PERI_CLUSTER_INCREMENT) ); 195 196 *value = xcu_address[XCU_REG(XCU_WTI_REG, wti_index)]; 219 *value = _xcu_get_register(cluster_xy, XCU_WTI_REG, wti_index); 197 220 198 221 #else … … 215 238 if (wti_index >= 32) _exit(); 216 239 217 unsigned int xcu_address = (unsigned int)SEG_XCU_BASE; 218 *address = xcu_address + (XCU_REG(XCU_WTI_REG, wti_index)<<2); 240 *address = SEG_XCU_BASE + (XCU_REG(XCU_WTI_REG, wti_index)<<2); 219 241 220 242 #else … … 239 261 if (y >= Y_SIZE) _exit(); 240 262 241 unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE + 242 (cluster_xy * PERI_CLUSTER_INCREMENT) ); 243 244 xcu_address[XCU_REG(XCU_PTI_PER, pti_index)] = period; 263 _xcu_set_register(cluster_xy, XCU_PTI_PER, pti_index, period); 245 264 246 265 #else … … 264 283 if (y >= Y_SIZE) _exit(); 265 284 266 unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE + 267 (cluster_xy * PERI_CLUSTER_INCREMENT) ); 268 269 xcu_address[XCU_REG(XCU_PTI_PER, pti_index)] = 0; 285 _xcu_set_register(cluster_xy, XCU_PTI_PER, pti_index, 0); 270 286 271 287 #else … … 291 307 if (y >= Y_SIZE) _exit(); 292 308 293 unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE +294 (cluster_xy * PERI_CLUSTER_INCREMENT) );295 296 309 // This return value is not used / avoid a compilation warning. 297 return xcu_address[XCU_REG(XCU_PTI_ACK, pti_index)];310 return _xcu_get_register(cluster_xy, XCU_PTI_ACK, pti_index); 298 311 299 312 #else … … 322 335 if (y >= Y_SIZE) _exit(); 323 336 324 unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE + 325 (cluster_xy * PERI_CLUSTER_INCREMENT) ); 326 327 unsigned int period = xcu_address[XCU_REG(XCU_PTI_PER, pti_index)]; 337 unsigned int per = _xcu_get_register(cluster_xy, XCU_PTI_PER, pti_index); 328 338 329 339 // we write 0 first because if the timer is currently running, 330 340 // the corresponding timer counter is not reset 331 xcu_address[XCU_REG(XCU_PTI_PER, pti_index)] = 0;332 xcu_address[XCU_REG(XCU_PTI_PER, pti_index)] = period;341 _xcu_set_register(cluster_xy, XCU_PTI_PER, pti_index, 0); 342 _xcu_set_register(cluster_xy, XCU_PTI_PER, pti_index, per); 333 343 334 344 #else
Note: See TracChangeset
for help on using the changeset viewer.