Changeset 685


Ignore:
Timestamp:
Jan 13, 2021, 12:45:27 AM (3 months ago)
Author:
alain
Message:

Introduce the display_socket() function.

Location:
trunk/libs/libalmosmkh
Files:
2 edited

Legend:

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

    r678 r685  
    2323
    2424#include <almosmkh.h>
     25#include <shared_almos.h>
    2526#include <hal_user.h>
    2627#include <hal_macros.h>
     
    6061int get_config( struct hard_config_s * config )
    6162{
    62     return hal_user_syscall( SYS_GET_CONFIG,
    63                              (reg_t)config, 0, 0, 0);
     63    return hal_user_syscall( SYS_GET,
     64                             GET_CONFIG,
     65                             (reg_t)config, 0, 0);
    6466}
    6567
     
    6870                 unsigned int * lid )
    6971{
    70     return hal_user_syscall( SYS_GET_CORE_ID,
     72    return hal_user_syscall( SYS_GET,
     73                             GET_CORE_ID,
    7174                             (reg_t)cxy,
    72                              (reg_t)lid, 0, 0 );
     75                             (reg_t)lid, 0 );
    7376}
    7477
     
    7780                  unsigned int * ncores )
    7881{
    79     return hal_user_syscall( SYS_GET_NB_CORES,
     82    return hal_user_syscall( SYS_GET,
     83                             GET_NB_CORES,
    8084                             (reg_t)cxy,
    81                              (reg_t)ncores, 0, 0 );
     85                             (reg_t)ncores, 0 );
    8286}
    8387
     
    8892                   unsigned int * lid )
    8993{
    90     return hal_user_syscall( SYS_GET_BEST_CORE,
    91                              (reg_t)base_cxy,
    92                              (reg_t)level,
     94    return hal_user_syscall( SYS_GET,
     95                             GET_BEST_CORE,
     96                             (reg_t)((base_cxy << 16) | (level & 0xFFFF)),
    9397                             (reg_t)cxy,
    9498                             (reg_t)lid );
    9599}
    96100
     101//////////////////////////////////////////////
     102int get_processes( unsigned int   cxy,
     103                   unsigned int   owned,
     104                   char         * u_buf,
     105                   unsigned int   size )
     106{
     107    return hal_user_syscall( SYS_GET,
     108                             GET_PROCESSES,
     109                             (reg_t)((cxy << 16) | (owned & 0xFFFF)),
     110                             (reg_t)u_buf,
     111                             (reg_t)size );
     112}
     113
    97114///////////////////////////////////////////
    98115int get_cycle( unsigned long long * cycle )
    99116{
    100     return hal_user_syscall( SYS_GET_CYCLE,
    101                              (reg_t)cycle, 0, 0, 0 );
     117    return hal_user_syscall( SYS_GET,
     118                             GET_CYCLE,
     119                             (reg_t)cycle, 0, 0 );
     120}
     121
     122///////////////////////////////////////////
     123int get_thread_info( thread_info_t * info )
     124{
     125    return hal_user_syscall( SYS_GET,
     126                             GET_THREAD_INFO,
     127                             (reg_t)info, 0, 0 );
    102128}
    103129
     
    180206    {
    181207        // test (decimal / hexa)
    182         if( (buf[0] == 0x30) && (buf[1] == 0x58) )     // hexadecimal input
     208        if( (buf[0] == 0x30) && ((buf[1] == 0x58) || (buf[1] == 0x78)) )     // hexa input
    183209        {
    184210            for (i = 2; (i < length) && (overflow == 0) ; i++)
     
    190216            }
    191217        }
    192         else                                           // decimal input
     218        else                                                                // decimal input
    193219        {
    194220            for (i = 0; (i < length) && (overflow == 0) ; i++)
     
    269295        }
    270296    }
    271 
    272     // set NUL character in string and return success
    273 
    274297}  // end get_string()
    275 
    276 
    277 /////////////////////////////
    278 int fget_string( int    fdid,
    279                  char * string,
    280                  int    maxlen )
    281 {
    282     int  ret;
    283     char c;
    284     int  length = 0;
    285 
    286     while( 1 )
    287     {
    288         // check buffer overflow
    289         if( length >= maxlen-1 )  length = 0;                 
    290 
    291         // read one character from stream
    292         ret = read( fdid , &c , 1 );
    293 
    294         if( ret == 1 )
    295         {
    296             if ( (c >= 0x20) && (c < 0x7F) )    // printable character
    297             {
    298                 string[length] = (char)c;       // register character in string
    299                 length++;                       // update length
    300             }
    301             else if ( c == 0 )                  // end of string
    302             {
    303                 string[length] = (char)c;       // register character in string
    304                 length++;                       // update length
    305                 break;                          // exit loop
    306             }
    307             // discard all characters not printable or NUL
    308         }
    309         else
    310         {
    311             printf("\n[%s] cannot read stream %d\n", __FUNCTION__, fdid );
    312             length = 0;
    313             break;
    314         }
    315     }
    316 }  // end fget_string()
    317298
    318299
     
    320301///////////////    non standard debug functions    ///////////////////////////////////
    321302//////////////////////////////////////////////////////////////////////////////////////
    322 
    323 ///////////////////////////////////////////
    324 int get_thread_info( thread_info_t * info )
    325 {
    326     return hal_user_syscall( SYS_GET_THREAD_INFO,
    327                              (reg_t)info, 0, 0, 0 );
    328 }
    329303
    330304////////////////////////////////////
  • trunk/libs/libalmosmkh/almosmkh.h

    r678 r685  
    22 * almosmkh.h - User level ALMOS-MKH specific library definition.
    33 *
    4  * Author     Alain Greiner (2016,2017,2018,2019,2020)
     4 * Author        Alain Greiner (2016,2017,2018,2019,2020)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    2626
    2727/***************************************************************************************
    28  * This file defines an user level, ALMOS-MKH specific library, containing:
     28 * This file defines an user level, ALMOS-MKH specific library, containing various
     29 * non standard functions and system calls:
     30 *
     31 * - non standard get_uint32() and get_string() functions.
    2932 * - non standard system calls.
    30  * - debug functions.
    31  * - remote malloc extensions.
    32  * - a parallel_pthread_create function.
    33  * - Frame Buffer access syscalls.
     33 * - non standard debug functions.
     34 * - non standard remote_malloc() functions.
     35 * - non standard parallel_pthread_create() function.
     36 * - non standard FBF access syscalls.
    3437 **************************************************************************************/
    3538
    3639#include <pthread.h>
    3740#include <shared_almos.h>
     41
     42
     43/****************** Non standard (ALMOS_MKH specific) functions  **********************/
     44
     45
     46/***************************************************************************************
     47 * This syscall returns a 32 bits integer captures from the STDIN terminal.
     48 * The value is copied in buffer pointed by the <buf> argument
     49 * Both decimal numbers and hexadecimal numbers (prefixed by 0x) are supported.
     50 ***************************************************************************************
     51 * @ buffer    : pointer on buffer.
     52 * @ returns 0 if success / returns -1 if failure.
     53 **************************************************************************************/
     54void get_uint32( unsigned int * buffer );
     55
     56
     57/***************************************************************************************
     58 * These syscalls return a NUL terminated string captured from the STDIN terminal.
     59 * The characters are copied in buffer pointed by the <string> argument.
     60 * If the number of captured characters exceeds <maxlen>, all characters are discarded,
     61 * and removed from the <string> buffer, and a new string capture start.
     62 * - All printable characters 'c' such as (0x20 <= c) and (c < 0x7f) are echoed
     63 *   and copied in the target buffer.
     64 * - The LF (0x0A) or CR (0x13) characters are interpreted as "end of string".
     65 *   It is echoed, and replaced by the NUL (0x00) character in the target buffer.
     66 * - The DEL (0x7F), BS (0x08) control characters are taken into account, and can be
     67 *   used to correct both the buffer content and the echoed string.
     68 * - All other non printable characters are discarded
     69 ***************************************************************************************
     70 * @ string   : pointer on the user space string buffer.
     71 * @ maxlen   : max number of bytes in string buffer, including the terminating NUL.
     72 * @ returns string length (including NUL) if success / returns 0 if failure.
     73 **************************************************************************************/
     74int get_string( char * string,
     75                int    maxlen );
     76
    3877
    3978
     
    112151                   unsigned int * lid );
    113152
     153/***************************************************************************************
     154 * This syscall returns in the user buffer defined by the <u_buf> and <size> arguments
     155 * a string containing the description of the processes registered in cluster specified
     156 * by the <cxy> argument (one line per process in the NUL terminated string).
     157 * Only the owned processes are returned when the <owned> argument is non zero.
     158 * It can be called by any thread running in any cluster.
     159 ***************************************************************************************
     160 * @ cxy      : [in] target cluster identifier.
     161 * @ owned    : [in] only owned processes if non zero.
     162 * @ return 0 if success / return -1 if illegal argument.
     163 **************************************************************************************/
     164int get_processes( unsigned int   cxy,
     165                   unsigned int   owned,
     166                   char         * u_buf,
     167                   unsigned int   size );
     168
    114169/***************************************************************************************
    115170 * This function returns the value contained in the calling core cycles counter,
     
    120175 **************************************************************************************/
    121176int get_cycle( unsigned long long * cycle );
    122 
    123 /***************************************************************************************
    124  * This syscall allows the calling thread to specify the target cluster for
    125  * a subsequent fork(). It must be called for each fork().
    126  ***************************************************************************************
    127  * @ cxy      : [in] target cluster identifier.
    128  * @ return 0 if success / returns -1 if illegal cxy argument.
    129  **************************************************************************************/
    130 int place_fork( unsigned int cxy );
    131 
    132 /***************************************************************************************
    133  * This syscall implements the operations related to User Thread Local Storage.
    134  ***************************************************************************************
    135  * @ operation  : UTLS operation type as defined in "shared_sycalls.h" file.
    136  * @ value      : argument value for the UTLS_SET operation.
    137  * @ return value for the UTLS_GET and UTLS_GET_ERRNO / return -1 if failure.
    138  **************************************************************************************/
    139 int utls( unsigned int operation,
    140           unsigned int value );
    141 
    142 /***************************************************************************************
    143  * This syscall returns an 32 bits integer from the TXT terminal.
    144  * The value is copied in buffer pointed by the <buf> argument
    145  * Both decimal numbers and hexadecimal numbers (prefixed by 0x) are supported.
    146  ***************************************************************************************
    147  * @ buffer    : pointer on buffer.
    148  * @ returns 0 if success / returns -1 if failure.
    149  **************************************************************************************/
    150 void get_uint32( unsigned int * buffer );
    151 
    152 
    153 /***************************************************************************************
    154  * These syscalls return a NUL terminated character string from the TXT terminal.
    155  * The characters are copied in buffer pointed by the <string> argument.
    156  * If the number of characters exceeds <maxlen>, all read characters are discarded,
    157  * and removed from the <string> buffer, and a new string capture start.
    158  * - Only printable characters c such as (0x20 <= c) and (c < 0x7f) are echoed
    159  *   and copied in the target buffer.
    160  * - The LF (0x0A) character signaling the end of string is replaced by an extra
    161  *   NUL (0x00) character in the target buffer.
    162  * - the DEL (0x7F), BS (0x08) control characters are taken into account, and can be
    163  *   used to correct both the buffer content and the echoed string.
    164  ***************************************************************************************
    165  * @ string   : pointer on the user space string buffer.
    166  * @ maxlen   : max number of bytes in string buffer, including the terminating NUL.
    167  * @ returns string length (including NUL) if success / returns 0 if failure.
    168  **************************************************************************************/
    169 int get_string( char * string,
    170                 int    maxlen );
    171 
    172 
    173 /***************** Non standard (ALMOS-MKH specific) debug functions ******************/
    174177
    175178/***************************************************************************************
     
    182185int get_thread_info( thread_info_t * info );
    183186
     187/***************************************************************************************
     188 * This syscall allows the calling thread to specify the target cluster for
     189 * a subsequent fork(). It must be called for each fork().
     190 ***************************************************************************************
     191 * @ cxy      : [in] target cluster identifier.
     192 * @ return 0 if success / returns -1 if illegal cxy argument.
     193 **************************************************************************************/
     194int place_fork( unsigned int cxy );
     195
     196/***************************************************************************************
     197 * This syscall implements the operations related to User Thread Local Storage.
     198 ***************************************************************************************
     199 * @ operation  : UTLS operation type as defined in "shared_sycalls.h" file.
     200 * @ value      : argument value for the UTLS_SET operation.
     201 * @ return value for the UTLS_GET and UTLS_GET_ERRNO / return -1 if failure.
     202 **************************************************************************************/
     203int utls( unsigned int operation,
     204          unsigned int value );
     205
     206
     207
     208/***************** Non standard (ALMOS-MKH specific) debug functions ******************/
     209
    184210/***************************************************************************************
    185211 * This debug syscall displays on the kernel terminal TXT0
    186  * the thread / process / core identifiers, the current cycle, plus a user defined
    187  * message as specified by the <string> argument.
     212 * an user defined message specified by the <string> argument, plus the current cycle.
    188213 ***************************************************************************************
    189214 * @ string    : [in] user defined message.
Note: See TracChangeset for help on using the changeset viewer.