Changeset 4046b2f4 in mainline for uspace/srv


Ignore:
Timestamp:
2011-08-30T17:35:04Z (14 years ago)
Author:
Martin Decky <martin@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7a72ce1a
Parents:
c3d19ac
Message:

TOC reading support
cherrypicked from lp:~jkavalik/cdfs/main

Location:
uspace/srv/bd/ata_bd
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/bd/ata_bd/ata_bd.c

    rc3d19ac r4046b2f4  
    118118static int ata_pcmd_inquiry(int dev_idx, void *obuf, size_t obuf_size);
    119119static int ata_pcmd_read_12(int dev_idx, uint64_t ba, size_t cnt,
     120    void *obuf, size_t obuf_size);
     121static int ata_pcmd_read_toc(int dev_idx, uint8_t ses,
    120122    void *obuf, size_t obuf_size);
    121123static void disk_print_summary(disk_t *d);
     
    353355                            UPPER32(disk[disk_id].blocks));
    354356                        continue;
     357                case BD_READ_TOC:
     358                        cnt = IPC_GET_ARG1(call);
     359                        if (disk[disk_id].dev_type == ata_pkt_dev)
     360                                retval = ata_pcmd_read_toc(disk_id, cnt, fs_va,
     361                                    disk[disk_id].block_size);
     362                        else
     363                                retval = EINVAL;
     364                        break;
    355365                default:
    356366                        retval = EINVAL;
     
    810820}
    811821
     822/** Issue ATAPI read TOC command.
     823 *
     824 * Read TOC in 'multi-session' format (first and last session number
     825 * with last session LBA).
     826 *
     827 * http://suif.stanford.edu/~csapuntz/specs/INF-8020.PDF page 171
     828 *
     829 * Output buffer must be large enough to hold the data, otherwise the
     830 * function will fail.
     831 *
     832 * @param dev_idx       Device index (0 or 1)
     833 * @param session       Starting session
     834 * @param obuf          Buffer for storing inquiry data read from device
     835 * @param obuf_size     Size of obuf in bytes
     836 *
     837 * @return EOK on success, EIO on error.
     838 */
     839static int ata_pcmd_read_toc(int dev_idx, uint8_t session, void *obuf,
     840    size_t obuf_size)
     841{
     842        ata_pcmd_read_toc_t cp;
     843        int rc;
     844
     845        memset(&cp, 0, sizeof(cp));
     846
     847        cp.opcode = PCMD_READ_TOC;
     848        cp.msf = 0;
     849        cp.format = 0x01; /* 0x01 = multi-session mode */
     850        cp.start = session;
     851        cp.size = host2uint16_t_be(obuf_size);
     852        cp.oldformat = 0x40; /* 0x01 = multi-session mode (shifted to MSB) */
     853       
     854        rc = ata_cmd_packet(0, &cp, sizeof(cp), obuf, obuf_size);
     855        if (rc != EOK)
     856                return rc;
     857       
     858        return EOK;
     859}
     860
    812861/** Read a physical from the device.
    813862 *
  • uspace/srv/bd/ata_bd/ata_hw.h

    rc3d19ac r4046b2f4  
    244244enum ata_pkt_command {
    245245        PCMD_INQUIRY            = 0x12,
    246         PCMD_READ_12            = 0xa8
     246        PCMD_READ_12            = 0xa8,
     247        PCMD_READ_TOC           = 0x43
    247248};
    248249
     
    269270        uint8_t _res2;
    270271} __attribute__ ((packed)) ata_pcmd_read_12_t;
     272
     273/** ATAPI Read TOC command */
     274typedef struct {
     275        uint8_t opcode;         /**< Operation code (PCMD_READ_TOC) */
     276        uint8_t msf;            /**< 0x2 = MSF bit set */
     277        uint8_t format;         /**< low 3 bits */
     278        uint8_t _res0;
     279        uint8_t _res1;
     280        uint8_t _res2;
     281        uint8_t start;          /**< starting track/session number */
     282        uint16_t size;          /**< Allocation length */
     283        uint8_t oldformat;         /**< high 2 bits */
     284        uint8_t _res3;
     285        uint8_t _res4;
     286} __attribute__ ((packed)) ata_pcmd_read_toc_t;
    271287
    272288/** Data returned from Inquiry command (mandatory part) */
Note: See TracChangeset for help on using the changeset viewer.