Changeset 89c57b6 in mainline for uspace/app/tester/devs/devman1.c
- Timestamp:
- 2011-04-13T14:45:41Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 88634420
- Parents:
- cefb126 (diff), 17279ead (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
rcefb126 r89c57b6 1 1 /* 2 * Copyright (c) 20 06 Ondrej Palkovsky2 * Copyright (c) 2011 Vojtech Horky 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 #include <stdio.h> 30 #include <unistd.h> 29 /** @addtogroup tester 30 * @brief Test devman service. 31 * @{ 32 */ 33 /** 34 * @file 35 */ 36 37 #include <inttypes.h> 38 #include <errno.h> 39 #include <str_error.h> 40 #include <sys/types.h> 31 41 #include <async.h> 32 #include <errno.h> 42 #include <devman.h> 43 #include <str.h> 44 #include <vfs/vfs.h> 45 #include <sys/stat.h> 46 #include <fcntl.h> 33 47 #include "../tester.h" 34 48 35 #define MAX_CONNECTIONS 50 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 36 53 37 static int connections[MAX_CONNECTIONS]; 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 } 38 70 39 static void client_connection(ipc_callid_t iid, ipc_call_t *icall) 40 { 41 unsigned int i; 42 43 TPRINTF("Connected phone %#x accepting\n", icall->in_phone_hash); 44 ipc_answer_0(iid, EOK); 45 for (i = 0; i < MAX_CONNECTIONS; i++) { 46 if (!connections[i]) { 47 connections[i] = icall->in_phone_hash; 48 break; 49 } 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"; 50 77 } 51 52 while (true) { 53 ipc_call_t call; 54 ipc_callid_t callid = async_get_call(&call); 55 int retval; 56 57 switch (IPC_GET_METHOD(call)) { 58 case IPC_M_PHONE_HUNGUP: 59 TPRINTF("Phone %#x hung up\n", icall->in_phone_hash); 60 retval = 0; 61 break; 62 case IPC_TEST_METHOD: 63 TPRINTF("Received well known message from %#x: %#x\n", 64 icall->in_phone_hash, callid); 65 ipc_answer_0(callid, EOK); 66 break; 67 default: 68 TPRINTF("Received unknown message from %#x: %#x\n", 69 icall->in_phone_hash, callid); 70 ipc_answer_0(callid, ENOENT); 71 break; 72 } 78 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"; 73 83 } 84 85 return NULL; 74 86 } 75 87 76 const char *test_register(void) 77 { 78 async_set_client_connection(client_connection); 79 80 ipcarg_t phonead; 81 int res = ipc_connect_to_me(PHONE_NS, IPC_TEST_SERVICE, 0, 0, &phonead); 82 if (res != 0) 83 return "Failed registering IPC service"; 84 85 TPRINTF("Registered as service %u, accepting connections\n", IPC_TEST_SERVICE); 86 async_manager(); 87 88 return NULL; 89 } 88 /** @} 89 */
Note:
See TracChangeset
for help on using the changeset viewer.