pit.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * GRUB -- GRand Unified Bootloader
  3. * Copyright (C) 2008 Free Software Foundation, Inc.
  4. *
  5. * GRUB is free software: you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation, either version 3 of the License, or
  8. * (at your option) any later version.
  9. *
  10. * GRUB is distributed in the hope that it will be useful,
  11. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. * GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with GRUB. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #ifndef KERNEL_CPU_PIT_HEADER
  19. #define KERNEL_CPU_PIT_HEADER 1
  20. #include <grub/types.h>
  21. #include <grub/err.h>
  22. enum
  23. {
  24. /* The PIT channel value ports. You can write to and read from them.
  25. Do not mess with timer 0 or 1. */
  26. GRUB_PIT_COUNTER_0 = 0x40,
  27. GRUB_PIT_COUNTER_1 = 0x41,
  28. GRUB_PIT_COUNTER_2 = 0x42,
  29. /* The PIT control port. You can only write to it. Do not mess with
  30. timer 0 or 1. */
  31. GRUB_PIT_CTRL = 0x43,
  32. /* The speaker port. */
  33. GRUB_PIT_SPEAKER_PORT = 0x61,
  34. };
  35. /* The speaker port. */
  36. enum
  37. {
  38. /* If 0, follow state of SPEAKER_DATA bit, otherwise enable output
  39. from timer 2. */
  40. GRUB_PIT_SPK_TMR2 = 0x01,
  41. /* If SPEAKER_TMR2 is not set, this provides direct input into the
  42. speaker. Otherwise, this enables or disables the output from the
  43. timer. */
  44. GRUB_PIT_SPK_DATA = 0x02,
  45. GRUB_PIT_SPK_TMR2_LATCH = 0x20
  46. };
  47. /* The PIT control port. You can only write to it. Do not mess with
  48. timer 0 or 1. */
  49. enum
  50. {
  51. GRUB_PIT_CTRL_SELECT_MASK = 0xc0,
  52. GRUB_PIT_CTRL_SELECT_0 = 0x00,
  53. GRUB_PIT_CTRL_SELECT_1 = 0x40,
  54. GRUB_PIT_CTRL_SELECT_2 = 0x80,
  55. /* Read and load control. */
  56. GRUB_PIT_CTRL_READLOAD_MASK= 0x30,
  57. GRUB_PIT_CTRL_COUNTER_LATCH = 0x00, /* Hold timer value until read. */
  58. GRUB_PIT_CTRL_READLOAD_LSB = 0x10, /* Read/load the LSB. */
  59. GRUB_PIT_CTRL_READLOAD_MSB = 0x20, /* Read/load the MSB. */
  60. GRUB_PIT_CTRL_READLOAD_WORD = 0x30, /* Read/load the LSB then the MSB. */
  61. /* Mode control. */
  62. GRUB_PIT_CTRL_MODE_MASK = 0x0e,
  63. /* Interrupt on terminal count. Setting the mode sets output to low.
  64. When counter is set and terminated, output is set to high. */
  65. GRUB_PIT_CTRL_INTR_ON_TERM = 0x00,
  66. /* Programmable one-shot. When loading counter, output is set to
  67. high. When counter terminated, output is set to low. Can be
  68. triggered again from that point on by setting the gate pin to
  69. high. */
  70. GRUB_PIT_CTRL_PROGR_ONE_SHOT = 0x02,
  71. /* Rate generator. Output is low for one period of the counter, and
  72. high for the other. */
  73. GRUB_PIT_CTRL_RATE_GEN = 0x04,
  74. /* Square wave generator. Output is low for one half of the period,
  75. and high for the other half. */
  76. GRUB_PIT_CTRL_SQUAREWAVE_GEN = 0x06,
  77. /* Software triggered strobe. Setting the mode sets output to high.
  78. When counter is set and terminated, output is set to low. */
  79. GRUB_PIT_CTRL_SOFTSTROBE = 0x08,
  80. /* Hardware triggered strobe. Like software triggered strobe, but
  81. only starts the counter when the gate pin is set to high. */
  82. GRUB_PIT_CTRL_HARDSTROBE = 0x0a,
  83. /* Count mode. */
  84. GRUB_PIT_CTRL_COUNT_MASK = 0x01,
  85. GRUB_PIT_CTRL_COUNT_BINARY = 0x00, /* 16-bit binary counter. */
  86. GRUB_PIT_CTRL_COUNT_BCD = 0x01 /* 4-decade BCD counter. */
  87. };
  88. #endif /* ! KERNEL_CPU_PIT_HEADER */