Changeset 3abf70c7 in mainline


Ignore:
Timestamp:
2014-08-16T22:33:41Z (10 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
da79df42
Parents:
35b8bfe
Message:

libblock is not the best place to define SCSI structures.

Location:
uspace
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/blkdump/Makefile

    r35b8bfe r3abf70c7  
    3030USPACE_PREFIX = ../..
    3131LIBS = $(LIBBLOCK_PREFIX)/libblock.a
    32 EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX)
     32EXTRA_CFLAGS = -I$(LIBBLOCK_PREFIX) -I$(LIBSCSI_PREFIX)/include
    3333BINARY = blkdump
    3434
  • uspace/app/blkdump/blkdump.c

    r35b8bfe r3abf70c7  
    4444#include <loc.h>
    4545#include <byteorder.h>
     46#include <scsi/mmc.h>
    4647#include <sys/types.h>
    4748#include <sys/typefmt.h>
     
    214215static int print_toc(void)
    215216{
    216         toc_block_t *toc;
    217 
    218         toc = block_get_toc(service_id, 0);
    219         if (toc == NULL)
     217        scsi_toc_multisess_data_t toc;
     218        int rc;
     219
     220        rc = block_read_toc(service_id, 0, &toc, sizeof(toc));
     221        if (rc != EOK)
    220222                return 1;
    221223
    222         printf("TOC size: %" PRIu16 " bytes\n", toc->size);
    223         printf("First session: %" PRIu8 "\n", toc->first_session);
    224         printf("Last_session: %" PRIu8 "\n", toc->last_session);
     224        printf("TOC size: %" PRIu16 " bytes\n", toc.toc_len);
     225        printf("First session: %" PRIu8 "\n", toc.first_sess);
     226        printf("Last_session: %" PRIu8 "\n", toc.last_sess);
    225227
    226228        return 0;
  • uspace/lib/block/block.c

    r35b8bfe r3abf70c7  
    877877 *
    878878 * @return Allocated TOC structure.
    879  * @return NULL on failure.
    880  *
    881  */
    882 toc_block_t *block_get_toc(service_id_t service_id, uint8_t session)
     879 * @return EOK on success or negative error code.
     880 *
     881 */
     882int block_read_toc(service_id_t service_id, uint8_t session, void *buf,
     883    size_t bufsize)
    883884{
    884885        devcon_t *devcon = devcon_search(service_id);
    885         toc_block_t *toc = NULL;
    886         int rc;
    887        
    888         assert(devcon);
    889        
    890         toc = (toc_block_t *) malloc(sizeof(toc_block_t));
    891         if (toc == NULL)
    892                 return NULL;
    893        
    894         rc = bd_read_toc(devcon->bd, session, toc, sizeof(toc_block_t));
    895         if (rc != EOK) {
    896                 free(toc);
    897                 return NULL;
    898         }
    899        
    900         return toc;
     886       
     887        assert(devcon);
     888        return bd_read_toc(devcon->bd, session, buf, bufsize);
    901889}
    902890
  • uspace/lib/block/block.h

    r35b8bfe r3abf70c7  
    9999};
    100100
    101 typedef struct {
    102         uint16_t size;
    103         uint8_t first_session;
    104         uint8_t last_session;
    105        
    106         uint8_t res0;
    107         uint8_t adr_ctrl;
    108         uint8_t first_track;
    109         uint8_t res1;
    110        
    111         uint32_t first_lba;
    112 } __attribute__((packed)) toc_block_t;
    113 
    114101extern int block_init(exch_mgmt_t, service_id_t, size_t);
    115102extern void block_fini(service_id_t);
     
    129116extern int block_get_bsize(service_id_t, size_t *);
    130117extern int block_get_nblocks(service_id_t, aoff64_t *);
    131 extern toc_block_t *block_get_toc(service_id_t, uint8_t);
     118extern int block_read_toc(service_id_t, uint8_t, void *, size_t);
    132119extern int block_read_direct(service_id_t, aoff64_t, size_t, void *);
    133120extern int block_read_bytes_direct(service_id_t, aoff64_t, size_t, void *);
  • uspace/lib/scsi/include/scsi/mmc.h

    r35b8bfe r3abf70c7  
    6969} __attribute__((packed)) scsi_cdb_read_toc_t;
    7070
     71/** TOC Track Descriptor */
     72typedef struct {
     73        /** Reserved */
     74        uint8_t reserved0;
     75        /** ADR, Control */
     76        uint8_t adr_control;
     77        /** Track Number */
     78        uint8_t track_no;
     79        /** Reserved */
     80        uint8_t reserved3;
     81        /** Track Start Address */
     82        uint32_t start_addr;
     83} __attribute__((packed)) scsi_toc_track_desc_t;
     84
     85/** Read TOC response format 00001b: Multi-session Information
     86 *
     87 * Returned for Read TOC command with Format 0001b
     88 */
     89typedef struct {
     90        /** TOC Data Length */
     91        uint16_t toc_len;
     92        /** First Complete Session Number */
     93        uint8_t first_sess;
     94        /** Last Complete Session Number */
     95        uint8_t last_sess;
     96        /** TOC Track Descriptor for first track in last complete session */
     97        scsi_toc_track_desc_t ftrack_lsess;
     98} __attribute__((packed)) scsi_toc_multisess_data_t;
     99
    71100#endif
    72101
  • uspace/srv/fs/cdfs/Makefile

    r35b8bfe r3abf70c7  
    2929USPACE_PREFIX = ../../..
    3030LIBS = $(LIBBLOCK_PREFIX)/libblock.a $(LIBFS_PREFIX)/libfs.a
    31 EXTRA_CFLAGS += -I$(LIBBLOCK_PREFIX) -I$(LIBFS_PREFIX)
     31EXTRA_CFLAGS += -I$(LIBBLOCK_PREFIX) -I$(LIBFS_PREFIX) \
     32    -I$(LIBSCSI_PREFIX)/include
    3233BINARY = cdfs
    3334
  • uspace/srv/fs/cdfs/cdfs_ops.c

    r35b8bfe r3abf70c7  
    4848#include <errno.h>
    4949#include <block.h>
     50#include <scsi/mmc.h>
    5051#include <str.h>
    5152#include <byteorder.h>
     
    10351036                        altroot = 0;
    10361037        } else {
    1037                 /* Read TOC and find the last session */
    1038                 toc_block_t *toc = block_get_toc(service_id, 1);
    1039                 if ((toc != NULL) && (uint16_t_be2host(toc->size) == 10)) {
    1040                         altroot = uint32_t_be2host(toc->first_lba);
    1041                         free(toc);
    1042                 }
     1038                /*
     1039                 * Read TOC multisession information and get the start address
     1040                 * of the first track in the last session
     1041                 */
     1042                scsi_toc_multisess_data_t toc;
     1043
     1044                rc = block_read_toc(service_id, 1, &toc, sizeof(toc));
     1045                if (rc == EOK && (uint16_t_be2host(toc.toc_len) == 10))
     1046                        altroot = uint32_t_be2host(toc.ftrack_lsess.start_addr);
    10431047        }
    10441048       
Note: See TracChangeset for help on using the changeset viewer.