summaryrefslogtreecommitdiff
path: root/arch/s390/kernel/early_printk.c
blob: cefe020a3be3819947c385ee8ac0f0f47c4cd9ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// SPDX-License-Identifier: GPL-2.0
/*
 *    Copyright IBM Corp. 2017
 */

#include <linux/console.h>
#include <linux/kernel.h>
#include <linux/init.h>
#include <asm/setup.h>
#include <asm/sclp.h>

static void sclp_early_write(struct console *con, const char *s, unsigned int len)
{
	__sclp_early_printk(s, len);
}

static struct console sclp_early_console = {
	.name  = "earlysclp",
	.write = sclp_early_write,
	.flags = CON_PRINTBUFFER | CON_BOOT,
	.index = -1,
};

void __init register_early_console(void)
{
	if (early_console)
		return;
	if (!sclp.has_linemode && !sclp.has_vt220)
		return;
	early_console = &sclp_early_console;
	register_console(early_console);
}

static int __init setup_early_printk(char *buf)
{
	if (early_console)
		return 0;
	/* Accept only "earlyprintk" and "earlyprintk=sclp" */
	if (buf && !str_has_prefix(buf, "sclp"))
		return 0;
	register_early_console();
	return 0;
}
early_param("earlyprintk", setup_early_printk);