Changeset 5 for trunk/kernel/kern/rpc.c


Ignore:
Timestamp:
Apr 26, 2017, 2:11:56 PM (7 years ago)
Author:
alain
Message:

Introduce the chdev_t structure in place of the device_t structure.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/kern/rpc.c

    r1 r5  
    3333#include <core.h>
    3434#include <mapper.h>
    35 #include <device.h>
     35#include <chdev.h>
    3636#include <bits.h>
    3737#include <thread.h>
     
    5555    &rpc_thread_user_create_server,     // 4
    5656    &rpc_thread_kernel_create_server,   // 5
    57     &rpc_icu_wti_alloc_server,          // 6                       
    58     &rpc_device_alloc_server,           // 7
     57    &rpc_undefined,                     // 6                       
     58    &rpc_undefined,                     // 7
    5959    &rpc_undefined,                     // 8
    6060    &rpc_undefined,                     // 9
     
    10181018
    10191019/////////////////////////////////////////////////////////////////////////////////////////
    1020 //               Marshaling functions attached to RPC_ICU_WTI_ALLOC
    1021 /////////////////////////////////////////////////////////////////////////////////////////
    1022 
    1023 //////////////////////////////////////////////
    1024 void rpc_icu_wti_alloc_client( cxy_t      cxy,
    1025                                uint32_t * wti_id )    // out
    1026 {
    1027     // RPC must be remote
    1028     if( cxy == local_cxy )
    1029     {
    1030         printk("PANIC in %s : target is not remote\n", __FUNCTION__ );
    1031         hal_core_sleep();
    1032     }
    1033 
    1034     // initialise RPC descriptor header
    1035     rpc_desc_t  rpc;
    1036     rpc.index    = RPC_ICU_WTI_ALLOC;
    1037     rpc.response = 1;
    1038 
    1039     // register RPC request in remote RPC fifo
    1040     rpc_send_sync( cxy , &rpc );
    1041 
    1042     // get output argument from rpc descriptor
    1043     *wti_id = (uint32_t)rpc.args[0];
    1044 }
    1045 
    1046 //////////////////////////////////////////
    1047 void rpc_icu_wti_alloc_server( xptr_t xp )
    1048 {
    1049     uint32_t      wti_id;
    1050 
    1051     // get client cluster identifier and pointer on RPC descriptor
    1052     cxy_t        client_cxy  = (cxy_t)GET_CXY( xp );
    1053     rpc_desc_t * desc = (rpc_desc_t *)GET_PTR( xp );
    1054 
    1055     // call icu_wti_alloc() function
    1056     wti_id = dev_icu_wti_alloc();
    1057 
    1058     // set output argument
    1059     hal_remote_swd( XPTR( client_cxy , &desc->args[0] ) , (uint64_t)wti_id);
    1060 }
    1061 
    1062 /////////////////////////////////////////////////////////////////////////////////////////
    1063 //               Marshaling functions attached to RPC_DEVICE_ALLOC
    1064 /////////////////////////////////////////////////////////////////////////////////////////
    1065 
    1066 /////////////////////////////////////////////
    1067 void rpc_device_alloc_client( cxy_t     cxy,
    1068                               xptr_t  * dev_xp,      // out
    1069                               error_t * error )      // out
    1070 {
    1071     // RPC must be remote
    1072     if( cxy == local_cxy )
    1073     {
    1074         printk("PANIC in %s : target is not remote\n", __FUNCTION__ );
    1075         hal_core_sleep();
    1076     }
    1077 
    1078     // initialise RPC descriptor header
    1079     rpc_desc_t  rpc;
    1080     rpc.index    = RPC_DEVICE_ALLOC;
    1081     rpc.response = 1;
    1082 
    1083     // register RPC request in remote RPC fifo
    1084     rpc_send_sync( cxy , &rpc );
    1085 
    1086     // get output argument from rpc descriptor
    1087     *dev_xp = (xptr_t)rpc.args[0];
    1088     *error  = (error_t)rpc.args[1];
    1089 }   
    1090 
    1091 /////////////////////////////////////////
    1092 void rpc_device_alloc_server( xptr_t xp )
    1093 {
    1094     error_t      error;
    1095     kmem_req_t   req;
    1096     device_t   * dev_ptr; 
    1097     xptr_t       dev_xp;
    1098 
    1099     // get client cluster identifier and pointer on RPC descriptor
    1100     cxy_t        client_cxy  = (cxy_t)GET_CXY( xp );
    1101     rpc_desc_t * desc = (rpc_desc_t *)GET_PTR( xp );
    1102 
    1103     // allocate memory for a device descriptor
    1104     req.type   = KMEM_DEVICE;
    1105     req.flags  = AF_ZERO;
    1106     dev_ptr    = (device_t *)kmem_alloc( &req );
    1107 
    1108     // set output arguments
    1109     error  = ( dev_ptr == NULL );
    1110     dev_xp = XPTR( local_cxy , dev_ptr );
    1111     hal_remote_swd( XPTR( client_cxy , &desc->args[0] ) , (uint64_t)dev_xp );
    1112     hal_remote_swd( XPTR( client_cxy , &desc->args[1] ) , (uint64_t)error );
    1113 }
    1114 
    1115 
    1116 /////////////////////////////////////////////////////////////////////////////////////////
    11171020//               Marshaling functions attached to RPC_FATFS_GET_CLUSTER
    11181021/////////////////////////////////////////////////////////////////////////////////////////
     
    11901093    bool_t     first;
    11911094    reg_t      sr_save;
     1095
     1096printk("\n@@@ coucou 0\n");
    11921097
    11931098    // get client CPU and cluster coordinates
     
    12201125    while( error );
    12211126 
     1127printk("\n@@@ coucou 1\n");
     1128
    12221129    rpc_dmsg("\n[INFO] %s on core %d in cluster %x sent RPC %p to cluster %x\n",
    12231130              __FUNCTION__ , client_lid , client_cxy , rpc , server_cxy );
     
    12401147        }
    12411148
     1149printk("\n@@@ coucou 2\n");
     1150
    12421151        // activate preemption to allow incoming RPC and avoid deadlock
    12431152        if( this->type == THREAD_RPC ) hal_enable_irq( &sr_save );
     
    12481157        if( rpc->response == 0 ) break;
    12491158    }
     1159
     1160printk("\n@@@ coucou 3\n");
    12501161
    12511162    // restore preemption
     
    14251336    error_t      error;
    14261337
    1427     // do nothing if light lock already taken or FIFO empty 
     1338    // calling thread does nothing if light lock already taken or FIFO empty 
    14281339        if( (rpc_fifo->owner != 0) || (local_fifo_is_empty( &rpc_fifo->fifo )) )
    14291340    {
     
    14311342    }
    14321343
    1433         // The calling thread try to take the light lock,
    1434     // and activate an RPC thread if success
     1344        // calling thread tries to take the light lock,
     1345    // and activates an RPC thread if success
    14351346    if( hal_atomic_test_set( &rpc_fifo->owner , this->trdid ) )
    14361347        {
     
    14521363        return false;
    14531364    }
    1454 } // end __rpc_check()
     1365} // end rpc_check()
    14551366
    14561367
Note: See TracChangeset for help on using the changeset viewer.