This commit is contained in:
dongpingx 2025-05-30 22:26:47 +08:00 committed by GitHub
commit ae6e51b6a0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
7 changed files with 108 additions and 3 deletions

View File

@ -47,7 +47,7 @@ static struct console_uart uart = {
.enabled = true,
.type = MMIO,
.mmio_base_vaddr = (void *)CONFIG_SERIAL_MMIO_BASE,
.reg_width = 1,
.reg_width = CONFIG_SERIAL_MMIO_REG_WIDTH,
};
#endif
@ -292,7 +292,11 @@ void uart16550_set_property(bool enabled, enum serial_dev_type uart_type, uint64
uart.reg_width = 4;
} else if (uart_type == MMIO) {
uart.mmio_base_vaddr = (void *)data;
uart.reg_width = 1;
#if defined(CONFIG_SERIAL_MMIO_BASE)
uart.reg_width = CONFIG_SERIAL_MMIO_REG_WIDTH;
#else
uart.reg_width = 1;
#endif
}
}

View File

@ -141,7 +141,8 @@ export default {
totalMsg: "",
showTotalMessageFlag: false,
isSaved:false,
isLoaded:false
isLoaded:false,
serial_console: '',
}
},
computed: {
@ -350,9 +351,28 @@ export default {
}
})
},
getOption(serial_cat){
return this.schemas.HV.BasicConfigType.definitions.DebugOptionsType.properties[serial_cat]['hidden']
},
showOption(serial_cat, show){
this.schemas.HV.BasicConfigType.definitions.DebugOptionsType.properties[serial_cat]["ui:hidden"]=!show
},
scenarioConfigFormDataUpdate(vmid, data) {
if (vmid === -1) {
this.scenario.hv = data
this.serial_console = this.scenario.hv.DEBUG_OPTIONS.SERIAL_CONSOLE
let cats = this.getOption('SERIAL_MMIO_REG_WIDTH')
if(cats.length==0){
this.showOption('SERIAL_MMIO_REG_WIDTH',false)
}
for(let c of cats){
if(this.serial_console===c){
this.showOption('SERIAL_MMIO_REG_WIDTH',true)
break
}else{
this.showOption('SERIAL_MMIO_REG_WIDTH',false)
}
}
} else {
this.scenario.vm.map((vmConfig, vmIndex) => {
if (vmConfig['@id'] === vmid) {

View File

@ -14,6 +14,9 @@ from bs4 import BeautifulSoup
from . import convert_result, nuc11_board, scenario_json_schema, nuc11_board_path
SERIAL_CATEGORIES = ('portio', 'mmio', 'pci')
def get_dynamic_scenario(board):
"""
@ -34,6 +37,25 @@ def get_dynamic_scenario(board):
elements = [(enum_type_convert[obj_type](x[0]), x[1]) for x in elements]
return elements
def get_serial(source, options, serial_cat):
elements = [str(e) for e in elementpath.select(source, options) if e][0].strip().split('\n\t')
# seri:/dev/ttyS7 type:mmio base:0x4017000000 irq:16 bdf:"00:1e.0"
serials = {c:[] for c in SERIAL_CATEGORIES}
for el in elements:
t = {}
for e in el.split(' '):
e_ = e.split(':')
k, v = e_[0], e_[1]
t[k] = v
if t['type'] == SERIAL_CATEGORIES[0]:
serials[SERIAL_CATEGORIES[0]].append(t['seri'])
elif t['type'] == SERIAL_CATEGORIES[1] and 'bdf' in t:
serials[SERIAL_CATEGORIES[2]].append(t['seri'])
else:
serials[SERIAL_CATEGORIES[1]].append(t['seri'])
print(serials)
return serials[serial_cat]
def dynamic_enum(**enum_setting):
# value from env
function, source = [
@ -50,6 +72,14 @@ def get_dynamic_scenario(board):
enum = sorted(enum, key=lambda x: fn(x[0]))
return zip(*enum)
def dynamic_serial(**hidden_setting):
function, source = [
{"get_serial": get_serial, "board_xml": board_xml}[hidden_setting[key]]
for key in ['function', 'source']
]
selector, serial_cat = [hidden_setting[key] for key in ['selector', 'serial_cat']]
return function(source, selector, serial_cat)
def dynamic_enum_apply(obj):
# get json schema enum obj
if 'enum' in obj and isinstance(obj['enum'], dict):
@ -61,6 +91,14 @@ def get_dynamic_scenario(board):
enum, enum_names = dynamic_enum(**enum_setting)
obj['enum'] = enum
obj['enumNames'] = enum_names
# get json schema hidden
if 'hidden' in obj and isinstance(obj['hidden'], dict):
hidden_setting = obj['hidden']
if hidden_setting['type'] == 'dynamicSerial':
hidden_setting['type'] = obj.get('type', '')
obj['hidden'] = dynamic_serial(**hidden_setting)
return obj
data = json.loads(scenario_json_schema, object_hook=dynamic_enum_apply)

View File

@ -371,6 +371,22 @@ class XS2JS:
else:
js_ele['enum'] = dynamic_enum
# dynamic serial
if '@acrn:hidden' in annotation:
xpath, serial_cat = annotation['@acrn:hidden'].split(',')
if 'dynamicSerial' in self.features:
dynamic_serial = {
'type': 'dynamicSerial',
'function': 'get_serial',
'source': 'board_xml',
'selector': xpath.strip(),
'serial_cat': serial_cat.strip(),
}
if 'items' in js_ele:
js_ele['items']['hidden'] = dynamic_serial
else:
js_ele['hidden'] = dynamic_serial
# widget and its options
self.convert_widget_config(annotation, js_ele)
@ -424,6 +440,7 @@ def main():
features = []
if not stand_json_schema:
features.append('dynamicEnum')
features.append('dynamicSerial')
json_schema = XS2JS(schema_file, features).get_json_schema()
json_schema = json.dumps(json_schema, indent='\t')

View File

@ -19,6 +19,13 @@
<xs:documentation>Select the host serial device used for hypervisor debugging.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="SERIAL_MMIO_REG_WIDTH" type="RegWidthType" default="1" minOccurs="0">
<xs:annotation acrn:title="Default register width for serial MMIO"
acrn:views="basic"
acrn:hidden="//TTYS_INFO/text(),mmio">
<xs:documentation>Select the default register width for serial MMIO. Value can be changed at runtime.</xs:documentation>
</xs:annotation>
</xs:element>
<xs:element name="MEM_LOGLEVEL" type="LogLevelType" default="5">
<xs:annotation acrn:title="ACRN log level" acrn:views="basic">
<xs:documentation>Select the default log level for log messages stored in memory. Value can be changed at runtime. Log messages with the selected value or lower are displayed.</xs:documentation>

View File

@ -118,6 +118,20 @@ higher value (lower severity) are discarded.</xs:documentation>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="RegWidthType">
<xs:annotation>
<xs:documentation>Register width should be 1 or 4.</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:enumeration value="1">
<xs:annotation acrn:title="1" />
</xs:enumeration>
<xs:enumeration value="4">
<xs:annotation acrn:title="4" />
</xs:enumeration>
</xs:restriction>
</xs:simpleType>
<xs:simpleType name="SchedulerType">
<xs:annotation>
<xs:documentation>A string specifying the scheduling option:

View File

@ -211,6 +211,7 @@
<xsl:template match="SERIAL_CONSOLE">
<xsl:variable name="tokens" select="concat(substring-before(substring-after(/acrn-offline-data/board-data/acrn-config/TTYS_INFO, concat('seri:', current())), '&#xa;'), ' ')" />
<xsl:variable name="mmio_reg_width" select="//config-data/acrn-config/hv/DEBUG_OPTIONS/SERIAL_MMIO_REG_WIDTH" />
<xsl:variable name="type" select="substring-before(substring-after($tokens, 'type:'), ' ')" />
<xsl:variable name="base" select="substring-before(substring-after($tokens, 'base:'), ' ')" />
<xsl:variable name="irq" select="substring-before(substring-after($tokens, 'irq:'), ' ')" />
@ -262,6 +263,10 @@
<xsl:with-param name="value" select="$base" />
</xsl:call-template>
</xsl:if>
<xsl:call-template name="integer-by-key-value">
<xsl:with-param name="key" select="'SERIAL_MMIO_REG_WIDTH'" />
<xsl:with-param name="value" select="$mmio_reg_width" />
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>