| 1 | #ifndef _upl_server_ |
| 2 | #define _upl_server_ |
| 3 | |
| 4 | /* Module upl */ |
| 5 | |
| 6 | #include <string.h> |
| 7 | #include <mach/ndr.h> |
| 8 | #include <mach/boolean.h> |
| 9 | #include <mach/kern_return.h> |
| 10 | #include <mach/notify.h> |
| 11 | #include <mach/mach_types.h> |
| 12 | #include <mach/message.h> |
| 13 | #include <mach/mig_errors.h> |
| 14 | #include <mach/port.h> |
| 15 | |
| 16 | /* BEGIN MIG_STRNCPY_ZEROFILL CODE */ |
| 17 | |
| 18 | #if defined(__has_include) |
| 19 | #if __has_include(<mach/mig_strncpy_zerofill_support.h>) |
| 20 | #ifndef USING_MIG_STRNCPY_ZEROFILL |
| 21 | #define USING_MIG_STRNCPY_ZEROFILL |
| 22 | #endif |
| 23 | #ifndef __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ |
| 24 | #define __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ |
| 25 | #ifdef __cplusplus |
| 26 | extern "C" { |
| 27 | #endif |
| 28 | extern int mig_strncpy_zerofill(char *dest, const char *src, int len) __attribute__((weak_import)); |
| 29 | #ifdef __cplusplus |
| 30 | } |
| 31 | #endif |
| 32 | #endif /* __MIG_STRNCPY_ZEROFILL_FORWARD_TYPE_DECLS__ */ |
| 33 | #endif /* __has_include(<mach/mig_strncpy_zerofill_support.h>) */ |
| 34 | #endif /* __has_include */ |
| 35 | |
| 36 | /* END MIG_STRNCPY_ZEROFILL CODE */ |
| 37 | |
| 38 | |
| 39 | #ifdef AUTOTEST |
| 40 | #ifndef FUNCTION_PTR_T |
| 41 | #define FUNCTION_PTR_T |
| 42 | typedef void (*function_ptr_t)(mach_port_t, char *, mach_msg_type_number_t); |
| 43 | typedef struct { |
| 44 | char *name; |
| 45 | function_ptr_t function; |
| 46 | } function_table_entry; |
| 47 | typedef function_table_entry *function_table_t; |
| 48 | #endif /* FUNCTION_PTR_T */ |
| 49 | #endif /* AUTOTEST */ |
| 50 | |
| 51 | #ifndef upl_MSG_COUNT |
| 52 | #define upl_MSG_COUNT 4 |
| 53 | #endif /* upl_MSG_COUNT */ |
| 54 | |
| 55 | #include <mach/std_types.h> |
| 56 | #include <mach/mig.h> |
| 57 | #include <ipc/ipc_voucher.h> |
| 58 | #include <kern/ipc_kobject.h> |
| 59 | #include <kern/ipc_tt.h> |
| 60 | #include <kern/ipc_host.h> |
| 61 | #include <kern/ipc_sync.h> |
| 62 | #include <kern/ledger.h> |
| 63 | #include <kern/processor.h> |
| 64 | #include <kern/sync_lock.h> |
| 65 | #include <kern/sync_sema.h> |
| 66 | #include <vm/memory_object.h> |
| 67 | #include <vm/vm_map.h> |
| 68 | #include <kern/ipc_mig.h> |
| 69 | #include <mach/mig.h> |
| 70 | #include <mach/mach_types.h> |
| 71 | |
| 72 | #ifdef __BeforeMigServerHeader |
| 73 | __BeforeMigServerHeader |
| 74 | #endif /* __BeforeMigServerHeader */ |
| 75 | |
| 76 | |
| 77 | /* Routine upl_abort */ |
| 78 | #ifdef mig_external |
| 79 | mig_external |
| 80 | #else |
| 81 | extern |
| 82 | #endif /* mig_external */ |
| 83 | kern_return_t upl_abort |
| 84 | ( |
| 85 | upl_t upl_object, |
| 86 | integer_t abort_cond |
| 87 | ); |
| 88 | |
| 89 | /* Routine upl_abort_range */ |
| 90 | #ifdef mig_external |
| 91 | mig_external |
| 92 | #else |
| 93 | extern |
| 94 | #endif /* mig_external */ |
| 95 | kern_return_t upl_abort_range |
| 96 | ( |
| 97 | upl_t upl_object, |
| 98 | upl_offset_t offset, |
| 99 | upl_size_t size, |
| 100 | integer_t abort_cond, |
| 101 | boolean_t *empty |
| 102 | ); |
| 103 | |
| 104 | /* Routine upl_commit */ |
| 105 | #ifdef mig_external |
| 106 | mig_external |
| 107 | #else |
| 108 | extern |
| 109 | #endif /* mig_external */ |
| 110 | kern_return_t upl_commit |
| 111 | ( |
| 112 | upl_t upl_object, |
| 113 | upl_page_info_array_t page_list, |
| 114 | mach_msg_type_number_t page_listCnt |
| 115 | ); |
| 116 | |
| 117 | /* Routine upl_commit_range */ |
| 118 | #ifdef mig_external |
| 119 | mig_external |
| 120 | #else |
| 121 | extern |
| 122 | #endif /* mig_external */ |
| 123 | kern_return_t upl_commit_range |
| 124 | ( |
| 125 | upl_t upl_object, |
| 126 | upl_offset_t offset, |
| 127 | upl_size_t size, |
| 128 | integer_t cntrl_flags, |
| 129 | upl_page_info_array_t page_list, |
| 130 | mach_msg_type_number_t page_listCnt, |
| 131 | boolean_t *empty |
| 132 | ); |
| 133 | |
| 134 | #ifdef mig_external |
| 135 | mig_external |
| 136 | #else |
| 137 | extern |
| 138 | #endif /* mig_external */ |
| 139 | boolean_t upl_server( |
| 140 | mach_msg_header_t *InHeadP, |
| 141 | mach_msg_header_t *OutHeadP); |
| 142 | |
| 143 | #ifdef mig_external |
| 144 | mig_external |
| 145 | #else |
| 146 | extern |
| 147 | #endif /* mig_external */ |
| 148 | mig_routine_t upl_server_routine( |
| 149 | mach_msg_header_t *InHeadP); |
| 150 | |
| 151 | |
| 152 | /* Description of this subsystem, for use in direct RPC */ |
| 153 | extern const struct upl_subsystem { |
| 154 | mig_server_routine_t server; /* Server routine */ |
| 155 | mach_msg_id_t start; /* Min routine number */ |
| 156 | mach_msg_id_t end; /* Max routine number + 1 */ |
| 157 | unsigned int maxsize; /* Max msg size */ |
| 158 | vm_address_t reserved; /* Reserved */ |
| 159 | struct routine_descriptor /*Array of routine descriptors */ |
| 160 | routine[4]; |
| 161 | } upl_subsystem; |
| 162 | |
| 163 | /* typedefs for all requests */ |
| 164 | |
| 165 | #ifndef __Request__upl_subsystem__defined |
| 166 | #define __Request__upl_subsystem__defined |
| 167 | |
| 168 | #ifdef __MigPackStructs |
| 169 | #pragma pack(4) |
| 170 | #endif |
| 171 | typedef struct { |
| 172 | mach_msg_header_t Head; |
| 173 | NDR_record_t NDR; |
| 174 | integer_t abort_cond; |
| 175 | } __Request__upl_abort_t __attribute__((unused)); |
| 176 | #ifdef __MigPackStructs |
| 177 | #pragma pack() |
| 178 | #endif |
| 179 | |
| 180 | #ifdef __MigPackStructs |
| 181 | #pragma pack(4) |
| 182 | #endif |
| 183 | typedef struct { |
| 184 | mach_msg_header_t Head; |
| 185 | NDR_record_t NDR; |
| 186 | upl_offset_t offset; |
| 187 | upl_size_t size; |
| 188 | integer_t abort_cond; |
| 189 | } __Request__upl_abort_range_t __attribute__((unused)); |
| 190 | #ifdef __MigPackStructs |
| 191 | #pragma pack() |
| 192 | #endif |
| 193 | |
| 194 | #ifdef __MigPackStructs |
| 195 | #pragma pack(4) |
| 196 | #endif |
| 197 | typedef struct { |
| 198 | mach_msg_header_t Head; |
| 199 | NDR_record_t NDR; |
| 200 | mach_msg_type_number_t page_listCnt; |
| 201 | upl_page_info_t page_list[256]; |
| 202 | } __Request__upl_commit_t __attribute__((unused)); |
| 203 | #ifdef __MigPackStructs |
| 204 | #pragma pack() |
| 205 | #endif |
| 206 | |
| 207 | #ifdef __MigPackStructs |
| 208 | #pragma pack(4) |
| 209 | #endif |
| 210 | typedef struct { |
| 211 | mach_msg_header_t Head; |
| 212 | NDR_record_t NDR; |
| 213 | upl_offset_t offset; |
| 214 | upl_size_t size; |
| 215 | integer_t cntrl_flags; |
| 216 | mach_msg_type_number_t page_listCnt; |
| 217 | upl_page_info_t page_list[256]; |
| 218 | } __Request__upl_commit_range_t __attribute__((unused)); |
| 219 | #ifdef __MigPackStructs |
| 220 | #pragma pack() |
| 221 | #endif |
| 222 | #endif /* !__Request__upl_subsystem__defined */ |
| 223 | |
| 224 | |
| 225 | /* union of all requests */ |
| 226 | |
| 227 | #ifndef __RequestUnion__upl_subsystem__defined |
| 228 | #define __RequestUnion__upl_subsystem__defined |
| 229 | union __RequestUnion__upl_subsystem { |
| 230 | __Request__upl_abort_t Request_upl_abort; |
| 231 | __Request__upl_abort_range_t Request_upl_abort_range; |
| 232 | __Request__upl_commit_t Request_upl_commit; |
| 233 | __Request__upl_commit_range_t Request_upl_commit_range; |
| 234 | }; |
| 235 | #endif /* __RequestUnion__upl_subsystem__defined */ |
| 236 | /* typedefs for all replies */ |
| 237 | |
| 238 | #ifndef __Reply__upl_subsystem__defined |
| 239 | #define __Reply__upl_subsystem__defined |
| 240 | |
| 241 | #ifdef __MigPackStructs |
| 242 | #pragma pack(4) |
| 243 | #endif |
| 244 | typedef struct { |
| 245 | mach_msg_header_t Head; |
| 246 | NDR_record_t NDR; |
| 247 | kern_return_t RetCode; |
| 248 | } __Reply__upl_abort_t __attribute__((unused)); |
| 249 | #ifdef __MigPackStructs |
| 250 | #pragma pack() |
| 251 | #endif |
| 252 | |
| 253 | #ifdef __MigPackStructs |
| 254 | #pragma pack(4) |
| 255 | #endif |
| 256 | typedef struct { |
| 257 | mach_msg_header_t Head; |
| 258 | NDR_record_t NDR; |
| 259 | kern_return_t RetCode; |
| 260 | boolean_t empty; |
| 261 | } __Reply__upl_abort_range_t __attribute__((unused)); |
| 262 | #ifdef __MigPackStructs |
| 263 | #pragma pack() |
| 264 | #endif |
| 265 | |
| 266 | #ifdef __MigPackStructs |
| 267 | #pragma pack(4) |
| 268 | #endif |
| 269 | typedef struct { |
| 270 | mach_msg_header_t Head; |
| 271 | NDR_record_t NDR; |
| 272 | kern_return_t RetCode; |
| 273 | } __Reply__upl_commit_t __attribute__((unused)); |
| 274 | #ifdef __MigPackStructs |
| 275 | #pragma pack() |
| 276 | #endif |
| 277 | |
| 278 | #ifdef __MigPackStructs |
| 279 | #pragma pack(4) |
| 280 | #endif |
| 281 | typedef struct { |
| 282 | mach_msg_header_t Head; |
| 283 | NDR_record_t NDR; |
| 284 | kern_return_t RetCode; |
| 285 | boolean_t empty; |
| 286 | } __Reply__upl_commit_range_t __attribute__((unused)); |
| 287 | #ifdef __MigPackStructs |
| 288 | #pragma pack() |
| 289 | #endif |
| 290 | #endif /* !__Reply__upl_subsystem__defined */ |
| 291 | |
| 292 | |
| 293 | /* union of all replies */ |
| 294 | |
| 295 | #ifndef __ReplyUnion__upl_subsystem__defined |
| 296 | #define __ReplyUnion__upl_subsystem__defined |
| 297 | union __ReplyUnion__upl_subsystem { |
| 298 | __Reply__upl_abort_t Reply_upl_abort; |
| 299 | __Reply__upl_abort_range_t Reply_upl_abort_range; |
| 300 | __Reply__upl_commit_t Reply_upl_commit; |
| 301 | __Reply__upl_commit_range_t Reply_upl_commit_range; |
| 302 | }; |
| 303 | #endif /* __RequestUnion__upl_subsystem__defined */ |
| 304 | |
| 305 | #ifndef subsystem_to_name_map_upl |
| 306 | #define subsystem_to_name_map_upl \ |
| 307 | { "upl_abort", 2050 },\ |
| 308 | { "upl_abort_range", 2051 },\ |
| 309 | { "upl_commit", 2052 },\ |
| 310 | { "upl_commit_range", 2053 } |
| 311 | #endif |
| 312 | |
| 313 | #ifdef __AfterMigServerHeader |
| 314 | __AfterMigServerHeader |
| 315 | #endif /* __AfterMigServerHeader */ |
| 316 | |
| 317 | #endif /* _upl_server_ */ |
| 318 | |