Changeset 54b141a in mainline for uspace/lib


Ignore:
Timestamp:
2010-12-04T17:01:24Z (15 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e28d228
Parents:
2cb6571 (diff), ad104e0 (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/lib
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/generic/remote_usbhc.c

    r2cb6571 r54b141a  
    5252static void remote_usbhc_control_read_data(device_t *, void *, ipc_callid_t, ipc_call_t *);
    5353static void remote_usbhc_control_read_status(device_t *, void *, ipc_callid_t, ipc_call_t *);
     54static void remote_usbhc_reserve_default_address(device_t *, void *, ipc_callid_t, ipc_call_t *);
     55static void remote_usbhc_release_default_address(device_t *, void *, ipc_callid_t, ipc_call_t *);
     56static void remote_usbhc_request_address(device_t *, void *, ipc_callid_t, ipc_call_t *);
     57static void remote_usbhc_release_address(device_t *, void *, ipc_callid_t, ipc_call_t *);
    5458//static void remote_usbhc(device_t *, void *, ipc_callid_t, ipc_call_t *);
    5559
     
    5761static remote_iface_func_ptr_t remote_usbhc_iface_ops [] = {
    5862        remote_usbhc_get_address,
     63
    5964        remote_usbhc_get_buffer,
     65
     66        remote_usbhc_reserve_default_address,
     67        remote_usbhc_release_default_address,
     68
     69        remote_usbhc_request_address,
     70        remote_usbhc_release_address,
     71
    6072        remote_usbhc_interrupt_out,
    6173        remote_usbhc_interrupt_in,
     74
    6275        remote_usbhc_control_write_setup,
    6376        remote_usbhc_control_write_data,
    6477        remote_usbhc_control_write_status,
     78
    6579        remote_usbhc_control_read_setup,
    6680        remote_usbhc_control_read_data,
     
    134148        free(trans->buffer);
    135149        free(trans);
     150}
     151
     152void remote_usbhc_reserve_default_address(device_t *device, void *iface,
     153    ipc_callid_t callid, ipc_call_t *call)
     154{
     155        usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;
     156
     157        if (!usb_iface->reserve_default_address) {
     158                ipc_answer_0(callid, ENOTSUP);
     159                return;
     160        }
     161
     162        int rc = usb_iface->reserve_default_address(device);
     163
     164        ipc_answer_0(callid, rc);
     165}
     166
     167void remote_usbhc_release_default_address(device_t *device, void *iface,
     168    ipc_callid_t callid, ipc_call_t *call)
     169{
     170        usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;
     171
     172        if (!usb_iface->release_default_address) {
     173                ipc_answer_0(callid, ENOTSUP);
     174                return;
     175        }
     176
     177        int rc = usb_iface->release_default_address(device);
     178
     179        ipc_answer_0(callid, rc);
     180}
     181
     182void remote_usbhc_request_address(device_t *device, void *iface,
     183    ipc_callid_t callid, ipc_call_t *call)
     184{
     185        usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;
     186
     187        if (!usb_iface->request_address) {
     188                ipc_answer_0(callid, ENOTSUP);
     189                return;
     190        }
     191
     192        usb_address_t address;
     193        int rc = usb_iface->request_address(device, &address);
     194        if (rc != EOK) {
     195                ipc_answer_0(callid, rc);
     196        } else {
     197                ipc_answer_1(callid, EOK, (ipcarg_t) address);
     198        }
     199}
     200
     201void remote_usbhc_release_address(device_t *device, void *iface,
     202    ipc_callid_t callid, ipc_call_t *call)
     203{
     204        usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;
     205
     206        if (!usb_iface->release_address) {
     207                ipc_answer_0(callid, ENOTSUP);
     208                return;
     209        }
     210
     211        usb_address_t address = (usb_address_t) IPC_GET_ARG1(*call);
     212
     213        int rc = usb_iface->release_address(device, address);
     214
     215        ipc_answer_0(callid, rc);
    136216}
    137217
  • uspace/lib/drv/include/usbhc_iface.h

    r2cb6571 r54b141a  
    111111
    112112
     113        /** Reserve usage of default address.
     114         * This call informs the host controller that the caller will be
     115         * using default USB address. It is duty of the HC driver to ensure
     116         * that only single entity will have it reserved.
     117         * The address is returned via IPC_M_USBHC_RELEASE_DEFAULT_ADDRESS.
     118         * The caller can start using the address after receiving EOK
     119         * answer.
     120         */
     121        IPC_M_USBHC_RESERVE_DEFAULT_ADDRESS,
     122
     123        /** Release usage of default address.
     124         * @see IPC_M_USBHC_RESERVE_DEFAULT_ADDRESS
     125         */
     126        IPC_M_USBHC_RELEASE_DEFAULT_ADDRESS,
     127
     128        /** Asks for address assignment by host controller.
     129         * Answer:
     130         * - ELIMIT - host controller run out of address
     131         * - EOK - address assigned
     132         * Answer arguments:
     133         * - assigned address
     134         *
     135         * The address must be released by via IPC_M_USBHC_RELEASE_ADDRESS.
     136         */
     137        IPC_M_USBHC_REQUEST_ADDRESS,
     138
     139        /** Release address in use.
     140         * Arguments:
     141         * - address to be released
     142         * Answer:
     143         * - ENOENT - address not in use
     144         * - EPERM - trying to release default USB address
     145         */
     146        IPC_M_USBHC_RELEASE_ADDRESS,
     147
     148
    113149        /** Send interrupt data to device.
    114150         * See explanation at usb_iface_funcs_t (OUT transaction).
     
    183219typedef struct {
    184220        int (*tell_address)(device_t *, devman_handle_t, usb_address_t *);
     221
     222        int (*reserve_default_address)(device_t *);
     223        int (*release_default_address)(device_t *);
     224        int (*request_address)(device_t *, usb_address_t *);
     225        int (*release_address)(device_t *, usb_address_t);
    185226
    186227        usbhc_iface_transfer_out_t interrupt_out;
  • uspace/lib/usb/Makefile

    r2cb6571 r54b141a  
    3535        src/hcdhubd.c \
    3636        src/hcdrv.c \
    37         src/hubdrv.c \
    3837        src/localdrv.c \
    3938        src/remotedrv.c \
  • uspace/lib/usb/include/usb/hcdhubd.h

    r2cb6571 r54b141a  
    166166
    167167int usb_hcd_main(usb_hc_driver_t *);
    168 int usb_hcd_add_root_hub(usb_hc_device_t *dev);
     168int usb_hcd_add_root_hub(device_t *dev);
    169169
    170170/**
  • uspace/lib/usb/include/usb/usbdrv.h

    r2cb6571 r54b141a  
    4141int usb_drv_hc_connect(device_t *, unsigned int);
    4242
     43int usb_drv_reserve_default_address(int);
     44int usb_drv_release_default_address(int);
     45usb_address_t usb_drv_request_address(int);
     46int usb_drv_release_address(int, usb_address_t);
     47
    4348usb_address_t usb_drv_get_my_address(int, device_t *);
    4449
  • uspace/lib/usb/src/hcdhubd.c

    r2cb6571 r54b141a  
    5151 */
    5252static int add_device(device_t *dev) {
    53         bool is_hc = str_cmp(dev->name, USB_HUB_DEVICE_NAME) != 0;
    54         printf("%s: add_device(name=\"%s\")\n", hc_driver->name, dev->name);
    55 
    56         if (is_hc) {
    57                 /*
    58                  * We are the HC itself.
    59                  */
    60                 return usb_add_hc_device(dev);
    61         } else {
    62                 /*
    63                  * We are some (maybe deeply nested) hub.
    64                  * Thus, assign our own operations and explore already
    65                  * connected devices.
    66                  */
    67                 return usb_add_hub_device(dev);
    68         }
     53        return ENOTSUP;
    6954}
    7055
     
    10590 * @return Error code.
    10691 */
    107 int usb_hcd_add_root_hub(usb_hc_device_t *dev) {
     92int usb_hcd_add_root_hub(device_t *dev)
     93{
    10894        char *id;
    109         int rc = asprintf(&id, "usb&hc=%s&hub", hc_driver->name);
     95        int rc = asprintf(&id, "usb&hub");
    11096        if (rc <= 0) {
    11197                return rc;
    11298        }
    11399
    114         rc = usb_hc_add_child_device(dev->generic, USB_HUB_DEVICE_NAME, id, true);
     100        rc = usb_hc_add_child_device(dev, USB_HUB_DEVICE_NAME, id, true);
    115101        if (rc != EOK) {
    116102                free(id);
  • uspace/lib/usb/src/hcdhubd_private.h

    r2cb6571 r54b141a  
    4646usb_address_t usb_get_address_by_handle(devman_handle_t);
    4747int usb_add_hc_device(device_t *);
    48 int usb_add_hub_device(device_t *);
    4948
    5049/** lowest allowed usb address */
  • uspace/lib/usb/src/hcdrv.c

    r2cb6571 r54b141a  
    4747LIST_INITIALIZE(hc_list);
    4848
     49/* Fake driver to have the name item initialized. */
     50static usb_hc_driver_t hc_driver_fake = {
     51        .name = "HCD",
     52};
     53
    4954/** Our HC driver. */
    50 usb_hc_driver_t *hc_driver = NULL;
     55usb_hc_driver_t *hc_driver = &hc_driver_fake;
    5156
    5257int usb_lowest_address = 1;
     
    8691int usb_add_hc_device(device_t *dev)
    8792{
     93        return ENOTSUP;
    8894        usb_hc_device_t *hc_dev = usb_hc_device_create(dev);
    8995
  • uspace/lib/usb/src/usbdrv.c

    r2cb6571 r54b141a  
    100100}
    101101
     102/** Tell HC to reserve default address.
     103 *
     104 * @param phone Open phone to host controller driver.
     105 * @return Error code.
     106 */
     107int usb_drv_reserve_default_address(int phone)
     108{
     109        return async_req_0_0(phone, IPC_M_USBHC_RESERVE_DEFAULT_ADDRESS);
     110}
     111
     112/** Tell HC to release default address.
     113 *
     114 * @param phone Open phone to host controller driver.
     115 * @return Error code.
     116 */
     117int usb_drv_release_default_address(int phone)
     118{
     119        return async_req_0_0(phone, IPC_M_USBHC_RELEASE_DEFAULT_ADDRESS);
     120}
     121
     122/** Ask HC for free address assignment.
     123 *
     124 * @param phone Open phone to host controller driver.
     125 * @return Assigned USB address or negative error code.
     126 */
     127usb_address_t usb_drv_request_address(int phone)
     128{
     129        ipcarg_t address;
     130        int rc = async_req_0_1(phone, IPC_M_USBHC_REQUEST_ADDRESS, &address);
     131        if (rc != EOK) {
     132                return rc;
     133        } else {
     134                return (usb_address_t) address;
     135        }
     136}
     137
     138/** Inform HC about address release.
     139 *
     140 * @param phone Open phone to host controller driver.
     141 * @param address Address to be released.
     142 * @return Error code.
     143 */
     144int usb_drv_release_address(int phone, usb_address_t address)
     145{
     146        return async_req_1_0(phone, IPC_M_USBHC_RELEASE_ADDRESS, address);
     147}
     148
    102149/** Send data to HCD.
    103150 *
Note: See TracChangeset for help on using the changeset viewer.