VTPM mini-os: Mini-os machine specific headers
PATCH 4/12 VTPM mini-os: Mini-os machine specific headers
This patch adds endian.h and byteorder.h to mini-os.
endian.h defines __BYTE_ORDER similar to how its done on linux and __WORDSIZE. byteorder.h defines the standard macros for cpu_to_be and friends for 16,32, and 64 bit.
The bswap inlines in byteswap.h were changed to macros to allow use in some initializer statements. A check is added to check gcc versions to use optimized gcc builtins if they are available.
Signed off by: Matthew Fioravante <[email protected]>
extras/mini-os/include/byteorder.h +36 -0
@@ -0,0 +1,36 @@ +#ifndef MINIOS_BYTEORDER_H +#define MINIOS_BYTEORDER_H + +#include <mini-os/byteswap.h> +#include <mini-os/endian.h> + +#if __BYTE_ORDER == __LITTLE_ENDIAN +#define be16_to_cpu (v) bswap_16(v) +#define be32_to_cpu (v) bswap_32(v) +#define be64_to_cpu (v) bswap_64(v) + +#define le16_to_cpu (v) (v) +#define le32_to_cpu (v) (v) +#define le64_to_cpu (v) (v) + +#else /*__BIG_ENDIAN*/ +#define be16_to_cpu (v) (v) +#define be32_to_cpu (v) (v) +#define be64_to_cpu (v) (v) + +#define le16_to_cpu (v) bswap_16(v) +#define le32_to_cpu (v) bswap_32(v) +#define le64_to_cpu (v) bswap_64(v) + +#endif + +#define cpu_to_be16 (v) be16_to_cpu(v) +#define cpu_to_be32 (v) be32_to_cpu(v) +#define cpu_to_be64 (v) be64_to_cpu(v) + +#define cpu_to_le16 (v) le16_to_cpu(v) +#define cpu_to_le32 (v) le32_to_cpu(v) +#define cpu_to_le64 (v) le64_to_cpu(v) + + +#endif
extras/mini-os/include/byteswap.h +31 -25
61 lines not on this page · raw message
extras/mini-os/include/endian.h +53 -0
53 lines not on this page · raw message
extras/mini-os/include/ia64/arch_endian.h +25 -0
@@ -0,0 +1,25 @@ +/* Copyright (C) 1992, 1996, 1997, 2000, 2008 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with the GNU C Library; if not, write to the Free +Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. */ + +#ifndef ARCH_ENDIAN_H +#error "Do not include arch_endian by itself, include endian.h" +#else + +#define __BYTE_ORDER __LITTLE_ENDIAN + +#endif
extras/mini-os/include/ia64/arch_wordsize.h +1 -0
@@ -0,0 +1 @@ +#define __WORDSIZE 64
extras/mini-os/include/x86/arch_endian.h +25 -0
@@ -0,0 +1,25 @@ +/* Copyright (C) 1992, 1996, 1997, 2000, 2008 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with the GNU C Library; if not, write to the Free +Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. */ + +#ifndef ARCH_ENDIAN_H +#error "Do not include arch_endian by itself, include endian.h" +#else + +#define __BYTE_ORDER __LITTLE_ENDIAN + +#endif
extras/mini-os/include/x86/x86_32/arch_wordsize.h +1 -0
@@ -0,0 +1 @@ +#define __WORDSIZE 32
extras/mini-os/include/x86/x86_64/arch_wordsize.h +2 -0
@@ -0,0 +1,2 @@ +#define __WORDSIZE 64 +#define __WORDSIZE_COMPAT32 1
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
extras/mini-os/include/byteswap.h line 15
Quoted 4 lines · Matthew Fioravante, le Fri 11 Mar 2011 17:44:01 -0500, a écrit :
extras/mini-os/include/byteswap.h +4
-0+/* Use gcc optimized versions if they exist */ +#if __GNUC__ >4 || (__GNUC__ ==4 && __GNUC_MINOR__ >=3 ) +#define bswap_32 (v) __builtin_bswap32(v) +#define bswap_64 (v) __builtin_bswap32(v)
Typo here, right?
Samuel
Which part? The check for gcc version >= 4.3 or the #defines for bswap_XX?
I think its correct
Quoted 8 lines · Samuel Thibault
extras/mini-os/include/byteswap.h line 15
Quoted 4 lines · Matthew Fioravante, le Fri 11 Mar 2011 17:44:01 -0500, a écrit :
extras/mini-os/include/byteswap.h +4
-0+/* Use gcc optimized versions if they exist */ +#if __GNUC__>4 || (__GNUC__ ==4 && __GNUC_MINOR__>=3 ) +#define bswap_32 (v) __builtin_bswap32(v) +#define bswap_64 (v) __builtin_bswap32(v)Typo here, right?
Samuel
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 3 lines · Matthew Fioravante, le Mon 14 Mar 2011 13:02:24 -0400, a écrit :
Which part? The check for gcc version >= 4.3 or the #defines for
bswap_XX?I think its correct
The 64bit #define. If it's really meant to be using __builtin_bswap32 instead of __builtin_bswap64, a comment should say why :)
Quoted 7 lines · Samuel Thibault
Quoted 6 lines
extras/mini-os/include/byteswap.h line 15
Quoted 4 lines · Matthew Fioravante, le Fri 11 Mar 2011 17:44:01 -0500, a écrit :
extras/mini-os/include/byteswap.h +4
-0+/* Use gcc optimized versions if they exist */ +#if __GNUC__>4 || (__GNUC__ ==4 && __GNUC_MINOR__>=3 ) +#define bswap_32 (v) __builtin_bswap32(v) +#define bswap_64 (v) __builtin_bswap32(v)Typo here, right?
Samuel
Quoted 12 lines · Matthew Fioravante
diff -Naur
xen-unstable-trp-sdp-pristine/extras/mini-os/include/endian.hxen-unstable-trp-sdp/extras/mini-os/include/endian.hextras/mini-os/include/endian.h +8
-0@@ -0,0 +1,53 @@ +/* Copyright (C) 1992, 1996, 1997, 2000, 2008 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. +
extras/mini-os/include/endian.h line 18
Quoted 10 lines
extras/mini-os/include/endian.h +10
-0+The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with the GNU C Library; if not, write to the Free +Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. */ +
MiniOS is BSD and we would like to keep it that way.
Quoted 12 lines
diff -Naur
xen-unstable-trp-sdp-pristine/extras/mini-os/include/ia64/arch_endian.hxen-unstable-trp-sdp/extras/mini-os/include/ia64/arch_endian.hextras/mini-os/include/ia64/arch_endian.h +8
-0@@ -0,0 +1,25 @@ +/* Copyright (C) 1992, 1996, 1997, 2000, 2008 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. +
extras/mini-os/include/ia64/arch_endian.h line 18
Quoted 10 lines
extras/mini-os/include/ia64/arch_endian.h +10
-0+The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with the GNU C Library; if not, write to the Free +Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. */ +
ditto
Quoted 11 lines
Quoted 1 line
diff -Naur
xen-unstable-trp-sdp-pristine/extras/mini-os/include/x86/arch_endian.hxen-unstable-trp-sdp/extras/mini-os/include/x86/arch_endian.hextras/mini-os/include/x86/arch_endian.h +7
-0@@ -0,0 +1,25 @@ +/* Copyright (C) 1992, 1996, 1997, 2000, 2008 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version.
extras/mini-os/include/x86/arch_endian.h line 17
Quoted 10 lines
extras/mini-os/include/x86/arch_endian.h +10
-0+ +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with the GNU C Library; if not, write to the Free +Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. */
ditto
I copied the header from the Linux system. Its a very simple header file. Can we just change the license or does our implementation have to significantly different?
Quoted 64 lines · Stefano Stabellini
Quoted 12 lines · Matthew Fioravante
diff -Naur
xen-unstable-trp-sdp-pristine/extras/mini-os/include/endian.hxen-unstable-trp-sdp/extras/mini-os/include/endian.hextras/mini-os/include/endian.h +8
-0@@ -0,0 +1,53 @@ +/* Copyright (C) 1992, 1996, 1997, 2000, 2008 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. +extras/mini-os/include/endian.h line 18
Quoted 10 lines
extras/mini-os/include/endian.h +10
-0+The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with the GNU C Library; if not, write to the Free +Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. */ +MiniOS is BSD and we would like to keep it that way.
Quoted 12 lines
diff -Naur
xen-unstable-trp-sdp-pristine/extras/mini-os/include/ia64/arch_endian.hxen-unstable-trp-sdp/extras/mini-os/include/ia64/arch_endian.hextras/mini-os/include/ia64/arch_endian.h +8
-0@@ -0,0 +1,25 @@ +/* Copyright (C) 1992, 1996, 1997, 2000, 2008 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. +extras/mini-os/include/ia64/arch_endian.h line 18
Quoted 10 lines
extras/mini-os/include/ia64/arch_endian.h +10
-0+The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with the GNU C Library; if not, write to the Free +Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. */ +ditto
Quoted 14 lines
Quoted 1 line
diff -Naur
xen-unstable-trp-sdp-pristine/extras/mini-os/include/x86/arch_endian.hxen-unstable-trp-sdp/extras/mini-os/include/x86/arch_endian.hextras/mini-os/include/x86/arch_endian.h +10
-0@@ -0,0 +1,25 @@ +/* Copyright (C) 1992, 1996, 1997, 2000, 2008 Free Software Foundation, Inc. +This file is part of the GNU C Library. + +The GNU C Library is free software; you can redistribute it and/or +modify it under the terms of the GNU Lesser General Public +License as published by the Free Software Foundation; either +version 2.1 of the License, or (at your option) any later version. + +The GNU C Library is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of
Quoted 9 lines
extras/mini-os/include/x86/arch_endian.h line 17
Quoted 7 lines
extras/mini-os/include/x86/arch_endian.h +7
-0+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +Lesser General Public License for more details. + +You should have received a copy of the GNU Lesser General Public +License along with the GNU C Library; if not, write to the Free +Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +02111-1307 USA. */ ditto
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 3 lines · Matthew Fioravante
I copied the header from the Linux system. Its a very simple header file. Can we just change the license or does our implementation have to significantly different?
You cannot change the license of a Linux header file, but you can copy the header from a BSD system instead.