Changeset 188 for trunk/kernel/devices/dev_ioc.c
- Timestamp:
- Jul 12, 2017, 8:12:41 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/devices/dev_ioc.c
r101 r188 39 39 ///////////////////////////////////////////////////////////////////////////////////////// 40 40 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" ); 41 extern chdev_directory_t chdev_dir; // allocated in kernel_init.c 42 43 ////////////////////////////////// 44 void 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" ); 52 51 53 52 // 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; 56 55 57 56 // set chdev name 58 s trcpy( chdev->name , "ioc");57 snprintf( ioc->name , 16 , "ioc_%d" , channel ); 59 58 60 59 // set driver specific fields in chdev descriptor and call driver init function 61 60 if( impl == IMPL_IOC_BDV ) 62 61 { 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 ); 66 65 } 67 66 else if( impl == IMPL_IOC_HBA ) 68 67 { 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 ); 72 71 } 73 72 else … … 76 75 } 77 76 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 84 78 lid_t lid = cluster_select_local_core(); 85 79 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 ); 92 85 93 86 // create server thread … … 98 91 THREAD_DEV, 99 92 &chdev_sequencial_server, 100 chdev,93 ioc, 101 94 lid ); 95 102 96 assert( (error == 0) , __FUNCTION__ , "cannot create server thread" ); 103 97 104 // set "server" field in chdevdescriptor105 chdev->server = new_thread;98 // set "server" field in ioc descriptor 99 ioc->server = new_thread; 106 100 107 101 // start server thread
Note: See TracChangeset
for help on using the changeset viewer.