source: soft/giet_vm/giet_libs/stdio.c @ 521

Last change on this file since 521 was 521, checked in by alain, 9 years ago

Introducing in the stdio.c / stdio.h files the system calls
related to the hardware coprocessors configuration and use.

  • Property svn:executable set to *
File size: 28.2 KB
Line 
1//////////////////////////////////////////////////////////////////////////////
2// File     : stdio.c         
3// Date     : 01/04/2010
4// Author   : alain greiner & Joel Porquet
5// Copyright (c) UPMC-LIP6
6//////////////////////////////////////////////////////////////////////////////
7
8#include <stdarg.h>
9#include <stdio.h>
10#include <giet_config.h>
11
12//////////////////////////////////////////////////////////////////////////////
13/////////////////////  MIPS32     related system calls ///////////////////////
14//////////////////////////////////////////////////////////////////////////////
15
16////////////////////////////////////////////
17void giet_proc_xyp( unsigned int* cluster_x,
18                    unsigned int* cluster_y,
19                    unsigned int* lpid )
20{
21    sys_call( SYSCALL_PROC_XYP,
22              (unsigned int)cluster_x,
23              (unsigned int)cluster_y,
24              (unsigned int)lpid,
25               0 );
26}
27
28////////////////////////////
29unsigned int giet_proctime() 
30{
31    return (unsigned int)sys_call( SYSCALL_PROC_TIME, 
32                                   0, 0, 0, 0 );
33}
34
35////////////////////////
36unsigned int giet_rand() 
37{
38    unsigned int x = (unsigned int)sys_call( SYSCALL_PROC_TIME,
39                                             0, 0, 0, 0);
40    if ((x & 0xF) > 7) 
41    {
42        return (x*x & 0xFFFF);
43    }
44    else 
45    {
46        return (x*x*x & 0xFFFF);
47    }
48}
49
50//////////////////////////////////////////////////////////////////////////////
51///////////////////// Task context  system calls /////////////////////////////
52//////////////////////////////////////////////////////////////////////////////
53
54////////////////////////////////
55unsigned int giet_proc_task_id() 
56{
57    return (unsigned int)sys_call( SYSCALL_LOCAL_TASK_ID, 
58                                   0, 0, 0, 0 );
59}
60
61//////////////////////////////////
62unsigned int giet_global_task_id() 
63{
64    return (unsigned int)sys_call( SYSCALL_GLOBAL_TASK_ID, 
65                                   0, 0, 0, 0 );
66}
67
68/////////////////////////////
69unsigned int giet_thread_id() 
70{
71    return (unsigned int)sys_call( SYSCALL_THREAD_ID, 
72                                   0, 0, 0, 0 );
73}
74
75
76//////////////////////////////////////////////////////////////////////////////
77///////////////////// Coprocessors  system calls  ////////////////////////////
78//////////////////////////////////////////////////////////////////////////////
79
80///////////////////////////////////////////////////
81void giet_coproc_alloc( unsigned int   coproc_type,
82                        unsigned int*  coproc_info,
83                        unsigned int*  cluster_xy )
84{
85    if ( sys_call( SYSCALL_COPROC_ALLOC,
86                   coproc_type,
87                   (unsigned int)coproc_info,
88                   (unsigned int)cluster_xy,
89                   0 ) ) 
90        giet_exit("error in giet_coproc_alloc()");
91}
92
93///////////////////////////////////////////////////
94void giet_coproc_release( unsigned int cluster_xy )
95{
96    if ( sys_call( SYSCALL_COPROC_RELEASE,
97                   cluster_xy,
98                   0, 0, 0 ) ) 
99        giet_exit("error in giet_coproc_release()");
100}
101
102//////////////////////////////////////////////////////////////////
103void giet_coproc_channel_init( unsigned int            cluster_xy,
104                               unsigned int            channel,
105                               giet_coproc_channel_t*  desc )
106{
107    if ( sys_call( SYSCALL_COPROC_CHANNEL_INIT,
108                   cluster_xy,
109                   channel,
110                   (unsigned int)desc,
111                   0 ) ) 
112        giet_exit("error in giet_coproc_channel_init");
113}
114
115////////////////////////////////////////////////////////////
116void giet_coproc_channel_start( unsigned int     cluster_xy,
117                                unsigned int     channel )
118{
119    if ( sys_call( SYSCALL_COPROC_CHANNEL_START,
120                   cluster_xy,
121                   channel,
122                   0, 0 ) ) 
123        giet_exit("error in giet_coproc_channel_start");
124}
125
126///////////////////////////////////////////////////////////
127void giet_coproc_channel_stop( unsigned int     cluster_xy,
128                               unsigned int     channel )
129{
130    if ( sys_call( SYSCALL_COPROC_CHANNEL_STOP,
131                   cluster_xy,
132                   channel,
133                   0, 0 ) ) 
134        giet_exit("error in giet_coproc_channel_stop");
135}
136
137/////////////////////////////////////////////////////////
138void giet_coproc_completed( unsigned int     cluster_xy )
139{
140    if ( sys_call( SYSCALL_COPROC_COMPLETED,
141                   cluster_xy,
142                   0, 0, 0 ) ) 
143        giet_exit("error in giet_coproc_completed");
144}
145
146///////////////////////////////////////////////////////////
147void giet_coproc_register_set( unsigned int     cluster_xy,
148                               unsigned int     index,
149                               unsigned int     value )
150{
151    if ( sys_call( SYSCALL_COPROC_REGISTER_SET,
152                   cluster_xy,
153                   index,
154                   value,
155                   0 ) ) 
156        giet_exit("error in giet_coproc_register_set");
157}
158
159///////////////////////////////////////////////////////////
160void giet_coproc_register_get( unsigned int     cluster_xy,
161                               unsigned int     index,
162                               unsigned int*    value )
163{
164    if ( sys_call( SYSCALL_COPROC_REGISTER_SET,
165                   cluster_xy,
166                   index,
167                   (unsigned int)value,
168                   0 ) ) 
169        giet_exit("error in giet_coproc_register_get");
170}
171
172
173//////////////////////////////////////////////////////////////////////////////
174/////////////////////  TTY device related system calls ///////////////////////
175//////////////////////////////////////////////////////////////////////////////
176
177/////////////////////
178void giet_tty_alloc()
179{
180    if ( sys_call( SYSCALL_TTY_ALLOC,
181                   0, 0, 0, 0 ) )  giet_exit("error in giet_tty_alloc()");
182}
183
184////////////////////////////////////////////////////////////////////////
185static  int __printf( char* format, unsigned int channel, va_list* args) 
186{
187    int ret;                    // return value from the syscall
188
189printf_text:
190
191    while (*format) 
192    {
193        unsigned int i;
194        for (i = 0 ; format[i] && (format[i] != '%') ; i++);
195        if (i) 
196        {
197            ret = sys_call(SYSCALL_TTY_WRITE, 
198                           (unsigned int)format,
199                           i, 
200                           channel,
201                           0);
202
203            if (ret != i) goto return_error;
204
205            format += i;
206        }
207        if (*format == '%') 
208        {
209            format++;
210            goto printf_arguments;
211        }
212    }
213
214    return 0;
215
216printf_arguments:
217
218    {
219        char buf[20];
220        char * pbuf;
221        unsigned int len = 0;
222        static const char HexaTab[] = "0123456789ABCDEF";
223        unsigned int i;
224
225        switch (*format++) 
226        {
227            case ('c'):             /* char conversion */
228            {
229                int val = va_arg( *args, int );
230                len = 1;
231                buf[0] = val;
232                pbuf = &buf[0];
233                break;
234            }
235            case ('d'):             /* 32 bits decimal signed integer */
236            {
237                int val = va_arg( *args, int );
238                if (val < 0) 
239                {
240                    val = -val;
241                    ret = sys_call(SYSCALL_TTY_WRITE, 
242                                   (unsigned int)"-",
243                                   1,
244                                   channel,
245                                   0);
246                    if (ret != 1) goto return_error;
247                }
248                for(i = 0; i < 10; i++) 
249                {
250                    buf[9 - i] = HexaTab[val % 10];
251                    if (!(val /= 10)) break;
252                }
253                len =  i + 1;
254                pbuf = &buf[9 - i];
255                break;
256            }
257            case ('u'):             /* 32 bits decimal unsigned integer */
258            {
259                unsigned int val = va_arg( *args, unsigned int );
260                for(i = 0; i < 10; i++) 
261                {
262                    buf[9 - i] = HexaTab[val % 10];
263                    if (!(val /= 10)) break;
264                }
265                len =  i + 1;
266                pbuf = &buf[9 - i];
267                break;
268            }
269            case ('x'):             /* 32 bits hexadecimal integer */
270            {
271                unsigned int val = va_arg( *args, unsigned int );
272                ret = sys_call(SYSCALL_TTY_WRITE,
273                               (unsigned int)"0x",
274                               2,
275                               channel,
276                               0);
277                if (ret != 2) goto return_error;       
278                for(i = 0; i < 8; i++) 
279                {
280                    buf[7 - i] = HexaTab[val % 16];
281                    if (!(val /= 16))  break;
282                }
283                len =  i + 1;
284                pbuf = &buf[7 - i];
285                break;
286            }
287            case ('l'):            /* 64 bits hexadecimal unsigned */
288            {
289                unsigned long long val = va_arg( *args, unsigned long long );
290                ret = sys_call(SYSCALL_TTY_WRITE,
291                               (unsigned int)"0x",
292                               2,
293                               channel,
294                               0);
295                if (ret != 2) goto return_error;
296                for(i = 0; i < 16; i++) 
297                {
298                    buf[15 - i] = HexaTab[val % 16];
299                    if (!(val /= 16))  break;
300                }
301                len =  i + 1;
302                pbuf = &buf[15 - i];
303                break;
304            }
305            case ('s'):             /* string */
306            {
307                char* str = va_arg( *args, char* );
308                while (str[len]) 
309                {
310                    len++;
311                }
312                pbuf = str;
313                break;
314            }
315            default:
316                goto return_error;
317        }
318
319        ret = sys_call(SYSCALL_TTY_WRITE, 
320                       (unsigned int)pbuf,
321                       len,
322                       channel, 
323                       0);
324        if (ret != len)  goto return_error;
325       
326        goto printf_text;
327    }
328
329return_error:
330    return 1;
331} // end __printf()
332
333
334////////////////////////////////////////
335void giet_tty_printf( char* format, ...) 
336{
337    va_list args;
338
339    va_start( args, format );
340    int ret = __printf(format, 0xFFFFFFFF, &args);
341    va_end( args );
342
343    if (ret)
344    {
345        giet_exit("ERROR in giet_tty_printf()");
346    }
347} // end giet_tty_printf()
348
349////////////////////////////////////////
350void giet_shr_printf( char* format, ...) 
351{
352    va_list args;
353    volatile unsigned int sr_save;
354
355    sys_call( SYSCALL_TTY_GET_LOCK,
356              0,
357              (unsigned int)&sr_save,
358              0, 0 );
359
360    va_start( args, format );
361    int ret = __printf(format, 0, &args);
362    va_end( args );
363
364    sys_call( SYSCALL_TTY_RELEASE_LOCK,
365              0,
366              (unsigned int)&sr_save,
367              0, 0 );
368
369    if (ret)
370    {
371        giet_exit("error in giet_shr_printf()");
372    }
373} // end giet_shr_printf()
374
375/////////////////////////////////
376void giet_tty_getc( char * byte ) 
377{
378    int ret;
379
380    do
381    {
382        ret = sys_call(SYSCALL_TTY_READ, 
383                      (unsigned int)byte,  // buffer address
384                      1,                   // number of characters
385                      0xFFFFFFFF,          // channel index from task context
386                      0);
387        if ( ret < 0 ) giet_exit("error in giet_tty_getc()");
388    }
389    while (ret != 1); 
390}
391
392/////////////////////////////////////
393void giet_tty_gets( char*        buf, 
394                    unsigned int bufsize ) 
395{
396    int           ret;
397    unsigned char byte;
398    unsigned int  index = 0;
399 
400    while (index < (bufsize - 1)) 
401    {
402        do 
403        { 
404            ret = sys_call(SYSCALL_TTY_READ, 
405                           (unsigned int)(&byte),
406                           1,
407                           0xFFFFFFFF,
408                           0);
409            if ( ret < 0 ) giet_exit("error in giet_tty_gets()");
410        } 
411        while (ret != 1);
412
413        if (byte == 0x0A)  /* LF */
414        {
415            break; 
416        }
417        else if ((byte == 0x7F) && (index > 0))  /* DEL */
418        {
419            index--; 
420        }
421        else 
422        {
423            buf[index] = byte;
424            index++;
425        }
426    }
427    buf[index] = 0;
428}
429
430///////////////////////////////////////
431void giet_tty_getw( unsigned int* val ) 
432{
433    unsigned char buf[32];
434    unsigned int  string_byte   = 0x00000000;    // string containing one single byte
435    unsigned int  string_cancel = 0x00082008;    // string containing BS/SPACE/BS
436    unsigned int  save = 0;
437    unsigned int  dec = 0;
438    unsigned int  done = 0;
439    unsigned int  overflow = 0;
440    unsigned int  length = 0;
441    unsigned int  i;
442    unsigned int  channel = 0xFFFFFFFF;
443    int           ret;      // return value from syscalls
444 
445    // get characters
446    while (done == 0) 
447    {
448        // read one character
449        do 
450        { 
451            ret = sys_call( SYSCALL_TTY_READ,
452                            (unsigned int)(&string_byte),
453                            1,
454                            channel, 
455                            0); 
456            if ( ret < 0 ) giet_exit("error in giet_tty_getw()");
457        } 
458        while (ret != 1);
459
460        // analyse character
461        if ((string_byte > 0x2F) && (string_byte < 0x3A))  /* decimal character */
462        {
463            buf[length] = (unsigned char)string_byte;
464            length++;
465
466            // echo
467            ret = sys_call( SYSCALL_TTY_WRITE, 
468                            (unsigned int)(&string_byte),
469                            1, 
470                            channel, 
471                            0 );
472            if ( ret < 0 ) giet_exit("error in giet_tty_gets()");
473        }
474        else if (string_byte == 0x0A)                     /* LF character */
475        {
476            done = 1;
477        }
478        else if ( (string_byte == 0x7F) ||                /* DEL character */
479                  (string_byte == 0x08) )                 /* BS  character */
480        {
481            if ( length > 0 ) 
482            {
483                length--;    // cancel the character
484
485                ret = sys_call( SYSCALL_TTY_WRITE, 
486                                (unsigned int)(&string_cancel),
487                                3, 
488                                channel, 
489                                0 );
490                if ( ret < 0 ) giet_exit("error in giet_tty_getw()");
491            }
492        }
493
494        // test buffer overflow
495        if ( length >= 32 ) 
496        {
497            overflow = 1;
498            done     = 1;
499        }
500    }  // end while characters
501
502    // string to int conversion with overflow detection
503    if ( overflow == 0 )
504    {
505        for (i = 0; (i < length) && (overflow == 0) ; i++) 
506        {
507            dec = dec * 10 + (buf[i] - 0x30);
508            if (dec < save)  overflow = 1; 
509            save = dec;
510        }
511    } 
512
513    // final evaluation
514    if ( overflow == 0 )
515    {
516        // return value
517        *val = dec;
518    }
519    else
520    {
521        // cancel all echo characters
522        for (i = 0; i < length ; i++) 
523        {
524            ret = sys_call( SYSCALL_TTY_WRITE, 
525                            (unsigned int)(&string_cancel),
526                            3, 
527                            channel, 
528                            0 );
529            if ( ret < 0 ) giet_exit("error in giet_tty_getw()");
530        }
531        // echo character '0'
532        string_byte = 0x30;
533        ret = sys_call( SYSCALL_TTY_WRITE, 
534                        (unsigned int)(&string_byte),
535                        1, 
536                        channel, 
537                        0 );
538        if ( ret < 0 ) giet_exit("error in giet_tty_getw()");
539
540        // return 0 value
541        *val = 0;
542    }
543}
544
545
546//////////////////////////////////////////////////////////////////////////////////
547/////////////////////  TIMER related system calls ////////////////////////////////
548//////////////////////////////////////////////////////////////////////////////////
549
550///////////////////////
551void giet_timer_alloc() 
552{
553    if ( sys_call( SYSCALL_TIM_ALLOC,
554                   0, 0, 0, 0 ) ) giet_exit("error in giet_timer_alloc()");
555}
556
557////////////////////////////////////////////
558void giet_timer_start( unsigned int period ) 
559{
560    if ( sys_call( SYSCALL_TIM_START,
561                   period,
562                   0, 0, 0 ) ) giet_exit("error in giet_timer_start()");
563}
564
565//////////////////////
566void giet_timer_stop() 
567{
568    if ( sys_call( SYSCALL_TIM_STOP,
569                   0, 0, 0, 0 ) ) giet_exit("error in giet_timer_stop()");
570}
571
572
573//////////////////////////////////////////////////////////////////////////////////
574///////////////  Frame buffer device related system calls  ///////////////////////
575//////////////////////////////////////////////////////////////////////////////////
576
577/////////////////////////
578void giet_fbf_cma_alloc()
579{
580    if ( sys_call( SYSCALL_FBF_CMA_ALLOC, 
581                   0, 0, 0, 0 ) )    giet_exit("error in giet_fbf_cma_alloc()");
582}
583
584///////////////////////////////////////////
585void giet_fbf_cma_start( void *       buf0,
586                         void *       buf1,
587                         unsigned int length )
588{
589    if ( sys_call( SYSCALL_FBF_CMA_START,
590                   (unsigned int)buf0, 
591                   (unsigned int)buf1, 
592                   length,
593                   0 ) )   giet_exit("error in giet_fbf_cma_start()");
594}
595
596////////////////////////////////////////////////
597void giet_fbf_cma_display( unsigned int buffer )
598{
599    if ( sys_call( SYSCALL_FBF_CMA_DISPLAY,
600                   buffer, 
601                   0, 0, 0 ) )   giet_exit("error in giet_fbf_cma_display()");
602}
603
604////////////////////////
605void giet_fbf_cma_stop()
606{
607    if ( sys_call( SYSCALL_FBF_CMA_STOP, 
608                   0, 0, 0, 0 ) )    giet_exit("error in giet_fbf_cma_stop()");
609}
610
611//////////////////////////////////////////////
612void giet_fbf_sync_write( unsigned int offset, 
613                          void *       buffer, 
614                          unsigned int length ) 
615{
616    if ( sys_call( SYSCALL_FBF_SYNC_WRITE, 
617                   offset, 
618                   (unsigned int)buffer, 
619                   length, 
620                   0 ) )  giet_exit("error in giet_fbf_sync_write()");
621}
622
623/////////////////////////////////////////////
624void giet_fbf_sync_read( unsigned int offset, 
625                         void *       buffer, 
626                         unsigned int length ) 
627{
628    if ( sys_call( SYSCALL_FBF_SYNC_READ, 
629                   offset, 
630                   (unsigned int)buffer, 
631                   length, 
632                   0 ) )   giet_exit("error in giet_fbf_sync_read()");
633}
634
635
636//////////////////////////////////////////////////////////////////////////////////
637/////////////////////// NIC related system calls /////////////////////////////////
638//////////////////////////////////////////////////////////////////////////////////
639
640////////////////////////////////////////////////////
641unsigned int giet_nic_rx_alloc( unsigned int xmax,
642                                unsigned int ymax )
643{
644    int channel = sys_call( SYSCALL_NIC_ALLOC,
645                            1, 
646                            xmax,
647                            ymax,
648                            0 );
649    if ( channel < 0 ) giet_exit("error in giet_nic_rx_alloc()");
650
651    return (unsigned int)channel;
652}
653
654////////////////////////////////////////////////////
655unsigned int giet_nic_tx_alloc( unsigned int xmax,
656                                unsigned int ymax )
657{
658    int channel = sys_call( SYSCALL_NIC_ALLOC,
659                            0,
660                            xmax,
661                            ymax,
662                            0 );
663    if ( channel < 0 ) giet_exit("error in giet_nic_tx_alloc()");
664
665    return (unsigned int)channel;
666}
667
668//////////////////////////////////////////////
669void giet_nic_rx_start( unsigned int channel )
670{
671    if ( sys_call( SYSCALL_NIC_START,
672                   1,
673                   channel,
674                   0, 0 ) ) giet_exit("error in giet_nic_rx_start()");
675}
676
677//////////////////////////////////////////////
678void giet_nic_tx_start( unsigned int channel )
679{
680    if ( sys_call( SYSCALL_NIC_START,
681                   0, 
682                   channel,
683                   0, 0 ) ) giet_exit("error in giet_nic_tx_start()");
684}
685
686///////////////////////////////////////////////////////////
687void giet_nic_rx_move( unsigned int channel, void* buffer )
688{
689    if ( sys_call( SYSCALL_NIC_MOVE,
690                   1,
691                   channel, 
692                   (unsigned int)buffer,
693                   0 ) )  giet_exit("error in giet_nic_rx_move()");
694}
695
696///////////////////////////////////////////////////////////
697void giet_nic_tx_move( unsigned int channel, void* buffer )
698{
699    if ( sys_call( SYSCALL_NIC_MOVE,
700                   0,
701                   channel, 
702                   (unsigned int)buffer,
703                   0 ) )  giet_exit("error in giet_nic_tx_move()");
704}
705
706/////////////////////////////////////////////
707void giet_nic_rx_stop( unsigned int channel )
708{
709    if ( sys_call( SYSCALL_NIC_STOP,
710                   1, 
711                   channel,
712                   0, 0 ) ) giet_exit("error in giet_nic_rx_stop()");
713}
714
715/////////////////////////////////////////////
716void giet_nic_tx_stop( unsigned int channel )
717{
718    if ( sys_call( SYSCALL_NIC_STOP,
719                   0, 
720                   channel,
721                   0, 0 ) ) giet_exit("error in giet_nic_tx_stop()");
722}
723
724//////////////////////////////////////////////
725void giet_nic_rx_stats( unsigned int channel )
726{
727    if ( sys_call( SYSCALL_NIC_STATS,
728                   1, 
729                   channel,
730                   0, 0 ) ) giet_exit("error in giet_nic_rx_stats()");
731}
732
733//////////////////////////////////////////////
734void giet_nic_tx_stats( unsigned int channel )
735{
736    if ( sys_call( SYSCALL_NIC_STATS,
737                   0, 
738                   channel,
739                   0, 0 ) ) giet_exit("error in giet_nic_tx_stats()");
740}
741
742//////////////////////////////////////////////
743void giet_nic_rx_clear( unsigned int channel )
744{
745    if ( sys_call( SYSCALL_NIC_CLEAR,
746                   1, 
747                   channel,
748                   0, 0 ) ) giet_exit("error in giet_nic_rx_clear()");
749}
750
751//////////////////////////////////////////////
752void giet_nic_tx_clear( unsigned int channel )
753{
754    if ( sys_call( SYSCALL_NIC_CLEAR,
755                   0, 
756                   channel,
757                   0, 0 ) ) giet_exit("error in giet_nic_tx_clear()");
758}
759
760
761
762///////////////////////////////////////////////////////////////////////////////////
763///////////////////// FAT related system calls ////////////////////////////////////
764///////////////////////////////////////////////////////////////////////////////////
765
766///////////////////////////////////////////
767int giet_fat_open( const char*   pathname, 
768                   unsigned int  flags )
769{
770    return sys_call( SYSCALL_FAT_OPEN, 
771                     (unsigned int)pathname, 
772                     flags,
773                     0, 0 );
774}
775
776////////////////////////////////////
777void giet_fat_read( unsigned int fd,     
778                    void*        buffer, 
779                    unsigned int count, 
780                    unsigned int offset ) 
781{
782    if ( sys_call( SYSCALL_FAT_READ,
783                   fd, 
784                   (unsigned int)buffer,
785                   count, 
786                   offset ) != count ) giet_exit("ERROR in giet_fat_read()");
787}
788
789/////////////////////////////////////
790void giet_fat_write( unsigned int fd,
791                     void*        buffer, 
792                     unsigned int count,
793                     unsigned int offset )
794{
795    if ( sys_call( SYSCALL_FAT_WRITE, 
796                   fd, 
797                   (unsigned int)buffer,
798                   count, 
799                   offset ) != count ) giet_exit("ERROR in giet_fat_write()");
800}
801
802/* variant implementing the UNIX spec
803///////////////////////////////////////////////////////////////////////////////////
804// This system call writes to a file identified by the "fd" file descriptor.
805// - "buffer" is the source buffer virtual address (must be word aligned).
806// - "count" is a number of bytes (must be multiple of 4).
807// It uses the implicit "lseek" pointer in file descriptor.
808///////////////////////////////////////////////////////////////////////////////////
809void giet_fat_write( unsigned int fd,
810                    void*        buffer,
811                    unsigned int count )  // number of bytes
812{
813    return sys_call( SYSCALL_FAT_WRITE,
814                     fd,
815                     (unsigned int)buffer,
816                     count, 0 );
817}
818*/
819
820/////////////////////////////////////
821void giet_fat_lseek( unsigned int fd, 
822                    unsigned int offset, 
823                    unsigned int whence )
824{
825    if ( sys_call( SYSCALL_FAT_LSEEK, 
826                   fd, 
827                   offset, 
828                   whence, 
829                   0 ) ) giet_exit("ERROR in giet_fat_lseek()");
830}
831
832//////////////////////////////////////
833void giet_fat_fstat( unsigned int fd )
834{
835    if ( sys_call( SYSCALL_FAT_FSTAT,
836                   fd,
837                   0, 0, 0 ) )  giet_exit("ERROR in giet_fat_lseek()");
838}
839
840/////////////////////////////////////
841void giet_fat_close( unsigned int fd )
842{
843    if ( sys_call( SYSCALL_FAT_CLOSE,
844                   fd,
845                   0, 0, 0 ) )  giet_exit("ERROR in giet_fat_close()");
846}
847
848
849
850
851//////////////////////////////////////////////////////////////////////////////////
852///////////////////// Miscellaneous system calls /////////////////////////////////
853//////////////////////////////////////////////////////////////////////////////////
854
855//////////////////////////////
856void giet_exit( char* string ) 
857{
858    sys_call( SYSCALL_EXIT,
859              (unsigned int)string,
860              0, 0, 0 );
861}
862
863/////////////////////////////////////////
864void giet_assert( unsigned int condition,
865                  char*        string )
866{
867    if ( condition == 0 ) giet_exit( string );
868}
869
870//////////////////////////
871void giet_context_switch() 
872{
873    sys_call( SYSCALL_CTX_SWITCH,
874              0, 0, 0, 0 );
875}
876
877/////////////////////////////////////////////////
878void giet_procs_number( unsigned int* x_size, 
879                        unsigned int* y_size,
880                        unsigned int* nprocs ) 
881{
882    if ( sys_call( SYSCALL_PROCS_NUMBER, 
883                   (unsigned int)x_size, 
884                   (unsigned int)y_size, 
885                   (unsigned int)nprocs, 
886                   0 ) )  giet_exit("ERROR in giet_procs_number()");
887}
888
889////////////////////////////////////////////////////
890void giet_vobj_get_vbase( char*         vspace_name, 
891                          char*         vobj_name, 
892                          unsigned int* vbase ) 
893{
894    if ( sys_call( SYSCALL_VOBJ_GET_VBASE, 
895                   (unsigned int) vspace_name,
896                   (unsigned int) vobj_name,
897                   (unsigned int) vbase,
898                   0 ) )  giet_exit("ERROR in giet_vobj_get_vbase()");
899}
900
901////////////////////////////////////////////////////
902void giet_vobj_get_length( char*         vspace_name, 
903                           char*         vobj_name, 
904                           unsigned int* length ) 
905{
906    if ( sys_call( SYSCALL_VOBJ_GET_LENGTH, 
907                   (unsigned int) vspace_name,
908                   (unsigned int) vobj_name,
909                   (unsigned int) length,
910                   0 ) )  giet_exit("ERROR in giet_vobj_get_length()");
911}
912
913/////////////////////////////////////////
914void giet_heap_info( unsigned int* vaddr, 
915                     unsigned int* length,
916                     unsigned int  x,
917                     unsigned int  y ) 
918{
919    if ( sys_call( SYSCALL_HEAP_INFO, 
920                   (unsigned int)vaddr, 
921                   (unsigned int)length, 
922                   x,
923                   y ) )  giet_exit("ERROR in giet_heap_info()");
924}
925
926/////////////////////////////////////////
927void giet_get_xy( void*         ptr,
928                  unsigned int* px,
929                  unsigned int* py )
930{
931    if ( sys_call( SYSCALL_GET_XY,
932                   (unsigned int)ptr,
933                   (unsigned int)px,
934                   (unsigned int)py,
935                   0 ) )  giet_exit("ERROR in giet_get_xy()");
936}
937
938// Local Variables:
939// tab-width: 4
940// c-basic-offset: 4
941// c-file-offsets:((innamespace . 0)(inline-open . 0))
942// indent-tabs-mode: nil
943// End:
944// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
945
Note: See TracBrowser for help on using the repository browser.