<div dir="ltr"><div>Hi,</div><div><br></div><div>Hao, you are 100% correct. It seems that not only is SourceLevelDebugPkg using a different CRC-16 algorithm, my CalculateCrc16()'s lookup table is incorrect.</div><div><br></div><div>I'll re-submit a v2 that fixes these issues.</div><div>Sorry for the trouble.</div><div><br></div><div>Thanks,</div><div>Pedro<br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Mar 28, 2022 at 1:14 AM Wu, Hao A <<a href="mailto:hao.a.wu@intel.com">hao.a.wu@intel.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hello,<br>
<br>
My local test shows that the results between the old (SourceLevelDebugPkg) & new (MdePkg) CRC16 implementation are different:<br>
<br>
UINT8  Array[16] = {1,2,3,4,5,6,7,8,8,7,6,5,4,3,2,1};<br>
UINT16 a, b;    <br>
a = CalculateCrc16New(Array, sizeof(Array), 0xFFFF);<br>
b = CalculateCrc16Old(Array, sizeof(Array), 0xFFFF);<br>
<br>
Result:<br>
a = 0x0af5<br>
b = 0x2778<br>
<br>
My take is that for the SourceLevelDebugPkg case, the CRC16 result should be the same (at BIOS host side). Otherwise, the target side will have issue for the CRC check.<br>
<br>
Best Regards,<br>
Hao Wu<br>
<br>
> -----Original Message-----<br>
> From: Pedro Falcato <<a href="mailto:pedro.falcato@gmail.com" target="_blank">pedro.falcato@gmail.com</a>><br>
> Sent: Sunday, March 27, 2022 8:58 AM<br>
> To: <a href="mailto:devel@edk2.groups.io" target="_blank">devel@edk2.groups.io</a><br>
> Cc: Wu, Hao A <<a href="mailto:hao.a.wu@intel.com" target="_blank">hao.a.wu@intel.com</a>><br>
> Subject: [PATCH 2/2] SourceLevelDebugPkg/DebugAgent: Delete the CRC16<br>
> implementation<br>
> <br>
> BZ: <a href="https://bugzilla.tianocore.org/show_bug.cgi?id=3871" rel="noreferrer" target="_blank">https://bugzilla.tianocore.org/show_bug.cgi?id=3871</a><br>
> <br>
> Deletes the CRC16 implementation as CalculateCrc16() is being merged into<br>
> BaseLib.<br>
> <br>
> Cc: Hao A Wu <<a href="mailto:hao.a.wu@intel.com" target="_blank">hao.a.wu@intel.com</a>><br>
> Signed-off-by: Pedro Falcato <<a href="mailto:pedro.falcato@gmail.com" target="_blank">pedro.falcato@gmail.com</a>><br>
> ---<br>
>  .../DebugAgent/DebugAgentCommon/DebugAgent.c  | 35 -------------------<br>
>  1 file changed, 35 deletions(-)<br>
> <br>
> diff --git<br>
> a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgen<br>
> t.c<br>
> b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgen<br>
> t.c<br>
> index a1e61a6ef90e..62c6a235d425 100644<br>
> ---<br>
> a/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgen<br>
> t.c<br>
> +++<br>
> b/SourceLevelDebugPkg/Library/DebugAgent/DebugAgentCommon/DebugAgen<br>
> t<br>
> +++ .c<br>
> @@ -126,41 +126,6 @@ GLOBAL_REMOVE_IF_UNREFERENCED<br>
> EFI_VECTOR_HANDOFF_INFO  mVectorHandoffInfoDebugAg<br>
> <br>
>  GLOBAL_REMOVE_IF_UNREFERENCED UINTN  mVectorHandoffInfoCount =<br>
> sizeof (mVectorHandoffInfoDebugAgent) / sizeof<br>
> (EFI_VECTOR_HANDOFF_INFO);<br>
> <br>
> -/**<br>
> -  Calculate CRC16 for target data.<br>
> -<br>
> -  @param[in]  Data              The target data.<br>
> -  @param[in]  DataSize          The target data size.<br>
> -  @param[in]  Crc               Initial CRC.<br>
> -<br>
> -  @return UINT16     The CRC16 value.<br>
> -<br>
> -**/<br>
> -UINT16<br>
> -CalculateCrc16 (<br>
> -  IN UINT8   *Data,<br>
> -  IN UINTN   DataSize,<br>
> -  IN UINT16  Crc<br>
> -  )<br>
> -{<br>
> -  UINTN  Index;<br>
> -  UINTN  BitIndex;<br>
> -<br>
> -  for (Index = 0; Index < DataSize; Index++) {<br>
> -    Crc ^= (UINT16)Data[Index];<br>
> -    for (BitIndex = 0; BitIndex < 8; BitIndex++) {<br>
> -      if ((Crc & 0x8000) != 0) {<br>
> -        Crc <<= 1;<br>
> -        Crc  ^= 0x1021;<br>
> -      } else {<br>
> -        Crc <<= 1;<br>
> -      }<br>
> -    }<br>
> -  }<br>
> -<br>
> -  return Crc;<br>
> -}<br>
> -<br>
>  /**<br>
>    Read IDT entry to check if IDT entries are setup by Debug Agent.<br>
> <br>
> --<br>
> 2.35.1<br>
<br>
</blockquote></div><br clear="all"><br>-- <br><div dir="ltr" class="gmail_signature"><div dir="ltr">Pedro Falcato</div></div>


 <div width="1" style="color:white;clear:both">_._,_._,_</div> <hr>   Groups.io Links:<p>   You receive all messages sent to this group.    <p> <a target="_blank" href="https://edk2.groups.io/g/devel/message/88084">View/Reply Online (#88084)</a> |    |  <a target="_blank" href="https://groups.io/mt/90054844/1813853">Mute This Topic</a>  | <a href="https://edk2.groups.io/g/devel/post">New Topic</a><br>    <a href="https://edk2.groups.io/g/devel/editsub/1813853">Your Subscription</a> | <a href="mailto:devel+owner@edk2.groups.io">Contact Group Owner</a> |  <a href="https://edk2.groups.io/g/devel/unsub">Unsubscribe</a>  [edk2-devel-archive@redhat.com]<br> <div width="1" style="color:white;clear:both">_._,_._,_</div>