display.c 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 "radeon.h"
  7. #include "fbtext.h"
  8. static void put_uint(unsigned int n)
  9. {
  10. char buf[12];
  11. char *p = buf + sizeof(buf) - 1;
  12. *p = '\0';
  13. if (n == 0) {
  14. io_putchar('0');
  15. return;
  16. }
  17. while (n) {
  18. *--p = (char)('0' + (n % 10));
  19. n /= 10;
  20. }
  21. while (*p)
  22. io_putchar(*p++);
  23. }
  24. static void put_hex(unsigned int n)
  25. {
  26. static const char hex[] = "0123456789ABCDEF";
  27. io_putstr("0x");
  28. if (n == 0) {
  29. io_putchar('0');
  30. return;
  31. }
  32. {
  33. char buf[9];
  34. char *q = buf + 8;
  35. *q = '\0';
  36. while (n) {
  37. *--q = hex[n & 0xF];
  38. n >>= 4;
  39. }
  40. while (*q)
  41. io_putchar(*q++);
  42. }
  43. }
  44. void program_display_main(void)
  45. {
  46. io_putstr("resolution ");
  47. put_uint(vga_fb_width());
  48. io_putstr(" x ");
  49. put_uint(vga_fb_height());
  50. io_putchar('\n');
  51. io_putstr("color depth ");
  52. put_uint(vga_fb_bpp());
  53. io_putstr(" bpp\n");
  54. io_putstr("pitch ");
  55. put_uint(vga_fb_pitch());
  56. io_putstr(" bytes/line\n");
  57. io_putstr("VRAM ");
  58. put_uint(vga_fb_vram_kb());
  59. io_putstr(" KB\n");
  60. io_putstr("LFB ");
  61. put_hex((unsigned int)(unsigned long)vga_fb_ptr());
  62. io_putchar('\n');
  63. io_putstr("rendering: ");
  64. io_putstr(vga_shadow_is_active() ? "shadow buffer" : "direct");
  65. io_putchar('\n');
  66. {
  67. unsigned int pci_id = vga_fb_pci_id();
  68. if (pci_id) {
  69. io_putstr("GPU ");
  70. io_putstr(gpu_vendor_name());
  71. io_putstr(" PCI ");
  72. put_hex(pci_id & 0xFFFF);
  73. io_putchar(':');
  74. put_hex(pci_id >> 16);
  75. io_putchar('\n');
  76. }
  77. }
  78. if (gpu_vendor() == GPU_VENDOR_ATI) {
  79. unsigned int method = ati_mmio_method();
  80. if (method) {
  81. io_putstr("ATI CRTC ");
  82. put_hex(ati_off_pitch_before());
  83. io_putstr(" -> ");
  84. put_hex(ati_off_pitch_after());
  85. io_putstr(" via ");
  86. if (method == 1)
  87. io_putstr("BAR2");
  88. else if (method == 2)
  89. io_putstr("LFB+8M");
  90. else if (method == 3)
  91. io_putstr("LFB+4M");
  92. else if (method == 4)
  93. io_putstr("IO");
  94. io_putchar('\n');
  95. } else if (ati_is_radeon()) {
  96. io_putstr("ATI Radeon (R200/RV280)");
  97. if (radeon_available())
  98. io_putstr(" hardware cursor");
  99. io_putchar('\n');
  100. }
  101. }
  102. io_putstr("text ");
  103. put_uint(fbtext_get_cols());
  104. io_putstr(" x ");
  105. put_uint(fbtext_get_rows());
  106. io_putstr(" chars\n");
  107. }