Add PCDP console detection support
PATCH 1/1 Add PCDP console detection support
Add support for the EFI/DIG PCDP console discovery table (see
http://www.dig64.org/specifications/DIG64_HCDPv20_042804.pdf).
This moves the code from drivers/serial/8250_hcdp.[ch] to drivers/firmware/pcdp.[ch], since it's no longer 8250-specific. It also obsoletes CONFIG_SERIAL_8250_HCDP, replacing it with CONFIG_EFI_PCDP (which defaults to Y for ia64).
In a nutshell, HCDP tells us "these UARTs are available for use as a console," and it's up to the user to explicitly specify the console device. The kernel can guess in some cases, but not all.
The PCDP (aka HCDP v2) tells us what we really want to know, namely, "this UART or VGA device is the console device." (It also has provision for support for new device types.)
drivers/serial/8250_hcdp.c | 264 --------------------------------------------- drivers/serial/8250_hcdp.h | 82 ------------- arch/ia64/kernel/setup.c | 29 ++-- drivers/firmware/Kconfig | 19 +++ drivers/firmware/Makefile | 1 drivers/firmware/pcdp.c | 206 +++++++++++++++++++++++++++++++++++ drivers/firmware/pcdp.h | 80 +++++++++++++ drivers/serial/Kconfig | 9 - drivers/serial/Makefile | 1 include/linux/efi.h | 4 10 files changed, 324 insertions(+), 371 deletions(-)
arch/ia64/kernel/setup.c +14 -15
@@ -319,31 +319,30 @@#ifdef CONFIG_ACPI_BOOT acpi_boot_init ();#endif -#ifdef CONFIG_SERIAL_8250_CONSOLE -#ifdef CONFIG_SERIAL_8250_HCDP -if (efi.hcdp) { -void setup_serial_hcdp (void *); -setup_serial_hcdp (efi.hcdp); - } +#ifdef CONFIG_EFI_PCDP +efi_setup_pcdp_console (*cmdline_p);#endif +#ifdef CONFIG_SERIAL_8250_CONSOLE if (!efi.hcdp)setup_serial_legacy ();#endif #ifdef CONFIG_VT +if (!conswitchp) {# if defined(CONFIG_DUMMY_CONSOLE ) - conswitchp = &dummy_con; + conswitchp = &dummy_con;# endif # if defined(CONFIG_VGA_CONSOLE ) -/* -* Non-legacy systems may route legacy VGA MMIO range to system -* memory. vga_con probes the MMIO hole, so memory looks like -* a VGA device to it. The EFI memory map can tell us if it's -* memory so we can avoid this problem. -*/ -if (efi_mem_type (0xA0000 ) !=EFI_CONVENTIONAL_MEMORY ) - conswitchp = &vga_con; +/* +* Non-legacy systems may route legacy VGA MMIO range to system +* memory. vga_con probes the MMIO hole, so memory looks like +* a VGA device to it. The EFI memory map can tell us if it's +* memory so we can avoid this problem. +*/ +if (efi_mem_type (0xA0000 ) !=EFI_CONVENTIONAL_MEMORY ) + conswitchp = &vga_con;# endif + }#endif /* enable IA-64 Machine Check Abort Handling */
drivers/firmware/Kconfig +19 -0
@@ -34,4 +34,23 @@ Subsequent efibootmgr releases may be found at: http://linux.dell.com/efibootmgr +config EFI_PCDP + bool "Console device selection via EFI PCDP or HCDP table" + depends on ACPI && EFI + default y if IA64 + help + If your firmware supplies the PCDP table, and you want to + automatically use the primary console device it describes + as the Linux console, say Y here. + + If your firmware supplies the HCDP table, and you want to + use the first serial port it describes as the Linux console, + say Y here. If your EFI ConOut path contains only a UART + device, it will become the console automatically. Otherwise, + you must specify the "console=ttyS0" kernel boot argument. + + You must also enable the appropriate drivers (serial, VGA, etc.) + + See <http://www.dig64.org/specifications/DIG64_HCDPv20_042804.pdf> + endmenu
drivers/firmware/Makefile +1 -0
@@ -3,3 +3,4 @@ # obj-$(CONFIG_EDD) += edd.o obj-$(CONFIG_EFI_VARS) += efivars.o +obj-$(CONFIG_EFI_PCDP) += pcdp.o
drivers/firmware/pcdp.c new file +206 -0
206 lines not on this page · raw message
drivers/firmware/pcdp.h new file +80 -0
80 lines not on this page · raw message
drivers/serial/8250_hcdp.c deleted +0 -264
264 lines not on this page · raw message
drivers/serial/8250_hcdp.h deleted +0 -82
82 lines not on this page · raw message
drivers/serial/Kconfig +0 -9
@@ -62,15 +62,6 @@ If unsure, say N. -config SERIAL_8250_HCDP - bool "Console device discovery via EFI HCDP table" - depends on IA64 - depends on SERIAL_8250_CONSOLE=y - ---help--- - If you wish to make the serial console port described by the EFI - HCDP table available for use as serial console, say Y here. See - <http://www.dig64.org/specifications/DIG64_HCDPv10a_01.pdf>. - config SERIAL_8250_CS tristate "8250/16550 PCMCIA device support" depends on PCMCIA && SERIAL_8250
drivers/serial/Makefile +0 -1
@@ -9,7 +9,6 @@ serial-8250-$(CONFIG_GSC) += 8250_gsc.o serial-8250-$(CONFIG_PCI) += 8250_pci.o serial-8250-$(CONFIG_PNP) += 8250_pnp.o -serial-8250-$(CONFIG_SERIAL_8250_HCDP) += 8250_hcdp.o obj-$(CONFIG_SERIAL_CORE) += serial_core.o obj-$(CONFIG_SERIAL_21285) += 21285.o
include/linux/efi.h +4 -0
@@ -305,6 +305,10 @@extern int __init efi_set_rtc_mmss (unsigned long nowtime);extern struct efi_memory_map memmap; +#ifdef CONFIG_EFI_PCDP +extern void __init efi_setup_pcdp_console (char *); +#endif +/* * We play games with efi_enabled so that the compiler will, if possible, remove * EFI-related code altogether.
Quoted 4 lines · Bjorn Helgaas
This moves the code from drivers/serial/8250_hcdp.[ch] to drivers/firmware/pcdp.[ch], since it's no longer 8250-specific. It also obsoletes
CONFIG_SERIAL_8250_HCDP, replacing it withCONFIG_EFI_PCDP(which defaults to Y for ia64).
I'm happy with this. The only thing I spotted on a quick read through was:
drivers/firmware/pcdp.c line 67
Quoted 8 lines
drivers/firmware/pcdp.c new file +7
-0+static void __init +setup_serial_console (int rev,struct pcdp_uart *uart) +{ +#ifdef CONFIG_SERIAL_8250_CONSOLE +if (uart->addr.address_space_id =ACPI_ADR_SPACE_SYSTEM_MEMORY ) { + port.mapbase = uart->addr.address; + port.membase =ioremap (port.mapbase,64 );
What if ioremap fails (can it fail here?)
drivers/firmware/pcdp.c line 68
Quoted 1 line
drivers/firmware/pcdp.c new file +1
-0+ port.iotype =SERIAL_IO_MEM ;
Should be UPIO_MEM please. Seems I missed this in the HCDP code...
drivers/firmware/pcdp.c line 71
Quoted 3 lines
drivers/firmware/pcdp.c new file +3
-0+ }else if (uart->addr.address_space_id =ACPI_ADR_SPACE_SYSTEM_IO ) { + port.iobase = uart->addr.address; + port.iotype =SERIAL_IO_PORT ;
Likewise should be UPIO_PORT please.
Signature · 4 lines
Russell King
Linux kernel 2.6 ARM Linux - http://www.arm.linux.org.uk/
maintainer of: 2.6 PCMCIA - http://pcmcia.arm.linux.org.uk/
2.6 Serial coreQuoted 6 lines · Russell King
Quoted 4 lines · Bjorn Helgaas
This moves the code from drivers/serial/8250_hcdp.[ch] to drivers/firmware/pcdp.[ch], since it's no longer 8250-specific. It also obsoletes
CONFIG_SERIAL_8250_HCDP, replacing it withCONFIG_EFI_PCDP(which defaults to Y for ia64).
Quoted 8 lines
I'm happy with this. The only thing I spotted on a quick read through was:
...
What if ioremap fails (can it fail here?)
...
Should beUPIO_MEMplease. Seems I missed this in the HCDP code...
...
Likewise should beUPIO_PORTplease.
OK, Andrew, can you apply the following additional patch to address the things Russell found (thanks, Russell)?
Check for ioremap failure and use correct UPIO_{MEM,PORT} constants.
=== drivers/firmware/pcdp.c 1.1 vs edited ==--- 1.1/drivers/firmware/pcdp.c 2004-06-27 11:52:01 -06:00
+++ edited/drivers/firmware/pcdp.c 2004-06-28 10:46:25 -06:00
@@ -56,6 +56,7 @@
#ifdef CONFIG_SERIAL_8250_CONSOLE
struct uart_port port;
static char options[16];
+ int mapsize = 64;
memset(&port, 0, sizeof(port));
port.uartclk = uart->clock_rate;
@@ -64,11 +65,16 @@
if (uart->addr.address_space_id = ACPI_ADR_SPACE_SYSTEM_MEMORY) {
port.mapbase = uart->addr.address;
- port.membase = ioremap(port.mapbase, 64);
- port.iotype = SERIAL_IO_MEM;
+ port.membase = ioremap(port.mapbase, mapsize);
+ if (!port.membase) {
+ printk(KERN_ERR "%s: couldn't ioremap 0x%lx-0x%lx\n",
+ __FUNCTION__, port.mapbase, port.mapbase + mapsize);
+ return;
+ }
+ port.iotype = UPIO_MEM;
} else if (uart->addr.address_space_id = ACPI_ADR_SPACE_SYSTEM_IO) {
port.iobase = uart->addr.address;
- port.iotype = SERIAL_IO_PORT;
+ port.iotype = UPIO_PORT;
} else
return;
@@ -102,7 +108,7 @@
add_preferred_console("ttyS", port.line, options);
printk(KERN_INFO "PCDP: serial console at %s 0x%lx (ttyS%d, options %s)\n",
- port.iotype = SERIAL_IO_MEM ? "MMIO" : "I/O",
+ port.iotype = UPIO_MEM ? "MMIO" : "I/O",
uart->addr.address, port.line, options);
#endif
}
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
"Bjorn" = Bjorn Helgaas <[email protected]> writes:
Hi Bjorn
Changeset [email protected]|ChangeSet|20040701140332|57856
broke the pcdp.c console setup, because it removes UPF_RESOURCES.
P ChangeSet
C [SERIAL] Remove UPF_RESOURCES
C
C The UPF_RESOURCES flag was added to the serial layer to cater for C the idiosyncrasies of the PCMCIA layer, where the PCMCIA core code C handles the claiming of busy resources.
C
C However, the PCMCIA core has progressed, and now does not claim busy C resources - IOW, it now behaves just like any other bus driver, C where resources are allocated non-busy and its up to the drivers to C mark their regions busy using request_region / request_mem_region. C
C The effect of this is that the UPF_RESOURCES hack in the serial C layer is now redundant, and can now be removed - 8250 devices C should now always use request_region / request_mem_region C unconditionally.
C
C Signed-off-by: Russell King.
I fixed here temporarily by just removing the UPF_RESOURCES flag, but really something more than that is needed.
--
Dr Peter Chubb http://www.gelato.unsw.edu.au peterc AT gelato.unsw.edu.au The technical we do immediately, the political takes *forever*