console.c 2.1 KB

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