Changeset 135486d in mainline for uspace/srv/bd


Ignore:
Timestamp:
2012-08-15T14:44:59Z (13 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
affaf2e, b546231
Parents:
4802dd7
Message:

Allow more than one client connection to block device.

Location:
uspace/srv/bd
Files:
9 edited

Legend:

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

    r4802dd7 r135486d  
    104104static void ata_bd_connection(ipc_callid_t iid, ipc_call_t *icall, void *);
    105105
    106 static int ata_bd_open(bd_srv_t *);
     106static int ata_bd_open(bd_srvs_t *, bd_srv_t *);
    107107static int ata_bd_close(bd_srv_t *);
    108108static int ata_bd_read_blocks(bd_srv_t *, uint64_t ba, size_t cnt, void *buf,
     
    146146static disk_t *bd_srv_disk(bd_srv_t *bd)
    147147{
    148         return (disk_t *)bd->arg;
     148        return (disk_t *)bd->srvs->sarg;
    149149}
    150150
     
    312312        }
    313313
    314         bd_conn(iid, icall, &ata_disk[disk_id].bd);
     314        bd_conn(iid, icall, &ata_disk[disk_id].bds);
    315315}
    316316
     
    336336        fibril_mutex_initialize(&d->lock);
    337337
    338         bd_srv_init(&d->bd);
    339         d->bd.ops = &ata_bd_ops;
    340         d->bd.arg = d;
     338        bd_srvs_init(&d->bds);
     339        d->bds.ops = &ata_bd_ops;
     340        d->bds.sarg = d;
    341341
    342342        /* Try identify command. */
     
    467467}
    468468
    469 static int ata_bd_open(bd_srv_t *bd)
     469static int ata_bd_open(bd_srvs_t *bds, bd_srv_t *bd)
    470470{
    471471        return EOK;
  • uspace/srv/bd/ata_bd/ata_bd.h

    r4802dd7 r135486d  
    119119        service_id_t service_id;
    120120        int disk_id;
    121         bd_srv_t bd;
     121        bd_srvs_t bds;
    122122} disk_t;
    123123
  • uspace/srv/bd/file_bd/file_bd.c

    r4802dd7 r135486d  
    6262
    6363static service_id_t service_id;
    64 static bd_srv_t bd_srv;
     64static bd_srvs_t bd_srvs;
    6565static fibril_mutex_t dev_lock;
    6666
     
    6969static void file_bd_connection(ipc_callid_t iid, ipc_call_t *icall, void *);
    7070
    71 static int file_bd_open(bd_srv_t *);
     71static int file_bd_open(bd_srvs_t *, bd_srv_t *);
    7272static int file_bd_close(bd_srv_t *);
    7373static int file_bd_read_blocks(bd_srv_t *, aoff64_t, size_t, void *, size_t);
     
    154154static int file_bd_init(const char *fname)
    155155{
    156         bd_srv_init(&bd_srv);
    157         bd_srv.ops = &file_bd_ops;
     156        bd_srvs_init(&bd_srvs);
     157        bd_srvs.ops = &file_bd_ops;
    158158       
    159159        async_set_client_connection(file_bd_connection);
     
    188188static void file_bd_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    189189{
    190         bd_conn(iid, icall, &bd_srv);
     190        bd_conn(iid, icall, &bd_srvs);
    191191}
    192192
    193193/** Open device. */
    194 static int file_bd_open(bd_srv_t *bd)
     194static int file_bd_open(bd_srvs_t *bds, bd_srv_t *bd)
    195195{
    196196        return EOK;
  • uspace/srv/bd/gxe_bd/gxe_bd.c

    r4802dd7 r135486d  
    8888/** GXE block device soft state */
    8989typedef struct {
    90         /** Block device server structure */
    91         bd_srv_t bd;
     90        /** Block device service structure */
     91        bd_srvs_t bds;
    9292        int disk_id;
    9393} gxe_bd_t;
     
    109109static int gxe_bd_write_block(int disk_id, uint64_t ba, const void *buf);
    110110
    111 static int gxe_bd_open(bd_srv_t *);
     111static int gxe_bd_open(bd_srvs_t *, bd_srv_t *);
    112112static int gxe_bd_close(bd_srv_t *);
    113113static int gxe_bd_read_blocks(bd_srv_t *, aoff64_t, size_t, void *, size_t);
     
    127127static gxe_bd_t *bd_srv_gxe(bd_srv_t *bd)
    128128{
    129         return (gxe_bd_t *)bd->arg;
     129        return (gxe_bd_t *)bd->srvs->sarg;
    130130}
    131131
     
    166166                char name[16];
    167167               
    168                 bd_srv_init(&gxe_bd[i].bd);
    169                 gxe_bd[i].bd.ops = &gxe_bd_ops;
    170                 gxe_bd[i].bd.arg = (void *)&gxe_bd[i];
     168                bd_srvs_init(&gxe_bd[i].bds);
     169                gxe_bd[i].bds.ops = &gxe_bd_ops;
     170                gxe_bd[i].bds.sarg = (void *)&gxe_bd[i];
    171171               
    172172                snprintf(name, 16, "%s/disk%u", NAMESPACE, i);
     
    203203        }
    204204
    205         bd_conn(iid, icall, &gxe_bd[disk_id].bd);
     205        bd_conn(iid, icall, &gxe_bd[disk_id].bds);
    206206}
    207207
    208208/** Open device. */
    209 static int gxe_bd_open(bd_srv_t *bd)
     209static int gxe_bd_open(bd_srvs_t *bds, bd_srv_t *bd)
    210210{
    211211        return EOK;
  • uspace/srv/bd/part/guid_part/guid_part.c

    r4802dd7 r135486d  
    8383        /** Service representing the partition (outbound device) */
    8484        service_id_t dsid;
    85         /** Block device server structure */
    86         bd_srv_t bd;
     85        /** Block device service structure */
     86        bd_srvs_t bds;
    8787        /** Points to next partition structure. */
    8888        struct part *next;
     
    104104static int gpt_bsa_translate(part_t *p, aoff64_t ba, size_t cnt, aoff64_t *gba);
    105105
    106 static int gpt_bd_open(bd_srv_t *);
     106static int gpt_bd_open(bd_srvs_t *, bd_srv_t *);
    107107static int gpt_bd_close(bd_srv_t *);
    108108static int gpt_bd_read_blocks(bd_srv_t *, aoff64_t, size_t, void *, size_t);
     
    122122static part_t *bd_srv_part(bd_srv_t *bd)
    123123{
    124         return (part_t *)bd->arg;
     124        return (part_t *)bd->srvs->sarg;
    125125}
    126126
     
    325325        }
    326326
    327         bd_srv_init(&part->bd);
    328         part->bd.ops = &gpt_bd_ops;
    329         part->bd.arg = part;
     327        bd_srvs_init(&part->bds);
     328        part->bds.ops = &gpt_bd_ops;
     329        part->bds.sarg = part;
    330330
    331331        part->dsid = 0;
     
    357357        assert(part->present == true);
    358358
    359         bd_conn(iid, icall, &part->bd);
     359        bd_conn(iid, icall, &part->bds);
    360360}
    361361
    362362/** Open device. */
    363 static int gpt_bd_open(bd_srv_t *bd)
     363static int gpt_bd_open(bd_srvs_t *bds, bd_srv_t *bd)
    364364{
    365365        return EOK;
  • uspace/srv/bd/part/mbr_part/mbr_part.c

    r4802dd7 r135486d  
    100100        /** Device representing the partition (outbound device) */
    101101        service_id_t dsid;
    102         /** Block device server structure */
    103         bd_srv_t bd;
     102        /** Block device service sturcture */
     103        bd_srvs_t bds;
    104104        /** Points to next partition structure. */
    105105        struct part *next;
     
    154154static int mbr_bsa_translate(part_t *p, uint64_t ba, size_t cnt, uint64_t *gba);
    155155
    156 static int mbr_bd_open(bd_srv_t *);
     156static int mbr_bd_open(bd_srvs_t *, bd_srv_t *);
    157157static int mbr_bd_close(bd_srv_t *);
    158158static int mbr_bd_read_blocks(bd_srv_t *, aoff64_t, size_t, void *, size_t);
     
    172172static part_t *bd_srv_part(bd_srv_t *bd)
    173173{
    174         return (part_t *)bd->arg;
     174        return (part_t *)bd->srvs->sarg;
    175175}
    176176
     
    402402        part->present = (pte->ptype != PT_UNUSED) ? true : false;
    403403
    404         bd_srv_init(&part->bd);
    405         part->bd.ops = &mbr_bd_ops;
    406         part->bd.arg = part;
     404        bd_srvs_init(&part->bds);
     405        part->bds.ops = &mbr_bd_ops;
     406        part->bds.sarg = part;
    407407
    408408        part->dsid = 0;
     
    433433
    434434        assert(part->present == true);
    435         bd_conn(iid, icall, &part->bd);
     435        bd_conn(iid, icall, &part->bds);
    436436}
    437437
    438438/** Open device. */
    439 static int mbr_bd_open(bd_srv_t *bd)
     439static int mbr_bd_open(bd_srvs_t *bds, bd_srv_t *bd)
    440440{
    441441        return EOK;
  • uspace/srv/bd/rd/rd.c

    r4802dd7 r135486d  
    6868static const size_t block_size = 512;
    6969
    70 static int rd_open(bd_srv_t *);
     70static int rd_open(bd_srvs_t *, bd_srv_t *);
    7171static int rd_close(bd_srv_t *);
    7272static int rd_read_blocks(bd_srv_t *, aoff64_t, size_t, void *, size_t);
     
    9393};
    9494
    95 static bd_srv_t bd_srv;
     95static bd_srvs_t bd_srvs;
    9696
    9797static void rd_client_conn(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    9898{
    99         bd_conn(iid, icall, &bd_srv);
     99        bd_conn(iid, icall, &bd_srvs);
    100100}
    101101
    102102/** Open device. */
    103 static int rd_open(bd_srv_t *bd)
     103static int rd_open(bd_srvs_t *bds, bd_srv_t *bd)
    104104{
    105105        return EOK;
     
    175175            (void *) addr_phys, size);
    176176       
    177         bd_srv_init(&bd_srv);
    178         bd_srv.ops = &rd_bd_ops;
     177        bd_srvs_init(&bd_srvs);
     178        bd_srvs.ops = &rd_bd_ops;
    179179       
    180180        async_set_client_connection(rd_client_conn);
  • uspace/srv/bd/sata_bd/sata_bd.c

    r4802dd7 r135486d  
    5757static int disk_count;
    5858
    59 static int sata_bd_open(bd_srv_t *);
     59static int sata_bd_open(bd_srvs_t *, bd_srv_t *);
    6060static int sata_bd_close(bd_srv_t *);
    6161static int sata_bd_read_blocks(bd_srv_t *, aoff64_t, size_t, void *, size_t);
     
    7575static sata_bd_dev_t *bd_srv_sata(bd_srv_t *bd)
    7676{
    77         return (sata_bd_dev_t *)bd->arg;
     77        return (sata_bd_dev_t *)bd->srvs->sarg;
    7878}
    7979
     
    104104                ahci_get_num_blocks(disk[disk_count].sess, &disk[disk_count].blocks);
    105105               
    106                 bd_srv_init(&disk[disk_count].bd);
    107                 disk[disk_count].bd.ops = &sata_bd_ops;
    108                 disk[disk_count].bd.arg = &disk[disk_count];
     106                bd_srvs_init(&disk[disk_count].bds);
     107                disk[disk_count].bds.ops = &sata_bd_ops;
     108                disk[disk_count].bds.sarg = &disk[disk_count];
    109109               
    110110                printf("Device %s - %s , blocks: %lu, block_size: %lu\n",
     
    183183        }
    184184
    185         bd_conn(iid, icall, &disk[disk_id].bd);
     185        bd_conn(iid, icall, &disk[disk_id].bds);
    186186}
    187187
    188188/** Open device. */
    189 static int sata_bd_open(bd_srv_t *bd)
     189static int sata_bd_open(bd_srvs_t *bds, bd_srv_t *bd)
    190190{
    191191        return EOK;
  • uspace/srv/bd/sata_bd/sata_bd.h

    r4802dd7 r135486d  
    5858        size_t block_size;
    5959        /** Block device server structure */
    60         bd_srv_t bd;
     60        bd_srvs_t bds;
    6161} sata_bd_dev_t;
    6262
Note: See TracChangeset for help on using the changeset viewer.