Changes in / [1f1fa64:f2f4c00] in mainline
- Location:
- uspace
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/nic/nic.c
r1f1fa64 rf2f4c00 226 226 } 227 227 228 printf("% d: %s\n", i, svc_name);228 printf("%zu: %s\n", i, svc_name); 229 229 printf("\tMAC address: %s\n", addr_str); 230 230 printf("\tVendor name: %s\n", -
uspace/drv/block/ata_bd/Makefile
r1f1fa64 rf2f4c00 28 28 29 29 USPACE_PREFIX = ../../.. 30 LIBS = $(LIBDRV_PREFIX)/libdrv.a 31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include 30 LIBS = $(LIBDRV_PREFIX)/libdrv.a $(LIBSCSI_PREFIX)/libscsi.a 31 EXTRA_CFLAGS += -I$(LIBDRV_PREFIX)/include -I$(LIBSCSI_PREFIX)/include 32 32 BINARY = ata_bd 33 33 -
uspace/drv/block/ata_bd/ata_bd.c
r1f1fa64 rf2f4c00 54 54 #include <bd_srv.h> 55 55 #include <fibril_synch.h> 56 #include <scsi/sbc.h> 56 57 #include <stdint.h> 57 58 #include <str.h> … … 103 104 static int ata_identify_pkt_dev(disk_t *disk, void *buf); 104 105 static int ata_cmd_packet(disk_t *disk, const void *cpkt, size_t cpkt_size, 105 void *obuf, size_t obuf_size); 106 static int ata_pcmd_inquiry(disk_t *disk, void *obuf, size_t obuf_size); 106 void *obuf, size_t obuf_size, size_t *rcvd_size); 107 static int ata_pcmd_inquiry(disk_t *disk, void *obuf, size_t obuf_size, 108 size_t *rcvd_size); 107 109 static int ata_pcmd_read_12(disk_t *disk, uint64_t ba, size_t cnt, 108 110 void *obuf, size_t obuf_size); 111 static int ata_pcmd_read_capacity(disk_t *disk, uint64_t *nblocks, 112 size_t *block_size); 109 113 static int ata_pcmd_read_toc(disk_t *disk, uint8_t ses, 110 114 void *obuf, size_t obuf_size); … … 340 344 uint8_t model[40]; 341 345 ata_inquiry_data_t inq_data; 346 size_t isize; 342 347 uint16_t w; 343 348 uint8_t c; 344 349 uint16_t bc; 350 uint64_t nblocks; 351 size_t block_size; 345 352 size_t pos, len; 346 353 int rc; … … 457 464 if (d->dev_type == ata_pkt_dev) { 458 465 /* Send inquiry. */ 459 rc = ata_pcmd_inquiry(d, &inq_data, sizeof(inq_data) );460 if (rc != EOK ) {466 rc = ata_pcmd_inquiry(d, &inq_data, sizeof(inq_data), &isize); 467 if (rc != EOK || isize < sizeof(inq_data)) { 461 468 ddf_msg(LVL_ERROR, "Device inquiry failed."); 462 469 d->present = false; … … 468 475 ddf_msg(LVL_WARN, "Peripheral device type is not CD-ROM."); 469 476 470 /* Assume 2k block size for now. */ 471 d->block_size = 2048; 477 rc = ata_pcmd_read_capacity(d, &nblocks, &block_size); 478 if (rc != EOK) { 479 ddf_msg(LVL_ERROR, "Read capacity command failed."); 480 d->present = false; 481 return EIO; 482 } 483 484 d->blocks = nblocks; 485 d->block_size = block_size; 472 486 } else { 473 487 /* Assume register Read always uses 512-byte blocks. */ … … 722 736 * @param obuf Buffer for storing data read from device 723 737 * @param obuf_size Size of obuf in bytes 738 * @param rcvd_size Place to store number of bytes read or @c NULL 724 739 * 725 740 * @return EOK on success, EIO on error. 726 741 */ 727 742 static int ata_cmd_packet(disk_t *disk, const void *cpkt, size_t cpkt_size, 728 void *obuf, size_t obuf_size )743 void *obuf, size_t obuf_size, size_t *rcvd_size) 729 744 { 730 745 ata_ctrl_t *ctrl = disk->ctrl; … … 800 815 return EIO; 801 816 817 if (rcvd_size != NULL) 818 *rcvd_size = data_size; 802 819 return EOK; 803 820 } … … 811 828 * @return EOK on success, EIO on error. 812 829 */ 813 static int ata_pcmd_inquiry(disk_t *disk, void *obuf, size_t obuf_size) 830 static int ata_pcmd_inquiry(disk_t *disk, void *obuf, size_t obuf_size, 831 size_t *rcvd_size) 814 832 { 815 833 ata_pcmd_inquiry_t cp; … … 821 839 cp.alloc_len = min(obuf_size, 0xff); /* Allocation length */ 822 840 823 rc = ata_cmd_packet(disk, &cp, sizeof(cp), obuf, obuf_size );841 rc = ata_cmd_packet(disk, &cp, sizeof(cp), obuf, obuf_size, rcvd_size); 824 842 if (rc != EOK) 825 843 return rc; 844 845 return EOK; 846 } 847 848 /** Issue ATAPI read capacity(10) command. 849 * 850 * @param disk Disk 851 * @param nblocks Place to store number of blocks 852 * @param block_size Place to store block size 853 * 854 * @return EOK on success, EIO on error. 855 */ 856 static int ata_pcmd_read_capacity(disk_t *disk, uint64_t *nblocks, 857 size_t *block_size) 858 { 859 scsi_cdb_read_capacity_10_t cdb; 860 scsi_read_capacity_10_data_t data; 861 size_t rsize; 862 int rc; 863 864 memset(&cdb, 0, sizeof(cdb)); 865 cdb.op_code = SCSI_CMD_READ_CAPACITY_10; 866 867 rc = ata_cmd_packet(disk, &cdb, sizeof(cdb), &data, sizeof(data), &rsize); 868 if (rc != EOK) 869 return rc; 870 871 if (rsize != sizeof(data)) 872 return EIO; 873 874 *nblocks = uint32_t_be2host(data.last_lba) + 1; 875 *block_size = uint32_t_be2host(data.block_size); 826 876 827 877 return EOK; … … 856 906 cp.nblocks = host2uint32_t_be(cnt); 857 907 858 rc = ata_cmd_packet(disk, &cp, sizeof(cp), obuf, obuf_size );908 rc = ata_cmd_packet(disk, &cp, sizeof(cp), obuf, obuf_size, NULL); 859 909 if (rc != EOK) 860 910 return rc; … … 895 945 cp.oldformat = 0x40; /* 0x01 = multi-session mode (shifted to MSB) */ 896 946 897 rc = ata_cmd_packet(disk, &cp, sizeof(cp), obuf, obuf_size );947 rc = ata_cmd_packet(disk, &cp, sizeof(cp), obuf, obuf_size, NULL); 898 948 if (rc != EOK) 899 949 return rc; -
uspace/drv/bus/isa/isa.dev
r1f1fa64 rf2f4c00 14 14 irq 12 15 15 io_range 060 5 16 17 ne2k: 18 match 100 isa/ne2k 19 irq 5 20 io_range 300 20 21 22 sb16: 23 match 100 isa/sb16 24 io_range 220 20 25 io_range 330 2 26 irq 5 27 dma 1 28 dma 5 16 29 17 30 cmos-rtc: -
uspace/lib/block/block.c
r1f1fa64 rf2f4c00 55 55 #include "block.h" 56 56 57 #define MAX_WRITE_RETRIES 10 58 57 59 /** Lock protecting the device connection list */ 58 60 static FIBRIL_MUTEX_INITIALIZE(dcl_lock); … … 79 81 void *bb_buf; 80 82 aoff64_t bb_addr; 83 aoff64_t pblocks; /**< Number of physical blocks */ 81 84 size_t pblock_size; /**< Physical block size. */ 82 85 cache_t *cache; … … 103 106 104 107 static int devcon_add(service_id_t service_id, async_sess_t *sess, 105 size_t bsize, bd_t *bd)108 size_t bsize, aoff64_t dev_size, bd_t *bd) 106 109 { 107 110 devcon_t *devcon; … … 118 121 devcon->bb_addr = 0; 119 122 devcon->pblock_size = bsize; 123 devcon->pblocks = dev_size; 120 124 devcon->cache = NULL; 121 125 … … 164 168 return rc; 165 169 } 166 167 rc = devcon_add(service_id, sess, bsize, bd); 170 171 aoff64_t dev_size; 172 rc = bd_get_num_blocks(bd, &dev_size); 173 if (rc != EOK) { 174 bd_close(bd); 175 async_hangup(sess); 176 return rc; 177 } 178 179 rc = devcon_add(service_id, sess, bsize, dev_size, bd); 168 180 if (rc != EOK) { 169 181 bd_close(bd); … … 349 361 fibril_mutex_initialize(&b->lock); 350 362 b->refcnt = 1; 363 b->write_failures = 0; 351 364 b->dirty = false; 352 365 b->toxic = false; … … 373 386 block_t *b; 374 387 link_t *link; 375 388 aoff64_t p_ba; 376 389 int rc; 377 390 … … 382 395 383 396 cache = devcon->cache; 397 398 /* Check whether the logical block (or part of it) is beyond 399 * the end of the device or not. 400 */ 401 p_ba = ba_ltop(devcon, ba); 402 p_ba += cache->blocks_cluster; 403 if (p_ba >= devcon->pblocks) { 404 /* This request cannot be satisfied */ 405 return EIO; 406 } 407 384 408 385 409 retry: … … 458 482 * another block next time. 459 483 */ 460 fibril_mutex_unlock(&b->lock); 461 goto retry; 462 } 484 if (b->write_failures < MAX_WRITE_RETRIES) { 485 b->write_failures++; 486 fibril_mutex_unlock(&b->lock); 487 goto retry; 488 } else { 489 printf("Too many errors writing block %" 490 PRIuOFF64 "from device handle %" PRIun "\n" 491 "SEVERE DATA LOSS POSSIBLE\n", 492 b->lba, devcon->service_id); 493 } 494 } else 495 b->write_failures = 0; 496 463 497 b->dirty = false; 464 498 if (!fibril_mutex_trylock(&cache->lock)) { … … 577 611 rc = write_blocks(devcon, block->pba, cache->blocks_cluster, 578 612 block->data, block->size); 613 if (rc == EOK) 614 block->write_failures = 0; 579 615 block->dirty = false; 580 616 } … … 602 638 */ 603 639 block->refcnt++; 604 fibril_mutex_unlock(&block->lock); 605 fibril_mutex_unlock(&cache->lock); 606 goto retry; 640 641 if (block->write_failures < MAX_WRITE_RETRIES) { 642 block->write_failures++; 643 fibril_mutex_unlock(&block->lock); 644 fibril_mutex_unlock(&cache->lock); 645 goto retry; 646 } else { 647 printf("Too many errors writing block %" 648 PRIuOFF64 "from device handle %" PRIun "\n" 649 "SEVERE DATA LOSS POSSIBLE\n", 650 block->lba, devcon->service_id); 651 } 607 652 } 608 653 /* … … 770 815 devcon_t *devcon = devcon_search(service_id); 771 816 assert(devcon); 772 817 773 818 return bd_get_num_blocks(devcon->bd, nblocks); 774 819 } -
uspace/lib/block/block.h
r1f1fa64 rf2f4c00 81 81 /** Size of the block. */ 82 82 size_t size; 83 /** Number of write failures. */ 84 int write_failures; 83 85 /** Link for placing the block into the free block list. */ 84 86 link_t free_link; -
uspace/lib/c/generic/adt/hash_table.c
r1f1fa64 rf2f4c00 370 370 */ 371 371 if (!f(cur_link, arg)) 372 return;373 } 374 } 375 372 goto out; 373 } 374 } 375 out: 376 376 h->apply_ongoing = false; 377 377 -
uspace/lib/mbr/libmbr.c
r1f1fa64 rf2f4c00 90 90 mbr_t *mbr_alloc_mbr(void) 91 91 { 92 return malloc(sizeof(mbr_t));92 return (mbr_t *)alloc_br(); 93 93 } 94 94 -
uspace/lib/mbr/libmbr.h
r1f1fa64 rf2f4c00 37 37 #define LIBMBR_LIBMBR_H_ 38 38 39 #include <adt/list.h> 40 #include <loc.h> 39 41 #include <sys/types.h> 40 42 #include "mbr.h" -
uspace/srv/fs/cdfs/cdfs_ops.c
r1f1fa64 rf2f4c00 249 249 cdfs_node_t *node = hash_table_get_inst(item, cdfs_node_t, nh_link); 250 250 251 assert(node->type == CDFS_DIRECTORY);252 253 link_t *link;254 while ((link = list_first(&node->cs_list)) != NULL) {255 cdfs_dentry_t *dentry = list_get_instance(link, cdfs_dentry_t,link);256 list_remove(&dentry->link);257 free(dentry);251 if (node->type == CDFS_DIRECTORY) { 252 link_t *link; 253 while ((link = list_first(&node->cs_list)) != NULL) { 254 cdfs_dentry_t *dentry = list_get_instance(link, cdfs_dentry_t, link); 255 list_remove(&dentry->link); 256 free(dentry); 257 } 258 258 } 259 259 -
uspace/srv/net/ethip/ethip_nic.c
r1f1fa64 rf2f4c00 309 309 break; 310 310 default: 311 log_msg(LOG_DEFAULT, LVL_DEBUG, "unknown IPC method: %d", IPC_GET_IMETHOD(call));311 log_msg(LOG_DEFAULT, LVL_DEBUG, "unknown IPC method: %d", (int) IPC_GET_IMETHOD(call)); 312 312 async_answer_0(callid, ENOTSUP); 313 313 }
Note:
See TracChangeset
for help on using the changeset viewer.