Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 00b6c73 in mainline


Ignore:
Timestamp:
2011-05-13T20:02:13Z (11 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master
Children:
e913cc9
Parents:
d29f32f
Message:

Virtual HC prints name of connected device

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/vhc/conndev.c

    rd29f32f r00b6c73  
    3737#include <errno.h>
    3838#include <ddf/driver.h>
     39#include <usbvirt/ipc.h>
    3940#include "conn.h"
    4041
    4142static fibril_local uintptr_t plugged_device_handle = 0;
     43#define PLUGGED_DEVICE_NAME_MAXLEN 256
     44static fibril_local char plugged_device_name[PLUGGED_DEVICE_NAME_MAXLEN + 1] = "<unknown>";
     45
     46/** Receive device name.
     47 *
     48 * @warning Errors are silently ignored.
     49 *
     50 * @param phone Phone to the virtual device.
     51 */
     52static void receive_device_name(int phone)
     53{
     54        aid_t opening_request = async_send_0(phone, IPC_M_USBVIRT_GET_NAME, NULL);
     55        if (opening_request == 0) {
     56                return;
     57        }
     58
     59
     60        ipc_call_t data_request_call;
     61        aid_t data_request = async_data_read(phone,
     62             plugged_device_name, PLUGGED_DEVICE_NAME_MAXLEN,
     63             &data_request_call);
     64
     65        if (data_request == 0) {
     66                async_wait_for(opening_request, NULL);
     67                return;
     68        }
     69
     70        sysarg_t data_request_rc;
     71        sysarg_t opening_request_rc;
     72        async_wait_for(data_request, &data_request_rc);
     73        async_wait_for(opening_request, &opening_request_rc);
     74
     75        if ((data_request_rc != EOK) || (opening_request_rc != EOK)) {
     76                return;
     77        }
     78
     79        size_t len = IPC_GET_ARG2(data_request_call);
     80        plugged_device_name[len] = 0;
     81}
    4282
    4383/** Default handler for IPC methods not handled by DDF.
     
    65105                async_answer_0(icallid, EOK);
    66106
    67                 usb_log_info("New virtual device `%s' (id = %" PRIxn ").\n",
    68                     rc == EOK ? "XXX" : "<unknown>", plugged_device_handle);
     107                receive_device_name(callback);
     108
     109                usb_log_info("New virtual device `%s' (id: %" PRIxn ").\n",
     110                    plugged_device_name, plugged_device_handle);
    69111
    70112                return;
     
    85127
    86128        if (plugged_device_handle != 0) {
    87                 usb_log_info("Virtual device disconnected (id = %" PRIxn ").\n",
    88                     plugged_device_handle);
     129                usb_log_info("Virtual device `%s' disconnected (id: %" PRIxn ").\n",
     130                    plugged_device_name, plugged_device_handle);
    89131                vhc_virtdev_unplug(vhc, plugged_device_handle);
    90132        }
Note: See TracChangeset for help on using the changeset viewer.