@@ -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
5368def get_memory (hv_info , config ):
@@ -66,7 +81,7 @@ def get_memory(hv_info, config):
6681
6782def 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+
86105def get_features (hv_info , config ):
87106
88107 print ("CONFIG_{}=y" .format (hv_info .features .scheduler ), file = config )
0 commit comments