branch update for HEAD-2002110701
[reactos.git] / include / ddk / mmtypes.h
1 /* $Id$ */
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 #define PAGE_ROUND_UP(x) ( (((ULONG)x)%PAGE_SIZE) ? ((((ULONG)x)&(~0xfff))+0x1000) : ((ULONG)x) )
11 #define PAGE_ROUND_DOWN(x) (((ULONG)x)&(~0xfff))
12
13
14 /*
15  * FUNCTION: Determines if the given virtual address is page aligned
16  */
17 #define IS_PAGE_ALIGNED(Va) (((ULONG)Va)&0xfff)
18
19 /*
20  * PURPOSE: Returns the byte offset of a field within a structure
21  */
22 #define FIELD_OFFSET(Type,Field) (LONG)(&(((Type *)(0))->Field))
23
24 /*
25  * PURPOSE: Returns the base address structure if the caller knows the 
26  * address of a field within the structure
27  * ARGUMENTS:
28  *          Address = address of the field
29  *          Type = Type of the whole structure
30  *          Field = Name of the field whose address is none
31  */
32 #define CONTAINING_RECORD(Address,Type,Field) (Type *)(((LONG)Address) - FIELD_OFFSET(Type,Field))
33
34
35 #define   MDL_MAPPED_TO_SYSTEM_VA      (0x1)
36 #define   MDL_PAGES_LOCKED             (0x2)
37 #define   MDL_SOURCE_IS_NONPAGED_POOL  (0x4)
38 #define   MDL_ALLOCATED_FIXED_SIZE     (0x8)
39 #define   MDL_PARTIAL                  (0x10)
40 #define   MDL_PARTIAL_HAS_BEEN_MAPPED  (0x20)
41 #define   MDL_IO_PAGE_READ             (0x40)
42 #define   MDL_WRITE_OPERATION          (0x80)
43 #define   MDL_PARENT_MAPPED_SYSTEM_VA  (0x100)
44 #define   MDL_LOCK_HELD                (0x200)
45 #define   MDL_SCATTER_GATHER_VA        (0x400)
46 #define   MDL_IO_SPACE                 (0x800)
47 #define   MDL_NETWORK_HEADER           (0x1000)
48 #define   MDL_MAPPING_CAN_FAIL         (0x2000)
49 #define   MDL_ALLOCATED_MUST_SUCCEED   (0x4000)
50 #define   MDL_64_BIT_VA                (0x8000)
51
52
53 typedef struct _MDL
54 /*
55  * PURPOSE: Describes a user buffer passed to a system API
56  */
57 {
58    struct _MDL* Next;
59    CSHORT Size;
60    CSHORT MdlFlags;
61    struct _EPROCESS* Process;
62    PVOID MappedSystemVa;
63    PVOID StartVa;
64    ULONG ByteCount;
65    ULONG ByteOffset;
66 } MDL, *PMDL;
67
68 #define MmSmallSystem (0)
69 #define MmMediumSystem (1)
70 #define MmLargeSystem (2)
71
72 /* Used in MmFlushImageSection */
73 typedef enum _MMFLUSH_TYPE
74 {
75         MmFlushForDelete,
76         MmFlushForWrite
77 } MMFLUSH_TYPE;
78
79 typedef enum _MEMORY_CACHING_TYPE
80 {
81         MmNonCached = FALSE,
82         MmCached = TRUE,
83         MmFrameBufferCached,
84         MmHardwareCoherentCached,
85         MmMaximumCacheType
86 } MEMORY_CACHING_TYPE;
87
88 #endif