Changeset 320 for soft/giet_vm/giet_drivers/xcu_driver.c
- Timestamp:
- Jun 10, 2014, 12:33:23 PM (10 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_drivers/xcu_driver.c
r295 r320 5 5 // Copyright (c) UPMC-LIP6 6 6 /////////////////////////////////////////////////////////////////////////////////// 7 7 // This peripheral is replicated in aall clusters containing processors. 8 // 9 // SEG_XCU_BASE and VSEG_CLUSTER_INCREMENT must be defined in hard_config.h file. 10 /////////////////////////////////////////////////////////////////////////////////// 11 12 #include <hard_config.h> 8 13 #include <giet_config.h> 9 14 #include <xcu_driver.h> … … 32 37 #endif 33 38 34 #if !defined( USE_XICU ) 35 # error: You must define USE_XICU in the hard_config.h file 39 #if !defined( USE_XCU ) 40 # error: You must define USE_XCU in the hard_config.h file 41 #endif 42 43 #if !defined( SEG_XCU_BASE ) 44 # error: You must define SEG_XCU_BASE in the hard_config.h file 45 #endif 46 47 #if !defined( VSEG_CLUSTER_INCREMENT ) 48 # error: You must define VSEG_CLUSTER_INCREMENT in the hard_config.h file 36 49 #endif 37 50 … … 47 60 unsigned int irq_type ) 48 61 { 49 #if USE_X ICU62 #if USE_XCU 50 63 // parameters checking 51 64 unsigned int x = cluster_xy >> Y_WIDTH; … … 55 68 if (channel >= (NB_PROCS_MAX * IRQ_PER_PROCESSOR)) _exit(); 56 69 57 volatile unsigned int* xcu_address = 58 (unsigned int *) ((unsigned int)&seg_xcu_base + 59 (cluster_xy * (unsigned int)&vseg_cluster_increment)); 70 unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE + 71 (cluster_xy * VSEG_CLUSTER_INCREMENT) ); 60 72 61 73 unsigned int func; 62 if (irq_type == IRQ_TYPE_PTI) func = X ICU_MSK_PTI_ENABLE;63 else if (irq_type == IRQ_TYPE_WTI) func = X ICU_MSK_WTI_ENABLE;64 else if (irq_type == IRQ_TYPE_HWI) func = X ICU_MSK_HWI_ENABLE;74 if (irq_type == IRQ_TYPE_PTI) func = XCU_MSK_PTI_ENABLE; 75 else if (irq_type == IRQ_TYPE_WTI) func = XCU_MSK_WTI_ENABLE; 76 else if (irq_type == IRQ_TYPE_HWI) func = XCU_MSK_HWI_ENABLE; 65 77 else 66 78 { … … 69 81 } 70 82 71 xcu_address[X ICU_REG(func,channel)] = value;72 73 #else 74 _printf("[GIET ERROR] _xcu_set_mask() should not be used if USE_X ICU not set\n");83 xcu_address[XCU_REG(func,channel)] = value; 84 85 #else 86 _printf("[GIET ERROR] _xcu_set_mask() should not be used if USE_XCU not set\n"); 75 87 _exit(); 76 88 #endif … … 90 102 unsigned int * irq_type ) 91 103 { 92 #if USE_X ICU104 #if USE_XCU 93 105 // parameters checking 94 106 unsigned int x = cluster_xy >> Y_WIDTH; … … 98 110 if (channel >= (NB_PROCS_MAX * IRQ_PER_PROCESSOR)) _exit(); 99 111 100 volatile unsigned int* xcu_address = 101 (unsigned int *) ((unsigned int)&seg_xcu_base + 102 (cluster_xy * (unsigned int)&vseg_cluster_increment)); 103 104 unsigned int prio = xcu_address[XICU_REG(XICU_PRIO,channel)]; 112 unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE + 113 (cluster_xy * VSEG_CLUSTER_INCREMENT) ); 114 115 unsigned int prio = xcu_address[XCU_REG(XCU_PRIO,channel)]; 105 116 unsigned int pti_ok = (prio & 0x00000001); 106 117 unsigned int hwi_ok = (prio & 0x00000002); … … 130 141 131 142 #else 132 _printf("[GIET ERROR] _xcu_get_index should not be used if USE_X ICU is not set\n");143 _printf("[GIET ERROR] _xcu_get_index should not be used if USE_XCU is not set\n"); 133 144 _exit(); 134 145 #endif … … 143 154 unsigned int wdata ) 144 155 { 145 #if USE_X ICU156 #if USE_XCU 146 157 // parameters checking 147 158 unsigned int x = cluster_xy >> Y_WIDTH; … … 151 162 if (wti_index >= 32) _exit(); 152 163 153 volatile unsigned int* xcu_address = 154 (unsigned int *) ((unsigned int)&seg_xcu_base + 155 (cluster_xy * (unsigned int)&vseg_cluster_increment)); 156 157 xcu_address[XICU_REG(XICU_WTI_REG,wti_index)] = wdata; 158 159 #else 160 _printf("[GIET ERROR] _xcu_send_ipi should not be used if USE_XICU is not set\n"); 164 unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE + 165 (cluster_xy * VSEG_CLUSTER_INCREMENT) ); 166 167 xcu_address[XCU_REG(XCU_WTI_REG,wti_index)] = wdata; 168 169 #else 170 _printf("[GIET ERROR] _xcu_send_ipi should not be used if USE_XCU is not set\n"); 161 171 _exit(); 162 172 #endif … … 173 183 unsigned int * value ) 174 184 { 175 #if USE_X ICU185 #if USE_XCU 176 186 // parameters checking 177 187 unsigned int x = cluster_xy >> Y_WIDTH; … … 181 191 if (wti_index >= 32) _exit(); 182 192 183 volatile unsigned int* xcu_address = 184 (unsigned int *) ((unsigned int)&seg_xcu_base + 185 (cluster_xy * (unsigned int)&vseg_cluster_increment)); 186 187 *value = xcu_address[XICU_REG(XICU_WTI_REG, wti_index)]; 188 189 #else 190 _printf("[GIET ERROR] in _xcu_get_wti_value() USE_XICU is not set\n"); 193 unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE + 194 (cluster_xy * VSEG_CLUSTER_INCREMENT) ); 195 196 *value = xcu_address[XCU_REG(XCU_WTI_REG, wti_index)]; 197 198 #else 199 _printf("[GIET ERROR] in _xcu_get_wti_value() USE_XCU is not set\n"); 191 200 _exit(); 192 201 #endif … … 203 212 unsigned int * address ) 204 213 { 205 #if USE_X ICU214 #if USE_XCU 206 215 if (wti_index >= 32) _exit(); 207 216 208 unsigned int xcu_address = (unsigned int) &seg_xcu_base;209 *address = xcu_address + (X ICU_REG(XICU_WTI_REG, wti_index)<<2);210 211 #else 212 _printf("[GIET ERROR] in _xcu_get_wti_address() USE_X ICU is not set\n");213 _exit(); 214 #endif 215 } 216 217 //////////////////////////////////////////////////////////////////////////////// 218 // This function activates a timer contained in X ICU by writing in the217 unsigned int xcu_address = (unsigned int)SEG_XCU_BASE; 218 *address = xcu_address + (XCU_REG(XCU_WTI_REG, wti_index)<<2); 219 220 #else 221 _printf("[GIET ERROR] in _xcu_get_wti_address() USE_XCU is not set\n"); 222 _exit(); 223 #endif 224 } 225 226 //////////////////////////////////////////////////////////////////////////////// 227 // This function activates a timer contained in XCU by writing in the 219 228 // proper register the period value. 220 229 //////////////////////////////////////////////////////////////////////////////// … … 223 232 unsigned int period ) 224 233 { 225 #if USE_X ICU234 #if USE_XCU 226 235 // parameters checking 227 236 unsigned int x = cluster_xy >> Y_WIDTH; … … 230 239 if (y >= Y_SIZE) _exit(); 231 240 232 volatile unsigned int* xcu_address = 233 (unsigned int *) ((unsigned int)&seg_xcu_base + 234 (cluster_xy * (unsigned int)&vseg_cluster_increment)); 235 236 xcu_address[XICU_REG(XICU_PTI_PER, pti_index)] = period; 237 238 #else 239 _printf("[GIET ERROR] in _xcu_timer_start() USE_XICU is not set\n"); 240 _exit(); 241 #endif 242 } 243 244 ////////////////////////////////////////////////////////////////////////////// 245 // This function desactivates a timer in XICU component 241 unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE + 242 (cluster_xy * VSEG_CLUSTER_INCREMENT) ); 243 244 xcu_address[XCU_REG(XCU_PTI_PER, pti_index)] = period; 245 246 #else 247 _printf("[GIET ERROR] in _xcu_timer_start() USE_XCU is not set\n"); 248 _exit(); 249 #endif 250 } 251 252 ////////////////////////////////////////////////////////////////////////////// 253 // This function desactivates a timer in XCU component 246 254 // by writing in the proper register. 247 255 ////////////////////////////////////////////////////////////////////////////// … … 249 257 unsigned int pti_index) 250 258 { 251 #if USE_X ICU259 #if USE_XCU 252 260 // parameters checking 253 261 unsigned int x = cluster_xy >> Y_WIDTH; … … 256 264 if (y >= Y_SIZE) _exit(); 257 265 258 volatile unsigned int * xcu_address = 259 (unsigned int *) ((unsigned int)&seg_xcu_base + 260 (cluster_xy * (unsigned int)&vseg_cluster_increment)); 261 262 xcu_address[XICU_REG(XICU_PTI_PER, pti_index)] = 0; 263 264 #else 265 _printf("[GIET ERROR] in _xcu_timer_stop() USE_XICU is not set\n"); 266 _exit(); 267 #endif 268 } 269 270 ////////////////////////////////////////////////////////////////////////////// 271 // This function acknowlegge a timer interrupt in XICU 272 // component by reading in the proper register. 266 unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE + 267 (cluster_xy * VSEG_CLUSTER_INCREMENT) ); 268 269 xcu_address[XCU_REG(XCU_PTI_PER, pti_index)] = 0; 270 271 #else 272 _printf("[GIET ERROR] in _xcu_timer_stop() USE_XCU is not set\n"); 273 _exit(); 274 #endif 275 } 276 277 ////////////////////////////////////////////////////////////////////////////// 278 // This function acknowlegge a timer interrupt in XCU 279 // component by reading in the proper XCU register. 273 280 // It can be used by both the isr_switch() for a "system" timer, 274 281 // or by the _isr_timer() for an "user" timer. 275 282 ////////////////////////////////////////////////////////////////////////////// 276 void_xcu_timer_reset_irq( unsigned int cluster_xy,277 unsigned int pti_index )278 { 279 #if USE_X ICU283 unsigned int _xcu_timer_reset_irq( unsigned int cluster_xy, 284 unsigned int pti_index ) 285 { 286 #if USE_XCU 280 287 // parameters checking 281 288 unsigned int x = cluster_xy >> Y_WIDTH; … … 284 291 if (y >= Y_SIZE) _exit(); 285 292 286 volatile unsigned int * xcu_address = 287 (unsigned int *) ((unsigned int)&seg_xcu_base + 288 (cluster_xy * (unsigned int)&vseg_cluster_increment)); 289 290 xcu_address[XICU_REG(XICU_PTI_ACK, pti_index)]; 291 292 #else 293 _printf("[GIET ERROR] in _xcu_timer_reset_irq() USE_XICU is not set\n"); 294 _exit(); 293 unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE + 294 (cluster_xy * VSEG_CLUSTER_INCREMENT) ); 295 296 // This return value is not used / avoid a compilation warning. 297 return xcu_address[XCU_REG(XCU_PTI_ACK, pti_index)]; 298 299 #else 300 _printf("[GIET ERROR] in _xcu_timer_reset_irq() USE_XCU is not set\n"); 301 _exit(); 302 return 0; 295 303 #endif 296 304 } … … 307 315 unsigned int pti_index ) 308 316 { 309 #if USE_X ICU317 #if USE_XCU 310 318 // parameters checking 311 319 unsigned int x = cluster_xy >> Y_WIDTH; … … 314 322 if (y >= Y_SIZE) _exit(); 315 323 316 volatile unsigned int * xcu_address = 317 (unsigned int *) ((unsigned int) &seg_xcu_base + 318 (cluster_xy * (unsigned int)&vseg_cluster_increment)); 319 320 unsigned int period = xcu_address[XICU_REG(XICU_PTI_PER, pti_index)]; 324 unsigned int* xcu_address = (unsigned int *) ( SEG_XCU_BASE + 325 (cluster_xy * VSEG_CLUSTER_INCREMENT) ); 326 327 unsigned int period = xcu_address[XCU_REG(XCU_PTI_PER, pti_index)]; 321 328 322 329 // we write 0 first because if the timer is currently running, 323 330 // the corresponding timer counter is not reset 324 xcu_address[X ICU_REG(XICU_PTI_PER, pti_index)] = 0;325 xcu_address[X ICU_REG(XICU_PTI_PER, pti_index)] = period;326 327 #else 328 _printf("[GIET ERROR] in _xcu_timer_reset_cpt() USE_X ICU is not set\n");331 xcu_address[XCU_REG(XCU_PTI_PER, pti_index)] = 0; 332 xcu_address[XCU_REG(XCU_PTI_PER, pti_index)] = period; 333 334 #else 335 _printf("[GIET ERROR] in _xcu_timer_reset_cpt() USE_XCU is not set\n"); 329 336 _exit(); 330 337 #endif
Note: See TracChangeset
for help on using the changeset viewer.