commit | 2325d5d5aa0538329d06ec2c4c000089525cbe20 | [log] [tgz] |
---|---|---|
author | Alexander Hansen <alexander.hansen@9elements.com> | Fri Jun 07 16:54:20 2024 +0200 |
committer | Andrew Jeffery <andrew@codeconstruct.com.au> | Wed Jul 24 15:00:45 2024 +0930 |
tree | 4fec7925297e9d3862a41fd20ffacffdbe15e6e0 | |
parent | e3a083ebf5a1ed337f3a851a6f6e6ce77a85113a [diff] |
console-server: refactor pollfd management Instead of the previous memory management of pollfd array, with a fixed and flexible part and hardcoded indices, provide two functions to request and release pollfds. - console_server_request_pollfd - console_server_release_pollfd The pollfds are still in the same array but can be requested and released by these functions now. struct console_server and struct console now contain indices into that array of pollfds. The benefit of this contribution is that the new interface provides a clean allocator-like abstraction for requesting and releasing pollfds, which will scale to multiple consoles and can be refactored or unit-tested more easily in the future. The previous implementation was tightly coupled to the single-console use-case and the pollfds stored at hardcoded indices. Change-Id: I93226699618130b175bffbeb4f71c20c91a7083a Signed-off-by: Alexander Hansen <alexander.hansen@9elements.com> Signed-off-by: Andrew Jeffery <andrew@codeconstruct.com.au>
To build this project, run the following shell commands:
meson setup build meson compile -C build
To test:
meson test -C build
Running the server requires a serial port (e.g. /dev/ttyS0):
touch obmc-console.conf ./obmc-console-server --config obmc-console.conf ttyS0
To connect to the server, simply run the client:
./obmc-console-client
To disconnect the client, use the standard ~.
combination.
This shows how the host UART connection is abstracted within the BMC as a Unix domain socket.
+---------------------------------------------------------------------------------------------+ | | | obmc-console-client unix domain socket obmc-console-server | | | | +----------------------+ +------------------------+ | | | client.2200.conf | +---------------------+ | server.ttyVUART0.conf | | +---+--+ +----------------------+ | | +------------------------+ +--------+-------+ Network | 2200 +--> +->+ @obmc-console.host0 +<-+ <--+ /dev/ttyVUART0 | UARTs +---+--+ | console-id = "host0" | | | | console-id = "host0" | +--------+-------+ | | | +---------------------+ | | | | +----------------------+ +------------------------+ | | | | | | | +---------------------------------------------------------------------------------------------+
This supports multiple independent consoles. The console-id
is a unique portion for the unix domain socket created by the obmc-console-server instance. The server needs to know this because it needs to know what to name the pipe; the client needs to know it as it needs to form the abstract socket name to which to connect.