Changeset 657 for trunk/kernel/devices/dev_dma.c
- Timestamp:
- Mar 18, 2020, 11:16:59 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/devices/dev_dma.c
r647 r657 2 2 * dev_dma.c - DMA (Interrupt Controler Unit) generic device API implementation. 3 3 * 4 * Authors Alain Greiner (2016,2017,2018,2019 )4 * Authors Alain Greiner (2016,2017,2018,2019,2020) 5 5 * 6 6 * Copyright (c) UPMC Sorbonne Universites … … 84 84 85 85 //////////////////////////////////////////////// 86 error_t dev_dma_ remote_memcpy( xptr_t dst_xp,87 88 86 error_t dev_dma_async_memcpy( xptr_t dst_xp, 87 xptr_t src_xp, 88 uint32_t size ) 89 89 { 90 90 thread_t * this = CURRENT_THREAD; 91 91 92 #if CONGIG_DEBUG_DEV_DMA92 #if DEBUG_DEV_DMA 93 93 uint32_t cycle = (uint32_t)hal_get_cycles(); 94 94 if( CONGIG_DEBUG_DEV_DMA < cycle ) … … 107 107 108 108 // register command in calling thread descriptor 109 this->dma_cmd.sync = false; 109 110 this->dma_cmd.dev_xp = dev_xp; 110 111 this->dma_cmd.dst_xp = dst_xp; … … 112 113 this->dma_cmd.size = size; 113 114 114 // register client thread in waiting queue, activate server thread115 // block client thread on THREAD_BLOCKED_IOand deschedule.116 // it is re-activated by the ISR signaling IO operation completion.115 // register the client thread in waiting queue, activate the server thread, 116 // block the client thread on THREAD_BLOCKED_IO, and deschedule. 117 // it is re-activated by the server thread when the transfer is completed. 117 118 chdev_register_command( dev_xp ); 118 119 119 #if CONGIG_DEBUG_DEV_DMA120 #if DEBUG_DEV_DMA 120 121 cycle = (uint32_t)hal_get_cycles(); 121 122 if( CONGIG_DEBUG_DEV_DMA < cycle ) … … 127 128 return this->dma_cmd.error; 128 129 129 } // dev_dma_ remote_memcpy()130 } // dev_dma_async_memcpy() 130 131 132 ////////////////////////////////////////////// 133 error_t dev_dma_sync_memcpy( xptr_t dst_xp, 134 xptr_t src_xp, 135 uint32_t size ) 136 { 137 thread_t * this = CURRENT_THREAD; 138 139 #if DEBUG_DEV_DMA 140 uint32_t cycle = (uint32_t)hal_get_cycles(); 141 if( CONGIG_DEBUG_DEV_DMA < cycle ) 142 printk("\n[DBG] %s : thread %x enters / dst %l / src %l / size = %x\n", 143 __FUNCTION__ , this, dst_xp, src_xp, size ); 144 #endif 145 146 // select DMA channel corresponding to core lid 147 uint32_t channel = this->core->lid; 148 149 // get extended pointer on selected DMA chdev descriptor 150 xptr_t dev_xp = chdev_dir.dma[channel]; 151 152 // check DMA chdev definition 153 assert( (dev_xp != XPTR_NULL) , "undefined DMA chdev descriptor" ); 154 155 // register command in calling thread descriptor 156 this->dma_cmd.sync = true; 157 this->dma_cmd.dev_xp = dev_xp; 158 this->dma_cmd.dst_xp = dst_xp; 159 this->dma_cmd.src_xp = src_xp; 160 this->dma_cmd.size = size; 161 162 // get driver command function 163 cxy_t dev_cxy = GET_CXY( dev_xp ); 164 chdev_t * dev_ptr = GET_PTR( dev_xp ); 165 dev_cmd_t * cmd = (dev_cmd_t *)hal_remote_lpt( XPTR( dev_cxy , &dev_ptr->cmd ) ); 166 167 // call directly the blocking driver function 168 cmd( XPTR( local_cxy , this ) ); 169 170 #if DEBUG_DEV_DMA 171 cycle = (uint32_t)hal_get_cycles(); 172 if( CONGIG_DEBUG_DEV_DMA < cycle ) 173 printk("\n[DBG] %s : thread %x exit / dst %l / src %l / size = %x\n", 174 __FUNCTION__ , this, dst_xp, src_xp, size ); 175 #endif 176 177 // return I/O operation status from calling thread descriptor 178 return this->dma_cmd.error; 179 180 } // dev_dma_sync_memcpy() 181
Note: See TracChangeset
for help on using the changeset viewer.