Changeset 426


Ignore:
Timestamp:
Jan 29, 2018, 6:00:54 PM (6 years ago)
Author:
alain
Message:

The "nostdio" library has been integrated in the stdio library.

Location:
trunk/libs
Files:
2 deleted
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/libs/malloc.c

    r416 r426  
    2222 */
    2323
    24 #include <nostdio.h>
    2524#include <stdlib.h>
    2625#include <stdio.h>
  • trunk/libs/pthread.c

    r412 r426  
    2424#include <shared_syscalls.h>
    2525#include <hal_user.h>
    26 #include <nostdio.h>
    2726#include <stdio.h>
    2827#include <stdlib.h>
  • trunk/libs/stdio.c

    r412 r426  
    2929#define  reg_t     int
    3030
     31///////////// POSIX standard system calls ////////////////////////////////////
     32
    3133///////////////////////
    3234void exit( int status )
     
    3638}
    3739
    38 // 11 ///////////////////////////
     40/////////////////////////////////
    3941int munmap( void         * addr,
    4042            unsigned int   size )
     
    4547}
    4648
    47 // 12 //////////////////////////
     49////////////////////////////////
    4850int open( const char * pathname,
    4951          int          flags,
     
    5658}
    5759
    58 // 13 /////////////////////////
     60///////////////////////////////
    5961void * mmap( void       * addr,
    6062             unsigned int length,
     
    7779}
    7880
    79 // 14 ////////////////////
     81//////////////////////////
    8082int read( int          fd,
    8183          void       * buf,
     
    8890}
    8991
    90 // 15 /////////////////////
     92///////////////////////////
    9193int write( int          fd,
    9294           const void * buf,
     
    99101}
    100102
    101 // 16 /////////////////////
     103///////////////////////////
    102104int lseek( int          fd,
    103105           unsigned int offset,
     
    110112}
    111113
    112 // 17 /////////////
     114///////////////////
    113115int close( int fd )
    114116{
     
    117119}
    118120
    119 // 18 /////////////////////////////
     121///////////////////////////////////
    120122int unlink( const char * pathname )
    121123{
     
    124126}
    125127
    126 // 19 ///////////////
     128/////////////////////
    127129int pipe( int fd[2] )
    128130{
     
    130132}
    131133
    132 // 20 ////////////////////////////
     134//////////////////////////////////
    133135int chdir( const char * pathname )
    134136{
     
    137139}
    138140
    139 // 21 ///////////////////////////
     141/////////////////////////////////
    140142int mkdir( const char * pathname,
    141143           int          mode )
     
    146148}
    147149
    148 // 22 ////////////////////////////
     150//////////////////////////////////
    149151int mkfifo( const char * pathname,
    150152            int          mode )
     
    155157}
    156158
    157 // 23 ////////////////////////////////
     159//////////////////////////////////////
    158160DIR * opendir( const char * pathname )
    159161{
     
    167169}
    168170
    169 // 24 ///////////////////////////////
     171/////////////////////////////////////
    170172struct dirent * readdir( DIR * dirp )
    171173{
     
    179181}
    180182
    181 // 25 ////////////////////
     183//////////////////////////
    182184int closedir( DIR * dirp )
    183185{
     
    186188}
    187189
    188 // 26 ///////////////////////
     190/////////////////////////////
    189191int getcwd( char       * buf,
    190192            unsigned int bytes )
     
    195197}
    196198
    197 // 29 //////////////////////
     199////////////////////////////
    198200int rmdir( char * pathname )
    199201{
     
    202204}
    203205
    204 // 30 ///////////////////////////
     206/////////////////////////////////
    205207int utls( unsigned int operation,
    206208          unsigned int value )
     
    211213}
    212214
    213 // 31 /////////////////////////
     215///////////////////////////////
    214216int chmod( char     * pathname,
    215217           unsigned int   rights )
     
    220222}
    221223
    222 // 32 ///////////////////////////
     224/////////////////////////////////
    223225int signal( unsigned int   sigid,
    224226            void         * handler )
     
    229231}
    230232
    231 // 33 /////////////////////////////////
     233///////////////////////////////////////
    232234int gettimeofday( struct timeval  * tv,
    233235                  struct timezone * tz )
     
    238240}
    239241
    240 // 34 /////////////////////
     242///////////////////////////
    241243int kill( unsigned int pid,
    242244          unsigned int sig_id )
     
    247249}
    248250
    249 // 35 //////
     251////////////
    250252int getpid()
    251253{
     
    253255}
    254256
    255 // 36 ////
     257//////////
    256258int fork()
    257259{
     
    259261}
    260262
    261 // 37 /////////////////////
     263///////////////////////////
    262264int exec( char  * pathname,
    263265          char ** argv,
     
    270272}
    271273
    272 // 38 ///////////////////////////
     274/////////////////////////////////
    273275int stat( const char  * pathname,
    274276          struct stat * stat )
    275277{
    276     return hal_user_syscall( SYS_EXEC,
     278    return hal_user_syscall( SYS_STAT,
    277279                             (reg_t)pathname,
    278280                             (reg_t)stat, 0, 0 );
    279281}
    280282
    281 // 39 ////////////////////////////
     283////////////////////////
     284int wait( int * status )
     285{
     286    return hal_user_syscall( SYS_WAIT,
     287                             (reg_t)status, 0, 0, 0 );
     288}
     289
     290
     291
     292/////////////     Non standard system calls ////////////////////////////////////
     293
     294//////////////////////////
     295int fg( unsigned int pid )
     296{
     297    return hal_user_syscall( SYS_FG,
     298                             (reg_t)pid, 0, 0, 0 );
     299}
     300
     301//////////////////////////////////////
     302int get_config( unsigned int * x_size,
     303                unsigned int * y_size,
     304                unsigned int * ncores )
     305{
     306    return hal_user_syscall( SYS_GET_CONFIG,
     307                             (reg_t)x_size,
     308                             (reg_t)y_size,
     309                             (reg_t)ncores, 0 );
     310}
     311
     312/////////////////////////////////
     313int get_core( unsigned int * cxy,
     314              unsigned int * lid )
     315{
     316    return hal_user_syscall( SYS_GET_CORE,
     317                             (reg_t)cxy,
     318                             (reg_t)lid, 0, 0 );
     319}
     320
     321////////////////////////////////////
     322void display_string( char * string )
     323{
     324    hal_user_syscall( SYS_DISPLAY,
     325                      DISPLAY_STRING,
     326                      (reg_t)string, 0, 0 );
     327}
     328
     329///////////////////////////////////
     330int display_vmm( unsigned int pid )
     331{
     332    return hal_user_syscall( SYS_DISPLAY,
     333                             DISPLAY_VMM,
     334                             (reg_t)pid, 0, 0 );
     335}
     336
     337////////////////////////////////
     338int display_sched( unsigned int cxy,
     339                   unsigned int lid )
     340{
     341    return hal_user_syscall( SYS_DISPLAY,
     342                             DISPLAY_SCHED,
     343                             (reg_t)cxy,
     344                             (reg_t)lid, 0 );
     345}
     346
     347///////////////////////////////////////
     348int display_process( unsigned int cxy )
     349{
     350    return hal_user_syscall( SYS_DISPLAY,
     351                             DISPLAY_PROCESS,
     352                             (reg_t)cxy, 0, 0 );
     353}
     354
     355///////////////////
     356int display_chdev()
     357{
     358    return hal_user_syscall( SYS_DISPLAY,
     359                             DISPLAY_CHDEV, 0, 0, 0 );
     360}
     361
     362/////////////////
     363int display_vfs()
     364{
     365    return hal_user_syscall( SYS_DISPLAY,
     366                             DISPLAY_VFS, 0, 0, 0 );
     367}
     368
     369///////////////////////////////////////////
     370int get_cycle( unsigned long long * cycle )
     371{
     372    return hal_user_syscall( SYS_GET_CYCLE,
     373                             (reg_t)cycle, 0, 0, 0 );
     374}
     375
     376//////////////////////////////////
    282377int trace( unsigned int operation,
    283378           unsigned int pid,
  • trunk/libs/stdio.h

    r412 r426  
    2929#define  NULL  (void *)0
    3030
     31/****************** Standard (POSIX) system calls  **************************************/
     32
    3133/*****************************************************************************************
    3234 * This function terminates a process.
     
    277279 * This function implements the POSIX "getpid" system call.
    278280 *****************************************************************************************
    279  * @ returns the process PID for the calling thread.
     281 * @ returns the process PID for the calling thread process.
    280282 ****************************************************************************************/
    281283int getpid();
     
    329331
    330332/*****************************************************************************************
    331  * This function is used to activate / desactivate the trace for a thread
     333 * This blocking function returns only when one child process of the calling process
     334 * changes state (from RUNNING to STOPPED / EXITED / KILLED). It returns the terminating
     335 * child process PID, and set in the <status> buffer the new child process state.
     336 *****************************************************************************************
     337 * @ status    : [out] terminating child process state.
     338 * @ returns terminating child process pid.
     339 ****************************************************************************************/
     340int wait( int * status );
     341
     342/****************** Non standard (ALMOS_MKH specific) system calls **********************/
     343
     344
     345/*****************************************************************************************
     346 * This function is used to give the process identified by the <pid> argument the
     347 * exclusive ownership of the attached TXT_RX terminal.
     348 *****************************************************************************************
     349 * @ pid        : process identifier.
     350 * @ returns O if success / returns -1 if process not found.
     351 ****************************************************************************************/
     352int fg( unsigned int pid );
     353
     354/***************************************************************************************
     355 * This function returns the hardware platform parameters.
     356 ***************************************************************************************
     357 * @ x_size   : [out] number of clusters in a row.
     358 * @ y_size   : [out] number of clusters in a column.
     359 * @ ncores   : [out] number of cores per cluster.
     360 * @ return always 0.
     361 **************************************************************************************/
     362int get_config( unsigned int * x_size,
     363                unsigned int * y_size,
     364                unsigned int * ncores );
     365
     366/***************************************************************************************
     367 * This function returns the cluster an local index for the calling core.
     368 ***************************************************************************************
     369 * @ cxy      : [out] cluster identifier.
     370 * @ lid      : [out] core local index in cluster.
     371 * @ return always 0.
     372 **************************************************************************************/
     373int get_core( unsigned int * cxy,
     374              unsigned int * lid );
     375
     376/***************************************************************************************
     377 * This function returns the calling core cycles counter,
     378 * taking into account a possible overflow on 32 bits architectures.
     379 ***************************************************************************************
     380 * @ cycle    : [out] current cycle value.
     381 * @ return always 0.
     382 **************************************************************************************/
     383int get_cycle( unsigned long long * cycle );
     384
     385/***************************************************************************************
     386 * This debug function displays on the kernel terminal TXT0
     387 * the thread / process / core identifiers, the current cycle, plus a user defined
     388 * message as specified by the <string> argument.
     389 ***************************************************************************************
     390 * @ string    : [in] user defined message.
     391 **************************************************************************************/
     392void display_string( char * string );
     393
     394/***************************************************************************************
     395 * This debug function displays on the kernel terminal TXT0
     396 * the state of the process VMM identified by the <pid> argument.
     397 * It can be called by any thread running in any cluster.
     398 ***************************************************************************************
     399 * @ pid      : [in] process identifier.
     400 * @ return 0 if success / return -1 if illegal argument.
     401 **************************************************************************************/
     402int display_vmm( unsigned int  pid );
     403
     404/***************************************************************************************
     405 * This debug function displays on the kernel terminal TXT0
     406 * the state of the core scheduler identified by the <cxy> and <lid> arguments.
     407 * It can be called by any thread running in any cluster.
     408 ***************************************************************************************
     409 * @ cxy      : [in] target cluster identifier.
     410 * @ lid      : [in] target core local index.
     411 * @ return 0 if success / return -1 if illegal arguments.
     412 **************************************************************************************/
     413int display_sched( unsigned int  cxy,
     414                   unsigned int  lid );
     415
     416/***************************************************************************************
     417 * This debug function displays on the kernel terminal TXT0
     418 * the list of process registered in a given cluster identified by the <cxy> argument.
     419 * It can be called by any thread running in any cluster.
     420 ***************************************************************************************
     421 * @ cxy      : [in] target cluster identifier.
     422 * @ return 0 if success / return -1 if illegal argument.
     423 **************************************************************************************/
     424int display_process( unsigned int  cxy );
     425
     426/***************************************************************************************
     427 * This debug function displays on the kernel terminal TXT0
     428 * the list of channel devices available in the architecture.
     429 * It can be called by any thread running in any cluster.
     430 ***************************************************************************************
     431 * @ return always 0.
     432 **************************************************************************************/
     433int display_chdev();
     434
     435/***************************************************************************************
     436 * This debug function displays on the kernel terminal TXT0
     437 * the list of channel device or pseudo-files registered in the VFS cache.
     438 * It can be called by any thread running in any cluster.
     439 ***************************************************************************************
     440 * @ return always 0.
     441 **************************************************************************************/
     442int display_vfs();
     443
     444/*****************************************************************************************
     445 * This debug function is used to activate / desactivate the trace for a thread
    332446 * identified by the <trdid> and <pid> arguments.
    333447 * It can be called by any other thread in the same process.
     
    336450 * @ pid        : process identifier.
    337451 * @ trdid      : thread identifier.
    338  * @ returns O if success / returns -1 if failure.
     452 * @ returns O if success / returns -1 if illegal arguments.
    339453 ****************************************************************************************/
    340454int trace( unsigned int operation,
  • trunk/libs/stdlib.c

    r416 r426  
    2222 */
    2323
    24 #include <nostdio.h>
    2524#include <stdio.h>
    2625#include <stdarg.h>
     
    4039}
    4140
    42 /////////////////////////
    43 int atoi(const char *str)
    44 {
    45     int res  = 0; // Initialize result
    46     int sign = 1; // Initialize sign as positive
    47     int i    = 0; // Initialize index of first digit
    48 
    49     if (str[0] == '-') //If number is negative, then update sign
    50     {
    51         sign = -1; 
    52         i++;           // Also update index of first digit
    53     }
    54 
    55     for (; str[i] != '\0'; ++i) // Iterate through all digits and update the result
    56     {
    57         res = res*10 + str[i] - '0';
     41//////////////////////////
     42int atoi(const char * str)
     43{
     44    int res  = 0;      // Initialize result
     45    int sign = 1;      // Initialize sign as positive
     46    int i    = 0;      // Initialize index of first digit
     47
     48    if( (str[0] == '0') && ((str[1] == 'x') || (str[1] == 'X')) )   // hexa
     49    {
     50        i = 2;
     51
     52        while( str[i] != 0 )
     53        {
     54            if     ( (str[i] >= '0') && (str[i] <= '9') ) res = (res<<4) + (str[i] - '0');
     55            else if( (str[i] >= 'A') && (str[i] <= 'F') ) res = (res<<4) + (str[i] - 'A');
     56            else if( (str[i] >= 'a') && (str[i] <= 'f') ) res = (res<<4) + (str[i] - 'a');
     57            else return 0;
     58            i++;
     59        }
     60    }
     61    else                                                            // decimal
     62    {
     63        if (str[0] == '-')  //  number is negative, update sign
     64        {
     65            sign = -1; 
     66            i++;           // Also update index of first digit
     67        }
     68
     69        while( str[i] != 0 )
     70        {
     71            if( (str[i] >= '0') && (str[i] <= '9') ) res = (res*10) + (str[i] - '0');
     72            else return 0;
     73            i++;
     74        }
    5875    }
    5976
     
    382399    if ( count == -1 )
    383400    {
    384         panic( "stdlib xprintf failure" );
     401        display_string( "stdlib : xprintf failure" );
    385402        return -1;
    386403    }
     
    495512}  // end getint()
    496513
    497 ///////////////////////////////////////////
    498 int snprintf( char       * string,
     514///////////////////////////////////////
     515int snprintf( char           * string,
    499516              unsigned int     length,
    500               const char * format, ... )
     517              const char     * format, ... )
    501518{
    502519    va_list   args;
Note: See TracChangeset for help on using the changeset viewer.