Changeset 3 for trunk/kernel/devices/dev_mmc.c
- Timestamp:
- Apr 26, 2017, 2:08:13 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/devices/dev_mmc.c
r1 r3 26 26 #include <soclib_mmc.h> 27 27 #include <printk.h> 28 #include <chdev.h> 28 29 #include <thread.h> 29 30 #include <dev_mmc.h> … … 33 34 ///////////////////////////////////////////////////////////////////////////////////////// 34 35 35 extern devices_directory_t devices_dir; // allocated in kernel_init.c 36 37 extern devices_input_irq_t devices_input_irq; // allocated in kernel_init.c 38 39 ////////////////////////////////// 40 void dev_mmc_init( xptr_t dev_xp ) 41 { 42 // get MMC device descriptor cluster and local pointer 43 cxy_t dev_cxy = GET_CXY( dev_xp ); 44 device_t * dev_ptr = (device_t *)GET_PTR( dev_xp ); 45 36 extern chdev_directory_t chdev_dir; // allocated in kernel_init.c 37 38 extern chdev_icu_input_t chdev_icu_input; // allocated in kernel_init.c 39 40 //////////////////////////////////// 41 void dev_mmc_init( chdev_t * chdev ) 42 { 46 43 // get implementation from device descriptor 47 uint32_t impl = hal_remote_lw( XPTR( dev_cxy , &dev_ptr->impl ) ); 48 49 // set driver specific fields in device descriptor 50 // and call driver init function 44 uint32_t impl = chdev->impl; 45 46 // set driver specific fields in device descriptor and call driver init function 51 47 if( impl == IMPL_MMC_TSR ) 52 48 { 53 hal_remote_spt( XPTR( dev_cxy , &dev_ptr->cmd ) , &soclib_mmc_command ); 54 hal_remote_spt( XPTR( dev_cxy , &dev_ptr->isr ) , &soclib_mmc_isr ); 55 hal_remote_memcpy( XPTR( dev_cxy , &dev_ptr->name ), 56 XPTR( local_cxy , "MMC_TSR" ) , 16 ); 57 soclib_mmc_init( dev_xp ); 49 chdev->cmd = &soclib_mmc_cmd; 50 chdev->isr = &soclib_mmc_isr; 51 soclib_mmc_init( chdev ); 58 52 } 59 53 else 60 54 { 61 printk("\n[PANIC] in %s: undefined MMC device implementation\n", __FUNCTION__ ); 62 hal_core_sleep(); 55 assert( false , __FUNCTION__ , "undefined MMC device implementation" ); 63 56 } 64 57 } // end dev_mmc_init() … … 72 65 { 73 66 mmc_dmsg("\n[INFO] %s enters for thread %x in process %x : command = %d\n", 74 __FUNCTION__ , this->trdid , this->process->pid , this-> dev.mmc.type );67 __FUNCTION__ , this->trdid , this->process->pid , this->command.mmc.type ); 75 68 76 69 // get extended pointer on MMC device 77 xptr_t dev_xp = this->dev.mmc.dev_xp; 78 79 if ( dev_xp == XPTR_NULL ) 80 { 81 printk("\n[PANIC] in %s : undefined MMC device descriptor " 82 "in cluster %x for thread %x in process %x\n", 83 __FUNCTION__ , local_cxy , this->trdid , this->process->pid ); 84 hal_core_sleep(); 85 } 70 xptr_t dev_xp = this->command.mmc.dev_xp; 71 72 assert( (dev_xp != XPTR_NULL) , __FUNCTION__ , "undefined MMC device descriptor" ); 86 73 87 74 // get MMC device cluster identifier & local pointer 88 cxy_t 89 device_t * dev_ptr = (device_t *)GET_PTR( dev_xp );75 cxy_t dev_cxy = GET_CXY( dev_xp ); 76 chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp ); 90 77 91 78 // get driver command function pointer from MMC device descriptor … … 116 103 cxy_t cxy = CXY_FROM_PADDR( buf_paddr ); 117 104 118 if ( buf_paddr & (CONFIG_CACHE_LINE_SIZE -1) ) 119 { 120 printk("\n[PANIC] in %s : buffer not aligned on cache line " 121 "for thread %x / target cluster %x\n", 122 __FUNCTION__ , this->trdid , cxy ); 123 hal_core_sleep(); 124 } 105 assert( ((buf_paddr & (CONFIG_CACHE_LINE_SIZE -1)) == 0) , __FUNCTION__ , 106 "buffer not aligned on cache line" ); 125 107 126 108 // get extended pointer on MMC device descriptor 127 xptr_t dev_xp = devices_dir.mmc[cxy];128 129 // store command arguments in thread descriptor 130 this-> dev.mmc.dev_xp = dev_xp;131 this-> dev.mmc.type = MMC_CC_INVAL;132 this-> dev.mmc.buf_paddr = buf_paddr;133 this-> dev.mmc.buf_size = buf_size;134 135 // execute operation 136 dev_mmc_access( this ); 137 138 // return operation status 139 return this-> dev.mmc.error;109 xptr_t dev_xp = chdev_dir.mmc[cxy]; 110 111 // store command arguments in thread descriptor 112 this->command.mmc.dev_xp = dev_xp; 113 this->command.mmc.type = MMC_CC_INVAL; 114 this->command.mmc.buf_paddr = buf_paddr; 115 this->command.mmc.buf_size = buf_size; 116 117 // execute operation 118 dev_mmc_access( this ); 119 120 // return operation status 121 return this->command.mmc.error; 140 122 } 141 123 … … 150 132 cxy_t cxy = CXY_FROM_PADDR( buf_paddr ); 151 133 152 if ( buf_paddr & (CONFIG_CACHE_LINE_SIZE -1) ) 153 { 154 printk("\n[PANIC] in %s : buffer not aligned on cache line " 155 "for thread %x / target cluster %x\n", 156 __FUNCTION__ , this->trdid , cxy ); 157 hal_core_sleep(); 158 } 159 160 // store command arguments in thread descriptor 161 this->dev.mmc.dev_xp = devices_dir.mmc[cxy]; 162 this->dev.mmc.type = MMC_CC_SYNC; 163 this->dev.mmc.buf_paddr = buf_paddr; 164 this->dev.mmc.buf_size = buf_size; 165 166 // execute operation 167 dev_mmc_access( this ); 168 169 // return operation status 170 return this->dev.mmc.error; 134 assert( ((buf_paddr & (CONFIG_CACHE_LINE_SIZE -1)) == 0) , __FUNCTION__ , 135 "buffer not aligned on cache line" ); 136 137 // store command arguments in thread descriptor 138 this->command.mmc.dev_xp = chdev_dir.mmc[cxy]; 139 this->command.mmc.type = MMC_CC_SYNC; 140 this->command.mmc.buf_paddr = buf_paddr; 141 this->command.mmc.buf_size = buf_size; 142 143 // execute operation 144 dev_mmc_access( this ); 145 146 // return operation status 147 return this->command.mmc.error; 171 148 } 172 149 … … 180 157 181 158 // store command arguments in thread descriptor 182 this-> dev.mmc.dev_xp = devices_dir.mmc[cxy];183 this-> dev.mmc.type = MMC_SET_ERROR;184 this-> dev.mmc.reg_index = index;185 this-> dev.mmc.reg_ptr = &wdata;186 187 // execute operation 188 dev_mmc_access( this ); 189 190 // return operation status 191 return this-> dev.mmc.error;159 this->command.mmc.dev_xp = chdev_dir.mmc[cxy]; 160 this->command.mmc.type = MMC_SET_ERROR; 161 this->command.mmc.reg_index = index; 162 this->command.mmc.reg_ptr = &wdata; 163 164 // execute operation 165 dev_mmc_access( this ); 166 167 // return operation status 168 return this->command.mmc.error; 192 169 } 193 170 … … 201 178 202 179 // store command arguments in thread descriptor 203 this-> dev.mmc.dev_xp = devices_dir.mmc[cxy];204 this-> dev.mmc.type = MMC_GET_ERROR;205 this-> dev.mmc.reg_index = index;206 this-> dev.mmc.reg_ptr = rdata;207 208 // execute operation 209 dev_mmc_access( this ); 210 211 // return operation status 212 return this-> dev.mmc.error;180 this->command.mmc.dev_xp = chdev_dir.mmc[cxy]; 181 this->command.mmc.type = MMC_GET_ERROR; 182 this->command.mmc.reg_index = index; 183 this->command.mmc.reg_ptr = rdata; 184 185 // execute operation 186 dev_mmc_access( this ); 187 188 // return operation status 189 return this->command.mmc.error; 213 190 } 214 191 … … 222 199 223 200 // store command arguments in thread descriptor 224 this-> dev.mmc.dev_xp = devices_dir.mmc[cxy];225 this-> dev.mmc.type = MMC_GET_INSTRU;226 this-> dev.mmc.reg_index = index;227 this-> dev.mmc.reg_ptr = rdata;228 229 // execute operation 230 dev_mmc_access( this ); 231 232 // return operation status 233 return this-> dev.mmc.error;201 this->command.mmc.dev_xp = chdev_dir.mmc[cxy]; 202 this->command.mmc.type = MMC_GET_INSTRU; 203 this->command.mmc.reg_index = index; 204 this->command.mmc.reg_ptr = rdata; 205 206 // execute operation 207 dev_mmc_access( this ); 208 209 // return operation status 210 return this->command.mmc.error; 234 211 } 235 212
Note: See TracChangeset
for help on using the changeset viewer.