diff options
author | Cédric Le Goater <clg@fr.ibm.com> | 2014-04-24 11:23:28 +0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2014-04-28 11:35:35 +0400 |
commit | 926e6940f54313813d177b5cfb9ec31a441cd259 (patch) | |
tree | 018b48b91e6556ef7dc184ae1545d050e57719a6 /arch/powerpc/boot | |
parent | 163bed77b97c2f1e941641f81566da8ea647deda (diff) | |
download | linux-926e6940f54313813d177b5cfb9ec31a441cd259.tar.xz |
powerpc/boot: Add byteswapping routines in oflib
Values will need to be byte-swapped when calling prom (big endian) from
a little endian boot wrapper.
Signed-off-by: Cédric Le Goater <clg@fr.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Diffstat (limited to 'arch/powerpc/boot')
-rw-r--r-- | arch/powerpc/boot/of.h | 3 | ||||
-rw-r--r-- | arch/powerpc/boot/ofconsole.c | 6 | ||||
-rw-r--r-- | arch/powerpc/boot/oflib.c | 22 |
3 files changed, 18 insertions, 13 deletions
diff --git a/arch/powerpc/boot/of.h b/arch/powerpc/boot/of.h index 5da03d9b9463..40d95bf7402b 100644 --- a/arch/powerpc/boot/of.h +++ b/arch/powerpc/boot/of.h @@ -20,4 +20,7 @@ void of_console_init(void); typedef u32 __be32; +#define cpu_to_be32(x) (x) +#define be32_to_cpu(x) (x) + #endif /* _PPC_BOOT_OF_H_ */ diff --git a/arch/powerpc/boot/ofconsole.c b/arch/powerpc/boot/ofconsole.c index ce0e02424453..8b754702460a 100644 --- a/arch/powerpc/boot/ofconsole.c +++ b/arch/powerpc/boot/ofconsole.c @@ -18,7 +18,7 @@ #include "of.h" -static void *of_stdout_handle; +static unsigned int of_stdout_handle; static int of_console_open(void) { @@ -27,8 +27,10 @@ static int of_console_open(void) if (((devp = of_finddevice("/chosen")) != NULL) && (of_getprop(devp, "stdout", &of_stdout_handle, sizeof(of_stdout_handle)) - == sizeof(of_stdout_handle))) + == sizeof(of_stdout_handle))) { + of_stdout_handle = be32_to_cpu(of_stdout_handle); return 0; + } return -1; } diff --git a/arch/powerpc/boot/oflib.c b/arch/powerpc/boot/oflib.c index 3b0c9458504f..0f72b1a42133 100644 --- a/arch/powerpc/boot/oflib.c +++ b/arch/powerpc/boot/oflib.c @@ -42,13 +42,13 @@ int of_call_prom(const char *service, int nargs, int nret, ...) struct prom_args args; va_list list; - args.service = ADDR(service); - args.nargs = nargs; - args.nret = nret; + args.service = cpu_to_be32(ADDR(service)); + args.nargs = cpu_to_be32(nargs); + args.nret = cpu_to_be32(nret); va_start(list, nret); for (i = 0; i < nargs; i++) - args.args[i] = va_arg(list, prom_arg_t); + args.args[i] = cpu_to_be32(va_arg(list, prom_arg_t)); va_end(list); for (i = 0; i < nret; i++) @@ -57,7 +57,7 @@ int of_call_prom(const char *service, int nargs, int nret, ...) if (prom(&args) < 0) return -1; - return (nret > 0)? args.args[nargs]: 0; + return (nret > 0) ? be32_to_cpu(args.args[nargs]) : 0; } static int of_call_prom_ret(const char *service, int nargs, int nret, @@ -67,13 +67,13 @@ static int of_call_prom_ret(const char *service, int nargs, int nret, struct prom_args args; va_list list; - args.service = ADDR(service); - args.nargs = nargs; - args.nret = nret; + args.service = cpu_to_be32(ADDR(service)); + args.nargs = cpu_to_be32(nargs); + args.nret = cpu_to_be32(nret); va_start(list, rets); for (i = 0; i < nargs; i++) - args.args[i] = va_arg(list, prom_arg_t); + args.args[i] = cpu_to_be32(va_arg(list, prom_arg_t)); va_end(list); for (i = 0; i < nret; i++) @@ -84,9 +84,9 @@ static int of_call_prom_ret(const char *service, int nargs, int nret, if (rets != (void *) 0) for (i = 1; i < nret; ++i) - rets[i-1] = args.args[nargs+i]; + rets[i-1] = be32_to_cpu(args.args[nargs+i]); - return (nret > 0)? args.args[nargs]: 0; + return (nret > 0) ? be32_to_cpu(args.args[nargs]) : 0; } /* returns true if s2 is a prefix of s1 */ |