console.c 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /*
  2. * linux/arch/alpha/kernel/console.c
  3. *
  4. * Architecture-specific specific support for VGA device on
  5. * non-0 I/O hose
  6. */
  7. #include <linux/pci.h>
  8. #include <linux/init.h>
  9. #include <linux/tty.h>
  10. #include <linux/console.h>
  11. #include <linux/vt.h>
  12. #include <asm/vga.h>
  13. #include <asm/machvec.h>
  14. #include "pci_impl.h"
  15. #ifdef CONFIG_VGA_HOSE
  16. struct pci_controller *pci_vga_hose;
  17. static struct resource alpha_vga = {
  18. .name = "alpha-vga+",
  19. .flags = IORESOURCE_IO,
  20. .start = 0x3C0,
  21. .end = 0x3DF
  22. };
  23. static struct pci_controller * __init
  24. default_vga_hose_select(struct pci_controller *h1, struct pci_controller *h2)
  25. {
  26. if (h2->index < h1->index)
  27. return h2;
  28. return h1;
  29. }
  30. void __init
  31. locate_and_init_vga(void *(*sel_func)(void *, void *))
  32. {
  33. struct pci_controller *hose = NULL;
  34. struct pci_dev *dev = NULL;
  35. /* Default the select function */
  36. if (!sel_func) sel_func = (void *)default_vga_hose_select;
  37. /* Find the console VGA device */
  38. for(dev=NULL; (dev=pci_get_class(PCI_CLASS_DISPLAY_VGA << 8, dev));) {
  39. if (!hose)
  40. hose = dev->sysdata;
  41. else
  42. hose = sel_func(hose, dev->sysdata);
  43. }
  44. /* Did we already initialize the correct one? Is there one? */
  45. if (!hose || (conswitchp == &vga_con && pci_vga_hose == hose))
  46. return;
  47. /* Create a new VGA ioport resource WRT the hose it is on. */
  48. alpha_vga.start += hose->io_space->start;
  49. alpha_vga.end += hose->io_space->start;
  50. request_resource(hose->io_space, &alpha_vga);
  51. /* Set the VGA hose and init the new console. */
  52. pci_vga_hose = hose;
  53. console_lock();
  54. do_take_over_console(&vga_con, 0, MAX_NR_CONSOLES-1, 1);
  55. console_unlock();
  56. }
  57. void __init
  58. find_console_vga_hose(void)
  59. {
  60. u64 *pu64 = (u64 *)((u64)hwrpb + hwrpb->ctbt_offset);
  61. if (pu64[7] == 3) { /* TERM_TYPE == graphics */
  62. struct pci_controller *hose;
  63. int h = (pu64[30] >> 24) & 0xff; /* console hose # */
  64. /*
  65. * Our hose numbering DOES match the console's, so find
  66. * the right one...
  67. */
  68. for (hose = hose_head; hose; hose = hose->next) {
  69. if (hose->index == h) break;
  70. }
  71. if (hose) {
  72. printk("Console graphics on hose %d\n", h);
  73. pci_vga_hose = hose;
  74. }
  75. }
  76. }
  77. #endif