[PATCH] config_tools: add pio serial port bdf to config.h


Zhao, Yuanyuan
 

Add bdf info of pio serial port to config.h.

Signed-off-by: Yuanyuan Zhao <yuanyuan.zhao@...>
---
misc/config_tools/xforms/config_common.xsl | 33 +++++++++-------------
misc/config_tools/xforms/lib.xsl | 23 +++++++++++++++
2 files changed, 36 insertions(+), 20 deletions(-)

diff --git a/misc/config_tools/xforms/config_common.xsl b/misc/config_tools/xforms/config_common.xsl
index 8d633df4e..5cf7949f5 100644
--- a/misc/config_tools/xforms/config_common.xsl
+++ b/misc/config_tools/xforms/config_common.xsl
@@ -186,6 +186,7 @@
</xsl:call-template>
</xsl:template>

+
<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="type" select="substring-before(substring-after($tokens, 'type:'), ' ')" />
@@ -205,32 +206,24 @@
<xsl:with-param name="key" select="'SERIAL_PIO_BASE'" />
<xsl:with-param name="value" select="$base" />
</xsl:call-template>
+ <xsl:if test="$bdf != ''">
+ <xsl:call-template name="boolean-by-key-value">
+ <xsl:with-param name="key" select="'SERIAL_PCI'" />
+ <xsl:with-param name="value" select="'y'" />
+ </xsl:call-template>
+ <xsl:variable name="serial_bdf" select="acrn:binary-bdf($bdf)" />
+ <xsl:call-template name="integer-by-key-value">
+ <xsl:with-param name="key" select="'SERIAL_PCI_BDF'" />
+ <xsl:with-param name="value" select="$serial_bdf" />
+ </xsl:call-template>
+ </xsl:if>
</xsl:when>
<xsl:when test="($type = 'mmio') and ($bdf != '')">
<xsl:call-template name="boolean-by-key-value">
<xsl:with-param name="key" select="'SERIAL_PCI'" />
<xsl:with-param name="value" select="'y'" />
</xsl:call-template>
-
- <xsl:variable name="bus" select="substring-before($bdf, ':')" />
- <xsl:variable name="device" select="substring-before(substring-after($bdf, ':'), '.')" />
- <xsl:variable name="function" select="substring-after($bdf, '.')" />
- <xsl:variable name="serial_bdf">
- <xsl:text>0b</xsl:text>
- <xsl:call-template name="hex-to-bin">
- <xsl:with-param name="s" select="$bus" />
- <xsl:with-param name="width" select="4" />
- </xsl:call-template>
- <xsl:call-template name="hex-to-bin">
- <xsl:with-param name="s" select="$device" />
- <xsl:with-param name="width" select="1" />
- </xsl:call-template>
- <xsl:call-template name="hex-to-bin">
- <xsl:with-param name="s" select="$function" />
- <xsl:with-param name="width" select="3" />
- </xsl:call-template>
- </xsl:variable>
-
+ <xsl:variable name="serial_bdf" select="acrn:binary-bdf($bdf)" />
<xsl:call-template name="integer-by-key-value">
<xsl:with-param name="key" select="'SERIAL_PCI_BDF'" />
<xsl:with-param name="value" select="$serial_bdf" />
diff --git a/misc/config_tools/xforms/lib.xsl b/misc/config_tools/xforms/lib.xsl
index 8974cc16a..7adf2dd47 100644
--- a/misc/config_tools/xforms/lib.xsl
+++ b/misc/config_tools/xforms/lib.xsl
@@ -544,6 +544,29 @@
<func:result select="$unique_mapping" />
</func:function>

+ <func:function name="acrn:binary-bdf">
+ <xsl:param name="bdf" />
+ <xsl:variable name="bus" select="substring-before($bdf, ':')" />
+ <xsl:variable name="device" select="substring-before(substring-after($bdf, ':'), '.')" />
+ <xsl:variable name="function" select="substring-after($bdf, '.')" />
+ <xsl:variable name="serial_bdf">
+ <xsl:text>0b</xsl:text>
+ <xsl:call-template name="hex-to-bin">
+ <xsl:with-param name="s" select="$bus" />
+ <xsl:with-param name="width" select="4" />
+ </xsl:call-template>
+ <xsl:call-template name="hex-to-bin">
+ <xsl:with-param name="s" select="$device" />
+ <xsl:with-param name="width" select="1" />
+ </xsl:call-template>
+ <xsl:call-template name="hex-to-bin">
+ <xsl:with-param name="s" select="$function" />
+ <xsl:with-param name="width" select="3" />
+ </xsl:call-template>
+ </xsl:variable>
+ <func:result select="$serial_bdf" />
+ </func:function>
+
<func:function name="acrn:get-vbdf">
<xsl:param name="vmid" />
<xsl:param name="name" />
--
2.25.1


Junjie Mao
 

-----Original Message-----
From: Yuanyuan Zhao <yuanyuan.zhao@...>
Sent: Friday, September 30, 2022 10:07 AM
To: Mao, Junjie <junjie.mao@...>; acrn-dev@...
Cc: yuanyuan.zhao@...
Subject: [PATCH] config_tools: add pio serial port bdf to config.h

Add bdf info of pio serial port to config.h.

Signed-off-by: Yuanyuan Zhao <yuanyuan.zhao@...>
Reviewed-by: Junjie Mao <junjie.mao@...>

Some cosmetic comments below.

---
misc/config_tools/xforms/config_common.xsl | 33 +++++++++-------------
misc/config_tools/xforms/lib.xsl | 23 +++++++++++++++
2 files changed, 36 insertions(+), 20 deletions(-)

diff --git a/misc/config_tools/xforms/config_common.xsl
b/misc/config_tools/xforms/config_common.xsl
index 8d633df4e..5cf7949f5 100644
--- a/misc/config_tools/xforms/config_common.xsl
+++ b/misc/config_tools/xforms/config_common.xsl
@@ -186,6 +186,7 @@
</xsl:call-template>
</xsl:template>

+
Is this new line needed?

<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="type" select="substring-before(substring-after($tokens, 'type:'),
' ')" />
@@ -205,32 +206,24 @@
<xsl:with-param name="key" select="'SERIAL_PIO_BASE'" />
<xsl:with-param name="value" select="$base" />
</xsl:call-template>
+ <xsl:if test="$bdf != ''">
Indentation does not look quite right here.

---
Best Regards
Junjie Mao

+ <xsl:call-template name="boolean-by-key-value">
+ <xsl:with-param name="key" select="'SERIAL_PCI'" />
+ <xsl:with-param name="value" select="'y'" />
+ </xsl:call-template>
+ <xsl:variable name="serial_bdf" select="acrn:binary-bdf($bdf)" />
+ <xsl:call-template name="integer-by-key-value">
+ <xsl:with-param name="key" select="'SERIAL_PCI_BDF'" />
+ <xsl:with-param name="value" select="$serial_bdf" />
+ </xsl:call-template>
+ </xsl:if>
</xsl:when>
<xsl:when test="($type = 'mmio') and ($bdf != '')">
<xsl:call-template name="boolean-by-key-value">
<xsl:with-param name="key" select="'SERIAL_PCI'" />
<xsl:with-param name="value" select="'y'" />
</xsl:call-template>
-
- <xsl:variable name="bus" select="substring-before($bdf, ':')" />
- <xsl:variable name="device" select="substring-before(substring-after($bdf, ':'),
'.')" />
- <xsl:variable name="function" select="substring-after($bdf, '.')" />
- <xsl:variable name="serial_bdf">
- <xsl:text>0b</xsl:text>
- <xsl:call-template name="hex-to-bin">
- <xsl:with-param name="s" select="$bus" />
- <xsl:with-param name="width" select="4" />
- </xsl:call-template>
- <xsl:call-template name="hex-to-bin">
- <xsl:with-param name="s" select="$device" />
- <xsl:with-param name="width" select="1" />
- </xsl:call-template>
- <xsl:call-template name="hex-to-bin">
- <xsl:with-param name="s" select="$function" />
- <xsl:with-param name="width" select="3" />
- </xsl:call-template>
- </xsl:variable>
-
+ <xsl:variable name="serial_bdf" select="acrn:binary-bdf($bdf)" />
<xsl:call-template name="integer-by-key-value">
<xsl:with-param name="key" select="'SERIAL_PCI_BDF'" />
<xsl:with-param name="value" select="$serial_bdf" />
diff --git a/misc/config_tools/xforms/lib.xsl b/misc/config_tools/xforms/lib.xsl
index 8974cc16a..7adf2dd47 100644
--- a/misc/config_tools/xforms/lib.xsl
+++ b/misc/config_tools/xforms/lib.xsl
@@ -544,6 +544,29 @@
<func:result select="$unique_mapping" />
</func:function>

+ <func:function name="acrn:binary-bdf">
+ <xsl:param name="bdf" />
+ <xsl:variable name="bus" select="substring-before($bdf, ':')" />
+ <xsl:variable name="device" select="substring-before(substring-after($bdf, ':'),
'.')" />
+ <xsl:variable name="function" select="substring-after($bdf, '.')" />
+ <xsl:variable name="serial_bdf">
+ <xsl:text>0b</xsl:text>
+ <xsl:call-template name="hex-to-bin">
+ <xsl:with-param name="s" select="$bus" />
+ <xsl:with-param name="width" select="4" />
+ </xsl:call-template>
+ <xsl:call-template name="hex-to-bin">
+ <xsl:with-param name="s" select="$device" />
+ <xsl:with-param name="width" select="1" />
+ </xsl:call-template>
+ <xsl:call-template name="hex-to-bin">
+ <xsl:with-param name="s" select="$function" />
+ <xsl:with-param name="width" select="3" />
+ </xsl:call-template>
+ </xsl:variable>
+ <func:result select="$serial_bdf" />
+ </func:function>
+
<func:function name="acrn:get-vbdf">
<xsl:param name="vmid" />
<xsl:param name="name" />
--
2.25.1


Zhao, Yuanyuan
 

On 2022/9/30 11:27, Mao, Junjie wrote:
-----Original Message-----
From: Yuanyuan Zhao <yuanyuan.zhao@...>
Sent: Friday, September 30, 2022 10:07 AM
To: Mao, Junjie <junjie.mao@...>; acrn-dev@...
Cc: yuanyuan.zhao@...
Subject: [PATCH] config_tools: add pio serial port bdf to config.h

Add bdf info of pio serial port to config.h.

Signed-off-by: Yuanyuan Zhao <yuanyuan.zhao@...>
Reviewed-by: Junjie Mao <junjie.mao@...>
Some cosmetic comments below.

---
misc/config_tools/xforms/config_common.xsl | 33 +++++++++-------------
misc/config_tools/xforms/lib.xsl | 23 +++++++++++++++
2 files changed, 36 insertions(+), 20 deletions(-)

diff --git a/misc/config_tools/xforms/config_common.xsl
b/misc/config_tools/xforms/config_common.xsl
index 8d633df4e..5cf7949f5 100644
--- a/misc/config_tools/xforms/config_common.xsl
+++ b/misc/config_tools/xforms/config_common.xsl
@@ -186,6 +186,7 @@
</xsl:call-template>
</xsl:template>

+
Is this new line needed?
OK, I will remove it.

<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="type" select="substring-before(substring-after($tokens, 'type:'),
' ')" />
@@ -205,32 +206,24 @@
<xsl:with-param name="key" select="'SERIAL_PIO_BASE'" />
<xsl:with-param name="value" select="$base" />
</xsl:call-template>
+ <xsl:if test="$bdf != ''">
Indentation does not look quite right here.Original code indentation have some problem. should i correct it?
---
Best Regards
Junjie Mao

+ <xsl:call-template name="boolean-by-key-value">
+ <xsl:with-param name="key" select="'SERIAL_PCI'" />
+ <xsl:with-param name="value" select="'y'" />
+ </xsl:call-template>
+ <xsl:variable name="serial_bdf" select="acrn:binary-bdf($bdf)" />
+ <xsl:call-template name="integer-by-key-value">
+ <xsl:with-param name="key" select="'SERIAL_PCI_BDF'" />
+ <xsl:with-param name="value" select="$serial_bdf" />
+ </xsl:call-template>
+ </xsl:if>
</xsl:when>
<xsl:when test="($type = 'mmio') and ($bdf != '')">
<xsl:call-template name="boolean-by-key-value">
<xsl:with-param name="key" select="'SERIAL_PCI'" />
<xsl:with-param name="value" select="'y'" />
</xsl:call-template>
-
- <xsl:variable name="bus" select="substring-before($bdf, ':')" />
- <xsl:variable name="device" select="substring-before(substring-after($bdf, ':'),
'.')" />
- <xsl:variable name="function" select="substring-after($bdf, '.')" />
- <xsl:variable name="serial_bdf">
- <xsl:text>0b</xsl:text>
- <xsl:call-template name="hex-to-bin">
- <xsl:with-param name="s" select="$bus" />
- <xsl:with-param name="width" select="4" />
- </xsl:call-template>
- <xsl:call-template name="hex-to-bin">
- <xsl:with-param name="s" select="$device" />
- <xsl:with-param name="width" select="1" />
- </xsl:call-template>
- <xsl:call-template name="hex-to-bin">
- <xsl:with-param name="s" select="$function" />
- <xsl:with-param name="width" select="3" />
- </xsl:call-template>
- </xsl:variable>
-
+ <xsl:variable name="serial_bdf" select="acrn:binary-bdf($bdf)" />
<xsl:call-template name="integer-by-key-value">
<xsl:with-param name="key" select="'SERIAL_PCI_BDF'" />
<xsl:with-param name="value" select="$serial_bdf" />
diff --git a/misc/config_tools/xforms/lib.xsl b/misc/config_tools/xforms/lib.xsl
index 8974cc16a..7adf2dd47 100644
--- a/misc/config_tools/xforms/lib.xsl
+++ b/misc/config_tools/xforms/lib.xsl
@@ -544,6 +544,29 @@
<func:result select="$unique_mapping" />
</func:function>

+ <func:function name="acrn:binary-bdf">
+ <xsl:param name="bdf" />
+ <xsl:variable name="bus" select="substring-before($bdf, ':')" />
+ <xsl:variable name="device" select="substring-before(substring-after($bdf, ':'),
'.')" />
+ <xsl:variable name="function" select="substring-after($bdf, '.')" />
+ <xsl:variable name="serial_bdf">
+ <xsl:text>0b</xsl:text>
+ <xsl:call-template name="hex-to-bin">
+ <xsl:with-param name="s" select="$bus" />
+ <xsl:with-param name="width" select="4" />
+ </xsl:call-template>
+ <xsl:call-template name="hex-to-bin">
+ <xsl:with-param name="s" select="$device" />
+ <xsl:with-param name="width" select="1" />
+ </xsl:call-template>
+ <xsl:call-template name="hex-to-bin">
+ <xsl:with-param name="s" select="$function" />
+ <xsl:with-param name="width" select="3" />
+ </xsl:call-template>
+ </xsl:variable>
+ <func:result select="$serial_bdf" />
+ </func:function>
+
<func:function name="acrn:get-vbdf">
<xsl:param name="vmid" />
<xsl:param name="name" />
--
2.25.1