Changeset 657 for trunk/libs


Ignore:
Timestamp:
Mar 18, 2020, 11:16:59 PM (4 years ago)
Author:
alain
Message:

Introduce remote_buf.c/.h & socket.c/.h files.
Update dev_nic.c/.h files.

Location:
trunk/libs/libalmosmkh
Files:
2 edited

Legend:

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

    r650 r657  
    22 * almosmkh.c - User level ALMOS-MKH specific library implementation.
    33 *
    4  * Author     Alain Greiner (2016,2017,2018,2019)
     4 * Author     Alain Greiner (2016,2017,2018,2019,2020)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    122122}
    123123
    124 ///////////////////////////////
    125 unsigned int get_uint32( void )
     124///////////////////////////////////////
     125int get_uint32( unsigned int * buffer )
    126126{
    127127    unsigned int  i;
     
    168168        else if ( c == 0 )                                      // EOF character
    169169        {
    170             return -1;
     170            overflow = 1;
     171            done     = 1;
    171172        }
    172173
     
    208209    {
    209210        // return value
    210         return value;
     211        *buffer = value;
     212        return 0;
    211213    }
    212214    else
     
    222224
    223225        // return 0 value
    224         return 0;
     226        *buffer = 0;
     227        return -1;
    225228    }
    226229}  // end get_uint32()
     
    388391
    389392///////////////////////////////////////
    390 int display_fat( unsigned int  page_id,
    391                  unsigned int  nb_entries )
     393int display_fat( unsigned int  min_slot,
     394                 unsigned int  nb_slots )
    392395{
    393396    return hal_user_syscall( SYS_DISPLAY,
    394397                             DISPLAY_FAT,
    395                              (reg_t)page_id,
    396                              (reg_t)nb_entries, 0 );
     398                             (reg_t)min_slot,
     399                             (reg_t)nb_slots, 0 );
    397400}
    398401
     
    412415{
    413416   char          cmd;
     417   int           error;
    414418
    415419   while( 1 )
     
    424428        if( cmd == 'b' )
    425429        {
     430            unsigned int pid;
     431            unsigned int trdid;
     432
    426433            printf("b / pid = ");
    427             unsigned int pid = get_uint32();
     434            error = get_uint32( &pid );
     435
    428436            printf(" / trdid = ");
    429             unsigned int trdid = get_uint32();
    430             display_busylocks( pid , trdid );
     437            error |= get_uint32( &trdid );
     438
     439            if( error == 0 ) display_busylocks( pid , trdid );
    431440        }
    432441        // return to calling process
     
    436445            break;
    437446        }
    438         // display FAT mapper(page,entries)
     447        // display FAT mapper(min,slots)
    439448        else if( cmd == 'f' )
    440449        {
    441             printf("f / page = ");
    442             unsigned int page = get_uint32();
    443             printf(" / entries = ");
    444             unsigned int entries = get_uint32();
    445             display_fat( page , entries );
     450            unsigned int min;
     451            unsigned int slots;
     452
     453            printf(" / min = ");
     454            error = get_uint32( &min );
     455
     456            printf(" / slots = ");
     457            error |= get_uint32( &slots );
     458
     459            if( error == 0 ) display_fat( min , slots );
    446460        }
    447461        // list all supported commands
     
    451465                   "- b : display on TXT0 busylocks taken by thread[pid,trdid]\n"
    452466                   "- c : resume calling process execution\n"
    453                    "- f : display on TXT0 FAT mapper[page,entries]\n"
     467                   "- f : display on TXT0 FAT mapper[min_slot,nb_slotss]\n"
    454468                   "- h : list of supported commands\n"
    455469                   "- m : display on TXT0 mapper[path,page,nbytes]\n"
     
    467481        {
    468482            char  path[128];
     483            unsigned int page;
     484            unsigned int nbytes;
     485
    469486            printf("m / path = ");
    470             int error = get_string( path , 128 );
     487            error = get_string( path , 128 );
     488
    471489            printf(" / page = ");
    472             unsigned int page = get_uint32();
     490            error |= get_uint32( &page );
     491
    473492            printf(" / nbytes = ");
    474             unsigned int nbytes = get_uint32();
     493            error |= get_uint32( &nbytes );
     494
    475495            if( error == 0 ) display_mapper( path , page , nbytes );
    476496        }
     
    478498        else if( cmd == 'p' )
    479499        {
     500            unsigned int cxy;
     501
    480502            printf("p / cxy = ");
    481             unsigned int cxy = get_uint32();
    482             display_cluster_processes( cxy , 0 );
     503            error = get_uint32( &cxy );
     504
     505            if( error == 0 ) display_cluster_processes( cxy , 0 );
    483506        }
    484507        // display DQDT
     
    491514        else if( cmd == 's' )
    492515        {
     516            unsigned int cxy;
     517            unsigned int lid;
     518
    493519            printf("s / cxy = ");
    494             unsigned int cxy = get_uint32();
     520            error = get_uint32( &cxy );
     521
    495522            printf(" / lid = ");
    496             unsigned int lid = get_uint32();
    497             display_sched( cxy , lid );
     523            error |= get_uint32( &lid );
     524
     525            if( error == 0 ) display_sched( cxy , lid );
    498526        }
    499527        // display all processes attached to TXT(txt_id)
    500528        else if( cmd == 't' )
    501529        {
     530            unsigned int txt_id;
     531
    502532            printf("t / txt_id = ");
    503             unsigned int txt_id = get_uint32();
    504             display_txt_processes( txt_id );
     533            error = get_uint32( &txt_id );
     534
     535            if( error == 0 ) display_txt_processes( txt_id );
    505536        }
    506537        // display vmm state for process(cxy, pid)
    507538        else if( cmd == 'v' )
    508539        {
     540            unsigned int cxy;
     541            unsigned int pid;
     542            unsigned int map;
     543
    509544            printf("v / cxy = ");
    510             unsigned int cxy = get_uint32();
     545            error = get_uint32( &cxy );
     546
    511547            printf(" / pid = ");
    512             unsigned int pid = get_uint32();
     548            error |= get_uint32( &pid );
     549
    513550            printf(" / mapping = ");
    514             unsigned int map = get_uint32();
    515             display_vmm( cxy , pid , map );
     551            error |= get_uint32( &map );
     552
     553            if( error == 0 ) display_vmm( cxy , pid , map );
    516554        }
    517555        // force the calling process to exit
     
    524562        else if( cmd == 'y' )
    525563        {
     564            unsigned int active;
     565            unsigned int cxy;
     566            unsigned int lid;
     567
    526568            printf("y / active = ");
    527             unsigned int active = get_uint32();
     569            error = get_uint32( &active );
     570
    528571            printf(" / cxy = ");
    529             unsigned int cxy    = get_uint32();
     572            error |= get_uint32( &cxy );
     573
    530574            printf(" / lid = ");
    531             unsigned int lid    = get_uint32();
    532             trace( active , cxy , lid );
     575            error |= get_uint32( &lid );
     576
     577            if( error == 0 ) trace( active , cxy , lid );
    533578        }
    534579    }  // en while
     
    15001545{
    15011546    return hal_user_syscall( SYS_FBF,
    1502                              FBF_GET_CONFIG,
     1547                             (reg_t)FBF_GET_CONFIG,
    15031548                             (reg_t)width,
    15041549                             (reg_t)height,                           
     
    15121557{
    15131558    return hal_user_syscall( SYS_FBF,
    1514                              FBF_READ,
     1559                             (reg_t)FBF_DIRECT_READ,
    15151560                             (reg_t)buffer,
    15161561                             (reg_t)length,                           
     
    15241569{
    15251570    return hal_user_syscall( SYS_FBF,
    1526                              FBF_WRITE,
     1571                             (reg_t)FBF_DIRECT_WRITE,
    15271572                             (reg_t)buffer,
    15281573                             (reg_t)length,                           
    15291574                             (reg_t)offset );   
     1575}
     1576
     1577//////////////////////////////////////////////
     1578int fbf_create_window( unsigned int    l_zero,
     1579                       unsigned int    p_zero,
     1580                       unsigned int    nlines,
     1581                       unsigned int    npixels,
     1582                       void         ** buffer )
     1583{
     1584    return hal_user_syscall( SYS_FBF,
     1585                             (reg_t)FBF_CREATE_WINDOW,
     1586                             (reg_t)((l_zero << 16) | p_zero),
     1587                             (reg_t)((nlines << 16) | npixels),
     1588                             (reg_t)buffer );
     1589}
     1590
     1591//////////////////////////////////////////
     1592int fbf_delete_window( unsigned int  wid )
     1593{
     1594    return hal_user_syscall( SYS_FBF,
     1595                             (reg_t)FBF_DELETE_WINDOW,
     1596                             (reg_t)wid, 0, 0 );
     1597}
     1598
     1599///////////////////////////////////////
     1600int fbf_move_window( unsigned int  wid,
     1601                     unsigned int  l_zero,
     1602                     unsigned int  p_zero )
     1603{
     1604    return hal_user_syscall( SYS_FBF,
     1605                             (reg_t)FBF_MOVE_WINDOW,
     1606                             (reg_t)wid,
     1607                             (reg_t)l_zero,
     1608                             (reg_t)p_zero );
     1609}
     1610
     1611/////////////////////////////////////////
     1612int fbf_resize_window( unsigned int  wid,
     1613                       unsigned int  width,
     1614                       unsigned int  height )
     1615{
     1616    return hal_user_syscall( SYS_FBF,
     1617                             (reg_t)FBF_RESIZE_WINDOW,
     1618                             (reg_t)wid,
     1619                             (reg_t)width,
     1620                             (reg_t)height );
     1621}
     1622
     1623//////////////////////////////////////////
     1624int fbf_refresh_window( unsigned int  wid,
     1625                        unsigned int  line_first,
     1626                        unsigned int  line_last )
     1627{
     1628    return hal_user_syscall( SYS_FBF,
     1629                             (reg_t)FBF_REFRESH_WINDOW,
     1630                             (reg_t)wid,
     1631                             (reg_t)line_first,
     1632                             (reg_t)line_last );
    15301633}
    15311634
  • trunk/libs/libalmosmkh/almosmkh.h

    r650 r657  
    22 * almosmkh.h - User level ALMOS-MKH specific library definition.
    33 *
    4  * Author     Alain Greiner (2016,2017,2018,2019)
     4 * Author     Alain Greiner (2016,2017,2018,2019,2020)
    55 *
    66 * Copyright (c) UPMC Sorbonne Universites
     
    2929 * - non standard system calls.
    3030 * - debug functions.
    31  * - remote malloc extensions.
     31 * - remote malloc extensions.
     32 * - a parallel_pthread_create function.
     33 * - Frame Buffer access syscalls.
    3234 **************************************************************************************/
    3335
    3436#include <pthread.h>
    3537#include <shared_almos.h>
     38
    3639
    3740/****************** Non standard (ALMOS_MKH specific) system calls ********************/
     
    138141
    139142/***************************************************************************************
    140  * This syscall returns an unsigned 32 bits integer from the standard "stdin" stream.
     143 * This syscall returns an 32 bits integer from the standard "stdin" stream.
     144 * The value is copied in buffer pointed by the <buf> argument
    141145 * Both decimal numbers and hexadecimal numbers (prefixed by 0x) are supported.
    142146 ***************************************************************************************
    143  * returns the integer value if success / returns -1 if failure.
    144  **************************************************************************************/
    145 unsigned int get_uint32( void );
     147 * @ buffer    : pointer on buffer.
     148 * @ returns 0 if success / returns -1 if failure.
     149 **************************************************************************************/
     150int get_uint32( unsigned int * buffer );
     151
     152/***************************************************************************************
     153 * This syscall returns a character string from the standard "stdin" stream.
     154 * 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.
     157 ***************************************************************************************
     158 * @ string   : pointer on the string buffer.
     159 * @ maxlen   : max number of bytes in string buffer.
     160 * @ returns 0 if success / returns -1 if failure.
     161 **************************************************************************************/
     162int get_string( char * string,
     163                int    maxlen );
    146164
    147165
     
    278296
    279297/***************************************************************************************
    280  * This debug syscall displays on the kernel terminal TXT0 the content of one given
    281  * page of the FAT mapper.
    282  * It can be called by any thread running in any cluster.
    283  ***************************************************************************************
    284  * @ page_id    : page index in file.
    285  * @ nb_entries : number of bytes to display.
     298 * This debug syscall displays on the kernel terminal TXT0 the content of <nb_slots>
     299 * of the FAT mapper, starting from <min_slot>.
     300 * If <nb_slots> is zero, it displays the state of the FATFS context in cluster
     301 * defined by the <min_slot> argument interpreted as a cluster identifier.
     302 * It can be called by any thread running in any cluster.
     303 ***************************************************************************************
     304 * @ min_slot   : first slot in page
     305 * @ nb_slots   : number of slots to display.
    286306 * @ return 0 if success / return -1 if page not found.
    287307 **************************************************************************************/
    288 int display_fat( unsigned int page_id,
    289                  unsigned int nb_entries );
     308int display_fat( unsigned int min_slot,
     309                 unsigned int nb_slots );
    290310
    291311/*****************************************************************************************
     
    551571
    552572
    553 
    554 
    555573/********* Non standard (ALMOS-MKH specific) Frame Buffer access syscalls   *************/
    556574
     
    562580
    563581/*****************************************************************************************
    564  * This function returns in the <width> and <height> arguments the buffer size.
     582 * This function returns in the <width>, <height> and <type> arguments
     583 * the implementation specific frame buffer features.
    565584 *****************************************************************************************
    566585 * @ width   : [out] number of pixels per line.
    567586 * @ height  : [out] number of lines.
    568587 * @ type    : [out] pixel encoding type.
    569  * @ returns 0 if success / returns -1 if error.
     588 * @ returns 0 if success / returns -1 if not found.
    570589 ****************************************************************************************/
    571590int fbf_get_config( unsigned int * width,
     
    574593
    575594/*****************************************************************************************
    576  * This blocking function moves <length> bytes from the frame buffer, starting
    577  * from <offset>, to the user buffer defined by <buffer> argument.
     595 * This function creates a new window defined by the <l_zero>, <p_zero>, <nlines>,
     596 * and <npixels> arguments for the calling process, and register the process PID, the
     597 * allocated <wid>, and the window size and coordinates in the FBF device descriptor.
     598 * It returns in the output argument <buffer> the pointer on the buffer associated to
     599 * the window, mapped in user space.
     600 * Warning : Both pixel [p_zero,l_zero] and pixel [p_zero+npixels-1,l_zero+nlines-1]
     601 * must be contained in the frame buffer.
     602 *****************************************************************************************
     603 * @ l_zero  : [in]  first line index in FBF coordinates system.
     604 * @ p_zero  : [in]  first pixel index in FBF coordinates system.
     605 * @ nlines  : [in]  number of lines in the window.
     606 * @ npixels : [in]  number of pixels per line in the window.
     607 * @ buffer  : [out] pointer on
     608 * @ returns <wid> if success / returns -1 if illegal size or coordinates.
     609 ****************************************************************************************/
     610int fbf_create_window( unsigned int   l_zero,
     611                       unsigned int   p_zero,
     612                       unsigned int   nlines,
     613                       unsigned int   npixels,
     614                       void        ** buffer );
     615
     616/*****************************************************************************************
     617 * This function deletes an existing window, identified by the <wid> argument.
     618 * The calling process must be the window owner.
     619 *****************************************************************************************
     620 * @ wid     : window identifier.
     621 * @ returns 0 if success / returns -1 if not found or process not owner.
     622 ****************************************************************************************/
     623int fbf_delete_window( unsigned int  wid );
     624
     625/*****************************************************************************************
     626 * This function refreshes in FBF all lines of a window identified by the <wid> argument,
     627 * when the line index is in the interval [line_first,line_last[.
     628 * It scans all registered windows to take into account the windows overlap.
     629 *****************************************************************************************
     630 * @ wid        : window identifier.
     631 * @ line_first : first line index.
     632 * @ line_last  : last line index (excluded).
     633 * @ returns 0 if success / returns -1 if illegal argument.
     634 ****************************************************************************************/
     635int fbf_refresh_window( unsigned int   wid,
     636                        unsigned int   line_first,
     637                        unsigned int   line_last );
     638
     639/*****************************************************************************************
     640 * This function changes the size of a window identified by the <wid> argument as defined
     641 * by the <width> and height> arguments. The calling process must be the window owner.
     642 * WARNING : Both pixel [p_zero,l_zero] and pixel [p_zero+width-1,l_zero+height-1]
     643 * must be contained in the frame buffer.
     644 *****************************************************************************************
     645 * @ wid     : window identifier.
     646 * @ width   : number of pixels in line (one byte per pixel).
     647 * @ height  : number of lines in window.
     648 * @ returns 0 if success / returns -1 if illegal arguments.
     649 ****************************************************************************************/
     650int fbf_resize_window( unsigned int   wid,
     651                       unsigned int   width,
     652                       unsigned int   height );
     653
     654/*****************************************************************************************
     655 * This function changes the <l_zero> & <p_zero> coordinates of a window identified
     656 * by the <wid> argument. The calling process must be the window owner.
     657 * WARNING : Both pixel [p_zero,l_zero] and pixel [p_zero+width-1,l_zero+height-1]
     658 * must be contained in the frame buffer.
     659 *****************************************************************************************
     660 * @ wid     : window identifier.
     661 * @ l_zero  : new first line index in FBF.
     662 * @ p_zero  : new first pixel index in FBF.
     663 * @ returns 0 if success / returns -1 if illegal arguments.
     664 ****************************************************************************************/
     665int fbf_move_window( unsigned int  wid,
     666                     unsigned int  l_zero,
     667                     unsigned int  p_zero );
     668
     669/*****************************************************************************************
     670 * This syscall is deprecated (january 2020 AG)
     671 * This blocking function moves <length> pixels from the user buffer defined by <buffer>
     672 * argument to the frame buffer, starting at <offset> in FBF.
    578673 *****************************************************************************************
    579674 * @ buffer  : pointer on buffer in user space.
    580675 * @ length  : number of pixels (one byte per pixel).
    581  * @ offset  : first pixel index in frame buffer.
    582  * @ returns 0 if success / returns -1 if error.
     676 * @ offset  : first pixel index in window.
     677 * @ returns 0 if success / returns -1 if illegal arguments.
     678 ****************************************************************************************/
     679int fbf_write( void         * buffer,
     680               unsigned int   length,
     681               unsigned int   offset );
     682
     683/*****************************************************************************************
     684 * This syscall is deprecated (january 2020 AG)
     685 * This blocking function moves <length> pixels from the frame buffer, starting at
     686 * <offset> in FBF, to the user buffer defined by <buffer>  argument.
     687 *****************************************************************************************
     688 * @ buffer  : pointer on buffer in user space.
     689 * @ length  : number of pixels (one byte per pixel).
     690 * @ offset  : first pixel index in window.
     691 * @ returns 0 if success / returns -1 if illegal arguments.
    583692 ****************************************************************************************/
    584693int fbf_read( void         * buffer,
     
    586695              unsigned int   offset );
    587696
    588 /*****************************************************************************************
    589  * This blocking function moves <length> bytes from the user buffer defined by <buffer>
    590  * argument to the frame buffer, starting at <offset> in frame buffer.
    591  *****************************************************************************************
    592  * @ buffer  : pointer on buffer in user space.
    593  * @ length  : number of pixels (one byte per pixel).
    594  * @ offset  : first pixel index in frame buffer.
    595  * @ returns 0 if success / returns -1 if error.
    596  ****************************************************************************************/
    597 int fbf_write( void         * buffer,
    598                unsigned int   length,
    599                unsigned int   offset );
    600697
    601698#endif /* _LIBALMOSMKH_H_ */
Note: See TracChangeset for help on using the changeset viewer.