Changeset c4f32fff in mainline for uspace/drv/block/ddisk/ddisk.c
- Timestamp:
- 2015-04-12T10:58:45Z (10 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 42d0eeb6
- Parents:
- 7b084d3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/block/ddisk/ddisk.c
r7b084d3 rc4f32fff 96 96 typedef struct { 97 97 fibril_mutex_t lock; 98 98 99 fibril_condvar_t io_cv; 99 100 bool io_busy; 101 102 ssize_t size; 103 size_t blocks; 104 105 uintptr_t dma_buffer_phys; 106 void *dma_buffer; 107 100 108 ddf_dev_t *dev; 101 109 ddf_fun_t *fun; 110 102 111 ddisk_res_t ddisk_res; 103 112 ddisk_regs_t *ddisk_regs; 104 uintptr_t dma_buffer_phys; 105 void *dma_buffer; 113 106 114 bd_srvs_t bds; 107 115 } ddisk_dev_t; … … 196 204 read, ba, buf); 197 205 198 if (ba >= pio_read_32(&ddisk_dev->ddisk_regs->size) / DDISK_BLOCK_SIZE)206 if (ba >= ddisk_dev->blocks) 199 207 return ELIMIT; 200 208 … … 268 276 ddisk_dev_t *ddisk_dev = (ddisk_dev_t *) bd->srvs->sarg; 269 277 270 *rnb = pio_read_32(&ddisk_dev->ddisk_regs->size) / DDISK_BLOCK_SIZE;278 *rnb = ddisk_dev->blocks; 271 279 return EOK; 272 280 } … … 366 374 ddisk_dev->fun = NULL; 367 375 rc = EOK; 376 368 377 error: 369 378 return rc; … … 405 414 int rc; 406 415 416 /* 417 * Get our resources. 418 */ 407 419 rc = ddisk_get_res(dev, &res); 408 420 if (rc != EOK) { … … 411 423 } 412 424 425 /* 426 * Allocate soft state. 427 */ 413 428 ddisk_dev = ddf_dev_data_alloc(dev, sizeof(ddisk_dev_t)); 414 429 if (!ddisk_dev) { … … 418 433 } 419 434 435 /* 436 * Initialize soft state. 437 */ 420 438 fibril_mutex_initialize(&ddisk_dev->lock); 439 ddisk_dev->dev = dev; 440 ddisk_dev->ddisk_res = res; 441 421 442 fibril_condvar_initialize(&ddisk_dev->io_cv); 422 443 ddisk_dev->io_busy = false; 423 ddisk_dev->dev = dev; 424 ddisk_dev->ddisk_res = res; 444 445 bd_srvs_init(&ddisk_dev->bds); 446 ddisk_dev->bds.ops = &ddisk_bd_ops; 447 ddisk_dev->bds.sarg = ddisk_dev; 425 448 426 449 /* … … 435 458 ddisk_dev->ddisk_regs = vaddr; 436 459 437 if ((int32_t) pio_read_32(&ddisk_dev->ddisk_regs->size) <= 0) { 460 ddisk_dev->size = (int32_t) pio_read_32(&ddisk_dev->ddisk_regs->size); 461 ddisk_dev->blocks = ddisk_dev->size / DDISK_BLOCK_SIZE; 462 463 if (ddisk_dev->size <= 0) { 438 464 ddf_msg(LVL_WARN, "No disk detected."); 439 465 rc = EIO; … … 456 482 ddisk_dev->dma_buffer, (void *) ddisk_dev->dma_buffer_phys); 457 483 458 bd_srvs_init(&ddisk_dev->bds); 459 ddisk_dev->bds.ops = &ddisk_bd_ops; 460 ddisk_dev->bds.sarg = ddisk_dev; 461 484 /* 485 * Create an exposed function. 486 */ 462 487 rc = ddisk_fun_create(ddisk_dev); 463 488 if (rc != EOK) { … … 485 510 */ 486 511 ddf_msg(LVL_NOTE, 487 "Device at %p with %" PRIu32 " blocks (%" PRIu32 488 "B) using interrupt %d", 489 (void *) ddisk_dev->ddisk_res.base, 490 pio_read_32(&ddisk_dev->ddisk_regs->size) / DDISK_BLOCK_SIZE, 491 pio_read_32(&ddisk_dev->ddisk_regs->size), 492 ddisk_dev->ddisk_res.irq); 512 "Device at %p with %zd blocks (%zuB) using interrupt %d", 513 (void *) ddisk_dev->ddisk_res.base, ddisk_dev->blocks, 514 ddisk_dev->size, ddisk_dev->ddisk_res.irq); 493 515 494 516 return EOK; … … 499 521 if (ddisk_dev->dma_buffer) 500 522 dmamem_unmap_anonymous(ddisk_dev->dma_buffer); 523 501 524 return rc; 502 525 }
Note:
See TracChangeset
for help on using the changeset viewer.