# --- T2-COPYRIGHT-NOTE-BEGIN --- # T2 SDE: architecture/powerpc64/package/*/0260-udbg-lv1-console.patch # Copyright (C) 2019 - 2022 The T2 SDE Project # # This Copyright note is generated by scripts/Create-CopyPatch, # more information can be found in the files COPYING and README. # # This patch file is dual-licensed. It is available under the license the # patched project is licensed under, as long as it is an OpenSource license # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms # of the GNU General Public License version 2 as used by the T2 SDE. # --- T2-COPYRIGHT-NOTE-END --- --- a/arch/powerpc/platforms/ps3/Kconfig +++ b/arch/powerpc/platforms/ps3/Kconfig @@ -237,4 +237,12 @@ config PS3GELIC_UDBG If in doubt, say N here. +config PS3_LV1_CONS_UDBG + bool "PS3 udbg output via LV1 console" + depends on PPC_PS3 + help + Enables udbg early debugging output to LV1 console. + + If in doubt, say N here. + endmenu --- a/arch/powerpc/platforms/ps3/Makefile +++ b/arch/powerpc/platforms/ps3/Makefile @@ -4,6 +4,7 @@ obj-y += interrupt.o exports.o os-area.o obj-y += system-bus.o obj-$(CONFIG_PPC_EARLY_DEBUG_PS3GELIC) += gelic_udbg.o +obj-$(CONFIG_PS3_LV1_CONS_UDBG) += lv1_cons_udbg.o obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_SPU_BASE) += spu.o obj-y += device-init.o --- /dev/null +++ b/arch/powerpc/platforms/ps3/lv1_cons_udbg.c @@ -0,0 +1,58 @@ +/* + * PS3 LV1 Debug Console + * + * Copyright (C) 2024 René Rebe + * Copyright (C) 2013 glevand + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published + * by the Free Software Foundation; version 2 of the License. + * + * This program 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 + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#include +#include +#include + +#define LV1_CONS_ID 1 +#define LV1_CONS_LENGTH 0xff0 + +static int initialized = 0; + +static void lv1_cons_udbg_putc(char ch) +{ + u64 data, written; + int ret; + + if (!initialized) { + ret = lv1_undocumented_function_105(LV1_CONS_ID, 0, 0, + LV1_CONS_LENGTH, LV1_CONS_LENGTH, 0, 0); + if ((ret != 0) && (ret != -7)) + return; + + initialized = 1; + } + + data = ch; + data <<= 56; + + lv1_undocumented_function_107(LV1_CONS_ID, 1, data, 0, 0, 0, &written); + + /* flush to console buffer in LV1 */ + + lv1_undocumented_function_109(LV1_CONS_ID); +} + +void __init udbg_init_ps3_lv1_cons(void) +{ + udbg_putc = lv1_cons_udbg_putc; +} --- a/arch/powerpc/Kconfig.debug +++ b/arch/powerpc/Kconfig.debug @@ -256,6 +256,14 @@ config PPC_EARLY_DEBUG_PS3GELIC Select this to enable early debugging for the PlayStation3 via UDP broadcasts sent out through the Ethernet port. +config PPC_EARLY_DEBUG_PS3_LV1_CONS + bool "Early debugging through the PS3 LV1 console" + depends on PPC_PS3 + select PS3_LV1_CONS_UDBG + help + Select this to enable early debugging for the PlayStation3 via + LV1 debug console. + config PPC_EARLY_DEBUG_OPAL_RAW bool "OPAL raw console" depends on HVC_OPAL --- linux-6.1/arch/powerpc/include/asm/udbg.h.vanilla 2022-12-21 13:04:59.885429328 +0100 +++ linux-6.1/arch/powerpc/include/asm/udbg.h 2022-12-21 13:05:14.743428236 +0100 @@ -50,6 +50,7 @@ void __init udbg_init_memcons(void); void __init udbg_init_ehv_bc(void); void __init udbg_init_ps3gelic(void); +void __init udbg_init_ps3_lv1_cons(void); void __init udbg_init_debug_opal_raw(void); void __init udbg_init_debug_opal_hvsi(void); void __init udbg_init_debug_16550(void); --- a/arch/powerpc/kernel/udbg.c +++ b/arch/powerpc/kernel/udbg.c @@ -63,6 +63,8 @@ void __init udbg_early_init(void) udbg_init_ehv_bc(); #elif defined(CONFIG_PPC_EARLY_DEBUG_PS3GELIC) udbg_init_ps3gelic(); +#elif defined(CONFIG_PPC_EARLY_DEBUG_PS3_LV1_CONS) + udbg_init_ps3_lv1_cons(); #elif defined(CONFIG_PPC_EARLY_DEBUG_OPAL_RAW) udbg_init_debug_opal_raw(); #elif defined(CONFIG_PPC_EARLY_DEBUG_OPAL_HVSI)