Changeset 1090b8c in mainline for uspace/srv/rd/rd.c


Ignore:
Timestamp:
2009-05-18T19:45:17Z (15 years ago)
Author:
Jiri Svoboda <jirik.svoboda@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c00589d
Parents:
c5747fe
Message:

C binding for devmap. Gets rid of duplicate code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/rd/rd.c

    rc5747fe r1090b8c  
    5353#include <futex.h>
    5454#include <stdio.h>
    55 #include <ipc/devmap.h>
     55#include <devmap.h>
    5656#include <ipc/bd.h>
    5757
     
    181181}
    182182
    183 static int driver_register(char *name)
    184 {
    185         ipcarg_t retval;
    186         aid_t req;
    187         ipc_call_t answer;
    188         int phone;
    189         ipcarg_t callback_phonehash;
    190 
    191         phone = ipc_connect_me_to_blocking(PHONE_NS, SERVICE_DEVMAP, DEVMAP_DRIVER, 0);
    192         if (phone < 0) {
    193                 printf(NAME ": Failed to connect to device mapper\n");
    194                 return -1;
    195         }
    196        
    197         req = async_send_2(phone, DEVMAP_DRIVER_REGISTER, 0, 0, &answer);
    198 
    199         retval = ipc_data_write_start(phone, (char *) name, str_size(name) + 1);
    200 
    201         if (retval != EOK) {
    202                 async_wait_for(req, NULL);
    203                 return -1;
    204         }
    205 
    206         async_set_client_connection(rd_connection);
    207 
    208         ipc_connect_to_me(phone, 0, 0, 0, &callback_phonehash);
    209         async_wait_for(req, &retval);
    210 
    211         return phone;
    212 }
    213 
    214 static int device_register(int driver_phone, char *name, int *handle)
    215 {
    216         ipcarg_t retval;
    217         aid_t req;
    218         ipc_call_t answer;
    219 
    220         req = async_send_2(driver_phone, DEVMAP_DEVICE_REGISTER, 0, 0, &answer);
    221 
    222         retval = ipc_data_write_start(driver_phone, (char *) name,
    223             str_size(name) + 1);
    224 
    225         if (retval != EOK) {
    226                 async_wait_for(req, NULL);
    227                 return retval;
    228         }
    229 
    230         async_wait_for(req, &retval);
    231 
    232         if (handle != NULL)
    233                 *handle = -1;
    234        
    235         if (EOK == retval) {
    236                 if (NULL != handle)
    237                         *handle = (int) IPC_GET_ARG1(answer);
    238         }
    239        
    240         return retval;
    241 }
    242 
    243183/** Prepare the ramdisk image for operation. */
    244184static bool rd_init(void)
     
    265205        printf(NAME ": Found RAM disk at %p, %d bytes\n", rd_ph_addr, rd_size);
    266206       
    267         int driver_phone = driver_register(NAME);
     207        int driver_phone = devmap_driver_register(NAME, rd_connection);
    268208        if (driver_phone < 0) {
    269209                printf(NAME ": Unable to register driver\n");
     
    272212       
    273213        int dev_handle;
    274         if (EOK != device_register(driver_phone, "initrd", &dev_handle)) {
     214        if (devmap_device_register(driver_phone, "initrd", &dev_handle) != EOK) {
    275215                ipc_hangup(driver_phone);
    276216                printf(NAME ": Unable to register device\n");
     
    284224         * be created dynamically...
    285225         */
    286         if (EOK != device_register(driver_phone, "spared", &dev_handle)) {
     226        if (devmap_device_register(driver_phone, "spared", &dev_handle) != EOK) {
    287227                ipc_hangup(driver_phone);
    288228                printf(NAME ": Unable to register device\n");
Note: See TracChangeset for help on using the changeset viewer.