info.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. /*++
  2. Copyright (c) 2014 Minoca Corp. All Rights Reserved
  3. Module Name:
  4. info.c
  5. Abstract:
  6. This module implements support for handling I/O subsystem information
  7. requests.
  8. Author:
  9. Evan Green 10-Apr-2014
  10. Environment:
  11. Kernel
  12. --*/
  13. //
  14. // ------------------------------------------------------------------- Includes
  15. //
  16. #include <minoca/kernel/kernel.h>
  17. #include "iop.h"
  18. //
  19. // ---------------------------------------------------------------- Definitions
  20. //
  21. //
  22. // ------------------------------------------------------ Data Type Definitions
  23. //
  24. //
  25. // ----------------------------------------------- Internal Function Prototypes
  26. //
  27. KSTATUS
  28. IopGetSetBootInformation (
  29. PVOID Data,
  30. PUINTN DataSize,
  31. BOOL Set
  32. );
  33. KSTATUS
  34. IopGetCacheStatistics (
  35. PVOID Data,
  36. PUINTN DataSize,
  37. BOOL Set
  38. );
  39. //
  40. // -------------------------------------------------------------------- Globals
  41. //
  42. //
  43. // Store the saved boot information.
  44. //
  45. IO_BOOT_INFORMATION IoBootInformation;
  46. //
  47. // ------------------------------------------------------------------ Functions
  48. //
  49. KSTATUS
  50. IoGetSetSystemInformation (
  51. BOOL FromKernelMode,
  52. IO_INFORMATION_TYPE InformationType,
  53. PVOID Data,
  54. PUINTN DataSize,
  55. BOOL Set
  56. )
  57. /*++
  58. Routine Description:
  59. This routine gets or sets system information.
  60. Arguments:
  61. FromKernelMode - Supplies a boolean indicating whether or not this request
  62. (and the buffer associated with it) originates from user mode (FALSE)
  63. or kernel mode (TRUE).
  64. InformationType - Supplies the information type.
  65. Data - Supplies a pointer to the data buffer where the data is either
  66. returned for a get operation or given for a set operation.
  67. DataSize - Supplies a pointer that on input contains the size of the
  68. data buffer. On output, contains the required size of the data buffer.
  69. Set - Supplies a boolean indicating if this is a get operation (FALSE) or
  70. a set operation (TRUE).
  71. Return Value:
  72. Status code.
  73. --*/
  74. {
  75. KSTATUS Status;
  76. switch (InformationType) {
  77. case IoInformationBoot:
  78. Status = IopGetSetBootInformation(Data, DataSize, Set);
  79. break;
  80. case IoInformationMountPoints:
  81. Status = IopGetSetMountPointInformation(Data, DataSize, Set);
  82. break;
  83. case IoInformationCacheStatistics:
  84. Status = IopGetCacheStatistics(Data, DataSize, Set);
  85. break;
  86. default:
  87. Status = STATUS_INVALID_PARAMETER;
  88. *DataSize = 0;
  89. break;
  90. }
  91. return Status;
  92. }
  93. //
  94. // --------------------------------------------------------- Internal Functions
  95. //
  96. KSTATUS
  97. IopGetSetBootInformation (
  98. PVOID Data,
  99. PUINTN DataSize,
  100. BOOL Set
  101. )
  102. /*++
  103. Routine Description:
  104. This routine gets or sets boot information.
  105. Arguments:
  106. Data - Supplies a pointer to the data buffer where the data is either
  107. returned for a get operation or given for a set operation.
  108. DataSize - Supplies a pointer that on input contains the size of the
  109. data buffer. On output, contains the required size of the data buffer.
  110. Set - Supplies a boolean indicating if this is a get operation (FALSE) or
  111. a set operation (TRUE).
  112. Return Value:
  113. Status code.
  114. --*/
  115. {
  116. if (*DataSize != sizeof(IO_BOOT_INFORMATION)) {
  117. *DataSize = sizeof(IO_BOOT_INFORMATION);
  118. return STATUS_DATA_LENGTH_MISMATCH;
  119. }
  120. if (Set != FALSE) {
  121. *DataSize = 0;
  122. return STATUS_ACCESS_DENIED;
  123. }
  124. RtlCopyMemory(Data, &IoBootInformation, sizeof(IO_BOOT_INFORMATION));
  125. return STATUS_SUCCESS;
  126. }
  127. KSTATUS
  128. IopGetCacheStatistics (
  129. PVOID Data,
  130. PUINTN DataSize,
  131. BOOL Set
  132. )
  133. /*++
  134. Routine Description:
  135. This routine gets page cache statistics.
  136. Arguments:
  137. Data - Supplies a pointer to the data buffer where the data is either
  138. returned for a get operation or given for a set operation.
  139. DataSize - Supplies a pointer that on input contains the size of the
  140. data buffer. On output, contains the required size of the data buffer.
  141. Set - Supplies a boolean indicating if this is a get operation (FALSE) or
  142. a set operation (TRUE).
  143. Return Value:
  144. Status code.
  145. --*/
  146. {
  147. if (*DataSize != sizeof(IO_CACHE_STATISTICS)) {
  148. *DataSize = sizeof(IO_CACHE_STATISTICS);
  149. return STATUS_DATA_LENGTH_MISMATCH;
  150. }
  151. if (Set != FALSE) {
  152. return STATUS_ACCESS_DENIED;
  153. }
  154. return IoGetCacheStatistics(Data);
  155. }