ia64/xen-unstable

view xen/arch/ia64/xen/pcdp.c @ 16785:af3550f53874

[IA64] domheap: Don't pin xenheap down. Now it's unnecessary.

Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>
author Alex Williamson <alex.williamson@hp.com>
date Thu Jan 17 12:05:43 2008 -0700 (2008-01-17)
parents 6a89339b81d0
children df89656a4b94
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/efi.h>
20 #include <linux/errno.h>
21 #include <asm/io.h>
22 #include <asm/iosapic.h>
23 #include <asm/system.h>
24 #include <acpi/acpi.h>
25 #endif
26 #include "pcdp.h"
28 #ifdef XEN
29 extern struct ns16550_defaults ns16550_com1;
30 extern unsigned int ns16550_com1_gsi;
31 extern unsigned int ns16550_com1_polarity;
32 extern unsigned int ns16550_com1_trigger;
34 /*
35 * This is kind of ugly, but older rev HCDP tables don't provide interrupt
36 * polarity and trigger information. Linux/ia64 discovers these properties
37 * later via ACPI names, but we don't have that luxury in Xen/ia64. Since
38 * all future platforms should have newer PCDP tables, this should be a
39 * fixed list of boxes in the field, so we can hardcode based on the model.
40 */
41 static void __init
42 pcdp_hp_irq_fixup(struct pcdp *pcdp, struct pcdp_uart *uart)
43 {
44 efi_system_table_t *systab;
45 efi_config_table_t *tables;
46 struct acpi20_table_rsdp *rsdp = NULL;
47 struct acpi_table_xsdt *xsdt;
48 struct acpi_table_header *hdr;
49 int i;
51 if (pcdp->rev >= 3 || strcmp((char *)pcdp->oemid, "HP"))
52 return;
54 /*
55 * Manually walk firmware provided tables to get to the XSDT.
56 * The OEM table ID on the XSDT is the platform model string.
57 * We only care about ACPI 2.0 tables as that's all HP provides.
58 */
59 systab = __va(ia64_boot_param->efi_systab);
61 if (!systab || systab->hdr.signature != EFI_SYSTEM_TABLE_SIGNATURE)
62 return;
64 tables = __va(systab->tables);
66 for (i = 0 ; i < (int)systab->nr_tables && !rsdp ; i++) {
67 if (efi_guidcmp(tables[i].guid, ACPI_20_TABLE_GUID) == 0)
68 rsdp =
69 (struct acpi20_table_rsdp *)__va(tables[i].table);
70 }
72 if (!rsdp || strncmp(rsdp->signature, RSDP_SIG, sizeof(RSDP_SIG) - 1))
73 return;
75 xsdt = (struct acpi_table_xsdt *)__va(rsdp->xsdt_address);
76 hdr = &xsdt->header;
78 if (strncmp(hdr->signature, XSDT_SIG, sizeof(XSDT_SIG) - 1))
79 return;
81 /* Sanity check; are we still looking at HP firmware tables? */
82 if (strcmp(hdr->oem_id, "HP"))
83 return;
85 if (!strcmp(hdr->oem_table_id, "zx2000") ||
86 !strcmp(hdr->oem_table_id, "zx6000") ||
87 !strcmp(hdr->oem_table_id, "rx2600") ||
88 !strcmp(hdr->oem_table_id, "cx2600")) {
90 ns16550_com1.irq = ns16550_com1_gsi = uart->gsi;
91 ns16550_com1_polarity = IOSAPIC_POL_HIGH;
92 ns16550_com1_trigger = IOSAPIC_EDGE;
94 } else if (!strcmp(hdr->oem_table_id, "rx2620") ||
95 !strcmp(hdr->oem_table_id, "cx2620") ||
96 !strcmp(hdr->oem_table_id, "rx1600") ||
97 !strcmp(hdr->oem_table_id, "rx1620")) {
99 ns16550_com1.irq = ns16550_com1_gsi = uart->gsi;
100 ns16550_com1_polarity = IOSAPIC_POL_LOW;
101 ns16550_com1_trigger = IOSAPIC_LEVEL;
102 }
103 }
105 static void __init
106 setup_pcdp_irq(struct pcdp *pcdp, struct pcdp_uart *uart)
107 {
108 /* PCDP provides full interrupt info */
109 if (pcdp->rev >= 3) {
110 if (uart->flags & PCDP_UART_IRQ) {
111 ns16550_com1.irq = ns16550_com1_gsi = uart->gsi,
112 ns16550_com1_polarity =
113 uart->flags & PCDP_UART_ACTIVE_LOW ?
114 IOSAPIC_POL_LOW : IOSAPIC_POL_HIGH;
115 ns16550_com1_trigger =
116 uart->flags & PCDP_UART_EDGE_SENSITIVE ?
117 IOSAPIC_EDGE : IOSAPIC_LEVEL;
118 }
119 return;
120 }
122 /* HCDP support */
123 if (uart->pci_func & PCDP_UART_IRQ) {
124 /*
125 * HCDP tables don't provide interrupt polarity/trigger
126 * info. If the UART is a PCI device, we know to program
127 * it as low/level. Otherwise rely on platform hacks or
128 * default to polling (irq = 0).
129 */
130 if (uart->pci_func & PCDP_UART_PCI) {
131 ns16550_com1.irq = ns16550_com1_gsi = uart->gsi;
132 ns16550_com1_polarity = IOSAPIC_POL_LOW;
133 ns16550_com1_trigger = IOSAPIC_LEVEL;
134 } else if (!strcmp((char *)pcdp->oemid, "HP"))
135 pcdp_hp_irq_fixup(pcdp, uart);
136 }
137 }
139 static int __init
140 setup_serial_console(struct pcdp_uart *uart)
141 {
143 ns16550_com1.baud = uart->baud ? uart->baud : BAUD_AUTO;
144 ns16550_com1.io_base = uart->addr.address;
145 if (uart->bits)
146 ns16550_com1.data_bits = uart->bits;
148 setup_pcdp_irq(efi.hcdp, uart);
150 /* Hide the HCDP table from dom0, xencons will be the console */
151 efi.hcdp = NULL;
153 return 0;
154 }
156 static int __init
157 setup_vga_console(struct pcdp_vga *vga)
158 {
159 #ifdef CONFIG_VGA
160 /*
161 * There was no console= in the original cmdline, and the PCDP
162 * is telling us VGA is the primary console. We can call
163 * cmdline_parse() manually to make things appear automagic.
164 *
165 * NB - cmdline_parse() expects the first part of the cmdline
166 * to be the image name. So "pcdp" below is just filler.
167 */
168 char *console_cmdline = "pcdp console=vga";
170 cmdline_parse(console_cmdline);
172 /*
173 * Leave efi.hcdp intact since dom0 will take ownership.
174 * vga=keep is handled in start_kernel().
175 */
177 return 0;
178 #else
179 return -ENODEV;
180 #endif
181 }
183 #else /* XEN */
185 static int __init
186 setup_serial_console(struct pcdp_uart *uart)
187 {
188 #ifdef CONFIG_SERIAL_8250_CONSOLE
189 int mmio;
190 static char options[64];
192 mmio = (uart->addr.address_space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY);
193 snprintf(options, sizeof(options), "console=uart,%s,0x%lx,%lun%d",
194 mmio ? "mmio" : "io", uart->addr.address, uart->baud,
195 uart->bits ? uart->bits : 8);
197 return early_serial_console_init(options);
198 #else
199 return -ENODEV;
200 #endif
201 }
203 static int __init
204 setup_vga_console(struct pcdp_vga *vga)
205 {
206 #if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE)
207 if (efi_mem_type(0xA0000) == EFI_CONVENTIONAL_MEMORY) {
208 printk(KERN_ERR "PCDP: VGA selected, but frame buffer is not MMIO!\n");
209 return -ENODEV;
210 }
212 conswitchp = &vga_con;
213 printk(KERN_INFO "PCDP: VGA console\n");
214 return 0;
215 #else
216 return -ENODEV;
217 #endif
218 }
219 #endif /* XEN */
221 int __init
222 efi_setup_pcdp_console(char *cmdline)
223 {
224 struct pcdp *pcdp;
225 struct pcdp_uart *uart;
226 struct pcdp_device *dev, *end;
227 int i, serial = 0;
229 pcdp = efi.hcdp;
230 if (!pcdp)
231 return -ENODEV;
233 printk(KERN_INFO "PCDP: v%d at 0x%lx\n", pcdp->rev, __pa(pcdp));
235 if (strstr(cmdline, "console=hcdp")) {
236 if (pcdp->rev < 3)
237 serial = 1;
238 } else if (strstr(cmdline, "console=")) {
239 printk(KERN_INFO "Explicit \"console=\"; ignoring PCDP\n");
240 return -ENODEV;
241 }
243 if (pcdp->rev < 3 && efi_uart_console_only())
244 serial = 1;
246 for (i = 0, uart = pcdp->uart; i < pcdp->num_uarts; i++, uart++) {
247 if (uart->flags & PCDP_UART_PRIMARY_CONSOLE || serial) {
248 if (uart->type == PCDP_CONSOLE_UART) {
249 return setup_serial_console(uart);
251 }
252 }
253 }
255 end = (struct pcdp_device *) ((u8 *) pcdp + pcdp->length);
256 for (dev = (struct pcdp_device *) (pcdp->uart + pcdp->num_uarts);
257 dev < end;
258 dev = (struct pcdp_device *) ((u8 *) dev + dev->length)) {
259 if (dev->flags & PCDP_PRIMARY_CONSOLE) {
260 if (dev->type == PCDP_CONSOLE_VGA) {
261 return setup_vga_console((struct pcdp_vga *) dev);
262 }
263 }
264 }
266 return -ENODEV;
267 }