qcom: Add userspace tools to talk to dsp and modem

cherry-picked from upstream device/linaro/dragonboard project.

Add Qcom userspace tools and their respective sepolicy rules.

Userspace tools are downloaded from following github:

To trigger loading of wlan firmware on SDM845
git clone https://github.com/andersson/pd-mapper

Userspace reference for net/qrtr in the Linux kernel
git clone https://github.com/andersson/qrtr

Qualcomm Remote Filesystem Service Implementation
git clone https://github.com/andersson/rmtfs

Trivial File Transfer Protocol server over AF_QIPCRTR
git clone https://github.com/andersson/tqftpserv

Change-Id: Ic466af6fef010a9b71c90e38205f49a876b001e2
Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
Signed-off-by: John Stultz <john.stultz@linaro.org>
Signed-off-by: Amit Pundir <pundiramit@gmail.com>
diff --git a/qcom/qrtr/lib/logging.c b/qcom/qrtr/lib/logging.c
new file mode 100644
index 0000000..0b0f103
--- /dev/null
+++ b/qcom/qrtr/lib/logging.c
@@ -0,0 +1,73 @@
+#include <stdbool.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <syslog.h>
+
+#define QLOG_BUF_SIZE 512
+
+static const char default_tag[] = "libqrtr";
+static const char *current_tag = default_tag;
+static int min_priority = LOG_INFO;
+
+static bool logging_to_syslog = false;
+
+void qlog_setup(const char *tag, bool use_syslog)
+{
+	current_tag = tag;
+	logging_to_syslog = use_syslog;
+
+	openlog(tag, LOG_PID, LOG_USER);
+}
+
+void qlog_set_min_priority(int priority)
+{
+	if (priority < LOG_EMERG || priority > LOG_DEBUG)
+		return;
+
+	min_priority = priority;
+}
+
+static const char *get_priority_string(int priority)
+{
+	switch (priority) {
+	case LOG_EMERG:
+		return "EMERG";
+	case LOG_ALERT:
+		return "ALERT";
+	case LOG_CRIT:
+		return "CRIT";
+	case LOG_ERR:
+		return "ERROR";
+	case LOG_WARNING:
+		return "WARNING";
+	case LOG_NOTICE:
+		return "NOTICE";
+	case LOG_INFO:
+		return "INFO";
+	case LOG_DEBUG:
+		return "DEBUG";
+	}
+	return "";
+}
+
+void qlog(int priority, const char *format, ...)
+{
+	va_list ap;
+
+	if (priority > min_priority)
+		return;
+
+	va_start(ap, format);
+
+	if (logging_to_syslog) {
+		vsyslog(priority, format, ap);
+	} else {
+		char buf[QLOG_BUF_SIZE];
+		vsnprintf(buf, QLOG_BUF_SIZE, format, ap);
+
+		fprintf(stderr, "%s %s: %s\n",
+		        get_priority_string(priority), current_tag, buf);
+	}
+
+	va_end(ap);
+}