ia64/xen-unstable

view xen/arch/ia64/pcdp.c @ 6552:a9873d384da4

Merge.
author adsharma@los-vmm.sc.intel.com
date Thu Aug 25 12:24:48 2005 -0700 (2005-08-25)
parents 112d44270733 fa0754a9f64f
children dfaf788ab18c
line source
1 /*
2 * Parse the EFI PCDP table to locate the console device.
3 *
4 * (c) Copyright 2002, 2003, 2004 Hewlett-Packard Development Company, L.P.
5 * Khalid Aziz <khalid.aziz@hp.com>
6 * Alex Williamson <alex.williamson@hp.com>
7 * Bjorn Helgaas <bjorn.helgaas@hp.com>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2 as
11 * published by the Free Software Foundation.
12 */
14 #include <linux/acpi.h>
15 #include <linux/console.h>
16 #include <linux/efi.h>
17 #include <linux/serial.h>
18 #ifdef XEN
19 #include <linux/errno.h>
20 #endif
21 #include "pcdp.h"
23 static int __init
24 setup_serial_console(struct pcdp_uart *uart)
25 {
26 #ifdef XEN
27 extern struct ns16550_defaults ns16550_com1;
28 ns16550_com1.baud = uart->baud;
29 ns16550_com1.io_base = uart->addr.address;
30 if (uart->bits)
31 ns16550_com1.data_bits = uart->bits;
32 return 0;
33 #else
34 #ifdef CONFIG_SERIAL_8250_CONSOLE
35 int mmio;
36 static char options[64];
38 mmio = (uart->addr.address_space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY);
39 snprintf(options, sizeof(options), "console=uart,%s,0x%lx,%lun%d",
40 mmio ? "mmio" : "io", uart->addr.address, uart->baud,
41 uart->bits ? uart->bits : 8);
43 return early_serial_console_init(options);
44 #else
45 return -ENODEV;
46 #endif
47 #endif
48 }
50 #ifndef XEN
51 static int __init
52 setup_vga_console(struct pcdp_vga *vga)
53 {
54 #if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE)
55 if (efi_mem_type(0xA0000) == EFI_CONVENTIONAL_MEMORY) {
56 printk(KERN_ERR "PCDP: VGA selected, but frame buffer is not MMIO!\n");
57 return -ENODEV;
58 }
60 conswitchp = &vga_con;
61 printk(KERN_INFO "PCDP: VGA console\n");
62 return 0;
63 #else
64 return -ENODEV;
65 #endif
66 }
67 #endif
69 int __init
70 efi_setup_pcdp_console(char *cmdline)
71 {
72 struct pcdp *pcdp;
73 struct pcdp_uart *uart;
74 struct pcdp_device *dev, *end;
75 int i, serial = 0;
77 pcdp = efi.hcdp;
78 if (!pcdp)
79 return -ENODEV;
81 #ifndef XEN
82 printk(KERN_INFO "PCDP: v%d at 0x%lx\n", pcdp->rev, __pa(pcdp));
83 #endif
85 if (strstr(cmdline, "console=hcdp")) {
86 if (pcdp->rev < 3)
87 serial = 1;
88 } else if (strstr(cmdline, "console=")) {
89 #ifndef XEN
90 printk(KERN_INFO "Explicit \"console=\"; ignoring PCDP\n");
91 #endif
92 return -ENODEV;
93 }
95 if (pcdp->rev < 3 && efi_uart_console_only())
96 serial = 1;
98 for (i = 0, uart = pcdp->uart; i < pcdp->num_uarts; i++, uart++) {
99 if (uart->flags & PCDP_UART_PRIMARY_CONSOLE || serial) {
100 if (uart->type == PCDP_CONSOLE_UART) {
101 return setup_serial_console(uart);
102 }
103 }
104 }
106 #ifndef XEN
107 end = (struct pcdp_device *) ((u8 *) pcdp + pcdp->length);
108 for (dev = (struct pcdp_device *) (pcdp->uart + pcdp->num_uarts);
109 dev < end;
110 dev = (struct pcdp_device *) ((u8 *) dev + dev->length)) {
111 if (dev->flags & PCDP_PRIMARY_CONSOLE) {
112 if (dev->type == PCDP_CONSOLE_VGA) {
113 return setup_vga_console((struct pcdp_vga *) dev);
114 }
115 }
116 }
117 #endif
119 return -ENODEV;
120 }