All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] instruction "xchgb" for x86_64
@ 2019-08-14  9:59 James Wang
  0 siblings, 0 replies; 5+ messages in thread
From: James Wang @ 2019-08-14  9:59 UTC (permalink / raw)
  To: u-boot

Hi Bin
 
>> 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.

>Do you mean cross compiling U-Boot's mkimage tool for Windows on Linux using gcc-mingw-w64? Do you want to support building U-Boot on Windows as well?

Yes, I am compiling with MinGW-w64, more specifically x86_64-w64-mingw32-gcc on Linux. I don't have setup to build host tools on Windows for now. Maybe I could have a try.
 
 
Best regards
James Wang Jinmin

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] instruction "xchgb" for x86_64
@ 2019-08-16  7:58 James Wang
  0 siblings, 0 replies; 5+ messages in thread
From: James Wang @ 2019-08-16  7:58 UTC (permalink / raw)
  To: u-boot


> 
> Hi,
> 
> (James please can you use plain-text email for the mailing list?)
  
OK. Thanks Simon for pointing out this. I am using outlook, so most likely will have "newline" difference. Hope can find a way out for this.
 
> 
> For chromebook_link64 I get:
> 
> output: '/usr/local/google/home/sjg/cosarm/src/third_party/u-
> boot/files/arch/x86/include/asm/byteorder.h:
> Assembler messages:
> /usr/local/google/home/sjg/cosarm/src/third_party/u-
> boot/files/arch/x86/include/asm/byteorder.h:22:
> Error: register type mismatch for `xchg'
> make[2]: *** [/usr/local/google/home/sjg/cosarm/src/third_party/u-
> boot/files/scripts/Makefile.build:278:
> net/tftp.o] Error 1
> make[2]: *** Waiting for unfinished jobs....
> /usr/local/google/home/sjg/cosarm/src/third_party/u-boot/files/net/net.c:
> In function 'net_process_received_packet':
> /usr/local/google/home/sjg/cosarm/src/third_party/u-
> boot/files/net/net.c:1324:1:
> error: extended registers have no high halves  }  ^
> /usr/local/google/home/sjg/cosarm/src/third_party/u-
> boot/files/arch/x86/include/asm/byteorder.h:
> Assembler messages:
> /usr/local/google/home/sjg/cosarm/src/third_party/u-
> boot/files/arch/x86/include/asm/byteorder.h:22:
> Error: register type mismatch for `xchg'
> /usr/local/google/home/sjg/cosarm/src/third_party/u-
> boot/files/arch/x86/include/asm/byteorder.h:22:
> Error: register type mismatch for `xchg'
> /usr/local/google/home/sjg/cosarm/src/third_party/u-
> boot/files/arch/x86/include/asm/byteorder.h:22:
> Error: register type mismatch for `xchg'
> make[2]: *** [/usr/local/google/home/sjg/cosarm/src/third_party/u-
> boot/files/scripts/Makefile.build:278:
> net/net.o] Error 1
> make[1]: *** [/usr/local/google/home/sjg/cosarm/src/third_party/u-
> boot/files/Makefile:1588:
> net] Error 2
> make[1]: *** Waiting for unfinished jobs....
> make: *** [Makefile:148: sub-make] Error 2
> 
> Perhaps there is another way to fix this?
> 

I tested two toolchains: 
1. With gcc version 7.3-win32 20180312 (the MinGW-w64 cross compiling), it can assemble the xchgb without error.
2. With gcc version 7.3.0 (Ubuntu 7.3.0-27ubuntu1~18.04), it uses /usr/include/x86_64-linux-gnu/asm/byteorder.h, (not the one in uboot), and that file is only to include the <little_endian.h> file

As the assembler you use reports error for xchgb  (no matter what's the cause), we may use ONLY the C version of implementation and remove the assembly version and relevant  CONFIG_IS_ENABLED checking (if performance is not critical here)?

How do you think, Simon and Bin?

Best regards
James Wang Jinmin

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] instruction "xchgb" for x86_64
  2019-08-14  7:35 ` Bin Meng
@ 2019-08-14 16:13   ` Simon Glass
  0 siblings, 0 replies; 5+ messages in thread
From: Simon Glass @ 2019-08-14 16:13 UTC (permalink / raw)
  To: u-boot

Hi,

(James please can you use plain-text email for the mailing list?)

On Wed, 14 Aug 2019 at 01:35, Bin Meng <bmeng.cn@gmail.com> wrote:
>
> Hi James,
>
> On Wed, Aug 14, 2019 at 1:08 PM James Wang <James.Wang@rohde-schwarz.com> wrote:
>>
>> 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.
>
>
> Do you mean cross compiling U-Boot's mkimage tool for Windows on Linux using gcc-mingw-w64? Do you want to support building U-Boot on Windows as well?
>
>>
>>
>>
>> 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@chromium.org>
>>
>> Reviewed-by: Bin Meng bmeng.cn at 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?
>
>
> I can't remember the details of why Simon changed this. xchgb is available in 64-bit. We probably need revert this change, Simon?

For chromebook_link64 I get:

output: '/usr/local/google/home/sjg/cosarm/src/third_party/u-boot/files/arch/x86/include/asm/byteorder.h:
Assembler messages:
/usr/local/google/home/sjg/cosarm/src/third_party/u-boot/files/arch/x86/include/asm/byteorder.h:22:
Error: register type mismatch for `xchg'
make[2]: *** [/usr/local/google/home/sjg/cosarm/src/third_party/u-boot/files/scripts/Makefile.build:278:
net/tftp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
/usr/local/google/home/sjg/cosarm/src/third_party/u-boot/files/net/net.c:
In function 'net_process_received_packet':
/usr/local/google/home/sjg/cosarm/src/third_party/u-boot/files/net/net.c:1324:1:
error: extended registers have no high halves
 }
 ^
/usr/local/google/home/sjg/cosarm/src/third_party/u-boot/files/arch/x86/include/asm/byteorder.h:
Assembler messages:
/usr/local/google/home/sjg/cosarm/src/third_party/u-boot/files/arch/x86/include/asm/byteorder.h:22:
Error: register type mismatch for `xchg'
/usr/local/google/home/sjg/cosarm/src/third_party/u-boot/files/arch/x86/include/asm/byteorder.h:22:
Error: register type mismatch for `xchg'
/usr/local/google/home/sjg/cosarm/src/third_party/u-boot/files/arch/x86/include/asm/byteorder.h:22:
Error: register type mismatch for `xchg'
make[2]: *** [/usr/local/google/home/sjg/cosarm/src/third_party/u-boot/files/scripts/Makefile.build:278:
net/net.o] Error 1
make[1]: *** [/usr/local/google/home/sjg/cosarm/src/third_party/u-boot/files/Makefile:1588:
net] Error 2
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:148: sub-make] Error 2

Perhaps there is another way to fix this?

Regards,
Simon

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] instruction "xchgb" for x86_64
  2019-08-14  5:08 James Wang
@ 2019-08-14  7:35 ` Bin Meng
  2019-08-14 16:13   ` Simon Glass
  0 siblings, 1 reply; 5+ messages in thread
From: Bin Meng @ 2019-08-14  7:35 UTC (permalink / raw)
  To: u-boot

Hi James,

On Wed, Aug 14, 2019 at 1:08 PM James Wang <James.Wang@rohde-schwarz.com>
wrote:

> 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.
>

Do you mean cross compiling U-Boot's mkimage tool for Windows on Linux
using gcc-mingw-w64? Do you want to support building U-Boot on Windows as
well?


>
>
> 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 <sjg@chromium.org>>*
>
> *Reviewed-by: Bin Meng bmeng.cn at gmail.com <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?
>

I can't remember the details of why Simon changed this. xchgb is available
in 64-bit. We probably need revert this change, Simon?

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [U-Boot] instruction "xchgb" for x86_64
@ 2019-08-14  5:08 James Wang
  2019-08-14  7:35 ` Bin Meng
  0 siblings, 1 reply; 5+ messages in thread
From: James Wang @ 2019-08-14  5:08 UTC (permalink / raw)
  To: u-boot

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>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2019-08-16  7:58 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-14  9:59 [U-Boot] instruction "xchgb" for x86_64 James Wang
  -- strict thread matches above, loose matches on Subject: below --
2019-08-16  7:58 James Wang
2019-08-14  5:08 James Wang
2019-08-14  7:35 ` Bin Meng
2019-08-14 16:13   ` Simon Glass

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.