Windows NT 4.0 source code leak
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

195 lines
3.4 KiB

4 years ago
  1. #if defined(JAZZ)
  2. /*++
  3. Copyright (c) 1991 Microsoft Corporation
  4. Module Name:
  5. jxvendor.c
  6. Abstract:
  7. Implementation of the vendor private routines for the Jazz ARC firmware.
  8. Author:
  9. David M. Robinson (davidro) 13-June-1991
  10. Revision History:
  11. --*/
  12. #include "fwp.h"
  13. //
  14. // Routine prototypes.
  15. //
  16. PVOID
  17. FwAllocatePool(
  18. IN ULONG NumberOfBytes
  19. );
  20. VOID
  21. FwStallExecution (
  22. IN ULONG MicroSeconds
  23. );
  24. //
  25. // Static Variables
  26. //
  27. PCHAR FwPoolBase;
  28. PCHAR FwFreePool;
  29. VOID
  30. FwVendorInitialize(
  31. VOID
  32. )
  33. /*++
  34. Routine Description:
  35. This routine initializes the vendor private routines.
  36. Arguments:
  37. None.
  38. Return Value:
  39. None.
  40. --*/
  41. {
  42. //
  43. // Initialize pointers and zero memory for the allocate pool routine.
  44. //
  45. FwPoolBase = (PCHAR)FW_POOL_BASE;
  46. FwFreePool = (PCHAR)FW_POOL_BASE;
  47. RtlZeroMemory(FwPoolBase, FW_POOL_SIZE);
  48. //
  49. // Initialize the vendor routine vector.
  50. //
  51. (PVEN_ALLOCATE_POOL_ROUTINE)SYSTEM_BLOCK->VendorVector[AllocatePoolRoutine] =
  52. FwAllocatePool;
  53. (PVEN_STALL_EXECUTION_ROUTINE)SYSTEM_BLOCK->VendorVector[StallExecutionRoutine] =
  54. FwStallExecution;
  55. (PVEN_PRINT_ROUTINE)SYSTEM_BLOCK->VendorVector[PrintRoutine] =
  56. FwPrint;
  57. return;
  58. }
  59. PVOID
  60. FwAllocatePool(
  61. IN ULONG NumberOfBytes
  62. )
  63. /*++
  64. Routine Description:
  65. This routine allocates the requested number of bytes from the firmware
  66. pool. If enough pool exists to satisfy the request, a pointer to the
  67. next free cache-aligned block is returned, otherwise NULL is returned.
  68. The pool is zeroed at initialization time, and no corresponding
  69. "FwFreePool" routine exists.
  70. Arguments:
  71. NumberOfBytes - Supplies the number of bytes to allocate.
  72. Return Value:
  73. NULL - Not enough pool exists to satisfy the request.
  74. NON-NULL - Returns a pointer to the allocated pool.
  75. --*/
  76. {
  77. PVOID Pool;
  78. //
  79. // If there is not enough free pool for this request or the requested
  80. // number of bytes is zero, return NULL, otherwise return a pointer to
  81. // the free block and update the free pointer.
  82. //
  83. if (((FwFreePool + NumberOfBytes) > (FwPoolBase + FW_POOL_SIZE)) ||
  84. (NumberOfBytes == 0)) {
  85. Pool = NULL;
  86. } else {
  87. Pool = FwFreePool;
  88. //
  89. // Move pointer to the next cache aligned section of free pool.
  90. //
  91. FwFreePool += ((NumberOfBytes - 1) & ~(KeGetDcacheFillSize() - 1)) +
  92. KeGetDcacheFillSize();
  93. }
  94. return Pool;
  95. }
  96. VOID
  97. FwStallExecution (
  98. IN ULONG MicroSeconds
  99. )
  100. /*++
  101. Routine Description:
  102. This function stalls execution for the specified number of microseconds.
  103. Arguments:
  104. MicroSeconds - Supplies the number of microseconds that execution is to be
  105. stalled.
  106. Return Value:
  107. None.
  108. --*/
  109. {
  110. ULONG Index;
  111. ULONG Limit;
  112. PULONG Store;
  113. ULONG Value;
  114. //
  115. // ****** begin temporary code ******
  116. //
  117. // This code must be replaced with a smarter version. For now it assumes
  118. // an execution rate of 50,000,000 instructions per second and 4 instructions
  119. // per iteration.
  120. //
  121. Store = &Value;
  122. Limit = (MicroSeconds * 50 / 4);
  123. for (Index = 0; Index < Limit; Index += 1) {
  124. *Store = Index;
  125. }
  126. return;
  127. }
  128. #endif