X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/0b4e3aa066abc0728aacb4bbeb86f53f9737156e..ff6e181ae92fc6f1e89841290f461d1f2f9badd9:/osfmk/default_pager/default_pager_internal.h diff --git a/osfmk/default_pager/default_pager_internal.h b/osfmk/default_pager/default_pager_internal.h index 85699351d..33fb33b81 100644 --- a/osfmk/default_pager/default_pager_internal.h +++ b/osfmk/default_pager/default_pager_internal.h @@ -1,21 +1,22 @@ /* - * 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@ */ @@ -135,7 +136,7 @@ extern int debug_mask; #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); \ @@ -156,7 +157,7 @@ extern int debug_mask; #else /* DEFAULT_PAGER_DEBUG */ -#define DEBUG(level, args) +#define DP_DEBUG(level, args) #define ASSERT(clause) #endif /* DEFAULT_PAGER_DEBUG */ @@ -176,7 +177,6 @@ extern char *mach_error_string(kern_return_t); */ #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 @@ -193,7 +193,7 @@ extern memory_object_default_t default_pager_object; #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; @@ -299,7 +299,7 @@ typedef struct backing_store *backing_store_t; #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 @@ -318,7 +318,7 @@ extern struct backing_store_list_head backing_store_list; 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 @@ -347,7 +347,7 @@ struct paging_segment { 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 @@ -373,7 +373,7 @@ typedef struct paging_segment *paging_segment_t; #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 @@ -403,7 +403,7 @@ extern int paging_segment_max; /* highest used paging segment index */ 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 @@ -459,7 +459,7 @@ typedef struct vs_map *vs_map_t; * 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) @@ -543,22 +543,23 @@ typedef struct vstruct_alias { } 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) @@ -610,8 +611,8 @@ typedef struct vstruct { 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 @@ -639,6 +640,7 @@ __private_extern__ void vs_wait_for_readers(vstruct_t); __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) @@ -704,13 +706,14 @@ __private_extern__ void vstruct_list_delete(vstruct_t 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; @@ -789,8 +792,8 @@ extern kern_return_t pvs_cluster_read(vstruct_t, 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, @@ -807,4 +810,16 @@ extern boolean_t bs_set_default_clsize(unsigned int); 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_ */