misc: add the CONFIG_SERIAL_REG_WIDTH

Tracked-On: #8721
Signed-off-by: Wei6 Zhang <wei6.zhang@intel.com>
This commit is contained in:
Wei6 Zhang
2025-08-19 15:52:55 +08:00
committed by Sun, Victor
parent a3b3440870
commit a26773314d
3 changed files with 53 additions and 14 deletions

View File

@@ -21,6 +21,7 @@ def get_serial_type():
ttys_type = ''
ttys_value = ''
pci_mmio = False
width = None # Only set if width field is found
# Get ttySx information from board config file
ttys_lines = board_cfg_lib.get_info(acrn_config_utilities.BOARD_INFO_FILE, "<TTYS_INFO>", "</TTYS_INFO>")
@@ -34,20 +35,34 @@ def get_serial_type():
for line in ttys_lines:
if ttyn in line:
# line format:
# seri:/dev/ttyS0 type:portio base:0x3F8 irq:4
# seri:/dev/ttyS0 type:mmio base:0xB3640000 irq:4 [bdf:"0:x.y"]
ttys_type = line.split()[1].split(':')[1]
# seri:/dev/ttyS0 type:portio base:0x3F8 [width:1byte] irq:4
# seri:/dev/ttyS0 type:mmio base:0xB3640000 [width:1byte] irq:4 [bdf:"0:x.y"]
parts = line.split()
ttys_type = parts[1].split(':')[1]
# Parse width if present
for part in parts:
if part.startswith('width:'):
width_str = part.split(':')[1]
if 'byte' in width_str:
width = int(width_str.replace('byte', ''))
break
if ttys_type == "portio":
ttys_value = line.split()[2].split(':')[1]
ttys_value = parts[2].split(':')[1]
elif ttys_type == "mmio":
if 'bdf' in line:
ttys_value = line.split()[-1].split('"')[1:-1][0]
pci_mmio = True
# Find the bdf field specifically
for part in parts:
if part.startswith('bdf:'):
ttys_value = part.split('"')[1]
pci_mmio = True
break
else:
ttys_value = line.split()[2].split(':')[1]
ttys_value = parts[2].split(':')[1]
break
return (ttys_type, ttys_value, pci_mmio)
return (ttys_type, ttys_value, pci_mmio, width)
def get_memory(hv_info, config):
@@ -66,7 +81,7 @@ def get_memory(hv_info, config):
def get_serial_console(config):
(serial_type, serial_value, pci_mmio) = get_serial_type()
(serial_type, serial_value, pci_mmio, width) = get_serial_type()
if serial_type == "portio":
print("CONFIG_SERIAL_LEGACY=y", file=config)
print("CONFIG_SERIAL_PIO_BASE={}".format(serial_value), file=config)
@@ -83,6 +98,10 @@ def get_serial_console(config):
if serial_value:
print('CONFIG_SERIAL_MMIO_BASE={}'.format(serial_value), file=config)
# Only output width configuration if width field was found
if width is not None:
print("CONFIG_SERIAL_REG_WIDTH={}".format(width), file=config)
def get_features(hv_info, config):
print("CONFIG_{}=y".format(hv_info.features.scheduler), file=config)

View File

@@ -80,14 +80,24 @@ def get_native_ttys():
for tty_line in ttys_lines:
tmp_dic = {}
#seri:/dev/ttySx type:mmio base:0x91526000 irq:4 [bdf:"00:18.0"]
#seri:/dev/ttySx type:mmio base:0x91526000 width:1byte irq:4 [bdf:"00:18.0"]
#seri:/dev/ttySy type:portio base:0x2f8 irq:5
tty = tty_line.split('/')[2].split()[0]
ttys_type = tty_line.split()[1].split(':')[1].strip()
ttys_base = tty_line.split()[2].split(':')[1].strip()
ttys_irq = tty_line.split()[3].split(':')[1].strip()
parts = tty_line.split()
tty = parts[0].split('/')[2]
ttys_type = parts[1].split(':')[1].strip()
ttys_base = parts[2].split(':')[1].strip()
# Find irq field by looking for "irq:" prefix
ttys_irq = None
for part in parts:
if part.startswith('irq:'):
ttys_irq = part.split(':')[1].strip()
break
tmp_dic['type'] = ttys_type
tmp_dic['base'] = ttys_base
tmp_dic['irq'] = int(ttys_irq)
if ttys_irq is not None:
tmp_dic['irq'] = int(ttys_irq)
native_ttys[tty] = tmp_dic
return native_ttys

View File

@@ -216,6 +216,8 @@
<xsl:variable name="irq" select="substring-before(substring-after($tokens, 'irq:'), ' ')" />
<xsl:variable name="bdf_string" select="substring-before(substring-after($tokens, 'bdf:'), ' ')" />
<xsl:variable name="bdf" select="substring($bdf_string, 2, string-length($bdf_string) - 2)" />
<xsl:variable name="width_string" select="substring-before(substring-after($tokens, 'width:'), ' ')" />
<xsl:variable name="width" select="substring-before($width_string, 'byte')" />
<xsl:choose>
<!-- TODO: Raise an error upon incomplete serial port info -->
@@ -264,6 +266,14 @@
</xsl:if>
</xsl:otherwise>
</xsl:choose>
<!-- Add width configuration if present -->
<xsl:if test="$width != ''">
<xsl:call-template name="integer-by-key-value">
<xsl:with-param name="key" select="'SERIAL_REG_WIDTH'" />
<xsl:with-param name="value" select="$width" />
</xsl:call-template>
</xsl:if>
</xsl:template>
<xsl:template match="MISC_CFG">