Skip to content

Commit 93edd02

Browse files
Finn Thaingeertu
authored andcommitted
m68k/mac: early console
Revive the old mac_serial_print() routine as mac_early_print(). mac_serial_print() did not function because it did not use the right offsets for its stack arguments. Fix this and make compilation conditional on CONFIG_EARLY_PRINTK instead of the obscure MAC_SERIAL_DEBUG macro. Give mac_early_print() a new string length parameter to fit the early console API. Send output to the framebuffer as well as serial ports. Change the line rate to 38400 baud to match the default for the real (pmac_zilog) serial console. Signed-off-by: Finn Thain <fthain@telegraphics.com.au> Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
1 parent f999489 commit 93edd02

3 files changed

Lines changed: 89 additions & 59 deletions

File tree

‎arch/m68k/Kconfig.debug‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ source "lib/Kconfig.debug"
44

55
config EARLY_PRINTK
66
bool "Early printk" if EMBEDDED
7-
depends on MVME16x
7+
depends on MVME16x || MAC
88
default y
99
help
1010
Write kernel log output directly to a serial port.

‎arch/m68k/kernel/head.S‎

Lines changed: 59 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -250,9 +250,8 @@
250250
* USE_MFP: Use the ST-MFP port (Modem1) for serial debug.
251251
*
252252
* Macintosh constants:
253-
* MAC_SERIAL_DEBUG: Turns on serial debug output for the Macintosh.
254-
* MAC_USE_SCC_A: Use the SCC port A (modem) for serial debug.
255-
* MAC_USE_SCC_B: Use the SCC port B (printer) for serial debug (default).
253+
* MAC_USE_SCC_A: Use SCC port A (modem) for serial debug and early console.
254+
* MAC_USE_SCC_B: Use SCC port B (printer) for serial debug and early console.
256255
*/
257256

258257
#include <linux/linkage.h>
@@ -268,33 +267,25 @@
268267

269268
#include <asm/machw.h>
270269

271-
/*
272-
* Macintosh console support
273-
*/
274-
275270
#ifdef CONFIG_FRAMEBUFFER_CONSOLE
276271
#define CONSOLE
277272
#define CONSOLE_PENGUIN
278273
#endif
279274

280-
/*
281-
* Macintosh serial debug support; outputs boot info to the printer
282-
* and/or modem serial ports
283-
*/
284-
#undef MAC_SERIAL_DEBUG
275+
#ifdef CONFIG_EARLY_PRINTK
276+
#define SERIAL_DEBUG
277+
#else
278+
#undef SERIAL_DEBUG
279+
#endif
285280

286-
/*
287-
* Macintosh serial debug port selection; define one or both;
288-
* requires MAC_SERIAL_DEBUG to be defined
289-
*/
290-
#define MAC_USE_SCC_A /* Macintosh modem serial port */
291-
#define MAC_USE_SCC_B /* Macintosh printer serial port */
281+
#else /* !CONFIG_MAC */
292282

293-
#endif /* CONFIG_MAC */
283+
#define SERIAL_DEBUG
284+
285+
#endif /* !CONFIG_MAC */
294286

295287
#undef MMU_PRINT
296288
#undef MMU_NOCACHE_KERNEL
297-
#define SERIAL_DEBUG
298289
#undef DEBUG
299290

300291
/*
@@ -655,11 +646,11 @@ ENTRY(__start)
655646
lea %pc@(L(mac_rowbytes)),%a1
656647
movel %a0@,%a1@
657648

658-
#ifdef MAC_SERIAL_DEBUG
649+
#ifdef SERIAL_DEBUG
659650
get_bi_record BI_MAC_SCCBASE
660651
lea %pc@(L(mac_sccbase)),%a1
661652
movel %a0@,%a1@
662-
#endif /* MAC_SERIAL_DEBUG */
653+
#endif
663654

664655
#if 0
665656
/*
@@ -1427,7 +1418,7 @@ L(mmu_fixup_done):
14271418
subl %d0,L(console_font)
14281419
subl %d0,L(console_font_data)
14291420
#endif
1430-
#ifdef MAC_SERIAL_DEBUG
1421+
#ifdef SERIAL_DEBUG
14311422
orl #0x50000000,L(mac_sccbase)
14321423
#endif
14331424
1:
@@ -1917,7 +1908,7 @@ mmu_030_print:
19171908
jbne 30b
19181909

19191910
mmu_print_done:
1920-
puts "\n\n"
1911+
puts "\n"
19211912

19221913
func_return mmu_print
19231914

@@ -2768,7 +2759,7 @@ L(scc_initable_mac):
27682759
.byte 9,0 /* no interrupts */
27692760
.byte 10,0 /* NRZ */
27702761
.byte 11,0x50 /* use baud rate generator */
2771-
.byte 12,10,13,0 /* 9600 baud */
2762+
.byte 12,1,13,0 /* 38400 baud */
27722763
.byte 14,1 /* Baud rate generator enable */
27732764
.byte 3,0xc1 /* enable receiver */
27742765
.byte 5,0xea /* enable transmitter */
@@ -2906,10 +2897,12 @@ func_start serial_init,%d0/%d1/%a0/%a1
29062897
#endif
29072898
#ifdef CONFIG_MAC
29082899
is_not_mac(L(serial_init_not_mac))
2909-
#ifdef MAC_SERIAL_DEBUG
2910-
#if !defined(MAC_USE_SCC_A) && !defined(MAC_USE_SCC_B)
2911-
#define MAC_USE_SCC_B
2912-
#endif
2900+
2901+
#ifdef SERIAL_DEBUG
2902+
/* You may define either or both of these. */
2903+
#define MAC_USE_SCC_A /* Modem port */
2904+
#define MAC_USE_SCC_B /* Printer port */
2905+
29132906
#define mac_scc_cha_b_ctrl_offset 0x0
29142907
#define mac_scc_cha_a_ctrl_offset 0x2
29152908
#define mac_scc_cha_b_data_offset 0x4
@@ -2940,7 +2933,7 @@ func_start serial_init,%d0/%d1/%a0/%a1
29402933
jra 7b
29412934
8:
29422935
#endif /* MAC_USE_SCC_B */
2943-
#endif /* MAC_SERIAL_DEBUG */
2936+
#endif /* SERIAL_DEBUG */
29442937

29452938
jra L(serial_init_done)
29462939
L(serial_init_not_mac):
@@ -3011,7 +3004,7 @@ func_start serial_putc,%d0/%d1/%a0/%a1
30113004
#ifdef CONFIG_MAC
30123005
is_not_mac(5f)
30133006

3014-
#ifdef MAC_SERIAL_DEBUG
3007+
#ifdef SERIAL_DEBUG
30153008

30163009
#ifdef MAC_USE_SCC_A
30173010
movel %pc@(L(mac_sccbase)),%a1
@@ -3029,7 +3022,7 @@ func_start serial_putc,%d0/%d1/%a0/%a1
30293022
moveb %d0,%a1@(mac_scc_cha_b_data_offset)
30303023
#endif /* MAC_USE_SCC_B */
30313024

3032-
#endif /* MAC_SERIAL_DEBUG */
3025+
#endif /* SERIAL_DEBUG */
30333026

30343027
jra L(serial_putc_done)
30353028
5:
@@ -3248,33 +3241,39 @@ func_return putn
32483241

32493242
#ifdef CONFIG_MAC
32503243
/*
3251-
* mac_serial_print
3244+
* mac_early_print
32523245
*
32533246
* This routine takes its parameters on the stack. It then
3254-
* turns around and calls the internal routine. This routine
3255-
* is used until the Linux console driver initializes itself.
3247+
* turns around and calls the internal routines. This routine
3248+
* is used by the boot console.
32563249
*
32573250
* The calling parameters are:
3258-
* void mac_serial_print(const char *str);
3251+
* void mac_early_print(const char *str, unsigned length);
32593252
*
32603253
* This routine does NOT understand variable arguments only
32613254
* simple strings!
32623255
*/
3263-
ENTRY(mac_serial_print)
3264-
moveml %d0/%a0,%sp@-
3265-
#if 1
3266-
move %sr,%sp@-
3256+
ENTRY(mac_early_print)
3257+
moveml %d0/%d1/%a0,%sp@-
3258+
movew %sr,%sp@-
32673259
ori #0x0700,%sr
3268-
#endif
3269-
movel %sp@(10),%a0 /* fetch parameter */
3260+
movel %sp@(18),%a0 /* fetch parameter */
3261+
movel %sp@(22),%d1 /* fetch parameter */
32703262
jra 2f
3271-
1: serial_putc %d0
3272-
2: moveb %a0@+,%d0
3273-
jne 1b
3274-
#if 1
3275-
move %sp@+,%sr
3263+
1:
3264+
#ifdef CONSOLE
3265+
console_putc %d0
32763266
#endif
3277-
moveml %sp@+,%d0/%a0
3267+
#ifdef SERIAL_DEBUG
3268+
serial_putc %d0
3269+
#endif
3270+
subq #1,%d1
3271+
2: jeq 3f
3272+
moveb %a0@+,%d0
3273+
jne 1b
3274+
3:
3275+
movew %sp@+,%sr
3276+
moveml %sp@+,%d0/%d1/%a0
32783277
rts
32793278
#endif /* CONFIG_MAC */
32803279

@@ -3409,10 +3408,10 @@ func_start console_put_stats,%a0/%d7
34093408
* a0 = pointer to boot_info
34103409
* d7 = value of boot_info fields
34113410
*/
3412-
puts "\nMacLinux\n\n"
3411+
puts "\nMacLinux\n"
34133412

34143413
#ifdef SERIAL_DEBUG
3415-
puts " vidaddr:"
3414+
puts "\n vidaddr:"
34163415
putn %pc@(L(mac_videobase)) /* video addr. */
34173416

34183417
puts "\n _stext:"
@@ -3423,19 +3422,21 @@ func_start console_put_stats,%a0/%d7
34233422
lea %pc@(_end),%a0
34243423
putn %a0
34253424

3426-
puts "\ncpuid:"
3425+
puts "\n cpuid:"
34273426
putn %pc@(L(cputype))
3428-
putc '\n'
34293427

3430-
#ifdef MAC_SERIAL_DEBUG
3428+
# ifdef CONFIG_MAC
3429+
puts "\n sccbase:"
34313430
putn %pc@(L(mac_sccbase))
3431+
# endif
3432+
# ifdef MMU_PRINT
34323433
putc '\n'
3433-
#endif
3434-
# if defined(MMU_PRINT)
34353434
jbsr mmu_print_machine_cpu_types
3436-
# endif /* MMU_PRINT */
3435+
# endif
34373436
#endif /* SERIAL_DEBUG */
34383437

3438+
putc '\n'
3439+
34393440
func_return console_put_stats
34403441

34413442
#ifdef CONSOLE_PENGUIN
@@ -3896,11 +3897,11 @@ L(mac_dimensions):
38963897
.long 0
38973898
L(mac_rowbytes):
38983899
.long 0
3899-
#ifdef MAC_SERIAL_DEBUG
3900+
#ifdef SERIAL_DEBUG
39003901
L(mac_sccbase):
39013902
.long 0
3902-
#endif /* MAC_SERIAL_DEBUG */
39033903
#endif
3904+
#endif /* CONFIG_MAC */
39043905

39053906
#if defined (CONFIG_APOLLO)
39063907
LSRB0 = 0x10412

‎arch/m68k/mac/config.c‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,31 @@ 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+
7499
static void __init mac_sched_init(irq_handler_t vector)
75100
{
76101
via_init_clock(vector);
@@ -164,6 +189,10 @@ void __init config_mac(void)
164189
mach_beep = mac_mksound;
165190
#endif
166191

192+
#ifdef CONFIG_EARLY_PRINTK
193+
register_console(&mac_early_cons);
194+
#endif
195+
167196
/*
168197
* Determine hardware present
169198
*/

0 commit comments

Comments
 (0)