Changeset 279 for trunk/kernel/devices


Ignore:
Timestamp:
Jul 27, 2017, 12:23:29 AM (7 years ago)
Author:
alain
Message:

1) Introduce independant command fields for the various devices in the thread descriptor.
2) Introduce a new dev_pic_enable_ipi() function in the generic PIC device
3) Fix two bugs identified by Maxime in the scheduler initialisation, and in the sched_select().
4) fix several bugs in the TSAR hal_kentry.S.
5) Introduce a third kgiet segment (besides kdata and kcode) in the TSAR bootloader.

Location:
trunk/kernel/devices
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/kernel/devices/dev_dma.c

    r262 r279  
    9999
    100100    // register command in calling thread descriptor
    101     this->command.dma.dev_xp  = dev_xp;
    102     this->command.dma.dst_xp  = dst_xp;
    103     this->command.dma.src_xp  = src_xp;
    104     this->command.dma.size    = size;
     101    this->dma_cmd.dev_xp  = dev_xp;
     102    this->dma_cmd.dst_xp  = dst_xp;
     103    this->dma_cmd.src_xp  = src_xp;
     104    this->dma_cmd.size    = size;
    105105
    106106    // register client thread in waiting queue, activate server thread
     
    110110
    111111    dma_dmsg("\n[INFO] %s : completes for thread %x / error = %d\n",
    112              __FUNCTION__ ,  this->trdid , this->command.dma.error );
     112             __FUNCTION__ ,  this->trdid , this->dma_cmd.error );
    113113
    114114    // return I/O operation status from calling thread descriptor
    115     return this->command.dma.error; 
     115    return this->dma_cmd.error; 
    116116
    117117}  // dev_dma_remote_memcpy()
  • trunk/kernel/devices/dev_fbf.c

    r214 r279  
    120120// It builds and registers the command in the calling thread descriptor, after
    121121// translation of buffer virtual address to physical address.
    122 // Then, it registers the calling thead in chdev waiting queue.
     122// Then, it registers the calling thead in the relevant DMA chdev waiting queue.
    123123// Finally it blocks on the THREAD_BLOCKED_DEV condition and deschedule.
    124124////////////////////////////////////i/////////////////////////////////////////////
  • trunk/kernel/devices/dev_iob.h

    r14 r279  
    3434 * The IOB device is used to access external peripherals. It implements an IO-MMU service
    3535 * for DMA transactions launched by DMA capable external peripherals.
     36 *
    3637 * This IOB peripheral is acting as a dynamically configurable bridge, used for others
    3738 * I/O operations. Therefore, ALMOS-MKH does not use the IOB device waiting queue,
  • trunk/kernel/devices/dev_ioc.c

    r238 r279  
    116116
    117117    // register command in calling thread descriptor
    118     this->command.ioc.dev_xp    = dev_xp;
    119     this->command.ioc.type      = cmd_type;
    120     this->command.ioc.buf_xp    = XPTR( local_cxy , buffer );
    121     this->command.ioc.lba       = lba;
    122     this->command.ioc.count     = count;
     118    this->ioc_cmd.dev_xp    = dev_xp;
     119    this->ioc_cmd.type      = cmd_type;
     120    this->ioc_cmd.buf_xp    = XPTR( local_cxy , buffer );
     121    this->ioc_cmd.lba       = lba;
     122    this->ioc_cmd.count     = count;
    123123
    124124    // register client thread in IOC chdev waiting queue, activate server thread,
     
    130130             " completes / error = %d / at cycle %d\n",
    131131             __FUNCTION__ , this->trdid , this->process->pid ,
    132              this->command.ioc.error , hal_get_cycles() );
     132             this->ioc_cmd.error , hal_get_cycles() );
    133133
    134134    // return I/O operation status
    135     return this->command.ioc.error;
     135    return this->ioc_cmd.error;
    136136
    137137}  // end dev_ioc_access()
     
    158158                           uint32_t   count )
    159159{
     160    ioc_dmsg("\n[INFO] %s : enter in cluster %x\n",
     161             __FUNCTION__ , local_cxy );
     162
    160163    // get pointer on calling thread
    161164    thread_t * this = CURRENT_THREAD;
     
    165168
    166169    // get extended pointer on IOC[0] chdev
    167     xptr_t  dev_xp = chdev_dir.ioc[0];
    168 
    169     assert( (dev_xp != XPTR_NULL) , __FUNCTION__ , "undefined IOC chdev descriptor" );
     170    xptr_t  ioc_xp = chdev_dir.ioc[0];
     171
     172    assert( (ioc_xp != XPTR_NULL) , __FUNCTION__ , "undefined IOC chdev descriptor" );
    170173
    171174    // register command in calling thread descriptor
    172     this->command.ioc.dev_xp    = dev_xp;
    173     this->command.ioc.type      = IOC_SYNC_READ;
    174     this->command.ioc.buf_xp    = XPTR( local_cxy , buffer );
    175     this->command.ioc.lba       = lba;
    176     this->command.ioc.count     = count;
     175    this->ioc_cmd.dev_xp    = ioc_xp;
     176    this->ioc_cmd.type      = IOC_SYNC_READ;
     177    this->ioc_cmd.buf_xp    = XPTR( local_cxy , buffer );
     178    this->ioc_cmd.lba       = lba;
     179    this->ioc_cmd.count     = count;
    177180
    178181    // get driver command function
    179     cxy_t       dev_cxy = GET_CXY( dev_xp );
    180     chdev_t   * dev_ptr = (chdev_t *)GET_PTR( dev_xp );
    181     dev_cmd_t * cmd = (dev_cmd_t *)hal_remote_lpt( XPTR( dev_cxy , &dev_ptr->cmd ) );
     182    cxy_t       ioc_cxy = GET_CXY( ioc_xp );
     183    chdev_t   * ioc_ptr = (chdev_t *)GET_PTR( ioc_xp );
     184    dev_cmd_t * cmd = (dev_cmd_t *)hal_remote_lpt( XPTR( ioc_cxy , &ioc_ptr->cmd ) );
     185
     186    // get core local index for the core handling the IOC IRQ
     187    thread_t * server = (thread_t *)hal_remote_lpt( XPTR( ioc_cxy , &ioc_ptr->server ) );
     188    core_t   * core   = (core_t *)hal_remote_lpt( XPTR( ioc_cxy , &server->core ) );
     189    lid_t      lid    = (lid_t)hal_remote_lw( XPTR( ioc_cxy , &core->lid ) );
    182190
    183191    // mask the IRQ
    184     thread_t * server = (thread_t *)hal_remote_lpt( XPTR( dev_cxy , &dev_ptr->server ) );
    185     core_t   * core = (core_t *)hal_remote_lpt( XPTR( dev_cxy , &server->core ) );
    186     lid_t      lid = (lid_t)hal_remote_lw( XPTR( dev_cxy , &core->lid ) );
    187     dev_pic_disable_irq( lid , dev_xp );
    188 
    189     // call directly driver command
     192    dev_pic_disable_irq( lid , ioc_xp );
     193
     194    ioc_dmsg("\n[INFO] %s : coucou 3\n",
     195             __FUNCTION__ );
     196
     197    // call driver function
    190198    cmd( XPTR( local_cxy , this ) );
    191199
    192200    // unmask the IRQ
    193     dev_pic_enable_irq( lid , dev_xp );
     201    dev_pic_enable_irq( lid , ioc_xp );
     202
     203    ioc_dmsg("\n[INFO] %s : exit in cluster %x\n",
     204             __FUNCTION__ , local_cxy );
    194205
    195206    // return I/O operation status from calling thread descriptor
    196     return this->command.ioc.error;
    197 }
    198 
     207    return this->ioc_cmd.error;
     208
     209}  // end ioc_sync_read()
     210
  • trunk/kernel/devices/dev_mmc.c

    r257 r279  
    6565{
    6666    // get extended pointer on MMC device descriptor
    67     xptr_t  dev_xp = this->command.mmc.dev_xp;
     67    xptr_t  dev_xp = this->mmc_cmd.dev_xp;
    6868
    6969    assert( (dev_xp != XPTR_NULL) , __FUNCTION__ , "target MMC device undefined" );
     
    8686
    8787    // return operation status
    88     return this->command.mmc.error; 
     88    return this->mmc_cmd.error; 
    8989
    9090}  // end dev_mmc_access()
     
    116116
    117117    // store command arguments in thread descriptor
    118     this->command.mmc.dev_xp    = chdev_dir.mmc[buf_cxy];
    119     this->command.mmc.type      = MMC_CC_INVAL;
    120     this->command.mmc.buf_paddr = buf_paddr;
    121     this->command.mmc.buf_size  = buf_size;
     118    this->mmc_cmd.dev_xp    = chdev_dir.mmc[buf_cxy];
     119    this->mmc_cmd.type      = MMC_CC_INVAL;
     120    this->mmc_cmd.buf_paddr = buf_paddr;
     121    this->mmc_cmd.buf_size  = buf_size;
    122122
    123123    // call MMC driver
     
    156156
    157157    // store command arguments in thread descriptor
    158     this->command.mmc.dev_xp    = chdev_dir.mmc[buf_cxy];
    159     this->command.mmc.type      = MMC_CC_SYNC;
    160     this->command.mmc.buf_paddr = buf_paddr;
    161     this->command.mmc.buf_size  = buf_size;
     158    this->mmc_cmd.dev_xp    = chdev_dir.mmc[buf_cxy];
     159    this->mmc_cmd.type      = MMC_CC_SYNC;
     160    this->mmc_cmd.buf_paddr = buf_paddr;
     161    this->mmc_cmd.buf_size  = buf_size;
    162162
    163163    // call MMC driver
     
    179179
    180180    // store command arguments in thread descriptor
    181     this->command.mmc.dev_xp    = chdev_dir.mmc[cxy];
    182     this->command.mmc.type      = MMC_SET_ERROR;
    183     this->command.mmc.reg_index = index;
    184     this->command.mmc.reg_ptr   = &wdata;
     181    this->mmc_cmd.dev_xp    = chdev_dir.mmc[cxy];
     182    this->mmc_cmd.type      = MMC_SET_ERROR;
     183    this->mmc_cmd.reg_index = index;
     184    this->mmc_cmd.reg_ptr   = &wdata;
    185185
    186186    // execute operation
     
    197197
    198198    // store command arguments in thread descriptor
    199     this->command.mmc.dev_xp    = chdev_dir.mmc[cxy];
    200     this->command.mmc.type      = MMC_GET_ERROR;
    201     this->command.mmc.reg_index = index;
    202     this->command.mmc.reg_ptr   = rdata;
     199    this->mmc_cmd.dev_xp    = chdev_dir.mmc[cxy];
     200    this->mmc_cmd.type      = MMC_GET_ERROR;
     201    this->mmc_cmd.reg_index = index;
     202    this->mmc_cmd.reg_ptr   = rdata;
    203203
    204204    // execute operation
     
    215215
    216216    // store command arguments in thread descriptor
    217     this->command.mmc.dev_xp    = chdev_dir.mmc[cxy];
    218     this->command.mmc.type      = MMC_GET_INSTRU;
    219     this->command.mmc.reg_index = index;
    220     this->command.mmc.reg_ptr   = rdata;
     217    this->mmc_cmd.dev_xp    = chdev_dir.mmc[cxy];
     218    this->mmc_cmd.type      = MMC_GET_INSTRU;
     219    this->mmc_cmd.reg_index = index;
     220    this->mmc_cmd.reg_ptr   = rdata;
    221221
    222222    // execute operation
  • trunk/kernel/devices/dev_nic.c

    r259 r279  
    110110
    111111    // initialize command in thread descriptor
    112     thread_ptr->command.nic.dev_xp = dev_xp;
     112    thread_ptr->nic_cmd.dev_xp = dev_xp;
    113113
    114114    // call driver to test readable
    115     thread_ptr->command.nic.cmd = NIC_CMD_READABLE;
    116     dev_ptr->cmd( thread_xp );
    117 
    118     // check error
    119     error = thread_ptr->command.nic.error;
     115    thread_ptr->nic_cmd.cmd = NIC_CMD_READABLE;
     116    dev_ptr->cmd( thread_xp );
     117
     118    // check error
     119    error = thread_ptr->nic_cmd.error;
    120120    if( error ) return error;
    121121
    122122    // block and deschedule if queue non readable
    123     if( thread_ptr->command.nic.status == false ) 
     123    if( thread_ptr->nic_cmd.status == false ) 
    124124    {
    125125        // enable NIC-RX IRQ
     
    135135
    136136    // call driver for actual read
    137     thread_ptr->command.nic.cmd     = NIC_CMD_READ;
    138     thread_ptr->command.nic.buffer  = pkd->buffer;
    139     dev_ptr->cmd( thread_xp );
    140 
    141     // check error
    142     error = thread_ptr->command.nic.error;
     137    thread_ptr->nic_cmd.cmd     = NIC_CMD_READ;
     138    thread_ptr->nic_cmd.buffer  = pkd->buffer;
     139    dev_ptr->cmd( thread_xp );
     140
     141    // check error
     142    error = thread_ptr->nic_cmd.error;
    143143    if( error ) return error;
    144144
    145145    // returns packet length   
    146     pkd->length = thread_ptr->command.nic.length;
     146    pkd->length = thread_ptr->nic_cmd.length;
    147147
    148148    nic_dmsg("\n[INFO] %s exit for NIC-RX thread on core %d in cluster %x\n",
     
    180180
    181181    // initialize command in thread descriptor
    182     thread_ptr->command.nic.dev_xp = dev_xp;
     182    thread_ptr->nic_cmd.dev_xp = dev_xp;
    183183
    184184    // call driver to test writable
    185     thread_ptr->command.nic.cmd = NIC_CMD_WRITABLE;
    186     dev_ptr->cmd( thread_xp );
    187 
    188     // check error
    189     error = thread_ptr->command.nic.error;
     185    thread_ptr->nic_cmd.cmd = NIC_CMD_WRITABLE;
     186    dev_ptr->cmd( thread_xp );
     187
     188    // check error
     189    error = thread_ptr->nic_cmd.error;
    190190    if( error ) return error;
    191191
    192192    // block and deschedule if queue non writable
    193     if( thread_ptr->command.nic.status == false ) 
     193    if( thread_ptr->nic_cmd.status == false ) 
    194194    {
    195195        // enable NIC-TX IRQ
     
    205205
    206206    // call driver for actual write
    207     thread_ptr->command.nic.cmd    = NIC_CMD_WRITE;
    208     thread_ptr->command.nic.buffer = pkd->buffer;
    209     thread_ptr->command.nic.length = pkd->length;
    210     dev_ptr->cmd( thread_xp );
    211 
    212     // check error
    213     error = thread_ptr->command.nic.error;
     207    thread_ptr->nic_cmd.cmd    = NIC_CMD_WRITE;
     208    thread_ptr->nic_cmd.buffer = pkd->buffer;
     209    thread_ptr->nic_cmd.length = pkd->length;
     210    dev_ptr->cmd( thread_xp );
     211
     212    // check error
     213    error = thread_ptr->nic_cmd.error;
    214214    if( error ) return error;
    215215
  • trunk/kernel/devices/dev_pic.c

    r252 r279  
    2626#include <chdev.h>
    2727#include <printk.h>
     28#include <thread.h>
    2829#include <hal_drivers.h>
    2930#include <dev_pic.h>
     
    8283                         xptr_t  src_chdev_xp )
    8384{
     85    irq_dmsg("\n[INFO] %s : core = [%x,%d] / source_chdev_xp = %l\n",
     86             __FUNCTION__ , local_cxy , lid , src_chdev_xp );
     87
    8488    // get pointer on PIC chdev
    8589    chdev_t * pic_ptr = (chdev_t *)GET_PTR( chdev_dir.pic );
     
    97101                          xptr_t  src_chdev_xp )
    98102{
     103    irq_dmsg("\n[INFO] %s : core = [%x,%d] / source_chdev_xp = %l\n",
     104             __FUNCTION__ , local_cxy , lid , src_chdev_xp );
     105
    99106    // get pointer on PIC chdev
    100107    chdev_t * pic_ptr = (chdev_t *)GET_PTR( chdev_dir.pic );
     
    111118void dev_pic_enable_timer( uint32_t period )
    112119{
     120    irq_dmsg("\n[INFO] %s : core = [%x,%d] / period = %d\n",
     121             __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , period );
     122
    113123    // get pointer on PIC chdev
    114124    chdev_t * pic_ptr = (chdev_t *)GET_PTR( chdev_dir.pic );
     
    122132}
    123133
     134/////////////////////////
     135void dev_pic_enable_ipi()
     136{
     137    irq_dmsg("\n[INFO] %s : core = [%x,%d]\n",
     138             __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid );
     139
     140    // get pointer on PIC chdev
     141    chdev_t * pic_ptr = (chdev_t *)GET_PTR( chdev_dir.pic );
     142    cxy_t     pic_cxy = GET_CXY( chdev_dir.pic );
     143
     144    // get pointer on enable_timer function
     145    enable_ipi_t * f = hal_remote_lpt( XPTR( pic_cxy , &pic_ptr->ext.pic.enable_ipi ) );
     146
     147    // call relevant driver function
     148    f();
     149}
     150
    124151//////////////////////////////////
    125152void dev_pic_send_ipi( cxy_t  cxy,
    126153                       lid_t  lid )
    127154{
     155    irq_dmsg("\n[INFO] %s : enter / src_core = [%x,%d] / dst_core = [%x,%d] / cycle = %d\n",
     156             __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, cxy, lid, hal_time_stamp() );
     157
    128158    // get pointer on PIC chdev
    129159    chdev_t * pic_ptr = (chdev_t *)GET_PTR( chdev_dir.pic );
     
    135165    // call relevant driver function
    136166    f( cxy , lid );
     167
     168    irq_dmsg("\n[INFO] %s : exit / src_core = [%x,%d] / dst_core = [%x,%d] / cycle = %d\n",
     169             __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, cxy, lid, hal_time_stamp() );
    137170}
    138171
  • trunk/kernel/devices/dev_pic.h

    r205 r279  
    3434 * to route a given IRQ to a given core, in a given cluster, and to help the interrupt
    3535 * handler to select  and execute the relevant ISR (Interrupt Service Routine).
    36  * It handles the following type of interrupts:
    37  * - External IRQs generated by the external (shared) peripherals.
    38  * - Internal IRQs generated by the internal (replicated) peripherals.
    39  * - Timer IRQs generated by the timers (one timer per core).
    40  * - Inter Processor IRQs (IPI) generated by software.
    41  *
    42  * In most supported manycores architectures, the PIC device contains two types
     36 * It handles the four following types of interrupts:
     37 *
     38 * 1) EXT_IRQ (External IRQ) generated by the external (shared) peripherals.
     39 * 2) INT_IRQ (Internal IRQ) generated by the internal (replicated) peripherals.
     40 * 3) TIM_IRQ (Timer IRQ) generated by the timers (one timer per core).
     41 * 4) IPI_IRQ (Inter Processor IRQ) generated by software (one IPI per core).
     42 *
     43 * In supported manycores architectures, the PIC device contains two types
    4344 * of hardware components:
    4445 * - the IOPIC is an external component, handling all external peripherals IRQs.
     
    5455 * at kernel initialization.
    5556 *
    56  * The PIC device defines 4 generic commands that can be used by each kernel instance,
     57 * The PIC device defines generic commands that can be used by each kernel instance,
    5758 * - to create in local cluster the PIC implementation specific interupt vector(s),
    5859 * - to bind a given IRQ (internal or external IRQ to a given core in the local cluster,
     
    6465 * cluster manager or to the core descriptors to register the interrupt vectors
    6566 * used by the kernel to select the relevant ISR when an interrupt is received
    66  * by a given core in agiven cluster.
     67 * by a given core in a given cluster.
    6768 
    6869 * This PIC device does not execute itself I/O operations. It is just acting as a
     
    8788typedef void   (disable_irq_t)  ( lid_t lid , xptr_t src_chdev_xp );   
    8889typedef void   (enable_timer_t) ( uint32_t period );   
     90typedef void   (enable_ipi_t)   ( );   
    8991typedef void   (send_ipi_t)     ( cxy_t cxy , lid_t lid );
    9092typedef void   (extend_init_t)  ( uint32_t * lapic_base );
     
    9698    disable_irq_t   * disable_irq;   /*! pointer on the driver "disable_irq" function   */
    9799    enable_timer_t  * enable_timer;  /*! pointer on the driver "enable_timer" function  */
     100    enable_timer_t  * enable_ipi;    /*! pointer on the driver "enable_ipi" function    */
    98101    send_ipi_t      * send_ipi;      /*! pointer on the driver "send_ipi" function      */
    99102    extend_init_t   * extend_init;   /*! pointer on the driver "init_extend" function   */
     
    186189
    187190/*****************************************************************************************
    188  * This function enables remote IRQ generated by a remote chdev, defined by the
     191 * This function enables the IRQ generated by a remote chdev, defined by the
    189192 * <src_chdev_xp> argument. It can be called by any thread running in any cluster,
    190193 * and can be used for both internal & external IRQs.
     
    199202 * This function disables remote IRQ generated by a remote chdev, defined by the
    200203 * <src_chdev_xp> argument. It can be called by any thread running in any cluster,
    201  * and can be used for both internal & external IRQs.
     204 * and can be used for both INT_IRq & EXT_IRQ.
    202205 *****************************************************************************************
    203206 * @ lid           : target core local index (in cluster containing the source chdev).
     
    208211
    209212/*****************************************************************************************
    210  * This function activates the TICK timer for the calling core.
    211  * The <period> argument define the number of cycles between IRQs.
     213 * This function activates the TIM_IRQ for the calling core.
     214 * The <period> argument define the number of cycles between twoo successive IRQs.
    212215 *****************************************************************************************
    213216 * @ period      : number of cycles between IRQs.
    214217 ****************************************************************************************/
    215218void dev_pic_enable_timer( uint32_t period );
     219
     220/*****************************************************************************************
     221 * This function activates the IPI_IRQ for the calling core.
     222 ****************************************************************************************/
     223void dev_pic_enable_ipi();
    216224
    217225/*****************************************************************************************
  • trunk/kernel/devices/dev_txt.c

    r255 r279  
    112112
    113113    // register command in calling thread descriptor
    114     this->command.txt.dev_xp  = dev_xp;
    115     this->command.txt.type    = type;
    116     this->command.txt.buf_xp  = XPTR( local_cxy , buffer );
    117     this->command.txt.count   = count;
     114    this->txt_cmd.dev_xp  = dev_xp;
     115    this->txt_cmd.type    = type;
     116    this->txt_cmd.buf_xp  = XPTR( local_cxy , buffer );
     117    this->txt_cmd.count   = count;
    118118
    119119    // register client thread in waiting queue, activate server thread
     
    123123
    124124    txt_dmsg("\n[INFO] in %s : thread %x in process %x completes / error = %d\n",
    125              __FUNCTION__ , this->trdid , this->process->pid , this->command.txt.error );
     125             __FUNCTION__ , this->trdid , this->process->pid , this->txt_cmd.error );
    126126
    127127    // return I/O operation status from calling thread descriptor
    128     return this->command.txt.error;
     128    return this->txt_cmd.error;
    129129}
    130130
     
    157157    assert( (dev_xp != XPTR_NULL) , __FUNCTION__ , "undefined TXT0 chdev descriptor" );
    158158
    159     // register command in calling thread
    160     this->command.txt.dev_xp  = dev_xp;
    161     this->command.txt.type    = TXT_SYNC_WRITE;
    162     this->command.txt.buf_xp  = XPTR( local_cxy , buffer );
    163     this->command.txt.count   = count;
     159    // register command in calling thread descriptor
     160    this->txt_cmd.dev_xp  = dev_xp;
     161    this->txt_cmd.type    = TXT_SYNC_WRITE;
     162    this->txt_cmd.buf_xp  = XPTR( local_cxy , buffer );
     163    this->txt_cmd.count   = count;
    164164
    165165    // get driver command function
     
    168168    dev_cmd_t * cmd = (dev_cmd_t *)hal_remote_lpt( XPTR( dev_cxy , &dev_ptr->cmd ) );
    169169
    170     // call directly driver command
     170    // call driver function
    171171    cmd( XPTR( local_cxy , this ) );
    172172
    173173    // return I/O operation status from calling thread descriptor
    174     return this->command.txt.error;
     174    return this->txt_cmd.error;
    175175}
    176176
Note: See TracChangeset for help on using the changeset viewer.