From a35a3427d49a618550d6c0b252270bbe51f858cd Mon Sep 17 00:00:00 2001
From: Jonathan Doman <jonathan.doman@intel.com>
Date: Fri, 5 May 2023 17:51:42 -0700
Subject: [PATCH] Use sol-configure.sh to configure UART routing

Change-Id: I7f4945a56565b30a4baa1e241905a055a9a0ada7
Signed-off-by: Jonathan Doman <jonathan.doman@intel.com>
Upstream-Status: Pending
---
 socket-handler.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/socket-handler.c b/socket-handler.c
index 5f9d383..9c2a587 100644
--- a/socket-handler.c
+++ b/socket-handler.c
@@ -299,6 +299,16 @@ err_close:
 	return POLLER_REMOVE;
 }
 
+static void init_routing()
+{
+	static bool init_done = false;
+	if (!init_done) {
+		if (system("/usr/bin/sol-configure.sh setup_routing") == 0) {
+			init_done = true;
+		}
+	}
+}
+
 static enum poller_ret socket_poll(struct handler *handler, int events,
 				   void __attribute__((unused)) * data)
 {
@@ -316,6 +326,8 @@ static enum poller_ret socket_poll(struct handler *handler, int events,
 		return POLLER_OK;
 	}
 
+	init_routing();
+
 	client = malloc(sizeof(*client));
 	memset(client, 0, sizeof(*client));
 
@@ -395,6 +407,8 @@ int dbus_create_socket_consumer(struct console *console)
 
 	n = sh->n_clients++;
 
+	init_routing();
+
 	/*
 	 * We're managing an array of pointers to aggregates, so don't warn about
 	 * sizeof() on a pointer type.
-- 
2.25.1

