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

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

Introduce user-level, distributed barriers and locks (quad-tree based).

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