Changeset 661


Ignore:
Timestamp:
Oct 10, 2020, 4:41:37 PM (20 months ago)
Author:
alain
Message:

Introduce the non-standatd display_socket() syscall.
Improve the non-standard get_string() syscall.

Location:
trunk/libs
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libs/libalmosmkh/almosmkh.c

    r657 r661  
    5757}
    5858
    59 //////////////////////////////////////
    60 int get_config( unsigned int * x_size,
    61                 unsigned int * y_size,
    62                 unsigned int * ncores )
     59///////////////////////////////////////////////
     60int get_config( struct hard_config_s * config )
    6361{
    6462    return hal_user_syscall( SYS_GET_CONFIG,
    65                              (reg_t)x_size,
    66                              (reg_t)y_size,
    67                              (reg_t)ncores, 0 );
     63                             (reg_t)config, 0, 0, 0);
    6864}
    6965
     
    242238        if( length >= maxlen-1 )
    243239        {
    244             return -1;                      // return failure   
     240            // cancel all echo characters
     241            while( length )
     242            {
     243               printf("\b \b");             // cancel one echo character
     244               length--;                   
     245            }
    245246        }
    246247
     
    257258        else if (c == 0x0A)                 // LF character marks end of string
    258259        {
     260            putchar( c );
    259261            done = 1;
    260262        }
     
    264266            if ( length > 0 )
    265267            {
     268                printf("\b \b");            // cancel one echo character
    266269                length--;         
    267                 printf("\b \b");            // BS /  / BS
    268270            }
    269271        }
    270272        else if ( c == 0 )                  // EOF character
    271273        {
     274            // cancel all echo characters
     275            while( length )
     276            {
     277               printf("\b \b");             // cancel one echo character
     278               length--;                   
     279            }
    272280            return -1;                      // return failure
    273281        }
     
    276284    // set NUL character in string and return success
    277285    string[length] = 0;
    278     return 0;
     286    return length + 1;
    279287
    280288}  // end get_string()
     
    399407                             (reg_t)nb_slots, 0 );
    400408}
     409
     410/////////////////////////////////////
     411int display_socket( unsigned int pid,
     412                    unsigned int fdid )
     413{
     414    return hal_user_syscall( SYS_DISPLAY,
     415                             DISPLAY_SOCKET,
     416                             (reg_t)pid,
     417                             (reg_t)fdid, 0 );
     418}
    401419
    402420///////////////////////////////
     
    14951513
    14961514    // get platform parameters
    1497     unsigned int   x_size;
    1498     unsigned int   y_size;
    1499     unsigned int   ncores;
    1500     get_config( &x_size , &y_size , &ncores );
     1515    hard_config_t  config;
     1516    get_config( &config );
     1517    unsigned int   x_size = config.x_size;
     1518    unsigned int   y_size = config.y_size;
     1519    unsigned int   ncores = config.ncores;
    15011520
    15021521    // get calling thread cluster identifier
  • trunk/libs/libalmosmkh/almosmkh.h

    r657 r661  
    6363
    6464/***************************************************************************************
    65  * This syscall returns the hardware platform parameters.
    66  ***************************************************************************************
    67  * @ x_size   : [out] number of clusters in a row.
    68  * @ y_size   : [out] number of clusters in a column.
    69  * @ ncores   : [out] number of cores per cluster.
    70  * @ return always 0.
    71  **************************************************************************************/
    72 int get_config( unsigned int * x_size,
    73                 unsigned int * y_size,
    74                 unsigned int * ncores );
     65 * This syscall returns the hardware platform parameters in the hard_config_t pointed
     66 * by the <config> argument. This structure is defined in the shared_almos.h file.
     67 * The available configuration parameters are :
     68 * - cores       : x_size / y_size / ncores
     69 * - peripherals : nb_txt_channels / nb_nic_channels / nb_ioc_channels / nb_fbf_channels
     70 ***************************************************************************************
     71 * @ config   : [out] pointer on hard_config_t structure in user space.
     72 * @ return 0 if success / return -1 if illegal argument.
     73 **************************************************************************************/
     74int get_config( struct hard_config_s * config );
    7575
    7676/***************************************************************************************
     
    153153 * This syscall returns a character string from the standard "stdin" stream.
    154154 * The string is copied in buffer pointed by the <string> argument.
    155  * The string length (including the NUL terminating character) cannot be larger
    156  * than the size defined by the <size> argument.
     155 * If the number of characters exceed the buffer length, all character are canceled
     156 * in both the buffer & the echoed string, and a new string capture start.
     157 * - Only printable characters c such as (0x20 <= c) and (c < 0x7f) are echoed
     158 *   and copied in the target buffer.
     159 * - The LF (0x0A) character signaling the end of string is replaced by an extra
     160 *   NUL (0x00) character in the target buffer.
     161 * - the DEL (0x7F), BS (0x08) control characters are taken into account, and can be
     162 *   used to correct both the buffer content and the echoed string.
    157163 ***************************************************************************************
    158164 * @ string   : pointer on the string buffer.
    159  * @ maxlen   : max number of bytes in string buffer.
    160  * @ returns 0 if success / returns -1 if failure.
     165 * @ maxlen   : max number of bytes in string buffer, including the terminating NUL.
     166 * @ returns string length (including NUL) if success / returns -1 if failure.
    161167 **************************************************************************************/
    162168int get_string( char * string,
     
    308314int display_fat( unsigned int min_slot,
    309315                 unsigned int nb_slots );
     316
     317/***************************************************************************************
     318 * This debug syscall displays on the kernel terminal the current state of
     319 * a socket identified by the <pid> and <fdid> arguments.
     320 * It can be called by any thread running in any cluster.
     321 ***************************************************************************************
     322 * @ pid        : target process identifier.
     323 * @ fdid       : file descriptor identifying the target socket.
     324 * @ return 0 if success / return -1 if socket not found.
     325 **************************************************************************************/
     326int display_socket( unsigned int pid,
     327                    unsigned int fdid );
    310328
    311329/*****************************************************************************************
  • trunk/libs/mini-libc/Makefile

    r445 r661  
    1414       mman.c    \
    1515       signal.c  \
     16       socket.c  \
    1617       stat.c    \
    1718       stdio.c   \
     
    5556        cp mman.h    build/include/sys/.
    5657        cp signal.h  build/include/.
     58        cp socket.h  build/include/sys/.
    5759        cp stat.h    build/include/sys/.
    5860        cp stdio.h   build/include/.
Note: See TracChangeset for help on using the changeset viewer.