Skip to content

Commit 7913ad1

Browse files
Finn Thaingeertu
authored andcommitted
m68k: Multi-platform EARLY_PRINTK
Make the boot console available to more m68k platforms by leveraging the head.S debug console. The boot console is enabled by the "earlyprintk" command line argument which is how most other architectures do this. This is a change of behaviour for the Mac but does not negatively impact the common use-case which is not debugging. This is also a change of behaviour for other platforms because it means the serial port stays quiet when CONFIG_EARLY_PRINTK is not enabled. This is also an improvement for the common use-case. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Tested-by: Stephen N Chivers <schivers@csc.com.au> [Geert: CONSOLE_DEBUG should depend on CONFIG_FONT_SUPPORT] Reported-by: kbuild test robot <fengguang.wu@intel.com> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
1 parent 97f3f68 commit 7913ad1

6 files changed

Lines changed: 84 additions & 56 deletions

File tree

‎Documentation/kernel-parameters.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -892,7 +892,7 @@ bytes respectively. Such letter suffixes can also be entirely omitted.
892892
(mmio) or 32-bit (mmio32).
893893
The options are the same as for ttyS, above.
894894

895-
earlyprintk= [X86,SH,BLACKFIN,ARM]
895+
earlyprintk= [X86,SH,BLACKFIN,ARM,M68k]
896896
earlyprintk=vga
897897
earlyprintk=efi
898898
earlyprintk=xen

‎arch/m68k/Kconfig.debug‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,17 @@ config BOOTPARAM_STRING
1212

1313
config EARLY_PRINTK
1414
bool "Early printk"
15-
depends on MVME16x || MAC
15+
depends on !(SUN3 || M68360 || M68000 || COLDFIRE)
1616
help
1717
Write kernel log output directly to a serial port.
18+
Where implemented, output goes to the framebuffer as well.
19+
PROM console functionality on Sun 3x is not affected by this option.
20+
21+
Pass "earlyprintk" on the kernel command line to get a
22+
boot console.
1823

1924
This is useful for kernel debugging when your machine crashes very
20-
early before the console code is initialized.
25+
early, i.e. before the normal console driver is loaded.
2126
You should normally say N here, unless you want to debug such a crash.
2227

2328
if !MMU

‎arch/m68k/kernel/Makefile‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,5 @@ obj-$(CONFIG_HAS_DMA) += dma.o
2525
obj-$(CONFIG_KEXEC) += machine_kexec.o relocate_kernel.o
2626
obj-$(CONFIG_BOOTINFO_PROC) += bootinfo_proc.o
2727

28+
obj-$(CONFIG_EARLY_PRINTK) += early_printk.o
29+

‎arch/m68k/kernel/early_printk.c‎

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* This file is subject to the terms and conditions of the GNU General Public
3+
* License. See the file "COPYING" in the main directory of this archive
4+
* for more details.
5+
*
6+
* Copyright (c) 2014 Finn Thain
7+
*/
8+
9+
#include <linux/kernel.h>
10+
#include <linux/console.h>
11+
#include <linux/init.h>
12+
#include <linux/string.h>
13+
#include <asm/setup.h>
14+
15+
asmlinkage void __init debug_cons_nputs(const char *s, unsigned n);
16+
17+
static void debug_cons_write(struct console *c,
18+
const char *s, unsigned n)
19+
{
20+
debug_cons_nputs(s, n);
21+
}
22+
23+
static struct console early_console_instance = {
24+
.name = "debug",
25+
.write = debug_cons_write,
26+
.flags = CON_PRINTBUFFER | CON_BOOT,
27+
.index = -1
28+
};
29+
30+
static int __init setup_early_printk(char *buf)
31+
{
32+
/* MVME16x registers an early console after interrupt setup. */
33+
if (MACH_IS_MVME16x)
34+
return 0;
35+
36+
if (early_console || buf)
37+
return 0;
38+
39+
early_console = &early_console_instance;
40+
register_console(early_console);
41+
42+
return 0;
43+
}
44+
early_param("earlyprintk", setup_early_printk);
45+
46+
/*
47+
* debug_cons_nputs() defined in arch/m68k/kernel/head.S cannot be called
48+
* after init sections are discarded (for platforms that use it).
49+
*/
50+
#if !(defined(CONFIG_SUN3) || defined(CONFIG_M68360) || \
51+
defined(CONFIG_M68000) || defined(CONFIG_COLDFIRE))
52+
53+
static int __init unregister_early_console(void)
54+
{
55+
if (!early_console)
56+
return 0;
57+
58+
return unregister_console(early_console);
59+
}
60+
late_initcall(unregister_early_console);
61+
62+
#endif

‎arch/m68k/kernel/head.S‎

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@
221221
* MMU_PRINT: There is a routine built into head.S that can display the
222222
* MMU data structures. It outputs its result through the serial_putc
223223
* interface. So where ever that winds up driving data, that's where the
224-
* mmu struct will appear. On the Macintosh that's typically the console.
224+
* mmu struct will appear.
225225
*
226226
* SERIAL_DEBUG: There are a series of putc() macro statements
227227
* scattered through out the code to give progress of status to the
@@ -249,8 +249,8 @@
249249
* USE_MFP: Use the ST-MFP port (Modem1) for serial debug.
250250
*
251251
* Macintosh constants:
252-
* MAC_USE_SCC_A: Use SCC port A (modem) for serial debug and early console.
253-
* MAC_USE_SCC_B: Use SCC port B (printer) for serial debug and early console.
252+
* MAC_USE_SCC_A: Use SCC port A (modem) for serial debug.
253+
* MAC_USE_SCC_B: Use SCC port B (printer) for serial debug.
254254
*/
255255

256256
#include <linux/linkage.h>
@@ -267,27 +267,17 @@
267267
#include <asm/pgtable.h>
268268
#include <asm/page.h>
269269
#include <asm/asm-offsets.h>
270-
271270
#ifdef CONFIG_MAC
272-
273-
#include <asm/machw.h>
274-
275-
#ifdef CONFIG_FRAMEBUFFER_CONSOLE
276-
#define CONSOLE_DEBUG
271+
# include <asm/machw.h>
277272
#endif
278273

279274
#ifdef CONFIG_EARLY_PRINTK
280-
#define SERIAL_DEBUG
281-
#else
282-
#undef SERIAL_DEBUG
275+
# define SERIAL_DEBUG
276+
# if defined(CONFIG_MAC) && defined(CONFIG_FONT_SUPPORT)
277+
# define CONSOLE_DEBUG
278+
# endif
283279
#endif
284280

285-
#else /* !CONFIG_MAC */
286-
287-
#define SERIAL_DEBUG
288-
289-
#endif /* !CONFIG_MAC */
290-
291281
#undef MMU_PRINT
292282
#undef MMU_NOCACHE_KERNEL
293283
#undef DEBUG
@@ -3213,21 +3203,19 @@ func_start putn,%d0-%d2
32133203

32143204
func_return putn
32153205

3216-
#ifdef CONFIG_MAC
3206+
#ifdef CONFIG_EARLY_PRINTK
32173207
/*
3218-
* mac_early_print
3219-
*
32203208
* This routine takes its parameters on the stack. It then
32213209
* turns around and calls the internal routines. This routine
32223210
* is used by the boot console.
32233211
*
32243212
* The calling parameters are:
3225-
* void mac_early_print(const char *str, unsigned length);
3213+
* void debug_cons_nputs(const char *str, unsigned length)
32263214
*
32273215
* This routine does NOT understand variable arguments only
32283216
* simple strings!
32293217
*/
3230-
ENTRY(mac_early_print)
3218+
ENTRY(debug_cons_nputs)
32313219
moveml %d0/%d1/%a0,%sp@-
32323220
movew %sr,%sp@-
32333221
ori #0x0700,%sr
@@ -3249,7 +3237,7 @@ ENTRY(mac_early_print)
32493237
movew %sp@+,%sr
32503238
moveml %sp@+,%d0/%d1/%a0
32513239
rts
3252-
#endif /* CONFIG_MAC */
3240+
#endif /* CONFIG_EARLY_PRINTK */
32533241

32543242
#if defined(CONFIG_HP300) || defined(CONFIG_APOLLO)
32553243
func_start set_leds,%d0/%a0

‎arch/m68k/mac/config.c‎

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -71,31 +71,6 @@ static void mac_get_model(char *str);
7171
static void mac_identify(void);
7272
static void mac_report_hardware(void);
7373

74-
#ifdef CONFIG_EARLY_PRINTK
75-
asmlinkage void __init mac_early_print(const char *s, unsigned n);
76-
77-
static void __init mac_early_cons_write(struct console *con,
78-
const char *s, unsigned n)
79-
{
80-
mac_early_print(s, n);
81-
}
82-
83-
static struct console __initdata mac_early_cons = {
84-
.name = "early",
85-
.write = mac_early_cons_write,
86-
.flags = CON_PRINTBUFFER | CON_BOOT,
87-
.index = -1
88-
};
89-
90-
int __init mac_unregister_early_cons(void)
91-
{
92-
/* mac_early_print can't be used after init sections are discarded */
93-
return unregister_console(&mac_early_cons);
94-
}
95-
96-
late_initcall(mac_unregister_early_cons);
97-
#endif
98-
9974
static void __init mac_sched_init(irq_handler_t vector)
10075
{
10176
via_init_clock(vector);
@@ -190,10 +165,6 @@ void __init config_mac(void)
190165
mach_beep = mac_mksound;
191166
#endif
192167

193-
#ifdef CONFIG_EARLY_PRINTK
194-
register_console(&mac_early_cons);
195-
#endif
196-
197168
/*
198169
* Determine hardware present
199170
*/

0 commit comments

Comments
 (0)