gt.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. /*++
  2. Copyright (c) 2016 Minoca Corp.
  3. This file is licensed under the terms of the GNU General Public License
  4. version 3. Alternative licensing terms are available. Contact
  5. info@minocacorp.com for details. See the LICENSE file at the root of this
  6. project for complete licensing information.
  7. Module Name:
  8. gt.h
  9. Abstract:
  10. This header contains definitions for the ARM Generic Timer.
  11. Author:
  12. Chris Stevens 9-Jun-2016
  13. --*/
  14. //
  15. // ------------------------------------------------------------------- Includes
  16. //
  17. //
  18. // ---------------------------------------------------------------- Definitions
  19. //
  20. //
  21. // ------------------------------------------------------ Data Type Definitions
  22. //
  23. /*++
  24. Structure Description:
  25. This structure describes the Generic Timer context.
  26. Members:
  27. Period - Stores the interrupt period in timer ticks.
  28. DueTime - Stores the current absolute time the timer is due to interrupt.
  29. --*/
  30. typedef struct _GT_CONTEXT {
  31. UINT64 Period;
  32. UINT64 DueTime;
  33. } GT_CONTEXT, *PGT_CONTEXT;
  34. //
  35. // -------------------------------------------------------------------- Globals
  36. //
  37. //
  38. // -------------------------------------------------------- Function Prototypes
  39. //
  40. EFI_STATUS
  41. EfipGtInitialize (
  42. PGT_CONTEXT Context
  43. );
  44. /*++
  45. Routine Description:
  46. This routine initializes an ARM Generic Timer.
  47. Arguments:
  48. Context - Supplies a pointer to the timer context.
  49. Return Value:
  50. EFI Status code.
  51. --*/
  52. UINT64
  53. EfipGtRead (
  54. PGT_CONTEXT Context
  55. );
  56. /*++
  57. Routine Description:
  58. This routine returns the hardware counter's raw value.
  59. Arguments:
  60. Context - Supplies a pointer to the timer context.
  61. Return Value:
  62. Returns the timer's current count.
  63. --*/
  64. EFI_STATUS
  65. EfipGtArm (
  66. PGT_CONTEXT Context,
  67. BOOLEAN Periodic,
  68. UINT64 TickCount
  69. );
  70. /*++
  71. Routine Description:
  72. This routine arms the timer to fire an interrupt after the specified number
  73. of ticks.
  74. Arguments:
  75. Context - Supplies a pointer to the timer context.
  76. Periodic - Supplies a boolean indicating whether or not the timer should
  77. interrupt periodically or just once.
  78. TickCount - Supplies the number of timer ticks from now for the timer to
  79. fire in.
  80. Return Value:
  81. EFI Status code.
  82. --*/
  83. VOID
  84. EfipGtDisarm (
  85. PGT_CONTEXT Context
  86. );
  87. /*++
  88. Routine Description:
  89. This routine disarms the timer, stopping interrupts from firing.
  90. Arguments:
  91. Context - Supplies a pointer to the timer context.
  92. Return Value:
  93. None.
  94. --*/
  95. VOID
  96. EfipGtAcknowledgeInterrupt (
  97. PGT_CONTEXT Context
  98. );
  99. /*++
  100. Routine Description:
  101. This routine performs any actions necessary upon reciept of a timer's
  102. interrupt. This may involve writing to an acknowledge register to re-enable
  103. the timer to fire again, or other hardware specific actions.
  104. Arguments:
  105. Context - Supplies a pointer to the timer context.
  106. Return Value:
  107. None.
  108. --*/