]>
Commit | Line | Data |
---|---|---|
91447636 | 1 | /* |
b0d623f7 | 2 | * Copyright (c) 1999-2008 Apple Inc. All rights reserved. |
91447636 | 3 | * |
2d21ac55 | 4 | * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ |
91447636 | 5 | * |
2d21ac55 A |
6 | * This file contains Original Code and/or Modifications of Original Code |
7 | * as defined in and that are subject to the Apple Public Source License | |
8 | * Version 2.0 (the 'License'). You may not use this file except in | |
9 | * compliance with the License. The rights granted to you under the License | |
10 | * may not be used to create, or enable the creation or redistribution of, | |
11 | * unlawful or unlicensed copies of an Apple operating system, or to | |
12 | * circumvent, violate, or enable the circumvention or violation of, any | |
13 | * terms of an Apple operating system software license agreement. | |
8f6c56a5 | 14 | * |
2d21ac55 A |
15 | * Please obtain a copy of the License at |
16 | * http://www.opensource.apple.com/apsl/ and read it before using this file. | |
17 | * | |
18 | * The Original Code and all software distributed under the License are | |
19 | * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER | |
8f6c56a5 A |
20 | * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, |
21 | * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, | |
2d21ac55 A |
22 | * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. |
23 | * Please see the License for the specific language governing rights and | |
24 | * limitations under the License. | |
8f6c56a5 | 25 | * |
2d21ac55 | 26 | * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ |
91447636 A |
27 | */ |
28 | /* | |
29 | * File: ubc.h | |
30 | * Author: Umesh Vaishampayan [umeshv@apple.com] | |
31 | * 05-Aug-1999 umeshv Created. | |
32 | * | |
33 | * Header file for Unified Buffer Cache. | |
34 | * | |
35 | */ | |
36 | ||
37 | #ifndef _SYS_UBC_INTERNAL_H_ | |
38 | #define _SYS_UBC_INTERNAL_H_ | |
39 | ||
40 | #include <sys/appleapiopts.h> | |
41 | #include <sys/types.h> | |
42 | #include <sys/kernel_types.h> | |
43 | #include <sys/ucred.h> | |
44 | #include <sys/vnode.h> | |
45 | #include <sys/ubc.h> | |
46 | #include <sys/mman.h> | |
47 | ||
48 | #include <sys/cdefs.h> | |
49 | ||
50 | #include <kern/locks.h> | |
51 | #include <mach/memory_object_types.h> | |
52 | ||
2d21ac55 A |
53 | #include <libkern/crypto/sha1.h> |
54 | ||
91447636 A |
55 | |
56 | #define UBC_INFO_NULL ((struct ubc_info *) 0) | |
57 | ||
58 | ||
59 | extern struct zone *ubc_info_zone; | |
60 | ||
61 | ||
b0d623f7 A |
62 | #define MAX_CLUSTERS 8 /* maximum number of vfs clusters per vnode */ |
63 | #define SPARSE_PUSH_LIMIT 4 /* limit on number of concurrent sparse pushes outside of the cl_lockw */ | |
64 | /* once we reach this limit, we'll hold the lock */ | |
91447636 A |
65 | |
66 | struct cl_extent { | |
67 | daddr64_t b_addr; | |
68 | daddr64_t e_addr; | |
69 | }; | |
70 | ||
71 | struct cl_wextent { | |
72 | daddr64_t b_addr; | |
73 | daddr64_t e_addr; | |
2d21ac55 | 74 | int io_flags; |
91447636 A |
75 | }; |
76 | ||
77 | struct cl_readahead { | |
78 | lck_mtx_t cl_lockr; | |
79 | daddr64_t cl_lastr; /* last block read by client */ | |
80 | daddr64_t cl_maxra; /* last block prefetched by the read ahead */ | |
81 | int cl_ralen; /* length of last prefetch */ | |
82 | }; | |
83 | ||
84 | struct cl_writebehind { | |
85 | lck_mtx_t cl_lockw; | |
91447636 | 86 | void * cl_scmap; /* pointer to sparse cluster map */ |
b0d623f7 A |
87 | int cl_sparse_pushes; /* number of pushes outside of the cl_lockw in progress */ |
88 | int cl_sparse_wait; /* synchronous push is in progress */ | |
91447636 A |
89 | int cl_number; /* number of packed write behind clusters currently valid */ |
90 | struct cl_wextent cl_clusters[MAX_CLUSTERS]; /* packed write behind clusters */ | |
91 | }; | |
92 | ||
93 | ||
2d21ac55 A |
94 | struct cs_blob { |
95 | struct cs_blob *csb_next; | |
96 | cpu_type_t csb_cpu_type; | |
97 | unsigned int csb_flags; | |
b0d623f7 A |
98 | off_t csb_base_offset; /* Offset of Mach-O binary in fat binary */ |
99 | off_t csb_start_offset; /* Blob coverage area start, from csb_base_offset */ | |
100 | off_t csb_end_offset; /* Blob coverage area end, from csb_base_offset */ | |
2d21ac55 A |
101 | ipc_port_t csb_mem_handle; |
102 | vm_size_t csb_mem_size; | |
103 | vm_offset_t csb_mem_offset; | |
104 | vm_address_t csb_mem_kaddr; | |
105 | unsigned char csb_sha1[SHA1_RESULTLEN]; | |
106 | }; | |
107 | ||
91447636 A |
108 | /* |
109 | * The following data structure keeps the information to associate | |
110 | * a vnode to the correspondig VM objects. | |
111 | */ | |
112 | struct ubc_info { | |
2d21ac55 A |
113 | memory_object_t ui_pager; /* pager */ |
114 | memory_object_control_t ui_control; /* VM control for the pager */ | |
b0d623f7 | 115 | uint32_t ui_flags; /* flags */ |
2d21ac55 A |
116 | vnode_t ui_vnode; /* vnode for this ubc_info */ |
117 | kauth_cred_t ui_ucred; /* holds credentials for NFS paging */ | |
118 | off_t ui_size; /* file size for the vnode */ | |
119 | ||
120 | struct cl_readahead *cl_rahead; /* cluster read ahead context */ | |
121 | struct cl_writebehind *cl_wbehind; /* cluster write behind context */ | |
122 | ||
123 | struct cs_blob *cs_blobs; /* for CODE SIGNING */ | |
91447636 A |
124 | }; |
125 | ||
126 | /* Defines for ui_flags */ | |
2d21ac55 A |
127 | #define UI_NONE 0x00000000 /* none */ |
128 | #define UI_HASPAGER 0x00000001 /* has a pager associated */ | |
129 | #define UI_INITED 0x00000002 /* newly initialized vnode */ | |
130 | #define UI_HASOBJREF 0x00000004 /* hold a reference on object */ | |
131 | #define UI_WASMAPPED 0x00000008 /* vnode was mapped */ | |
132 | #define UI_ISMAPPED 0x00000010 /* vnode is currently mapped */ | |
133 | #define UI_MAPBUSY 0x00000020 /* vnode is being mapped or unmapped */ | |
134 | #define UI_MAPWAITING 0x00000040 /* someone waiting for UI_MAPBUSY */ | |
91447636 A |
135 | |
136 | /* | |
137 | * exported primitives for loadable file systems. | |
138 | */ | |
139 | ||
140 | __BEGIN_DECLS | |
b0d623f7 | 141 | __private_extern__ void ubc_init(void) __attribute__((section("__TEXT, initcode")));; |
2d21ac55 | 142 | __private_extern__ int ubc_umount(mount_t mp); |
91447636 | 143 | __private_extern__ void ubc_unmountall(void); |
2d21ac55 | 144 | __private_extern__ memory_object_t ubc_getpager(vnode_t); |
2d21ac55 | 145 | __private_extern__ void ubc_destroy_named(vnode_t); |
91447636 A |
146 | |
147 | /* internal only */ | |
148 | __private_extern__ void cluster_release(struct ubc_info *); | |
cf7d32b8 | 149 | __private_extern__ uint32_t cluster_max_io_size(mount_t, int); |
b0d623f7 A |
150 | __private_extern__ uint32_t cluster_hard_throttle_limit(vnode_t, uint32_t *, uint32_t); |
151 | ||
91447636 A |
152 | |
153 | /* Flags for ubc_getobject() */ | |
154 | #define UBC_FLAGS_NONE 0x0000 | |
155 | #define UBC_HOLDOBJECT 0x0001 | |
156 | #define UBC_FOR_PAGEOUT 0x0002 | |
157 | ||
2d21ac55 | 158 | memory_object_control_t ubc_getobject(vnode_t, int); |
91447636 | 159 | |
2d21ac55 A |
160 | int ubc_info_init(vnode_t); |
161 | int ubc_info_init_withsize(vnode_t, off_t); | |
162 | void ubc_info_deallocate(struct ubc_info *); | |
91447636 | 163 | |
2d21ac55 A |
164 | int ubc_isinuse(vnode_t, int); |
165 | int ubc_isinuse_locked(vnode_t, int, int); | |
91447636 | 166 | |
2d21ac55 | 167 | int ubc_getcdhash(vnode_t, off_t, unsigned char *); |
91447636 | 168 | |
b0d623f7 | 169 | #ifdef XNU_KERNEL_PRIVATE |
91447636 | 170 | int UBCINFOEXISTS(vnode_t); |
b0d623f7 | 171 | #endif /* XNU_KERNEL_PRIVATE */ |
91447636 | 172 | |
593a1d5f A |
173 | /* code signing */ |
174 | struct cs_blob; | |
175 | int ubc_cs_blob_add(vnode_t, cpu_type_t, off_t, vm_address_t, vm_size_t); | |
176 | struct cs_blob *ubc_get_cs_blobs(vnode_t); | |
177 | int ubc_cs_getcdhash(vnode_t, off_t, unsigned char *); | |
178 | kern_return_t ubc_cs_blob_allocate(vm_offset_t *, vm_size_t *); | |
179 | void ubc_cs_blob_deallocate(vm_offset_t, vm_size_t); | |
180 | ||
91447636 A |
181 | __END_DECLS |
182 | ||
183 | ||
184 | #endif /* _SYS_UBC_INTERNAL_H_ */ | |
185 |