display.c 3.1 KB

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