Index: uspace/srv/hid/output/port/chardev.c
===================================================================
--- uspace/srv/hid/output/port/chardev.c	(revision a91d71982386caa12384a03fa70c36a61e3b0f7c)
+++ uspace/srv/hid/output/port/chardev.c	(revision 7259317ff15733bb06bf5d4dcff8e0c2bb588a7d)
@@ -39,7 +39,10 @@
 #include <errno.h>
 #include <str.h>
+#include <sysinfo.h>
 #include "../ctl/serial.h"
 #include "../output.h"
 #include "chardev.h"
+
+static char *console;
 
 static async_sess_t *sess;
@@ -61,10 +64,20 @@
 }
 
+/*
+ * This callback scans all the services in the 'serial' category, hoping to see
+ * the single one the user wishes to use as a serial console. If it spots it, it
+ * connects to it and registers it as an output device. Then it ublocks the
+ * fibril blocked in chardev_init().
+ */
 static void check_for_dev(void)
 {
 	int rc;
 
-	if (sess)
+	fibril_mutex_lock(&discovery_lock);
+	if (discovery_finished) {
+		// TODO: no need to receive these callbacks anymore
+		fibril_mutex_unlock(&discovery_lock);
 		return;
+	}
 
 	service_id_t *svc;
@@ -72,18 +85,41 @@
 	rc = loc_category_get_svcs(serial_cat_id, &svc, &svcs);
 	if (rc != EOK) {
+		fibril_mutex_unlock(&discovery_lock);
 		printf("%s: Failed to get services\n", NAME);
 		return;
 	}
 
-	if (svcs < 1) {
-		free(svc);
+	service_id_t sid;
+	bool found = false;
+
+	for (size_t i = 0; i < svcs && !found; i++) {
+		char *name;
+		
+		rc = loc_service_get_name(svc[i], &name);
+		if (rc != EOK)
+			continue;
+
+		if (!str_cmp(console, name)) {
+			/*
+			 * This is the serial console service that the user
+			 * wanted to use.
+			 */
+			found = true;
+			sid = svc[i];
+		}
+			
+		free(name);
+	}
+
+	free(svc);
+
+	if (!found) {
+		fibril_mutex_unlock(&discovery_lock);
 		return;
 	}
 
-	service_id_t sid = svc[0];
-	free(svc);
-
 	sess = loc_service_connect(sid, INTERFACE_DDF, IPC_FLAG_BLOCKING);
 	if (!sess) {
+		fibril_mutex_unlock(&discovery_lock);
 		printf("%s: Failed connecting to device\n", NAME);
 		return;
@@ -91,5 +127,4 @@
 	serial_init(chardev_putchar, chardev_control_puts);
 
-	fibril_mutex_lock(&discovery_lock);
 	discovery_finished = true;
 	fibril_condvar_signal(&discovery_cv);
@@ -99,5 +134,26 @@
 int chardev_init(void)
 {
+	char *boot_args;
+	size_t size;
 	int rc;
+
+	boot_args = sysinfo_get_data("boot_args", &size);
+	if (!boot_args || !size) {
+		/*
+		 * Ok, there is nothing in the boot arguments. That means that
+		 * the user did not specify a serial console device.
+		 */
+		return EOK;
+	}
+
+	char *args = boot_args;
+	char *arg;
+#define ARG_CONSOLE	"console="
+	while ((arg = str_tok(args, " ", &args)) != NULL) {
+		if (!str_lcmp(arg, ARG_CONSOLE, str_length(ARG_CONSOLE))) {
+			console = arg + str_length(ARG_CONSOLE);
+			break;
+		}
+	}
 
 	rc = loc_category_get_id("serial", &serial_cat_id, IPC_FLAG_BLOCKING);
