sysres.h 5.4 KB

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