Changes in uspace/lib/block/libblock.c [63f8966:991f645] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/block/libblock.c
r63f8966 r991f645 75 75 typedef struct { 76 76 link_t link; 77 dev _handle_t dev_handle;77 devmap_handle_t devmap_handle; 78 78 int dev_phone; 79 79 fibril_mutex_t comm_area_lock; … … 91 91 static int get_num_blocks(int dev_phone, aoff64_t *nblocks); 92 92 93 static devcon_t *devcon_search(dev _handle_t dev_handle)93 static devcon_t *devcon_search(devmap_handle_t devmap_handle) 94 94 { 95 95 link_t *cur; … … 98 98 for (cur = dcl_head.next; cur != &dcl_head; cur = cur->next) { 99 99 devcon_t *devcon = list_get_instance(cur, devcon_t, link); 100 if (devcon->dev _handle == dev_handle) {100 if (devcon->devmap_handle == devmap_handle) { 101 101 fibril_mutex_unlock(&dcl_lock); 102 102 return devcon; … … 107 107 } 108 108 109 static int devcon_add(dev _handle_t dev_handle, int dev_phone, size_t bsize,109 static int devcon_add(devmap_handle_t devmap_handle, int dev_phone, size_t bsize, 110 110 void *comm_area, size_t comm_size) 111 111 { … … 121 121 122 122 link_initialize(&devcon->link); 123 devcon->dev _handle = dev_handle;123 devcon->devmap_handle = devmap_handle; 124 124 devcon->dev_phone = dev_phone; 125 125 fibril_mutex_initialize(&devcon->comm_area_lock); … … 134 134 for (cur = dcl_head.next; cur != &dcl_head; cur = cur->next) { 135 135 devcon_t *d = list_get_instance(cur, devcon_t, link); 136 if (d->dev _handle == dev_handle) {136 if (d->devmap_handle == devmap_handle) { 137 137 fibril_mutex_unlock(&dcl_lock); 138 138 free(devcon); … … 152 152 } 153 153 154 int block_init(dev _handle_t dev_handle, size_t comm_size)154 int block_init(devmap_handle_t devmap_handle, size_t comm_size) 155 155 { 156 156 int rc; … … 165 165 } 166 166 167 dev_phone = devmap_device_connect(dev _handle, IPC_FLAG_BLOCKING);167 dev_phone = devmap_device_connect(devmap_handle, IPC_FLAG_BLOCKING); 168 168 if (dev_phone < 0) { 169 169 munmap(comm_area, comm_size); … … 185 185 } 186 186 187 rc = devcon_add(dev _handle, dev_phone, bsize, comm_area, comm_size);187 rc = devcon_add(devmap_handle, dev_phone, bsize, comm_area, comm_size); 188 188 if (rc != EOK) { 189 189 munmap(comm_area, comm_size); … … 195 195 } 196 196 197 void block_fini(dev _handle_t dev_handle)198 { 199 devcon_t *devcon = devcon_search(dev _handle);197 void block_fini(devmap_handle_t devmap_handle) 198 { 199 devcon_t *devcon = devcon_search(devmap_handle); 200 200 assert(devcon); 201 201 202 202 if (devcon->cache) 203 (void) block_cache_fini(dev _handle);203 (void) block_cache_fini(devmap_handle); 204 204 205 205 devcon_remove(devcon); … … 214 214 } 215 215 216 int block_bb_read(dev _handle_t dev_handle, aoff64_t ba)216 int block_bb_read(devmap_handle_t devmap_handle, aoff64_t ba) 217 217 { 218 218 void *bb_buf; 219 219 int rc; 220 220 221 devcon_t *devcon = devcon_search(dev _handle);221 devcon_t *devcon = devcon_search(devmap_handle); 222 222 if (!devcon) 223 223 return ENOENT; … … 244 244 } 245 245 246 void *block_bb_get(dev _handle_t dev_handle)247 { 248 devcon_t *devcon = devcon_search(dev _handle);246 void *block_bb_get(devmap_handle_t devmap_handle) 247 { 248 devcon_t *devcon = devcon_search(devmap_handle); 249 249 assert(devcon); 250 250 return devcon->bb_buf; … … 272 272 }; 273 273 274 int block_cache_init(dev _handle_t dev_handle, size_t size, unsigned blocks,274 int block_cache_init(devmap_handle_t devmap_handle, size_t size, unsigned blocks, 275 275 enum cache_mode mode) 276 276 { 277 devcon_t *devcon = devcon_search(dev _handle);277 devcon_t *devcon = devcon_search(devmap_handle); 278 278 cache_t *cache; 279 279 if (!devcon) … … 305 305 } 306 306 307 int block_cache_fini(dev _handle_t dev_handle)308 { 309 devcon_t *devcon = devcon_search(dev _handle);307 int block_cache_fini(devmap_handle_t devmap_handle) 308 { 309 devcon_t *devcon = devcon_search(devmap_handle); 310 310 cache_t *cache; 311 311 int rc; … … 374 374 * @param block Pointer to where the function will store the 375 375 * block pointer on success. 376 * @param dev _handle Device handle of the block device.376 * @param devmap_handle Device handle of the block device. 377 377 * @param boff Block offset. 378 378 * @param flags If BLOCK_FLAGS_NOREAD is specified, block_get() … … 382 382 * @return EOK on success or a negative error code. 383 383 */ 384 int block_get(block_t **block, dev _handle_t dev_handle, aoff64_t boff, int flags)384 int block_get(block_t **block, devmap_handle_t devmap_handle, aoff64_t boff, int flags) 385 385 { 386 386 devcon_t *devcon; … … 391 391 int rc; 392 392 393 devcon = devcon_search(dev _handle);393 devcon = devcon_search(devmap_handle); 394 394 395 395 assert(devcon); … … 500 500 501 501 block_initialize(b); 502 b->dev _handle = dev_handle;502 b->devmap_handle = devmap_handle; 503 503 b->size = cache->lblock_size; 504 504 b->boff = boff; … … 549 549 int block_put(block_t *block) 550 550 { 551 devcon_t *devcon = devcon_search(block->dev _handle);551 devcon_t *devcon = devcon_search(block->devmap_handle); 552 552 cache_t *cache; 553 553 unsigned blocks_cached; … … 645 645 /** Read sequential data from a block device. 646 646 * 647 * @param dev _handle Device handle of the block device.647 * @param devmap_handle Device handle of the block device. 648 648 * @param bufpos Pointer to the first unread valid offset within the 649 649 * communication buffer. … … 657 657 * @return EOK on success or a negative return code on failure. 658 658 */ 659 int block_seqread(dev _handle_t dev_handle, size_t *bufpos, size_t *buflen,659 int block_seqread(devmap_handle_t devmap_handle, size_t *bufpos, size_t *buflen, 660 660 aoff64_t *pos, void *dst, size_t size) 661 661 { … … 665 665 devcon_t *devcon; 666 666 667 devcon = devcon_search(dev _handle);667 devcon = devcon_search(devmap_handle); 668 668 assert(devcon); 669 669 block_size = devcon->pblock_size; … … 711 711 /** Read blocks directly from device (bypass cache). 712 712 * 713 * @param dev _handle Device handle of the block device.713 * @param devmap_handle Device handle of the block device. 714 714 * @param ba Address of first block. 715 715 * @param cnt Number of blocks. … … 718 718 * @return EOK on success or negative error code on failure. 719 719 */ 720 int block_read_direct(dev _handle_t dev_handle, aoff64_t ba, size_t cnt, void *buf)720 int block_read_direct(devmap_handle_t devmap_handle, aoff64_t ba, size_t cnt, void *buf) 721 721 { 722 722 devcon_t *devcon; 723 723 int rc; 724 724 725 devcon = devcon_search(dev _handle);725 devcon = devcon_search(devmap_handle); 726 726 assert(devcon); 727 727 … … 739 739 /** Write blocks directly to device (bypass cache). 740 740 * 741 * @param dev _handle Device handle of the block device.741 * @param devmap_handle Device handle of the block device. 742 742 * @param ba Address of first block. 743 743 * @param cnt Number of blocks. … … 746 746 * @return EOK on success or negative error code on failure. 747 747 */ 748 int block_write_direct(dev _handle_t dev_handle, aoff64_t ba, size_t cnt,748 int block_write_direct(devmap_handle_t devmap_handle, aoff64_t ba, size_t cnt, 749 749 const void *data) 750 750 { … … 752 752 int rc; 753 753 754 devcon = devcon_search(dev _handle);754 devcon = devcon_search(devmap_handle); 755 755 assert(devcon); 756 756 … … 767 767 /** Get device block size. 768 768 * 769 * @param dev _handle Device handle of the block device.769 * @param devmap_handle Device handle of the block device. 770 770 * @param bsize Output block size. 771 771 * 772 772 * @return EOK on success or negative error code on failure. 773 773 */ 774 int block_get_bsize(dev _handle_t dev_handle, size_t *bsize)774 int block_get_bsize(devmap_handle_t devmap_handle, size_t *bsize) 775 775 { 776 776 devcon_t *devcon; 777 777 778 devcon = devcon_search(dev _handle);778 devcon = devcon_search(devmap_handle); 779 779 assert(devcon); 780 780 … … 784 784 /** Get number of blocks on device. 785 785 * 786 * @param dev _handle Device handle of the block device.786 * @param devmap_handle Device handle of the block device. 787 787 * @param nblocks Output number of blocks. 788 788 * 789 789 * @return EOK on success or negative error code on failure. 790 790 */ 791 int block_get_nblocks(dev _handle_t dev_handle, aoff64_t *nblocks)791 int block_get_nblocks(devmap_handle_t devmap_handle, aoff64_t *nblocks) 792 792 { 793 793 devcon_t *devcon; 794 794 795 devcon = devcon_search(dev _handle);795 devcon = devcon_search(devmap_handle); 796 796 assert(devcon); 797 797 … … 818 818 printf("Error %d reading %d blocks starting at block %" PRIuOFF64 819 819 " from device handle %d\n", rc, cnt, ba, 820 devcon->dev _handle);820 devcon->devmap_handle); 821 821 #ifndef NDEBUG 822 822 stacktrace_print(); … … 844 844 if (rc != EOK) { 845 845 printf("Error %d writing %d blocks starting at block %" PRIuOFF64 846 " to device handle %d\n", rc, cnt, ba, devcon->dev _handle);846 " to device handle %d\n", rc, cnt, ba, devcon->devmap_handle); 847 847 #ifndef NDEBUG 848 848 stacktrace_print();
Note:
See TracChangeset
for help on using the changeset viewer.