Changeset 279 for trunk/kernel/devices
- Timestamp:
- Jul 27, 2017, 12:23:29 AM (7 years ago)
- Location:
- trunk/kernel/devices
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/devices/dev_dma.c
r262 r279 99 99 100 100 // register command in calling thread descriptor 101 this-> command.dma.dev_xp = dev_xp;102 this-> command.dma.dst_xp = dst_xp;103 this-> command.dma.src_xp = src_xp;104 this-> command.dma.size = size;101 this->dma_cmd.dev_xp = dev_xp; 102 this->dma_cmd.dst_xp = dst_xp; 103 this->dma_cmd.src_xp = src_xp; 104 this->dma_cmd.size = size; 105 105 106 106 // register client thread in waiting queue, activate server thread … … 110 110 111 111 dma_dmsg("\n[INFO] %s : completes for thread %x / error = %d\n", 112 __FUNCTION__ , this->trdid , this-> command.dma.error );112 __FUNCTION__ , this->trdid , this->dma_cmd.error ); 113 113 114 114 // return I/O operation status from calling thread descriptor 115 return this-> command.dma.error;115 return this->dma_cmd.error; 116 116 117 117 } // dev_dma_remote_memcpy() -
trunk/kernel/devices/dev_fbf.c
r214 r279 120 120 // It builds and registers the command in the calling thread descriptor, after 121 121 // translation of buffer virtual address to physical address. 122 // Then, it registers the calling thead in chdev waiting queue.122 // Then, it registers the calling thead in the relevant DMA chdev waiting queue. 123 123 // Finally it blocks on the THREAD_BLOCKED_DEV condition and deschedule. 124 124 ////////////////////////////////////i///////////////////////////////////////////// -
trunk/kernel/devices/dev_iob.h
r14 r279 34 34 * The IOB device is used to access external peripherals. It implements an IO-MMU service 35 35 * for DMA transactions launched by DMA capable external peripherals. 36 * 36 37 * This IOB peripheral is acting as a dynamically configurable bridge, used for others 37 38 * I/O operations. Therefore, ALMOS-MKH does not use the IOB device waiting queue, -
trunk/kernel/devices/dev_ioc.c
r238 r279 116 116 117 117 // register command in calling thread descriptor 118 this-> command.ioc.dev_xp = dev_xp;119 this-> command.ioc.type = cmd_type;120 this-> command.ioc.buf_xp = XPTR( local_cxy , buffer );121 this-> command.ioc.lba = lba;122 this-> command.ioc.count = count;118 this->ioc_cmd.dev_xp = dev_xp; 119 this->ioc_cmd.type = cmd_type; 120 this->ioc_cmd.buf_xp = XPTR( local_cxy , buffer ); 121 this->ioc_cmd.lba = lba; 122 this->ioc_cmd.count = count; 123 123 124 124 // register client thread in IOC chdev waiting queue, activate server thread, … … 130 130 " completes / error = %d / at cycle %d\n", 131 131 __FUNCTION__ , this->trdid , this->process->pid , 132 this-> command.ioc.error , hal_get_cycles() );132 this->ioc_cmd.error , hal_get_cycles() ); 133 133 134 134 // return I/O operation status 135 return this-> command.ioc.error;135 return this->ioc_cmd.error; 136 136 137 137 } // end dev_ioc_access() … … 158 158 uint32_t count ) 159 159 { 160 ioc_dmsg("\n[INFO] %s : enter in cluster %x\n", 161 __FUNCTION__ , local_cxy ); 162 160 163 // get pointer on calling thread 161 164 thread_t * this = CURRENT_THREAD; … … 165 168 166 169 // get extended pointer on IOC[0] chdev 167 xptr_t dev_xp = chdev_dir.ioc[0];168 169 assert( ( dev_xp != XPTR_NULL) , __FUNCTION__ , "undefined IOC chdev descriptor" );170 xptr_t ioc_xp = chdev_dir.ioc[0]; 171 172 assert( (ioc_xp != XPTR_NULL) , __FUNCTION__ , "undefined IOC chdev descriptor" ); 170 173 171 174 // register command in calling thread descriptor 172 this-> command.ioc.dev_xp = dev_xp;173 this-> command.ioc.type = IOC_SYNC_READ;174 this-> command.ioc.buf_xp = XPTR( local_cxy , buffer );175 this-> command.ioc.lba = lba;176 this-> command.ioc.count = count;175 this->ioc_cmd.dev_xp = ioc_xp; 176 this->ioc_cmd.type = IOC_SYNC_READ; 177 this->ioc_cmd.buf_xp = XPTR( local_cxy , buffer ); 178 this->ioc_cmd.lba = lba; 179 this->ioc_cmd.count = count; 177 180 178 181 // get driver command function 179 cxy_t dev_cxy = GET_CXY( dev_xp ); 180 chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp ); 181 dev_cmd_t * cmd = (dev_cmd_t *)hal_remote_lpt( XPTR( dev_cxy , &dev_ptr->cmd ) ); 182 cxy_t ioc_cxy = GET_CXY( ioc_xp ); 183 chdev_t * ioc_ptr = (chdev_t *)GET_PTR( ioc_xp ); 184 dev_cmd_t * cmd = (dev_cmd_t *)hal_remote_lpt( XPTR( ioc_cxy , &ioc_ptr->cmd ) ); 185 186 // get core local index for the core handling the IOC IRQ 187 thread_t * server = (thread_t *)hal_remote_lpt( XPTR( ioc_cxy , &ioc_ptr->server ) ); 188 core_t * core = (core_t *)hal_remote_lpt( XPTR( ioc_cxy , &server->core ) ); 189 lid_t lid = (lid_t)hal_remote_lw( XPTR( ioc_cxy , &core->lid ) ); 182 190 183 191 // mask the IRQ 184 thread_t * server = (thread_t *)hal_remote_lpt( XPTR( dev_cxy , &dev_ptr->server ));185 core_t * core = (core_t *)hal_remote_lpt( XPTR( dev_cxy , &server->core ) ); 186 lid_t lid = (lid_t)hal_remote_lw( XPTR( dev_cxy , &core->lid ) );187 dev_pic_disable_irq( lid , dev_xp);188 189 // call d irectly driver command192 dev_pic_disable_irq( lid , ioc_xp ); 193 194 ioc_dmsg("\n[INFO] %s : coucou 3\n", 195 __FUNCTION__ ); 196 197 // call driver function 190 198 cmd( XPTR( local_cxy , this ) ); 191 199 192 200 // unmask the IRQ 193 dev_pic_enable_irq( lid , dev_xp ); 201 dev_pic_enable_irq( lid , ioc_xp ); 202 203 ioc_dmsg("\n[INFO] %s : exit in cluster %x\n", 204 __FUNCTION__ , local_cxy ); 194 205 195 206 // return I/O operation status from calling thread descriptor 196 return this->command.ioc.error; 197 } 198 207 return this->ioc_cmd.error; 208 209 } // end ioc_sync_read() 210 -
trunk/kernel/devices/dev_mmc.c
r257 r279 65 65 { 66 66 // get extended pointer on MMC device descriptor 67 xptr_t dev_xp = this-> command.mmc.dev_xp;67 xptr_t dev_xp = this->mmc_cmd.dev_xp; 68 68 69 69 assert( (dev_xp != XPTR_NULL) , __FUNCTION__ , "target MMC device undefined" ); … … 86 86 87 87 // return operation status 88 return this-> command.mmc.error;88 return this->mmc_cmd.error; 89 89 90 90 } // end dev_mmc_access() … … 116 116 117 117 // store command arguments in thread descriptor 118 this-> command.mmc.dev_xp = chdev_dir.mmc[buf_cxy];119 this-> command.mmc.type = MMC_CC_INVAL;120 this-> command.mmc.buf_paddr = buf_paddr;121 this-> command.mmc.buf_size = buf_size;118 this->mmc_cmd.dev_xp = chdev_dir.mmc[buf_cxy]; 119 this->mmc_cmd.type = MMC_CC_INVAL; 120 this->mmc_cmd.buf_paddr = buf_paddr; 121 this->mmc_cmd.buf_size = buf_size; 122 122 123 123 // call MMC driver … … 156 156 157 157 // store command arguments in thread descriptor 158 this-> command.mmc.dev_xp = chdev_dir.mmc[buf_cxy];159 this-> command.mmc.type = MMC_CC_SYNC;160 this-> command.mmc.buf_paddr = buf_paddr;161 this-> command.mmc.buf_size = buf_size;158 this->mmc_cmd.dev_xp = chdev_dir.mmc[buf_cxy]; 159 this->mmc_cmd.type = MMC_CC_SYNC; 160 this->mmc_cmd.buf_paddr = buf_paddr; 161 this->mmc_cmd.buf_size = buf_size; 162 162 163 163 // call MMC driver … … 179 179 180 180 // store command arguments in thread descriptor 181 this-> command.mmc.dev_xp = chdev_dir.mmc[cxy];182 this-> command.mmc.type = MMC_SET_ERROR;183 this-> command.mmc.reg_index = index;184 this-> command.mmc.reg_ptr = &wdata;181 this->mmc_cmd.dev_xp = chdev_dir.mmc[cxy]; 182 this->mmc_cmd.type = MMC_SET_ERROR; 183 this->mmc_cmd.reg_index = index; 184 this->mmc_cmd.reg_ptr = &wdata; 185 185 186 186 // execute operation … … 197 197 198 198 // store command arguments in thread descriptor 199 this-> command.mmc.dev_xp = chdev_dir.mmc[cxy];200 this-> command.mmc.type = MMC_GET_ERROR;201 this-> command.mmc.reg_index = index;202 this-> command.mmc.reg_ptr = rdata;199 this->mmc_cmd.dev_xp = chdev_dir.mmc[cxy]; 200 this->mmc_cmd.type = MMC_GET_ERROR; 201 this->mmc_cmd.reg_index = index; 202 this->mmc_cmd.reg_ptr = rdata; 203 203 204 204 // execute operation … … 215 215 216 216 // store command arguments in thread descriptor 217 this-> command.mmc.dev_xp = chdev_dir.mmc[cxy];218 this-> command.mmc.type = MMC_GET_INSTRU;219 this-> command.mmc.reg_index = index;220 this-> command.mmc.reg_ptr = rdata;217 this->mmc_cmd.dev_xp = chdev_dir.mmc[cxy]; 218 this->mmc_cmd.type = MMC_GET_INSTRU; 219 this->mmc_cmd.reg_index = index; 220 this->mmc_cmd.reg_ptr = rdata; 221 221 222 222 // execute operation -
trunk/kernel/devices/dev_nic.c
r259 r279 110 110 111 111 // initialize command in thread descriptor 112 thread_ptr-> command.nic.dev_xp = dev_xp;112 thread_ptr->nic_cmd.dev_xp = dev_xp; 113 113 114 114 // call driver to test readable 115 thread_ptr-> command.nic.cmd = NIC_CMD_READABLE;116 dev_ptr->cmd( thread_xp ); 117 118 // check error 119 error = thread_ptr-> command.nic.error;115 thread_ptr->nic_cmd.cmd = NIC_CMD_READABLE; 116 dev_ptr->cmd( thread_xp ); 117 118 // check error 119 error = thread_ptr->nic_cmd.error; 120 120 if( error ) return error; 121 121 122 122 // block and deschedule if queue non readable 123 if( thread_ptr-> command.nic.status == false )123 if( thread_ptr->nic_cmd.status == false ) 124 124 { 125 125 // enable NIC-RX IRQ … … 135 135 136 136 // call driver for actual read 137 thread_ptr-> command.nic.cmd = NIC_CMD_READ;138 thread_ptr-> command.nic.buffer = pkd->buffer;139 dev_ptr->cmd( thread_xp ); 140 141 // check error 142 error = thread_ptr-> command.nic.error;137 thread_ptr->nic_cmd.cmd = NIC_CMD_READ; 138 thread_ptr->nic_cmd.buffer = pkd->buffer; 139 dev_ptr->cmd( thread_xp ); 140 141 // check error 142 error = thread_ptr->nic_cmd.error; 143 143 if( error ) return error; 144 144 145 145 // returns packet length 146 pkd->length = thread_ptr-> command.nic.length;146 pkd->length = thread_ptr->nic_cmd.length; 147 147 148 148 nic_dmsg("\n[INFO] %s exit for NIC-RX thread on core %d in cluster %x\n", … … 180 180 181 181 // initialize command in thread descriptor 182 thread_ptr-> command.nic.dev_xp = dev_xp;182 thread_ptr->nic_cmd.dev_xp = dev_xp; 183 183 184 184 // call driver to test writable 185 thread_ptr-> command.nic.cmd = NIC_CMD_WRITABLE;186 dev_ptr->cmd( thread_xp ); 187 188 // check error 189 error = thread_ptr-> command.nic.error;185 thread_ptr->nic_cmd.cmd = NIC_CMD_WRITABLE; 186 dev_ptr->cmd( thread_xp ); 187 188 // check error 189 error = thread_ptr->nic_cmd.error; 190 190 if( error ) return error; 191 191 192 192 // block and deschedule if queue non writable 193 if( thread_ptr-> command.nic.status == false )193 if( thread_ptr->nic_cmd.status == false ) 194 194 { 195 195 // enable NIC-TX IRQ … … 205 205 206 206 // call driver for actual write 207 thread_ptr-> command.nic.cmd = NIC_CMD_WRITE;208 thread_ptr-> command.nic.buffer = pkd->buffer;209 thread_ptr-> command.nic.length = pkd->length;210 dev_ptr->cmd( thread_xp ); 211 212 // check error 213 error = thread_ptr-> command.nic.error;207 thread_ptr->nic_cmd.cmd = NIC_CMD_WRITE; 208 thread_ptr->nic_cmd.buffer = pkd->buffer; 209 thread_ptr->nic_cmd.length = pkd->length; 210 dev_ptr->cmd( thread_xp ); 211 212 // check error 213 error = thread_ptr->nic_cmd.error; 214 214 if( error ) return error; 215 215 -
trunk/kernel/devices/dev_pic.c
r252 r279 26 26 #include <chdev.h> 27 27 #include <printk.h> 28 #include <thread.h> 28 29 #include <hal_drivers.h> 29 30 #include <dev_pic.h> … … 82 83 xptr_t src_chdev_xp ) 83 84 { 85 irq_dmsg("\n[INFO] %s : core = [%x,%d] / source_chdev_xp = %l\n", 86 __FUNCTION__ , local_cxy , lid , src_chdev_xp ); 87 84 88 // get pointer on PIC chdev 85 89 chdev_t * pic_ptr = (chdev_t *)GET_PTR( chdev_dir.pic ); … … 97 101 xptr_t src_chdev_xp ) 98 102 { 103 irq_dmsg("\n[INFO] %s : core = [%x,%d] / source_chdev_xp = %l\n", 104 __FUNCTION__ , local_cxy , lid , src_chdev_xp ); 105 99 106 // get pointer on PIC chdev 100 107 chdev_t * pic_ptr = (chdev_t *)GET_PTR( chdev_dir.pic ); … … 111 118 void dev_pic_enable_timer( uint32_t period ) 112 119 { 120 irq_dmsg("\n[INFO] %s : core = [%x,%d] / period = %d\n", 121 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid , period ); 122 113 123 // get pointer on PIC chdev 114 124 chdev_t * pic_ptr = (chdev_t *)GET_PTR( chdev_dir.pic ); … … 122 132 } 123 133 134 ///////////////////////// 135 void dev_pic_enable_ipi() 136 { 137 irq_dmsg("\n[INFO] %s : core = [%x,%d]\n", 138 __FUNCTION__ , local_cxy , CURRENT_THREAD->core->lid ); 139 140 // get pointer on PIC chdev 141 chdev_t * pic_ptr = (chdev_t *)GET_PTR( chdev_dir.pic ); 142 cxy_t pic_cxy = GET_CXY( chdev_dir.pic ); 143 144 // get pointer on enable_timer function 145 enable_ipi_t * f = hal_remote_lpt( XPTR( pic_cxy , &pic_ptr->ext.pic.enable_ipi ) ); 146 147 // call relevant driver function 148 f(); 149 } 150 124 151 ////////////////////////////////// 125 152 void dev_pic_send_ipi( cxy_t cxy, 126 153 lid_t lid ) 127 154 { 155 irq_dmsg("\n[INFO] %s : enter / src_core = [%x,%d] / dst_core = [%x,%d] / cycle = %d\n", 156 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, cxy, lid, hal_time_stamp() ); 157 128 158 // get pointer on PIC chdev 129 159 chdev_t * pic_ptr = (chdev_t *)GET_PTR( chdev_dir.pic ); … … 135 165 // call relevant driver function 136 166 f( cxy , lid ); 167 168 irq_dmsg("\n[INFO] %s : exit / src_core = [%x,%d] / dst_core = [%x,%d] / cycle = %d\n", 169 __FUNCTION__, local_cxy, CURRENT_THREAD->core->lid, cxy, lid, hal_time_stamp() ); 137 170 } 138 171 -
trunk/kernel/devices/dev_pic.h
r205 r279 34 34 * to route a given IRQ to a given core, in a given cluster, and to help the interrupt 35 35 * handler to select and execute the relevant ISR (Interrupt Service Routine). 36 * It handles the following type of interrupts: 37 * - External IRQs generated by the external (shared) peripherals. 38 * - Internal IRQs generated by the internal (replicated) peripherals. 39 * - Timer IRQs generated by the timers (one timer per core). 40 * - Inter Processor IRQs (IPI) generated by software. 41 * 42 * In most supported manycores architectures, the PIC device contains two types 36 * It handles the four following types of interrupts: 37 * 38 * 1) EXT_IRQ (External IRQ) generated by the external (shared) peripherals. 39 * 2) INT_IRQ (Internal IRQ) generated by the internal (replicated) peripherals. 40 * 3) TIM_IRQ (Timer IRQ) generated by the timers (one timer per core). 41 * 4) IPI_IRQ (Inter Processor IRQ) generated by software (one IPI per core). 42 * 43 * In supported manycores architectures, the PIC device contains two types 43 44 * of hardware components: 44 45 * - the IOPIC is an external component, handling all external peripherals IRQs. … … 54 55 * at kernel initialization. 55 56 * 56 * The PIC device defines 4generic commands that can be used by each kernel instance,57 * The PIC device defines generic commands that can be used by each kernel instance, 57 58 * - to create in local cluster the PIC implementation specific interupt vector(s), 58 59 * - to bind a given IRQ (internal or external IRQ to a given core in the local cluster, … … 64 65 * cluster manager or to the core descriptors to register the interrupt vectors 65 66 * used by the kernel to select the relevant ISR when an interrupt is received 66 * by a given core in a given cluster.67 * by a given core in a given cluster. 67 68 68 69 * This PIC device does not execute itself I/O operations. It is just acting as a … … 87 88 typedef void (disable_irq_t) ( lid_t lid , xptr_t src_chdev_xp ); 88 89 typedef void (enable_timer_t) ( uint32_t period ); 90 typedef void (enable_ipi_t) ( ); 89 91 typedef void (send_ipi_t) ( cxy_t cxy , lid_t lid ); 90 92 typedef void (extend_init_t) ( uint32_t * lapic_base ); … … 96 98 disable_irq_t * disable_irq; /*! pointer on the driver "disable_irq" function */ 97 99 enable_timer_t * enable_timer; /*! pointer on the driver "enable_timer" function */ 100 enable_timer_t * enable_ipi; /*! pointer on the driver "enable_ipi" function */ 98 101 send_ipi_t * send_ipi; /*! pointer on the driver "send_ipi" function */ 99 102 extend_init_t * extend_init; /*! pointer on the driver "init_extend" function */ … … 186 189 187 190 /***************************************************************************************** 188 * This function enables remote IRQ generated by a remote chdev, defined by the191 * This function enables the IRQ generated by a remote chdev, defined by the 189 192 * <src_chdev_xp> argument. It can be called by any thread running in any cluster, 190 193 * and can be used for both internal & external IRQs. … … 199 202 * This function disables remote IRQ generated by a remote chdev, defined by the 200 203 * <src_chdev_xp> argument. It can be called by any thread running in any cluster, 201 * and can be used for both internal & external IRQs.204 * and can be used for both INT_IRq & EXT_IRQ. 202 205 ***************************************************************************************** 203 206 * @ lid : target core local index (in cluster containing the source chdev). … … 208 211 209 212 /***************************************************************************************** 210 * This function activates the TI CK timerfor the calling core.211 * The <period> argument define the number of cycles between IRQs.213 * This function activates the TIM_IRQ for the calling core. 214 * The <period> argument define the number of cycles between twoo successive IRQs. 212 215 ***************************************************************************************** 213 216 * @ period : number of cycles between IRQs. 214 217 ****************************************************************************************/ 215 218 void dev_pic_enable_timer( uint32_t period ); 219 220 /***************************************************************************************** 221 * This function activates the IPI_IRQ for the calling core. 222 ****************************************************************************************/ 223 void dev_pic_enable_ipi(); 216 224 217 225 /***************************************************************************************** -
trunk/kernel/devices/dev_txt.c
r255 r279 112 112 113 113 // register command in calling thread descriptor 114 this-> command.txt.dev_xp = dev_xp;115 this-> command.txt.type = type;116 this-> command.txt.buf_xp = XPTR( local_cxy , buffer );117 this-> command.txt.count = count;114 this->txt_cmd.dev_xp = dev_xp; 115 this->txt_cmd.type = type; 116 this->txt_cmd.buf_xp = XPTR( local_cxy , buffer ); 117 this->txt_cmd.count = count; 118 118 119 119 // register client thread in waiting queue, activate server thread … … 123 123 124 124 txt_dmsg("\n[INFO] in %s : thread %x in process %x completes / error = %d\n", 125 __FUNCTION__ , this->trdid , this->process->pid , this-> command.txt.error );125 __FUNCTION__ , this->trdid , this->process->pid , this->txt_cmd.error ); 126 126 127 127 // return I/O operation status from calling thread descriptor 128 return this-> command.txt.error;128 return this->txt_cmd.error; 129 129 } 130 130 … … 157 157 assert( (dev_xp != XPTR_NULL) , __FUNCTION__ , "undefined TXT0 chdev descriptor" ); 158 158 159 // register command in calling thread 160 this-> command.txt.dev_xp = dev_xp;161 this-> command.txt.type = TXT_SYNC_WRITE;162 this-> command.txt.buf_xp = XPTR( local_cxy , buffer );163 this-> command.txt.count = count;159 // register command in calling thread descriptor 160 this->txt_cmd.dev_xp = dev_xp; 161 this->txt_cmd.type = TXT_SYNC_WRITE; 162 this->txt_cmd.buf_xp = XPTR( local_cxy , buffer ); 163 this->txt_cmd.count = count; 164 164 165 165 // get driver command function … … 168 168 dev_cmd_t * cmd = (dev_cmd_t *)hal_remote_lpt( XPTR( dev_cxy , &dev_ptr->cmd ) ); 169 169 170 // call d irectly driver command170 // call driver function 171 171 cmd( XPTR( local_cxy , this ) ); 172 172 173 173 // return I/O operation status from calling thread descriptor 174 return this-> command.txt.error;174 return this->txt_cmd.error; 175 175 } 176 176
Note: See TracChangeset
for help on using the changeset viewer.