powerpc/boot: Add OPAL console to epapr wrappers
Subsystems (2)
PATCH v3 1/1 powerpc/boot: Add OPAL console to epapr wrappers
This patch adds an OPAL console backend to the powerpc boot wrapper so that decompression failures inside the wrapper can be reported to the user. This is important since it typically indicates data corruption in the firmware and other nasty things.
Currently this only works when building a little endian kernel. When compiling a 64 bit BE kernel the wrapper is always build 32 bit to be compatible with some 32 bit firmwares. BE support will be added at a later date. Another limitation of this is that only the "raw" type of OPAL console is supported, however machines that provide a hvsi console also provide a raw console so this is not an issue in practice.
---
Changelog:
v2: Added missing files
v3: Added copyright headers to opal.c and opal-calls.S
--- arch/powerpc/boot/Makefile | 4 +- arch/powerpc/boot/opal-calls.S | 58 +++++++++++++++++++++++++ arch/powerpc/boot/opal.c | 97 ++++++++++++++++++++++++++++++++++++++++++ arch/powerpc/boot/ops.h | 1 + arch/powerpc/boot/ppc_asm.h | 4 ++ arch/powerpc/boot/serial.c | 2 + arch/powerpc/boot/types.h | 10 +++++ 7 files changed, 174 insertions(+), 2 deletions(-) create mode 100644 arch/powerpc/boot/opal-calls.S create mode 100644 arch/powerpc/boot/opal.c
arch/powerpc/boot/Makefile +2 -2
@@ -70,7 +70,7 @@ $(addprefix $(obj)/,$(zlib) cuboot-c2k.o gunzip_util.o main.o): \ libfdt := fdt.c fdt_ro.c fdt_wip.c fdt_sw.c fdt_rw.c fdt_strerror.c libfdtheader := fdt.h libfdt.h libfdt_internal.h -$(addprefix $(obj)/,$(libfdt) libfdt-wrapper.o simpleboot.o epapr.o): \ +$(addprefix $(obj)/,$(libfdt) libfdt-wrapper.o simpleboot.o epapr.o opal.o): \ $(addprefix $(obj)/,$(libfdtheader)) src-wlib-y := string.S crt0.S crtsavres.S stdio.c main.c \
@@ -78,7 +78,7 @@ src-wlib-y := string.S crt0.S crtsavres.S stdio.c main.c \ ns16550.c serial.c simple_alloc.c div64.S util.S \ gunzip_util.c elf_util.c $(zlib) devtree.c stdlib.c \ oflib.c ofconsole.c cuboot.c mpsc.c cpm-serial.c \ - uartlite.c mpc52xx-psc.c + uartlite.c mpc52xx-psc.c opal.c opal-calls.S src-wlib-$(CONFIG_40x) += 4xx.c planetcore.c src-wlib-$(CONFIG_44x) += 4xx.c ebony.c bamboo.c src-wlib-$(CONFIG_8xx) += mpc8xx.c planetcore.c fsl-soc.c
arch/powerpc/boot/opal-calls.S new file +58 -0
58 lines not on this page · raw message
arch/powerpc/boot/opal.c new file +97 -0
97 lines not on this page · raw message
arch/powerpc/boot/ops.h +1 -0
@@ -89,6 +89,7 @@ int mpsc_console_init(void *devp, struct serial_console_data *scdp);int cpm_console_init (void *devp,struct serial_console_data *scdp);int mpc5200_psc_console_init (void *devp,struct serial_console_data *scdp);int uartlite_console_init (void *devp,struct serial_console_data *scdp); +int opal_console_init (void *devp,struct serial_console_data *scdp);void *simple_alloc_init (char *base,unsigned long heap_size,unsigned long granularity,unsigned long max_allocs);extern void flush_cache (void *,unsigned long );
arch/powerpc/boot/ppc_asm.h +4 -0
@@ -61,6 +61,10 @@#define SPRN_TBRL 268#define SPRN_TBRU 269 +#define SPRN_HSRR0 0x13A/* Hypervisor Save/Restore 0 */ +#define SPRN_HSRR1 0x13B/* Hypervisor Save/Restore 1 */ + +#define MSR_LE 0x0000000000000001#define FIXUP_ENDIAN \ tdi 0, 0, 0x48;/* Reverse endian of b . + 8 */ \
arch/powerpc/boot/serial.c +2 -0
@@ -132,6 +132,8 @@ int serial_console_init(void)else if (dt_is_compatible (devp,"xlnx,opb-uartlite-1.00.b" ) ||dt_is_compatible (devp,"xlnx,xps-uartlite-1.00.a" )) rc =uartlite_console_init (devp, &serial_cd); +else if (dt_is_compatible (devp,"ibm,opal-console-raw" )) + rc =opal_console_init (devp, &serial_cd);/* Add other serial console driver calls here */
arch/powerpc/boot/types.h +10 -0
@@ -12,6 +12,16 @@ typedef short s16;typedef int s32 ;typedef long long s64 ; +/* required for opal-api.h */ +typedef u8 uint8_t ; +typedef u16 uint16_t ; +typedef u32 uint32_t ; +typedef u64 uint64_t ; +typedef s8 int8_t ; +typedef s16 int16_t ; +typedef s32 int32_t ; +typedef s64 int64_t ; +#define min (x,y) ({ \ typeof(x) _x = (x); \ typeof(y) _y = (y); \
Signature · 1 line
2.5.5
Michael Ellerman
reviewerQuoted 4 lines · Oliver O'Halloran
This patch adds an OPAL console backend to the powerpc boot wrapper so that decompression failures inside the wrapper can be reported to the user. This is important since it typically indicates data corruption in the firmware and other nasty things.
...
Quoted 1 line
I've dropped stable, something this big needs to get some wider testing before it goes to stable.
It was also giving me:
arch/powerpc/boot/opal.c:30:12: warning: ‘opal_con_open’ defined but not used [-Wunused-function]
So I applied the following patch to fix it:
arch/powerpc/boot/opal.c +3 -2
@@ -13,6 +13,8 @@#include <libfdt.h> #include "../include/asm/opal-api.h" +#ifdef __powerpc64__ + /* Global OPAL struct used by opal-call.S */ struct opal { u64 base;
@@ -70,7 +72,6 @@ static void opal_init(void) opal.entry =be64_to_cpu (opal.entry); } -#ifdef __powerpc64__int opal_console_init (void *devp,struct serial_console_data *scdp) {opal_init ();
@@ -94,4 +95,4 @@ int opal_console_init(void *devp, struct serial_console_data *scdp) {return -1 ; } -#endif +#endif /* __powerpc64__ */
cheers
Quoted 12 lines · Oliver O'Halloran
This patch adds an OPAL console backend to the powerpc boot wrapper so that decompression failures inside the wrapper can be reported to the user. This is important since it typically indicates data corruption in the firmware and other nasty things.
Currently this only works when building a little endian kernel. When compiling a 64 bit BE kernel the wrapper is always build 32 bit to be compatible with some 32 bit firmwares. BE support will be added at a later date. Another limitation of this is that only the "raw" type of OPAL console is supported, however machines that provide a hvsi console also provide a raw console so this is not an issue in practice.
Quoted 2 lines
Actually-written-by Benjamin Herrenschmidt <[email protected]>Signed-off-by Oliver O'Halloran <[email protected]>
Applied to powerpc next, thanks.
https://git.kernel.org/powerpc/c/656ad58ef19e2a763fa5c938b2
cheers