Changeset e28d228 in mainline for uspace/drv


Ignore:
Timestamp:
2010-12-04T17:54:34Z (15 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
35537a7
Parents:
54b141a (diff), 9ca0013 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge with vojtechhorky/

Location:
uspace/drv
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbhub/utils.c

    r54b141a re28d228  
    186186                 */
    187187
     188                /*
     189                 * WARNING: sample code, will not work out of the box.
     190                 * And does not contain code for checking for errors.
     191                 */
     192#if 0
     193                /*
     194                 * Before opening the port, we must acquire the default
     195                 * address.
     196                 */
     197                usb_drv_reserve_default_address(hc);
     198
     199                usb_address_t new_device_address = usb_drv_request_address(hc);
     200
     201                // TODO: open the port
     202
     203                // TODO: send request for setting address to new_device_address
     204
     205                /*
     206                 * Once new address is set, we can release the default
     207                 * address.
     208                 */
     209                usb_drv_release_default_address(hc);
     210
     211                /*
     212                 * Obtain descriptors and create match ids for devman.
     213                 */
     214
     215                // TODO: get device descriptors
     216
     217                // TODO: create match ids
     218
     219                // TODO: add child device
     220
     221                // child_device_register sets the device handle
     222                // TODO: store it here
     223                devman_handle_t new_device_handle = 0;
     224
     225                /*
     226                 * Inform the HC that the new device has devman handle
     227                 * assigned.
     228                 */
     229                usb_drv_bind_address(hc, new_device_address, new_device_handle);
     230
     231                /*
     232                 * That's all.
     233                 */
     234#endif
     235
    188236
    189237                /*
  • uspace/drv/vhc/addrmgm.c

    r54b141a re28d228  
    4949typedef struct {
    5050        usb_address_t address;
     51        devman_handle_t devman_handle;
    5152        bool available;
    5253} address_info_t;
     
    6970                dev_address[i].address = i + 1;
    7071                dev_address[i].available = true;
     72                dev_address[i].devman_handle = 0;
    7173        }
    7274
     
    120122}
    121123
     124int bind_address(device_t *dev, usb_address_t address, devman_handle_t handle)
     125{
     126        if (address == DEFAULT_ADDRESS) {
     127                return EPERM;
     128        }
     129
     130        int rc = EPERM;
     131
     132        fibril_mutex_lock(&address_guard);
     133        usb_address_t i;
     134        for (i = 0; i < ADDRESS_COUNT; i++) {
     135                if (dev_address[i].address == address) {
     136                        if (dev_address[i].available) {
     137                                rc = ENOENT;
     138                                break;
     139                        }
     140
     141                        dev_address[i].devman_handle = handle;
     142                        rc = EOK;
     143                        break;
     144                }
     145        }
     146        fibril_mutex_unlock(&address_guard);
     147
     148        return rc;
     149}
     150
     151int tell_address(device_t *dev, devman_handle_t handle, usb_address_t *address)
     152{
     153        int rc = ENOENT;
     154
     155        fibril_mutex_lock(&address_guard);
     156        usb_address_t i;
     157        for (i = 0; i < ADDRESS_COUNT; i++) {
     158                if (dev_address[i].devman_handle == handle) {
     159                        *address = dev_address[i].address;
     160                        rc = EOK;
     161                        break;
     162                }
     163        }
     164        fibril_mutex_unlock(&address_guard);
     165
     166        return rc;
     167}
     168
    122169int release_address(device_t *dev, usb_address_t address)
    123170{
     
    138185
    139186                        dev_address[i].available = true;
     187                        dev_address[i].devman_handle = 0;
    140188                        rc = EOK;
    141189                        break;
  • uspace/drv/vhc/conn.h

    r54b141a re28d228  
    5252int request_address(device_t *, usb_address_t *);
    5353int release_address(device_t *, usb_address_t);
     54int bind_address(device_t *, usb_address_t, devman_handle_t);
    5455
     56int tell_address(device_t *, devman_handle_t, usb_address_t *);
    5557
    5658void default_connection_handler(device_t *, ipc_callid_t, ipc_call_t *);
  • uspace/drv/vhc/connhost.c

    r54b141a re28d228  
    148148
    149149
    150 static int get_address(device_t *dev, devman_handle_t handle,
    151     usb_address_t *address)
    152 {
    153         return ENOTSUP;
    154 }
    155 
    156150static int interrupt_out(device_t *dev, usb_target_t target,
    157151    void *data, size_t size,
     
    226220
    227221usbhc_iface_t vhc_iface = {
    228         .tell_address = get_address,
     222        .tell_address = tell_address,
    229223
    230224        .reserve_default_address = reserve_default_address,
    231225        .release_default_address = release_default_address,
    232226        .request_address = request_address,
     227        .bind_address = bind_address,
    233228        .release_address = release_address,
    234229
Note: See TracChangeset for help on using the changeset viewer.