Ignore:
Timestamp:
Feb 12, 2013, 6:33:31 PM (11 years ago)
Author:
meunier
Message:

Added support for memspaces and const.
Added an interrupt masking to the "giet_context_switch" syscall
Corrected two bugs in boot/boot_init.c (one minor and one regarding barriers initialization)
Reformatted the code in all files.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • soft/giet_vm/libs/stdio.c

    r218 r228  
    2121#define SYSCALL_GCD_WRITE       0x06
    2222#define SYSCALL_GCD_READ        0x07
     23#define SYSCALL_TASK_ID         0x09
    2324#define SYSCALL_CTX_SWITCH      0x0D
    2425#define SYSCALL_EXIT            0x0E
     
    3233#define SYSCALL_IOC_READ        0x16
    3334#define SYSCALL_IOC_COMPLETED   0x17
    34 #define SYSCALL_VOBJ_GET_VBASE  0x1A
     35#define SYSCALL_VOBJ_GET_VBASE  0x1A
    3536#define SYSCALL_NIC_WRITE       0x1B
    3637#define SYSCALL_NIC_READ        0x1C
     
    4344// and tells GCC what has been modified by system call execution.
    4445//////////////////////////////////////////////////////////////////////////////////
    45 static inline unsigned int sys_call( unsigned int call_no,
    46                                      unsigned int arg_0,
    47                                      unsigned int arg_1,
    48                                      unsigned int arg_2,
    49                                      unsigned int arg_3)
    50 {
     46static inline unsigned int sys_call(unsigned int call_no,
     47        unsigned int arg_0,
     48        unsigned int arg_1,
     49        unsigned int arg_2,
     50        unsigned int arg_3) {
    5151    register unsigned int reg_no_and_output asm("v0") = call_no;
    52     register unsigned int reg_a0            asm("a0") = arg_0;
    53     register unsigned int reg_a1            asm("a1") = arg_1;
    54     register unsigned int reg_a2            asm("a2") = arg_2;
    55     register unsigned int reg_a3            asm("a3") = arg_3;
     52    register unsigned int reg_a0 asm("a0") = arg_0;
     53    register unsigned int reg_a1 asm("a1") = arg_1;
     54    register unsigned int reg_a2 asm("a2") = arg_2;
     55    register unsigned int reg_a3 asm("a3") = arg_3;
    5656
    5757    asm volatile(
     
    5959            : "=r" (reg_no_and_output)  /* output argument */
    6060            : "r" (reg_a0),             /* input arguments */
    61               "r" (reg_a1),
    62               "r" (reg_a2),
    63               "r" (reg_a3),
    64               "r" (reg_no_and_output)
     61            "r" (reg_a1),
     62            "r" (reg_a2),
     63            "r" (reg_a3),
     64            "r" (reg_no_and_output)
    6565            : "memory",
    6666            /* These persistant registers will be saved on the stack by the
     
    8383}
    8484
    85 /////   MIPS32 related system calls  /////
     85/////     MIPS32 related system calls  /////
    8686
    8787////////////////////////////////////////////////////////////////////////////////////
     
    9090// This function returns the processor identifier.
    9191////////////////////////////////////////////////////////////////////////////////////
    92 unsigned int giet_procid()
    93 {
    94     return sys_call(SYSCALL_PROCID,
    95                     0, 0, 0, 0);
    96 }
     92unsigned int giet_procid() {
     93    return sys_call(SYSCALL_PROCID, 0, 0, 0, 0);
     94}
     95
     96
    9797////////////////////////////////////////////////////////////////////////////////////
    9898// giet_proctime()
     
    100100// This function returns the local processor time (clock cycles since boot)
    101101////////////////////////////////////////////////////////////////////////////////////
    102 unsigned int giet_proctime()
    103 {
    104     return sys_call(SYSCALL_PROCTIME,
    105                     0, 0, 0, 0);
    106 }
    107 
    108 //////  TTY device related system calls /////
     102unsigned int giet_proctime() {
     103    return sys_call(SYSCALL_PROCTIME, 0, 0, 0, 0);
     104}
     105
     106
     107//////     TTY device related system calls /////
    109108
    110109////////////////////////////////////////////////////////////////////////////////////
     
    116115// - Returns 1 if the character has been written, 0 otherwise.
    117116////////////////////////////////////////////////////////////////////////////////////
    118 unsigned int giet_tty_putc(char byte)
    119 {
    120     return sys_call(SYSCALL_TTY_WRITE,
    121                     (unsigned int)(&byte),
    122                     1,
    123                     0,0);
    124 }
     117unsigned int giet_tty_putc(char byte) {
     118    return sys_call(SYSCALL_TTY_WRITE, (unsigned int) (&byte), 1, 0, 0);
     119}
     120
     121
    125122////////////////////////////////////////////////////////////////////////////////////
    126123// giet_tty_puts()
     
    132129// - Returns the number of written characters.
    133130////////////////////////////////////////////////////////////////////////////////////
    134 unsigned int giet_tty_puts(char *buf)
    135 {
     131unsigned int giet_tty_puts(char * buf) {
    136132    unsigned int length = 0;
    137     while (buf[length] != 0)
    138     {
     133    while (buf[length] != 0) {
    139134        length++;
    140135    }
    141     return sys_call(SYSCALL_TTY_WRITE,
    142                     (unsigned int)buf,
    143                     length,
    144                     0,0);
    145 }
     136    return sys_call(SYSCALL_TTY_WRITE, (unsigned int) buf, length, 0, 0);
     137}
     138
     139
    146140////////////////////////////////////////////////////////////////////////////////////
    147141// giet_tty_putw()
     
    152146// Returns the number of written characters (should be equal to ten).
    153147////////////////////////////////////////////////////////////////////////////////////
    154 unsigned int giet_tty_putw(unsigned int val)
    155 {
     148unsigned int giet_tty_putw(unsigned int val) {
    156149    char buf[10];
    157150    unsigned int i;
    158     for (i = 0; i < 10; i++)
    159     {
    160         buf[9-i] = (val % 10) + 0x30;
     151    for (i = 0; i < 10; i++) {
     152        buf[9 - i] = (val % 10) + 0x30;
    161153        val = val / 10;
    162154    }
    163     return sys_call(SYSCALL_TTY_WRITE,
    164                     (unsigned int)buf,
    165                     10,
    166                     0,0);
    167 }
     155    return sys_call(SYSCALL_TTY_WRITE, (unsigned int) buf, 10, 0, 0);
     156}
     157
     158
    168159////////////////////////////////////////////////////////////////////////////////////
    169160// giet_tty_getc()
     
    174165// - Returns 0 when completed.
    175166////////////////////////////////////////////////////////////////////////////////////
    176 unsigned int giet_tty_getc(char *byte)
    177 {
     167unsigned int giet_tty_getc(char * byte) {
    178168    unsigned int ret = 0;
    179     while (ret == 0)
    180     {
    181         ret = sys_call(SYSCALL_TTY_READ,
    182                        (unsigned int)byte,
    183                        1,
    184                        0,0);
     169    while (ret == 0) {
     170        ret = sys_call(SYSCALL_TTY_READ, (unsigned int)byte, 1, 0, 0);
    185171    }
    186172    return 0;
    187173}
     174
     175
    188176////////////////////////////////////////////////////////////////////////////////////
    189177// giet_tty_gets()
     
    201189//   removed from the target buffer.
    202190////////////////////////////////////////////////////////////////////////////////////
    203 unsigned int giet_tty_gets( char*                       buf,
    204                             unsigned int        bufsize )
    205 {
     191unsigned int giet_tty_gets(char * buf, unsigned int bufsize) {
    206192    unsigned int ret;
    207193    unsigned char byte;
    208194    unsigned int index = 0;
    209195
    210     while (index < (bufsize - 1))
    211     {
     196    while (index < (bufsize - 1)) {
    212197        do {
    213             ret = sys_call(SYSCALL_TTY_READ,
    214                            (unsigned int)(&byte),
    215                            1,
    216                            0,0);
     198            ret = sys_call(SYSCALL_TTY_READ, (unsigned int) (&byte), 1, 0, 0);
    217199        } while (ret != 1);
    218200
    219         if ( byte == 0x0A )
     201        if (byte == 0x0A) {
    220202            break; /* LF */
    221         else if ((byte == 0x7F) && (index > 0))
     203        }
     204        else if ((byte == 0x7F) && (index > 0)) {
    222205            index--; /* DEL */
    223         else
    224         {
     206        }
     207        else {
    225208            buf[index] = byte;
    226209            index++;
     
    230213    return 0;
    231214}
     215
     216
    232217////////////////////////////////////////////////////////////////////////////////////
    233218// giet_tty_getw()
     
    248233//   bits range, the zero value is returned.
    249234////////////////////////////////////////////////////////////////////////////////////
    250 unsigned int giet_tty_getw(unsigned int *val)
    251 {
     235unsigned int giet_tty_getw(unsigned int * val) {
    252236    unsigned char buf[32];
    253237    unsigned char byte;
     
    260244    unsigned int ret;
    261245
    262     while (done == 0)
    263     {
     246    while (done == 0) {
    264247        do {
    265             ret = sys_call(SYSCALL_TTY_READ,
    266                            (unsigned int)(&byte),
    267                            1,
    268                            0,0);
     248            ret = sys_call(SYSCALL_TTY_READ, (unsigned int) (&byte), 1, 0, 0);
    269249        } while (ret != 1);
    270250
    271         if ((byte > 0x2F) && (byte < 0x3A)) /* decimal character */
    272         {
     251        if ((byte > 0x2F) && (byte < 0x3A)) {
     252            /* decimal character */
    273253            buf[max] = byte;
    274254            max++;
    275255            giet_tty_putc(byte);
    276256        }
    277         else if ((byte == 0x0A) || (byte == 0x0D)) /* LF or CR character */
    278         {
     257        else if ((byte == 0x0A) || (byte == 0x0D)) {
     258            /* LF or CR character */
    279259            done = 1;
    280260        }
    281         else if (byte == 0x7F) /* DEL character */
    282         {
    283             if (max > 0)
    284             {
     261        else if (byte == 0x7F) {
     262            /* DEL character */
     263            if (max > 0) {
    285264                max--; /* cancel the character */
    286265                giet_tty_putc(0x08);
     
    289268            }
    290269        }
    291         if (max == 32) /* decimal string overflow */
    292         {
    293             for (i = 0; i < max; i++) /* cancel the string */
    294             {
     270        if (max == 32) {
     271            /* decimal string overflow */
     272            for (i = 0; i < max; i++) {
     273                /* cancel the string */
    295274                giet_tty_putc(0x08);
    296275                giet_tty_putc(0x20);
     
    304283
    305284    /* string conversion */
    306     for (i = 0; i < max; i++)
    307     {
     285    for (i = 0; i < max; i++) {
    308286        dec = dec * 10 + (buf[i] - 0x30);
    309         if (dec < save)
     287        if (dec < save) {
    310288            overflow = 1;
     289        }
    311290        save = dec;
    312291    }
    313292
    314293    /* check overflow */
    315     if (overflow == 0)
    316     {
     294    if (overflow == 0) {
    317295        *val = dec; /* return decimal value */
    318296    }
    319     else
    320     {
    321         for (i = 0; i < max; i++) /* cancel the string */
    322         {
     297    else {
     298        for (i = 0; i < max; i++) {
     299            /* cancel the string */
    323300            giet_tty_putc(0x08);
    324301            giet_tty_putc(0x20);
     
    330307    return 0;
    331308}
     309
     310
    332311////////////////////////////////////////////////////////////////////////////////////
    333312// giet_tty_printf()
     
    344323// - Returns 0 if success, > 0 if error.
    345324////////////////////////////////////////////////////////////////////////////////////
    346 unsigned int giet_tty_printf(char *format, ...)
    347 {
     325unsigned int giet_tty_printf(char * format, ...) {
    348326    va_list ap;
    349327    va_start(ap, format);
     
    354332    while (*format) {
    355333        unsigned int i;
    356         for (i = 0; format[i] && format[i] != '%'; i++)
    357             ;
     334        for (i = 0; format[i] && format[i] != '%'; i++);
    358335        if (i) {
    359             ret = sys_call(SYSCALL_TTY_WRITE,
    360                     (unsigned int)format,
    361                     i,
    362                     0,0);
    363             if (ret != i)
     336            ret = sys_call(SYSCALL_TTY_WRITE, (unsigned int) format, i, 0, 0);
     337            if (ret != i) {
    364338                return 1; /* return error */
     339            }
    365340            format += i;
    366341        }
     
    377352
    378353    {
    379         int         val = va_arg(ap, long);
    380         char            buf[20];
    381         char*          pbuf;
    382         unsigned int        len = 0;
    383         static const char   HexaTab[] = "0123456789ABCDEF";
    384         unsigned int        i;
     354        int val = va_arg(ap, long);
     355        char buf[20];
     356        char * pbuf;
     357        unsigned int len = 0;
     358        static const char HexaTab[] = "0123456789ABCDEF";
     359        unsigned int i;
    385360
    386361        switch (*format++) {
     
    393368                if (val < 0) {
    394369                    val = -val;
    395                     ret = sys_call(SYSCALL_TTY_WRITE,
    396                             (unsigned int)"-",
    397                             1,
    398                             0,0);
    399                     if (ret != 1)
     370                    ret = sys_call(SYSCALL_TTY_WRITE, (unsigned int)"-", 1, 0, 0);
     371                    if (ret != 1) {
    400372                        return 1; /* return error */
     373                    }
    401374                }
    402375            case ('u'):             /* decimal unsigned integer */
    403                 for( i=0 ; i<10 ; i++) {
    404                     buf[9-i] = HexaTab[val % 10];
    405                     if (!(val /= 10)) break;
     376                for(i = 0; i < 10; i++) {
     377                    buf[9 - i] = HexaTab[val % 10];
     378                    if (!(val /= 10)) {
     379                        break;
     380                    }
    406381                }
    407                 len =  i+1;
    408                 pbuf = &buf[9-i];
     382                len =  i + 1;
     383                pbuf = &buf[9 - i];
    409384                break;
    410385            case ('x'):             /* hexadecimal integer */
    411                 ret = sys_call(SYSCALL_TTY_WRITE,
    412                         (unsigned int)"0x",
    413                         2,
    414                         0,0);
    415                 if (ret != 2)
     386                ret = sys_call(SYSCALL_TTY_WRITE, (unsigned int) "0x", 2, 0, 0);
     387                if (ret != 2) {
    416388                    return 1; /* return error */
    417                 for( i=0 ; i<8 ; i++) {
    418                     buf[7-i] = HexaTab[val % 16U];
    419                     if (!(val /= 16U)) break;
    420389                }
    421                 len =  i+1;
    422                 pbuf = &buf[7-i];
     390                for(i = 0; i < 8; i++) {
     391                    buf[7 - i] = HexaTab[val % 16U];
     392                    if (!(val /= 16U)) {
     393                        break;
     394                    }
     395                }
     396                len =  i + 1;
     397                pbuf = &buf[7 - i];
    423398                break;
    424399            case ('s'):             /* string */
    425400                {
    426                     char *str = (char*)val;
    427                     while ( str[len] ) len++;
    428                     pbuf = (char*)val;
     401                    char * str = (char *) val;
     402                    while (str[len]) {
     403                        len++;
     404                    }
     405                    pbuf = (char *) val;
    429406                }
    430407                break;
     
    433410        }
    434411
    435         ret = sys_call(SYSCALL_TTY_WRITE,
    436                 (unsigned int)pbuf,
    437                 len,
    438                 0,0);
    439         if (ret != len)
     412        ret = sys_call(SYSCALL_TTY_WRITE, (unsigned int) pbuf, len, 0, 0);
     413        if (ret != len) {
    440414            return 1;
     415        }
    441416        goto printf_text;
    442417    }
     
    453428// - Returns 0 if success, > 0 if error.
    454429//////////////////////////////////////////////////////////////////////////////////
    455 unsigned int giet_timer_start()
    456 {
    457     return sys_call(SYSCALL_TIMER_START,
    458                    0,0,0,0);
    459 }
     430unsigned int giet_timer_start() {
     431    return sys_call(SYSCALL_TIMER_START, 0, 0, 0, 0);
     432}
     433
     434
    460435//////////////////////////////////////////////////////////////////////////////////
    461436// giet_timer_stop()
     
    464439// - Returns 0 if success, > 0 if error.
    465440//////////////////////////////////////////////////////////////////////////////////
    466 unsigned int giet_timer_stop()
    467 {
    468     return sys_call(SYSCALL_TIMER_STOP,
    469                    0,0,0,0);
    470 }
     441unsigned int giet_timer_stop() {
     442    return sys_call(SYSCALL_TIMER_STOP, 0, 0, 0, 0);
     443}
     444
    471445
    472446/////  GCD (Greatest Common Divider) related system calls
     
    483457// - Returns 0 if success, > 0 if error.
    484458//////////////////////////////////////////////////////////////////////////////////
    485 unsigned int giet_gcd_set_opa(unsigned int val)
    486 {
    487     return sys_call(SYSCALL_GCD_WRITE,
    488                     GCD_OPA,
    489                     val,
    490                     0, 0);
    491 }
    492 //////////////////////////////////////////////////////////////////////////////////
    493 //      giet_gcd_set_opb()
     459unsigned int giet_gcd_set_opa(unsigned int val) {
     460    return sys_call(SYSCALL_GCD_WRITE, GCD_OPA, val, 0, 0);
     461}
     462
     463
     464//////////////////////////////////////////////////////////////////////////////////
     465//     giet_gcd_set_opb()
    494466//////////////////////////////////////////////////////////////////////////////////
    495467// This function sets operand B in the GCD coprocessor.
    496468// - Returns 0 if success, > 0 if error.
    497469//////////////////////////////////////////////////////////////////////////////////
    498 unsigned int giet_gcd_set_opb(unsigned int val)
    499 {
    500     return sys_call(SYSCALL_GCD_WRITE,
    501                     GCD_OPB,
    502                     val,
    503                     0, 0);
    504 }
    505 //////////////////////////////////////////////////////////////////////////////////
    506 //      giet_gcd_start()
     470unsigned int giet_gcd_set_opb(unsigned int val) {
     471    return sys_call(SYSCALL_GCD_WRITE, GCD_OPB, val, 0, 0);
     472}
     473
     474
     475//////////////////////////////////////////////////////////////////////////////////
     476//     giet_gcd_start()
    507477//////////////////////////////////////////////////////////////////////////////////
    508478// This function starts the computation in the GCD coprocessor.
    509479// - Returns 0 if success, > 0 if error.
    510480//////////////////////////////////////////////////////////////////////////////////
    511 unsigned int giet_gcd_start()
    512 {
    513     return sys_call(SYSCALL_GCD_WRITE,
    514                     GCD_START,
    515                     0, 0, 0);
    516 }
    517 //////////////////////////////////////////////////////////////////////////////////
    518 //      giet_gcd_get_status()
     481unsigned int giet_gcd_start() {
     482    return sys_call(SYSCALL_GCD_WRITE, GCD_START, 0, 0, 0);
     483}
     484
     485
     486//////////////////////////////////////////////////////////////////////////////////
     487//     giet_gcd_get_status()
    519488//////////////////////////////////////////////////////////////////////////////////
    520489// This function gets the status fromn the GCD coprocessor.
    521490// - The value is 0 when the coprocessor is idle (computation completed).
    522491//////////////////////////////////////////////////////////////////////////////////
    523 unsigned int giet_gcd_get_status(unsigned int *val)
    524 {
    525     return sys_call(SYSCALL_GCD_READ,
    526             GCD_STATUS,
    527             (unsigned int)val,
    528             0, 0);
    529 }
    530 //////////////////////////////////////////////////////////////////////////////////
    531 //      giet_gcd_get_result()
     492unsigned int giet_gcd_get_status(unsigned int * val) {
     493    return sys_call(SYSCALL_GCD_READ, GCD_STATUS, (unsigned int) val, 0, 0);
     494}
     495
     496
     497//////////////////////////////////////////////////////////////////////////////////
     498//     giet_gcd_get_result()
    532499//////////////////////////////////////////////////////////////////////////////////
    533500// This function gets the result of the computation from the GCD coprocessor.
    534501//////////////////////////////////////////////////////////////////////////////////
    535 unsigned int giet_gcd_get_result(unsigned int *val)
    536 {
    537     return sys_call(SYSCALL_GCD_READ,
    538             GCD_OPA,
    539             (unsigned int)val,
    540             0, 0);
    541 }
     502unsigned int giet_gcd_get_result(unsigned int * val) {
     503    return sys_call(SYSCALL_GCD_READ, GCD_OPA, (unsigned int) val, 0, 0);
     504}
     505
    542506
    543507///// Block device related system calls  /////
    544508
    545509//////////////////////////////////////////////////////////////////////////////////
    546 //      giet_ioc_write()
     510//     giet_ioc_write()
    547511//////////////////////////////////////////////////////////////////////////////////
    548512// Transfer data from a memory buffer to a file on the block_device.
     
    552516// - Returns 0 if success, > 0 if error (e.g. memory buffer not in user space).
    553517//////////////////////////////////////////////////////////////////////////////////
    554 unsigned int giet_ioc_write( unsigned int       lba,
    555                              void*                      buffer,
    556                              unsigned int       count)
    557 {
    558     return sys_call(SYSCALL_IOC_WRITE,
    559             lba,
    560             (unsigned int)buffer,
    561             count,
    562             0);
    563 }
     518unsigned int giet_ioc_write( unsigned int lba, void * buffer, unsigned int count) {
     519    return sys_call(SYSCALL_IOC_WRITE, lba, (unsigned int) buffer, count, 0);
     520}
     521
     522
    564523//////////////////////////////////////////////////////////////////////////////////
    565524// giet_ioc_read()
     
    571530// - Returns 0 if success, > 0 if error (e.g. memory buffer not in user space).
    572531//////////////////////////////////////////////////////////////////////////////////
    573 unsigned int giet_ioc_read( unsigned int                lba,
    574                             void*                               buffer,
    575                             unsigned int                count )
    576 {
    577     return sys_call(SYSCALL_IOC_READ,
    578             lba,
    579             (unsigned int)buffer,
    580             count,
    581             0);
    582 }
     532unsigned int giet_ioc_read(unsigned int lba, void * buffer, unsigned int count) {
     533    return sys_call(SYSCALL_IOC_READ, lba, (unsigned int) buffer, count, 0);
     534}
     535
     536
    583537//////////////////////////////////////////////////////////////////////////////////
    584538// giet_ioc_completed()
     
    587541// successfully completed, and returns 1 if an address error has been detected.
    588542//////////////////////////////////////////////////////////////////////////////////
    589 unsigned int giet_ioc_completed()
    590 {
    591     return sys_call(SYSCALL_IOC_COMPLETED,
    592             0, 0, 0, 0);
    593 }
     543unsigned int giet_ioc_completed() {
     544    return sys_call(SYSCALL_IOC_COMPLETED, 0, 0, 0, 0);
     545}
     546
    594547
    595548/////  Frame buffer device related system calls  /////
     
    605558// - Returns 0 if success, > 0 if error (e.g. memory buffer not in user space).
    606559//////////////////////////////////////////////////////////////////////////////////
    607 unsigned int giet_fb_sync_write( unsigned int   offset,
    608                                  void*                  buffer,
    609                                  unsigned int   length )
    610 {
    611     return sys_call(SYSCALL_FB_SYNC_WRITE,
    612             offset,
    613             (unsigned int)buffer,
    614             length,
    615             0);
    616 }
     560unsigned int giet_fb_sync_write(unsigned int offset, void * buffer, unsigned int length) {
     561    return sys_call(SYSCALL_FB_SYNC_WRITE, offset, (unsigned int) buffer, length, 0);
     562}
     563
     564
    617565//////////////////////////////////////////////////////////////////////////////////
    618566// giet_fb_sync_read()
     
    625573// - Returns 0 if success, > 0 if error (e.g. memory buffer not in user space).
    626574//////////////////////////////////////////////////////////////////////////////////
    627 unsigned int giet_fb_sync_read( unsigned int    offset,
    628                                 void*                   buffer,
    629                                 unsigned int    length )
    630 {
    631     return sys_call(SYSCALL_FB_SYNC_READ,
    632             offset,
    633             (unsigned int)buffer,
    634             length,
    635             0);
    636 }
     575unsigned int giet_fb_sync_read(unsigned int offset, void * buffer, unsigned int length) {
     576    return sys_call(SYSCALL_FB_SYNC_READ, offset, (unsigned int) buffer, length, 0);
     577}
     578
     579
    637580//////////////////////////////////////////////////////////////////////////////////
    638581// giet_fb_write()
     
    647590// - Returns 0 if success, > 0 if error (e.g. memory buffer not in user space).
    648591//////////////////////////////////////////////////////////////////////////////////
    649 unsigned int giet_fb_write( unsigned int        offset,
    650                             void*               buffer,
    651                             unsigned int        length )
    652 {
    653     return sys_call(SYSCALL_FB_WRITE,
    654             offset,
    655             (unsigned int)buffer,
    656             length,
    657             0);
    658 }
     592unsigned int giet_fb_write(unsigned int offset, void * buffer, unsigned int length) {
     593    return sys_call(SYSCALL_FB_WRITE, offset, (unsigned int) buffer, length, 0);
     594}
     595
     596
    659597//////////////////////////////////////////////////////////////////////////////////
    660598// giet_fb_read()
     
    669607// - Returns 0 if success, > 0 if error (e.g. memory buffer not in user space).
    670608//////////////////////////////////////////////////////////////////////////////////
    671 unsigned int giet_fb_read( unsigned int         offset,
    672                            void*                buffer,
    673                            unsigned int         length )
    674 {
    675     return sys_call(SYSCALL_FB_READ,
    676                     offset,
    677                     (unsigned int)buffer,
    678                     length,
    679                     0);
    680 }
     609unsigned int giet_fb_read(unsigned int offset, void * buffer, unsigned int length) {
     610    return sys_call(SYSCALL_FB_READ, offset, (unsigned int) buffer, length, 0);
     611}
     612
     613
    681614//////////////////////////////////////////////////////////////////////////////////
    682615// giet_fb_completed()
     
    685618// - Returns 0 if success, > 0 if error.
    686619//////////////////////////////////////////////////////////////////////////////////
    687 unsigned int giet_fb_completed()
    688 {
    689     return sys_call(SYSCALL_FB_COMPLETED,
    690                     0, 0, 0, 0);
    691 }
     620unsigned int giet_fb_completed() {
     621    return sys_call(SYSCALL_FB_COMPLETED, 0, 0, 0, 0);
     622}
     623
    692624
    693625//////////////////////////////////////////////////////////////////////////////////
     
    704636//////////////////////////////////////////////////////////////////////////////////
    705637
    706 unsigned int giet_nic_write( unsigned int       offset,
    707                              void*              buffer,
    708                              unsigned int       length )
    709 {
    710     return sys_call(SYSCALL_NIC_WRITE,
    711             offset,
    712             (unsigned int)buffer,
    713             length,
    714             0);
    715 }
     638unsigned int giet_nic_write(unsigned int offset, void * buffer, unsigned int length) {
     639    return sys_call(SYSCALL_NIC_WRITE, offset, (unsigned int) buffer, length, 0);
     640}
     641
    716642
    717643//////////////////////////////////////////////////////////////////////////////////
     
    728654//////////////////////////////////////////////////////////////////////////////////
    729655
    730 unsigned int giet_nic_read( unsigned int        offset,
    731                             void*                   buffer,
    732                             unsigned int        length )
    733 {
    734     return sys_call(SYSCALL_NIC_READ,
    735             offset,
    736             (unsigned int)buffer,
    737             length,
    738             0);
    739 }
     656unsigned int giet_nic_read(unsigned int offset, void * buffer, unsigned int length) {
     657    return sys_call(SYSCALL_NIC_READ, offset, (unsigned int) buffer, length, 0);
     658}
     659
    740660
    741661//////////////////////////////////////////////////////////////////////////////////
     
    745665// - Returns 0 if success, > 0 if error.
    746666//////////////////////////////////////////////////////////////////////////////////
    747 unsigned int giet_nic_completed()
    748 {
    749     return sys_call(SYSCALL_NIC_COMPLETED,
    750                     0, 0, 0, 0);
    751 }
     667unsigned int giet_nic_completed() {
     668    return sys_call(SYSCALL_NIC_COMPLETED, 0, 0, 0, 0);
     669}
     670
    752671
    753672///// Miscellaneous related system calls /////
     
    762681// - Returns the address if success,  0 if error ( not defined or wrong type )
    763682//////////////////////////////////////////////////////////////////////////////////
    764 unsigned int giet_vobj_get_vbase( char*                 vspace_name,
    765                                   char*                 vobj_name,
    766                                   unsigned int  vobj_type,
    767                                   unsigned int* vobj_vaddr )
    768 {
     683unsigned int giet_vobj_get_vbase(char * vspace_name, char * vobj_name, unsigned int vobj_type, unsigned int * vobj_vaddr) {
    769684    return sys_call(SYSCALL_VOBJ_GET_VBASE,
    770                     (unsigned int)vspace_name,
    771                     (unsigned int)vobj_name,
    772                     (unsigned int)vobj_type,
    773                     (unsigned int)vobj_vaddr);
    774 }
     685            (unsigned int) vspace_name,
     686            (unsigned int) vobj_name,
     687            (unsigned int) vobj_type,
     688            (unsigned int) vobj_vaddr);
     689}
     690
    775691
    776692////////////////////////////////////////////////////////////////////////////////////
     
    781697// - Returns 0 if success, > 0 if error ( cluster index too large )
    782698////////////////////////////////////////////////////////////////////////////////////
    783 unsigned int giet_proc_number( unsigned int             cluster_id,
    784                                unsigned int*    buffer )
    785 {
    786     return sys_call(SYSCALL_PROC_NUMBER,
    787                     cluster_id,
    788                     (unsigned int)buffer,
    789                     0, 0);
    790 }
     699unsigned int giet_proc_number(unsigned int cluster_id, unsigned int * buffer) {
     700    return sys_call(SYSCALL_PROC_NUMBER, cluster_id, (unsigned int) buffer, 0, 0);
     701}
     702
    791703
    792704/////  Miscellaneous system calls /////
     
    799711// The task is blocked, but it still consume processor cycles ...
    800712//////////////////////////////////////////////////////////////////////////////////
    801 void giet_exit()
    802 {
    803     sys_call(SYSCALL_EXIT,
    804              0, 0, 0, 0);
    805 }
     713void giet_exit() {
     714    sys_call(SYSCALL_EXIT, 0, 0, 0, 0);
     715}
     716
     717
    806718///////////////////////////////////////////////////////////////////////////////////
    807719// giet_rand()
     
    809721// count. This value is comprised between 0 & 65535.
    810722///////////////////////////////////////////////////////////////////////////////////
    811 unsigned int giet_rand()
    812 {
    813     unsigned int x = sys_call(SYSCALL_PROCTIME,
    814                               0, 0, 0, 0);
    815     if((x & 0xF) > 7)
     723unsigned int giet_rand() {
     724    unsigned int x = sys_call(SYSCALL_PROCTIME, 0, 0, 0, 0);
     725    if ((x & 0xF) > 7) {
    816726        return (x*x & 0xFFFF);
    817     else
     727    }
     728    else {
    818729        return (x*x*x & 0xFFFF);
    819 }
    820 //////////////////////////////////////////////////////////////////////////////////
    821 // giet_ctx_switch()
     730    }
     731}
     732
     733
     734//////////////////////////////////////////////////////////////////////////////////
     735// giet_context_switch()
    822736// The user task calling this function is descheduled and
    823737// the processor is allocated to another task.
    824738//////////////////////////////////////////////////////////////////////////////////
    825 unsigned int giet_ctx_switch()
    826 {
    827     return sys_call(SYSCALL_CTX_SWITCH,
    828                     0, 0, 0, 0);
    829 }
    830 
    831 
     739unsigned int giet_context_switch() {
     740    return sys_call(SYSCALL_CTX_SWITCH, 0, 0, 0, 0);
     741}
     742
     743//////////////////////////////////////////////////////////////////////////////////
     744// giet_get_task_id()
     745// The user task calling this function is descheduled and
     746// the processor is allocated to another task.
     747//////////////////////////////////////////////////////////////////////////////////
     748unsigned int giet_task_id() {
     749    return sys_call(SYSCALL_TASK_ID, 0, 0, 0, 0);
     750}
     751
     752
     753// Local Variables:
     754// tab-width: 4
     755// c-basic-offset: 4
     756// c-file-offsets:((innamespace . 0)(inline-open . 0))
     757// indent-tabs-mode: nil
     758// End:
     759// vim: filetype=c:expandtab:shiftwidth=4:tabstop=4:softtabstop=4
     760
Note: See TracChangeset for help on using the changeset viewer.