Ignore:
Timestamp:
2010-11-03T15:05:41Z (13 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d70a463
Parents:
af894a21
Message:

Old code removal

Completely removed old methods for communicating with HCD (the ones
that used callback phones). Now only methods using the async framework
are available.

File:
1 edited

Legend:

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

    raf894a21 r1d1f894  
    5252
    5353
     54static dev_handle_t handle_virtual_device;
     55static dev_handle_t handle_host_driver;
     56
    5457static void client_connection(ipc_callid_t iid, ipc_call_t *icall)
    5558{
    5659        ipcarg_t phone_hash = icall->in_phone_hash;
     60        dev_handle_t handle = (dev_handle_t)IPC_GET_ARG1(*icall);
    5761       
    58         ipc_answer_0(iid, EOK);
    59        
    60         while (true) {
    61                 ipc_callid_t callid;
    62                 ipc_call_t call;
    63                
    64                 callid = async_get_call(&call);
    65                
     62        if (handle == handle_host_driver) {
    6663                /*
    67                  * We can do nothing until we have the callback phone.
    68                  * Thus, we will wait for the callback and start processing
    69                  * after that.
     64                 * We can connect host controller driver immediately.
    7065                 */
    71                 int method = (int) IPC_GET_METHOD(call);
    72                
    73                 if (method == IPC_M_PHONE_HUNGUP) {
    74                         ipc_answer_0(callid, EOK);
    75                         return;
    76                 }
    77                
    78                 if (method == IPC_M_CONNECT_TO_ME) {
    79                         int kind = IPC_GET_ARG1(call);
    80                         int callback = IPC_GET_ARG5(call);
    81                        
     66                ipc_answer_0(iid, EOK);
     67                connection_handler_host(phone_hash);
     68        } else if (handle == handle_virtual_device) {
     69                ipc_answer_0(iid, EOK);
     70
     71                while (true) {
    8272                        /*
    83                          * Determine whether host connected to us
    84                          * or a device.
     73                         * We need to wait for callback request to allow
     74                         * connection of virtual device.
    8575                         */
    86                         if (kind == 0) {
     76                        ipc_callid_t callid;
     77                        ipc_call_t call;
     78
     79                        callid = async_get_call(&call);
     80
     81                        /*
     82                         * We can do nothing until we have the callback phone.
     83                         * Thus, we will wait for the callback and start processing
     84                         * after that.
     85                         */
     86                        int method = (int) IPC_GET_METHOD(call);
     87
     88                        if (method == IPC_M_PHONE_HUNGUP) {
    8789                                ipc_answer_0(callid, EOK);
    88                                 connection_handler_host(phone_hash, callback);
    8990                                return;
    90                         } else if (kind == 1) {
     91                        }
     92
     93                        if (method == IPC_M_CONNECT_TO_ME) {
     94                                int callback = IPC_GET_ARG5(call);
    9195                                virtdev_connection_t *dev
    9296                                    = virtdev_add_device(callback);
     
    100104                                virtdev_destroy_device(dev);
    101105                                return;
    102                         } else {
    103                                 ipc_answer_0(callid, EINVAL);
    104                                 ipc_hangup(callback);
    105                                 return;
    106106                        }
     107
     108                        /*
     109                         * No other methods could be served now.
     110                         */
     111                        dprintf_inval_call(1, call, phone_hash);
     112                        ipc_answer_0(callid, ENOTSUP);
    107113                }
    108                
     114        } else {
    109115                /*
    110                  * No other methods could be served now.
     116                 * Hmmm, someone else just tried to connect to us.
     117                 * Kick him out ;-).
    111118                 */
    112                 dprintf_inval_call(1, call, phone_hash);
    113                 ipc_answer_0(callid, ENOTSUP);
     119                ipc_answer_0(iid, ENOTSUP);
     120                return;
    114121        }
    115122}
     
    135142        }
    136143
    137         rc = devmap_device_register(DEVMAP_PATH, NULL);
     144        rc = devmap_device_register(DEVMAP_PATH_HC, &handle_host_driver);
    138145        if (rc != EOK) {
    139146                printf("%s: unable to register device %s (%s).\n",
    140                     NAME, DEVMAP_PATH, str_error(rc));
     147                    NAME, DEVMAP_PATH_HC, str_error(rc));
    141148                return 1;
    142149        }
    143150       
     151        rc = devmap_device_register(DEVMAP_PATH_DEV, &handle_virtual_device);
     152        if (rc != EOK) {
     153                printf("%s: unable to register device %s (%s).\n",
     154                    NAME, DEVMAP_PATH_DEV, str_error(rc));
     155                return 1;
     156        }
     157
    144158        hub_init();
    145159       
    146         printf("%s: accepting connections [devmap=%s, debug=%d].\n", NAME,
    147             DEVMAP_PATH, debug_level);
     160        printf("%s: accepting connections [debug=%d]\n", NAME, debug_level);
     161        printf("%s:  -> host controller at %s\n", NAME, DEVMAP_PATH_HC);
     162        printf("%s:  -> virtual hub at %s\n", NAME, DEVMAP_PATH_DEV);
     163
    148164        hc_manager();
    149165       
Note: See TracChangeset for help on using the changeset viewer.