Changeset 317 for trunk/kernel


Ignore:
Timestamp:
Aug 4, 2017, 2:03:44 PM (4 years ago)
Author:
alain
Message:

1) Introduce the TSAR hal_cpu_context_switch() function.
2) Introduce the generic vfs_kernel_move() function.

Location:
trunk/kernel
Files:
6 edited

Legend:

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

    r296 r317  
    3333#include <chdev.h>
    3434#include <devfs.h>
     35
     36
     37extern chdev_directory_t    chdev_dir;   // allocated in kernel_init.c
     38
    3539
    3640////////////////////////////////////////////
     
    188192}  // end chdev_sequencial_server()
    189193
     194////////////////////////
     195void chdev_dir_display()
     196{
     197    cxy_t     iob_cxy  = GET_CXY( chdev_dir.iob );
     198    chdev_t * iob_ptr  = (chdev_t *)GET_PTR( chdev_dir.iob );
     199    xptr_t    iob_base = hal_remote_lwd( XPTR( iob_cxy , &iob_ptr->base ) );
     200
     201    cxy_t     pic_cxy  = GET_CXY( chdev_dir.pic );
     202    chdev_t * pic_ptr  = (chdev_t *)GET_PTR( chdev_dir.pic );
     203    xptr_t    pic_base = hal_remote_lwd( XPTR( pic_cxy , &pic_ptr->base ) );
     204
     205    cxy_t     txt0_cxy  = GET_CXY( chdev_dir.txt[0] );
     206    chdev_t * txt0_ptr  = (chdev_t *)GET_PTR( chdev_dir.txt[0] );
     207    xptr_t    txt0_base = hal_remote_lwd( XPTR( txt0_cxy , &txt0_ptr->base ) );
     208
     209    cxy_t     txt1_cxy  = GET_CXY( chdev_dir.txt[1] );
     210    chdev_t * txt1_ptr  = (chdev_t *)GET_PTR( chdev_dir.txt[1] );
     211    xptr_t    txt1_base = hal_remote_lwd( XPTR( txt1_cxy , &txt1_ptr->base ) );
     212
     213    cxy_t     txt2_cxy  = GET_CXY( chdev_dir.txt[2] );
     214    chdev_t * txt2_ptr  = (chdev_t *)GET_PTR( chdev_dir.txt[2] );
     215    xptr_t    txt2_base = hal_remote_lwd( XPTR( txt2_cxy , &txt2_ptr->base ) );
     216
     217    cxy_t     ioc_cxy  = GET_CXY( chdev_dir.ioc[0] );
     218    chdev_t * ioc_ptr  = (chdev_t *)GET_PTR( chdev_dir.ioc[0] );
     219    xptr_t    ioc_base = hal_remote_lwd( XPTR( ioc_cxy , &ioc_ptr->base ) );
     220
     221    cxy_t     fbf_cxy  = GET_CXY( chdev_dir.fbf[0] );
     222    chdev_t * fbf_ptr  = (chdev_t *)GET_PTR( chdev_dir.fbf[0] );
     223    xptr_t    fbf_base = hal_remote_lwd( XPTR( fbf_cxy , &fbf_ptr->base ) );
     224
     225    cxy_t     nic_rx_cxy  = GET_CXY( chdev_dir.nic_rx[0] );
     226    chdev_t * nic_rx_ptr  = (chdev_t *)GET_PTR( chdev_dir.nic_rx[0] );
     227    xptr_t    nic_rx_base = hal_remote_lwd( XPTR( nic_rx_cxy , &nic_rx_ptr->base ) );
     228
     229    cxy_t     nic_tx_cxy  = GET_CXY( chdev_dir.nic_tx[0] );
     230    chdev_t * nic_tx_ptr  = (chdev_t *)GET_PTR( chdev_dir.nic_tx[0] );
     231    xptr_t    nic_tx_base = hal_remote_lwd( XPTR( nic_tx_cxy , &nic_tx_ptr->base ) );
     232
     233    printk("\n***** external chdev directory in cluster %x\n"
     234           "  - iob       = %l / base = %l\n"
     235           "  - pic       = %l / base = %l\n"
     236           "  - txt[0]    = %l / base = %l\n"
     237           "  - txt[1]    = %l / base = %l\n"
     238           "  - txt[2]    = %l / base = %l\n"
     239           "  - ioc[0]    = %l / base = %l\n"
     240           "  - fbf[0]    = %l / base = %l\n"
     241           "  - nic_rx[0] = %l / base = %l\n"
     242           "  - nic_tx[0] = %l / base = %l\n",
     243           local_cxy,
     244           chdev_dir.iob, iob_base,
     245           chdev_dir.pic, pic_base,
     246           chdev_dir.txt[0], txt0_base,
     247           chdev_dir.txt[1], txt1_base,
     248           chdev_dir.txt[2], txt2_base,
     249           chdev_dir.ioc[0], ioc_base,
     250           chdev_dir.fbf[0], fbf_base,
     251           chdev_dir.nic_rx[0], nic_rx_base,
     252           chdev_dir.nic_tx[0], nic_tx_base );
     253
     254}  // end chdev_dir_display()
     255
  • trunk/kernel/kern/chdev.h

    r279 r317  
    233233void chdev_sequencial_server( chdev_t * chdev );
    234234
     235/******************************************************************************************
     236 * This function displays the local copy of the external chdevs directory.
     237 * (global variable replicated in all clusters)
     238 *****************************************************************************************/
     239void chdev_dir_display();
     240
     241
    235242
    236243#endif  /* _CHDEV_H_ */
  • trunk/kernel/kern/kernel_init.c

    r296 r317  
    656656    }
    657657    return EINVAL;
    658 }
    659 
    660 ////////////////////////////////////////////////////////////////////////////////////////////
    661 // This function display on TXT0 the content of the external chdev directory,
    662 // in the local cluster.
    663 ////////////////////////////////////////////////////////////////////////////////////////////
    664 static void chdev_dir_display( )
    665 {
    666     cxy_t     iob_cxy  = GET_CXY( chdev_dir.iob );
    667     chdev_t * iob_ptr  = (chdev_t *)GET_PTR( chdev_dir.iob );
    668     xptr_t    iob_base = hal_remote_lwd( XPTR( iob_cxy , &iob_ptr->base ) );
    669 
    670     cxy_t     pic_cxy  = GET_CXY( chdev_dir.pic );
    671     chdev_t * pic_ptr  = (chdev_t *)GET_PTR( chdev_dir.pic );
    672     xptr_t    pic_base = hal_remote_lwd( XPTR( pic_cxy , &pic_ptr->base ) );
    673 
    674     cxy_t     txt0_cxy  = GET_CXY( chdev_dir.txt[0] );
    675     chdev_t * txt0_ptr  = (chdev_t *)GET_PTR( chdev_dir.txt[0] );
    676     xptr_t    txt0_base = hal_remote_lwd( XPTR( txt0_cxy , &txt0_ptr->base ) );
    677 
    678     cxy_t     txt1_cxy  = GET_CXY( chdev_dir.txt[1] );
    679     chdev_t * txt1_ptr  = (chdev_t *)GET_PTR( chdev_dir.txt[1] );
    680     xptr_t    txt1_base = hal_remote_lwd( XPTR( txt1_cxy , &txt1_ptr->base ) );
    681 
    682     cxy_t     txt2_cxy  = GET_CXY( chdev_dir.txt[2] );
    683     chdev_t * txt2_ptr  = (chdev_t *)GET_PTR( chdev_dir.txt[2] );
    684     xptr_t    txt2_base = hal_remote_lwd( XPTR( txt2_cxy , &txt2_ptr->base ) );
    685 
    686     cxy_t     ioc_cxy  = GET_CXY( chdev_dir.ioc[0] );
    687     chdev_t * ioc_ptr  = (chdev_t *)GET_PTR( chdev_dir.ioc[0] );
    688     xptr_t    ioc_base = hal_remote_lwd( XPTR( ioc_cxy , &ioc_ptr->base ) );
    689 
    690     cxy_t     fbf_cxy  = GET_CXY( chdev_dir.fbf[0] );
    691     chdev_t * fbf_ptr  = (chdev_t *)GET_PTR( chdev_dir.fbf[0] );
    692     xptr_t    fbf_base = hal_remote_lwd( XPTR( fbf_cxy , &fbf_ptr->base ) );
    693 
    694     cxy_t     nic_rx_cxy  = GET_CXY( chdev_dir.nic_rx[0] );
    695     chdev_t * nic_rx_ptr  = (chdev_t *)GET_PTR( chdev_dir.nic_rx[0] );
    696     xptr_t    nic_rx_base = hal_remote_lwd( XPTR( nic_rx_cxy , &nic_rx_ptr->base ) );
    697 
    698     cxy_t     nic_tx_cxy  = GET_CXY( chdev_dir.nic_tx[0] );
    699     chdev_t * nic_tx_ptr  = (chdev_t *)GET_PTR( chdev_dir.nic_tx[0] );
    700     xptr_t    nic_tx_base = hal_remote_lwd( XPTR( nic_tx_cxy , &nic_tx_ptr->base ) );
    701 
    702     printk("\n*** external chdev directory in cluster %x\n"
    703            "  - iob       = %l / base = %l\n"
    704            "  - pic       = %l / base = %l\n"
    705            "  - txt[0]    = %l / base = %l\n"
    706            "  - txt[1]    = %l / base = %l\n"
    707            "  - txt[2]    = %l / base = %l\n"
    708            "  - ioc[0]    = %l / base = %l\n"
    709            "  - fbf[0]    = %l / base = %l\n"
    710            "  - nic_rx[0] = %l / base = %l\n"
    711            "  - nic_tx[0] = %l / base = %l\n",
    712            local_cxy,
    713            chdev_dir.iob, iob_base,
    714            chdev_dir.pic, pic_base,
    715            chdev_dir.txt[0], txt0_base,
    716            chdev_dir.txt[1], txt1_base,
    717            chdev_dir.txt[2], txt2_base,
    718            chdev_dir.ioc[0], ioc_base,
    719            chdev_dir.fbf[0], fbf_base,
    720            chdev_dir.nic_rx[0], nic_rx_base,
    721            chdev_dir.nic_tx[0], nic_tx_base );
    722658}
    723659
  • trunk/kernel/kern/scheduler.c

    r311 r317  
    358358    remote_spinlock_lock_busy( lock_xp , &save_sr );
    359359
    360     nolock_printk("\n********** scheduler state for core[%x,%d] **********************\n"
     360    nolock_printk("\n***** scheduler state for core[%x,%d]\n"
    361361           "kernel_threads = %d / user_threads = %d / current = %x\n",
    362362            local_cxy , core->lid,
  • trunk/kernel/vfs/vfs.c

    r315 r317  
    662662}  // end vfs_open()
    663663
    664 //////////////////////////////////////////
     664////////////////////////////////////////////
    665665error_t vfs_user_move( bool_t   to_buffer,
    666666                       xptr_t   file_xp,
     
    722722}  // end vfs_user_move()
    723723
     724////////////////////////////////////////////
     725error_t vfs_kernel_move( bool_t   to_buffer,
     726                         xptr_t   file_xp,
     727                         xptr_t   buffer_xp,
     728                         uint32_t size )
     729{
     730    assert( ( file_xp != XPTR_NULL ) , __FUNCTION__ , "file_xp == XPTR_NULL" );
     731
     732    cxy_t              file_cxy;     // remote file descriptor cluster
     733    vfs_file_t       * file_ptr;     // remote file descriptor local pointer
     734    vfs_inode_type_t   inode_type;
     735    uint32_t           file_offset;  // current offset in file
     736    mapper_t         * mapper;
     737    error_t            error;
     738
     739    // get cluster and local pointer on remote file descriptor
     740    file_cxy  = GET_CXY( file_xp );
     741    file_ptr  = (vfs_file_t *)GET_PTR( file_xp );
     742
     743    // get inode type from remote file descriptor
     744    inode_type = hal_remote_lw( XPTR( file_cxy , &file_ptr->type   ) );
     745   
     746    // action depends on inode type
     747    if( inode_type == INODE_TYPE_FILE )
     748    {
     749        // get mapper pointer and file offset from file descriptor
     750        file_offset = hal_remote_lw( XPTR( file_cxy , &file_ptr->offset ) );
     751        mapper = (mapper_t *)hal_remote_lpt( XPTR( file_cxy , &file_ptr->mapper ) );
     752
     753        // move data between mapper and buffer
     754        if( file_cxy == local_cxy )
     755        {
     756            error = mapper_move_kernel( mapper,
     757                                        to_buffer,
     758                                        file_offset,
     759                                        buffer_xp,
     760                                        size );
     761        }
     762        else
     763        {
     764            rpc_mapper_move_buffer_client( file_cxy,
     765                                           mapper,
     766                                           to_buffer,
     767                                           false,          // kernel buffer
     768                                           file_offset,
     769                                           buffer_xp,
     770                                           size,
     771                                           &error );
     772        }
     773
     774        if( error ) return -1;
     775        else        return 0;
     776    }
     777    else
     778    {
     779        printk("\n[ERROR] in %s : inode is not a file", __FUNCTION__ );
     780        return -1;
     781    }
     782}  // end vfs_kernel_move()
     783
    724784//////////////////////////////////////
    725785error_t vfs_lseek( xptr_t     file_xp,
  • trunk/kernel/vfs/vfs.h

    r313 r317  
    735735 * <file_xp> argument, and a - possibly distributed - user space <buffer>, taken into
    736736 * account the offset in <file_xp>. The transfer direction is defined by <to_buffer>.
    737  * This function is called by the sys_read() and sys_write() system calls.
     737 * This function is called by the elf_load_process() function.
    738738 ******************************************************************************************
    739739 * @ to_buffer : mapper -> buffer if true / buffer -> mapper if false.
     
    741741 * @ buffer    : user space pointer on buffer (can be physically distributed).
    742742 * @ size      : requested number of bytes from offset.
    743  * @ returns number of bytes actually transfered / -1 if error.
     743 * @ returns 0 f success / -1 if error.
    744744 *****************************************************************************************/
    745745error_t vfs_user_move( bool_t   to_buffer,
     
    747747                       void   * buffer,
    748748                       uint32_t size );
     749
     750/******************************************************************************************
     751 * This function moves <size> bytes between a remote file mapper, identified by the
     752 * <file_xp> argument, and a - possibly remote - kernel <buffer_xp>, taken into
     753 * account the offset in <file_xp>. The transfer direction is defined by <to_buffer>.
     754 * This function is called by the  system calls.
     755 ******************************************************************************************
     756 * @ to_buffer : mapper -> buffer if true / buffer -> mapper if false.
     757 * @ file_xp   : extended pointer on the remote file descriptor.
     758 * @ buffer_xp : user space pointer on buffer (can be physically distributed).
     759 * @ size      : requested number of bytes from offset.
     760 * @ returns number of bytes actually transfered / -1 if error.
     761 *****************************************************************************************/
     762error_t vfs_kernel_move( bool_t   to_buffer,
     763                         xptr_t   file_xp,
     764                         xptr_t   buffer_xp,
     765                         uint32_t size );
    749766
    750767/******************************************************************************************
Note: See TracChangeset for help on using the changeset viewer.