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_pic.c

    r23 r188  
    2424#include <hal_types.h>
    2525#include <hal_special.h>
    26 #include <dev_icu.h>
    2726#include <chdev.h>
    28 #include <memcpy.h>
    2927#include <printk.h>
    3028#include <soclib_pic.h>
    3129#include <dev_pic.h>
     30#include <cluster.h>
    3231
    3332/////////////////////////////////////////////////////////////////////////////////////////
     
    3736extern chdev_directory_t  chdev_dir;         // allocated in kernel_init.c
    3837
    39 extern chdev_pic_input_t  chdev_pic_input;   // allocated in kernel_init.c
    40 
    4138///////////////////////////////////
    42 void dev_pic_init( chdev_t * chdev,
    43                    uint32_t  irq_nr )
     39void dev_pic_init( chdev_t  * pic )
    4440{
    45     // set PIC chdev extension field
    46     chdev->ext.pic.irq_nr = irq_nr;
    47 
    4841    // get implementation
    49     uint32_t impl = chdev->impl;
     42    uint32_t impl = pic->impl;
    5043
    5144    // set chdev name
    52     strcpy( chdev->name , "pic" );
    53  
    54     // call the relevant driver init function
    55     if( impl == IMPL_PIC_SOC )
     45    strcpy( pic->name , "pic" );
     46
     47    // call the relevant driver init function,
     48    // and register commands in PIC device extension
     49    if( impl == IMPL_PIC_SCL )
    5650    {
    57         soclib_pic_init( chdev );
     51        // call the PIC SOCLIB driver
     52        soclib_pic_init( pic );
     53
     54        // update the PIC chdev extension
     55        pic->ext.pic.enable_timer = &soclib_pic_enable_timer;
     56        pic->ext.pic.enable_irq   = &soclib_pic_enable_irq;
     57        pic->ext.pic.disable_irq  = &soclib_pic_disable_irq;
     58        pic->ext.pic.bind_irq     = &soclib_pic_bind_irq;
     59        pic->ext.pic.send_ipi     = &soclib_pic_send_ipi;
     60        pic->ext.pic.extend_init  = &soclib_pic_extend_init;
     61    }
     62    else if( impl == IMPL_PIC_I86 )
     63    {
     64        assert( false , __FUNCTION__ , "missing implementation for X86\n" );
    5865    }
    5966    else
    6067    {
    61         assert( false , __FUNCTION__ , "illegal PIC device implementation" );
     68        assert( false , __FUNCTION__ , "undefined PIC device implementation" );
    6269    }
    6370} // end dev_pic_init()
    6471
    65 /////////////////////////////////////////
    66 void dev_pic_bind_irq( uint32_t   irq_id,
    67                        cxy_t      cxy,
    68                        uint32_t   wti_id )
     72/////////////////////////////////////////////////
     73void dev_pic_extend_init( uint32_t * lapic_base )
    6974{
    70     // get extended pointer on WTI mailbox
    71     xptr_t wti_xp = XPTR( cxy , dev_icu_wti_ptr( wti_id ) );
     75    // get pointer on PIC chdev
     76    chdev_t * pic = (chdev_t *)GET_PTR( chdev_dir.pic );
    7277
    73     // get extended pointer on PIC chdev from directory
    74     xptr_t dev_xp = chdev_dir.pic;
     78    // call relevant driver function
     79    pic->ext.pic.extend_init( lapic_base );
     80}
    7581
    76     // get PIC chdev cluster and local pointer
    77     cxy_t     dev_cxy = GET_CXY( dev_xp );
    78     chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );
     82/////////////////////////////////////
     83void dev_pic_bind_irq( lid_t     lid,
     84                       chdev_t * src_chdev )
     85{
     86    // get pointer on PIC chdev
     87    chdev_t * pic = (chdev_t *)GET_PTR( chdev_dir.pic );
    7988
    80     // get implementation index and segment base
    81     uint32_t impl   = hal_remote_lw( XPTR( dev_cxy , &dev_ptr->impl ) );
     89    // call relevant driver function
     90    pic->ext.pic.bind_irq( lid , src_chdev );
     91
    8292
    83     // call the implementation specific driver function
    84     if( impl == IMPL_PIC_SOC )
    85     {
    86         soclib_pic_bind_irq( dev_xp , irq_id , wti_xp );
    87     }
    88 }  // end dev_pic_link_wti()
     93///////////////////////////////////////
     94void dev_pic_enable_irq( lid_t     lid,
     95                         chdev_t * src_chdev )
     96{
     97    // get pointer on PIC chdev
     98    chdev_t * pic = (chdev_t *)GET_PTR( chdev_dir.pic );
    8999
    90 //////////////////////////////////////////
    91 void dev_pic_unbind_irq( uint32_t irq_id )
     100    // call relevant driver function
     101    pic->ext.pic.enable_irq( src_chdev );
     102}
     103
     104////////////////////////////////////////
     105void dev_pic_disable_irq( lid_t     lid,
     106                          chdev_t * src_chdev )
    92107{
    93     // get extended pointer on PIC chdev from directory
    94     xptr_t dev_xp = chdev_dir.pic;
     108    // get pointer on PIC chdev
     109    chdev_t * pic = (chdev_t *)GET_PTR( chdev_dir.pic );
    95110
    96     // get PIC chdev cluster and local pointer
    97     cxy_t     dev_cxy = GET_CXY( dev_xp );
    98     chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );
     111    // call relevant driver function
     112    pic->ext.pic.disable_irq( src_chdev );
     113}
    99114
    100     // get implementation index
    101     uint32_t impl = hal_remote_lw( XPTR( dev_cxy , &dev_ptr->impl ) );
     115////////////////////////////////////////////
     116void dev_pic_enable_timer( uint32_t period )
     117{
     118    // get pointer on PIC chdev
     119    chdev_t * pic = (chdev_t *)GET_PTR( chdev_dir.pic );
    102120
    103     // call the implementation specific driver function
    104     if( impl == IMPL_PIC_SOC )
    105     {
    106         soclib_pic_unbind_irq( dev_xp , irq_id );
    107     }
    108 } // end dev_pic_disable_irq()
     121    // call relevant driver function
     122    pic->ext.pic.enable_timer( period );
     123}
     124
     125//////////////////////////////////
     126void dev_pic_send_ipi( cxy_t  cxy,
     127                       lid_t  lid )
     128{
     129    // get pointer on PIC chdev
     130    chdev_t * pic = (chdev_t *)GET_PTR( chdev_dir.pic );
     131
     132    // call relevant driver function
     133    pic->ext.pic.send_ipi( cxy , lid );
     134}
    109135
    110136
Note: See TracChangeset for help on using the changeset viewer.