Changeset f8e8738 in mainline for uspace/app/tester/devs/devman1.c
- Timestamp:
- 2011-04-07T20:22:40Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fee6381
- Parents:
- 61257f4 (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. - File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/tester/devs/devman1.c
r61257f4 rf8e8738 1 1 /* 2 * Copyright (c) 201 0 Matus Dekanek2 * Copyright (c) 2011 Vojtech Horky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup drvusbhub 29 /** @addtogroup tester 30 * @brief Test devman service. 30 31 * @{ 31 32 */ 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 38 35 */ 39 #ifndef USBLIST_H40 #define USBLIST_H41 36 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" 49 48 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 52 53 53 /** initialize head of usb general list */ 54 void usb_lst_init(usb_general_list_t * lst); 54 const 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 } 55 70 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 } 56 78 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; 60 86 } 61 87 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 /** @} 82 89 */
Note:
See TracChangeset
for help on using the changeset viewer.