display.c 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /* display command: print resolution, color depth, and other graphics info. */
  2. #include "io.h"
  3. #include "vga.h"
  4. #include "gpu.h"
  5. #include "ati.h"
  6. #include "nvidia.h"
  7. #include "radeon.h"
  8. #include "mouse.h"
  9. #include "fbtext.h"
  10. static void put_uint(unsigned int n)
  11. {
  12. char buf[12];
  13. char *p = buf + sizeof(buf) - 1;
  14. *p = '\0';
  15. if (n == 0) {
  16. io_putchar('0');
  17. return;
  18. }
  19. while (n) {
  20. *--p = (char)('0' + (n % 10));
  21. n /= 10;
  22. }
  23. while (*p)
  24. io_putchar(*p++);
  25. }
  26. static void put_hex(unsigned int n)
  27. {
  28. static const char hex[] = "0123456789ABCDEF";
  29. io_putstr("0x");
  30. if (n == 0) {
  31. io_putchar('0');
  32. return;
  33. }
  34. {
  35. char buf[9];
  36. char *q = buf + 8;
  37. *q = '\0';
  38. while (n) {
  39. *--q = hex[n & 0xF];
  40. n >>= 4;
  41. }
  42. while (*q)
  43. io_putchar(*q++);
  44. }
  45. }
  46. void program_display_main(void)
  47. {
  48. io_putstr("resolution ");
  49. put_uint(vga_fb_width());
  50. io_putstr(" x ");
  51. put_uint(vga_fb_height());
  52. io_putchar('\n');
  53. io_putstr("color depth ");
  54. put_uint(vga_fb_bpp());
  55. io_putstr(" bpp\n");
  56. io_putstr("pitch ");
  57. put_uint(vga_fb_pitch());
  58. io_putstr(" bytes/line\n");
  59. io_putstr("VRAM ");
  60. put_uint(vga_fb_vram_kb());
  61. io_putstr(" KB\n");
  62. io_putstr("LFB ");
  63. put_hex((unsigned int)(unsigned long)vga_fb_ptr());
  64. io_putchar('\n');
  65. io_putstr("LFB phys ");
  66. put_hex((unsigned int)vga_fb_lfb_addr());
  67. io_putchar('\n');
  68. io_putstr("rendering: ");
  69. io_putstr(vga_shadow_is_active() ? "shadow buffer" : "direct");
  70. io_putchar('\n');
  71. {
  72. unsigned int pci_id = vga_fb_pci_id();
  73. if (pci_id) {
  74. io_putstr("GPU ");
  75. io_putstr(gpu_vendor_name());
  76. io_putstr(" PCI ");
  77. put_hex(pci_id & 0xFFFF);
  78. io_putchar(':');
  79. put_hex(pci_id >> 16);
  80. io_putchar('\n');
  81. }
  82. }
  83. if (gpu_vendor() == GPU_VENDOR_ATI) {
  84. unsigned int method = ati_mmio_method();
  85. if (method) {
  86. io_putstr("ATI CRTC ");
  87. put_hex(ati_off_pitch_before());
  88. io_putstr(" -> ");
  89. put_hex(ati_off_pitch_after());
  90. io_putstr(" via ");
  91. if (method == 1)
  92. io_putstr("BAR2");
  93. else if (method == 2)
  94. io_putstr("LFB+8M");
  95. else if (method == 3)
  96. io_putstr("LFB+4M");
  97. else if (method == 4)
  98. io_putstr("IO");
  99. io_putchar('\n');
  100. } else if (ati_is_radeon()) {
  101. io_putstr("ATI Radeon (R200/RV280)");
  102. if (radeon_available())
  103. io_putstr(" hardware cursor");
  104. io_putchar('\n');
  105. }
  106. }
  107. if (gpu_vendor() == GPU_VENDOR_NVIDIA) {
  108. unsigned int lfb = (unsigned int)vga_fb_lfb_addr();
  109. unsigned int bar3 = nvidia_bar3();
  110. io_putstr("NVIDIA ");
  111. io_putstr(nvidia_chip_name());
  112. io_putstr(" chipset ");
  113. put_hex(nvidia_chipset());
  114. io_putstr(" regs ");
  115. put_hex(nvidia_bar0());
  116. io_putstr(" bar3 ");
  117. put_hex(bar3);
  118. if (bar3 && lfb >= bar3) {
  119. /* VRAM offset of the raster (BAR3 maps VRAM 1:1):
  120. the base for offscreen VRAM (cursor image etc.). */
  121. io_putstr(" FB ofs ");
  122. put_hex(lfb - bar3);
  123. }
  124. io_putchar('\n');
  125. }
  126. io_putstr("cursor backend ");
  127. io_putstr(mouse_cursor_backend_name());
  128. io_putchar('\n');
  129. io_putstr("text ");
  130. put_uint(fbtext_get_cols());
  131. io_putstr(" x ");
  132. put_uint(fbtext_get_rows());
  133. io_putstr(" chars\n");
  134. }