Changeset 8ff0bd2 in mainline for uspace/srv/bd/ata_bd/ata_bd.c


Ignore:
Timestamp:
2011-09-04T11:30:58Z (13 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
03bc76a
Parents:
d2c67e7 (diff), deac215e (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge mainline changes

File:
1 edited

Legend:

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

    rd2c67e7 r8ff0bd2  
    5757#include <stdint.h>
    5858#include <str.h>
    59 #include <devmap.h>
     59#include <loc.h>
    6060#include <sys/types.h>
    6161#include <inttypes.h>
     
    8181static const size_t identify_data_size = 512;
    8282
    83 /** Size of the communication area. */
    84 static size_t comm_size;
    85 
    8683/** I/O base address of the command registers. */
    8784static uintptr_t cmd_physical;
     
    105102static void print_syntax(void);
    106103static int ata_bd_init(void);
    107 static void ata_bd_connection(ipc_callid_t iid, ipc_call_t *icall);
     104static void ata_bd_connection(ipc_callid_t iid, ipc_call_t *icall, void *);
    108105static int ata_bd_read_blocks(int disk_id, uint64_t ba, size_t cnt,
    109106    void *buf);
     
    122119static int ata_pcmd_read_12(int dev_idx, uint64_t ba, size_t cnt,
    123120    void *obuf, size_t obuf_size);
     121static int ata_pcmd_read_toc(int dev_idx, uint8_t ses,
     122    void *obuf, size_t obuf_size);
    124123static void disk_print_summary(disk_t *d);
    125124static int coord_calc(disk_t *d, uint64_t ba, block_coord_t *bc);
     
    179178               
    180179                snprintf(name, 16, "%s/ata%udisk%d", NAMESPACE, ctl_num, i);
    181                 rc = devmap_device_register(name, &disk[i].devmap_handle);
     180                rc = loc_service_register(name, &disk[i].service_id);
    182181                if (rc != EOK) {
    183182                        printf(NAME ": Unable to register device %s.\n", name);
     
    247246        int rc;
    248247
    249         rc = devmap_driver_register(NAME, ata_bd_connection);
     248        rc = loc_server_register(NAME, ata_bd_connection);
    250249        if (rc < 0) {
    251250                printf(NAME ": Unable to register driver.\n");
     
    274273
    275274/** Block device connection handler */
    276 static void ata_bd_connection(ipc_callid_t iid, ipc_call_t *icall)
     275static void ata_bd_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    277276{
    278277        void *fs_va = NULL;
     
    280279        ipc_call_t call;
    281280        sysarg_t method;
    282         devmap_handle_t dh;
     281        service_id_t dsid;
     282        size_t comm_size;       /**< Size of the communication area. */
    283283        unsigned int flags;
    284284        int retval;
     
    287287        int disk_id, i;
    288288
    289         /* Get the device handle. */
    290         dh = IPC_GET_ARG1(*icall);
     289        /* Get the device service ID. */
     290        dsid = IPC_GET_ARG1(*icall);
    291291
    292292        /* Determine which disk device is the client connecting to. */
    293293        disk_id = -1;
    294294        for (i = 0; i < MAX_DISKS; i++)
    295                 if (disk[i].devmap_handle == dh)
     295                if (disk[i].service_id == dsid)
    296296                        disk_id = i;
    297297
     
    355355                            UPPER32(disk[disk_id].blocks));
    356356                        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;
    357365                default:
    358366                        retval = EINVAL;
     
    812820}
    813821
     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
    814861/** Read a physical from the device.
    815862 *
Note: See TracChangeset for help on using the changeset viewer.