autoconsole
Anton Blanchard
anton at samba.org
Thu Jan 15 12:18:08 EST 2004
> I haven't had time to check it out yet, but Sparc pushed an
> add_preferred_console() to 2.5 a couple weeks ago. See
> arch/sparc/kernel/setup.c set_preferred_console() ; it's a bit cleaner
> looking than what you've posted here. :)
Agreed, how does this look? I could only compile test it, I dont have a
machine to run on at the moment.
Could we ever end up with the console on a hvc other than 0?
Anton
===== arch/ppc64/kernel/setup.c 1.31 vs edited =====
--- 1.31/arch/ppc64/kernel/setup.c Wed Oct 8 12:53:40 2003
+++ edited/arch/ppc64/kernel/setup.c Thu Jan 15 12:14:06 2004
@@ -405,6 +405,56 @@
}
}
+static int __init set_preferred_console(void)
+{
+ struct device_node *prom_stdout;
+ char *name;
+
+ /* The user has requested a console so this is already set up. */
+ if (strstr(cmd_line, "console="))
+ return -EBUSY;
+
+ prom_stdout = find_path_device(of_stdout_device);
+ if (!prom_stdout)
+ return -ENODEV;
+
+ name = (char *)get_property(prom_stdout, "name", NULL);
+ if (!name)
+ return -ENODEV;
+
+ if (strcmp(name, "serial") == 0) {
+ int i;
+ u32 *reg = (u32 *)get_property(prom_stdout, "reg", &i);
+ if (i > 8) {
+ int offset;
+ switch (reg[1]) {
+ case 0x3f8:
+ offset = 0;
+ break;
+ case 0x2f8:
+ offset = 1;
+ break;
+ case 0x898:
+ offset = 2;
+ break;
+ case 0x890:
+ offset = 3;
+ break;
+ default:
+ /* We dont recognise the serial port */
+ return -ENODEV;
+ }
+
+ return add_preferred_console("ttyS", offset, NULL);
+ }
+ } else if (strcmp(name, "vty") == 0) {
+ /* pSeries LPAR virtual console */
+ return add_preferred_console("hvc", 0, NULL);
+ }
+
+ return -ENODEV;
+}
+console_initcall(set_preferred_console);
char *bi_tag2str(unsigned long tag)
{
** Sent via the linuxppc64-dev mail list. See http://lists.linuxppc.org/
More information about the Linuxppc64-dev
mailing list