Changeset ca07cd3 in mainline for uspace/srv


Ignore:
Timestamp:
2010-10-25T13:23:33Z (15 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
23cb44b
Parents:
355f7c2
Message:

Code cleanup, various bugfixes

The internal functions of virtual device framework always get
device structure as parameter, thus possible enabling more devices
within single task (that is not possible because currently there
is no way to pass extra argument into callback_connection()).

Also, added some missing comments and completely removed the device
id nonsense (devices can send their descriptors and the hub is able
to enable/disable its ports).

Location:
uspace/srv/hw/bus/usb/hcd/virtual
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hw/bus/usb/hcd/virtual/conndev.c

    r355f7c2 rca07cd3  
    4242#include "hub.h"
    4343
     44#define DEVICE_NAME_MAXLENGTH 32
     45
     46static int get_device_name(int phone, char *buffer, size_t len)
     47{
     48        ipc_call_t answer_data;
     49        ipcarg_t answer_rc;
     50        aid_t req;
     51        int rc;
     52       
     53        req = async_send_0(phone,
     54            IPC_M_USBVIRT_GET_NAME,
     55            &answer_data);
     56       
     57        rc = async_data_read_start(phone, buffer, len);
     58        if (rc != EOK) {
     59                async_wait_for(req, NULL);
     60                return EINVAL;
     61        }
     62       
     63        async_wait_for(req, &answer_rc);
     64        rc = (int)answer_rc;
     65       
     66        if (IPC_GET_ARG1(answer_data) < len) {
     67                len = IPC_GET_ARG1(answer_data);
     68        } else {
     69                len--;
     70        }
     71        buffer[len] = 0;
     72       
     73        return rc;
     74}
     75
    4476/** Connection handler for communcation with virtual device.
    4577 *
     
    5385        assert(dev != NULL);
    5486       
    55         dprintf(0, "virtual device connected through phone %#x", phone_hash);
     87        char devname[DEVICE_NAME_MAXLENGTH + 1];
     88        int rc = get_device_name(dev->phone, devname, DEVICE_NAME_MAXLENGTH);
     89       
     90        dprintf(0, "virtual device connected (phone: %#x, name: %s)",
     91            phone_hash, rc == EOK ? devname : "<unknown>");
     92       
    5693       
    5794        while (true) {
  • uspace/srv/hw/bus/usb/hcd/virtual/devices.c

    r355f7c2 rca07cd3  
    4343#include <str_error.h>
    4444
    45 #include <usbvirt/ids.h>
    4645#include <usbvirt/hub.h>
    4746
     
    5554
    5655LIST_INITIALIZE(devices);
    57 
    58 /** Recognise device by id.
    59  *
    60  * @param id Device id.
    61  * @param phone Callback phone.
    62  */
    63 virtdev_connection_t *virtdev_recognise(int id, int phone)
    64 {
    65         virtdev_connection_t * dev = virtdev_add_device(phone);
    66        
    67         /*
    68          * We do not want to mess-up the virtdev_add_device() as
    69          * the id is needed only before device probing/detection
    70          * is implemented.
    71          *
    72          * However, that does not mean that this will happen soon.
    73          */
    74         if (dev) {
    75                 dev->id = id;
    76         }
    77        
    78         return dev;
    79 }
    8056
    8157/** Create virtual device.
  • uspace/srv/hw/bus/usb/hcd/virtual/devices.h

    r355f7c2 rca07cd3  
    4545        /** Phone used when sending data to device. */
    4646        int phone;
    47         /** Device id. */
    48         int id;
    4947        /** Linked-list handle. */
    5048        link_t link;
    5149} virtdev_connection_t;
    5250
    53 virtdev_connection_t *virtdev_recognise(int, int);
    5451virtdev_connection_t *virtdev_add_device(int);
    5552void virtdev_destroy_device(virtdev_connection_t *);
  • uspace/srv/hw/bus/usb/hcd/virtual/hc.h

    r355f7c2 rca07cd3  
    3737
    3838#include <usb/hcd.h>
    39 #include <usbvirt/ids.h>
     39#include <usbvirt/hub.h>
    4040
    4141/** Callback after transaction is sent to USB.
  • uspace/srv/hw/bus/usb/hcd/virtual/hcd.c

    r355f7c2 rca07cd3  
    8989                                return;
    9090                        } else if (kind == 1) {
    91                                 int device_id = IPC_GET_ARG2(call);
    9291                                virtdev_connection_t *dev
    93                                     = virtdev_recognise(device_id, callback);
     92                                    = virtdev_add_device(callback);
    9493                                if (!dev) {
    9594                                        ipc_answer_0(callid, EEXISTS);
Note: See TracChangeset for help on using the changeset viewer.