| 1 | //////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 2 | // File : stdio.c |
|---|
| 3 | // Written by Alain Greiner |
|---|
| 4 | // Date : janvier 2014 |
|---|
| 5 | // |
|---|
| 6 | // This file defines various functions that can be used by applications to access |
|---|
| 7 | // peripherals, for the TSAR multi-processors multi_clusters architecture. |
|---|
| 8 | // There is NO separation between application code and system code, as the |
|---|
| 9 | // application are running in kernel mode without system calls. |
|---|
| 10 | // This basic GIET does not support virtual memory, and does not support multi-tasking. |
|---|
| 11 | // |
|---|
| 12 | // The supported peripherals are: |
|---|
| 13 | // - the SoClib multi_tty |
|---|
| 14 | // - The SoCLib frame_buffer |
|---|
| 15 | // - The SoCLib block_device |
|---|
| 16 | // |
|---|
| 17 | // The following parameters must be defined in the hard_config.h file. |
|---|
| 18 | // - X_SIZE : number of clusters in a row |
|---|
| 19 | // - Y_SIZE : number of clusters in a column |
|---|
| 20 | // - X_WIDTH : number of bits for X field in proc_id |
|---|
| 21 | // - Y_WIDTH : number of bits for Y field in proc_id |
|---|
| 22 | // - NB_PROCS_MAX : max number of processor per cluster |
|---|
| 23 | // - NB_TTY_CHANNELS : max number of TTY channels |
|---|
| 24 | // |
|---|
| 25 | // The follobing base addresses must be defined in the ldscript |
|---|
| 26 | // - seg_tty_base |
|---|
| 27 | // - seg_fbf_base |
|---|
| 28 | // - seg_ioc_base |
|---|
| 29 | //////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 30 | |
|---|
| 31 | #include "stdio.h" |
|---|
| 32 | |
|---|
| 33 | #if !defined(NB_PROCS_MAX) |
|---|
| 34 | #error: you must define NB_PROCS_MAX in the hard_config.h file |
|---|
| 35 | #endif |
|---|
| 36 | |
|---|
| 37 | #if !defined(X_IO) || !defined(Y_IO) |
|---|
| 38 | #error: you must define X_IO and Y_IO in the hard_config.h file |
|---|
| 39 | #endif |
|---|
| 40 | |
|---|
| 41 | #if !defined(X_SIZE) |
|---|
| 42 | #error: you must define X_SIZE in the hard_config.h file |
|---|
| 43 | #endif |
|---|
| 44 | |
|---|
| 45 | #if !defined(Y_SIZE) |
|---|
| 46 | #error: you must define Y_SIZE in the hard_config.h file |
|---|
| 47 | #endif |
|---|
| 48 | |
|---|
| 49 | #if !defined(X_WIDTH) |
|---|
| 50 | #error: you must define X_WIDTH in the hard_config.h file |
|---|
| 51 | #endif |
|---|
| 52 | |
|---|
| 53 | #if (X_WIDTH != 4) |
|---|
| 54 | #error: The X_WIDTH parameter must be equal to 4 |
|---|
| 55 | #endif |
|---|
| 56 | |
|---|
| 57 | #if !defined(Y_WIDTH) |
|---|
| 58 | #error: you must define X_WIDTH in the hard_config.h file |
|---|
| 59 | #endif |
|---|
| 60 | |
|---|
| 61 | #if (X_WIDTH != 4) |
|---|
| 62 | #error: The Y_WIDTH parameter must be equal to 4 |
|---|
| 63 | #endif |
|---|
| 64 | |
|---|
| 65 | #if !defined(NB_TTY_CHANNELS) |
|---|
| 66 | #error: you must define NB_TTY_CHANNELS in the hard_config.h file |
|---|
| 67 | #endif |
|---|
| 68 | |
|---|
| 69 | #define NB_LOCKS 256 |
|---|
| 70 | #define NB_BARRIERS 16 |
|---|
| 71 | |
|---|
| 72 | #define in_drivers __attribute__((section (".drivers"))) |
|---|
| 73 | #define in_unckdata __attribute__((section (".unckdata"))) |
|---|
| 74 | |
|---|
| 75 | ////////////////////////////////////////////////////////////// |
|---|
| 76 | // various informations that must be defined in ldscript |
|---|
| 77 | ////////////////////////////////////////////////////////////// |
|---|
| 78 | |
|---|
| 79 | struct plouf; |
|---|
| 80 | extern volatile struct plouf seg_tty_base; |
|---|
| 81 | extern volatile struct plouf seg_fbf_base; |
|---|
| 82 | extern volatile struct plouf seg_ioc_base; |
|---|
| 83 | extern volatile struct plouf seg_mmc_base; |
|---|
| 84 | extern volatile struct plouf seg_ramdisk_base; |
|---|
| 85 | |
|---|
| 86 | //////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 87 | // Global uncachable variables for synchronization between drivers and ISRs |
|---|
| 88 | //////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 89 | |
|---|
| 90 | static in_unckdata int volatile _ioc_lock = 0; |
|---|
| 91 | static in_unckdata int volatile _ioc_done = 0; |
|---|
| 92 | static in_unckdata int volatile _ioc_status; |
|---|
| 93 | |
|---|
| 94 | static in_unckdata char volatile _tty_get_buf[NB_TTY_CHANNELS]; |
|---|
| 95 | static in_unckdata int volatile _tty_get_full[NB_TTY_CHANNELS] = { [0 ... NB_TTY_CHANNELS-1] = 0 }; |
|---|
| 96 | |
|---|
| 97 | //////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 98 | // Global uncachable variables for inter-task barriers |
|---|
| 99 | //////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 100 | |
|---|
| 101 | static in_unckdata int volatile _barrier_value[NB_BARRIERS] = { [0 ... NB_BARRIERS-1] = 0 }; |
|---|
| 102 | static in_unckdata int volatile _barrier_count[NB_BARRIERS] = { [0 ... NB_BARRIERS-1] = 0 }; |
|---|
| 103 | static in_unckdata int volatile _barrier_lock[NB_BARRIERS] = { [0 ... NB_BARRIERS-1] = 0 }; |
|---|
| 104 | |
|---|
| 105 | //////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 106 | // Global uncachable variables for spin_locks using LL/C instructions |
|---|
| 107 | //////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 108 | |
|---|
| 109 | static in_unckdata int volatile _spin_lock[NB_LOCKS] = { [0 ... NB_LOCKS-1] = 0 }; |
|---|
| 110 | |
|---|
| 111 | //////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 112 | // Memcopy taken from MutekH. |
|---|
| 113 | //////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 114 | in_drivers void* _memcpy( void* _dst, |
|---|
| 115 | const void* _src, |
|---|
| 116 | unsigned int size ) |
|---|
| 117 | { |
|---|
| 118 | unsigned int *dst = _dst; |
|---|
| 119 | const unsigned int *src = _src; |
|---|
| 120 | if ( ! ((unsigned int)dst & 3) && ! ((unsigned int)src & 3) ) |
|---|
| 121 | { |
|---|
| 122 | while (size > 3) |
|---|
| 123 | { |
|---|
| 124 | *dst++ = *src++; |
|---|
| 125 | size -= 4; |
|---|
| 126 | } |
|---|
| 127 | } |
|---|
| 128 | |
|---|
| 129 | unsigned char *cdst = (unsigned char*)dst; |
|---|
| 130 | unsigned char *csrc = (unsigned char*)src; |
|---|
| 131 | |
|---|
| 132 | while (size--) |
|---|
| 133 | { |
|---|
| 134 | *cdst++ = *csrc++; |
|---|
| 135 | } |
|---|
| 136 | return _dst; |
|---|
| 137 | } |
|---|
| 138 | //////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 139 | // Memcopy using extended addresses |
|---|
| 140 | //////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 141 | in_drivers void _extended_memcpy( unsigned int dst_cluster, |
|---|
| 142 | unsigned int dst_address, |
|---|
| 143 | unsigned int src_address, |
|---|
| 144 | unsigned int length ) |
|---|
| 145 | { |
|---|
| 146 | if ( (dst_address & 0x3) || (src_address & 0x3) || (length & 0x3) ) |
|---|
| 147 | { |
|---|
| 148 | _tty_get_lock( 0 ); |
|---|
| 149 | _tty_puts( "ERROR in _extended_memcpy()" ); |
|---|
| 150 | _tty_release_lock( 0 ); |
|---|
| 151 | _exit(); |
|---|
| 152 | } |
|---|
| 153 | |
|---|
| 154 | unsigned int i; |
|---|
| 155 | unsigned int word; |
|---|
| 156 | |
|---|
| 157 | for ( i = 0 ; i < length ; i = i+4 ) |
|---|
| 158 | { |
|---|
| 159 | word = _word_extended_read( src_cluster, (src_address + i) ); |
|---|
| 160 | _word_extended_write( dst_cluster, (dst_address + i), word ); |
|---|
| 161 | } |
|---|
| 162 | } |
|---|
| 163 | //////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 164 | // Access CP0 and returns processor ident |
|---|
| 165 | // No more than 1024 processors... |
|---|
| 166 | //////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 167 | in_drivers unsigned int _procid() |
|---|
| 168 | { |
|---|
| 169 | unsigned int ret; |
|---|
| 170 | asm volatile( "mfc0 %0, $15, 1": "=r"(ret) ); |
|---|
| 171 | return (ret & 0x3FF); |
|---|
| 172 | } |
|---|
| 173 | //////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 174 | // Access CP0 and returns processor time |
|---|
| 175 | //////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 176 | in_drivers unsigned int _proctime() |
|---|
| 177 | { |
|---|
| 178 | unsigned int ret; |
|---|
| 179 | asm volatile( "mfc0 %0, $9": "=r"(ret) ); |
|---|
| 180 | return ret; |
|---|
| 181 | } |
|---|
| 182 | //////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 183 | // Returns the number of processsors controled by the GIET |
|---|
| 184 | //////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 185 | in_drivers inline unsigned int _procnumber() |
|---|
| 186 | { |
|---|
| 187 | return (unsigned int)(NB_PROCS_MAX * X_SIZE * Y_SIZE); |
|---|
| 188 | } |
|---|
| 189 | //////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 190 | // Returns pseudo-random number |
|---|
| 191 | //////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 192 | in_drivers unsigned int _rand() |
|---|
| 193 | { |
|---|
| 194 | unsigned int x = _proctime(); |
|---|
| 195 | if((x & 0xF) > 7) |
|---|
| 196 | return (x*x & 0xFFFF); |
|---|
| 197 | else |
|---|
| 198 | return (x*x*x & 0xFFFF); |
|---|
| 199 | } |
|---|
| 200 | //////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 201 | // Access CP0 and enable IRQs |
|---|
| 202 | //////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 203 | in_drivers inline void _it_enable() |
|---|
| 204 | { |
|---|
| 205 | asm volatile( |
|---|
| 206 | "mfc0 $8, $12 \n" |
|---|
| 207 | "ori $8, $8, 1 \n" |
|---|
| 208 | "mtc0 $8, $12 \n" |
|---|
| 209 | ::: "$8"); |
|---|
| 210 | } |
|---|
| 211 | //////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 212 | // Access CP0 and mask IRQs |
|---|
| 213 | //////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 214 | in_drivers inline void _it_disable() |
|---|
| 215 | { |
|---|
| 216 | asm volatile( |
|---|
| 217 | "li $9, 0xFFFFFFFE \n" |
|---|
| 218 | "mfc0 $8, $12 \n" |
|---|
| 219 | "and $8, $8, $9 \n" |
|---|
| 220 | "mtc0 $8, $12 \n" |
|---|
| 221 | ::: "$8","$9"); |
|---|
| 222 | } |
|---|
| 223 | |
|---|
| 224 | //////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 225 | // Access CP0 and mask IRQs |
|---|
| 226 | //////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 227 | in_drivers inline void _sr_write(int sr) |
|---|
| 228 | { |
|---|
| 229 | asm volatile("mtc0 %0, $12 \n" : /* no outputs */ : "r" (sr)); |
|---|
| 230 | } |
|---|
| 231 | |
|---|
| 232 | in_drivers inline int _sr_read() |
|---|
| 233 | { |
|---|
| 234 | int ret; |
|---|
| 235 | asm volatile("mfc0 %0, $12 \n" : "=r" (ret)); |
|---|
| 236 | return ret; |
|---|
| 237 | } |
|---|
| 238 | |
|---|
| 239 | ////////////////////////////////////////////////////////////////////// |
|---|
| 240 | // Invalidate all cache lines corresponding to a memory buffer. |
|---|
| 241 | // This is used by the block_device driver. |
|---|
| 242 | ///////////////////////////////////////////////////////////////////////// |
|---|
| 243 | in_drivers void _dcache_buf_invalidate(const void * buffer, size_t size) |
|---|
| 244 | { |
|---|
| 245 | size_t i; |
|---|
| 246 | size_t dcache_line_size; |
|---|
| 247 | |
|---|
| 248 | // retrieve dcache line size from config register (bits 12:10) |
|---|
| 249 | asm volatile("mfc0 %0, $16, 1" : "=r" (dcache_line_size)); |
|---|
| 250 | |
|---|
| 251 | dcache_line_size = 2 << ((dcache_line_size>>10) & 0x7); |
|---|
| 252 | |
|---|
| 253 | // iterate on lines to invalidate each one of them |
|---|
| 254 | for ( i=0; i<size; i+=dcache_line_size ) |
|---|
| 255 | asm volatile(" cache %0, %1" |
|---|
| 256 | : |
|---|
| 257 | :"i" (0x11), "R" (*((char*)buffer+i))); |
|---|
| 258 | } |
|---|
| 259 | |
|---|
| 260 | //////////////////////////////////////////////////////////////////////////// |
|---|
| 261 | // This function makes a physical read access to a 32 bits word in memory, |
|---|
| 262 | // after a temporary paddr extension. |
|---|
| 263 | //////////////////////////////////////////////////////////////////////////// |
|---|
| 264 | in_drivers volatile unsigned int _word_extended_read( unsigned int cluster, |
|---|
| 265 | unsigned int address ) |
|---|
| 266 | { |
|---|
| 267 | int sr = _sr_read(); |
|---|
| 268 | volatile unsigned int value; |
|---|
| 269 | asm volatile( |
|---|
| 270 | "li $3, 0xFFFFFFFE \n" |
|---|
| 271 | "and $3, %3, $3 \n" |
|---|
| 272 | "mtc0 $3, $12 \n" /* IRQ disabled */ |
|---|
| 273 | |
|---|
| 274 | "mtc2 %2, $24 \n" /* PADDR_EXT <= msb */ |
|---|
| 275 | "lw %0, 0(%1) \n" /* value <= *paddr */ |
|---|
| 276 | "mtc2 $0, $24 \n" /* PADDR_EXT <= 0 */ |
|---|
| 277 | |
|---|
| 278 | : "=r" (value) |
|---|
| 279 | : "r" (address), "r" (cluster), "r" (sr) |
|---|
| 280 | : "$2", "$3", "memory" ); |
|---|
| 281 | |
|---|
| 282 | _sr_write(sr); |
|---|
| 283 | return value; |
|---|
| 284 | } |
|---|
| 285 | //////////////////////////////////////////////////////////////////////////// |
|---|
| 286 | // This function makes a physical read access to a single byte in memory, |
|---|
| 287 | // after a temporary paddr extension. |
|---|
| 288 | //////////////////////////////////////////////////////////////////////////// |
|---|
| 289 | in_drivers volatile unsigned char _byte_extended_read( unsigned int cluster, |
|---|
| 290 | unsigned int address ) |
|---|
| 291 | { |
|---|
| 292 | int sr = _sr_read(); |
|---|
| 293 | volatile unsigned char value; |
|---|
| 294 | asm volatile( |
|---|
| 295 | "li $3, 0xFFFFFFFE \n" |
|---|
| 296 | "and $3, %3, $3 \n" |
|---|
| 297 | "mtc0 $3, $12 \n" /* IRQ disabled */ |
|---|
| 298 | |
|---|
| 299 | "mtc2 %2, $24 \n" /* PADDR_EXT <= msb */ |
|---|
| 300 | "lb %0, 0(%1) \n" /* value <= *paddr */ |
|---|
| 301 | "mtc2 $0, $24 \n" /* PADDR_EXT <= 0 */ |
|---|
| 302 | |
|---|
| 303 | : "=r" (value) |
|---|
| 304 | : "r" (address), "r" (cluster), "r" (sr) |
|---|
| 305 | : "$2", "$3", "memory" ); |
|---|
| 306 | |
|---|
| 307 | _sr_write(sr); |
|---|
| 308 | return value; |
|---|
| 309 | } |
|---|
| 310 | //////////////////////////////////////////////////////////////////////////// |
|---|
| 311 | // This function makes a physical write access to a 32 bits word in memory, |
|---|
| 312 | // after a temporary DTLB address extension. |
|---|
| 313 | //////////////////////////////////////////////////////////////////////////// |
|---|
| 314 | in_drivers void _word_extended_write( unsigned int cluster, |
|---|
| 315 | unsigned int address, |
|---|
| 316 | unsigned int word ) |
|---|
| 317 | { |
|---|
| 318 | int sr = _sr_read(); |
|---|
| 319 | asm volatile( |
|---|
| 320 | "li $3, 0xFFFFFFFE \n" |
|---|
| 321 | "and $3, %3, $3 \n" |
|---|
| 322 | "mtc0 $3, $12 \n" /* IRQ disabled */ |
|---|
| 323 | |
|---|
| 324 | "mtc2 %2, $24 \n" /* PADDR_EXT <= msb */ |
|---|
| 325 | "sw %0, 0(%1) \n" /* *paddr <= value */ |
|---|
| 326 | "mtc2 $0, $24 \n" /* PADDR_EXT <= 0 */ |
|---|
| 327 | |
|---|
| 328 | "sync \n" |
|---|
| 329 | : |
|---|
| 330 | : "r" (word), "r" (address), "r" (cluster), "r" (sr) |
|---|
| 331 | : "$2", "$3", "memory"); |
|---|
| 332 | |
|---|
| 333 | _sr_write(sr); |
|---|
| 334 | } |
|---|
| 335 | //////////////////////////////////////////////////////////////////////////// |
|---|
| 336 | // This function makes a physical write access to single byte in memory, |
|---|
| 337 | // after a temporary DTLB de-activation and address extension. |
|---|
| 338 | //////////////////////////////////////////////////////////////////////////// |
|---|
| 339 | in_drivers void _byte_extended_write( unsigned int cluster, |
|---|
| 340 | unsigned int address, |
|---|
| 341 | unsigned char byte ) |
|---|
| 342 | { |
|---|
| 343 | int sr = _sr_read(); |
|---|
| 344 | asm volatile( |
|---|
| 345 | "li $3, 0xFFFFFFFE \n" |
|---|
| 346 | "and $3, %3, $3 \n" |
|---|
| 347 | "mtc0 $3, $12 \n" /* IRQ disabled */ |
|---|
| 348 | |
|---|
| 349 | "mtc2 %2, $24 \n" /* PADDR_EXT <= msb */ |
|---|
| 350 | "sb %0, 0(%1) \n" /* *paddr <= value */ |
|---|
| 351 | "mtc2 $0, $24 \n" /* PADDR_EXT <= 0 */ |
|---|
| 352 | |
|---|
| 353 | "sync \n" |
|---|
| 354 | : |
|---|
| 355 | : "r" (byte), "r" (address), "r" (cluster), "r" (sr) |
|---|
| 356 | : "$2", "$3", "memory"); |
|---|
| 357 | |
|---|
| 358 | _sr_write(sr); |
|---|
| 359 | } |
|---|
| 360 | |
|---|
| 361 | /////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 362 | // Exit (suicide) after printing message on TTY0 |
|---|
| 363 | /////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 364 | in_drivers void _exit() |
|---|
| 365 | { |
|---|
| 366 | unsigned int proc_id = _procid(); |
|---|
| 367 | unsigned int l = proc_id % NB_PROCS_MAX; |
|---|
| 368 | unsigned int x = (proc_id / NB_PROCS_MAX) >> Y_WIDTH; |
|---|
| 369 | unsigned int y = (proc_id / NB_PROCS_MAX) & ((1<<Y_WIDTH) - 1); |
|---|
| 370 | |
|---|
| 371 | _tty_get_lock( 0 ); |
|---|
| 372 | _tty_puts("\n !!! exit proc["); |
|---|
| 373 | _tty_putd( x ); |
|---|
| 374 | _tty_puts(","); |
|---|
| 375 | _tty_putd( y ); |
|---|
| 376 | _tty_puts(","); |
|---|
| 377 | _tty_putd( l ); |
|---|
| 378 | _tty_puts("] !!!\n"); |
|---|
| 379 | _tty_release_lock( 0 ); |
|---|
| 380 | |
|---|
| 381 | while(1) asm volatile("nop"); // infinite loop... |
|---|
| 382 | } |
|---|
| 383 | |
|---|
| 384 | ///////////////////////////////////////////////////////////////////////// |
|---|
| 385 | // convert a 32 bits unsigned int to a string of 10 decimal characters. |
|---|
| 386 | ///////////////////////////////////////////////////////////////////////// |
|---|
| 387 | in_drivers void _itoa_dec(unsigned val, char* buf) |
|---|
| 388 | { |
|---|
| 389 | const char DecTab[] = "0123456789"; |
|---|
| 390 | unsigned int i; |
|---|
| 391 | for( i=0 ; i<10 ; i++ ) |
|---|
| 392 | { |
|---|
| 393 | if( (val!=0) || (i==0) ) buf[9-i] = DecTab[val % 10]; |
|---|
| 394 | else buf[9-i] = 0x20; |
|---|
| 395 | val /= 10; |
|---|
| 396 | } |
|---|
| 397 | } |
|---|
| 398 | ////////////////////////////////////////////////////////////////////////// |
|---|
| 399 | // convert a 32 bits unsigned int to a string of 8 hexadecimal characters. |
|---|
| 400 | /////////////////////////////////////////////////////////////////////////// |
|---|
| 401 | in_drivers void _itoa_hex(unsigned int val, char* buf) |
|---|
| 402 | { |
|---|
| 403 | const char HexaTab[] = "0123456789ABCD"; |
|---|
| 404 | unsigned int i; |
|---|
| 405 | for( i=0 ; i<8 ; i++ ) |
|---|
| 406 | { |
|---|
| 407 | buf[7-i] = HexaTab[val % 16]; |
|---|
| 408 | val /= 16; |
|---|
| 409 | } |
|---|
| 410 | } |
|---|
| 411 | |
|---|
| 412 | |
|---|
| 413 | /////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 414 | // VCI MULTI_TTY |
|---|
| 415 | /////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 416 | // The total number of TTY terminals is defined by NB_TTY_CHANNELS. |
|---|
| 417 | // - If there is only one terminal, it is supposed to be shared, and used by |
|---|
| 418 | // all processors: a lock must be taken before display. |
|---|
| 419 | // - If there is several terminals, and the number of processors is smaller |
|---|
| 420 | // than the number of terminals, there is one terminal per processor, but |
|---|
| 421 | // the TTY index is not equal to the proc_id, due to cluster indexing policy: |
|---|
| 422 | // proc_id = cluster_xy * NB_PROCS_MAX + local_id (with cluster_xy = x << Y_WIDTH + y) |
|---|
| 423 | // tty_id = cluster_id * NB_PROCS_MAX + local_id (with cluster_id = x * Y_SIZE + y) |
|---|
| 424 | // - If the computed tty_id is larger than NB_TTY_CHANNELS, an error is returned. |
|---|
| 425 | /////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 426 | |
|---|
| 427 | /////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 428 | // Write one or several characters directly from a fixed length user buffer |
|---|
| 429 | // to the TTY_WRITE register of the TTY controler. |
|---|
| 430 | // The channel index must be checked by the calling function. |
|---|
| 431 | // This is a non blocking call : it test the TTY_STATUS register. |
|---|
| 432 | // If the TTY_STATUS_WRITE bit is set, the transfer stops and the function |
|---|
| 433 | // returns the number of characters that have been actually written. |
|---|
| 434 | /////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 435 | in_drivers int _tty_write( char* buffer, |
|---|
| 436 | unsigned int length, |
|---|
| 437 | unsigned int channel ) |
|---|
| 438 | { |
|---|
| 439 | unsigned int base = (unsigned int)&seg_tty_base + channel*TTY_SPAN*4; |
|---|
| 440 | unsigned int nwritten = 0; |
|---|
| 441 | unsigned int status; |
|---|
| 442 | unsigned int i; |
|---|
| 443 | |
|---|
| 444 | for ( i=0 ; i < length ; i++ ) |
|---|
| 445 | { |
|---|
| 446 | status = _word_extended_read( CLUSTER_IO, base + TTY_STATUS*4 ); |
|---|
| 447 | if ( (status & 0x2) == 0x2 ) break; |
|---|
| 448 | else |
|---|
| 449 | { |
|---|
| 450 | _byte_extended_write( CLUSTER_IO, base + TTY_WRITE*4 , buffer[i] ); |
|---|
| 451 | nwritten++; |
|---|
| 452 | } |
|---|
| 453 | } |
|---|
| 454 | |
|---|
| 455 | return nwritten; |
|---|
| 456 | } |
|---|
| 457 | |
|---|
| 458 | /////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 459 | // Fetch one character directly from the TTY_READ register of the TTY controler, |
|---|
| 460 | // and writes this character to the user buffer. |
|---|
| 461 | // The channel index must be checked by the calling function. |
|---|
| 462 | // This is a non blocking call : it returns 0 if the register is empty, |
|---|
| 463 | // and returns 1 if the register is full. |
|---|
| 464 | /////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 465 | in_drivers int _tty_read( char* buffer, |
|---|
| 466 | unsigned int channel ) |
|---|
| 467 | { |
|---|
| 468 | unsigned int base = (unsigned int)&seg_tty_base + channel*TTY_SPAN*4; |
|---|
| 469 | unsigned int status; |
|---|
| 470 | |
|---|
| 471 | status = _word_extended_read( CLUSTER_IO, base + TTY_STATUS*4 ); |
|---|
| 472 | if ( (status & 0x1) == 0x1 ) |
|---|
| 473 | { |
|---|
| 474 | buffer[0] = (char)_word_extended_read( CLUSTER_IO, base + TTY_READ*4 ); |
|---|
| 475 | return 1; |
|---|
| 476 | } |
|---|
| 477 | return 0; |
|---|
| 478 | } |
|---|
| 479 | |
|---|
| 480 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 481 | // This function displays a string on TTY0. |
|---|
| 482 | // The string must be terminated by a NUL character. |
|---|
| 483 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 484 | in_drivers void _tty_puts( char* string ) |
|---|
| 485 | { |
|---|
| 486 | int length = 0; |
|---|
| 487 | while (string[length] != 0) length++; |
|---|
| 488 | _tty_write( string, length, 0 ); |
|---|
| 489 | } |
|---|
| 490 | |
|---|
| 491 | /////////////////////////////////////////////////////////////////////////////// |
|---|
| 492 | // This function displays a 32 bits unsigned int as an hexa string on TTY0. |
|---|
| 493 | /////////////////////////////////////////////////////////////////////////////// |
|---|
| 494 | in_drivers void _tty_putx(unsigned int val) |
|---|
| 495 | { |
|---|
| 496 | static const char HexaTab[] = "0123456789ABCDEF"; |
|---|
| 497 | char buf[11]; |
|---|
| 498 | unsigned int c; |
|---|
| 499 | |
|---|
| 500 | buf[0] = '0'; |
|---|
| 501 | buf[1] = 'x'; |
|---|
| 502 | buf[10] = 0; |
|---|
| 503 | |
|---|
| 504 | for (c = 0; c < 8; c++) |
|---|
| 505 | { |
|---|
| 506 | buf[9 - c] = HexaTab[val & 0xF]; |
|---|
| 507 | val = val >> 4; |
|---|
| 508 | } |
|---|
| 509 | _tty_puts( buf ); |
|---|
| 510 | } |
|---|
| 511 | |
|---|
| 512 | /////////////////////////////////////////////////////////////////////////////// |
|---|
| 513 | // This function displays a 32 bits unsigned int as a decimal string on TTY0. |
|---|
| 514 | /////////////////////////////////////////////////////////////////////////////// |
|---|
| 515 | in_drivers void _tty_putd( unsigned int val ) |
|---|
| 516 | { |
|---|
| 517 | static const char DecTab[] = "0123456789"; |
|---|
| 518 | char buf[11]; |
|---|
| 519 | unsigned int i; |
|---|
| 520 | unsigned int first = 0; |
|---|
| 521 | |
|---|
| 522 | buf[10] = 0; |
|---|
| 523 | |
|---|
| 524 | for (i = 0; i < 10; i++) |
|---|
| 525 | { |
|---|
| 526 | if ((val != 0) || (i == 0)) |
|---|
| 527 | { |
|---|
| 528 | buf[9 - i] = DecTab[val % 10]; |
|---|
| 529 | first = 9 - i; |
|---|
| 530 | } |
|---|
| 531 | else |
|---|
| 532 | { |
|---|
| 533 | break; |
|---|
| 534 | } |
|---|
| 535 | val /= 10; |
|---|
| 536 | } |
|---|
| 537 | _tty_puts( &buf[first] ); |
|---|
| 538 | } |
|---|
| 539 | |
|---|
| 540 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 541 | // This function try to take the hardwired lock protecting exclusive access |
|---|
| 542 | // to TTY terminal identified by the channel argument. |
|---|
| 543 | // It returns only when the lock has been successfully taken. |
|---|
| 544 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 545 | in_drivers void _tty_get_lock( unsigned int channel ) |
|---|
| 546 | { |
|---|
| 547 | unsigned int base = (unsigned int)&seg_tty_base; |
|---|
| 548 | unsigned int offset = (TTY_CONFIG + channel*TTY_SPAN) << 2; |
|---|
| 549 | while ( _word_extended_read( CLUSTER_IO, base + offset ) ); |
|---|
| 550 | } |
|---|
| 551 | |
|---|
| 552 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 553 | // This function releases the hardwired lock protecting exclusive access |
|---|
| 554 | // to TTY terminal identified by the channel argument. |
|---|
| 555 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 556 | in_drivers void _tty_release_lock( unsigned int channel ) |
|---|
| 557 | { |
|---|
| 558 | unsigned int base = (unsigned int)&seg_tty_base; |
|---|
| 559 | unsigned int offset = (TTY_CONFIG + channel*TTY_SPAN) << 2; |
|---|
| 560 | _word_extended_write( CLUSTER_IO, base + offset, 0 ); |
|---|
| 561 | } |
|---|
| 562 | |
|---|
| 563 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 564 | // This function fetch a single ascii character from a terminal |
|---|
| 565 | // implicitely defined by the processor ID. |
|---|
| 566 | // It is a blocking function. |
|---|
| 567 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 568 | in_drivers void _tty_getc( char* buf ) |
|---|
| 569 | { |
|---|
| 570 | unsigned int proc_id = _procid(); |
|---|
| 571 | unsigned int channel; |
|---|
| 572 | unsigned int l; |
|---|
| 573 | unsigned int x; |
|---|
| 574 | unsigned int y; |
|---|
| 575 | |
|---|
| 576 | // check TTY channel |
|---|
| 577 | l = (proc_id % NB_PROCS_MAX); |
|---|
| 578 | x = (proc_id / NB_PROCS_MAX) >> Y_WIDTH; |
|---|
| 579 | y = (proc_id / NB_PROCS_MAX) & ((1<<Y_WIDTH) - 1); |
|---|
| 580 | channel = (x * Y_SIZE + y) * NB_PROCS_MAX + l; |
|---|
| 581 | if (channel >= NB_TTY_CHANNELS ) |
|---|
| 582 | { |
|---|
| 583 | _tty_get_lock( 0 ); |
|---|
| 584 | _tty_puts( "ERROR in _tty_getc(): TTY index too large\n" ); |
|---|
| 585 | _tty_release_lock( 0 ); |
|---|
| 586 | _exit(); |
|---|
| 587 | } |
|---|
| 588 | |
|---|
| 589 | while( _tty_read( buf, channel ) == 0 ) asm volatile("nop"); |
|---|
| 590 | } |
|---|
| 591 | |
|---|
| 592 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 593 | // Fetch a string of decimal characters (most significant digit first) |
|---|
| 594 | // to build a 32 bits unsigned int. |
|---|
| 595 | // The terminal index is implicitely defined by the processor ID. |
|---|
| 596 | // This is a blocking function. |
|---|
| 597 | // The decimal characters are written in a 32 characters buffer |
|---|
| 598 | // until a <LF> or <CR> character is read. |
|---|
| 599 | // The <DEL> character is interpreted, and previous characters can be |
|---|
| 600 | // cancelled. All others characters are ignored. |
|---|
| 601 | // When the <LF> or <CR> character is received, the string is converted |
|---|
| 602 | // to an unsigned int value. If the number of decimal digit is too large |
|---|
| 603 | // for the 32 bits range, the zero value is returned. |
|---|
| 604 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 605 | in_drivers void _tty_getw( unsigned int* word_buffer ) |
|---|
| 606 | { |
|---|
| 607 | char buf[32]; |
|---|
| 608 | char byte; |
|---|
| 609 | char cancel_string[3] = { 0x08, 0x20, 0x08 }; |
|---|
| 610 | char zero = 0x30; |
|---|
| 611 | unsigned int save = 0; |
|---|
| 612 | unsigned int val = 0; |
|---|
| 613 | unsigned int done = 0; |
|---|
| 614 | unsigned int overflow = 0; |
|---|
| 615 | unsigned int max = 0; |
|---|
| 616 | unsigned int proc_id = _procid(); |
|---|
| 617 | unsigned int i; |
|---|
| 618 | unsigned int channel; |
|---|
| 619 | unsigned int x; |
|---|
| 620 | unsigned int y; |
|---|
| 621 | unsigned int l; |
|---|
| 622 | |
|---|
| 623 | // check TTY channel |
|---|
| 624 | l = (proc_id % NB_PROCS_MAX); |
|---|
| 625 | x = (proc_id / NB_PROCS_MAX) >> Y_WIDTH; |
|---|
| 626 | y = (proc_id / NB_PROCS_MAX) & ((1<<Y_WIDTH) - 1); |
|---|
| 627 | channel = (x * Y_SIZE + y) * NB_PROCS_MAX + l; |
|---|
| 628 | if (channel >= NB_TTY_CHANNELS ) |
|---|
| 629 | { |
|---|
| 630 | _tty_get_lock( 0 ); |
|---|
| 631 | _tty_puts( "ERROR in _tty_getw(): TTY index too large\n" ); |
|---|
| 632 | _tty_release_lock( 0 ); |
|---|
| 633 | _exit(); |
|---|
| 634 | } |
|---|
| 635 | |
|---|
| 636 | while( done == 0 ) |
|---|
| 637 | { |
|---|
| 638 | _tty_read( &byte, channel ); |
|---|
| 639 | |
|---|
| 640 | if (( byte > 0x2F) && (byte < 0x3A)) // decimal character |
|---|
| 641 | { |
|---|
| 642 | buf[max] = byte; |
|---|
| 643 | max++; |
|---|
| 644 | _tty_write( &byte, 1, channel ); |
|---|
| 645 | } |
|---|
| 646 | else if ( (byte == 0x0A) || (byte == 0x0D) ) // LF or CR character |
|---|
| 647 | { |
|---|
| 648 | done = 1; |
|---|
| 649 | } |
|---|
| 650 | else if ( byte == 0x7F ) // DEL character |
|---|
| 651 | { |
|---|
| 652 | if (max > 0) |
|---|
| 653 | { |
|---|
| 654 | max--; // cancel the character |
|---|
| 655 | _tty_write( cancel_string, 3, channel ); |
|---|
| 656 | } |
|---|
| 657 | } |
|---|
| 658 | } // end while |
|---|
| 659 | |
|---|
| 660 | // string conversion |
|---|
| 661 | for( i=0 ; i<max ; i++ ) |
|---|
| 662 | { |
|---|
| 663 | val = val*10 + (buf[i] - 0x30); |
|---|
| 664 | if (val < save) overflow = 1; |
|---|
| 665 | save = val; |
|---|
| 666 | } |
|---|
| 667 | if (overflow == 0) |
|---|
| 668 | { |
|---|
| 669 | *word_buffer = val; // return decimal value |
|---|
| 670 | } |
|---|
| 671 | else |
|---|
| 672 | { |
|---|
| 673 | for( i=0 ; i<max ; i++) // cancel the string |
|---|
| 674 | { |
|---|
| 675 | _tty_write( cancel_string, 3, channel ); |
|---|
| 676 | } |
|---|
| 677 | _tty_write( &zero, 1, channel ); |
|---|
| 678 | *word_buffer = 0; // return 0 value |
|---|
| 679 | } |
|---|
| 680 | } |
|---|
| 681 | |
|---|
| 682 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 683 | // This function is a simplified version of the mutek_printf() function. |
|---|
| 684 | // It takes the TTY lock on the selected channel for exclusive access. |
|---|
| 685 | // Only a limited number of formats are supported: |
|---|
| 686 | // - %d : signed decimal |
|---|
| 687 | // - %u : unsigned decimal |
|---|
| 688 | // - %x : hexadecimal |
|---|
| 689 | // - %c : char |
|---|
| 690 | // - %s : string |
|---|
| 691 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 692 | in_drivers void _tty_printf( char *format, ...) |
|---|
| 693 | { |
|---|
| 694 | va_list ap; |
|---|
| 695 | va_start( ap, format ); |
|---|
| 696 | |
|---|
| 697 | unsigned int channel; |
|---|
| 698 | unsigned int x; |
|---|
| 699 | unsigned int y; |
|---|
| 700 | unsigned int proc_id = _procid(); |
|---|
| 701 | |
|---|
| 702 | // compute TTY channel : |
|---|
| 703 | // if the number of TTY channels is smaller |
|---|
| 704 | // than the number of clusters, use TTY_0_0 |
|---|
| 705 | // else, TTY channel <= cluster index |
|---|
| 706 | if ( NB_TTY_CHANNELS < (X_SIZE * Y_SIZE) ) |
|---|
| 707 | { |
|---|
| 708 | channel = 0; |
|---|
| 709 | } |
|---|
| 710 | else |
|---|
| 711 | { |
|---|
| 712 | x = (proc_id / NB_PROCS_MAX) >> Y_WIDTH; |
|---|
| 713 | y = (proc_id / NB_PROCS_MAX) & ((1<<Y_WIDTH) - 1); |
|---|
| 714 | channel = (x * Y_SIZE + y); |
|---|
| 715 | } |
|---|
| 716 | |
|---|
| 717 | // take the TTY lock |
|---|
| 718 | _tty_get_lock( channel ); |
|---|
| 719 | |
|---|
| 720 | printf_text: |
|---|
| 721 | |
|---|
| 722 | while (*format) |
|---|
| 723 | { |
|---|
| 724 | unsigned int i; |
|---|
| 725 | for (i = 0; format[i] && format[i] != '%'; i++) |
|---|
| 726 | ; |
|---|
| 727 | if (i) |
|---|
| 728 | { |
|---|
| 729 | _tty_write( format, i, channel ); |
|---|
| 730 | format += i; |
|---|
| 731 | } |
|---|
| 732 | if (*format == '%') |
|---|
| 733 | { |
|---|
| 734 | format++; |
|---|
| 735 | goto printf_arguments; |
|---|
| 736 | } |
|---|
| 737 | } // end while |
|---|
| 738 | |
|---|
| 739 | va_end( ap ); |
|---|
| 740 | |
|---|
| 741 | // release lock |
|---|
| 742 | _tty_release_lock( 0 ); |
|---|
| 743 | |
|---|
| 744 | return; |
|---|
| 745 | |
|---|
| 746 | printf_arguments: |
|---|
| 747 | |
|---|
| 748 | { |
|---|
| 749 | int val = va_arg(ap, long); |
|---|
| 750 | char buf[20]; |
|---|
| 751 | char* pbuf; |
|---|
| 752 | unsigned int len = 0; |
|---|
| 753 | static const char HexaTab[] = "0123456789ABCDEF"; |
|---|
| 754 | unsigned int i; |
|---|
| 755 | |
|---|
| 756 | switch (*format++) { |
|---|
| 757 | case ('c'): // char conversion |
|---|
| 758 | len = 1; |
|---|
| 759 | buf[0] = val; |
|---|
| 760 | pbuf = buf; |
|---|
| 761 | break; |
|---|
| 762 | case ('d'): // decimal signed integer |
|---|
| 763 | if (val < 0) |
|---|
| 764 | { |
|---|
| 765 | val = -val; |
|---|
| 766 | _tty_write( "_" , 1, channel ); |
|---|
| 767 | } |
|---|
| 768 | case ('u'): // decimal unsigned integer |
|---|
| 769 | for( i=0 ; i<10 ; i++) |
|---|
| 770 | { |
|---|
| 771 | buf[9-i] = HexaTab[val % 10]; |
|---|
| 772 | if (!(val /= 10)) break; |
|---|
| 773 | } |
|---|
| 774 | len = i+1; |
|---|
| 775 | pbuf = &buf[9-i]; |
|---|
| 776 | break; |
|---|
| 777 | case ('x'): // hexadecimal integer |
|---|
| 778 | _tty_write( "0x", 2, channel ); |
|---|
| 779 | for( i=0 ; i<8 ; i++) |
|---|
| 780 | { |
|---|
| 781 | buf[7-i] = HexaTab[val % 16U]; |
|---|
| 782 | if (!(val /= 16U)) break; |
|---|
| 783 | } |
|---|
| 784 | len = i+1; |
|---|
| 785 | pbuf = &buf[7-i]; |
|---|
| 786 | break; |
|---|
| 787 | case ('s'): // string |
|---|
| 788 | { |
|---|
| 789 | char *str = (char*)val; |
|---|
| 790 | while ( str[len] ) len++; |
|---|
| 791 | pbuf = (char*)val; |
|---|
| 792 | } |
|---|
| 793 | break; |
|---|
| 794 | default: |
|---|
| 795 | goto printf_text; |
|---|
| 796 | } // end switch |
|---|
| 797 | |
|---|
| 798 | _tty_write( pbuf, len, channel ); |
|---|
| 799 | goto printf_text; |
|---|
| 800 | } |
|---|
| 801 | } // end printf() |
|---|
| 802 | |
|---|
| 803 | ////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 804 | // These functions are the ISRs that must be executed when an IRQ is activated |
|---|
| 805 | // by the TTY: _tty_isr_XX is associated to TTY channel [XX]. |
|---|
| 806 | // It save the character in the communication buffer _tty_get_buf[XX], |
|---|
| 807 | // and set the set/reset variable _tty_get_full[XX]. |
|---|
| 808 | // A character is lost if the buffer is full when the ISR is executed. |
|---|
| 809 | ////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 810 | in_drivers void _tty_isr_indexed(size_t index) |
|---|
| 811 | { |
|---|
| 812 | unsigned int base = (unsigned int)&seg_tty_base; |
|---|
| 813 | unsigned int offset = (index*TTY_SPAN + TTY_READ) << 2; |
|---|
| 814 | |
|---|
| 815 | _tty_get_buf[index] = _byte_extended_read(CLUSTER_IO, base + offset); |
|---|
| 816 | _tty_get_full[index] = 1; // signals character available |
|---|
| 817 | } |
|---|
| 818 | |
|---|
| 819 | in_drivers void _tty_isr() { _tty_isr_indexed(0); } |
|---|
| 820 | |
|---|
| 821 | in_drivers void _tty_isr_00() { _tty_isr_indexed(0); } |
|---|
| 822 | in_drivers void _tty_isr_01() { _tty_isr_indexed(1); } |
|---|
| 823 | in_drivers void _tty_isr_02() { _tty_isr_indexed(2); } |
|---|
| 824 | in_drivers void _tty_isr_03() { _tty_isr_indexed(3); } |
|---|
| 825 | in_drivers void _tty_isr_04() { _tty_isr_indexed(4); } |
|---|
| 826 | in_drivers void _tty_isr_05() { _tty_isr_indexed(5); } |
|---|
| 827 | in_drivers void _tty_isr_06() { _tty_isr_indexed(6); } |
|---|
| 828 | in_drivers void _tty_isr_07() { _tty_isr_indexed(7); } |
|---|
| 829 | in_drivers void _tty_isr_08() { _tty_isr_indexed(8); } |
|---|
| 830 | in_drivers void _tty_isr_09() { _tty_isr_indexed(9); } |
|---|
| 831 | in_drivers void _tty_isr_10() { _tty_isr_indexed(10); } |
|---|
| 832 | in_drivers void _tty_isr_11() { _tty_isr_indexed(11); } |
|---|
| 833 | in_drivers void _tty_isr_12() { _tty_isr_indexed(12); } |
|---|
| 834 | in_drivers void _tty_isr_13() { _tty_isr_indexed(13); } |
|---|
| 835 | in_drivers void _tty_isr_14() { _tty_isr_indexed(14); } |
|---|
| 836 | in_drivers void _tty_isr_15() { _tty_isr_indexed(15); } |
|---|
| 837 | in_drivers void _tty_isr_16() { _tty_isr_indexed(16); } |
|---|
| 838 | in_drivers void _tty_isr_17() { _tty_isr_indexed(17); } |
|---|
| 839 | in_drivers void _tty_isr_18() { _tty_isr_indexed(18); } |
|---|
| 840 | in_drivers void _tty_isr_19() { _tty_isr_indexed(19); } |
|---|
| 841 | in_drivers void _tty_isr_20() { _tty_isr_indexed(20); } |
|---|
| 842 | in_drivers void _tty_isr_21() { _tty_isr_indexed(21); } |
|---|
| 843 | in_drivers void _tty_isr_22() { _tty_isr_indexed(22); } |
|---|
| 844 | in_drivers void _tty_isr_23() { _tty_isr_indexed(23); } |
|---|
| 845 | in_drivers void _tty_isr_24() { _tty_isr_indexed(24); } |
|---|
| 846 | in_drivers void _tty_isr_25() { _tty_isr_indexed(25); } |
|---|
| 847 | in_drivers void _tty_isr_26() { _tty_isr_indexed(26); } |
|---|
| 848 | in_drivers void _tty_isr_27() { _tty_isr_indexed(27); } |
|---|
| 849 | in_drivers void _tty_isr_28() { _tty_isr_indexed(28); } |
|---|
| 850 | in_drivers void _tty_isr_29() { _tty_isr_indexed(29); } |
|---|
| 851 | in_drivers void _tty_isr_30() { _tty_isr_indexed(30); } |
|---|
| 852 | in_drivers void _tty_isr_31() { _tty_isr_indexed(31); } |
|---|
| 853 | |
|---|
| 854 | |
|---|
| 855 | ////////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 856 | // BLOCK_DEVICE (IOC) |
|---|
| 857 | ////////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 858 | // The block size is 512 bytes. |
|---|
| 859 | // The functions below use the three variables _ioc_lock _ioc_done, |
|---|
| 860 | // and _ioc_status for synchronisation. |
|---|
| 861 | // - As the IOC component can be used by several programs running in parallel, |
|---|
| 862 | // the _ioc_lock variable guaranties exclusive access to the device. |
|---|
| 863 | // The _ioc_read() and _ioc_write() functions use atomic LL/SC to get the lock. |
|---|
| 864 | // and set _ioc_lock to a non zero value. |
|---|
| 865 | // The _ioc_write() and _ioc_read() functions are blocking, polling the _ioc_lock |
|---|
| 866 | // variable until the device is available. |
|---|
| 867 | // - When the tranfer is completed, the ISR routine activated by the IOC IRQ |
|---|
| 868 | // set the _ioc_done variable to a non-zero value. Possible address errors detected |
|---|
| 869 | // by the IOC peripheral are reported by the ISR in the _ioc_status variable. |
|---|
| 870 | // The _ioc_completed() function is polling the _ioc_done variable, waiting for |
|---|
| 871 | // tranfer conpletion. When the completion is signaled, the _ioc_completed() function |
|---|
| 872 | // reset the _ioc_done variable to zero, and releases the _ioc_lock variable. |
|---|
| 873 | /////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 874 | // If USE_RAMDISK is set, we access a "virtual" block device controler implemented |
|---|
| 875 | // as a memory-mapped segment in cluster [0,0] at address seg_ramdisk_base. |
|---|
| 876 | // The tranfer being fully synchronous, the IOC interrupt is not activated. |
|---|
| 877 | /////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 878 | |
|---|
| 879 | /////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 880 | // This blocking function is used by the _ioc_read() and _ioc_write() functions |
|---|
| 881 | // to get _ioc_lock using LL/SC. |
|---|
| 882 | /////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 883 | in_drivers void _ioc_get_lock() |
|---|
| 884 | { |
|---|
| 885 | register unsigned int* plock = (unsigned int*)&_ioc_lock; |
|---|
| 886 | |
|---|
| 887 | asm volatile ( |
|---|
| 888 | "1: \n" |
|---|
| 889 | "ll $2, 0(%0) \n" // $2 <= _ioc_lock |
|---|
| 890 | "bnez $2, 1b \n" // retry if busy |
|---|
| 891 | "li $3, 1 \n" // prepare argument for sc |
|---|
| 892 | "sc $3, 0(%0) \n" // try to set _ioc_busy |
|---|
| 893 | "beqz $3, 1b \n" // retry if not atomic |
|---|
| 894 | ::"r"(plock) :"$2","$3"); |
|---|
| 895 | } |
|---|
| 896 | |
|---|
| 897 | ////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 898 | // Transfer data from a memory buffer to the block_device. |
|---|
| 899 | // - lba : first block index on the disk |
|---|
| 900 | // - buffer : base address of the memory buffer |
|---|
| 901 | // - count : number of blocks to be transfered |
|---|
| 902 | // - ext : cluster index for the memory buffer |
|---|
| 903 | /////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 904 | in_drivers void _ioc_write( size_t lba, |
|---|
| 905 | void* buffer, |
|---|
| 906 | size_t count, |
|---|
| 907 | size_t ext ) |
|---|
| 908 | { |
|---|
| 909 | // get the lock |
|---|
| 910 | _ioc_get_lock(); |
|---|
| 911 | |
|---|
| 912 | if ( USE_RAMDISK ) // we use an extended_memcpy |
|---|
| 913 | { |
|---|
| 914 | unsigned int src_address = (unsigned int)buffer; |
|---|
| 915 | unsigned int src_cluster = ext; |
|---|
| 916 | unsigned int dst_address = (unsigned int)&seg_ramdisk_base + lba*512; |
|---|
| 917 | unsigned int dst_cluster = 0; |
|---|
| 918 | |
|---|
| 919 | _extended_memcpy( dst_cluster, |
|---|
| 920 | dst_address, |
|---|
| 921 | src_cluster, |
|---|
| 922 | src_address, |
|---|
| 923 | count*512 ); |
|---|
| 924 | |
|---|
| 925 | _ioc_status = BLOCK_DEVICE_WRITE_SUCCESS; |
|---|
| 926 | _ioc_done = 1; |
|---|
| 927 | |
|---|
| 928 | return; |
|---|
| 929 | } |
|---|
| 930 | |
|---|
| 931 | unsigned int base = (unsigned int)&seg_ioc_base; |
|---|
| 932 | _word_extended_write( CLUSTER_IO, base + BLOCK_DEVICE_BUFFER*4, (unsigned int)buffer ); |
|---|
| 933 | _word_extended_write( CLUSTER_IO, base + BLOCK_DEVICE_BUFFER_EXT*4, ext ); |
|---|
| 934 | _word_extended_write( CLUSTER_IO, base + BLOCK_DEVICE_COUNT*4, count ); |
|---|
| 935 | _word_extended_write( CLUSTER_IO, base + BLOCK_DEVICE_LBA*4, lba ); |
|---|
| 936 | _word_extended_write( CLUSTER_IO, base + BLOCK_DEVICE_IRQ_ENABLE*4, 1 ); |
|---|
| 937 | _word_extended_write( CLUSTER_IO, base + BLOCK_DEVICE_OP*4, BLOCK_DEVICE_WRITE ); |
|---|
| 938 | } |
|---|
| 939 | |
|---|
| 940 | /////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 941 | // Transfer data from a file on the block device to a memory buffer. |
|---|
| 942 | // - lba : first block index on the disk |
|---|
| 943 | // - buffer : base address of the memory buffer |
|---|
| 944 | // - count : number of blocks to be transfered |
|---|
| 945 | // - ext : cluster index for the memory buffer |
|---|
| 946 | /////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 947 | in_drivers void _ioc_read( size_t lba, |
|---|
| 948 | void* buffer, |
|---|
| 949 | size_t count, |
|---|
| 950 | size_t ext ) |
|---|
| 951 | { |
|---|
| 952 | // get the lock |
|---|
| 953 | _ioc_get_lock(); |
|---|
| 954 | |
|---|
| 955 | if ( USE_RAMDISK ) // we use an extended_memcpy |
|---|
| 956 | { |
|---|
| 957 | unsigned int dst_address = (unsigned int)buffer; |
|---|
| 958 | unsigned int dst_cluster = ext; |
|---|
| 959 | unsigned int src_address = (unsigned int)&seg_ramdisk_base + lba*512; |
|---|
| 960 | unsigned int src_cluster = 0; |
|---|
| 961 | |
|---|
| 962 | _extended_memcpy( dst_cluster, |
|---|
| 963 | dst_address, |
|---|
| 964 | src_cluster, |
|---|
| 965 | src_address, |
|---|
| 966 | count*512 ); |
|---|
| 967 | |
|---|
| 968 | _ioc_status = BLOCK_DEVICE_READ_SUCCESS; |
|---|
| 969 | _ioc_done = 1; |
|---|
| 970 | |
|---|
| 971 | return; |
|---|
| 972 | } |
|---|
| 973 | |
|---|
| 974 | const unsigned int base = (unsigned int)&seg_ioc_base; |
|---|
| 975 | _word_extended_write( CLUSTER_IO, base + BLOCK_DEVICE_BUFFER*4, (unsigned int)buffer ); |
|---|
| 976 | _word_extended_write( CLUSTER_IO, base + BLOCK_DEVICE_BUFFER_EXT*4, ext ); |
|---|
| 977 | _word_extended_write( CLUSTER_IO, base + BLOCK_DEVICE_COUNT*4, count ); |
|---|
| 978 | _word_extended_write( CLUSTER_IO, base + BLOCK_DEVICE_LBA*4, lba ); |
|---|
| 979 | _word_extended_write( CLUSTER_IO, base + BLOCK_DEVICE_IRQ_ENABLE*4, 1 ); |
|---|
| 980 | _word_extended_write( CLUSTER_IO, base + BLOCK_DEVICE_OP*4, BLOCK_DEVICE_READ ); |
|---|
| 981 | } |
|---|
| 982 | |
|---|
| 983 | in_drivers inline unsigned int _ioc_get_blocksize() { |
|---|
| 984 | const unsigned int base = (unsigned int)&seg_ioc_base; |
|---|
| 985 | return _word_extended_read( CLUSTER_IO, base + BLOCK_DEVICE_BLOCK_SIZE*4 ); |
|---|
| 986 | } |
|---|
| 987 | |
|---|
| 988 | /////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 989 | // This blocking function cheks completion of an I/O transfer and reports errors. |
|---|
| 990 | // It returns 0 if the transfer is successfully completed. |
|---|
| 991 | // It returns -1 if an error has been reported. |
|---|
| 992 | /////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 993 | in_drivers void _ioc_completed() |
|---|
| 994 | { |
|---|
| 995 | // waiting for completion |
|---|
| 996 | while (_ioc_done == 0) asm volatile("nop"); |
|---|
| 997 | |
|---|
| 998 | // reset synchronisation variables |
|---|
| 999 | _ioc_done = 0; |
|---|
| 1000 | _ioc_lock = 0; |
|---|
| 1001 | |
|---|
| 1002 | if( (_ioc_status != BLOCK_DEVICE_READ_SUCCESS) && |
|---|
| 1003 | (_ioc_status != BLOCK_DEVICE_WRITE_SUCCESS) ) |
|---|
| 1004 | { |
|---|
| 1005 | _tty_get_lock( 0 ); |
|---|
| 1006 | _tty_puts( "ERROR in _ioc_completed()\n"); |
|---|
| 1007 | _tty_release_lock( 0 ); |
|---|
| 1008 | _exit(); |
|---|
| 1009 | } |
|---|
| 1010 | } |
|---|
| 1011 | |
|---|
| 1012 | ////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 1013 | // This ISR must be executed when an IRQ is activated by IOC to signal completion. |
|---|
| 1014 | // It acknowledge the IRQ using the ioc base address, save the status in _ioc_status, |
|---|
| 1015 | // and set the _ioc_done variable to signal completion. |
|---|
| 1016 | // This variable is defined in the drivers.c file. |
|---|
| 1017 | ////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 1018 | in_drivers void _ioc_isr() |
|---|
| 1019 | { |
|---|
| 1020 | unsigned int base = (unsigned int)&seg_ioc_base; |
|---|
| 1021 | |
|---|
| 1022 | _ioc_status = _word_extended_read( CLUSTER_IO, base + BLOCK_DEVICE_STATUS*4 ); |
|---|
| 1023 | _ioc_done = 1; // signals completion |
|---|
| 1024 | } |
|---|
| 1025 | |
|---|
| 1026 | ////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 1027 | // FRAME_BUFFER |
|---|
| 1028 | ////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 1029 | // The _fb_sync_write & _fb_sync_read functions use a memcpy strategy to implement |
|---|
| 1030 | // the transfer between a data buffer and the frame buffer. |
|---|
| 1031 | // They are blocking until completion of the transfer. |
|---|
| 1032 | ////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 1033 | |
|---|
| 1034 | ////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 1035 | // _fb_sync_write() |
|---|
| 1036 | // Transfer data from an user buffer to the frame_buffer device with a memcpy. |
|---|
| 1037 | // - offset : offset (in bytes) in the frame buffer |
|---|
| 1038 | // - buffer : base address of the memory buffer |
|---|
| 1039 | // - length : number of bytes to be transfered |
|---|
| 1040 | // - ext : cluster_xy for the user buffer |
|---|
| 1041 | ////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 1042 | in_drivers void _fb_sync_write( unsigned int offset, |
|---|
| 1043 | unsigned int buffer, |
|---|
| 1044 | unsigned int length, |
|---|
| 1045 | unsigned int ext ) |
|---|
| 1046 | { |
|---|
| 1047 | unsigned int src_address = buffer; |
|---|
| 1048 | unsigned int src_cluster = ext; |
|---|
| 1049 | unsigned int dst_address = (unsigned int)&seg_fbf_base + offset; |
|---|
| 1050 | |
|---|
| 1051 | _extended_memcpy( CLUSTER_IO, |
|---|
| 1052 | dst_address, |
|---|
| 1053 | src_cluster, |
|---|
| 1054 | src_address, |
|---|
| 1055 | length ); |
|---|
| 1056 | } |
|---|
| 1057 | |
|---|
| 1058 | /////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 1059 | // _fb_sync_read() |
|---|
| 1060 | // Transfer data from the frame_buffer device to an user buffer with a memcpy. |
|---|
| 1061 | // - offset : offset (in bytes) in the frame buffer |
|---|
| 1062 | // - buffer : base address of the memory buffer |
|---|
| 1063 | // - length : number of bytes to be transfered |
|---|
| 1064 | // - ext : cluster_xy for the user buffer |
|---|
| 1065 | ////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 1066 | in_drivers void _fb_sync_read( unsigned int offset, |
|---|
| 1067 | unsigned int buffer, |
|---|
| 1068 | unsigned int length, |
|---|
| 1069 | unsigned int ext ) |
|---|
| 1070 | { |
|---|
| 1071 | unsigned int dst_address = buffer; |
|---|
| 1072 | unsigned int dst_cluster = ext; |
|---|
| 1073 | unsigned int src_address = (unsigned int)&seg_fbf_base + offset; |
|---|
| 1074 | |
|---|
| 1075 | _extended_memcpy( dst_cluster, |
|---|
| 1076 | dst_address, |
|---|
| 1077 | CLUSTER_IO, |
|---|
| 1078 | src_address, |
|---|
| 1079 | length ); |
|---|
| 1080 | } |
|---|
| 1081 | |
|---|
| 1082 | ////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 1083 | // This ISR must be executed when an IRQ is activated by MEMC to signal |
|---|
| 1084 | // an error detected by the TSAR memory cache after a write transaction. |
|---|
| 1085 | // It displays an error message on the TTY terminal allocated to the processor |
|---|
| 1086 | // executing the ISR. |
|---|
| 1087 | ////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 1088 | in_drivers void _mmc_isr() |
|---|
| 1089 | { |
|---|
| 1090 | //int* mmc_address = (int*)&seg_mmc_base; |
|---|
| 1091 | unsigned int cluster_xy = _procid() / NB_PROCS_MAX; |
|---|
| 1092 | |
|---|
| 1093 | _tty_printf( "WRITE ERROR signaled by Memory Cache in cluster %x\n", cluster_xy ); |
|---|
| 1094 | } |
|---|
| 1095 | |
|---|
| 1096 | /////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 1097 | // Release a software spin-lock |
|---|
| 1098 | /////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 1099 | in_drivers void _release_lock(size_t index) |
|---|
| 1100 | |
|---|
| 1101 | { |
|---|
| 1102 | if( index >= NB_LOCKS ) |
|---|
| 1103 | { |
|---|
| 1104 | _tty_get_lock( 0 ); |
|---|
| 1105 | _tty_puts( "ERROR in _release_lock()" ); |
|---|
| 1106 | _tty_release_lock( 0 ); |
|---|
| 1107 | _exit(); |
|---|
| 1108 | } |
|---|
| 1109 | |
|---|
| 1110 | _spin_lock[index] = 0; |
|---|
| 1111 | } |
|---|
| 1112 | |
|---|
| 1113 | /////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 1114 | // Try to take a software spin-lock. |
|---|
| 1115 | // This is a blocking call, as there is a busy-waiting loop, |
|---|
| 1116 | // until the lock is granted to the requester. |
|---|
| 1117 | // There is an internal delay of about 100 cycles between |
|---|
| 1118 | // two successive lock read, to avoid bus saturation. |
|---|
| 1119 | /////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 1120 | in_drivers void _get_lock(size_t index) |
|---|
| 1121 | { |
|---|
| 1122 | if( index >= NB_LOCKS ) |
|---|
| 1123 | { |
|---|
| 1124 | _tty_get_lock( 0 ); |
|---|
| 1125 | _tty_puts( "ERROR in _get_lock()" ); |
|---|
| 1126 | _tty_release_lock( 0 ); |
|---|
| 1127 | _exit(); |
|---|
| 1128 | } |
|---|
| 1129 | |
|---|
| 1130 | register int delay = ((_proctime() +_procid()) & 0xF) << 4; |
|---|
| 1131 | register int * plock = (int *) &_spin_lock[index]; |
|---|
| 1132 | |
|---|
| 1133 | asm volatile ("_locks_llsc: \n" |
|---|
| 1134 | "ll $2, 0(%0) \n" // $2 <= _locks_lock |
|---|
| 1135 | "bnez $2, _locks_delay \n" // random delay if busy |
|---|
| 1136 | "li $3, 1 \n" // prepare argument for sc |
|---|
| 1137 | "sc $3, 0(%0) \n" // try to set _locks_busy |
|---|
| 1138 | "bnez $3, _locks_ok \n" // exit if atomic |
|---|
| 1139 | "_locks_delay: \n" |
|---|
| 1140 | "move $4, %1 \n" // $4 <= delay |
|---|
| 1141 | "_locks_loop: \n" |
|---|
| 1142 | "addi $4, $4, -1 \n" // $4 <= $4 - 1 |
|---|
| 1143 | "beqz $4, _locks_loop \n" // test end delay |
|---|
| 1144 | "j _locks_llsc \n" // retry |
|---|
| 1145 | "_locks_ok: \n" |
|---|
| 1146 | ::"r"(plock),"r"(delay):"$2","$3","$4"); |
|---|
| 1147 | } |
|---|
| 1148 | |
|---|
| 1149 | |
|---|
| 1150 | ////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 1151 | // This function makes a cooperative initialisation of the barrier: |
|---|
| 1152 | // - barrier_count[index] <= N |
|---|
| 1153 | // - barrier_lock[index] <= 0 |
|---|
| 1154 | // All tasks try to initialize the barrier, but the initialisation |
|---|
| 1155 | // is done by only one task, using LL/SC instructions. |
|---|
| 1156 | // This cooperative initialisation is questionnable, |
|---|
| 1157 | // because the barrier can ony be initialised once... |
|---|
| 1158 | ////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 1159 | in_drivers void _barrier_init(unsigned int index, unsigned int value) |
|---|
| 1160 | { |
|---|
| 1161 | register int* pinit = (int*)&_barrier_value[index]; |
|---|
| 1162 | register int* pcount = (int*)&_barrier_count[index]; |
|---|
| 1163 | register int* plock = (int*)&_barrier_lock[index]; |
|---|
| 1164 | |
|---|
| 1165 | if ( index >= NB_BARRIERS ) |
|---|
| 1166 | { |
|---|
| 1167 | _tty_get_lock( 0 ); |
|---|
| 1168 | _tty_puts( "ERROR in _barrier_init()" ); |
|---|
| 1169 | _tty_release_lock( 0 ); |
|---|
| 1170 | _exit(); |
|---|
| 1171 | } |
|---|
| 1172 | |
|---|
| 1173 | // parallel initialisation using atomic instructions LL/SC |
|---|
| 1174 | asm volatile ("_barrier_init_test: \n" |
|---|
| 1175 | "ll $2, 0(%0) \n" // read barrier_value |
|---|
| 1176 | "bnez $2, _barrier_init_done \n" |
|---|
| 1177 | "move $3, %3 \n" |
|---|
| 1178 | "sc $3, 0(%0) \n" // try to write barrier_value |
|---|
| 1179 | "beqz $3, _barrier_init_test \n" |
|---|
| 1180 | "move $3, %3 \n" |
|---|
| 1181 | "sw $3, 0(%1) \n" // barrier_count <= barrier_value |
|---|
| 1182 | "move $3, $0 \n" // |
|---|
| 1183 | "sw $3, 0(%2) \n" // barrier_lock <= 0 |
|---|
| 1184 | "_barrier_init_done: \n" |
|---|
| 1185 | ::"r"(pinit),"r"(pcount),"r"(plock),"r"(value):"$2","$3"); |
|---|
| 1186 | } |
|---|
| 1187 | |
|---|
| 1188 | ////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 1189 | // This blocking function uses a busy_wait technics (on the barrier_lock value), |
|---|
| 1190 | // because the GIET does not support dynamic scheduling/descheduling of tasks. |
|---|
| 1191 | // The barrier state is actually defined by two variables: |
|---|
| 1192 | // _barrier_count[index] define the number of particpants that are waiting |
|---|
| 1193 | // _barrier_lock[index] define the bool variable whose value is polled |
|---|
| 1194 | // The last participant change the value of _barrier_lock[index] to release the barrier... |
|---|
| 1195 | // There is at most 16 independant barriers, and an error is returned |
|---|
| 1196 | // if the barrier index is larger than 15. |
|---|
| 1197 | ////////////////////////////////////////////////////////////////////////////////////// |
|---|
| 1198 | in_drivers void _barrier_wait(unsigned int index) |
|---|
| 1199 | { |
|---|
| 1200 | register int* pcount = (int*)&_barrier_count[index]; |
|---|
| 1201 | register int count; |
|---|
| 1202 | int lock = _barrier_lock[index]; |
|---|
| 1203 | |
|---|
| 1204 | if ( index >= NB_BARRIERS ) |
|---|
| 1205 | { |
|---|
| 1206 | _tty_get_lock( 0 ); |
|---|
| 1207 | _tty_puts( "ERROR in _barrier_wait()" ); |
|---|
| 1208 | _tty_release_lock( 0 ); |
|---|
| 1209 | _exit(); |
|---|
| 1210 | } |
|---|
| 1211 | |
|---|
| 1212 | // parallel decrement _barrier_count[index] using atomic instructions LL/SC |
|---|
| 1213 | // input : pointer on _barrier_count[index] |
|---|
| 1214 | // output : count = _barrier_count[index] (before decrementation) |
|---|
| 1215 | asm volatile ("_barrier_decrement: \n" |
|---|
| 1216 | "ll %0, 0(%1) \n" |
|---|
| 1217 | "addi $3, %0, -1 \n" |
|---|
| 1218 | "sc $3, 0(%1) \n" |
|---|
| 1219 | "beqz $3, _barrier_decrement \n" |
|---|
| 1220 | :"=&r"(count) |
|---|
| 1221 | :"r"(pcount) |
|---|
| 1222 | :"$2","$3"); |
|---|
| 1223 | |
|---|
| 1224 | // the last task re-initializes the barrier_ count variable |
|---|
| 1225 | // and the barrier_lock variable, waking up all other waiting tasks |
|---|
| 1226 | |
|---|
| 1227 | if ( count == 1 ) // last task |
|---|
| 1228 | { |
|---|
| 1229 | _barrier_count[index] = _barrier_value[index]; |
|---|
| 1230 | asm volatile( "sync" ); |
|---|
| 1231 | _barrier_lock[index] = (lock == 0) ? 1 : 0; |
|---|
| 1232 | } |
|---|
| 1233 | else // other tasks |
|---|
| 1234 | { |
|---|
| 1235 | while ( lock == _barrier_lock[index] ); |
|---|
| 1236 | } |
|---|
| 1237 | } |
|---|
| 1238 | |
|---|
| 1239 | |
|---|
| 1240 | // Local Variables: |
|---|
| 1241 | // tab-width: 4; |
|---|
| 1242 | // c-basic-offset: 4; |
|---|
| 1243 | // c-file-offsets:((innamespace . 0)(inline-open . 0)); |
|---|
| 1244 | // indent-tabs-mode: nil; |
|---|
| 1245 | // End: |
|---|
| 1246 | // |
|---|
| 1247 | // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4 |
|---|
| 1248 | |
|---|