Changeset e5556e4a in mainline


Ignore:
Timestamp:
2013-09-11T09:46:38Z (11 years ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
7969087
Parents:
4c6ade6
Message:

Reverse order of drivers in driver list. Print driver state.

Location:
uspace
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/devctl/devctl.c

    r4c6ade6 re5556e4a  
    162162{
    163163        devman_handle_t *drvs;
     164        driver_state_t state;
     165        const char *sstate;
    164166        size_t ndrvs;
    165167        size_t i;
     
    170172                return rc;
    171173
    172         printf("Got %d handles\n", ndrvs);
    173174        for (i = 0; i < ndrvs; i++) {
    174175                rc = devman_driver_get_name(drvs[i], drv_name, MAX_NAME_LENGTH);
    175176                if (rc != EOK)
    176177                        continue;
    177                 printf("%3d %s\n", (int)drvs[i], drv_name);
     178                rc = devman_driver_get_state(drvs[i], &state);
     179                if (rc != EOK)
     180                        continue;
     181                switch (state) {
     182                case DRIVER_NOT_STARTED:
     183                        sstate = "not started";
     184                        break;
     185                case DRIVER_STARTING:
     186                        sstate = "starting";
     187                        break;
     188                case DRIVER_RUNNING:
     189                        sstate = "running";
     190                        break;
     191                default:
     192                        sstate = "unknown";
     193                }
     194                printf("%3d %-10s %s\n", (int)drvs[i], drv_name, sstate);
    178195        }
    179196        free(drvs);
  • uspace/lib/c/generic/devman.c

    r4c6ade6 re5556e4a  
    604604}
    605605
     606int devman_driver_get_state(devman_handle_t drvh, driver_state_t *rstate)
     607{
     608        sysarg_t state;
     609        async_exch_t *exch = devman_exchange_begin(DEVMAN_CLIENT);
     610        if (exch == NULL)
     611                return ENOMEM;
     612       
     613        int rc = async_req_1_1(exch, DEVMAN_DRIVER_GET_STATE, drvh,
     614            &state);
     615       
     616        devman_exchange_end(exch);
     617        if (rc != EOK)
     618                return rc;
     619
     620        *rstate = state;
     621        return rc;
     622}
     623
    606624/** @}
    607625 */
  • uspace/lib/c/include/devman.h

    r4c6ade6 re5556e4a  
    7373extern int devman_get_drivers(devman_handle_t **, size_t *);
    7474extern int devman_driver_get_name(devman_handle_t, char *, size_t);
     75extern int devman_driver_get_state(devman_handle_t, driver_state_t *);
    7576
    7677#endif
  • uspace/lib/c/include/ipc/devman.h

    r4c6ade6 re5556e4a  
    4242
    4343typedef sysarg_t devman_handle_t;
     44
     45typedef enum {
     46        /** Driver has not been started. */
     47        DRIVER_NOT_STARTED = 0,
     48       
     49        /**
     50         * Driver has been started, but has not registered as running and ready
     51         * to receive requests.
     52         */
     53        DRIVER_STARTING,
     54       
     55        /** Driver is running and prepared to serve incomming requests. */
     56        DRIVER_RUNNING
     57} driver_state_t;
    4458
    4559typedef enum {
     
    163177        DEVMAN_FUN_SID_TO_HANDLE,
    164178        DEVMAN_GET_DRIVERS,
    165         DEVMAN_DRIVER_GET_NAME
     179        DEVMAN_DRIVER_GET_NAME,
     180        DEVMAN_DRIVER_GET_STATE
    166181} client_to_devman_t;
    167182
  • uspace/srv/devman/client_conn.c

    r4c6ade6 re5556e4a  
    490490}
    491491
     492/** Get driver state. */
     493static void devman_driver_get_state(ipc_callid_t iid, ipc_call_t *icall)
     494{
     495        driver_t *drv;
     496       
     497        drv = driver_find(&drivers_list, IPC_GET_ARG1(*icall));
     498        if (drv == NULL) {
     499                async_answer_0(iid, ENOENT);
     500                return;
     501        }
     502       
     503        async_answer_1(iid, EOK, (sysarg_t) drv->state);
     504}
     505
    492506/** Function for handling connections from a client to the device manager. */
    493507void devman_connection_client(ipc_callid_t iid, ipc_call_t *icall)
     
    537551                        devman_driver_get_name(callid, &call);
    538552                        break;
     553                case DEVMAN_DRIVER_GET_STATE:
     554                        devman_driver_get_state(callid, &call);
     555                        break;
    539556                default:
    540557                        async_answer_0(callid, ENOENT);
  • uspace/srv/devman/devman.h

    r4c6ade6 re5556e4a  
    6262} client_t;
    6363
    64 typedef enum {
    65         /** Driver has not been started. */
    66         DRIVER_NOT_STARTED = 0,
    67        
    68         /**
    69          * Driver has been started, but has not registered as running and ready
    70          * to receive requests.
    71          */
    72         DRIVER_STARTING,
    73        
    74         /** Driver is running and prepared to serve incomming requests. */
    75         DRIVER_RUNNING
    76 } driver_state_t;
    77 
    7864/** Representation of device driver. */
    7965typedef struct driver {
     
    8773         * and prepared to receive requests.
    8874         */
    89         int state;
     75        driver_state_t state;
    9076       
    9177        /** Session asociated with this driver. */
  • uspace/srv/devman/driver.c

    r4c6ade6 re5556e4a  
    8181{
    8282        fibril_mutex_lock(&drivers_list->drivers_mutex);
    83         list_prepend(&drv->drivers, &drivers_list->drivers);
     83        list_append(&drv->drivers, &drivers_list->drivers);
    8484        drv->handle = drivers_list->next_handle++;
    8585        fibril_mutex_unlock(&drivers_list->drivers_mutex);
Note: See TracChangeset for help on using the changeset viewer.