pcdp.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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. */
  13. #include <linux/config.h>
  14. #include <linux/acpi.h>
  15. #include <linux/console.h>
  16. #include <linux/efi.h>
  17. #include <linux/serial.h>
  18. #include "pcdp.h"
  19. static int __init
  20. setup_serial_console(struct pcdp_uart *uart)
  21. {
  22. #ifdef CONFIG_SERIAL_8250_CONSOLE
  23. int mmio;
  24. static char options[64], *p = options;
  25. mmio = (uart->addr.address_space_id == ACPI_ADR_SPACE_SYSTEM_MEMORY);
  26. p += sprintf(p, "console=uart,%s,0x%lx",
  27. mmio ? "mmio" : "io", uart->addr.address);
  28. if (uart->baud)
  29. p += sprintf(p, ",%lu", uart->baud);
  30. if (uart->bits)
  31. p += sprintf(p, "n%d", uart->bits);
  32. return early_serial_console_init(options);
  33. #else
  34. return -ENODEV;
  35. #endif
  36. }
  37. static int __init
  38. setup_vga_console(struct pcdp_vga *vga)
  39. {
  40. #if defined(CONFIG_VT) && defined(CONFIG_VGA_CONSOLE)
  41. if (efi_mem_type(0xA0000) == EFI_CONVENTIONAL_MEMORY) {
  42. printk(KERN_ERR "PCDP: VGA selected, but frame buffer is not MMIO!\n");
  43. return -ENODEV;
  44. }
  45. conswitchp = &vga_con;
  46. printk(KERN_INFO "PCDP: VGA console\n");
  47. return 0;
  48. #else
  49. return -ENODEV;
  50. #endif
  51. }
  52. int __init
  53. efi_setup_pcdp_console(char *cmdline)
  54. {
  55. struct pcdp *pcdp;
  56. struct pcdp_uart *uart;
  57. struct pcdp_device *dev, *end;
  58. int i, serial = 0;
  59. pcdp = efi.hcdp;
  60. if (!pcdp)
  61. return -ENODEV;
  62. printk(KERN_INFO "PCDP: v%d at 0x%lx\n", pcdp->rev, __pa(pcdp));
  63. if (strstr(cmdline, "console=hcdp")) {
  64. if (pcdp->rev < 3)
  65. serial = 1;
  66. } else if (strstr(cmdline, "console=")) {
  67. printk(KERN_INFO "Explicit \"console=\"; ignoring PCDP\n");
  68. return -ENODEV;
  69. }
  70. if (pcdp->rev < 3 && efi_uart_console_only())
  71. serial = 1;
  72. for (i = 0, uart = pcdp->uart; i < pcdp->num_uarts; i++, uart++) {
  73. if (uart->flags & PCDP_UART_PRIMARY_CONSOLE || serial) {
  74. if (uart->type == PCDP_CONSOLE_UART) {
  75. return setup_serial_console(uart);
  76. }
  77. }
  78. }
  79. end = (struct pcdp_device *) ((u8 *) pcdp + pcdp->length);
  80. for (dev = (struct pcdp_device *) (pcdp->uart + pcdp->num_uarts);
  81. dev < end;
  82. dev = (struct pcdp_device *) ((u8 *) dev + dev->length)) {
  83. if (dev->flags & PCDP_PRIMARY_CONSOLE) {
  84. if (dev->type == PCDP_CONSOLE_VGA) {
  85. return setup_vga_console((struct pcdp_vga *) dev);
  86. }
  87. }
  88. }
  89. return -ENODEV;
  90. }