Skip to content

Commit a267733

Browse files
6ZhangWeijsun26intel
authored andcommitted
misc: add the CONFIG_SERIAL_REG_WIDTH
Tracked-On: #8721 Signed-off-by: Wei6 Zhang <wei6.zhang@intel.com>
1 parent a3b3440 commit a267733

3 files changed

Lines changed: 53 additions & 14 deletions

File tree

misc/config_tools/hv_config/board_defconfig.py

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ def get_serial_type():
2121
ttys_type = ''
2222
ttys_value = ''
2323
pci_mmio = False
24+
width = None # Only set if width field is found
2425

2526
# Get ttySx information from board config file
2627
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():
3435
for line in ttys_lines:
3536
if ttyn in line:
3637
# line format:
37-
# seri:/dev/ttyS0 type:portio base:0x3F8 irq:4
38-
# seri:/dev/ttyS0 type:mmio base:0xB3640000 irq:4 [bdf:"0:x.y"]
39-
ttys_type = line.split()[1].split(':')[1]
38+
# seri:/dev/ttyS0 type:portio base:0x3F8 [width:1byte] irq:4
39+
# seri:/dev/ttyS0 type:mmio base:0xB3640000 [width:1byte] irq:4 [bdf:"0:x.y"]
40+
parts = line.split()
41+
ttys_type = parts[1].split(':')[1]
42+
43+
# Parse width if present
44+
for part in parts:
45+
if part.startswith('width:'):
46+
width_str = part.split(':')[1]
47+
if 'byte' in width_str:
48+
width = int(width_str.replace('byte', ''))
49+
break
50+
4051
if ttys_type == "portio":
41-
ttys_value = line.split()[2].split(':')[1]
52+
ttys_value = parts[2].split(':')[1]
4253
elif ttys_type == "mmio":
4354
if 'bdf' in line:
44-
ttys_value = line.split()[-1].split('"')[1:-1][0]
45-
pci_mmio = True
55+
# Find the bdf field specifically
56+
for part in parts:
57+
if part.startswith('bdf:'):
58+
ttys_value = part.split('"')[1]
59+
pci_mmio = True
60+
break
4661
else:
47-
ttys_value = line.split()[2].split(':')[1]
62+
ttys_value = parts[2].split(':')[1]
4863
break
4964

50-
return (ttys_type, ttys_value, pci_mmio)
65+
return (ttys_type, ttys_value, pci_mmio, width)
5166

5267

5368
def get_memory(hv_info, config):
@@ -66,7 +81,7 @@ def get_memory(hv_info, config):
6681

6782
def get_serial_console(config):
6883

69-
(serial_type, serial_value, pci_mmio) = get_serial_type()
84+
(serial_type, serial_value, pci_mmio, width) = get_serial_type()
7085
if serial_type == "portio":
7186
print("CONFIG_SERIAL_LEGACY=y", file=config)
7287
print("CONFIG_SERIAL_PIO_BASE={}".format(serial_value), file=config)
@@ -83,6 +98,10 @@ def get_serial_console(config):
8398
if serial_value:
8499
print('CONFIG_SERIAL_MMIO_BASE={}'.format(serial_value), file=config)
85100

101+
# Only output width configuration if width field was found
102+
if width is not None:
103+
print("CONFIG_SERIAL_REG_WIDTH={}".format(width), file=config)
104+
86105
def get_features(hv_info, config):
87106

88107
print("CONFIG_{}=y".format(hv_info.features.scheduler), file=config)

misc/config_tools/static_allocators/lib/lib.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,14 +80,24 @@ def get_native_ttys():
8080
for tty_line in ttys_lines:
8181
tmp_dic = {}
8282
#seri:/dev/ttySx type:mmio base:0x91526000 irq:4 [bdf:"00:18.0"]
83+
#seri:/dev/ttySx type:mmio base:0x91526000 width:1byte irq:4 [bdf:"00:18.0"]
8384
#seri:/dev/ttySy type:portio base:0x2f8 irq:5
84-
tty = tty_line.split('/')[2].split()[0]
85-
ttys_type = tty_line.split()[1].split(':')[1].strip()
86-
ttys_base = tty_line.split()[2].split(':')[1].strip()
87-
ttys_irq = tty_line.split()[3].split(':')[1].strip()
85+
parts = tty_line.split()
86+
tty = parts[0].split('/')[2]
87+
ttys_type = parts[1].split(':')[1].strip()
88+
ttys_base = parts[2].split(':')[1].strip()
89+
90+
# Find irq field by looking for "irq:" prefix
91+
ttys_irq = None
92+
for part in parts:
93+
if part.startswith('irq:'):
94+
ttys_irq = part.split(':')[1].strip()
95+
break
96+
8897
tmp_dic['type'] = ttys_type
8998
tmp_dic['base'] = ttys_base
90-
tmp_dic['irq'] = int(ttys_irq)
99+
if ttys_irq is not None:
100+
tmp_dic['irq'] = int(ttys_irq)
91101
native_ttys[tty] = tmp_dic
92102
return native_ttys
93103

misc/config_tools/xforms/config_common.xsl

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,8 @@
216216
<xsl:variable name="irq" select="substring-before(substring-after($tokens, 'irq:'), ' ')" />
217217
<xsl:variable name="bdf_string" select="substring-before(substring-after($tokens, 'bdf:'), ' ')" />
218218
<xsl:variable name="bdf" select="substring($bdf_string, 2, string-length($bdf_string) - 2)" />
219+
<xsl:variable name="width_string" select="substring-before(substring-after($tokens, 'width:'), ' ')" />
220+
<xsl:variable name="width" select="substring-before($width_string, 'byte')" />
219221

220222
<xsl:choose>
221223
<!-- TODO: Raise an error upon incomplete serial port info -->
@@ -264,6 +266,14 @@
264266
</xsl:if>
265267
</xsl:otherwise>
266268
</xsl:choose>
269+
270+
<!-- Add width configuration if present -->
271+
<xsl:if test="$width != ''">
272+
<xsl:call-template name="integer-by-key-value">
273+
<xsl:with-param name="key" select="'SERIAL_REG_WIDTH'" />
274+
<xsl:with-param name="value" select="$width" />
275+
</xsl:call-template>
276+
</xsl:if>
267277
</xsl:template>
268278

269279
<xsl:template match="MISC_CFG">

0 commit comments

Comments
 (0)