Changeset b04967a in mainline for uspace/app/tester/devs/devman1.c


Ignore:
Timestamp:
2011-04-07T15:53:46Z (13 years ago)
Author:
Matej Klonfar <maklf@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c156c2d
Parents:
64dbc83 (diff), a82889e (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:

development merge

File:
1 moved

Legend:

Unmodified
Added
Removed
  • uspace/app/tester/devs/devman1.c

    r64dbc83 rb04967a  
    11/*
    2  * Copyright (c) 2010 Matus Dekanek
     2 * Copyright (c) 2011 Vojtech Horky
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup drvusbhub
     29/** @addtogroup tester
     30 * @brief Test devman service.
    3031 * @{
    3132 */
    32 /** @file
    33  * @brief HC driver and hub driver.
    34  *
    35  * My private list implementation; I did not like the original helenos list.
    36  * This one does not depend on the structure of stored data and has
    37  * much simpler and more straight-forward semantics.
     33/**
     34 * @file
    3835 */
    39 #ifndef USBLIST_H
    40 #define USBLIST_H
    4136
    42 /**
    43  * general list structure
    44  */
    45 typedef struct usb_general_list{
    46         void * data;
    47         struct usb_general_list * prev, * next;
    48 } usb_general_list_t;
     37#include <inttypes.h>
     38#include <errno.h>
     39#include <str_error.h>
     40#include <sys/types.h>
     41#include <async.h>
     42#include <devman.h>
     43#include <str.h>
     44#include <vfs/vfs.h>
     45#include <sys/stat.h>
     46#include <fcntl.h>
     47#include "../tester.h"
    4948
    50 /** create head of usb general list */
    51 usb_general_list_t * usb_lst_create(void);
     49#define DEVICE_PATH_NORMAL "/virt/null/a"
     50#define DEVICE_CLASS "virt-null"
     51#define DEVICE_CLASS_NAME "1"
     52#define DEVICE_PATH_CLASSES DEVICE_CLASS "/" DEVICE_CLASS_NAME
    5253
    53 /** initialize head of usb general list */
    54 void usb_lst_init(usb_general_list_t * lst);
     54const char *test_devman1(void)
     55{
     56        devman_handle_t handle_primary;
     57        devman_handle_t handle_class;
     58       
     59        int rc;
     60       
     61        TPRINTF("Asking for handle of `%s'...\n", DEVICE_PATH_NORMAL);
     62        rc = devman_device_get_handle(DEVICE_PATH_NORMAL, &handle_primary, 0);
     63        if (rc != EOK) {
     64                TPRINTF(" ...failed: %s.\n", str_error(rc));
     65                if (rc == ENOENT) {
     66                        TPRINTF("Have you compiled the test drivers?\n");
     67                }
     68                return "Failed getting device handle";
     69        }
    5570
     71        TPRINTF("Asking for handle of `%s' by class..\n", DEVICE_PATH_CLASSES);
     72        rc = devman_device_get_handle_by_class(DEVICE_CLASS, DEVICE_CLASS_NAME,
     73            &handle_class, 0);
     74        if (rc != EOK) {
     75                TPRINTF(" ...failed: %s.\n", str_error(rc));
     76                return "Failed getting device class handle";
     77        }
    5678
    57 /** is the list empty? */
    58 static inline bool usb_lst_empty(usb_general_list_t * lst){
    59         return lst?(lst->next==lst):true;
     79        TPRINTF("Received handles %" PRIun " and %" PRIun ".\n",
     80            handle_primary, handle_class);
     81        if (handle_primary != handle_class) {
     82                return "Retrieved different handles for the same device";
     83        }
     84
     85        return NULL;
    6086}
    6187
    62 /** append data behind item */
    63 void usb_lst_append(usb_general_list_t * lst, void * data);
    64 
    65 /** prepend data beore item */
    66 void usb_lst_prepend(usb_general_list_t * lst, void * data);
    67 
    68 /** remove list item from list */
    69 void usb_lst_remove(usb_general_list_t * item);
    70 
    71 /** get data o specified type from list item */
    72 #define usb_lst_get_data(item, type)  (type *) (item->data)
    73 
    74 /** get usb_hub_info_t data from list item */
    75 static inline usb_hub_info_t * usb_hub_lst_get_data(usb_general_list_t * item) {
    76         return usb_lst_get_data(item,usb_hub_info_t);
    77 }
    78 
    79 #endif  /* USBLIST_H */
    80 /**
    81  * @}
     88/** @}
    8289 */
Note: See TracChangeset for help on using the changeset viewer.