display.c 1.8 KB

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