public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: James Wang <James.Wang@rohde-schwarz.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] instruction "xchgb" for x86_64
Date: Wed, 14 Aug 2019 05:08:49 +0000	[thread overview]
Message-ID: <08e714dd67a24fb29ce5ef395a45f8e5@rohde-schwarz.com> (raw)

Hi Simon,

This is James and am working on u-boot to bring back MinGW tool chain for cross compiling host tools for Windows on Linux. After complete the code, I plan to generate a patch for community review.

During work, I face an compiling error in file <arch/x86/include/asm/byteorder.h> with macro CONFIG_IS_ENABLED. After some background study, seems this macro should not be available when compiling host tools.

After check history, it's from 909780506773a9b09ae88cb267dbfa6a8d0caa7b on 2017-01-16 22:04:04, Below is the log message

   x86: Fix up byteorder.h for x86_64

    Remove the very old x86 code and add support for 64-bit.

    Signed-off-by: Simon Glass <sjg at chromium.org<mailto:sjg@chromium.org>>
Reviewed-by: Bin Meng bmeng.cn at gmail.com<mailto:bmeng.cn@gmail.com>

Below are the relevant changes.

+#define _constant_swab16(x) ((__u16)(                                             \
+      (((__u16)(x) & (__u16)0x00ffU) << 8) |                            \
+      (((__u16)(x) & (__u16)0xff00U) >> 8)))
+
static __inline__ __u16 ___arch__swab16(__u16 x)
{
+#if CONFIG_IS_ENABLED(X86_64)
+      return _constant_swab16(x);
+#else
       __asm__("xchgb %b0,%h0"                   /* swap bytes                */ \
                   : "=q" (x) \
                   :  "0" (x)); \
                   return x;
+#endif
}

I am not familiar with x86 instructions and not understand the purpose of this change, is it because instruction "xchgb" not available on 64-bit architecture or something else?

Thanks!


Best regards
James Wang Jinmin

Rohde & Schwarz Asia Pte Ltd
9 Changi Business Park Vista, #01-01, Singapore 486 041
DID: 65-6307 0374    Fax: 65-6307 0300
[ONE logo 2018_email]

Privileged/Confidential information may be contained in this message.
If you are not the intended recipient, Please notify the sender immediately and
you must not use the message for any purpose nor disclose it to anyone.
http://www.rohde-schwarz.com/sg
P Please consider the environment before printing this email.  <http://www.rohde-schwarz.com.sg/>



-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 13947 bytes
Desc: image001.png
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190814/c2c329c8/attachment.png>

             reply	other threads:[~2019-08-14  5:08 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-14  5:08 James Wang [this message]
2019-08-14  7:35 ` [U-Boot] instruction "xchgb" for x86_64 Bin Meng
2019-08-14 16:13   ` Simon Glass
  -- strict thread matches above, loose matches on Subject: below --
2019-08-14  9:59 James Wang
2019-08-16  7:58 James Wang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=08e714dd67a24fb29ce5ef395a45f8e5@rohde-schwarz.com \
    --to=james.wang@rohde-schwarz.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox