/*
- * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
+ * Copyright (c) 2000-2004 Apple Computer, Inc. All rights reserved.
*
* @APPLE_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. Please obtain a copy of the License at
+ * http://www.opensource.apple.com/apsl/ and read it before using this
+ * file.
*
- * This Original Code and all software distributed under the License are
- * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
+ * 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,
- * 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@
*/
#define DEBUG_BS_EXTERNAL 0x01000000
#define DEBUG_BS_INTERNAL 0x02000000
-#define DEBUG(level, args) \
+#define DP_DEBUG(level, args) \
do { \
if (debug_mask & (level)) \
dprintf(args); \
#else /* DEFAULT_PAGER_DEBUG */
-#define DEBUG(level, args)
+#define DP_DEBUG(level, args)
#define ASSERT(clause)
#endif /* DEFAULT_PAGER_DEBUG */
*/
#ifdef MACH_KERNEL
#define vm_page_size page_size
-extern vm_size_t page_size;
#else
extern vm_object_size_t vm_page_size;
#endif
#ifdef MACH_KERNEL
extern mutex_t dpt_lock; /* Lock for the dpt array */
-extern unsigned int default_pager_internal_count;
+extern int default_pager_internal_count;
extern MACH_PORT_FACE default_pager_host_port;
/* extern task_t default_pager_self; */ /* dont need or want */
extern MACH_PORT_FACE default_pager_internal_set;
#define BS_STAT(bs, clause) VSTATS_ACTION(&(bs)->bs_lock, (clause))
#ifdef MACH_KERNEL
-#define BS_LOCK_INIT(bs) mutex_init(&(bs)->bs_lock, ETAP_DPAGE_BS)
+#define BS_LOCK_INIT(bs) mutex_init(&(bs)->bs_lock, 0)
#else
#define BS_LOCK_INIT(bs) mutex_init(&(bs)->bs_lock)
#endif
extern int backing_store_release_trigger_disable;
#ifdef MACH_KERNEL
-#define BSL_LOCK_INIT() mutex_init(&backing_store_list.bsl_lock, ETAP_DPAGE_BSL)
+#define BSL_LOCK_INIT() mutex_init(&backing_store_list.bsl_lock, 0)
#else
#define BSL_LOCK_INIT() mutex_init(&backing_store_list.bsl_lock)
#endif
unsigned int ps_ncls; /* Number of clusters in segment */
unsigned int ps_clcount; /* Number of free clusters */
unsigned int ps_pgcount; /* Number of free pages */
- long ps_hint; /* Hint of where to look next. */
+ unsigned long ps_hint; /* Hint of where to look next. */
/* bitmap */
#ifdef MACH_KERNEL
#define PAGING_SEGMENT_NULL ((paging_segment_t) 0)
#ifdef MACH_KERNEL
-#define PS_LOCK_INIT(ps) mutex_init(&(ps)->ps_lock, ETAP_DPAGE_SEGMENT)
+#define PS_LOCK_INIT(ps) mutex_init(&(ps)->ps_lock, 0)
#else
#define PS_LOCK_INIT(ps) mutex_init(&(ps)->ps_lock)
#endif
extern int ps_select_array[DEFAULT_PAGER_BACKING_STORE_MAXPRI+1];
#ifdef MACH_KERNEL
-#define PSL_LOCK_INIT() mutex_init(&paging_segments_lock, ETAP_DPAGE_SEGLIST)
+#define PSL_LOCK_INIT() mutex_init(&paging_segments_lock, 0)
#else
#define PSL_LOCK_INIT() mutex_init(&paging_segments_lock)
#endif
* Exported macros for manipulating the vs_map structure --
* checking status, getting and setting bits.
*/
-#define VSCLSIZE(vs) (1 << (vs)->vs_clshift)
+#define VSCLSIZE(vs) (1UL << (vs)->vs_clshift)
#define VSM_ISCLR(vsm) (((vsm).vsmap_entry == VSM_ENTRY_NULL) && \
((vsm).vsmap_error == 0))
#define VSM_ISERR(vsm) ((vsm).vsmap_error)
} vstruct_alias_t;
#ifdef MACH_KERNEL
-#define DPT_LOCK_INIT(lock) mutex_init(&(lock), ETAP_DPAGE_VSTRUCT)
+#define DPT_LOCK_INIT(lock) mutex_init(&(lock), 0)
#define DPT_LOCK(lock) mutex_lock(&(lock))
#define DPT_UNLOCK(lock) mutex_unlock(&(lock))
+#define DPT_SLEEP(lock, e, i) thread_sleep_mutex(&(lock), (event_t)(e), i)
#define VS_LOCK_TYPE hw_lock_data_t
#define VS_LOCK_INIT(vs) hw_lock_init(&(vs)->vs_lock)
#define VS_TRY_LOCK(vs) (VS_LOCK(vs),TRUE)
#define VS_LOCK(vs) hw_lock_lock(&(vs)->vs_lock)
#define VS_UNLOCK(vs) hw_lock_unlock(&(vs)->vs_lock)
#define VS_MAP_LOCK_TYPE mutex_t
-#define VS_MAP_LOCK_INIT(vs) mutex_init(&(vs)->vs_map_lock, ETAP_DPAGE_VSMAP)
+#define VS_MAP_LOCK_INIT(vs) mutex_init(&(vs)->vs_map_lock, 0)
#define VS_MAP_LOCK(vs) mutex_lock(&(vs)->vs_map_lock)
#define VS_MAP_TRY_LOCK(vs) mutex_try(&(vs)->vs_map_lock)
#define VS_MAP_UNLOCK(vs) mutex_unlock(&(vs)->vs_map_lock)
#else
#define VS_LOCK_TYPE struct mutex
-#define VS_LOCK_INIT(vs) mutex_init(&(vs)->vs_lock, ETAP_DPAGE_VSTRUCT)
+#define VS_LOCK_INIT(vs) mutex_init(&(vs)->vs_lock, 0)
#define VS_TRY_LOCK(vs) mutex_try(&(vs)->vs_lock)
#define VS_LOCK(vs) mutex_lock(&(vs)->vs_lock)
#define VS_UNLOCK(vs) mutex_unlock(&(vs)->vs_lock)
queue_chain_t vs_links; /* Link in pager-wide list */
- int vs_clshift; /* Bit shift: clusters->pages */
- int vs_size; /* Object size in clusters */
+ unsigned int vs_clshift; /* Bit shift: clusters->pages */
+ unsigned int vs_size; /* Object size in clusters */
#ifdef MACH_KERNEL
mutex_t vs_map_lock; /* to protect map below */
#else
__private_extern__ void vs_start_write(vstruct_t);
__private_extern__ void vs_finish_write(vstruct_t);
__private_extern__ void vs_wait_for_writers(vstruct_t);
+__private_extern__ void vs_wait_for_sync_writers(vstruct_t);
#else /* PARALLEL */
#define vs_lock(vs)
#define vs_unlock(vs)
#ifdef MACH_KERNEL
-#define VSL_LOCK_INIT() mutex_init(&vstruct_list.vsl_lock, ETAP_DPAGE_VSLIST)
+#define VSL_LOCK_INIT() mutex_init(&vstruct_list.vsl_lock, 0)
#else
#define VSL_LOCK_INIT() mutex_init(&vstruct_list.vsl_lock)
#endif
#define VSL_LOCK() mutex_lock(&vstruct_list.vsl_lock)
#define VSL_LOCK_TRY() mutex_try(&vstruct_list.vsl_lock)
#define VSL_UNLOCK() mutex_unlock(&vstruct_list.vsl_lock)
+#define VSL_SLEEP(e,i) thread_sleep_mutex((e), &vstruct_list.vsl_lock, (i))
#ifdef MACH_KERNEL
__private_extern__ zone_t vstruct_zone;
vm_size_t);
extern kern_return_t vs_cluster_write(vstruct_t,
upl_t,
- vm_offset_t,
- vm_size_t,
+ upl_offset_t,
+ upl_size_t,
boolean_t,
int);
extern vm_offset_t ps_clmap(vstruct_t,
extern boolean_t verbose;
+extern thread_call_t default_pager_backing_store_monitor_callout;
+extern void default_pager_backing_store_monitor(thread_call_param_t, thread_call_param_t);
+
+extern ipc_port_t max_pages_trigger_port;
+extern unsigned int dp_pages_free;
+extern unsigned int maximum_pages_free;
+
+/* Do we know yet if swap files need to be encrypted ? */
+extern boolean_t dp_encryption_inited;
+/* Should we encrypt data before writing to swap ? */
+extern boolean_t dp_encryption;
+
#endif /* _DEFAULT_PAGER_INTERNAL_H_ */