Author: afaerber Date: Mon Nov 8 22:12:36 2010 New Revision: 949 URL: http://tracker.coreboot.org/trac/openbios/changeset/949
Log: Introduce FMT_plx for phys_addr_t
Define a zero-padded format string to be used for phys_addr_t arguments. Introduce PRIx{32,64} macros as needed.
v2: * Also define PRIx32 for sparc32 and sparc64, requested by Blue.
Cc: Mark Cave-Ayland mark.cave-ayland@siriusit.co.uk Cc: Blue Swirl blauwirbel@gmail.com Signed-off-by: Andreas Färber andreas.faerber@web.de
Modified: trunk/openbios-devel/include/arch/amd64/types.h trunk/openbios-devel/include/arch/ia64/types.h trunk/openbios-devel/include/arch/ppc/types.h trunk/openbios-devel/include/arch/sparc32/types.h trunk/openbios-devel/include/arch/sparc64/types.h trunk/openbios-devel/include/arch/x86/types.h
Modified: trunk/openbios-devel/include/arch/amd64/types.h ============================================================================== --- trunk/openbios-devel/include/arch/amd64/types.h Sun Nov 7 19:08:41 2010 (r948) +++ trunk/openbios-devel/include/arch/amd64/types.h Mon Nov 8 22:12:36 2010 (r949) @@ -17,8 +17,11 @@ #include "autoconf.h"
/* physical address */ + typedef uint64_t phys_addr_t;
+#define FMT_plx "%016" PRIx64 + /* cell based types */
typedef long long cell;
Modified: trunk/openbios-devel/include/arch/ia64/types.h ============================================================================== --- trunk/openbios-devel/include/arch/ia64/types.h Sun Nov 7 19:08:41 2010 (r948) +++ trunk/openbios-devel/include/arch/ia64/types.h Mon Nov 8 22:12:36 2010 (r949) @@ -18,8 +18,11 @@ #include <endian.h>
/* physical address */ + typedef uint64_t phys_addr_t;
+#define FMT_plx "%016" PRIx64 + /* cell based types */
typedef int64_t cell;
Modified: trunk/openbios-devel/include/arch/ppc/types.h ============================================================================== --- trunk/openbios-devel/include/arch/ppc/types.h Sun Nov 7 19:08:41 2010 (r948) +++ trunk/openbios-devel/include/arch/ppc/types.h Mon Nov 8 22:12:36 2010 (r949) @@ -25,6 +25,9 @@ typedef int int32_t; typedef long long int64_t; typedef long intptr_t; + +#define PRIx32 "x" +#define PRIx64 "llx" #endif
/* endianess */ @@ -33,8 +36,10 @@ /* physical address */ #if defined(__powerpc64__) typedef uint64_t phys_addr_t; +#define FMT_plx "%016" PRIx64 #else typedef uint32_t phys_addr_t; +#define FMT_plx "%08" PRIx32 #endif
/* cell based types */
Modified: trunk/openbios-devel/include/arch/sparc32/types.h ============================================================================== --- trunk/openbios-devel/include/arch/sparc32/types.h Sun Nov 7 19:08:41 2010 (r948) +++ trunk/openbios-devel/include/arch/sparc32/types.h Mon Nov 8 22:12:36 2010 (r949) @@ -25,14 +25,20 @@ typedef int int32_t; typedef long long int64_t; typedef long intptr_t; + +#define PRIx32 "x" +#define PRIx64 "llx" #endif
/* endianess */ #include "autoconf.h"
/* physical address: 36 bits */ + typedef uint64_t phys_addr_t;
+#define FMT_plx "%09" PRIx64 + /* cell based types */
typedef int32_t cell;
Modified: trunk/openbios-devel/include/arch/sparc64/types.h ============================================================================== --- trunk/openbios-devel/include/arch/sparc64/types.h Sun Nov 7 19:08:41 2010 (r948) +++ trunk/openbios-devel/include/arch/sparc64/types.h Mon Nov 8 22:12:36 2010 (r949) @@ -25,6 +25,9 @@ typedef int int32_t; typedef long long int64_t; typedef long intptr_t; + +#define PRIx32 "x" +#define PRIx64 "llx" #endif
/* endianess */ @@ -33,6 +36,8 @@ /* physical address */ typedef uint64_t phys_addr_t;
+#define FMT_plx "%016" PRIx64 + /* cell based types */ typedef long long cell; typedef unsigned long long ucell;
Modified: trunk/openbios-devel/include/arch/x86/types.h ============================================================================== --- trunk/openbios-devel/include/arch/x86/types.h Sun Nov 7 19:08:41 2010 (r948) +++ trunk/openbios-devel/include/arch/x86/types.h Mon Nov 8 22:12:36 2010 (r949) @@ -18,8 +18,11 @@ #include "autoconf.h"
/* physical address: XXX theoretically 36 bits for PAE */ + typedef uint32_t phys_addr_t;
+#define FMT_plx "%08" PRIx32 + /* cell based types */
typedef int32_t cell;
On Mon, Nov 8, 2010 at 9:12 PM, repository service svn@openbios.org wrote:
Author: afaerber Date: Mon Nov 8 22:12:36 2010 New Revision: 949 URL: http://tracker.coreboot.org/trac/openbios/changeset/949
Log: Introduce FMT_plx for phys_addr_t
Define a zero-padded format string to be used for phys_addr_t arguments. Introduce PRIx{32,64} macros as needed.
v2:
- Also define PRIx32 for sparc32 and sparc64, requested by Blue.
What I meant was that all PRIx* macros should be defined for all architectures for consistency.
Am 08.11.2010 um 22:17 schrieb Blue Swirl:
On Mon, Nov 8, 2010 at 9:12 PM, repository service svn@openbios.org wrote:
Author: afaerber Date: Mon Nov 8 22:12:36 2010 New Revision: 949 URL: http://tracker.coreboot.org/trac/openbios/changeset/949
Log: Introduce FMT_plx for phys_addr_t
Define a zero-padded format string to be used for phys_addr_t arguments. Introduce PRIx{32,64} macros as needed.
v2:
- Also define PRIx32 for sparc32 and sparc64, requested by Blue.
What I meant was that all PRIx* macros should be defined for all architectures for consistency.
So in particular you mean PRIx16 and PRIx8? ppc, sparc32 and sparc64 are in fact consistent now in defining both PRIx32 and PRIx64.
x86, amd64 and ia64 use the system headers, so we shouldn't define any such macro there, just like we don't do in the bootstrap code path.
Andreas
On Mon, Nov 8, 2010 at 9:31 PM, Andreas Färber andreas.faerber@web.de wrote:
Am 08.11.2010 um 22:17 schrieb Blue Swirl:
On Mon, Nov 8, 2010 at 9:12 PM, repository service svn@openbios.org wrote:
Author: afaerber Date: Mon Nov 8 22:12:36 2010 New Revision: 949 URL: http://tracker.coreboot.org/trac/openbios/changeset/949
Log: Introduce FMT_plx for phys_addr_t
Define a zero-padded format string to be used for phys_addr_t arguments. Introduce PRIx{32,64} macros as needed.
v2:
- Also define PRIx32 for sparc32 and sparc64, requested by Blue.
What I meant was that all PRIx* macros should be defined for all architectures for consistency.
So in particular you mean PRIx16 and PRIx8? ppc, sparc32 and sparc64 are in fact consistent now in defining both PRIx32 and PRIx64.
I don't think PRIx16 or PRIx8 will be used, maybe not even PRIx32. But for consistency, all architectures should have PRIx64 defined. If PRIx32 is useful, then it should also be available always.
x86, amd64 and ia64 use the system headers, so we shouldn't define any such macro there, just like we don't do in the bootstrap code path.
That's a bug. System headers may not be used, except for Unix target. Consider for example 'errno', which may be defined by system headers as a macro evaluating to a function call to libc: # define errno (*__errno_location ())