Changeset 14 for trunk/kernel/devices


Ignore:
Timestamp:
May 3, 2017, 1:23:24 PM (5 years ago)
Author:
alain
Message:

Bugs fix.

Location:
trunk/kernel/devices
Files:
14 edited

Legend:

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

    r3 r14  
    2525#define _DEV_DMA_H_
    2626
    27 #include <almos_config.h>
     27#include <kernel_config.h>
    2828#include <hal_types.h>
    2929#include <spinlock.h>
  • trunk/kernel/devices/dev_fbf.c

    r3 r14  
    2222 */
    2323
    24 #include <almos_config.h>
     24#include <kernel_config.h>
    2525#include <hal_types.h>
    2626#include <hal_gpt.h>
  • trunk/kernel/devices/dev_icu.c

    r3 r14  
    8282    if( irq_type == HWI_TYPE )
    8383    {
    84         assert( (irq_index < icu->ext.icu.hwi_nr) , __FUNCTION__ , "illegal HWI" );
    85     }
    86     if( irq_type == WTI_TYPE )
    87     {
    88         assert( (irq_index < icu->ext.icu.wti_nr) , __FUNCTION__ , "illegal WTI" );
    89     }
    90     if( irq_type == PTI_TYPE )
    91     {
    92         assert( (irq_index < icu->ext.icu.pti_nr) , __FUNCTION__ , "illegal PTI" );
     84        if( irq_index >= icu->ext.icu.hwi_nr )
     85        {
     86            printk("\n[PANIC] in %s : illegal HWI index = %d / max = %d\n",
     87                   __FUNCTION__ , irq_index , icu->ext.icu.hwi_nr );
     88            hal_core_sleep();
     89        }
     90    }
     91    else if( irq_type == WTI_TYPE )
     92    {
     93        if( irq_index >= icu->ext.icu.wti_nr )
     94        {
     95            printk("\n[PANIC] in %s : illegal WTI index = %d / max = %d\n",
     96                   __FUNCTION__ , irq_index , icu->ext.icu.wti_nr );
     97            hal_core_sleep();
     98        }
     99    }
     100    else  //  irq_type == PTI_TYPE
     101    {
     102        if( irq_index >= icu->ext.icu.pti_nr )
     103        {
     104            printk("\n[PANIC] in %s : illegal PTI index = %d / max = %d\n",
     105                   __FUNCTION__ , irq_index , icu->ext.icu.pti_nr );
     106            hal_core_sleep();
     107        }
    93108    }
    94109}  // end dev_icu_check_irq()
     
    107122    dev_icu_check_irq( icu , irq_type , irq_index );
    108123
    109     // (1) call implementation specific ICU driver to enable IRQ
     124    // call implementation specific ICU driver to enable IRQ
    110125    if( icu->impl == IMPL_ICU_XCU )
    111126    {
    112         soclib_xcu_enable_irq( icu , 1<<irq_index , irq_type , lid );
    113     }
    114 
    115     // (2) get selected core local pointer, and register
    116     // source chdev pointer in relevant interrupt vector
    117     core_t * core = &LOCAL_CLUSTER->core_tbl[lid];
    118         core_set_irq_vector_entry( core , irq_type , irq_index , src_chdev );
    119 
    120     // (3) register IRQ type and index in source chdev descriptor
    121     src_chdev->irq_type = irq_type;
    122     src_chdev->irq_id   = irq_index;
    123 
     127         soclib_xcu_enable_irq( icu , 1<<irq_index , irq_type , lid );
     128    }
     129
     130    // This is only done for an HWI, or for a WTI that is not an IPI
     131    if( (irq_type != PTI_TYPE) && (src_chdev != NULL) )
     132    {
     133        // get selected core local pointer, and register
     134        // source chdev pointer in relevant interrupt vector
     135        core_t * core = &LOCAL_CLUSTER->core_tbl[lid];
     136            core_set_irq_vector_entry( core , irq_type , irq_index , src_chdev );
     137
     138        // (3) register IRQ type and index in source chdev descriptor
     139        src_chdev->irq_type = irq_type;
     140        src_chdev->irq_id   = irq_index;
     141    }
    124142}  // end dev_icu_enable_irq()
    125143
     
    136154    dev_icu_check_irq( icu , irq_type , irq_index );
    137155
    138     // (1) call the implementation specific ICU driver to disable IRQ
     156    // call the implementation specific ICU driver to disable IRQ
    139157    if( icu->impl == IMPL_ICU_XCU )
    140158    {
     
    142160    }
    143161
    144     // (2) get selected remote core local pointer, and remove
    145     // the source chdev xptr from relevant interrupt vector
    146 
    147     core_t * core = &LOCAL_CLUSTER->core_tbl[lid];
    148         core_set_irq_vector_entry( core , irq_type , irq_index , NULL );
    149 
     162    // This is only done for HWI or WTI that are not IPI
     163    if( irq_type != PTI_TYPE )
     164    {
     165        // get selected remote core local pointer, and remove
     166        // the source chdev xptr from relevant interrupt vector
     167        core_t * core = &LOCAL_CLUSTER->core_tbl[lid];
     168            core_set_irq_vector_entry( core , irq_type , irq_index , NULL );
     169    }
    150170} // end dev_icu_disable_irq()
     171
     172///////////////////////////////////////
     173void dev_icu_get_masks( lid_t      lid,
     174                        uint32_t * hwi_mask,
     175                        uint32_t * wti_mask,
     176                        uint32_t * pti_mask )
     177{
     178    // get local pointer on local ICU chdev
     179    xptr_t    icu_xp = chdev_dir.icu[local_cxy];
     180    chdev_t * icu    = (chdev_t *)GET_PTR( icu_xp );
     181
     182    if( icu->impl == IMPL_ICU_XCU )
     183    {
     184        soclib_xcu_get_masks( icu , lid , hwi_mask , wti_mask , pti_mask );
     185    }
     186}
    151187
    152188//////////////////////////////////////////////
     
    312348        dev_icu_ack_timer( index );
    313349
    314         // TODO execute all actions related to TICK event
    315         core_clock( core );
     350        if( index < LOCAL_CLUSTER->cores_nr )  // its a TICK event
     351        {
     352            // TODO execute all actions related to TICK event
     353            core_clock( core );
     354        }
     355        else
     356        {
     357            printk("\n[WARNING] in %s : no handler for PTI %d on core %d in cluster %x\n",
     358                   __FUNCTION__ , index , core->lid , local_cxy );
     359                core->spurious_irqs ++;
     360            dev_icu_disable_irq( core->lid , PTI_TYPE , index );
     361        }
    316362        }
    317363}  // end dev_icu_irq_handler()
     
    340386    // release lock
    341387    spinlock_unlock( lock );
    342 
     388 
    343389    return index;
    344390}  // end dev_icu_wti_alloc()
  • trunk/kernel/devices/dev_icu.h

    r3 r14  
    2525#define _DEV_ICU_H_
    2626
    27 #include <almos_config.h>
     27#include <kernel_config.h>
    2828#include <hal_types.h>
    2929#include <spinlock.h>
     
    179179                          uint32_t   irq_type,
    180180                          uint32_t   irq_id );
    181                        
     181
     182/*****************************************************************************************
     183 * This function returns the set of enabled IRQs for a given core.
     184 *****************************************************************************************
     185 * @ lid       : local index of selected core in remote cluster.
     186 * @ hwi_mask  : each non zero bit define an enabled HWI IRQ.
     187 * @ wti_mask  : each non zero bit define an enabled WTI IRQ.
     188 * @ pti_mask  : each non zero bit define an enabled PTI IRQ.
     189 ****************************************************************************************/
     190void dev_icu_get_masks( lid_t      lid,
     191                        uint32_t * hwi_mask,
     192                        uint32_t * WTi_mask,
     193                        uint32_t * pti_mask );
     194
    182195/*****************************************************************************************
    183196 * This function set the period value for a timer identified by the PTI index,
  • trunk/kernel/devices/dev_iob.c

    r3 r14  
    2222 */
    2323
    24 #include <almos_config.h>
     24#include <kernel_config.h>
    2525#include <hal_types.h>
    2626#include <hal_special.h>
  • trunk/kernel/devices/dev_iob.h

    r3 r14  
    2525#define _DEV_IOB_H_
    2626
    27 #include <almos_config.h>
     27#include <kernel_config.h>
    2828#include <hal_types.h>
    2929#include <spinlock.h>
  • trunk/kernel/devices/dev_ioc.c

    r3 r14  
    2222 */
    2323
    24 #include <almos_config.h>
     24#include <kernel_config.h>
    2525#include <hal_types.h>
    2626#include <hal_gpt.h>
  • trunk/kernel/devices/dev_ioc.h

    r3 r14  
    2525#define _DEV_IOC_H
    2626
    27 #include <almos_config.h>
     27#include <kernel_config.h>
    2828#include <hal_types.h>
    2929
  • trunk/kernel/devices/dev_mmc.c

    r3 r14  
    5555        assert( false , __FUNCTION__ , "undefined MMC device implementation" );
    5656    }
     57
     58    // get MMC HWI IRQ index
     59    uint32_t hwi_id = chdev_icu_input.mmc;
     60
     61    // enable HWI IRQ to CP0 in local ICU, and update  interrupt vector
     62    dev_icu_enable_irq( 0 , HWI_TYPE , hwi_id , chdev );
     63   
    5764}  // end dev_mmc_init()
    5865
  • trunk/kernel/devices/dev_mmc.h

    r3 r14  
    2525#define _DEV_MMC_H_
    2626
    27 #include <almos_config.h>
     27#include <kernel_config.h>
    2828#include <hal_types.h>
    2929#include <spinlock.h>
  • trunk/kernel/devices/dev_nic.h

    r3 r14  
    2525#define _DEV_NIC_H
    2626
    27 #include <almos_config.h>
     27#include <kernel_config.h>
    2828#include <hal_types.h>
    2929
  • trunk/kernel/devices/dev_pic.h

    r3 r14  
    2525#define _DEV_PIC_H_
    2626
    27 #include <almos_config.h>
     27#include <kernel_config.h>
    2828#include <hal_types.h>
    2929
  • trunk/kernel/devices/dev_txt.c

    r3 r14  
    158158                            uint32_t   count )
    159159{
     160    uint32_t  save_sr;
     161
    160162    // get pointer on calling thread
    161163    thread_t * this = CURRENT_THREAD;
     
    175177    dev_cmd_t * cmd = (dev_cmd_t *)hal_remote_lpt( XPTR( dev_cxy , &dev_ptr->cmd ) );
    176178
    177     // call directly driver command after taking chdev lock
    178     remote_spinlock_lock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
     179    // call directly driver command
    179180    cmd( XPTR( local_cxy , this ) );
    180     remote_spinlock_unlock( XPTR( dev_cxy , &dev_ptr->wait_lock ) );
    181181
    182182    // return I/O operation status from calling thread descriptor
  • trunk/kernel/devices/dev_txt.h

    r3 r14  
    2525#define _DEV_TXT_H_
    2626
    27 #include <almos_config.h>
     27#include <kernel_config.h>
    2828#include <hal_types.h>
    2929
     
    8080/******************************************************************************************
    8181 * This function completes the TXT chdev descriptor initialisation,
    82  * namely the link with the implementation specific driver.
     82i * namely the link with the implementation specific driver.
    8383 * The func, impl, channel, is_rxt, base fields have been previously initialised.
    8484 * It calls the specific driver initialisation function, to initialise the hardware
Note: See TracChangeset for help on using the changeset viewer.