Changes in trunk/kernel/devices/dev_mmc.c [3:1]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/kernel/devices/dev_mmc.c
r3 r1 26 26 #include <soclib_mmc.h> 27 27 #include <printk.h> 28 #include <chdev.h>29 28 #include <thread.h> 30 29 #include <dev_mmc.h> … … 34 33 ///////////////////////////////////////////////////////////////////////////////////////// 35 34 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 { 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 43 46 // get implementation from device descriptor 44 uint32_t impl = chdev->impl; 45 46 // set driver specific fields in device descriptor and call driver init function 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 47 51 if( impl == IMPL_MMC_TSR ) 48 52 { 49 chdev->cmd = &soclib_mmc_cmd; 50 chdev->isr = &soclib_mmc_isr; 51 soclib_mmc_init( chdev ); 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 ); 52 58 } 53 59 else 54 60 { 55 assert( false , __FUNCTION__ , "undefined MMC device implementation" ); 61 printk("\n[PANIC] in %s: undefined MMC device implementation\n", __FUNCTION__ ); 62 hal_core_sleep(); 56 63 } 57 64 } // end dev_mmc_init() … … 65 72 { 66 73 mmc_dmsg("\n[INFO] %s enters for thread %x in process %x : command = %d\n", 67 __FUNCTION__ , this->trdid , this->process->pid , this-> command.mmc.type );74 __FUNCTION__ , this->trdid , this->process->pid , this->dev.mmc.type ); 68 75 69 76 // get extended pointer on MMC device 70 xptr_t dev_xp = this->command.mmc.dev_xp; 71 72 assert( (dev_xp != XPTR_NULL) , __FUNCTION__ , "undefined MMC device descriptor" ); 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 } 73 86 74 87 // get MMC device cluster identifier & local pointer 75 cxy_t dev_cxy = GET_CXY( dev_xp );76 chdev_t * dev_ptr = (chdev_t *)GET_PTR( dev_xp );88 cxy_t dev_cxy = GET_CXY( dev_xp ); 89 device_t * dev_ptr = (device_t *)GET_PTR( dev_xp ); 77 90 78 91 // get driver command function pointer from MMC device descriptor … … 103 116 cxy_t cxy = CXY_FROM_PADDR( buf_paddr ); 104 117 105 assert( ((buf_paddr & (CONFIG_CACHE_LINE_SIZE -1)) == 0) , __FUNCTION__ , 106 "buffer not aligned on cache line" ); 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 } 107 125 108 126 // get extended pointer on MMC device descriptor 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;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; 122 140 } 123 141 … … 132 150 cxy_t cxy = CXY_FROM_PADDR( buf_paddr ); 133 151 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; 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; 148 171 } 149 172 … … 157 180 158 181 // store command arguments in thread descriptor 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;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; 169 192 } 170 193 … … 178 201 179 202 // store command arguments in thread descriptor 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;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; 190 213 } 191 214 … … 199 222 200 223 // store command arguments in thread descriptor 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;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; 211 234 } 212 235
Note: See TracChangeset
for help on using the changeset viewer.