Changeset 188 for trunk/kernel/devices/dev_pic.c
- Timestamp:
- Jul 12, 2017, 8:12:41 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/devices/dev_pic.c
r23 r188 24 24 #include <hal_types.h> 25 25 #include <hal_special.h> 26 #include <dev_icu.h>27 26 #include <chdev.h> 28 #include <memcpy.h>29 27 #include <printk.h> 30 28 #include <soclib_pic.h> 31 29 #include <dev_pic.h> 30 #include <cluster.h> 32 31 33 32 ///////////////////////////////////////////////////////////////////////////////////////// … … 37 36 extern chdev_directory_t chdev_dir; // allocated in kernel_init.c 38 37 39 extern chdev_pic_input_t chdev_pic_input; // allocated in kernel_init.c40 41 38 /////////////////////////////////// 42 void dev_pic_init( chdev_t * chdev, 43 uint32_t irq_nr ) 39 void dev_pic_init( chdev_t * pic ) 44 40 { 45 // set PIC chdev extension field46 chdev->ext.pic.irq_nr = irq_nr;47 48 41 // get implementation 49 uint32_t impl = chdev->impl;42 uint32_t impl = pic->impl; 50 43 51 44 // 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 ) 56 50 { 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" ); 58 65 } 59 66 else 60 67 { 61 assert( false , __FUNCTION__ , " illegalPIC device implementation" );68 assert( false , __FUNCTION__ , "undefined PIC device implementation" ); 62 69 } 63 70 } // end dev_pic_init() 64 71 65 ///////////////////////////////////////// 66 void dev_pic_bind_irq( uint32_t irq_id, 67 cxy_t cxy, 68 uint32_t wti_id ) 72 ///////////////////////////////////////////////// 73 void dev_pic_extend_init( uint32_t * lapic_base ) 69 74 { 70 // get extended pointer on WTI mailbox71 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 ); 72 77 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 } 75 81 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 ///////////////////////////////////// 83 void 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 ); 79 88 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 } 82 92 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 /////////////////////////////////////// 94 void 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 ); 89 99 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 //////////////////////////////////////// 105 void dev_pic_disable_irq( lid_t lid, 106 chdev_t * src_chdev ) 92 107 { 93 // get extended pointer on PIC chdev from directory94 xptr_t dev_xp = chdev_dir.pic;108 // get pointer on PIC chdev 109 chdev_t * pic = (chdev_t *)GET_PTR( chdev_dir.pic ); 95 110 96 // get PIC chdev cluster and local pointer97 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 } 99 114 100 // get implementation index 101 uint32_t impl = hal_remote_lw( XPTR( dev_cxy , &dev_ptr->impl ) ); 115 //////////////////////////////////////////// 116 void 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 ); 102 120 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 ////////////////////////////////// 126 void 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 } 109 135 110 136
Note: See TracChangeset
for help on using the changeset viewer.