archsupc.c 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /*++
  2. Copyright (c) 2014 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. archsupc.c
  5. Abstract:
  6. This module implements ARMv7 processor architecture features.
  7. Author:
  8. Chris Stevens 3-Feb-2014
  9. Environment:
  10. Kernel
  11. --*/
  12. //
  13. // ------------------------------------------------------------------- Includes
  14. //
  15. #include <minoca/kernel/kernel.h>
  16. #include <minoca/kernel/arm.h>
  17. //
  18. // ---------------------------------------------------------------- Definitions
  19. //
  20. //
  21. // ------------------------------------------------------ Data Type Definitions
  22. //
  23. //
  24. // ----------------------------------------------- Internal Function Prototypes
  25. //
  26. //
  27. // -------------------------------------------------------------------- Globals
  28. //
  29. //
  30. // ------------------------------------------------------------------ Functions
  31. //
  32. VOID
  33. ArSetUpUserSharedDataFeatures (
  34. VOID
  35. )
  36. /*++
  37. Routine Description:
  38. This routine initialize the user shared data processor specific features.
  39. Arguments:
  40. None.
  41. Return Value:
  42. None.
  43. --*/
  44. {
  45. ULONG Architecture;
  46. PUSER_SHARED_DATA Data;
  47. ULONG MainId;
  48. Data = MmGetUserSharedData();
  49. MainId = ArGetMainIdRegister();
  50. Architecture = (MainId & ARM_MAIN_ID_ARCHITECTURE_MASK) >>
  51. ARM_MAIN_ID_ARCHITECTURE_SHIFT;
  52. if (Architecture == ARM_MAIN_ID_ARCHITECTURE_CPUID) {
  53. Data->ProcessorFeatures |= ARM_FEATURE_V7;
  54. }
  55. ArInitializeVfpSupport();
  56. return;
  57. }
  58. VOID
  59. ArpInitializePerformanceMonitor (
  60. VOID
  61. )
  62. /*++
  63. Routine Description:
  64. This routine initializes the system's performance monitor.
  65. Arguments:
  66. None.
  67. Return Value:
  68. None.
  69. --*/
  70. {
  71. //
  72. // Disable performance monitor interrupts, and access to the performance
  73. // monitors in user mode.
  74. //
  75. if (ArGetPerformanceControlRegister() != 0) {
  76. ArClearPerformanceInterruptRegister(PERF_MONITOR_COUNTER_MASK);
  77. ArSetPerformanceUserEnableRegister(0);
  78. }
  79. return;
  80. }
  81. VOID
  82. ArSetThreadPointer (
  83. PVOID Thread,
  84. PVOID NewThreadPointer
  85. )
  86. /*++
  87. Routine Description:
  88. This routine sets the new thread pointer value.
  89. Arguments:
  90. Thread - Supplies a pointer to the thread to set the thread pointer for.
  91. NewThreadPointer - Supplies the new thread pointer value to set.
  92. Return Value:
  93. None.
  94. --*/
  95. {
  96. PULONG LowPointer;
  97. RUNLEVEL OldRunLevel;
  98. PKTHREAD TypedThread;
  99. OldRunLevel = KeRaiseRunLevel(RunLevelDispatch);
  100. //
  101. // Only set the low 32-bits, the upper 32-bits are used to hold the
  102. // read/write thread pointer.
  103. //
  104. TypedThread = Thread;
  105. LowPointer = (PULONG)&(TypedThread->ThreadPointer);
  106. *LowPointer = (ULONG)NewThreadPointer;
  107. if (Thread == KeGetCurrentThread()) {
  108. ArSetThreadPointerUserReadOnly(NewThreadPointer);
  109. }
  110. KeLowerRunLevel(OldRunLevel);
  111. return;
  112. }
  113. //
  114. // --------------------------------------------------------- Internal Functions
  115. //