Changeset 286 for branch/giet_vm_ioc_drivers/giet_drivers/hba_driver.c
- Timestamp:
- Jan 31, 2014, 5:05:21 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branch/giet_vm_ioc_drivers/giet_drivers/hba_driver.c
r283 r286 77 77 #include <ctx_handler.h> 78 78 #include <mmc_driver.h> 79 #include <hba_driver.h> 79 80 #include <vmem.h> 80 81 … … 128 129 if( channel >= NB_HBA_CHANNELS ) 129 130 { 130 _ get_lock(&_tty_put_lock);131 _tty_get_lock( 0 ); 131 132 _puts("\n[GIET ERROR] in _hba_get_status() : illegal channel\n"); 132 _ release_lock(&_tty_put_lock);133 _tty_release_lock( 0 ); 133 134 return 1; 134 135 } … … 150 151 if( channel >= NB_HBA_CHANNELS ) 151 152 { 152 _ get_lock(&_tty_put_lock);153 _tty_get_lock( 0 ); 153 154 _puts("\n[GIET ERROR] in _hba_reset_status() : illegal channel\n"); 154 _ release_lock(&_tty_put_lock);155 _tty_release_lock( 0 ); 155 156 return 1; 156 157 } … … 191 192 hba_cmd_table_t* cmd_table; // command table pointer 192 193 193 // TODO The block size must be obtained from the hardware... 194 block_size = 512; 194 block_size = _hba_get_block_size(); 195 195 196 196 // check buffer alignment 197 197 if( buf_vaddr & (block_size-1) ) 198 198 { 199 _ get_lock(&_tty_put_lock);199 _tty_get_lock( 0 ); 200 200 _puts("\n[GIET ERROR] in _hba_set_cmd() : user buffer not block aligned\n"); 201 _ release_lock(&_tty_put_lock);201 _tty_release_lock( 0 ); 202 202 return 1; 203 203 } … … 207 207 if ( channel_id == 0xFFFFFFFF ) 208 208 { 209 _ get_lock(&_tty_put_lock);209 _tty_get_lock( 0 ); 210 210 _puts("\n[GIET ERROR] in _hba_set_cmd() : no HBA channel allocated\n"); 211 _ release_lock(&_tty_put_lock);211 _tty_release_lock( 0 ); 212 212 return 1; 213 213 } … … 223 223 if( pxci & (1<<cmd_id ) ) 224 224 { 225 _ get_lock(&_tty_put_lock);225 _tty_get_lock( 0 ); 226 226 _puts("\n[GIET ERROR] in _hba_set_cmd() : command list full in channel \n"); 227 227 _putd( channel_id ); 228 228 _puts("\n"); 229 _ release_lock(&_tty_put_lock);229 _tty_release_lock( 0 ); 230 230 return 1; 231 231 } … … 262 262 if ( ko ) 263 263 { 264 _ get_lock(&_tty_put_lock);264 _tty_get_lock( 0 ); 265 265 _puts("[GIET ERROR] in _hba_set_cmd() : user buffer unmapped\n"); 266 _ release_lock(&_tty_put_lock);266 _tty_release_lock( 0 ); 267 267 return 1; 268 268 } 269 269 if ((flags & PTE_U) == 0) 270 270 { 271 _ get_lock(&_tty_put_lock);271 _tty_get_lock( 0 ); 272 272 _puts("[GIET ERROR] in _hba_set_cmd() : user buffer not in user space\n"); 273 _ release_lock(&_tty_put_lock);273 _tty_release_lock( 0 ); 274 274 return 1; 275 275 } 276 276 if (((flags & PTE_W) == 0 ) && (is_read == 0) ) 277 277 { 278 _ get_lock(&_tty_put_lock);278 _tty_get_lock( 0 ); 279 279 _puts("[GIET ERROR] in _hba_set_cmd() : user buffer not writable\n"); 280 _ release_lock(&_tty_put_lock);280 _tty_release_lock( 0 ); 281 281 return 1; 282 282 } … … 285 285 if( buf_id > 245 ) 286 286 { 287 _ get_lock(&_tty_put_lock);287 _tty_get_lock( 0 ); 288 288 _puts("[GIET ERROR] in _hba_set_cmd() : max number of buffers is 248\n"); 289 _ release_lock(&_tty_put_lock);289 _tty_release_lock( 0 ); 290 290 return 1; 291 291 } … … 415 415 // Returns 0 if success, > 0 if error. 416 416 /////////////////////////////////////////////////////////////////// 417 unsigned int _hba_write( unsigned int lba, 417 unsigned int _hba_write( unsigned int mode, 418 unsigned int lba, 418 419 void* buffer, 419 420 unsigned int count ) … … 427 428 // Returns 0 if success, > 0 if error. 428 429 /////////////////////////////////////////////////////////////////// 429 unsigned int _hba_read( unsigned int lba, 430 unsigned int _hba_read( unsigned int mode, 431 unsigned int lba, 430 432 void* buffer, 431 433 unsigned int count ) … … 440 442 // - the command tables physical addresses array, 441 443 ////////////////////////////////////////////////////////////////// 442 void_hba_init( unsigned int channel )444 unsigned int _hba_init( unsigned int channel ) 443 445 { 444 446 unsigned int ppn; … … 473 475 if ( fail ) 474 476 { 475 _ get_lock(&_tty_put_lock);477 _tty_get_lock( 0 ); 476 478 _puts("[GIET ERROR] in _hba_init() : command list unmapped\n"); 477 _ release_lock(&_tty_put_lock);478 _exit();479 _tty_release_lock( 0 ); 480 return 1; 479 481 } 480 482 hba_cmd_list_paddr[channel] = ((paddr_t)ppn) | (vbase & 0xFFF); … … 490 492 if ( fail ) 491 493 { 492 _ get_lock(&_tty_put_lock);494 _tty_get_lock( 0 ); 493 495 _puts("[GIET ERROR] in _hba_init() : command table unmapped\n"); 494 _ release_lock(&_tty_put_lock);495 _exit();496 _tty_release_lock( 0 ); 497 return 1; 496 498 } 497 499 hba_cmd_table_paddr[channel][c] = ((paddr_t)ppn) | (vbase & 0xFFF); 498 500 } 501 502 return 0; 499 503 } 500 504 505 /////////////////////////////////////////////////////////////////////////////// 506 // _hba_get_block_size() 507 // This function returns the block_size of HBA controller 508 /////////////////////////////////////////////////////////////////////////////// 509 unsigned int _hba_get_block_size() 510 { 511 // TODO The block size must be obtained from the hardware... 512 return 512; 513 } 501 514 502 515
Note: See TracChangeset
for help on using the changeset viewer.