diff options
| author | Joe Perches <joe@perches.com> | 2013-07-31 16:53:42 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-07-31 17:41:03 -0400 |
| commit | b9ee979e9d770dc10f94936ef6ff9efddc23c911 (patch) | |
| tree | a099ce69f9facb3285754e9b410d8494f9652204 /kernel/printk | |
| parent | b99b94b52339dc186810e29f1f6472d86c42d2d9 (diff) | |
printk: move to separate directory for easier modification
Make it easier to break up printk into bite-sized chunks.
Remove printk path/filename from comment.
Signed-off-by: Joe Perches <joe@perches.com>
Cc: Samuel Thibault <samuel.thibault@ens-lyon.org>
Cc: Ming Lei <ming.lei@canonical.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'kernel/printk')
| -rw-r--r-- | kernel/printk/Makefile | 1 | ||||
| -rw-r--r-- | kernel/printk/printk.c | 2924 |
2 files changed, 2925 insertions, 0 deletions
diff --git a/kernel/printk/Makefile b/kernel/printk/Makefile new file mode 100644 index 000000000000..36d306d9273c --- /dev/null +++ b/kernel/printk/Makefile | |||
| @@ -0,0 +1 @@ | |||
| obj-y = printk.o | |||
diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c new file mode 100644 index 000000000000..69b0890ed7e5 --- /dev/null +++ b/kernel/printk/printk.c | |||
| @@ -0,0 +1,2924 @@ | |||
| 1 | /* | ||
| 2 | * linux/kernel/printk.c | ||
| 3 | * | ||
| 4 | * Copyright (C) 1991, 1992 Linus Torvalds | ||
| 5 | * | ||
| 6 | * Modified to make sys_syslog() more flexible: added commands to | ||
| 7 | * return the last 4k of kernel messages, regardless of whether | ||
| 8 | * they've been read or not. Added option to suppress kernel printk's | ||
| 9 | * to the console. Added hook for sending the console messages | ||
| 10 | * elsewhere, in preparation for a serial line console (someday). | ||
| 11 | * Ted Ts'o, 2/11/93. | ||
| 12 | * Modified for sysctl support, 1/8/97, Chris Horn. | ||
| 13 | * Fixed SMP synchronization, 08/08/99, Manfred Spraul | ||
| 14 | * manfred@colorfullife.com | ||
| 15 | * Rewrote bits to get rid of console_lock | ||
| 16 | * 01Mar01 Andrew Morton | ||
| 17 | */ | ||
| 18 | |||
| 19 | #include <linux/kernel.h> | ||
| 20 | #include <linux/mm.h> | ||
| 21 | #include <linux/tty.h> | ||
| 22 | #include <linux/tty_driver.h> | ||
| 23 | #include <linux/console.h> | ||
| 24 | #include <linux/init.h> | ||
| 25 | #include <linux/jiffies.h> | ||
| 26 | #include <linux/nmi.h> | ||
| 27 | #include <linux/module.h> | ||
| 28 | #include <linux/moduleparam.h> | ||
| 29 | #include <linux/interrupt.h> /* For in_interrupt() */ | ||
| 30 | #include <linux/delay.h> | ||
| 31 | #include <linux/smp.h> | ||
| 32 | #include <linux/security.h> | ||
| 33 | #include <linux/bootmem.h> | ||
| 34 | #include <linux/memblock.h> | ||
| 35 | #include <linux/aio.h> | ||
| 36 | #include <linux/syscalls.h> | ||
| 37 | #include <linux/kexec.h> | ||
| 38 | #include <linux/kdb.h> | ||
| 39 | #include <linux/ratelimit.h> | ||
| 40 | #include <linux/kmsg_dump.h> | ||
| 41 | #include <linux/syslog.h> | ||
| 42 | #include <linux/cpu.h> | ||
| 43 | #include <linux/notifier.h> | ||
| 44 | #include <linux/rculist.h> | ||
| 45 | #include <linux/poll.h> | ||
| 46 | #include <linux/irq_work.h> | ||
| 47 | #include <linux/utsname.h> | ||
| 48 | |||
| 49 | #include <asm/uaccess.h> | ||
| 50 | |||
| 51 | #define CREATE_TRACE_POINTS | ||
| 52 | #include <trace/events/printk.h> | ||
| 53 | |||
| 54 | /* printk's without a loglevel use this.. */ | ||
| 55 | #define DEFAULT_MESSAGE_LOGLEVEL CONFIG_DEFAULT_MESSAGE_LOGLEVEL | ||
| 56 | |||
| 57 | /* We show everything that is MORE important than this.. */ | ||
| 58 | #define MINIMUM_CONSOLE_LOGLEVEL 1 /* Minimum loglevel we let people use */ | ||
| 59 | #define DEFAULT_CONSOLE_LOGLEVEL 7 /* anything MORE serious than KERN_DEBUG */ | ||
| 60 | |||
| 61 | int console_printk[4] = { | ||
| 62 | DEFAULT_CONSOLE_LOGLEVEL, /* console_loglevel */ | ||
| 63 | DEFAULT_MESSAGE_LOGLEVEL, /* default_message_loglevel */ | ||
| 64 | MINIMUM_CONSOLE_LOGLEVEL, /* minimum_console_loglevel */ | ||
| 65 | DEFAULT_CONSOLE_LOGLEVEL, /* default_console_loglevel */ | ||
| 66 | }; | ||
| 67 | |||
| 68 | /* | ||
| 69 | * Low level drivers may need that to know if they can schedule in | ||
| 70 | * their unblank() callback or not. So let's export it. | ||
| 71 | */ | ||
| 72 | int oops_in_progress; | ||
| 73 | EXPORT_SYMBOL(oops_in_progress); | ||
| 74 | |||
| 75 | /* | ||
| 76 | * console_sem protects the console_drivers list, and also | ||
| 77 | * provides serialisation for access to the entire console | ||
| 78 | * driver system. | ||
| 79 | */ | ||
| 80 | static DEFINE_SEMAPHORE(console_sem); | ||
| 81 | struct console *console_drivers; | ||
| 82 | EXPORT_SYMBOL_GPL(console_drivers); | ||
| 83 | |||
| 84 | #ifdef CONFIG_LOCKDEP | ||
| 85 | static struct lockdep_map console_lock_dep_map = { | ||
| 86 | .name = "console_lock" | ||
| 87 | }; | ||
| 88 | #endif | ||
| 89 | |||
| 90 | /* | ||
| 91 | * This is used for debugging the mess that is the VT code by | ||
| 92 | * keeping track if we have the console semaphore held. It's | ||
| 93 | * definitely not the perfect debug tool (we don't know if _WE_ | ||
| 94 | * hold it are racing, but it helps tracking those weird code | ||
| 95 | * path in the console code where we end up in places I want | ||
| 96 | * locked without the console sempahore held | ||
| 97 | */ | ||
| 98 | static int console_locked, console_suspended; | ||
| 99 | |||
| 100 | /* | ||
| 101 | * If exclusive_console is non-NULL then only this console is to be printed to. | ||
| 102 | */ | ||
| 103 | static struct console *exclusive_console; | ||
| 104 | |||
| 105 | /* | ||
| 106 | * Array of consoles built from command line options (console=) | ||
| 107 | */ | ||
| 108 | struct console_cmdline | ||
| 109 | { | ||
| 110 | char name[8]; /* Name of the driver */ | ||
| 111 | int index; /* Minor dev. to use */ | ||
| 112 | char *options; /* Options for the driver */ | ||
| 113 | #ifdef CONFIG_A11Y_BRAILLE_CONSOLE | ||
| 114 | char *brl_options; /* Options for braille driver */ | ||
| 115 | #endif | ||
| 116 | }; | ||
| 117 | |||
| 118 | #define MAX_CMDLINECONSOLES 8 | ||
| 119 | |||
| 120 | static struct console_cmdline console_cmdline[MAX_CMDLINECONSOLES]; | ||
| 121 | static int selected_console = -1; | ||
| 122 | static int preferred_console = -1; | ||
| 123 | int console_set_on_cmdline; | ||
| 124 | EXPORT_SYMBOL(console_set_on_cmdline); | ||
| 125 | |||
| 126 | /* Flag: console code may call schedule() */ | ||
| 127 | static int console_may_schedule; | ||
| 128 | |||
| 129 | /* | ||
| 130 | * The printk log buffer consists of a chain of concatenated variable | ||
| 131 | * length records. Every record starts with a record header, containing | ||
| 132 | * the overall length of the record. | ||
| 133 | * | ||
| 134 | * The heads to the first and last entry in the buffer, as well as the | ||
| 135 | * sequence numbers of these both entries are maintained when messages | ||
| 136 | * are stored.. | ||
| 137 | * | ||
| 138 | * If the heads indicate available messages, the length in the header | ||
| 139 | * tells the start next message. A length == 0 for the next message | ||
| 140 | * indicates a wrap-around to the beginning of the buffer. | ||
| 141 | * | ||
| 142 | * Every record carries the monotonic timestamp in microseconds, as well as | ||
| 143 | * the standard userspace syslog level and syslog facility. The usual | ||
| 144 | * kernel messages use LOG_KERN; userspace-injected messages always carry | ||
| 145 | * a matching syslog facility, by default LOG_USER. The origin of every | ||
| 146 | * message can be reliably determined that way. | ||
| 147 | * | ||
| 148 | * The human readable log message directly follows the message header. The | ||
| 149 | * length of the message text is stored in the header, the stored message | ||
| 150 | * is not terminated. | ||
| 151 | * | ||
| 152 | * Optionally, a message can carry a dictionary of properties (key/value pairs), | ||
| 153 | * to provide userspace with a machine-readable message context. | ||
| 154 | * | ||
| 155 | * Examples for well-defined, commonly used property names are: | ||
| 156 | * DEVICE=b12:8 device identifier | ||
| 157 | * b12:8 block dev_t | ||
| 158 | * c127:3 char dev_t | ||
| 159 | * n8 netdev ifindex | ||
| 160 | * +sound:card0 subsystem:devname | ||
| 161 | * SUBSYSTEM=pci driver-core subsystem name | ||
| 162 | * | ||
| 163 | * Valid characters in property names are [a-zA-Z0-9.-_]. The plain text value | ||
| 164 | * follows directly after a '=' character. Every property is terminated by | ||
| 165 | * a '\0' character. The last property is not terminated. | ||
| 166 | * | ||
| 167 | * Example of a message structure: | ||
| 168 | * 0000 ff 8f 00 00 00 00 00 00 monotonic time in nsec | ||
| 169 | * 0008 34 00 record is 52 bytes long | ||
| 170 | * 000a 0b 00 text is 11 bytes long | ||
| 171 | * 000c 1f 00 dictionary is 23 bytes long | ||
| 172 | * 000e 03 00 LOG_KERN (facility) LOG_ERR (level) | ||
| 173 | * 0010 69 74 27 73 20 61 20 6c "it's a l" | ||
| 174 | * 69 6e 65 "ine" | ||
| 175 | * 001b 44 45 56 49 43 "DEVIC" | ||
| 176 | * 45 3d 62 38 3a 32 00 44 "E=b8:2\0D" | ||
| 177 | * 52 49 56 45 52 3d 62 75 "RIVER=bu" | ||
| 178 | * 67 "g" | ||
| 179 | * 0032 00 00 00 padding to next message header | ||
| 180 | * | ||
| 181 | * The 'struct log' buffer header must never be directly exported to | ||
| 182 | * userspace, it is a kernel-private implementation detail that might | ||
| 183 | * need to be changed in the future, when the requirements change. | ||
| 184 | * | ||
| 185 | * /dev/kmsg exports the structured data in the following line format: | ||
| 186 | * "level,sequnum,timestamp;<message text>\n" | ||
| 187 | * | ||
| 188 | * The optional key/value pairs are attached as continuation lines starting | ||
| 189 | * with a space character and terminated by a newline. All possible | ||
| 190 | * non-prinatable characters are escaped in the "\xff" notation. | ||
| 191 | * | ||
