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.

File:
1 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
Note: See TracChangeset for help on using the changeset viewer.