sc15025.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. #include <u.h>
  2. #include <libc.h>
  3. #include <bio.h>
  4. #include "pci.h"
  5. #include "vga.h"
  6. /*
  7. * Sierra SC1502[56] HiCOLOR-24 Palette.
  8. */
  9. static void
  10. pixmask(void)
  11. {
  12. inportb(PaddrW);
  13. }
  14. static void
  15. commandrw(void)
  16. {
  17. int i;
  18. pixmask();
  19. for(i = 0; i < 4; i++)
  20. inportb(Pixmask);
  21. }
  22. static uchar
  23. commandr(void)
  24. {
  25. uchar command;
  26. commandrw();
  27. command = inportb(Pixmask);
  28. pixmask();
  29. return command;
  30. }
  31. static void
  32. commandw(uchar command)
  33. {
  34. commandrw();
  35. outportb(Pixmask, command);
  36. pixmask();
  37. }
  38. static void
  39. options(Vga*, Ctlr* ctlr)
  40. {
  41. ctlr->flag |= Foptions;
  42. }
  43. static void
  44. init(Vga* vga, Ctlr* ctlr)
  45. {
  46. ulong pclk;
  47. char *p;
  48. /*
  49. * Part comes in -125, -110, -80, and -66MHz speed-grades.
  50. * Work out the part speed-grade from name. Name can have,
  51. * e.g. '-110' on the end for 100MHz part.
  52. */
  53. pclk = 66000000;
  54. if(p = strrchr(ctlr->name, '-'))
  55. pclk = strtoul(p+1, 0, 0) * 1000000;
  56. /*
  57. * If we don't already have a desired pclk,
  58. * take it from the mode.
  59. * Check it's within range.
  60. */
  61. if(vga->f[0] == 0)
  62. vga->f[0] = vga->mode->frequency;
  63. if(vga->f[0] > pclk)
  64. error("%s: invalid pclk - %ld\n", ctlr->name, vga->f[0]);
  65. }
  66. static void
  67. load(Vga*, Ctlr*)
  68. {
  69. uchar aux, command;
  70. aux = 0x00;
  71. /*
  72. if(vga->mode->z == 8)
  73. aux = 0x01;
  74. */
  75. commandrw();
  76. command = inportb(Pixmask);
  77. outportb(Pixmask, command|0x18);
  78. outportb(PaddrR, 0x08);
  79. outportb(PaddrW, aux);
  80. commandw(command);
  81. }
  82. static void
  83. dump(Vga*, Ctlr* ctlr)
  84. {
  85. int i;
  86. uchar command;
  87. printitem(ctlr->name, "command");
  88. command = commandr();
  89. printreg(command);
  90. printitem(ctlr->name, "index08");
  91. commandw(command|0x10);
  92. for(i = 0x08; i < 0x11; i++){
  93. outportb(PaddrR, i);
  94. printreg(inportb(PaddrW));
  95. }
  96. commandw(command);
  97. }
  98. Ctlr sc15025 = {
  99. "sc15025", /* name */
  100. 0, /* snarf */
  101. options, /* options */
  102. init, /* init */
  103. load, /* load */
  104. dump, /* dump */
  105. };