Changeset 07b39338 in mainline for uspace/app
- Timestamp:
- 2011-08-20T18:21:49Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 6ab014d
- Parents:
- 0cf27ee (diff), f00af83 (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. - Location:
- uspace/app
- Files:
-
- 2 added
- 2 deleted
- 8 edited
- 2 moved
-
bdsh/exec.c (modified) (3 diffs)
-
devctl/Makefile (added)
-
devctl/devctl.c (moved) (moved from uspace/app/tester/devs/devman2.c ) (2 diffs)
-
locinfo/Makefile (added)
-
locinfo/locinfo.c (moved) (moved from uspace/app/tester/devs/devman1.c ) (2 diffs)
-
lsusb/main.c (modified) (3 diffs)
-
mkbd/main.c (modified) (1 diff)
-
tester/Makefile (modified) (1 diff)
-
tester/devs/devman1.def (deleted)
-
tester/devs/devman2.def (deleted)
-
tester/hw/misc/virtchar1.c (modified) (2 diffs)
-
tester/hw/serial/serial1.c (modified) (1 diff)
-
tester/tester.c (modified) (1 diff)
-
trace/trace.c (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/app/bdsh/exec.c
r0cf27ee r07b39338 40 40 #include <str_error.h> 41 41 #include <errno.h> 42 #include <vfs/vfs.h> 42 43 43 44 #include "config.h" … … 99 100 char *tmp; 100 101 int rc, retval, i; 101 fdi_node_t file_nodes[3];102 fdi_node_t *file_nodes_p[4];102 int file_handles[3]; 103 int *file_handles_p[4]; 103 104 FILE *files[3]; 104 105 … … 111 112 112 113 for (i = 0; i < 3 && files[i] != NULL; i++) { 113 if (f node(files[i], &file_nodes[i]) == EOK) {114 file_ nodes_p[i] = &file_nodes[i];114 if (fhandle(files[i], &file_handles[i]) == EOK) { 115 file_handles_p[i] = &file_handles[i]; 115 116 } 116 117 else { 117 file_ nodes_p[i] = NULL;118 file_handles_p[i] = NULL; 118 119 } 119 120 } 120 file_ nodes_p[i] = NULL;121 file_handles_p[i] = NULL; 121 122 122 rc = task_spawnvf(&tid, tmp, (const char **) argv, file_ nodes_p);123 rc = task_spawnvf(&tid, tmp, (const char **) argv, file_handles_p); 123 124 free(tmp); 124 125 -
uspace/app/devctl/devctl.c
r0cf27ee r07b39338 1 1 /* 2 * Copyright (c) 2011 Vojtech Horky2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup tester 30 * @brief Test devman service. 29 /** @addtogroup devctl 31 30 * @{ 32 31 */ 33 /** 34 * @file 32 /** @file Control device framework (devman server). 35 33 */ 36 34 37 #include < inttypes.h>35 #include <devman.h> 38 36 #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 <async.h> 45 #include <vfs/vfs.h> 46 #include <vfs/vfs_sess.h> 47 #include <sys/stat.h> 48 #include <fcntl.h> 49 #include "../tester.h" 37 #include <stdio.h> 38 #include <stdlib.h> 39 #include <sys/typefmt.h> 50 40 51 #define DEVICE_CLASS "test3"41 #define NAME "devctl" 52 42 53 const char *test_devman2(void) 43 #define MAX_NAME_LENGTH 1024 44 45 static int fun_tree_print(devman_handle_t funh, int lvl) 54 46 { 55 size_t idx = 1; 56 int rc = EOK; 57 const char *err_msg = NULL; 58 char *path = NULL; 59 while (rc == EOK) { 60 rc = asprintf(&path, "/loc/class/%s\\%zu", DEVICE_CLASS, idx); 61 if (rc < 0) { 62 continue; 63 } 64 int fd = open(path, O_RDONLY); 65 if (fd < 0) { 66 TPRINTF("Failed opening `%s': %s.\n", 67 path, str_error(fd)); 68 rc = fd; 69 err_msg = "Failed opening file"; 70 continue; 71 } 72 async_sess_t *sess = fd_session(EXCHANGE_SERIALIZE, fd); 73 close(fd); 74 if (sess == NULL) { 75 TPRINTF("Failed opening phone: %s.\n", str_error(errno)); 76 rc = errno; 77 err_msg = "Failed opening file descriptor phone"; 78 continue; 79 } 80 async_hangup(sess); 81 TPRINTF("Path `%s' okay.\n", path); 82 free(path); 83 idx++; 84 rc = EOK; 47 char name[MAX_NAME_LENGTH]; 48 devman_handle_t devh; 49 devman_handle_t *cfuns; 50 size_t count, i; 51 int rc; 52 int j; 53 54 for (j = 0; j < lvl; j++) 55 printf(" "); 56 57 rc = devman_fun_get_name(funh, name, MAX_NAME_LENGTH); 58 if (rc != EOK) { 59 str_cpy(name, MAX_NAME_LENGTH, "unknown"); 60 return ENOMEM; 85 61 } 86 87 if (path != NULL) 88 free(path); 89 90 return err_msg; 62 63 if (name[0] == '\0') 64 str_cpy(name, MAX_NAME_LENGTH, "/"); 65 66 printf("%s (%" PRIun ")\n", name, funh); 67 68 rc = devman_fun_get_child(funh, &devh); 69 if (rc == ENOENT) 70 return EOK; 71 72 if (rc != EOK) { 73 printf(NAME ": Failed getting child device for function " 74 "%s.\n", "xxx"); 75 return rc; 76 } 77 78 rc = devman_dev_get_functions(devh, &cfuns, &count); 79 if (rc != EOK) { 80 printf(NAME ": Failed getting list of functions for " 81 "device %s.\n", "xxx"); 82 return rc; 83 } 84 85 for (i = 0; i < count; i++) 86 fun_tree_print(cfuns[i], lvl + 1); 87 88 free(cfuns); 89 return EOK; 90 } 91 92 int main(int argc, char *argv[]) 93 { 94 devman_handle_t root_fun; 95 int rc; 96 97 rc = devman_fun_get_handle("/", &root_fun, 0); 98 if (rc != EOK) { 99 printf(NAME ": Error resolving root function.\n"); 100 return 1; 101 } 102 103 rc = fun_tree_print(root_fun, 0); 104 if (rc != EOK) 105 return 1; 106 107 return 0; 91 108 } 92 109 -
uspace/app/locinfo/locinfo.c
r0cf27ee r07b39338 1 1 /* 2 * Copyright (c) 2011 Vojtech Horky2 * Copyright (c) 2011 Jiri Svoboda 3 3 * All rights reserved. 4 4 * … … 27 27 */ 28 28 29 /** @addtogroup tester 30 * @brief Test devman service. 29 /** @addtogroup locinfo 31 30 * @{ 32 31 */ 33 /** 34 * @file 32 /** @file locinfo.c Print information from location service. 35 33 */ 36 34 37 #include <inttypes.h>38 35 #include <errno.h> 39 #include <str_error.h> 36 #include <loc.h> 37 #include <stdio.h> 38 #include <stdlib.h> 39 #include <str.h> 40 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" 41 #include <sys/typefmt.h> 48 42 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 43 #define NAME "locinfo" 53 44 54 const char *test_devman1(void)45 int main(int argc, char *argv[]) 55 46 { 56 devman_handle_t handle_primary; 57 devman_handle_t handle_class; 58 47 category_id_t *cat_ids; 48 size_t cat_cnt; 49 service_id_t *svc_ids; 50 size_t svc_cnt; 51 52 size_t i, j; 53 char *cat_name; 54 char *svc_name; 59 55 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); 56 57 rc = loc_get_categories(&cat_ids, &cat_cnt); 63 58 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"; 59 printf(NAME ": Error getting list of categories.\n"); 60 return 1; 69 61 } 70 62 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"; 63 for (i = 0; i < cat_cnt; i++) { 64 rc = loc_category_get_name(cat_ids[i], &cat_name); 65 if (rc != EOK) 66 cat_name = str_dup("<unknown>"); 67 68 if (cat_name == NULL) { 69 printf(NAME ": Error allocating memory.\n"); 70 return 1; 71 } 72 73 printf("%s (%" PRIun "):\n", cat_name, cat_ids[i]); 74 75 rc = loc_category_get_svcs(cat_ids[i], &svc_ids, &svc_cnt); 76 if (rc != EOK) { 77 printf(NAME ": Failed getting list of services in " 78 "category %s, skipping.\n", cat_name); 79 free(cat_name); 80 continue; 81 } 82 83 for (j = 0; j < svc_cnt; j++) { 84 rc = loc_service_get_name(svc_ids[j], &svc_name); 85 if (rc != EOK) { 86 printf(NAME ": Unknown service name (SID %" 87 PRIun ").\n", svc_ids[j]); 88 continue; 89 } 90 printf("\t%s (%" PRIun ")\n", svc_name, svc_ids[j]); 91 } 92 93 free(svc_ids); 94 free(cat_name); 77 95 } 78 96 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; 97 free(cat_ids); 98 return 0; 86 99 } 87 100 -
uspace/app/lsusb/main.c
r0cf27ee r07b39338 50 50 51 51 #define MAX_USB_ADDRESS USB11_ADDRESS_MAX 52 #define MAX_FAILED_ATTEMPTS 1053 52 #define MAX_PATH_LENGTH 1024 54 53 55 static void print_found_hc(s ize_t class_index, const char *path)54 static void print_found_hc(service_id_t sid, const char *path) 56 55 { 57 // printf(NAME ": host controller %zu is `%s'.\n", class_index, path); 58 printf("Bus %02zu: %s\n", class_index, path); 56 printf("Bus %" PRIun ": %s\n", sid, path); 59 57 } 60 58 static void print_found_dev(usb_address_t addr, const char *path) 61 59 { 62 // printf(NAME ": device with address %d is `%s'.\n", addr, path);63 60 printf(" Device %02d: %s\n", addr, path); 64 61 } … … 84 81 } 85 82 char path[MAX_PATH_LENGTH]; 86 rc = devman_ get_device_path(dev_handle, path, MAX_PATH_LENGTH);83 rc = devman_fun_get_path(dev_handle, path, MAX_PATH_LENGTH); 87 84 if (rc != EOK) { 88 85 continue; … … 95 92 int main(int argc, char *argv[]) 96 93 { 97 size_t class_index = 0; 98 size_t failed_attempts = 0; 94 category_id_t usbhc_cat; 95 service_id_t *svcs; 96 size_t count; 97 size_t i; 98 int rc; 99 99 100 while (failed_attempts < MAX_FAILED_ATTEMPTS) { 101 class_index++; 100 rc = loc_category_get_id(USB_HC_CATEGORY, &usbhc_cat, 0); 101 if (rc != EOK) { 102 printf(NAME ": Error resolving category '%s'", 103 USB_HC_CATEGORY); 104 return 1; 105 } 106 107 rc = loc_category_get_svcs(usbhc_cat, &svcs, &count); 108 if (rc != EOK) { 109 printf(NAME ": Error getting list of host controllers.\n"); 110 return 1; 111 } 112 113 for (i = 0; i < count; i++) { 102 114 devman_handle_t hc_handle = 0; 103 int rc = usb_ddf_get_hc_handle_by_ class(class_index, &hc_handle);115 int rc = usb_ddf_get_hc_handle_by_sid(svcs[i], &hc_handle); 104 116 if (rc != EOK) { 105 failed_attempts++; 117 printf(NAME ": Error resolving handle of HC with SID %" 118 PRIun ", skipping.\n", svcs[i]); 106 119 continue; 107 120 } 108 121 char path[MAX_PATH_LENGTH]; 109 rc = devman_ get_device_path(hc_handle, path, MAX_PATH_LENGTH);122 rc = devman_fun_get_path(hc_handle, path, MAX_PATH_LENGTH); 110 123 if (rc != EOK) { 124 printf(NAME ": Error resolving path of HC with SID %" 125 PRIun ", skipping.\n", svcs[i]); 111 126 continue; 112 127 } 113 print_found_hc( class_index, path);128 print_found_hc(svcs[i], path); 114 129 print_hc_devices(hc_handle); 115 130 } 131 132 free(svcs); 116 133 117 134 return 0; -
uspace/app/mkbd/main.c
r0cf27ee r07b39338 240 240 241 241 char path[MAX_PATH_LENGTH]; 242 rc = devman_ get_device_path(dev_handle, path, MAX_PATH_LENGTH);242 rc = devman_fun_get_path(dev_handle, path, MAX_PATH_LENGTH); 243 243 if (rc != EOK) { 244 244 return ENOMEM; -
uspace/app/tester/Makefile
r0cf27ee r07b39338 56 56 mm/malloc3.c \ 57 57 mm/mapping1.c \ 58 devs/devman1.c \59 devs/devman2.c \60 58 hw/misc/virtchar1.c \ 61 59 hw/serial/serial1.c \ -
uspace/app/tester/hw/misc/virtchar1.c
r0cf27ee r07b39338 49 49 50 50 #define DEVICE_PATH_NORMAL "/loc/devices/\\virt\\null\\a" 51 #define DEVICE_PATH_CLASSES "/loc/class/virt-null\\1"52 51 #define BUFFER_SIZE 64 53 52 … … 105 104 } 106 105 107 res = test_virtchar1_internal(DEVICE_PATH_CLASSES);108 if (res != NULL) {109 return res;110 }111 112 106 return NULL; 113 107 } -
uspace/app/tester/hw/serial/serial1.c
r0cf27ee r07b39338 72 72 73 73 devman_handle_t handle; 74 int res = devman_ device_get_handle("/hw/pci0/00:01.0/com1/a", &handle,74 int res = devman_fun_get_handle("/hw/pci0/00:01.0/com1/a", &handle, 75 75 IPC_FLAG_BLOCKING); 76 76 if (res != EOK) -
uspace/app/tester/tester.c
r0cf27ee r07b39338 68 68 #include "hw/misc/virtchar1.def" 69 69 #include "libext2/libext2_1.def" 70 #include "devs/devman1.def"71 #include "devs/devman2.def"72 70 {NULL, NULL, NULL, false} 73 71 }; -
uspace/app/trace/trace.c
r0cf27ee r07b39338 50 50 #include <sys/types.h> 51 51 #include <sys/typefmt.h> 52 #include <vfs/vfs.h> 52 53 53 54 #include <libc.h> … … 586 587 587 588 /* Send default files */ 588 fdi_node_t *files[4];589 fdi_node_t stdin_node;590 fdi_node_t stdout_node;591 fdi_node_t stderr_node;592 593 if ((stdin != NULL) && (f node(stdin, &stdin_node) == EOK))594 files[0] = & stdin_node;589 int *files[4]; 590 int fd_stdin; 591 int fd_stdout; 592 int fd_stderr; 593 594 if ((stdin != NULL) && (fhandle(stdin, &fd_stdin) == EOK)) 595 files[0] = &fd_stdin; 595 596 else 596 597 files[0] = NULL; 597 598 598 if ((stdout != NULL) && (f node(stdout, &stdout_node) == EOK))599 files[1] = & stdout_node;599 if ((stdout != NULL) && (fhandle(stdout, &fd_stdout) == EOK)) 600 files[1] = &fd_stdout; 600 601 else 601 602 files[1] = NULL; 602 603 603 if ((stderr != NULL) && (f node(stderr, &stderr_node) == EOK))604 files[2] = & stderr_node;604 if ((stderr != NULL) && (fhandle(stderr, &fd_stderr) == EOK)) 605 files[2] = &fd_stderr; 605 606 else 606 607 files[2] = NULL; … … 761 762 o = oper_new("open", 2, arg_def, V_INT_ERRNO, 0, resp_def); 762 763 proto_add_oper(p, VFS_IN_OPEN, o); 763 o = oper_new("open_node", 4, arg_def, V_INT_ERRNO, 0, resp_def);764 proto_add_oper(p, VFS_IN_OPEN_NODE, o);765 764 o = oper_new("read", 1, arg_def, V_ERRNO, 1, resp_def); 766 765 proto_add_oper(p, VFS_IN_READ, o);
Note:
See TracChangeset
for help on using the changeset viewer.
