License cleanup: add SPDX GPL-2.0 license identifier to files with no license
Many source files in the tree are missing licensing information, which
makes it harder for compliance tools to determine the correct license.
By default all files without license information are under the default
license of the kernel, which is GPL version 2.
Update the files which contain no license information with the 'GPL-2.0'
SPDX license identifier. The SPDX identifier is a legally binding
shorthand, which can be used instead of the full boiler plate text.
This patch is based on work done by Thomas Gleixner and Kate Stewart and
Philippe Ombredanne.
How this work was done:
Patches were generated and checked against linux-4.14-rc6 for a subset of
the use cases:
- file had no licensing information it it.
- file was a */uapi/* one with no licensing information in it,
- file was a */uapi/* one with existing licensing information,
Further patches will be generated in subsequent months to fix up cases
where non-standard license headers were used, and references to license
had to be inferred by heuristics based on keywords.
The analysis to determine which SPDX License Identifier to be applied to
a file was done in a spreadsheet of side by side results from of the
output of two independent scanners (ScanCode & Windriver) producing SPDX
tag:value files created by Philippe Ombredanne. Philippe prepared the
base worksheet, and did an initial spot review of a few 1000 files.
The 4.13 kernel was the starting point of the analysis with 60,537 files
assessed. Kate Stewart did a file by file comparison of the scanner
results in the spreadsheet to determine which SPDX license identifier(s)
to be applied to the file. She confirmed any determination that was not
immediately clear with lawyers working with the Linux Foundation.
Criteria used to select files for SPDX license identifier tagging was:
- Files considered eligible had to be source code files.
- Make and config files were included as candidates if they contained >5
lines of source
- File already had some variant of a license header in it (even if <5
lines).
All documentation files were explicitly excluded.
The following heuristics were used to determine which SPDX license
identifiers to apply.
- when both scanners couldn't find any license traces, file was
considered to have no license information in it, and the top level
COPYING file license applied.
For non */uapi/* files that summary was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 11139
and resulted in the first patch in this series.
If that file was a */uapi/* path one, it was "GPL-2.0 WITH
Linux-syscall-note" otherwise it was "GPL-2.0". Results of that was:
SPDX license identifier # files
---------------------------------------------------|-------
GPL-2.0 WITH Linux-syscall-note 930
and resulted in the second patch in this series.
- if a file had some form of licensing information in it, and was one
of the */uapi/* ones, it was denoted with the Linux-syscall-note if
any GPL family license was found in the file or had no licensing in
it (per prior point). Results summary:
SPDX license identifier # files
---------------------------------------------------|------
GPL-2.0 WITH Linux-syscall-note 270
GPL-2.0+ WITH Linux-syscall-note 169
((GPL-2.0 WITH Linux-syscall-note) OR BSD-2-Clause) 21
((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) 17
LGPL-2.1+ WITH Linux-syscall-note 15
GPL-1.0+ WITH Linux-syscall-note 14
((GPL-2.0+ WITH Linux-syscall-note) OR BSD-3-Clause) 5
LGPL-2.0+ WITH Linux-syscall-note 4
LGPL-2.1 WITH Linux-syscall-note 3
((GPL-2.0 WITH Linux-syscall-note) OR MIT) 3
((GPL-2.0 WITH Linux-syscall-note) AND MIT) 1
and that resulted in the third patch in this series.
- when the two scanners agreed on the detected license(s), that became
the concluded license(s).
- when there was disagreement between the two scanners (one detected a
license but the other didn't, or they both detected different
licenses) a manual inspection of the file occurred.
- In most cases a manual inspection of the information in the file
resulted in a clear resolution of the license that should apply (and
which scanner probably needed to revisit its heuristics).
- When it was not immediately clear, the license identifier was
confirmed with lawyers working with the Linux Foundation.
- If there was any question as to the appropriate license identifier,
the file was flagged for further research and to be revisited later
in time.
In total, over 70 hours of logged manual review was done on the
spreadsheet to determine the SPDX license identifiers to apply to the
source files by Kate, Philippe, Thomas and, in some cases, confirmation
by lawyers working with the Linux Foundation.
Kate also obtained a third independent scan of the 4.13 code base from
FOSSology, and compared selected files where the other two scanners
disagreed against that SPDX file, to see if there was new insights. The
Windriver scanner is based on an older version of FOSSology in part, so
they are related.
Thomas did random spot checks in about 500 files from the spreadsheets
for the uapi headers and agreed with SPDX license identifier in the
files he inspected. For the non-uapi files Thomas did random spot checks
in about 15000 files.
In initial set of patches against 4.14-rc6, 3 files were found to have
copy/paste license identifier errors, and have been fixed to reflect the
correct identifier.
Additionally Philippe spent 10 hours this week doing a detailed manual
inspection and review of the 12,461 patched files from the initial patch
version early this week with:
- a full scancode scan run, collecting the matched texts, detected
license ids and scores
- reviewing anything where there was a license detected (about 500+
files) to ensure that the applied SPDX license was correct
- reviewing anything where there was no detection but the patch license
was not GPL-2.0 WITH Linux-syscall-note to ensure that the applied
SPDX license was correct
This produced a worksheet with 20 files needing minor correction. This
worksheet was then exported into 3 different .csv files for the
different types of files to be modified.
These .csv files were then reviewed by Greg. Thomas wrote a script to
parse the csv files and add the proper SPDX tag to the file, in the
format that the file expected. This script was further refined by Greg
based on the output to detect more types of files automatically and to
distinguish between header and source .c files (which need different
comment types.) Finally Greg ran the script using the .csv files to
generate the patches.
Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org>
Reviewed-by: Philippe Ombredanne <pombredanne@nexb.com>
Reviewed-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-11-01 22:07:57 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
2007-10-11 17:17:24 +08:00
|
|
|
#include <linux/console.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/string.h>
|
|
|
|
#include <linux/screen_info.h>
|
2008-07-25 08:29:40 +08:00
|
|
|
#include <linux/usb/ch9.h>
|
|
|
|
#include <linux/pci_regs.h>
|
|
|
|
#include <linux/pci_ids.h>
|
|
|
|
#include <linux/errno.h>
|
2020-06-09 12:32:42 +08:00
|
|
|
#include <linux/pgtable.h>
|
2007-10-11 17:17:24 +08:00
|
|
|
#include <asm/io.h>
|
|
|
|
#include <asm/processor.h>
|
|
|
|
#include <asm/fcntl.h>
|
2007-10-16 08:13:22 +08:00
|
|
|
#include <asm/setup.h>
|
2007-10-11 17:17:24 +08:00
|
|
|
#include <xen/hvc-console.h>
|
2008-07-25 08:29:40 +08:00
|
|
|
#include <asm/pci-direct.h>
|
|
|
|
#include <asm/fixmap.h>
|
|
|
|
#include <linux/usb/ehci_def.h>
|
2017-03-21 16:01:31 +08:00
|
|
|
#include <linux/usb/xhci-dbgp.h>
|
2015-01-20 20:07:57 +08:00
|
|
|
#include <asm/pci_x86.h>
|
2005-04-17 06:20:36 +08:00
|
|
|
|
2007-10-11 17:17:24 +08:00
|
|
|
/* Simple VGA output */
|
|
|
|
#define VGABASE (__ISA_IO_base + 0xb8000)
|
|
|
|
|
|
|
|
static int max_ypos = 25, max_xpos = 80;
|
2008-02-29 20:26:56 +08:00
|
|
|
static int current_ypos = 25, current_xpos;
|
2007-10-11 17:17:24 +08:00
|
|
|
|
|
|
|
static void early_vga_write(struct console *con, const char *str, unsigned n)
|
|
|
|
{
|
|
|
|
char c;
|
|
|
|
int i, k, j;
|
|
|
|
|
|
|
|
while ((c = *str++) != '\0' && n-- > 0) {
|
|
|
|
if (current_ypos >= max_ypos) {
|
|
|
|
/* scroll 1 line up */
|
|
|
|
for (k = 1, j = 0; k < max_ypos; k++, j++) {
|
|
|
|
for (i = 0; i < max_xpos; i++) {
|
|
|
|
writew(readw(VGABASE+2*(max_xpos*k+i)),
|
|
|
|
VGABASE + 2*(max_xpos*j + i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (i = 0; i < max_xpos; i++)
|
|
|
|
writew(0x720, VGABASE + 2*(max_xpos*j + i));
|
|
|
|
current_ypos = max_ypos-1;
|
|
|
|
}
|
2010-05-21 10:04:31 +08:00
|
|
|
#ifdef CONFIG_KGDB_KDB
|
|
|
|
if (c == '\b') {
|
|
|
|
if (current_xpos > 0)
|
|
|
|
current_xpos--;
|
|
|
|
} else if (c == '\r') {
|
|
|
|
current_xpos = 0;
|
|
|
|
} else
|
|
|
|
#endif
|
2007-10-11 17:17:24 +08:00
|
|
|
if (c == '\n') {
|
|
|
|
current_xpos = 0;
|
|
|
|
current_ypos++;
|
|
|
|
} else if (c != '\r') {
|
|
|
|
writew(((0x7 << 8) | (unsigned short) c),
|
|
|
|
VGABASE + 2*(max_xpos*current_ypos +
|
|
|
|
current_xpos++));
|
|
|
|
if (current_xpos >= max_xpos) {
|
|
|
|
current_xpos = 0;
|
|
|
|
current_ypos++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct console early_vga_console = {
|
|
|
|
.name = "earlyvga",
|
|
|
|
.write = early_vga_write,
|
|
|
|
.flags = CON_PRINTBUFFER,
|
|
|
|
.index = -1,
|
|
|
|
};
|
|
|
|
|
|
|
|
/* Serial functions loosely based on a similar package from Klaus P. Gerlicher */
|
|
|
|
|
2015-01-20 20:07:57 +08:00
|
|
|
static unsigned long early_serial_base = 0x3f8; /* ttyS0 */
|
2007-10-11 17:17:24 +08:00
|
|
|
|
|
|
|
#define XMTRDY 0x20
|
|
|
|
|
|
|
|
#define DLAB 0x80
|
|
|
|
|
|
|
|
#define TXR 0 /* Transmit register (WRITE) */
|
|
|
|
#define RXR 0 /* Receive register (READ) */
|
|
|
|
#define IER 1 /* Interrupt Enable */
|
|
|
|
#define IIR 2 /* Interrupt ID */
|
|
|
|
#define FCR 2 /* FIFO control */
|
|
|
|
#define LCR 3 /* Line control */
|
|
|
|
#define MCR 4 /* Modem control */
|
|
|
|
#define LSR 5 /* Line Status */
|
|
|
|
#define MSR 6 /* Modem Status */
|
|
|
|
#define DLL 0 /* Divisor Latch Low */
|
|
|
|
#define DLH 1 /* Divisor latch High */
|
|
|
|
|
2015-01-20 20:07:57 +08:00
|
|
|
static unsigned int io_serial_in(unsigned long addr, int offset)
|
|
|
|
{
|
|
|
|
return inb(addr + offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void io_serial_out(unsigned long addr, int offset, int value)
|
|
|
|
{
|
|
|
|
outb(value, addr + offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned int (*serial_in)(unsigned long addr, int offset) = io_serial_in;
|
|
|
|
static void (*serial_out)(unsigned long addr, int offset, int value) = io_serial_out;
|
|
|
|
|
2007-10-11 17:17:24 +08:00
|
|
|
static int early_serial_putc(unsigned char ch)
|
|
|
|
{
|
|
|
|
unsigned timeout = 0xffff;
|
2008-07-25 08:29:40 +08:00
|
|
|
|
2015-01-20 20:07:57 +08:00
|
|
|
while ((serial_in(early_serial_base, LSR) & XMTRDY) == 0 && --timeout)
|
2007-10-11 17:17:24 +08:00
|
|
|
cpu_relax();
|
2015-01-20 20:07:57 +08:00
|
|
|
serial_out(early_serial_base, TXR, ch);
|
2007-10-11 17:17:24 +08:00
|
|
|
return timeout ? 0 : -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void early_serial_write(struct console *con, const char *s, unsigned n)
|
|
|
|
{
|
|
|
|
while (*s && n-- > 0) {
|
|
|
|
if (*s == '\n')
|
|
|
|
early_serial_putc('\r');
|
|
|
|
early_serial_putc(*s);
|
|
|
|
s++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-20 20:07:57 +08:00
|
|
|
static __init void early_serial_hw_init(unsigned divisor)
|
|
|
|
{
|
|
|
|
unsigned char c;
|
|
|
|
|
|
|
|
serial_out(early_serial_base, LCR, 0x3); /* 8n1 */
|
|
|
|
serial_out(early_serial_base, IER, 0); /* no interrupt */
|
|
|
|
serial_out(early_serial_base, FCR, 0); /* no fifo */
|
|
|
|
serial_out(early_serial_base, MCR, 0x3); /* DTR + RTS */
|
|
|
|
|
|
|
|
c = serial_in(early_serial_base, LCR);
|
|
|
|
serial_out(early_serial_base, LCR, c | DLAB);
|
|
|
|
serial_out(early_serial_base, DLL, divisor & 0xff);
|
|
|
|
serial_out(early_serial_base, DLH, (divisor >> 8) & 0xff);
|
|
|
|
serial_out(early_serial_base, LCR, c & ~DLAB);
|
|
|
|
}
|
|
|
|
|
2007-10-11 17:17:24 +08:00
|
|
|
#define DEFAULT_BAUD 9600
|
|
|
|
|
|
|
|
static __init void early_serial_init(char *s)
|
|
|
|
{
|
|
|
|
unsigned divisor;
|
2015-01-20 20:07:57 +08:00
|
|
|
unsigned long baud = DEFAULT_BAUD;
|
2007-10-11 17:17:24 +08:00
|
|
|
char *e;
|
|
|
|
|
|
|
|
if (*s == ',')
|
|
|
|
++s;
|
|
|
|
|
|
|
|
if (*s) {
|
|
|
|
unsigned port;
|
2008-02-29 20:25:30 +08:00
|
|
|
if (!strncmp(s, "0x", 2)) {
|
2007-10-11 17:17:24 +08:00
|
|
|
early_serial_base = simple_strtoul(s, &e, 16);
|
|
|
|
} else {
|
2008-08-29 19:49:55 +08:00
|
|
|
static const int __initconst bases[] = { 0x3f8, 0x2f8 };
|
2007-10-11 17:17:24 +08:00
|
|
|
|
2008-02-29 20:25:30 +08:00
|
|
|
if (!strncmp(s, "ttyS", 4))
|
2007-10-11 17:17:24 +08:00
|
|
|
s += 4;
|
|
|
|
port = simple_strtoul(s, &e, 10);
|
|
|
|
if (port > 1 || s == e)
|
|
|
|
port = 0;
|
|
|
|
early_serial_base = bases[port];
|
|
|
|
}
|
|
|
|
s += strcspn(s, ",");
|
|
|
|
if (*s == ',')
|
|
|
|
s++;
|
|
|
|
}
|
|
|
|
|
2015-01-20 20:07:57 +08:00
|
|
|
if (*s) {
|
x86/earlyprintk: Allow early_printk() to use console style parameters like '115200n8'
When I enable early_printk on a kernel, I cut and paste the
console= input and add to earlyprintk parameter. But I notice
recently that ktest has not been detecting triple faults. The
way it detects it, is by seeing the kernel banner "Linux version
.." with a different kernel version pop up. Then I noticed that
early printk was no longer working on my console, which was why
ktest was not seeing it.
I bisected it down and it was added to 4.0 with this commit:
ea9e9d802902 ("Specify PCI based UART for earlyprintk")
because it converted the simple_strtoul() that converts the baud
number into a kstrtoul(). The problem with this is, I had as my
baud rate, 115200n8 (acceptable for console=ttyS0), but because
of the "n8", the kstrtoul() doesn't parse the baud rate and
returns an error, which sets the baud rate to the default 9600.
This explains the garbage on my screen.
Now, earlyprintk= kernel parameter does not say it accepts that
format. Thus, one answer would simply be me changing my kernel
parameters to remove the "n8" since it isn't parsed anyway. But
I wonder if other people run into this, and it seems strange
that the two consoles for serial accepts different input.
I could also extend this to have earlyprintk do something with
that "n8" or whatever it has and have it match the console
parsing (which, BTW, still uses simple_strtoul(), as I guess it
has to).
This patch just makes my old kernel parameter parsing work like
it use to.
Although, simple_strtoull() is considered obsolete, it is the
only standard string parsing function that parses a number that
is attached to text. Ironically, commit ea9e9d802902 also added
several calls to simple_strtoul()!
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
Cc: Alan Cox <alan@linux.intel.com>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: David Cohen <david.a.cohen@linux.intel.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stuart R. Anderson <stuart.r.anderson@intel.com>
Cc: Thomas Gleixner <tglx@linutronix.de>
Link: http://lkml.kernel.org/r/20150706101434.5f6a351b@gandalf.local.home
[ Cleaned it up a bit. ]
Signed-off-by: Ingo Molnar <mingo@kernel.org>
2015-07-06 22:14:34 +08:00
|
|
|
baud = simple_strtoull(s, &e, 0);
|
|
|
|
|
|
|
|
if (baud == 0 || s == e)
|
2015-01-20 20:07:57 +08:00
|
|
|
baud = DEFAULT_BAUD;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Convert from baud to divisor value */
|
|
|
|
divisor = 115200 / baud;
|
|
|
|
|
|
|
|
/* These will always be IO based ports */
|
|
|
|
serial_in = io_serial_in;
|
|
|
|
serial_out = io_serial_out;
|
|
|
|
|
|
|
|
/* Set up the HW */
|
|
|
|
early_serial_hw_init(divisor);
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifdef CONFIG_PCI
|
2015-04-02 05:32:04 +08:00
|
|
|
static void mem32_serial_out(unsigned long addr, int offset, int value)
|
|
|
|
{
|
2015-10-12 18:47:17 +08:00
|
|
|
u32 __iomem *vaddr = (u32 __iomem *)addr;
|
2015-04-02 05:32:04 +08:00
|
|
|
/* shift implied by pointer type */
|
|
|
|
writel(value, vaddr + offset);
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned int mem32_serial_in(unsigned long addr, int offset)
|
|
|
|
{
|
2015-10-12 18:47:17 +08:00
|
|
|
u32 __iomem *vaddr = (u32 __iomem *)addr;
|
2015-04-02 05:32:04 +08:00
|
|
|
/* shift implied by pointer type */
|
|
|
|
return readl(vaddr + offset);
|
|
|
|
}
|
|
|
|
|
2015-01-20 20:07:57 +08:00
|
|
|
/*
|
|
|
|
* early_pci_serial_init()
|
|
|
|
*
|
|
|
|
* This function is invoked when the early_printk param starts with "pciserial"
|
2018-10-03 00:49:21 +08:00
|
|
|
* The rest of the param should be "[force],B:D.F,baud", where B, D & F describe
|
|
|
|
* the location of a PCI device that must be a UART device. "force" is optional
|
|
|
|
* and overrides the use of an UART device with a wrong PCI class code.
|
2015-01-20 20:07:57 +08:00
|
|
|
*/
|
|
|
|
static __init void early_pci_serial_init(char *s)
|
|
|
|
{
|
|
|
|
unsigned divisor;
|
|
|
|
unsigned long baud = DEFAULT_BAUD;
|
|
|
|
u8 bus, slot, func;
|
2015-04-02 05:32:04 +08:00
|
|
|
u32 classcode, bar0;
|
|
|
|
u16 cmdreg;
|
2015-01-20 20:07:57 +08:00
|
|
|
char *e;
|
2018-10-03 00:49:21 +08:00
|
|
|
int force = 0;
|
2015-01-20 20:07:57 +08:00
|
|
|
|
|
|
|
if (*s == ',')
|
|
|
|
++s;
|
|
|
|
|
|
|
|
if (*s == 0)
|
|
|
|
return;
|
|
|
|
|
2018-10-03 00:49:21 +08:00
|
|
|
/* Force the use of an UART device with wrong class code */
|
|
|
|
if (!strncmp(s, "force,", 6)) {
|
|
|
|
force = 1;
|
|
|
|
s += 6;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Part the param to get the BDF values
|
|
|
|
*/
|
2015-01-20 20:07:57 +08:00
|
|
|
bus = (u8)simple_strtoul(s, &e, 16);
|
|
|
|
s = e;
|
|
|
|
if (*s != ':')
|
|
|
|
return;
|
|
|
|
++s;
|
|
|
|
slot = (u8)simple_strtoul(s, &e, 16);
|
|
|
|
s = e;
|
|
|
|
if (*s != '.')
|
|
|
|
return;
|
|
|
|
++s;
|
|
|
|
func = (u8)simple_strtoul(s, &e, 16);
|
|
|
|
s = e;
|
2007-10-11 17:17:24 +08:00
|
|
|
|
2015-01-20 20:07:57 +08:00
|
|
|
/* A baud might be following */
|
|
|
|
if (*s == ',')
|
|
|
|
s++;
|
|
|
|
|
|
|
|
/*
|
2018-10-03 00:49:21 +08:00
|
|
|
* Find the device from the BDF
|
2015-01-20 20:07:57 +08:00
|
|
|
*/
|
|
|
|
cmdreg = read_pci_config(bus, slot, func, PCI_COMMAND);
|
|
|
|
classcode = read_pci_config(bus, slot, func, PCI_CLASS_REVISION);
|
|
|
|
bar0 = read_pci_config(bus, slot, func, PCI_BASE_ADDRESS_0);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Verify it is a UART type device
|
|
|
|
*/
|
|
|
|
if (((classcode >> 16 != PCI_CLASS_COMMUNICATION_MODEM) &&
|
|
|
|
(classcode >> 16 != PCI_CLASS_COMMUNICATION_SERIAL)) ||
|
2018-10-03 00:49:21 +08:00
|
|
|
(((classcode >> 8) & 0xff) != 0x02)) /* 16550 I/F at BAR0 */ {
|
|
|
|
if (!force)
|
|
|
|
return;
|
|
|
|
}
|
2015-01-20 20:07:57 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Determine if it is IO or memory mapped
|
|
|
|
*/
|
|
|
|
if (bar0 & 0x01) {
|
|
|
|
/* it is IO mapped */
|
|
|
|
serial_in = io_serial_in;
|
|
|
|
serial_out = io_serial_out;
|
|
|
|
early_serial_base = bar0&0xfffffffc;
|
|
|
|
write_pci_config(bus, slot, func, PCI_COMMAND,
|
|
|
|
cmdreg|PCI_COMMAND_IO);
|
|
|
|
} else {
|
|
|
|
/* It is memory mapped - assume 32-bit alignment */
|
|
|
|
serial_in = mem32_serial_in;
|
|
|
|
serial_out = mem32_serial_out;
|
|
|
|
/* WARNING! assuming the address is always in the first 4G */
|
|
|
|
early_serial_base =
|
|
|
|
(unsigned long)early_ioremap(bar0 & 0xfffffff0, 0x10);
|
|
|
|
write_pci_config(bus, slot, func, PCI_COMMAND,
|
|
|
|
cmdreg|PCI_COMMAND_MEMORY);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2018-10-03 00:49:21 +08:00
|
|
|
* Initialize the hardware
|
2015-01-20 20:07:57 +08:00
|
|
|
*/
|
2007-10-11 17:17:24 +08:00
|
|
|
if (*s) {
|
2015-01-20 20:07:57 +08:00
|
|
|
if (strcmp(s, "nocfg") == 0)
|
|
|
|
/* Sometimes, we want to leave the UART alone
|
|
|
|
* and assume the BIOS has set it up correctly.
|
|
|
|
* "nocfg" tells us this is the case, and we
|
|
|
|
* should do no more setup.
|
|
|
|
*/
|
|
|
|
return;
|
|
|
|
if (kstrtoul(s, 0, &baud) < 0 || baud == 0)
|
2007-10-11 17:17:24 +08:00
|
|
|
baud = DEFAULT_BAUD;
|
|
|
|
}
|
|
|
|
|
2015-01-20 20:07:57 +08:00
|
|
|
/* Convert from baud to divisor value */
|
2007-10-11 17:17:24 +08:00
|
|
|
divisor = 115200 / baud;
|
2015-01-20 20:07:57 +08:00
|
|
|
|
|
|
|
/* Set up the HW */
|
|
|
|
early_serial_hw_init(divisor);
|
2007-10-11 17:17:24 +08:00
|
|
|
}
|
2015-01-20 20:07:57 +08:00
|
|
|
#endif
|
2007-10-11 17:17:24 +08:00
|
|
|
|
|
|
|
static struct console early_serial_console = {
|
|
|
|
.name = "earlyser",
|
|
|
|
.write = early_serial_write,
|
|
|
|
.flags = CON_PRINTBUFFER,
|
|
|
|
.index = -1,
|
|
|
|
};
|
|
|
|
|
2015-09-28 20:23:56 +08:00
|
|
|
static void early_console_register(struct console *con, int keep_early)
|
2009-08-21 04:39:52 +08:00
|
|
|
{
|
2013-04-30 07:17:18 +08:00
|
|
|
if (con->index != -1) {
|
2009-09-24 07:13:13 +08:00
|
|
|
printk(KERN_CRIT "ERROR: earlyprintk= %s already used\n",
|
|
|
|
con->name);
|
|
|
|
return;
|
|
|
|
}
|
2009-08-21 04:39:52 +08:00
|
|
|
early_console = con;
|
|
|
|
if (keep_early)
|
|
|
|
early_console->flags &= ~CON_BOOT;
|
|
|
|
else
|
|
|
|
early_console->flags |= CON_BOOT;
|
|
|
|
register_console(early_console);
|
|
|
|
}
|
2007-10-11 17:17:24 +08:00
|
|
|
|
|
|
|
static int __init setup_early_printk(char *buf)
|
|
|
|
{
|
2009-08-21 04:39:52 +08:00
|
|
|
int keep;
|
2008-07-25 08:29:40 +08:00
|
|
|
|
2007-10-11 17:17:24 +08:00
|
|
|
if (!buf)
|
|
|
|
return 0;
|
|
|
|
|
2013-04-30 07:17:18 +08:00
|
|
|
if (early_console)
|
2007-10-11 17:17:24 +08:00
|
|
|
return 0;
|
|
|
|
|
2009-08-21 04:39:52 +08:00
|
|
|
keep = (strstr(buf, "keep") != NULL);
|
|
|
|
|
|
|
|
while (*buf != '\0') {
|
|
|
|
if (!strncmp(buf, "serial", 6)) {
|
2009-09-24 22:08:30 +08:00
|
|
|
buf += 6;
|
|
|
|
early_serial_init(buf);
|
2009-08-21 04:39:52 +08:00
|
|
|
early_console_register(&early_serial_console, keep);
|
2009-09-24 22:08:30 +08:00
|
|
|
if (!strncmp(buf, ",ttyS", 5))
|
|
|
|
buf += 5;
|
2009-08-21 04:39:52 +08:00
|
|
|
}
|
|
|
|
if (!strncmp(buf, "ttyS", 4)) {
|
|
|
|
early_serial_init(buf + 4);
|
|
|
|
early_console_register(&early_serial_console, keep);
|
|
|
|
}
|
2015-01-20 20:07:57 +08:00
|
|
|
#ifdef CONFIG_PCI
|
|
|
|
if (!strncmp(buf, "pciserial", 9)) {
|
|
|
|
early_pci_serial_init(buf + 9);
|
|
|
|
early_console_register(&early_serial_console, keep);
|
|
|
|
buf += 9; /* Keep from match the above "serial" */
|
|
|
|
}
|
|
|
|
#endif
|
2009-08-21 04:39:52 +08:00
|
|
|
if (!strncmp(buf, "vga", 3) &&
|
|
|
|
boot_params.screen_info.orig_video_isVGA == 1) {
|
|
|
|
max_xpos = boot_params.screen_info.orig_video_cols;
|
|
|
|
max_ypos = boot_params.screen_info.orig_video_lines;
|
|
|
|
current_ypos = boot_params.screen_info.orig_y;
|
|
|
|
early_console_register(&early_vga_console, keep);
|
|
|
|
}
|
2008-07-25 08:29:40 +08:00
|
|
|
#ifdef CONFIG_EARLY_PRINTK_DBGP
|
2009-08-21 04:39:52 +08:00
|
|
|
if (!strncmp(buf, "dbgp", 4) && !early_dbgp_init(buf + 4))
|
|
|
|
early_console_register(&early_dbgp_console, keep);
|
2008-07-25 08:29:40 +08:00
|
|
|
#endif
|
2007-10-11 17:17:24 +08:00
|
|
|
#ifdef CONFIG_HVC_XEN
|
2009-08-21 04:39:52 +08:00
|
|
|
if (!strncmp(buf, "xen", 3))
|
|
|
|
early_console_register(&xenboot_console, keep);
|
2010-09-13 15:08:55 +08:00
|
|
|
#endif
|
2017-03-21 16:01:31 +08:00
|
|
|
#ifdef CONFIG_EARLY_PRINTK_USB_XDBC
|
|
|
|
if (!strncmp(buf, "xdbc", 4))
|
|
|
|
early_xdbc_parse_parameter(buf + 4);
|
|
|
|
#endif
|
2013-10-04 16:36:56 +08:00
|
|
|
|
2009-08-21 04:39:52 +08:00
|
|
|
buf++;
|
2007-10-11 17:17:24 +08:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2008-07-25 08:29:40 +08:00
|
|
|
|
2007-10-11 17:17:24 +08:00
|
|
|
early_param("earlyprintk", setup_early_printk);
|