Changeset 263 for soft/giet_vm/giet_drivers/xcu_driver.c
- Timestamp:
- Dec 19, 2013, 9:36:48 AM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
soft/giet_vm/giet_drivers/xcu_driver.c
r258 r263 16 16 // The virtual base address of the segment associated to the component is: 17 17 // 18 // seg_xcu_base + cluster_ id* vseg_cluster_increment18 // seg_xcu_base + cluster_xy * vseg_cluster_increment 19 19 // 20 20 // The seg_xcu_base and vseg_cluster_increment values must be defined … … 24 24 #include <giet_config.h> 25 25 #include <xcu_driver.h> 26 #include <tty_driver.h> 27 #include <mapping_info.h> 26 28 #include <utils.h> 27 29 28 #if !defined(NB_CLUSTERS) 29 # error: You must define NB_CLUSTERS in the hard_config.h file 30 #endif 31 32 #if (NB_CLUSTERS > 256) 33 # error: NB_CLUSTERS cannot be larger than 256! 30 #if !defined(X_SIZE) 31 # error: You must define X_SIZE in the hard_config.h file 32 #endif 33 34 #if !defined(Y_SIZE) 35 # error: You must define X_SIZE in the hard_config.h file 36 #endif 37 38 #if !defined(X_WIDTH) 39 # error: You must define X_WIDTH in the hard_config.h file 40 #endif 41 42 #if !defined(Y_WIDTH) 43 # error: You must define X_WIDTH in the hard_config.h file 34 44 #endif 35 45 36 46 #if !defined(NB_PROCS_MAX) 37 47 # error: You must define NB_PROCS_MAX in the hard_config.h file 38 #endif39 40 #if (NB_PROCS_MAX > 8)41 # error: NB_PROCS_MAX cannot be larger than 8!42 48 #endif 43 49 … … 53 59 // Returns 0 if success, > 0 if error. 54 60 //////////////////////////////////////////////////////////////////////////////// 55 unsigned int _xcu_set_mask( unsigned int cluster_id, unsigned int proc_id, 61 unsigned int _xcu_set_mask( unsigned int cluster_xy, 62 unsigned int proc_id, 56 63 unsigned int value, 57 unsigned int is_PTI) 58 { 59 // parameters checking 60 if (cluster_id >= NB_CLUSTERS) return 1; 61 if (proc_id >= NB_PROCS_MAX) return 1; 64 unsigned int irq_type ) 65 { 66 // parameters checking 67 unsigned int x = cluster_xy >> Y_WIDTH; 68 unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); 69 if (x >= X_SIZE) return 1; 70 if (y >= Y_SIZE) return 1; 71 if (proc_id >= NB_PROCS_MAX) return 1; 62 72 63 73 #if USE_XICU 64 74 unsigned int* xcu_address = (unsigned int *) ((unsigned int)&seg_xcu_base + 65 (cluster_id * (unsigned int)&vseg_cluster_increment)); 66 if (is_PTI) 67 xcu_address[XICU_REG(XICU_MSK_PTI_ENABLE, proc_id)] = value; 68 else 69 xcu_address[XICU_REG(XICU_MSK_HWI_ENABLE, proc_id)] = value; 75 (cluster_xy * (unsigned int)&vseg_cluster_increment)); 76 unsigned int func; 77 if (irq_type == IRQ_TYPE_PTI) func = XICU_MSK_PTI_ENABLE; 78 else if (irq_type == IRQ_TYPE_SWI) func = XICU_MSK_WTI_ENABLE; 79 else func = XICU_MSK_HWI_ENABLE; 80 xcu_address[XICU_REG(func,proc_id)] = value; 70 81 return 0; 71 82 #else … … 86 97 // Returns 0 if success, > 0 if error. 87 98 //////////////////////////////////////////////////////////////////////////////// 88 unsigned int _xcu_get_index( unsigned int cluster_ id,99 unsigned int _xcu_get_index( unsigned int cluster_xy, 89 100 unsigned int proc_id, 90 101 unsigned int * buffer) 91 102 { 92 103 // parameters checking 93 if (cluster_id >= NB_CLUSTERS) return 1; 94 if (proc_id >= NB_PROCS_MAX) return 1; 104 unsigned int x = cluster_xy >> Y_WIDTH; 105 unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); 106 if (x >= X_SIZE) return 1; 107 if (y >= Y_SIZE) return 1; 108 if (proc_id >= NB_PROCS_MAX) return 1; 95 109 96 110 #if USE_XICU 97 111 unsigned int* xcu_address = (unsigned int *) ((unsigned int)&seg_xcu_base + 98 (cluster_ id* (unsigned int)&vseg_cluster_increment));112 (cluster_xy * (unsigned int)&vseg_cluster_increment)); 99 113 100 114 unsigned int prio = xcu_address[XICU_REG(XICU_PRIO, proc_id)]; … … 125 139 // Returns 0 if success, > 0 if error. 126 140 //////////////////////////////////////////////////////////////////////////////// 127 unsigned int _xcu_send_ipi( unsigned int cluster_ id,141 unsigned int _xcu_send_ipi( unsigned int cluster_xy, 128 142 unsigned int proc_id, 129 143 unsigned int wdata ) 130 144 { 131 145 // parameters checking 132 if (cluster_id >= NB_CLUSTERS) return 1; 133 if (proc_id >= NB_PROCS_MAX) return 1; 146 unsigned int x = cluster_xy >> Y_WIDTH; 147 unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); 148 if (x >= X_SIZE) return 1; 149 if (y >= Y_SIZE) return 1; 150 if (proc_id >= NB_PROCS_MAX) return 1; 134 151 135 152 #if USE_XICU 136 153 unsigned int* xcu_address = (unsigned int *) ((unsigned int)&seg_xcu_base + 137 (cluster_ id* (unsigned int)&vseg_cluster_increment));154 (cluster_xy * (unsigned int)&vseg_cluster_increment)); 138 155 xcu_address[XICU_REG(XICU_WTI_REG, proc_id)] = wdata; 139 156 return 0; … … 152 169 // Returns 0 if success, > 0 if error. 153 170 //////////////////////////////////////////////////////////////////////////////// 154 unsigned int _xcu_timer_start( unsigned int cluster_ id,155 unsigned int local_id,171 unsigned int _xcu_timer_start( unsigned int cluster_xy, 172 unsigned int proc_id, 156 173 unsigned int period ) 157 174 { 158 175 // parameters checking 159 if (cluster_id >= NB_CLUSTERS) return 1; 160 if (local_id >= NB_TIM_CHANNELS) return 1; 176 unsigned int x = cluster_xy >> Y_WIDTH; 177 unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); 178 if (x >= X_SIZE) return 1; 179 if (y >= Y_SIZE) return 1; 180 if (proc_id >= NB_PROCS_MAX) return 1; 161 181 162 182 #if USE_XICU 163 183 unsigned int* xcu_address = (unsigned int *) ((unsigned int)&seg_xcu_base + 164 (cluster_ id* (unsigned int)&vseg_cluster_increment));165 xcu_address[XICU_REG(XICU_PTI_PER, local_id)] = period;184 (cluster_xy * (unsigned int)&vseg_cluster_increment)); 185 xcu_address[XICU_REG(XICU_PTI_PER, proc_id)] = period; 166 186 return 0; 167 187 #else … … 179 199 // Returns 0 if success, > 0 if error. 180 200 ////////////////////////////////////////////////////////////////////////////// 181 unsigned int _xcu_timer_stop( unsigned int cluster_id, 182 unsigned int local_id) 183 { 184 // parameters checking 185 if (cluster_id >= NB_CLUSTERS) return 1; 186 if (local_id >= NB_TIM_CHANNELS) return 1; 201 unsigned int _xcu_timer_stop( unsigned int cluster_xy, 202 unsigned int proc_id) 203 { 204 // parameters checking 205 unsigned int x = cluster_xy >> Y_WIDTH; 206 unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); 207 if (x >= X_SIZE) return 1; 208 if (y >= Y_SIZE) return 1; 209 if (proc_id >= NB_PROCS_MAX) return 1; 187 210 188 211 #if USE_XICU 189 212 unsigned int * xcu_address = (unsigned int *) ((unsigned int)&seg_xcu_base + 190 (cluster_ id* (unsigned int)&vseg_cluster_increment));191 xcu_address[XICU_REG(XICU_PTI_PER, local_id)] = 0;213 (cluster_xy * (unsigned int)&vseg_cluster_increment)); 214 xcu_address[XICU_REG(XICU_PTI_PER, proc_id)] = 0; 192 215 return 0; 193 216 #else … … 207 230 // Returns 0 if success, > 0 if error. 208 231 ////////////////////////////////////////////////////////////////////////////// 209 unsigned int _xcu_timer_reset_irq( unsigned int cluster_id, 210 unsigned int local_id ) 211 { 212 // parameters checking 213 if (cluster_id >= NB_CLUSTERS) return 1; 214 if (local_id >= NB_TIM_CHANNELS) return 1; 232 unsigned int _xcu_timer_reset_irq( unsigned int cluster_xy, 233 unsigned int proc_id ) 234 { 235 // parameters checking 236 unsigned int x = cluster_xy >> Y_WIDTH; 237 unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); 238 if (x >= X_SIZE) return 1; 239 if (y >= Y_SIZE) return 1; 240 if (proc_id >= NB_PROCS_MAX) return 1; 215 241 216 242 #if USE_XICU 217 243 unsigned int * xcu_address = (unsigned int *) ((unsigned int)&seg_xcu_base + 218 (cluster_ id* (unsigned int)&vseg_cluster_increment));219 220 unsigned int bloup = xcu_address[XICU_REG(XICU_PTI_ACK, local_id)];244 (cluster_xy * (unsigned int)&vseg_cluster_increment)); 245 246 unsigned int bloup = xcu_address[XICU_REG(XICU_PTI_ACK, proc_id)]; 221 247 bloup++; // to avoid a warning 222 248 return 0; … … 238 264 // This function is called during a context switch (user or preemptive) 239 265 ///////////////////////////////////////////////////////////////////////////// 240 unsigned int _xcu_timer_reset_cpt( unsigned int cluster_id, 241 unsigned int local_id ) 242 { 243 // parameters checking 244 if (cluster_id >= NB_CLUSTERS) return 1; 245 if (local_id >= NB_TIM_CHANNELS) return 1; 266 unsigned int _xcu_timer_reset_cpt( unsigned int cluster_xy, 267 unsigned int proc_id ) 268 { 269 // parameters checking 270 unsigned int x = cluster_xy >> Y_WIDTH; 271 unsigned int y = cluster_xy & ((1<<Y_WIDTH)-1); 272 if (x >= X_SIZE) return 1; 273 if (y >= Y_SIZE) return 1; 274 if (proc_id >= NB_PROCS_MAX) return 1; 246 275 247 276 #if USE_XICU 248 277 unsigned int * xcu_address = (unsigned int *) ((unsigned int) &seg_xcu_base + 249 (cluster_ id* (unsigned int)&vseg_cluster_increment));250 251 unsigned int period = xcu_address[XICU_REG(XICU_PTI_PER, local_id)];278 (cluster_xy * (unsigned int)&vseg_cluster_increment)); 279 280 unsigned int period = xcu_address[XICU_REG(XICU_PTI_PER, proc_id)]; 252 281 253 282 // we write 0 first because if the timer is currently running, 254 283 // the corresponding timer counter is not reset 255 xcu_address[XICU_REG(XICU_PTI_PER, local_id)] = 0;256 xcu_address[XICU_REG(XICU_PTI_PER, local_id)] = period;284 xcu_address[XICU_REG(XICU_PTI_PER, proc_id)] = 0; 285 xcu_address[XICU_REG(XICU_PTI_PER, proc_id)] = period; 257 286 return 0; 258 287 #else
Note: See TracChangeset
for help on using the changeset viewer.