display.c 2.1 KB

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