powerpc/pmac: Early debug output on screen on 64-bit macs
PATCH 1/1 powerpc/pmac: Early debug output on screen on 64-bit macs
We have a bunch of CONFIG_PPC_EARLY_DEBUG_* options that are intended for bringup/debug only. They hard wire a machine specific udbg backend very early on (before we even probe the platform), and use whatever tricks are available on each machine/cpu to be able to get some kind of output out there early on.
So far, on powermac with no serial ports, we have CONFIG_PPC_EARLY_DEBUG_BOOTX to use the low-level btext engine on the screen, but it doesn't do much, at least on 64-bit. It only really gets enabled after the platform has been probed and the MMU enabled.
This adds a way to enable it much earlier. From prom_init.c (while still running with Open Firmware), we grab the screen details and set things up using the physical address of the frame buffer.
Then btext itself uses the "rm_ci" feature of the 970 processor (Real Mode Cache Inhibited) to access it while in real mode.
We need to do a little bit of reorg of the btext code to inline things better, in order to limit how much we touch memory while in this mode as the consequences might be ... interesting.
This successfully allowed me to debug problems early on with the G5 (related to gold being broken vs. ppc64 kernels).
---
arch/powerpc/include/asm/btext.h +1 -0
@@ -13,6 +13,7 @@ extern void btext_update_display(unsigned long phys, int width, int height,extern void btext_setup_display (int width,int height,int depth,int pitch,unsigned long address);extern void btext_prepare_BAT (void ); +extern void btext_map (void );extern void btext_unmap (void );extern void btext_drawchar (char c);
arch/powerpc/kernel/btext.c +139 -115
321 lines not on this page · raw message
arch/powerpc/kernel/misc_64.S +31 -0
@@ -247,6 +247,37 @@ _GLOBAL(__bswapdi2) blr #if defined(CONFIG_PPC_PMAC) || defined(CONFIG_PPC_MAPLE) + +_GLOBAL(rmci_on) + sync + isync + li r3,0x100 + rldicl r3,r3,32,0 + mfspr r5,SPRN_HID4 + or r5,r5,r3 + sync + mtspr SPRN_HID4,r5 + isync + slbia + isync + sync + blr + +_GLOBAL(rmci_off) + sync + isync + li r3,0x100 + rldicl r3,r3,32,0 + mfspr r5,SPRN_HID4 + andc r5,r5,r3 + sync + mtspr SPRN_HID4,r5 + isync + slbia + isync + sync + blr + /* * Do an IO access in real mode */
arch/powerpc/kernel/prom_init.c +16 -0
@@ -2082,6 +2082,22 @@ static void __init prom_check_displays(void) clut[2]) != 0)break ;#endif /* CONFIG_LOGO_LINUX_CLUT224 */ + +#ifdef CONFIG_PPC_EARLY_DEBUG_BOOTX +if (prom_getprop (node,"linux,boot-display" ,NULL ,0 ) != +PROM_ERROR ) { +u32 width, height, pitch, addr; + +prom_printf ("Setting btext !\n" ); +prom_getprop (node,"width" , &width,4 ); +prom_getprop (node,"height" , &height,4 ); +prom_getprop (node,"linebytes" , &pitch,4 ); +prom_getprop (node,"address" , &addr,4 ); +prom_printf ("W=%d H=%d LB=%d addr=0x%x\n" , + width, height, pitch, addr); +btext_setup_display (width, height,8 , pitch, addr); + } +#endif /* CONFIG_PPC_EARLY_DEBUG_BOOTX */ } }
arch/powerpc/kernel/prom_init_check.sh +2 -1
@@ -22,7 +22,8 @@ __secondary_hold_acknowledge __secondary_hold_spinloop __start strcmp strcpy strlcpy strlen strncmp strstr logo_linux_clut224 reloc_got2 kernstart_addr memstart_addr linux_banner _stext opal_query_takeover opal_do_takeover opal_enter_rtas opal_secondary_entry -boot_command_line __prom_init_toc_start __prom_init_toc_end" +boot_command_line __prom_init_toc_start __prom_init_toc_end +btext_setup_display" NM="$1" OBJ="$2"
arch/powerpc/kernel/setup_64.c +13 -1
@@ -10,7 +10,7 @@* 2 of the License, or (at your option) any later version. */ -#undef DEBUG +#define DEBUG #include <linux/export.h> #include <linux/string.h>
@@ -237,6 +237,18 @@ void __init early_setup(unsigned long dt_ptr)reserve_hugetlb_gpages ();DBG (" <- early_setup()\n" ); + +#ifdef CONFIG_PPC_EARLY_DEBUG_BOOTX +/* +* This needs to be done *last* (after the above DBG() even) +* +* Right after we return from this function, we turn on the MMU +* which means the real-mode access trick that btext does will +* no longer work, it needs to switch to using a real MMU +* mapping. This call will ensure that it does +*/ +btext_map (); +#endif /* CONFIG_PPC_EARLY_DEBUG_BOOTX */ }#ifdef CONFIG_SMP
arch/powerpc/kernel/setup_64.c line 13
Quoted 8 lines · Benjamin Herrenschmidt
arch/powerpc/kernel/setup_64.c +1
-1@@ -10,7 +10,7 @@* 2 of the License, or (at your option) any later version. */ -#undef DEBUG +#define DEBUG
Ooops... sent the wrong version. Will send an updated one later, if there are no other comments.
Cheers,
Ben.
Quoted 7 lines · Benjamin Herrenschmidt
Quoted 6 lines · Benjamin Herrenschmidt
arch/powerpc/kernel/setup_64.c +0
-0@@ -10,7 +10,7 @@* 2 of the License, or (at your option) any later version. */
Quoted 5 lines
arch/powerpc/kernel/setup_64.c line 13
Quoted 2 lines
arch/powerpc/kernel/setup_64.c +1
-1-#undef DEBUG +#define DEBUG Ooops... sent the wrong version. Will send an updated one later, if there are no other comments.
Looks like you merged the version with #define DEBUG.
cheers
Quoted 3 lines · Michael Ellerman
Looks like you merged the version with #define DEBUG.
Yes, it looks like I've been distracted, I'll remove it again (or you can send a patch :-)
Cheers,
Ben.