From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.65; helo=mga03.intel.com; envelope-from=yonghong.zhu@intel.com; receiver=edk2-devel@lists.01.org Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 3BCA72194D3AE for ; Sat, 27 Oct 2018 04:40:22 -0700 (PDT) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Oct 2018 04:40:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.54,431,1534834800"; d="scan'208";a="269240989" Received: from fmsmsx107.amr.corp.intel.com ([10.18.124.205]) by orsmga005.jf.intel.com with ESMTP; 27 Oct 2018 04:40:21 -0700 Received: from FMSMSX109.amr.corp.intel.com (10.18.116.9) by fmsmsx107.amr.corp.intel.com (10.18.124.205) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sat, 27 Oct 2018 04:40:21 -0700 Received: from shsmsx151.ccr.corp.intel.com (10.239.6.50) by fmsmsx109.amr.corp.intel.com (10.18.116.9) with Microsoft SMTP Server (TLS) id 14.3.319.2; Sat, 27 Oct 2018 04:40:20 -0700 Received: from shsmsx103.ccr.corp.intel.com ([169.254.4.161]) by SHSMSX151.ccr.corp.intel.com ([169.254.3.199]) with mapi id 14.03.0415.000; Sat, 27 Oct 2018 19:40:18 +0800 From: "Zhu, Yonghong" To: "Feng, YunhuaX" , "edk2-devel@lists.01.org" CC: "Gao, Liming" , "Zhu, Yonghong" Thread-Topic: [PATCH 1/1] BaseTools: Sync MdePkg/Library/UefiDevicePathLib/DevicePathToText.c code Thread-Index: AdRtBxg9Jx8KFntERhm30dCk286A0wA3bmOQ Date: Sat, 27 Oct 2018 11:40:18 +0000 Message-ID: References: <47C64442C08CCD4089DC43B6B5E46BC49088A1@shsmsx102.ccr.corp.intel.com> In-Reply-To: <47C64442C08CCD4089DC43B6B5E46BC49088A1@shsmsx102.ccr.corp.intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [PATCH 1/1] BaseTools: Sync MdePkg/Library/UefiDevicePathLib/DevicePathToText.c code X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 27 Oct 2018 11:40:22 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable The code was synced from DevicePathFromText.c, not from DevicePathToText.c So please update the title. Maybe: Sync the DevicePath Function update from= MdePkg, and in the description to add detail function updates. Reviewed-by: Yonghong Zhu Best Regards, Zhu Yonghong -----Original Message----- From: Feng, YunhuaX=20 Sent: Friday, October 26, 2018 4:37 PM To: edk2-devel@lists.01.org Cc: Zhu, Yonghong ; Gao, Liming Subject: [PATCH 1/1] BaseTools: Sync MdePkg/Library/UefiDevicePathLib/Devic= ePathToText.c code Sync MdePkg/Library/UefiDevicePathLib/DevicePathToText.c code Cc: Liming Gao Cc: Yonghong Zhu Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Yunhua Feng --- BaseTools/Source/C/DevicePath/DevicePath.c | 2 +- BaseTools/Source/C/DevicePath/DevicePathFromText.c | 59 ++++++++++++++++++= ---- BaseTools/Source/C/Include/Protocol/DevicePath.h | 2 +- 3 files changed, 50 insertions(+), 13 deletions(-) diff --git a/BaseTools/Source/C/DevicePath/DevicePath.c b/BaseTools/Source/= C/DevicePath/DevicePath.c index 956bbffb5f..356f5f7e24 100644 --- a/BaseTools/Source/C/DevicePath/DevicePath.c +++ b/BaseTools/Source/C/DevicePath/DevicePath.c @@ -23,11 +23,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITH= ER EXPRESS OR IMPLIED. // Utility version information // #define UTILITY_MAJOR_VERSION 0 #define UTILITY_MINOR_VERSION 1 =20 -EFI_GUID gEfiDebugPortDevicePathGuid =3D DEVICE_PATH_MESSAGING_DEBUGPORT; +EFI_GUID gEfiDebugPortProtocolGuid =3D DEVICE_PATH_MESSAGING_DEBUGPORT; EFI_GUID gEfiPcAnsiGuid =3D EFI_PC_ANSI_GUID; EFI_GUID gEfiVT100Guid =3D = EFI_VT_100_GUID; EFI_GUID gEfiVT100PlusGuid =3D EFI_VT_100_PLUS_GUID; EFI= _GUID gEfiVTUTF8Guid =3D EFI_VT_UTF8_GUID; EFI_GUID gEfiUartDevicePathGuid= =3D EFI_UART_DEVICE_PATH_GUID; diff --git a/BaseTools/Source/C/DevicePath/= DevicePathFromText.c b/BaseTools/Source/C/DevicePath/DevicePathFromText.c index bb74e2e170..555efa1acd 100644 --- a/BaseTools/Source/C/DevicePath/DevicePathFromText.c +++ b/BaseTools/Source/C/DevicePath/DevicePathFromText.c @@ -762,11 +762,20 @@ DevPathFromTextAcpiExp ( ACPI_EXTENDED_DP, Length ); =20 AcpiEx->HID =3D EisaIdFromText (HIDStr); - AcpiEx->CID =3D EisaIdFromText (CIDStr); + // + // According to UEFI spec, the CID parametr is optional and has a defaul= t value of 0. + // So when the CID parametr is not specified or specified as 0 in the te= xt device node. + // Set the CID to 0 in the ACPI extension device path structure. + // + if (*CIDStr =3D=3D L'\0' || *CIDStr =3D=3D L'0') { + AcpiEx->CID =3D 0; + } else { + AcpiEx->CID =3D EisaIdFromText (CIDStr); } AcpiEx->UID =3D 0; =20 AsciiStr =3D (CHAR8 *) ((UINT8 *)AcpiEx + sizeof (ACPI_EXTENDED_HID_DEVI= CE_PATH)); // // HID string is NULL @@ -1601,19 +1610,19 @@ DevPathFromTextEmmc ( EFI_DEVICE_PATH_PROTOCOL * DevPathFromTextDebugPort ( CHAR16 *TextDeviceNode ) { - VENDOR_DEFINED_MESSAGING_DEVICE_PATH *Vend; + VENDOR_DEVICE_PATH *Vend; =20 - Vend =3D (VENDOR_DEFINED_MESSAGING_DEVICE_PATH *) CreateDeviceNode ( + Vend =3D (VENDOR_DEVICE_PATH *) CreateDeviceNode ( MESSAGING_DEVICE_PATH, MSG_VENDOR_DP, - (UINT16) sizeof (VENDO= R_DEFINED_MESSAGING_DEVICE_PATH) + (UINT16) sizeof (VENDO= R_DEVICE_PATH) ); =20 - CopyGuid (&Vend->Guid, &gEfiDebugPortDevicePathGuid); + CopyGuid (&Vend->Guid, &gEfiDebugPortProtocolGuid); =20 return (EFI_DEVICE_PATH_PROTOCOL *) Vend; } =20 /** @@ -1904,26 +1913,46 @@ ConvertFromTextUsbClass ( =20 VIDStr =3D GetNextParamStr (&TextDeviceNode); PIDStr =3D GetNextParamStr (&TextDeviceNode); if (UsbClassText->ClassExist) { ClassStr =3D GetNextParamStr (&TextDeviceNode); - UsbClass->DeviceClass =3D (UINT8) Strtoi (ClassStr); + if (*ClassStr =3D=3D L'\0') { + UsbClass->DeviceClass =3D 0xFF; + } else { + UsbClass->DeviceClass =3D (UINT8) Strtoi (ClassStr); + } } else { UsbClass->DeviceClass =3D UsbClassText->Class; } if (UsbClassText->SubClassExist) { SubClassStr =3D GetNextParamStr (&TextDeviceNode); - UsbClass->DeviceSubClass =3D (UINT8) Strtoi (SubClassStr); + if (*SubClassStr =3D=3D L'\0') { + UsbClass->DeviceSubClass =3D 0xFF; + } else { + UsbClass->DeviceSubClass =3D (UINT8) Strtoi (SubClassStr); + } } else { UsbClass->DeviceSubClass =3D UsbClassText->SubClass; } =20 ProtocolStr =3D GetNextParamStr (&TextDeviceNode); =20 - UsbClass->VendorId =3D (UINT16) Strtoi (VIDStr); - UsbClass->ProductId =3D (UINT16) Strtoi (PIDStr); - UsbClass->DeviceProtocol =3D (UINT8) Strtoi (ProtocolStr); + if (*VIDStr =3D=3D L'\0') { + UsbClass->VendorId =3D 0xFFFF; + } else { + UsbClass->VendorId =3D (UINT16) Strtoi (VIDStr); + } + if (*PIDStr =3D=3D L'\0') { + UsbClass->ProductId =3D 0xFFFF; + } else { + UsbClass->ProductId =3D (UINT16) Strtoi (PIDStr); + } + if (*ProtocolStr =3D=3D L'\0') { + UsbClass->DeviceProtocol =3D 0xFF; + } else { + UsbClass->DeviceProtocol =3D (UINT8) Strtoi (ProtocolStr); + } =20 return (EFI_DEVICE_PATH_PROTOCOL *) UsbClass; } =20 =20 @@ -3259,11 +3288,19 @@ DevPathFromTextSata ( MESSAGING_DEVICE_PATH, MSG_SATA_DP, (UINT16) sizeof (SATA_DEVICE_PATH) ); Sata->HBAPortNumber =3D (UINT16) Strtoi (Param1); - Sata->PortMultiplierPortNumber =3D (UINT16) Strtoi (Param2); + + // + // According to UEFI spec, if PMPN is not provided, the default is 0xFFF= F + // + if (*Param2 =3D=3D L'\0' ) { + Sata->PortMultiplierPortNumber =3D 0xFFFF; + } else { + Sata->PortMultiplierPortNumber =3D (UINT16) Strtoi (Param2); + } Sata->Lun =3D (UINT16) Strtoi (Param3); =20 return (EFI_DEVICE_PATH_PROTOCOL *) Sata; } =20 diff --git a/BaseTools/Source/C/Include/Protocol/DevicePath.h b/BaseTools/S= ource/C/Include/Protocol/DevicePath.h index 68bb37e479..0295582cbd 100644 --- a/BaseTools/Source/C/Include/Protocol/DevicePath.h +++ b/BaseTools/Source/C/Include/Protocol/DevicePath.h @@ -1378,11 +1378,11 @@ extern EFI_GUID gEfiDebugPortVariableGuid; =20 // // DebugPort device path definitions... // #define DEVICE_PATH_MESSAGING_DEBUGPORT EFI_DEBUGPORT_PROTOCOL_GUID -extern EFI_GUID gEfiDebugPortDevicePathGuid; +extern EFI_GUID gEfiDebugPortProtocolGuid; =20 typedef struct { EFI_DEVICE_PATH_PROTOCOL Header; EFI_GUID Guid; } DEBUGPORT_DEVICE_PATH; --=20 2.12.2.windows.2