sysres.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. /*++
  2. Copyright (c) 2012 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. sysres.h
  9. Abstract:
  10. This header contains definitions for builtin system resources.
  11. Author:
  12. Evan Green 17-Oct-2012
  13. --*/
  14. //
  15. // ------------------------------------------------------------------- Includes
  16. //
  17. //
  18. // ---------------------------------------------------------------- Definitions
  19. //
  20. //
  21. // ------------------------------------------------------ Data Type Definitions
  22. //
  23. typedef enum _SYSTEM_RESOURCE_TYPE {
  24. SystemResourceInvalid,
  25. SystemResourceFrameBuffer,
  26. SystemResourceRamDisk,
  27. SystemResourceHardwareModule,
  28. SystemResourceDebugDevice,
  29. SystemResourceMemory,
  30. } SYSTEM_RESOURCE_TYPE, *PSYSTEM_RESOURCE_TYPE;
  31. typedef enum _SYSTEM_MEMORY_RESOURCE_TYPE {
  32. SystemMemoryResourceHardwareModule,
  33. SystemMemoryResourceHardwareModuleDevice,
  34. } SYSTEM_MEMORY_RESOURCE_TYPE, *PSYSTEM_MEMORY_RESOURCE_TYPE;
  35. /*++
  36. Structure Description:
  37. This structure stores the common header for a builtin system resource.
  38. Members:
  39. ListEntry - Stores pointers to the next and previous system resources.
  40. Type - Stores the type of the system resource being described.
  41. Acquired - Stores a boolean indicating whether this resource is already
  42. acquired.
  43. PhysicalAddress - Stores the physical address of the resource, if the
  44. resource requires memory address space.
  45. Size - Stores the size of the frame buffer, in bytes. This will be 0 if the
  46. device requires no memory mapped resources.
  47. VirtualAddress - Stores the mapped virtual address of the frame buffer. This
  48. will be NULL if the device requires no memory mapped resoures, or the
  49. resources have not yet been mapped.
  50. --*/
  51. typedef struct _SYSTEM_RESOURCE_HEADER {
  52. LIST_ENTRY ListEntry;
  53. SYSTEM_RESOURCE_TYPE Type;
  54. BOOL Acquired;
  55. PHYSICAL_ADDRESS PhysicalAddress;
  56. ULONGLONG Size;
  57. PVOID VirtualAddress;
  58. } SYSTEM_RESOURCE_HEADER, *PSYSTEM_RESOURCE_HEADER;
  59. /*++
  60. Structure Description:
  61. This structure stores information about a frame buffer resource.
  62. Members:
  63. Header - Stores the common system resource header.
  64. Mode - Stores the base video mode. This is of type BASE_VIDEO_MODE.
  65. Width - Stores the width of the frame buffer, in pixels.
  66. Height - Stores the height of the frame buffer, in pixels.
  67. BitsPerPixel - Stores the number of bits that correspond to one pixel.
  68. PixelsPerScanLine - Stores the number of pixels in a scan line.
  69. RedMask - Stores the mask of bits in the pixel that correspond to the red
  70. channel. This is assumed to be a contiguous chunk of bits.
  71. GreenMask - Stores the mask of bits in the pixel that correspond to the
  72. green channel. This is assumed to be a contiguous chunk of bits.
  73. BlueMask - Stores the mask of bits in the pixel that correspond to the blue
  74. channel. This is assumed to be a contiguous chunk of bits.
  75. --*/
  76. typedef struct _SYSTEM_RESOURCE_FRAME_BUFFER {
  77. SYSTEM_RESOURCE_HEADER Header;
  78. ULONG Mode;
  79. ULONG Width;
  80. ULONG Height;
  81. ULONG BitsPerPixel;
  82. ULONG PixelsPerScanLine;
  83. ULONG RedMask;
  84. ULONG GreenMask;
  85. ULONG BlueMask;
  86. } SYSTEM_RESOURCE_FRAME_BUFFER, *PSYSTEM_RESOURCE_FRAME_BUFFER;
  87. /*++
  88. Structure Description:
  89. This structure stores information about a hardware module device resource.
  90. Members:
  91. Header - Stores the common system resource header.
  92. --*/
  93. typedef struct _SYSTEM_RESOURCE_HARDWARE_MODULE {
  94. SYSTEM_RESOURCE_HEADER Header;
  95. } SYSTEM_RESOURCE_HARDWARE_MODULE, *PSYSTEM_RESOURCE_HARDWARE_MODULE;
  96. /*++
  97. Structure Description:
  98. This structure stores information about a RAM disk resource.
  99. Members:
  100. Header - Stores the common system resource header.
  101. --*/
  102. typedef struct _SYSTEM_RESOURCE_RAM_DISK {
  103. SYSTEM_RESOURCE_HEADER Header;
  104. } SYSTEM_RESOURCE_RAM_DISK, *PSYSTEM_RESOURCE_RAM_DISK;
  105. /*++
  106. Structure Description:
  107. This structure stores information about a debug device resource.
  108. Members:
  109. Header - Stores the common system resource header.
  110. --*/
  111. typedef struct _SYSTEM_RESOURCE_DEBUG_DEVICE {
  112. SYSTEM_RESOURCE_HEADER Header;
  113. } SYSTEM_RESOURCE_DEBUG_DEVICE, *PSYSTEM_RESOURCE_DEBUG_DEVICE;
  114. /*++
  115. Structure Description:
  116. This structure stores information about a system memory resource.
  117. Members:
  118. Header - Stores the common system resource header.
  119. MemoryType - Stores the type of memory this resource represents.
  120. --*/
  121. typedef struct _SYSTEM_RESOURCE_MEMORY {
  122. SYSTEM_RESOURCE_HEADER Header;
  123. SYSTEM_MEMORY_RESOURCE_TYPE MemoryType;
  124. } SYSTEM_RESOURCE_MEMORY, *PSYSTEM_RESOURCE_MEMORY;
  125. //
  126. // -------------------------------------------------------------------- Globals
  127. //
  128. //
  129. // -------------------------------------------------------- Function Prototypes
  130. //
  131. KERNEL_API
  132. PSYSTEM_RESOURCE_HEADER
  133. KeAcquireSystemResource (
  134. SYSTEM_RESOURCE_TYPE ResourceType
  135. );
  136. /*++
  137. Routine Description:
  138. This routine attempts to find an unacquired system resource of the given
  139. type.
  140. Arguments:
  141. ResourceType - Supplies a pointer to the type of builtin resource to
  142. acquire.
  143. Return Value:
  144. Returns a pointer to a resource of the given type on success.
  145. NULL on failure.
  146. --*/
  147. KERNEL_API
  148. VOID
  149. KeReleaseSystemResource (
  150. PSYSTEM_RESOURCE_HEADER ResourceHeader
  151. );
  152. /*++
  153. Routine Description:
  154. This routine releases a system resource.
  155. Arguments:
  156. ResourceHeader - Supplies a pointer to the resource header to release back
  157. to the system.
  158. Return Value:
  159. None.
  160. --*/