Ignore:
Timestamp:
Jul 12, 2017, 8:12:41 PM (7 years ago)
Author:
alain
Message:

Redefine the PIC device API.

File:
1 edited

Legend:

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

    r101 r188  
    3939/////////////////////////////////////////////////////////////////////////////////////////
    4040
    41 extern chdev_directory_t  chdev_dir;         // allocated in kernel_init.c
    42 
    43 extern chdev_pic_input_t  chdev_pic_input;   // allocated in kernel_init.c
    44 
    45 ////////////////////////////////////
    46 void dev_ioc_init( chdev_t * chdev )
    47 {
    48     // the local ICU chdev must be initialized before the IOC chdev, because
    49     // the IOC chdev initialisation requires allocation of a WTI from local ICU
    50     xptr_t  icu_xp  = chdev_dir.icu[local_cxy];
    51     assert( (icu_xp != XPTR_NULL) , __FUNCTION__ , "ICU not initialised before IOC" );
     41extern chdev_directory_t  chdev_dir;     // allocated in kernel_init.c
     42
     43//////////////////////////////////
     44void dev_ioc_init( chdev_t * ioc )
     45{
     46    // the PIC chdev must be initialized before the IOC chdev, because
     47    // the IOC chdev initialisation requires the routing of an external IRQ
     48    xptr_t  pic_xp  = chdev_dir.pic;
     49
     50    assert( (pic_xp != XPTR_NULL) , __FUNCTION__ , "PIC not initialised before IOC" );
    5251
    5352    // get implementation and channel from chdev descriptor
    54     uint32_t  impl    = chdev->impl;
    55     uint32_t  channel = chdev->channel;
     53    uint32_t  impl    = ioc->impl;
     54    uint32_t  channel = ioc->channel;
    5655
    5756    // set chdev name
    58     strcpy( chdev->name , "ioc" );
     57    snprintf( ioc->name , 16 , "ioc_%d" , channel );
    5958
    6059    // set driver specific fields in chdev descriptor and call driver init function
    6160    if( impl == IMPL_IOC_BDV )
    6261    {
    63         chdev->cmd = &soclib_bdv_cmd;
    64         chdev->isr = &soclib_bdv_isr;
    65         soclib_bdv_init( chdev );
     62        ioc->cmd = &soclib_bdv_cmd;
     63        ioc->isr = &soclib_bdv_isr;
     64        soclib_bdv_init( ioc );
    6665    }
    6766    else if( impl == IMPL_IOC_HBA )
    6867    {
    69         chdev->cmd = &soclib_hba_cmd;
    70         chdev->isr = &soclib_hba_isr;
    71         soclib_hba_init( chdev );
     68        ioc->cmd = &soclib_hba_cmd;
     69        ioc->isr = &soclib_hba_isr;
     70        soclib_hba_init( ioc );
    7271    }
    7372    else
     
    7675    }
    7776
    78     // get a WTI mailbox from local ICU
    79     uint32_t wti_id = dev_icu_wti_alloc();
    80 
    81     assert( (wti_id != -1) , __FUNCTION__ , "cannot allocate WTI mailbox" );
    82 
    83     // select a core
     77    // select a core to execute the IOC server thread
    8478    lid_t lid = cluster_select_local_core();
    8579
    86     // enable WTI IRQ and update WTI interrupt vector
    87     dev_icu_enable_irq( lid , WTI_TYPE , wti_id , chdev );
    88 
    89     // link IOC IRQ to WTI mailbox in PIC component
    90     uint32_t irq_id = chdev_pic_input.ioc[channel];
    91     dev_pic_bind_irq( irq_id , local_cxy , wti_id );
     80    // bind the IOC IRQ to the selected core
     81    dev_pic_bind_irq( lid , ioc );
     82
     83    // enable IRQ
     84    dev_pic_enable_irq( lid ,ioc );
    9285
    9386    // create server thread
     
    9891                                  THREAD_DEV,
    9992                                  &chdev_sequencial_server,
    100                                   chdev,
     93                                  ioc,
    10194                                  lid );
     95
    10296    assert( (error == 0) , __FUNCTION__ , "cannot create server thread" );
    10397
    104     // set "server" field in chdev descriptor
    105     chdev->server = new_thread;
     98    // set "server" field in ioc descriptor
     99    ioc->server = new_thread;
    106100   
    107101    // start server thread
Note: See TracChangeset for help on using the changeset viewer.