source: trunk/softs/giet_tsar/stdio.c @ 360

Last change on this file since 360 was 158, checked in by alain, 13 years ago

Introducing the three sub-directories in the softs directory:

  • giet_tsar
  • soft_filter_giet
  • soft_transpose_giet
File size: 27.9 KB
Line 
1/*********************************************************************
2    fichier stdio.c
3    Written Alain greiner & Nicolas Pouillon
4    Date : 19/10/2009
5
6 These function implement the drivers for the SoCLib peripherals.
7 *********************************************************************/
8
9#include <stdarg.h>
10
11#include "stdio.h"
12
13#include "timer.h"
14#include "tty.h"
15#include "gcd.h"
16#include "icu.h"
17#include "dma.h"
18#include "block_device.h"
19
20/*********************************************************************
21  We define a generic C function to implement all system calls.
22 *********************************************************************/
23inline int sys_call( int call_no,
24        int arg_0,
25        int arg_1,
26        int arg_2,
27        int arg_3 )
28{
29    register int reg_no_and_output asm("v0") = call_no;
30    register int reg_a0 asm("a0") = arg_0;
31    register int reg_a1 asm("a1") = arg_1;
32    register int reg_a2 asm("a2") = arg_2;
33    register int reg_a3 asm("a3") = arg_3;
34
35    asm volatile(
36            "syscall"
37            : "=r" (reg_no_and_output)  // arguments de sortie
38            : "r" (reg_a0),         // arguments d'entrée
39            "r" (reg_a1),
40            "r" (reg_a2),
41            "r" (reg_a3),
42            "r" (reg_no_and_output)
43            : "memory",             // ressources modifiees:
44            "at",
45            "v1",
46            "ra",            // Ces registres persistants seront sauvegardes
47            "t0",            // sur la pile par le compilateur
48            "t1",            // seulement s'ils contiennent des donnees
49            "t2",            // calculees par la fonction effectuant le syscall,
50            "t3",            // et que ces valeurs sont reutilisees par cette
51            "t4",            // fonction au retour du syscall.
52            "t5",
53            "t6",
54            "t7",
55            "t8",
56            "t9"
57               );
58    return reg_no_and_output;
59}
60
61/********************************************************************
62  procid()
63  Returns the processor ident.
64 ********************************************************************/
65int procid()
66{
67    return sys_call(SYSCALL_PROCID, 0, 0, 0, 0);
68}
69/********************************************************************
70  proctime()
71  Returns the local processor time.
72 ********************************************************************/
73int proctime()
74{
75    return sys_call(SYSCALL_PROCTIME, 0, 0, 0, 0);
76}
77/********************************************************************
78  procnumber()
79  Returns the number of processors controled by the system.
80 ********************************************************************/
81int procnumber()
82{
83    return sys_call(SYSCALL_PROCNUMBER, 0, 0, 0, 0);
84}
85/********************************************************************
86  exit()
87  Exit the program with a TTY message, and enter an infinite loop...
88 ********************************************************************/
89int exit()
90{
91    int proc_index = procid();
92    return sys_call(SYSCALL_EXIT, proc_index, 0, 0, 0);
93}
94/********************************************************************
95  rand()
96  Returns a pseudo-random value derived from the processor cycle count.
97  This value is comprised between 0 & 65535.
98 ********************************************************************/
99int rand()
100{
101    int x = sys_call(SYSCALL_PROCTIME, 0, 0, 0, 0);
102    if((x & 0xF) > 7)
103        return (x*x & 0xFFFF);
104    else
105        return (x*x*x & 0xFFFF);
106}
107
108/*************************************************************************
109  MULTI-TTY
110 **************************************************************************
111 tty_putc()
112 Display a single ascii character on a terminal.
113 The terminal index is implicitely defined by the processor ID.
114 (and by the task ID in case of multi-tasking)
115 It doesn't use the TTY_PUT_IRQ interrupt, and the associated kernel buffer.
116 This function returns 0 in case of success.
117 ******************************i*******************************************/
118int tty_putc(char byte)
119{
120    return sys_call(SYSCALL_TTY_WRITE,
121            (int)(&byte),
122            1,
123            0,0);
124}
125/*************************************************************************
126  tty_puts()
127  Display a string on a terminal.
128  The terminal index is implicitely defined by the processor ID.
129  (and by the task ID in case of multi-tasking)
130  The string must be terminated by a NUL character.
131  It doesn't use the TTY_PUT_IRQinterrupt, and the associated kernel buffer.
132  This function returns 0 in case of success.
133 **************************************************************************/
134int tty_puts(char* string)
135{
136    int length = 0;
137    while (string[length] != 0) {
138        length++;
139    }
140    return sys_call(SYSCALL_TTY_WRITE,
141            (int)string,
142            length,
143            0,0);
144}
145/*************************************************************************
146  tty_putw()
147  Display the value of a 32 bits word (decimal characters).
148  The terminal index is implicitely defined by the processor ID.
149  (and by pthe task ID in case of multi-tasking)
150  It doesn't use the TTY_PUT_IRQ interrupt, and the associated kernel buffer.
151  This function returns 0 in case of success.
152 **************************************************************************/
153int tty_putw(int val)
154{
155    char buf[10];
156    int i;
157    for( i=0 ; i<10 ; i++ ) {
158        buf[9-i] = (val % 10) + 0x30;
159        val = val / 10;
160    }
161    return sys_call(SYSCALL_TTY_WRITE,
162            (int)buf,
163            10,
164            0,0);
165}
166/********************************************************************
167  tty_getc()
168  Fetch a single ascii character from a terminal.
169  The terminal index is implicitely defined by the processor ID.
170  (and by the task ID in case of multi-tasking)
171  It doesn't use the IRQ_GET interrupt, and the associated kernel buffer.
172  It is a blocking function that returns 0 if a valid char is stored
173  in the buffer, and returns -1 in case of error.
174 ********************************************************************/
175int tty_getc(char* buf)
176{
177    int ret = 0;
178    while( ret == 0 )
179    {
180        ret = sys_call(SYSCALL_TTY_READ,
181                (int)buf,
182                1,
183                0,0);
184        if ((ret < 0) || (ret > 1)) return -1;  // return error
185    }
186    return 0;   // return ok
187}
188/********************************************************************
189  tty_getc_irq()
190  Fetch a single ascii character from a terminal.
191  The terminal index is implicitely defined by the processor ID.
192  (and by the task ID in case of multi-tasking)
193  It uses the IRQ_GET interrupt, and the associated kernel buffer.
194  It is a blocking function that returns 0 if a valid char is stored
195  in the buffer, and returns -1 in case of error.
196 ********************************************************************/
197int tty_getc_irq(char* buf)
198{
199    int ret = 0;
200    while( ret == 0 )
201    {
202        ret = sys_call(SYSCALL_TTY_READ_IRQ,
203                (int)buf,
204                1,
205                0,0);
206        if ((ret < 0) || (ret > 1)) return -1;  // return error
207    }
208    return 0;   // return ok
209}
210/********************************************************************
211  tty_gets_irq()
212  Fetch a string from a terminal to a bounded length buffer.
213  The terminal index is implicitely defined by the processor ID.
214  (and by the task ID in case of multi-tasking)
215  It uses the TTY_GET_IRQ interrupt, anf the associated kernel buffer.
216  It is a blocking function that returns 0 if a valid string is stored
217  in the buffer, and returns -1 in case of error.
218  Up to (bufsize - 1) characters (including the non printable
219  characters) will be copied into buffer, and the string is
220  always completed by a NUL character.
221  The <LF> character is interpreted, as the function close
222  the string with a NUL character if <LF> is read.
223  The <DEL> character is interpreted, and the corresponding
224  character(s) are removed from the target buffer.
225 ********************************************************************/
226int tty_gets_irq(char* buf, int bufsize)
227{
228    int ret;
229    unsigned char byte;
230    unsigned int index = 0;
231
232    while( index < (bufsize-1) )
233    {
234        ret = sys_call(SYSCALL_TTY_READ_IRQ,
235                (int)(&byte),
236                1,
237                0,0);
238
239        if ((ret < 0) || (ret > 1)) return -1;  // return error
240
241        else if ( ret == 1 )            // valid character
242        {
243            if ( byte == 0x0A ) break; // LF
244            else if ((byte == 0x7F) && (index>0)) index--; // DEL
245            else
246            {
247                buf[index] = byte;
248                index++;
249            }
250        }
251    } // end while
252    buf[index] = 0;
253    return 0;       // return ok
254}
255/********************************************************************
256  tty_getw_irq()
257  Fetch a string of decimal characters (most significant digit first)
258  to build a 32 bits unsigned int.
259  The terminal index is implicitely defined by the processor ID.
260  (and by the task ID in case of multi-tasking)
261  This is a blocking function that returns 0 if a valid unsigned int
262  is stored in the buffer, and returns -1 in case of error.
263  It uses the TTY_GET_IRQ interrupt, anf the associated kernel buffer.
264  The non-blocking system function _tty_read_irq is called several times,
265  and the decimal characters are written in a 32 characters buffer
266  until a <LF> character is read.
267  The <DEL> character is interpreted, and previous characters can be
268  cancelled. All others characters are ignored.
269  When the <LF> character is received, the string is converted to
270  an unsigned int value. If the number of decimal digit is too large
271  for the 32 bits range, the zero value is returned.
272 ********************************************************************/
273int tty_getw_irq(int* word_buffer)
274{
275    unsigned char buf[32];
276    unsigned char byte;
277    unsigned int save = 0;
278    unsigned int val = 0;
279    unsigned int done = 0;
280    unsigned int overflow = 0;
281    unsigned int max = 0;
282    unsigned int i;
283    int ret;
284
285    while(done == 0)
286    {
287        ret = sys_call(SYSCALL_TTY_READ_IRQ,
288                (int)(&byte),
289                1,
290                0,0);
291        if ((ret < 0) || (ret > 1)) return -1;  // return error
292
293        if ( ret == 1 )     // get one character
294        {
295            if (( byte > 0x2F) && (byte < 0x3A))  // decimal character
296            {
297                buf[max] = byte;
298                max++;
299                tty_putc(byte);
300            }
301            else if ( (byte == 0x0A) || (byte == 0x0D) ) // LF or CR character
302            {
303                done = 1;
304            }
305            else if ( byte == 0x7F )        // DEL character
306            {
307                if (max > 0)
308                {
309                    max--;          // cancel the character
310                    tty_putc(0x08);
311                    tty_putc(0x20);
312                    tty_putc(0x08);
313                }
314            }
315            if ( max == 32 )            // decimal string overflow
316            {
317                for( i=0 ; i<max ; i++)     // cancel the string
318                {
319                    tty_putc(0x08);
320                    tty_putc(0x20);
321                    tty_putc(0x08);
322                }
323                tty_putc(0x30);
324                *word_buffer = 0;           // return 0 value
325                return 0;
326            }
327        }
328    } // end while
329
330    // string conversion
331    for( i=0 ; i<max ; i++ )
332    {
333        val = val*10 + (buf[i] - 0x30);
334        if (val < save) overflow = 1;
335        save = val;
336    }
337    if (overflow == 0)
338    {
339        *word_buffer = val;     // return decimal value
340    }
341    else
342    {
343        for( i=0 ; i<max ; i++)     // cancel the string
344        {
345            tty_putc(0x08);
346            tty_putc(0x20);
347            tty_putc(0x08);
348        }
349        tty_putc(0x30);
350        *word_buffer = 0;       // return 0 value
351    }
352    return 0;
353}
354/*********************************************************************
355  tty_printf()
356  This function is a simplified version of the mutek_printf() function.
357  The terminal index is implicitely defined by the processor ID.
358  (and by the task ID in case of multi-tasking)
359  It doesn't use the IRQ_PUT interrupt, anf the associated kernel buffer.
360  Only a limited number of formats are supported:
361  - %d : signed decimal
362  - %u : unsigned decimal
363  - %x : hexadecimal
364  - %c : char
365  - %s : string
366 *********************************************************************/
367int tty_printf(char *format, ...)
368{
369    va_list ap;
370    va_start(ap, format);
371
372printf_text:
373
374    while (*format) {
375        unsigned int i;
376        for (i = 0; format[i] && format[i] != '%'; i++)
377            ;
378        if (i) {
379            sys_call(SYSCALL_TTY_WRITE,
380                    (int)format,
381                    i,
382                    0,0);
383            format += i;
384        }
385        if (*format == '%') {
386            format++;
387            goto printf_arguments;
388        }
389    } // end while
390
391    va_end(ap);
392    return 0;
393
394printf_arguments:
395
396    {
397        int         val = va_arg(ap, long);
398        char            buf[20];
399        char*           pbuf;
400        unsigned int        len = 0;
401        static const char   HexaTab[] = "0123456789ABCDEF";
402        unsigned int        i;
403
404        switch (*format++) {
405            case ('c'):             // char conversion
406                len = 1;
407                buf[0] = val;
408                pbuf = buf;
409                break;
410            case ('d'):             // decimal signed integer
411                if (val < 0) {
412                    val = -val;
413                    sys_call(SYSCALL_TTY_WRITE,
414                            (int)"-",
415                            1,
416                            0,0);
417                }
418            case ('u'):             // decimal unsigned integer
419                for( i=0 ; i<10 ; i++) {
420                    buf[9-i] = HexaTab[val % 10];
421                    if (!(val /= 10)) break;
422                }
423                len =  i+1;
424                pbuf = &buf[9-i];
425                break;
426            case ('x'):             // hexadecimal integer
427                sys_call(SYSCALL_TTY_WRITE,
428                        (int)"0x",
429                        2,
430                        0,0);
431                for( i=0 ; i<8 ; i++) {
432                    buf[7-i] = HexaTab[val % 16U];
433                    if (!(val /= 16U)) break;
434                }
435                len =  i+1;
436                pbuf = &buf[7-i];
437                break;
438            case ('s'):             // string
439                {
440                    char *str = (char*)val;
441                    while ( str[len] ) len++;
442                    pbuf = (char*)val;
443                }
444                break;
445            default:
446                goto printf_text;
447        } // end switch
448
449        sys_call(SYSCALL_TTY_WRITE,
450                (int)pbuf,
451                len,
452                0,0);
453        goto printf_text;
454    }
455} // end printf()
456
457/********************************************************************
458  MULTI-TIMER
459  For all system calls, the first argument is the Timer index.
460 *********************************************************************
461 timer_set_mode()
462 The possible values for the TIMER_MODE register are
463 - 0x0 : Timer not activated
464 - 0x1 : Timer activated, but no interrupt is generated
465 - 0x3 : Timer activarted and periodic interrupts generated
466 ********************************************************************/
467int timer_set_mode(int timer_index, int val)
468{
469    return sys_call(SYSCALL_TIMER_WRITE,
470            timer_index,
471            TIMER_MODE,
472            val,
473            0);
474}
475/********************************************************************
476  timer_set_period()
477  Defines the period value for the periodic interrupt.
478 ********************************************************************/
479int timer_set_period(int timer_index, int val)
480{
481    return sys_call(SYSCALL_TIMER_WRITE,
482            timer_index,
483            TIMER_PERIOD,
484            val,
485            0);
486}
487/********************************************************************
488  timer_reset_irq()
489 ********************************************************************/
490int timer_reset_irq(int timer_index)
491{
492    return sys_call(SYSCALL_TIMER_WRITE,
493            timer_index,
494            TIMER_RESETIRQ,
495            0, 0);
496}
497/********************************************************************
498  timer_get_time()
499  returns the current timer value.
500 ********************************************************************/
501int timer_get_time(int timer_index, int* time)
502{
503    return sys_call(SYSCALL_TIMER_READ,
504            timer_index,
505            TIMER_VALUE,
506            (int)time,
507            0);
508}
509
510/********************************************************************
511  GCD COPROCESSOR
512 *********************************************************************
513 gcd_set_opa(int val)
514 Set operand A in the GCD (Greater Common Divider) coprocessor.
515 ********************************************************************/
516int gcd_set_opa(int val)
517{
518    return sys_call(SYSCALL_GCD_WRITE,
519            GCD_OPA,
520            val,
521            0, 0);
522}
523/********************************************************************
524  gcd_set_opb(int val)
525  Set operand B in the GCD (Greater Common Divider) coprocessor.
526 ********************************************************************/
527int gcd_set_opb(int val)
528{
529    return sys_call(SYSCALL_GCD_WRITE,
530            GCD_OPB,
531            val,
532            0, 0);
533}
534/********************************************************************
535  gcd_start()
536  Start computation in the GCD (Greater Common Divider) coprocessor.
537 ********************************************************************/
538int gcd_start(int val)
539{
540    return sys_call(SYSCALL_GCD_WRITE,
541            GCD_START,
542            0, 0, 0);
543}
544/********************************************************************
545  gcd_get_status(int* val)
546  Get status fromn the GCD (Greater Common Divider) coprocessor.
547  The value is nul when the coprocessor is idle (computation completed)
548 ********************************************************************/
549int gcd_get_status(int* val)
550{
551    return sys_call(SYSCALL_GCD_READ,
552            GCD_STATUS,
553            (int)val,
554            0, 0);
555}
556/********************************************************************
557  gcd_get_result(int* val)
558  Get result fromn the GCD (Greater Common Divider) coprocessor.
559 ********************************************************************/
560int gcd_get_result(int* val)
561{
562    return sys_call(SYSCALL_GCD_READ,
563            GCD_OPA,
564            (int)val,
565            0, 0);
566}
567
568/********************************************************************
569  ICU(s)
570 *********************************************************************
571 icu_set_mask()
572 Set some bits in the Interrupt Enable Mask of the ICU component.
573 Each bit set in the written word will be set in the Mask Enable.
574 ********************************************************************/
575int icu_set_mask(int val)
576{
577    return sys_call(SYSCALL_ICU_WRITE,
578            ICU_MASK_SET,
579            val,
580            0, 0);
581}
582/********************************************************************
583  icu_clear_mask()
584  Reset some bits in the Interrupt Enable Mask of the ICU component.
585  Each bit set in the written word will be reset in the Mask Enable.
586 ********************************************************************/
587int icu_clear_mask(int val)
588{
589    return sys_call(SYSCALL_ICU_WRITE,
590            ICU_MASK_CLEAR,
591            val,
592            0, 0);
593}
594/********************************************************************
595  icu_get_mask()
596  Read the Interrupt Enable Mask of the ICU component.
597 ********************************************************************/
598int icu_get_mask(int* buffer)
599{
600    return sys_call(SYSCALL_ICU_READ,
601            ICU_MASK,
602            (int)buffer,
603            0, 0);
604}
605/********************************************************************
606  icu_get_irqs()
607  Read the value of the 32 interrupt lines (IRQ inputs).
608 ********************************************************************/
609int icu_get_irqs(int* buffer)
610{
611    return sys_call(SYSCALL_ICU_READ,
612            ICU_INT,
613            (int)buffer,
614            0, 0);
615}
616/********************************************************************
617  icu_get_index()
618  Read the index of the highest priority active interrupt.
619  (If no active interrupt, -1 is returned).
620 ********************************************************************/
621int icu_get_index(int* buffer)
622{
623    return sys_call(SYSCALL_ICU_READ,
624            ICU_IT_VECTOR,
625            (int)buffer,
626            0, 0);
627}
628
629/********************************************************************
630  LOCKS
631 *********************************************************************
632 lock_acquire()
633 This system call performs a spin-lock acquisition.
634 It is dedicated to the SoCLib LOCKS peripheral.
635 In case of busy waiting, there is a random delay
636 of about 100 cycles between two successive lock read,
637 to avoid bus saturation.
638 ********************************************************************/
639int lock_acquire(int lock_index)
640{
641    return sys_call(SYSCALL_LOCKS_READ,
642            lock_index,
643            0, 0, 0);
644}
645
646/********************************************************************
647  lock_release()
648  You must use this system call to release a spin-lock,
649  as the LOCKS peripheral is in the kernel segment.
650 ********************************************************************/
651int lock_release(int lock_index)
652{
653    return sys_call(SYSCALL_LOCKS_WRITE,
654            lock_index,
655            0, 0, 0);
656}
657
658/********************************************************************
659  I/O BLOCK DEVICE
660 *********************************************************************
661 ioc_write()
662 Transfer data from a memory buffer to a file on the block_device.
663 - lba        : Logical Block Address (first block index)
664 - buffer     : base address of the memory buffer
665 - count      : number of blocks to be transfered
666 This function returns 0 if the transfert can be done.
667 It returns -1 if the buffer is not in user address space.
668 ********************************************************************/
669int ioc_write(size_t lba, void* buffer, size_t count)
670{
671    return sys_call(SYSCALL_IOC_WRITE,
672            lba,
673            (int)buffer,
674            count,
675            0);
676}
677/********************************************************************
678  ioc_read()
679  Transfer data from a file on the block_device to a memory buffer.
680  - lba        : Logical Block Address (first block index)
681  - buffer     : base address of the memory buffer
682  - count      : number of blocks to be transfered
683  This function returns 0 if the transfert can be done.
684  It returns -1 if the buffer is not in user address space.
685 ********************************************************************/
686int ioc_read(size_t lba, void* buffer, size_t count)
687{
688    return sys_call(SYSCALL_IOC_READ,
689            lba,
690            (int)buffer,
691            count,
692            0);
693}
694/********************************************************************
695  ioc_completed()
696  This blocking function returns 0 when the I/O transfer is
697  successfully completed, and returns -1 if an address error
698  has been detected.
699 ********************************************************************/
700int ioc_completed()
701{
702    return sys_call(SYSCALL_IOC_COMPLETED,
703            0, 0, 0, 0);
704}
705
706/********************************************************************
707  FRAME BUFFER
708 *********************************************************************
709 fb_sync_write()
710 This blocking function use a memory copy strategy to transfer data
711 from a user buffer to the frame buffer device in kernel space,
712 - offset     : offset (in bytes) in the frame buffer
713 - buffer     : base address of the memory buffer
714 - length     : number of bytes to be transfered
715 It returns 0 when the transfer is completed.
716 ********************************************************************/
717int fb_sync_write(size_t offset, void* buffer, size_t length)
718{
719    return sys_call(SYSCALL_FB_SYNC_WRITE,
720            offset,
721            (int)buffer,
722            length,
723            0);
724}
725/********************************************************************
726  fb_sync_read()
727  This blocking function use a memory copy strategy to transfer data
728  from the frame buffer device in kernel space to an user buffer.
729  - offset     : offset (in bytes) in the frame buffer
730  - buffer     : base address of the user buffer
731  - length     : number of bytes to be transfered
732  It returns 0 when the transfer is completed.
733 ********************************************************************/
734int fb_sync_read(size_t offset, void* buffer, size_t length)
735{
736    return sys_call(SYSCALL_FB_SYNC_READ,
737            offset,
738            (int)buffer,
739            length,
740            0);
741}
742/********************************************************************
743  fb_write()
744  This non-blocking function use the DMA coprocessor to transfer data
745  from a user buffer to the frame buffer device in kernel space,
746  - offset     : offset (in bytes) in the frame buffer
747  - buffer     : base address of the user buffer
748  - length     : number of bytes to be transfered
749  It returns 0 when the transfer can be started.
750  It returns -1 if the buffer is not in user address space.
751  The transfer completion is signaled by an IRQ, and must be
752  tested by the fb_completed() function.
753 ********************************************************************/
754int fb_write(size_t offset, void* buffer, size_t length)
755{
756    return sys_call(SYSCALL_FB_WRITE,
757            offset,
758            (int)buffer,
759            length,
760            0);
761}
762/********************************************************************
763  fb_read()
764  This non-blocking function use the DMA coprocessor to transfer data
765  from the frame buffer device in kernel space to an user buffer.
766  - offset     : offset (in bytes) in the frame buffer
767  - buffer     : base address of the memory buffer
768  - length     : number of bytes to be transfered
769  It returns 0 when the transfer can be started.
770  It returns -1 if the buffer is not in user address space.
771  The transfer completion is signaled by an IRQ, and must be
772  tested by the fb_completed() function.
773 ********************************************************************/
774int fb_read(size_t offset, void* buffer, size_t length)
775{
776    return sys_call(SYSCALL_FB_READ,
777            offset,
778            (int)buffer,
779            length,
780            0);
781}
782/********************************************************************
783  fb_completed()
784  This blocking function returns when the transfer is completed.
785  It returns 0 if the transfer is successful.
786  It returns -1 if an address error has been detected.
787 ********************************************************************/
788int fb_completed()
789{
790    return sys_call(SYSCALL_FB_COMPLETED,
791            0, 0, 0, 0);
792}
793
794/********************************************************************
795  SYNCHRONISATION BARRIERS
796 *********************************************************************
797  barrier_init()
798  This function initializes the counter for barrier[index].
799  - index     : index of the barrier (between 0 & 7)
800  - count     : number of tasks to be synchronized.
801  The GIET supports up to 8 independant barriers.
802  It returns a non zero value when the barrier index is larger than 7.
803* ********************************************************************/
804int barrier_init(size_t index, size_t count)
805{
806    return sys_call(SYSCALL_BARRIER_INIT,
807            (int)index,
808            (int)count,
809            0, 0);
810}
811/********************************************************************
812  barrier_wait()
813  This blocking function use a busy waiting policy, and returns only
814  when all synchonized asks have reached the barrier.
815  - index     : index of the barrier (between 0 & 7)
816  The GIET supports up to 8 independant barriers.
817  It returns a non zero value when the barrier index is larger than 7.
818 ********************************************************************/
819int barrier_wait(size_t index)
820{
821    return sys_call(SYSCALL_BARRIER_WAIT,
822            (int)index,
823            0, 0, 0);
824}
825// Local Variables:
826// tab-width: 4;
827// c-basic-offset: 4;
828// c-file-offsets:((innamespace . 0)(inline-open . 0));
829// indent-tabs-mode: nil;
830// End:
831//
832// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
833
Note: See TracBrowser for help on using the repository browser.