msvc compatibility
[reactos.git] / reactos / include / ddk / mmtypes.h
1 /* $Id: mmtypes.h,v 1.21 2004/12/22 05:06:59 royce Exp $ */
2
3 #ifndef _INCLUDE_DDK_MMTYPES_H
4 #define _INCLUDE_DDK_MMTYPES_H
5
6 #include <ddk/i386/pagesize.h>
7 #include <ntos/mm.h>
8
9 /*
10 * FUNCTION: Determines if the given virtual address is page aligned
11 */
12 #define IS_PAGE_ALIGNED(Va) (((ULONG)Va)&0xfff)
13
14 /*
15 * PURPOSE: Returns the byte offset of a field within a structure
16 */
17 #ifndef FIELD_OFFSET
18 #define FIELD_OFFSET(Type,Field) ((LONG)(&(((Type *)(0))->Field)))
19 #endif
20
21 /*
22 * PURPOSE: Returns the base address structure if the caller knows the
23 * address of a field within the structure
24 * ARGUMENTS:
25 * Address = address of the field
26 * Type = Type of the whole structure
27 * Field = Name of the field whose address is none
28 */
29 #ifndef CONTAINING_RECORD
30 #define CONTAINING_RECORD(Address,Type,Field) ((Type *)(((LONG)Address) - FIELD_OFFSET(Type,Field)))
31 #endif
32
33
34 #define MDL_MAPPED_TO_SYSTEM_VA (0x1)
35 #define MDL_PAGES_LOCKED (0x2)
36 #define MDL_SOURCE_IS_NONPAGED_POOL (0x4)
37 #define MDL_ALLOCATED_FIXED_SIZE (0x8)
38 #define MDL_PARTIAL (0x10)
39 #define MDL_PARTIAL_HAS_BEEN_MAPPED (0x20)
40 #define MDL_IO_PAGE_READ (0x40)
41 #define MDL_WRITE_OPERATION (0x80)
42 #define MDL_PARENT_MAPPED_SYSTEM_VA (0x100)
43 #define MDL_LOCK_HELD (0x200)
44 #define MDL_SCATTER_GATHER_VA (0x400)
45 #define MDL_IO_SPACE (0x800)
46 #define MDL_NETWORK_HEADER (0x1000)
47 #define MDL_MAPPING_CAN_FAIL (0x2000)
48 #define MDL_ALLOCATED_MUST_SUCCEED (0x4000)
49 #define MDL_64_BIT_VA (0x8000)
50
51
52 typedef struct _MDL
53 /*
54 * PURPOSE: Describes a user buffer passed to a system API
55 */
56 {
57 struct _MDL* Next;
58 CSHORT Size;
59 CSHORT MdlFlags;
60 struct _EPROCESS* Process;
61 PVOID MappedSystemVa;
62 PVOID StartVa;
63 ULONG ByteCount;
64 ULONG ByteOffset;
65 } MDL, *PMDL;
66
67 typedef struct _PHYSICAL_MEMORY_RANGE {
68 PHYSICAL_ADDRESS BaseAddress;
69 LARGE_INTEGER NumberOfBytes;
70 } PHYSICAL_MEMORY_RANGE, *PPHYSICAL_MEMORY_RANGE;
71
72 // read file scatter / write file scatter
73 typedef union _FILE_SEGMENT_ELEMENT {
74 PVOID Buffer;
75 ULONG Alignment;
76 }FILE_SEGMENT_ELEMENT, *PFILE_SEGMENT_ELEMENT;
77
78 typedef struct _READ_LIST {
79 struct _FILE_OBJECT* FileObject;
80 ULONG NumberOfEntries;
81 ULONG IsImage;
82 FILE_SEGMENT_ELEMENT List[1];
83 } READ_LIST, *PREAD_LIST;
84
85 #define MmSmallSystem (0)
86 #define MmMediumSystem (1)
87 #define MmLargeSystem (2)
88
89 /* Used in MmFlushImageSection */
90 typedef enum _MMFLUSH_TYPE
91 {
92 MmFlushForDelete,
93 MmFlushForWrite
94 } MMFLUSH_TYPE;
95
96 typedef enum _MEMORY_CACHING_TYPE_ORIG {
97 MmFrameBufferCached = 2
98 } MEMORY_CACHING_TYPE_ORIG;
99
100 typedef enum _MEMORY_CACHING_TYPE
101 {
102 MmNonCached = FALSE,
103 MmCached = TRUE,
104 MmWriteCombined = MmFrameBufferCached,
105 MmHardwareCoherentCached,
106 MmMaximumCacheType
107 } MEMORY_CACHING_TYPE;
108
109 typedef struct _MMWSL *PMMWSL;
110
111 typedef struct _MMSUPPORT_FLAGS {
112 ULONG SessionSpace : 1;
113 ULONG BeingTrimmed : 1;
114 ULONG SessionLeader : 1;
115 ULONG TrimHard : 1;
116 ULONG WorkingSetHard : 1;
117 ULONG AddressSpaceBeingDeleted : 1;
118 ULONG Available : 10;
119 ULONG AllowWorkingSetAdjustment : 8;
120 ULONG MemoryPriority : 8;
121 } MMSUPPORT_FLAGS, *PMMSUPPORT_FLAGS;
122
123 typedef struct _MMSUPPORT
124 {
125 LARGE_INTEGER LastTrimTime;
126 MMSUPPORT_FLAGS Flags;
127 ULONG PageFaultCount;
128 ULONG PeakWorkingSetSize;
129 ULONG WorkingSetSize;
130 ULONG MinimumWorkingSetSize;
131 ULONG MaximumWorkingSetSize;
132 PMMWSL VmWorkingSetList;
133 LIST_ENTRY WorkingSetExpansionLinks;
134 ULONG Claim;
135 ULONG NextEstimationSlot;
136 ULONG NextAgingSlot;
137 ULONG EstimatedAvailable;
138 ULONG GrowthSinceLastEstimate;
139 } MMSUPPORT, *PMMSUPPORT;
140
141 #endif