From 163b29a07c4d25ee9d3157eb5c517f06a170f42c Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Wed, 13 Mar 2019 15:05:42 -0400 Subject: [PATCH] Update autocons.py This is the version that landed in xCAT genesis --- misc/autocons.py | 57 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 misc/autocons.py diff --git a/misc/autocons.py b/misc/autocons.py new file mode 100644 index 00000000..5c5bf127 --- /dev/null +++ b/misc/autocons.py @@ -0,0 +1,57 @@ +import os +import struct +import termios + +addrtoname = { + 0x3f8: '/dev/ttyS0', + 0x2f8: '/dev/ttyS1', + 0x3e8: '/dev/ttyS2', + 0x2e8: '/dev/ttyS3', +} +speedmap = { + 0: None, + 3: 9600, + 4: 19200, + 6: 57600, + 7: 115200, +} + +termiobaud = { + 9600: termios.B9600, + 19200: termios.B19200, + 57600: termios.B57600, + 115200: termios.B115200, +} + +def do_serial_config(): + if 'console=ttyS' in open('/proc/cmdline').read(): + return None # Do not do autoconsole if manually configured + spcr = open("/sys/firmware/acpi/tables/SPCR", "rb") + spcr = bytearray(spcr.read()) + if spcr[8] != 2 or spcr[36] != 0 or spcr[40] != 1: + return None + address = struct.unpack(' {0} >&0 2>&1'.format(serialinfo['tty']))