[OpenBIOS] [PATCH] Introduce FMT_plx for phys_addr_t
Blue Swirl
blauwirbel at gmail.com
Mon Nov 8 19:20:36 CET 2010
On Sun, Nov 7, 2010 at 5:39 PM, Andreas Färber <andreas.faerber at web.de> wrote:
> Define a zero-padded format string to be used for phys_addr_t arguments.
> Introduce PRIx{32,64} macros as needed.
>
> Cc: Mark Cave-Ayland <mark.cave-ayland at siriusit.co.uk>
> Cc: Blue Swirl <blauwirbel at gmail.com>
> Signed-off-by: Andreas Färber <andreas.faerber at web.de>
> ---
> To play safe for bootstrapping and the x86/amd64/ia64 architectures,
> I resorted to PRIx32 / PRIx64. Tested that with a custom printk()
> on ppc. In future patches I'd like to extend their use to the cell
> definitions to avoid lx vs. l uint32_t and llx vs. lx uint64_t issues.
>
> Note that I intentionally used 9 for sparc32 to handle the additional
> nibble. On x86 since we're still using uint32_t I chose 8.
>
> Andreas
Looks OK, except I'd always define PRIx64 etc. for consistency.
> include/arch/amd64/types.h | 3 +++
> include/arch/ia64/types.h | 3 +++
> include/arch/ppc/types.h | 5 +++++
> include/arch/sparc32/types.h | 5 +++++
> include/arch/sparc64/types.h | 4 ++++
> include/arch/x86/types.h | 3 +++
> 6 files changed, 23 insertions(+), 0 deletions(-)
>
> diff --git a/include/arch/amd64/types.h b/include/arch/amd64/types.h
> index 672f02c..44d2182 100644
> --- a/include/arch/amd64/types.h
> +++ b/include/arch/amd64/types.h
> @@ -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;
> diff --git a/include/arch/ia64/types.h b/include/arch/ia64/types.h
> index d423461..3bd2edb 100644
> --- a/include/arch/ia64/types.h
> +++ b/include/arch/ia64/types.h
> @@ -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;
> diff --git a/include/arch/ppc/types.h b/include/arch/ppc/types.h
> index aaa66fc..ed9100c 100644
> --- a/include/arch/ppc/types.h
> +++ b/include/arch/ppc/types.h
> @@ -25,6 +25,9 @@ typedef short int16_t;
> 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 @@ typedef long intptr_t;
> /* 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 */
> diff --git a/include/arch/sparc32/types.h b/include/arch/sparc32/types.h
> index bf96f57..7840e5b 100644
> --- a/include/arch/sparc32/types.h
> +++ b/include/arch/sparc32/types.h
> @@ -25,14 +25,19 @@ typedef short int16_t;
> typedef int int32_t;
> typedef long long int64_t;
> typedef long intptr_t;
> +
> +#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;
> diff --git a/include/arch/sparc64/types.h b/include/arch/sparc64/types.h
> index 8baa5ee..3a235d9 100644
> --- a/include/arch/sparc64/types.h
> +++ b/include/arch/sparc64/types.h
> @@ -25,6 +25,8 @@ typedef short int16_t;
> typedef int int32_t;
> typedef long long int64_t;
> typedef long intptr_t;
> +
> +#define PRIx64 "llx"
glibc uses just "lx" on 64 bit hosts.
> #endif
>
> /* endianess */
> @@ -33,6 +35,8 @@ typedef long intptr_t;
> /* 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;
> diff --git a/include/arch/x86/types.h b/include/arch/x86/types.h
> index 3ba4807..3b1b331 100644
> --- a/include/arch/x86/types.h
> +++ b/include/arch/x86/types.h
> @@ -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;
> --
> 1.7.3
>
>
More information about the OpenBIOS
mailing list