Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/bd/part/mbr_part/mbr_part.c

    r47b7006 r30c78c0  
    6161#include <as.h>
    6262#include <fibril_synch.h>
    63 #include <devmap.h>
     63#include <loc.h>
    6464#include <sys/types.h>
    6565#include <sys/typefmt.h>
    6666#include <inttypes.h>
    6767#include <libblock.h>
    68 #include <devmap.h>
    6968#include <errno.h>
    7069#include <bool.h>
     
    10099        aoff64_t length;
    101100        /** Device representing the partition (outbound device) */
    102         devmap_handle_t dev;
     101        service_id_t dsid;
    103102        /** Points to next partition structure. */
    104103        struct part *next;
     
    141140
    142141/** Partitioned device (inbound device) */
    143 static devmap_handle_t indev_handle;
     142static service_id_t indef_sid;
    144143
    145144/** List of partitions. This structure is an empty head. */
     
    150149static part_t *mbr_part_new(void);
    151150static void mbr_pte_to_part(uint32_t base, const pt_entry_t *pte, part_t *part);
    152 static void mbr_connection(ipc_callid_t iid, ipc_call_t *icall);
     151static void mbr_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg);
    153152static int mbr_bd_read(part_t *p, uint64_t ba, size_t cnt, void *buf);
    154153static int mbr_bd_write(part_t *p, uint64_t ba, size_t cnt, const void *buf);
     
    180179        int i;
    181180        char *name;
    182         devmap_handle_t dev;
     181        service_id_t dsid;
    183182        uint64_t size_mb;
    184183        part_t *part;
    185184
    186         rc = devmap_device_get_handle(dev_name, &indev_handle, 0);
     185        rc = loc_service_get_id(dev_name, &indef_sid, 0);
    187186        if (rc != EOK) {
    188187                printf(NAME ": could not resolve device `%s'.\n", dev_name);
     
    190189        }
    191190
    192         rc = block_init(indev_handle, 2048);
     191        rc = block_init(EXCHANGE_SERIALIZE, indef_sid, 2048);
    193192        if (rc != EOK)  {
    194193                printf(NAME ": could not init libblock.\n");
     
    198197        /* Determine and verify block size. */
    199198
    200         rc = block_get_bsize(indev_handle, &block_size);
     199        rc = block_get_bsize(indef_sid, &block_size);
    201200        if (rc != EOK) {
    202201                printf(NAME ": error getting block size.\n");
     
    214213                return rc;
    215214
    216         /* Register the driver with device mapper. */
    217         rc = devmap_driver_register(NAME, mbr_connection);
     215        /* Register server with location service. */
     216        rc = loc_server_register(NAME, mbr_connection);
    218217        if (rc != EOK) {
    219                 printf(NAME ": Unable to register driver.\n");
     218                printf(NAME ": Unable to register server.\n");
    220219                return rc;
    221220        }
     
    239238                        return ENOMEM;
    240239
    241                 rc = devmap_device_register(name, &dev);
     240                rc = loc_service_register(name, &dsid);
    242241                if (rc != EOK) {
    243                         printf(NAME ": Unable to register device %s.\n", name);
     242                        printf(NAME ": Unable to register service %s.\n", name);
    244243                        return rc;
    245244                }
     
    250249                    "%" PRIu64 " MB.\n", name, part->length, size_mb);
    251250
    252                 part->dev = dev;
     251                part->dsid = dsid;
    253252                free(name);
    254253
     
    281280         */
    282281
    283         rc = block_read_direct(indev_handle, 0, 1, brb);
     282        rc = block_read_direct(indef_sid, 0, 1, brb);
    284283        if (rc != EOK) {
    285284                printf(NAME ": Failed reading MBR block.\n");
     
    332331                 */
    333332                ba = cp.start_addr;
    334                 rc = block_read_direct(indev_handle, ba, 1, brb);
     333                rc = block_read_direct(indef_sid, ba, 1, brb);
    335334                if (rc != EOK) {
    336335                        printf(NAME ": Failed reading EBR block at %"
     
    381380        part->present = (pte->ptype != PT_UNUSED) ? true : false;
    382381
    383         part->dev = 0;
     382        part->dsid = 0;
    384383        part->next = NULL;
    385384}
    386385
    387 static void mbr_connection(ipc_callid_t iid, ipc_call_t *icall)
     386static void mbr_connection(ipc_callid_t iid, ipc_call_t *icall, void *arg)
    388387{
    389388        size_t comm_size;
     
    392391        ipc_call_t call;
    393392        sysarg_t method;
    394         devmap_handle_t dh;
     393        service_id_t dh;
    395394        unsigned int flags;
    396395        int retval;
     
    408407         */
    409408        part = plist_head.next;
    410         while (part != NULL && part->dev != dh)
     409        while (part != NULL && part->dsid != dh)
    411410                part = part->next;
    412411
     
    437436                callid = async_get_call(&call);
    438437                method = IPC_GET_IMETHOD(call);
    439                 switch (method) {
    440                 case IPC_M_PHONE_HUNGUP:
     438               
     439                if (!method) {
    441440                        /* The other side has hung up. */
    442441                        async_answer_0(callid, EOK);
    443442                        return;
     443                }
     444               
     445                switch (method) {
    444446                case BD_READ_BLOCKS:
    445447                        ba = MERGE_LOUP32(IPC_GET_ARG1(call),
     
    485487                return ELIMIT;
    486488
    487         return block_read_direct(indev_handle, gba, cnt, buf);
     489        return block_read_direct(indef_sid, gba, cnt, buf);
    488490}
    489491
     
    496498                return ELIMIT;
    497499
    498         return block_write_direct(indev_handle, gba, cnt, buf);
     500        return block_write_direct(indef_sid, gba, cnt, buf);
    499501}
    500502
Note: See TracChangeset for help on using the changeset viewer.