]> git.saurik.com Git - apple/xnu.git/blobdiff - osfmk/mach/vm_region.h
xnu-3247.10.11.tar.gz
[apple/xnu.git] / osfmk / mach / vm_region.h
index 2f46e4e0d2fbafc9855cbcb61d56e92bc523cca4..729c7d81f89b241812c9653d5d68b70f50400f2c 100644 (file)
@@ -1,49 +1,33 @@
 /*
 /*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved.
  *
  *
- * @APPLE_LICENSE_HEADER_START@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
  * 
  * 
- * The contents of this file constitute Original Code as defined in and
- * are subject to the Apple Public Source License Version 1.1 (the
- * "License").  You may not use this file except in compliance with the
- * License.  Please obtain a copy of the License at
- * http://www.apple.com/publicsource and read it before using this file.
+ * This file contains Original Code and/or Modifications of Original Code
+ * as defined in and that are subject to the Apple Public Source License
+ * Version 2.0 (the 'License'). You may not use this file except in
+ * compliance with the License. The rights granted to you under the License
+ * may not be used to create, or enable the creation or redistribution of,
+ * unlawful or unlicensed copies of an Apple operating system, or to
+ * circumvent, violate, or enable the circumvention or violation of, any
+ * terms of an Apple operating system software license agreement.
  * 
  * 
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this file.
+ * 
+ * The Original Code and all software distributed under the License are
+ * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
- * License for the specific language governing rights and limitations
- * under the License.
+ * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
+ * Please see the License for the specific language governing rights and
+ * limitations under the License.
  * 
  * 
- * @APPLE_LICENSE_HEADER_END@
+ * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
  */
 /*
  * @OSF_COPYRIGHT@
  */
  */
 /*
  * @OSF_COPYRIGHT@
  */
-/*
- * HISTORY
- * 
- * Revision 1.1.1.1  1998/09/22 21:05:31  wsanchez
- * Import of Mac OS X kernel (~semeria)
- *
- * Revision 1.1.1.1  1998/03/07 02:25:46  wsanchez
- * Import of OSF Mach kernel (~mburg)
- *
- * Revision 1.1.5.1  1995/01/16  17:22:27  bolinger
- *     Import files unchanged from osc1.3b11 into cnmk_shared.
- *     [1995/01/16  17:20:37  bolinger]
- *
- * Revision 1.1.3.2  1993/10/05  22:23:22  watkins
- *     Merge forward.
- *     [1993/10/05  22:05:05  watkins]
- * 
- * Revision 1.1.1.2  1993/09/28  19:42:50  watkins
- *     Created to comply with spec.
- * 
- * $EndLog$
- */
 /*
  *     File:   mach/vm_region.h
  *
 /*
  *     File:   mach/vm_region.h
  *
 #include <mach/vm_prot.h>
 #include <mach/vm_inherit.h>
 #include <mach/vm_behavior.h>
 #include <mach/vm_prot.h>
 #include <mach/vm_inherit.h>
 #include <mach/vm_behavior.h>
+#include <mach/vm_types.h>
+#include <mach/message.h>
+#include <mach/machine/vm_param.h>
+#include <mach/machine/vm_types.h>
+#include <mach/memory_object_types.h>
+
+#include <sys/cdefs.h>
+
+#pragma pack(4)
+
+// LP64todo: all the current tools are 32bit, obviously never worked for 64b
+// so probably should be a real 32b ID vs. ptr.
+// Current users just check for equality
+typedef uint32_t vm32_object_id_t;
 
 /*
  *     Types defined:
 
 /*
  *     Types defined:
@@ -73,37 +71,42 @@ typedef int *vm_region_recurse_info_64_t;
 typedef int     vm_region_flavor_t;
 typedef int     vm_region_info_data_t[VM_REGION_INFO_MAX];
 
 typedef int     vm_region_flavor_t;
 typedef int     vm_region_info_data_t[VM_REGION_INFO_MAX];
 
-#define VM_REGION_BASIC_INFO   10
-
+#define VM_REGION_BASIC_INFO_64                9
 struct vm_region_basic_info_64 {
        vm_prot_t               protection;
        vm_prot_t               max_protection;
        vm_inherit_t            inheritance;
        boolean_t               shared;
        boolean_t               reserved;
 struct vm_region_basic_info_64 {
        vm_prot_t               protection;
        vm_prot_t               max_protection;
        vm_inherit_t            inheritance;
        boolean_t               shared;
        boolean_t               reserved;
-       vm_object_offset_t      offset;
+       memory_object_offset_t  offset;
        vm_behavior_t           behavior;
        unsigned short          user_wired_count;
 };
        vm_behavior_t           behavior;
        unsigned short          user_wired_count;
 };
-
 typedef struct vm_region_basic_info_64         *vm_region_basic_info_64_t;
 typedef struct vm_region_basic_info_64          vm_region_basic_info_data_64_t;
 
 typedef struct vm_region_basic_info_64         *vm_region_basic_info_64_t;
 typedef struct vm_region_basic_info_64          vm_region_basic_info_data_64_t;
 
-#define VM_REGION_BASIC_INFO_COUNT_64          \
-       (sizeof(vm_region_basic_info_data_64_t)/sizeof(int))
+#define VM_REGION_BASIC_INFO_COUNT_64  ((mach_msg_type_number_t) \
+       (sizeof(vm_region_basic_info_data_64_t)/sizeof(int)))
 
 
+/*
+ * Passing VM_REGION_BASIC_INFO to vm_region_64
+ * automatically converts it to a VM_REGION_BASIC_INFO_64.
+ * Please use that explicitly instead.
+ */
+#define VM_REGION_BASIC_INFO           10
 
 
+/*
+ * This is the legacy basic info structure.  It is
+ * deprecated because it passes only a 32-bit memory object
+ * offset back - too small for many larger objects (e.g. files).
+ */
 struct vm_region_basic_info {
        vm_prot_t               protection;
        vm_prot_t               max_protection;
        vm_inherit_t            inheritance;
        boolean_t               shared;
        boolean_t               reserved;
 struct vm_region_basic_info {
        vm_prot_t               protection;
        vm_prot_t               max_protection;
        vm_inherit_t            inheritance;
        boolean_t               shared;
        boolean_t               reserved;
-#ifdef soon
-       vm_object_offset_t      offset;
-#else
-       vm_offset_t     offset;
-#endif
+       uint32_t                offset; /* too small for a real offset */
        vm_behavior_t           behavior;
        unsigned short          user_wired_count;
 };
        vm_behavior_t           behavior;
        unsigned short          user_wired_count;
 };
@@ -111,12 +114,8 @@ struct vm_region_basic_info {
 typedef struct vm_region_basic_info            *vm_region_basic_info_t;
 typedef struct vm_region_basic_info             vm_region_basic_info_data_t;
 
 typedef struct vm_region_basic_info            *vm_region_basic_info_t;
 typedef struct vm_region_basic_info             vm_region_basic_info_data_t;
 
-#define VM_REGION_BASIC_INFO_COUNT             \
-       (sizeof(vm_region_basic_info_data_t)/sizeof(int))
-
-
-
-#define VM_REGION_EXTENDED_INFO        11
+#define VM_REGION_BASIC_INFO_COUNT ((mach_msg_type_number_t) \
+       (sizeof(vm_region_basic_info_data_t)/sizeof(int)))
 
 #define SM_COW             1
 #define SM_PRIVATE         2
 
 #define SM_COW             1
 #define SM_PRIVATE         2
@@ -125,6 +124,7 @@ typedef struct vm_region_basic_info          vm_region_basic_info_data_t;
 #define SM_TRUESHARED      5
 #define SM_PRIVATE_ALIASED 6
 #define SM_SHARED_ALIASED  7
 #define SM_TRUESHARED      5
 #define SM_PRIVATE_ALIASED 6
 #define SM_SHARED_ALIASED  7
+#define SM_LARGE_PAGE      8
 
 /* 
  * For submap info,  the SM flags above are overlayed when a submap
 
 /* 
  * For submap info,  the SM flags above are overlayed when a submap
@@ -134,25 +134,55 @@ typedef struct vm_region_basic_info                vm_region_basic_info_data_t;
  * back.
  */
 
  * back.
  */
 
+#if MACH_KERNEL_PRIVATE
+#define VM_REGION_EXTENDED_INFO__legacy        11
+struct vm_region_extended_info__legacy {
+       vm_prot_t               protection;
+        unsigned int            user_tag;
+        unsigned int            pages_resident;
+        unsigned int            pages_shared_now_private;
+        unsigned int            pages_swapped_out;
+        unsigned int            pages_dirtied;
+        unsigned int            ref_count;
+        unsigned short          shadow_depth;
+        unsigned char           external_pager;
+        unsigned char           share_mode;
+       /*
+        * XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX
+        *  DO NOT EXTEND THIS DATA STRUCTURE.
+        *  IT IS NOW ABANDONED AND REPLACED WITH vm_region_extended_info BELOW.
+        * XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX
+        */
+};
+#define VM_REGION_EXTENDED_INFO_COUNT__legacy              \
+       ((mach_msg_type_number_t)                           \
+        (sizeof (struct vm_region_extended_info__legacy) / \
+         sizeof (natural_t)))
+#endif /* MACH_KERNEL_PRIVATE */
+
 
 
+
+#define VM_REGION_EXTENDED_INFO        13
 struct vm_region_extended_info {
        vm_prot_t               protection;
         unsigned int            user_tag;
         unsigned int            pages_resident;
         unsigned int            pages_shared_now_private;
         unsigned int            pages_swapped_out;
 struct vm_region_extended_info {
        vm_prot_t               protection;
         unsigned int            user_tag;
         unsigned int            pages_resident;
         unsigned int            pages_shared_now_private;
         unsigned int            pages_swapped_out;
-        unsigned int            pages_referenced;
+        unsigned int            pages_dirtied;
         unsigned int            ref_count;
         unsigned short          shadow_depth;
         unsigned char           external_pager;
         unsigned char           share_mode;
         unsigned int            ref_count;
         unsigned short          shadow_depth;
         unsigned char           external_pager;
         unsigned char           share_mode;
+       unsigned int            pages_reusable;
 };
 };
-
 typedef struct vm_region_extended_info         *vm_region_extended_info_t;
 typedef struct vm_region_extended_info          vm_region_extended_info_data_t;
 typedef struct vm_region_extended_info         *vm_region_extended_info_t;
 typedef struct vm_region_extended_info          vm_region_extended_info_data_t;
+#define VM_REGION_EXTENDED_INFO_COUNT                  \
+       ((mach_msg_type_number_t)                       \
+        (sizeof (vm_region_extended_info_data_t) / sizeof (natural_t)))
+
 
 
-#define VM_REGION_EXTENDED_INFO_COUNT          \
-       (sizeof(vm_region_extended_info_data_t)/sizeof(int))
 
 
 #define VM_REGION_TOP_INFO     12
 
 
 #define VM_REGION_TOP_INFO     12
@@ -168,8 +198,9 @@ struct vm_region_top_info {
 typedef struct vm_region_top_info              *vm_region_top_info_t;
 typedef struct vm_region_top_info               vm_region_top_info_data_t;
 
 typedef struct vm_region_top_info              *vm_region_top_info_t;
 typedef struct vm_region_top_info               vm_region_top_info_data_t;
 
-#define VM_REGION_TOP_INFO_COUNT               \
-       (sizeof(vm_region_top_info_data_t)/sizeof(int))
+#define VM_REGION_TOP_INFO_COUNT                                       \
+       ((mach_msg_type_number_t)                                       \
+        (sizeof(vm_region_top_info_data_t) / sizeof(natural_t)))
 
 
 
 
 
 
@@ -192,72 +223,147 @@ typedef struct vm_region_top_info                 vm_region_top_info_data_t;
  * chain (where one is present), and a walking of the resident page queue.
  * 
  */
  * chain (where one is present), and a walking of the resident page queue.
  * 
  */
+
 struct vm_region_submap_info {
        vm_prot_t               protection;     /* present access protection */
        vm_prot_t               max_protection; /* max avail through vm_prot */
        vm_inherit_t            inheritance;/* behavior of map/obj on fork */
 struct vm_region_submap_info {
        vm_prot_t               protection;     /* present access protection */
        vm_prot_t               max_protection; /* max avail through vm_prot */
        vm_inherit_t            inheritance;/* behavior of map/obj on fork */
-#ifdef soon
-       vm_object_offset_t      offset;         /* offset into object/map */
-#else
-       vm_offset_t     offset;         /* offset into object/map */
-#endif
+       uint32_t                offset;         /* offset into object/map */
         unsigned int            user_tag;      /* user tag on map entry */
         unsigned int            pages_resident;        /* only valid for objects */
         unsigned int            pages_shared_now_private; /* only for objects */
         unsigned int            pages_swapped_out; /* only for objects */
         unsigned int            user_tag;      /* user tag on map entry */
         unsigned int            pages_resident;        /* only valid for objects */
         unsigned int            pages_shared_now_private; /* only for objects */
         unsigned int            pages_swapped_out; /* only for objects */
-        unsigned int            pages_referenced; /* only for objects */
+        unsigned int            pages_dirtied;   /* only for objects */
         unsigned int            ref_count;      /* obj/map mappers, etc */
         unsigned short          shadow_depth;  /* only for obj */
         unsigned char           external_pager;  /* only for obj */
         unsigned char           share_mode;    /* see enumeration */
        boolean_t               is_submap;      /* submap vs obj */
        vm_behavior_t           behavior;       /* access behavior hint */
         unsigned int            ref_count;      /* obj/map mappers, etc */
         unsigned short          shadow_depth;  /* only for obj */
         unsigned char           external_pager;  /* only for obj */
         unsigned char           share_mode;    /* see enumeration */
        boolean_t               is_submap;      /* submap vs obj */
        vm_behavior_t           behavior;       /* access behavior hint */
-       vm_offset_t             object_id;      /* obj/map name, not a handle */
+       vm32_object_id_t        object_id;      /* obj/map name, not a handle */
        unsigned short          user_wired_count; 
 };
 
 typedef struct vm_region_submap_info           *vm_region_submap_info_t;
 typedef struct vm_region_submap_info            vm_region_submap_info_data_t;
 
        unsigned short          user_wired_count; 
 };
 
 typedef struct vm_region_submap_info           *vm_region_submap_info_t;
 typedef struct vm_region_submap_info            vm_region_submap_info_data_t;
 
-#define VM_REGION_SUBMAP_INFO_COUNT            \
-       (sizeof(vm_region_submap_info_data_t)/sizeof(int))
-
-
+#define VM_REGION_SUBMAP_INFO_COUNT                                    \
+       ((mach_msg_type_number_t)                                       \
+        (sizeof(vm_region_submap_info_data_t) / sizeof(natural_t)))
 
 struct vm_region_submap_info_64 {
        vm_prot_t               protection;     /* present access protection */
        vm_prot_t               max_protection; /* max avail through vm_prot */
        vm_inherit_t            inheritance;/* behavior of map/obj on fork */
 
 struct vm_region_submap_info_64 {
        vm_prot_t               protection;     /* present access protection */
        vm_prot_t               max_protection; /* max avail through vm_prot */
        vm_inherit_t            inheritance;/* behavior of map/obj on fork */
-       vm_object_offset_t      offset;         /* offset into object/map */
+       memory_object_offset_t  offset;         /* offset into object/map */
         unsigned int            user_tag;      /* user tag on map entry */
         unsigned int            pages_resident;        /* only valid for objects */
         unsigned int            pages_shared_now_private; /* only for objects */
         unsigned int            pages_swapped_out; /* only for objects */
         unsigned int            user_tag;      /* user tag on map entry */
         unsigned int            pages_resident;        /* only valid for objects */
         unsigned int            pages_shared_now_private; /* only for objects */
         unsigned int            pages_swapped_out; /* only for objects */
-        unsigned int            pages_referenced; /* only for objects */
+        unsigned int            pages_dirtied;   /* only for objects */
         unsigned int            ref_count;      /* obj/map mappers, etc */
         unsigned short          shadow_depth;  /* only for obj */
         unsigned char           external_pager;  /* only for obj */
         unsigned char           share_mode;    /* see enumeration */
        boolean_t               is_submap;      /* submap vs obj */
        vm_behavior_t           behavior;       /* access behavior hint */
         unsigned int            ref_count;      /* obj/map mappers, etc */
         unsigned short          shadow_depth;  /* only for obj */
         unsigned char           external_pager;  /* only for obj */
         unsigned char           share_mode;    /* see enumeration */
        boolean_t               is_submap;      /* submap vs obj */
        vm_behavior_t           behavior;       /* access behavior hint */
-       vm_offset_t             object_id;      /* obj/map name, not a handle */
-       unsigned short          user_wired_count; 
+       vm32_object_id_t        object_id;      /* obj/map name, not a handle */
+       unsigned short          user_wired_count;
+       unsigned int            pages_reusable;
 };
 
 typedef struct vm_region_submap_info_64                *vm_region_submap_info_64_t;
 typedef struct vm_region_submap_info_64                 vm_region_submap_info_data_64_t;
 
 };
 
 typedef struct vm_region_submap_info_64                *vm_region_submap_info_64_t;
 typedef struct vm_region_submap_info_64                 vm_region_submap_info_data_64_t;
 
-#define VM_REGION_SUBMAP_INFO_COUNT_64         \
-       (sizeof(vm_region_submap_info_data_64_t)/sizeof(int))
+#define VM_REGION_SUBMAP_INFO_V1_SIZE  \
+       (sizeof (vm_region_submap_info_data_64_t))
+#define VM_REGION_SUBMAP_INFO_V0_SIZE  \
+       (VM_REGION_SUBMAP_INFO_V1_SIZE - \
+        sizeof (unsigned int) /* pages_reusable */)
 
 
+#define VM_REGION_SUBMAP_INFO_V1_COUNT_64 \
+       ((mach_msg_type_number_t) \
+        (VM_REGION_SUBMAP_INFO_V1_SIZE / sizeof (natural_t)))
+#define VM_REGION_SUBMAP_INFO_V0_COUNT_64 \
+       ((mach_msg_type_number_t) \
+        (VM_REGION_SUBMAP_INFO_V0_SIZE / sizeof (natural_t)))
+
+/* set this to the latest version */
+#define VM_REGION_SUBMAP_INFO_COUNT_64         VM_REGION_SUBMAP_INFO_V1_COUNT_64
+
+struct vm_region_submap_short_info_64 {
+       vm_prot_t               protection;     /* present access protection */
+       vm_prot_t               max_protection; /* max avail through vm_prot */
+       vm_inherit_t            inheritance;/* behavior of map/obj on fork */
+       memory_object_offset_t  offset;         /* offset into object/map */
+        unsigned int            user_tag;      /* user tag on map entry */
+        unsigned int            ref_count;      /* obj/map mappers, etc */
+        unsigned short          shadow_depth;  /* only for obj */
+        unsigned char           external_pager;  /* only for obj */
+        unsigned char           share_mode;    /* see enumeration */
+       boolean_t               is_submap;      /* submap vs obj */
+       vm_behavior_t           behavior;       /* access behavior hint */
+       vm32_object_id_t        object_id;      /* obj/map name, not a handle */
+       unsigned short          user_wired_count; 
+};
+
+typedef struct vm_region_submap_short_info_64  *vm_region_submap_short_info_64_t;
+typedef struct vm_region_submap_short_info_64   vm_region_submap_short_info_data_64_t;
+
+#define VM_REGION_SUBMAP_SHORT_INFO_COUNT_64                           \
+       ((mach_msg_type_number_t)                                       \
+        (sizeof (vm_region_submap_short_info_data_64_t) / sizeof (natural_t)))
+
+
+
+struct mach_vm_read_entry {
+       mach_vm_address_t address;
+       mach_vm_size_t size;
+};
 
 struct vm_read_entry {
        vm_address_t    address;
        vm_size_t       size;
 };
 
 
 struct vm_read_entry {
        vm_address_t    address;
        vm_size_t       size;
 };
 
+#if VM32_SUPPORT
+struct vm32_read_entry {
+       vm32_address_t  address;
+       vm32_size_t     size;
+};
+#endif
+
+
 #define VM_MAP_ENTRY_MAX  (256)
 
 #define VM_MAP_ENTRY_MAX  (256)
 
-typedef struct vm_read_entry   vm_read_entry_t[VM_MAP_ENTRY_MAX];
+typedef struct mach_vm_read_entry      mach_vm_read_entry_t[VM_MAP_ENTRY_MAX];
+typedef struct vm_read_entry           vm_read_entry_t[VM_MAP_ENTRY_MAX];
+#if VM32_SUPPORT
+typedef struct vm32_read_entry         vm32_read_entry_t[VM_MAP_ENTRY_MAX];
+#endif
+
+#pragma pack()
+
+
+#define VM_PAGE_INFO_MAX 
+typedef int *vm_page_info_t;
+typedef int vm_page_info_data_t[VM_PAGE_INFO_MAX];
+typedef int vm_page_info_flavor_t;
+
+#define VM_PAGE_INFO_BASIC             1
+struct vm_page_info_basic {
+       int                     disposition;
+       int                     ref_count;
+       vm_object_id_t          object_id;
+       memory_object_offset_t  offset;
+       int                     depth;
+       int                     __pad; /* pad to 64-bit boundary */
+};
+typedef struct vm_page_info_basic              *vm_page_info_basic_t;
+typedef struct vm_page_info_basic              vm_page_info_basic_data_t;
+
+#define VM_PAGE_INFO_BASIC_COUNT       ((mach_msg_type_number_t) \
+       (sizeof(vm_page_info_basic_data_t)/sizeof(int)))
+
 
 #endif /*_MACH_VM_REGION_H_*/
 
 #endif /*_MACH_VM_REGION_H_*/