Changeset 7259317 in mainline
- Timestamp:
- 2016-12-23T21:21:20Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 00130656
- Parents:
- a91d719
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/output/port/chardev.c
ra91d719 r7259317 39 39 #include <errno.h> 40 40 #include <str.h> 41 #include <sysinfo.h> 41 42 #include "../ctl/serial.h" 42 43 #include "../output.h" 43 44 #include "chardev.h" 45 46 static char *console; 44 47 45 48 static async_sess_t *sess; … … 61 64 } 62 65 66 /* 67 * This callback scans all the services in the 'serial' category, hoping to see 68 * the single one the user wishes to use as a serial console. If it spots it, it 69 * connects to it and registers it as an output device. Then it ublocks the 70 * fibril blocked in chardev_init(). 71 */ 63 72 static void check_for_dev(void) 64 73 { 65 74 int rc; 66 75 67 if (sess) 76 fibril_mutex_lock(&discovery_lock); 77 if (discovery_finished) { 78 // TODO: no need to receive these callbacks anymore 79 fibril_mutex_unlock(&discovery_lock); 68 80 return; 81 } 69 82 70 83 service_id_t *svc; … … 72 85 rc = loc_category_get_svcs(serial_cat_id, &svc, &svcs); 73 86 if (rc != EOK) { 87 fibril_mutex_unlock(&discovery_lock); 74 88 printf("%s: Failed to get services\n", NAME); 75 89 return; 76 90 } 77 91 78 if (svcs < 1) { 79 free(svc); 92 service_id_t sid; 93 bool found = false; 94 95 for (size_t i = 0; i < svcs && !found; i++) { 96 char *name; 97 98 rc = loc_service_get_name(svc[i], &name); 99 if (rc != EOK) 100 continue; 101 102 if (!str_cmp(console, name)) { 103 /* 104 * This is the serial console service that the user 105 * wanted to use. 106 */ 107 found = true; 108 sid = svc[i]; 109 } 110 111 free(name); 112 } 113 114 free(svc); 115 116 if (!found) { 117 fibril_mutex_unlock(&discovery_lock); 80 118 return; 81 119 } 82 120 83 service_id_t sid = svc[0];84 free(svc);85 86 121 sess = loc_service_connect(sid, INTERFACE_DDF, IPC_FLAG_BLOCKING); 87 122 if (!sess) { 123 fibril_mutex_unlock(&discovery_lock); 88 124 printf("%s: Failed connecting to device\n", NAME); 89 125 return; … … 91 127 serial_init(chardev_putchar, chardev_control_puts); 92 128 93 fibril_mutex_lock(&discovery_lock);94 129 discovery_finished = true; 95 130 fibril_condvar_signal(&discovery_cv); … … 99 134 int chardev_init(void) 100 135 { 136 char *boot_args; 137 size_t size; 101 138 int rc; 139 140 boot_args = sysinfo_get_data("boot_args", &size); 141 if (!boot_args || !size) { 142 /* 143 * Ok, there is nothing in the boot arguments. That means that 144 * the user did not specify a serial console device. 145 */ 146 return EOK; 147 } 148 149 char *args = boot_args; 150 char *arg; 151 #define ARG_CONSOLE "console=" 152 while ((arg = str_tok(args, " ", &args)) != NULL) { 153 if (!str_lcmp(arg, ARG_CONSOLE, str_length(ARG_CONSOLE))) { 154 console = arg + str_length(ARG_CONSOLE); 155 break; 156 } 157 } 102 158 103 159 rc = loc_category_get_id("serial", &serial_cat_id, IPC_FLAG_BLOCKING);
Note:
See TracChangeset
for help on using the changeset viewer.