console-server: Add PTY support for testing purposes

Different TTY device types have different configuration options. The
existing code kinda smooshes the differences between UARTs and VUARTs
together. PTYs do not require the configuration applicable to either
UARTs or VUARTs. Given this, separate out and be explict about the
concepts and configuration required for all three types.

This in turn, with some further patches, allows testing of obmc-console
using `socat`:

https://amboar.github.io/notes/2023/05/02/testing-obmc-console-with-socat.html

Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
Change-Id: I3c1ce610132fce8ef6b5324ed3b4e0c86395e433
diff --git a/console-server.h b/console-server.h
index d275ad8..bd287c8 100644
--- a/console-server.h
+++ b/console-server.h
@@ -78,16 +78,32 @@
 typedef enum poller_ret (*poller_timeout_fn_t)(struct handler *handler,
 					       void *data);
 
+enum tty_device {
+	TTY_DEVICE_UNDEFINED = 0,
+	TTY_DEVICE_VUART,
+	TTY_DEVICE_UART,
+	TTY_DEVICE_PTY,
+};
+
 /* Console server structure */
 struct console {
-	const char *tty_kname;
-	char *tty_sysfs_devnode;
-	char *tty_dev;
+	struct {
+		const char *kname;
+		char *dev;
+		int fd;
+		enum tty_device type;
+		union {
+			struct {
+				char *sysfs_devnode;
+				int sirq;
+				uint16_t lpc_addr;
+			} vuart;
+			struct {
+				speed_t baud;
+			} uart;
+		};
+	} tty;
 	const char *console_id;
-	int tty_sirq;
-	uint16_t tty_lpc_addr;
-	speed_t tty_baud;
-	int tty_fd;
 
 	/* Socket name starts with null character hence we need length */
 	socket_path_t socket_name;