| 1 | /* |
| 2 | * IDENTIFICATION: |
| 3 | * stub generated by bootstrap_cmds-133 |
| 4 | * OPTIONS: |
| 5 | * KernelUser |
| 6 | */ |
| 7 | #define __MIG_check__Reply__exc_subsystem__ 1 |
| 8 | |
| 9 | #include "exc.h" |
| 10 | |
| 11 | /* TODO: #include <mach/mach.h> */ |
| 12 | #ifdef __cplusplus |
| 13 | extern "C" { |
| 14 | #endif /* __cplusplus */ |
| 15 | extern void mach_msg_destroy(mach_msg_header_t *); |
| 16 | #ifdef __cplusplus |
| 17 | } |
| 18 | #endif /* __cplusplus */ |
| 19 | |
| 20 | #ifndef mig_internal |
| 21 | #define mig_internal static __inline__ |
| 22 | #endif /* mig_internal */ |
| 23 | |
| 24 | #ifndef mig_external |
| 25 | #define mig_external |
| 26 | #endif /* mig_external */ |
| 27 | |
| 28 | #if !defined(__MigTypeCheck) && defined(TypeCheck) |
| 29 | #define __MigTypeCheck TypeCheck /* Legacy setting */ |
| 30 | #endif /* !defined(__MigTypeCheck) */ |
| 31 | |
| 32 | #if !defined(__MigKernelSpecificCode) && defined(_MIG_KERNEL_SPECIFIC_CODE_) |
| 33 | #define __MigKernelSpecificCode _MIG_KERNEL_SPECIFIC_CODE_ /* Legacy setting */ |
| 34 | #endif /* !defined(__MigKernelSpecificCode) */ |
| 35 | |
| 36 | #ifndef LimitCheck |
| 37 | #define LimitCheck 0 |
| 38 | #endif /* LimitCheck */ |
| 39 | |
| 40 | #ifndef min |
| 41 | #define min(a,b) ( ((a) < (b))? (a): (b) ) |
| 42 | #endif /* min */ |
| 43 | |
| 44 | #if !defined(_WALIGN_) |
| 45 | #define _WALIGN_(x) (((x) + 3) & ~3) |
| 46 | #endif /* !defined(_WALIGN_) */ |
| 47 | |
| 48 | #if !defined(_WALIGNSZ_) |
| 49 | #define _WALIGNSZ_(x) _WALIGN_(sizeof(x)) |
| 50 | #endif /* !defined(_WALIGNSZ_) */ |
| 51 | |
| 52 | #ifndef UseStaticTemplates |
| 53 | #define UseStaticTemplates 0 |
| 54 | #endif /* UseStaticTemplates */ |
| 55 | |
| 56 | #ifndef MIG_SERVER_ROUTINE |
| 57 | #define MIG_SERVER_ROUTINE |
| 58 | #endif |
| 59 | |
| 60 | #ifndef __MachMsgErrorWithTimeout |
| 61 | #define __MachMsgErrorWithTimeout(_R_) { \ |
| 62 | switch (_R_) { \ |
| 63 | case MACH_SEND_INVALID_DATA: \ |
| 64 | case MACH_SEND_INVALID_DEST: \ |
| 65 | case MACH_SEND_INVALID_HEADER: \ |
| 66 | mig_put_reply_port(InP->Head.msgh_reply_port); \ |
| 67 | break; \ |
| 68 | case MACH_SEND_TIMED_OUT: \ |
| 69 | case MACH_RCV_TIMED_OUT: \ |
| 70 | default: \ |
| 71 | mig_dealloc_reply_port(InP->Head.msgh_reply_port); \ |
| 72 | } \ |
| 73 | } |
| 74 | #endif /* __MachMsgErrorWithTimeout */ |
| 75 | |
| 76 | #ifndef __MachMsgErrorWithoutTimeout |
| 77 | #define __MachMsgErrorWithoutTimeout(_R_) { \ |
| 78 | switch (_R_) { \ |
| 79 | case MACH_SEND_INVALID_DATA: \ |
| 80 | case MACH_SEND_INVALID_DEST: \ |
| 81 | case MACH_SEND_INVALID_HEADER: \ |
| 82 | mig_put_reply_port(InP->Head.msgh_reply_port); \ |
| 83 | break; \ |
| 84 | default: \ |
| 85 | mig_dealloc_reply_port(InP->Head.msgh_reply_port); \ |
| 86 | } \ |
| 87 | } |
| 88 | #endif /* __MachMsgErrorWithoutTimeout */ |
| 89 | |
| 90 | #ifndef __DeclareSendRpc |
| 91 | #define __DeclareSendRpc(_NUM_, _NAME_) |
| 92 | #endif /* __DeclareSendRpc */ |
| 93 | |
| 94 | #ifndef __BeforeSendRpc |
| 95 | #define __BeforeSendRpc(_NUM_, _NAME_) |
| 96 | #endif /* __BeforeSendRpc */ |
| 97 | |
| 98 | #ifndef __AfterSendRpc |
| 99 | #define __AfterSendRpc(_NUM_, _NAME_) |
| 100 | #endif /* __AfterSendRpc */ |
| 101 | |
| 102 | #ifndef __DeclareSendSimple |
| 103 | #define __DeclareSendSimple(_NUM_, _NAME_) |
| 104 | #endif /* __DeclareSendSimple */ |
| 105 | |
| 106 | #ifndef __BeforeSendSimple |
| 107 | #define __BeforeSendSimple(_NUM_, _NAME_) |
| 108 | #endif /* __BeforeSendSimple */ |
| 109 | |
| 110 | #ifndef __AfterSendSimple |
| 111 | #define __AfterSendSimple(_NUM_, _NAME_) |
| 112 | #endif /* __AfterSendSimple */ |
| 113 | |
| 114 | #define msgh_request_port msgh_remote_port |
| 115 | #define msgh_reply_port msgh_local_port |
| 116 | |
| 117 | |
| 118 | |
| 119 | #if ( __MigTypeCheck ) |
| 120 | #if __MIG_check__Reply__exc_subsystem__ |
| 121 | #if !defined(__MIG_check__Reply__exception_raise_t__defined) |
| 122 | #define __MIG_check__Reply__exception_raise_t__defined |
| 123 | |
| 124 | mig_internal kern_return_t __MIG_check__Reply__exception_raise_t(__Reply__exception_raise_t *Out0P) |
| 125 | { |
| 126 | |
| 127 | typedef __Reply__exception_raise_t __Reply __attribute__((unused)); |
| 128 | if (Out0P->Head.msgh_id != 2501) { |
| 129 | if (Out0P->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) |
| 130 | { return MIG_SERVER_DIED; } |
| 131 | else |
| 132 | { return MIG_REPLY_MISMATCH; } |
| 133 | } |
| 134 | |
| 135 | #if __MigTypeCheck |
| 136 | if ((Out0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || |
| 137 | (Out0P->Head.msgh_size != (mach_msg_size_t)sizeof(__Reply))) |
| 138 | { return MIG_TYPE_ERROR ; } |
| 139 | #endif /* __MigTypeCheck */ |
| 140 | |
| 141 | #if __MigTypeCheck |
| 142 | if (Out0P->Head.msgh_request_port != MACH_PORT_NULL) { |
| 143 | return MIG_TYPE_ERROR; |
| 144 | } |
| 145 | #endif /* __MigTypeCheck */ |
| 146 | { |
| 147 | return Out0P->RetCode; |
| 148 | } |
| 149 | } |
| 150 | #endif /* !defined(__MIG_check__Reply__exception_raise_t__defined) */ |
| 151 | #endif /* __MIG_check__Reply__exc_subsystem__ */ |
| 152 | #endif /* ( __MigTypeCheck ) */ |
| 153 | |
| 154 | |
| 155 | /* Routine exception_raise */ |
| 156 | mig_external kern_return_t exception_raise |
| 157 | ( |
| 158 | mach_port_t exception_port, |
| 159 | mach_port_t thread, |
| 160 | mach_port_t task, |
| 161 | exception_type_t exception, |
| 162 | exception_data_t code, |
| 163 | mach_msg_type_number_t codeCnt |
| 164 | ) |
| 165 | { |
| 166 | |
| 167 | #ifdef __MigPackStructs |
| 168 | #pragma pack(push, 4) |
| 169 | #endif |
| 170 | typedef struct { |
| 171 | mach_msg_header_t Head; |
| 172 | /* start of the kernel processed data */ |
| 173 | mach_msg_body_t msgh_body; |
| 174 | mach_msg_port_descriptor_t thread; |
| 175 | mach_msg_port_descriptor_t task; |
| 176 | /* end of the kernel processed data */ |
| 177 | NDR_record_t NDR; |
| 178 | exception_type_t exception; |
| 179 | mach_msg_type_number_t codeCnt; |
| 180 | integer_t code[2]; |
| 181 | } Request __attribute__((unused)); |
| 182 | #ifdef __MigPackStructs |
| 183 | #pragma pack(pop) |
| 184 | #endif |
| 185 | |
| 186 | #ifdef __MigPackStructs |
| 187 | #pragma pack(push, 4) |
| 188 | #endif |
| 189 | typedef struct { |
| 190 | mach_msg_header_t Head; |
| 191 | NDR_record_t NDR; |
| 192 | kern_return_t RetCode; |
| 193 | mach_msg_trailer_t trailer; |
| 194 | } Reply __attribute__((unused)); |
| 195 | #ifdef __MigPackStructs |
| 196 | #pragma pack(pop) |
| 197 | #endif |
| 198 | |
| 199 | #ifdef __MigPackStructs |
| 200 | #pragma pack(push, 4) |
| 201 | #endif |
| 202 | typedef struct { |
| 203 | mach_msg_header_t Head; |
| 204 | NDR_record_t NDR; |
| 205 | kern_return_t RetCode; |
| 206 | } __Reply __attribute__((unused)); |
| 207 | #ifdef __MigPackStructs |
| 208 | #pragma pack(pop) |
| 209 | #endif |
| 210 | /* |
| 211 | * typedef struct { |
| 212 | * mach_msg_header_t Head; |
| 213 | * NDR_record_t NDR; |
| 214 | * kern_return_t RetCode; |
| 215 | * } mig_reply_error_t; |
| 216 | */ |
| 217 | |
| 218 | union { |
| 219 | Request In; |
| 220 | Reply Out; |
| 221 | } Mess; |
| 222 | |
| 223 | Request *InP = &Mess.In; |
| 224 | Reply *Out0P = &Mess.Out; |
| 225 | |
| 226 | mach_msg_return_t msg_result; |
| 227 | unsigned int msgh_size; |
| 228 | |
| 229 | #ifdef __MIG_check__Reply__exception_raise_t__defined |
| 230 | kern_return_t check_result; |
| 231 | #endif /* __MIG_check__Reply__exception_raise_t__defined */ |
| 232 | |
| 233 | __DeclareSendRpc(2401, "exception_raise" ) |
| 234 | |
| 235 | #if UseStaticTemplates |
| 236 | const static mach_msg_port_descriptor_t threadTemplate = { |
| 237 | /* name = */ MACH_PORT_NULL, |
| 238 | /* pad1 = */ 0, |
| 239 | /* pad2 = */ 0, |
| 240 | /* disp = */ 19, |
| 241 | /* type = */ MACH_MSG_PORT_DESCRIPTOR, |
| 242 | }; |
| 243 | #endif /* UseStaticTemplates */ |
| 244 | |
| 245 | #if UseStaticTemplates |
| 246 | const static mach_msg_port_descriptor_t taskTemplate = { |
| 247 | /* name = */ MACH_PORT_NULL, |
| 248 | /* pad1 = */ 0, |
| 249 | /* pad2 = */ 0, |
| 250 | /* disp = */ 19, |
| 251 | /* type = */ MACH_MSG_PORT_DESCRIPTOR, |
| 252 | }; |
| 253 | #endif /* UseStaticTemplates */ |
| 254 | |
| 255 | InP->msgh_body.msgh_descriptor_count = 2; |
| 256 | #if UseStaticTemplates |
| 257 | InP->thread = threadTemplate; |
| 258 | InP->thread.name = thread; |
| 259 | #else /* UseStaticTemplates */ |
| 260 | InP->thread.name = thread; |
| 261 | InP->thread.disposition = 19; |
| 262 | InP->thread.type = MACH_MSG_PORT_DESCRIPTOR; |
| 263 | #endif /* UseStaticTemplates */ |
| 264 | |
| 265 | #if UseStaticTemplates |
| 266 | InP->task = taskTemplate; |
| 267 | InP->task.name = task; |
| 268 | #else /* UseStaticTemplates */ |
| 269 | InP->task.name = task; |
| 270 | InP->task.disposition = 19; |
| 271 | InP->task.type = MACH_MSG_PORT_DESCRIPTOR; |
| 272 | #endif /* UseStaticTemplates */ |
| 273 | |
| 274 | InP->NDR = NDR_record; |
| 275 | |
| 276 | InP->exception = exception; |
| 277 | |
| 278 | if (codeCnt > 2) { |
| 279 | { return MIG_ARRAY_TOO_LARGE; } |
| 280 | } |
| 281 | (void)memcpy(dst: (char *) InP->code, src: (const char *) code, n: 4 * codeCnt); |
| 282 | |
| 283 | InP->codeCnt = codeCnt; |
| 284 | |
| 285 | msgh_size = (mach_msg_size_t)(sizeof(Request) - 8) + ((4 * codeCnt)); |
| 286 | InP->Head.msgh_reply_port = mig_get_reply_port(); |
| 287 | InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX| |
| 288 | MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); |
| 289 | /* msgh_size passed as argument */ |
| 290 | InP->Head.msgh_request_port = exception_port; |
| 291 | InP->Head.msgh_id = 2401; |
| 292 | InP->Head.msgh_reserved = 0; |
| 293 | |
| 294 | __BeforeSendRpc(2401, "exception_raise" ) |
| 295 | #if (__MigKernelSpecificCode) || (_MIG_KERNELSPECIFIC_CODE_) |
| 296 | msg_result = mach_msg_rpc_from_kernel(msg: &InP->Head, send_size: msgh_size, rcv_size: (mach_msg_size_t)sizeof(Reply)); |
| 297 | #else |
| 298 | msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, msgh_size, (mach_msg_size_t)sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); |
| 299 | #endif /* __MigKernelSpecificCode */ |
| 300 | __AfterSendRpc(2401, "exception_raise" ) |
| 301 | if (msg_result != MACH_MSG_SUCCESS) { |
| 302 | __MachMsgErrorWithoutTimeout(msg_result); |
| 303 | } |
| 304 | if (msg_result != MACH_MSG_SUCCESS) { |
| 305 | { return msg_result; } |
| 306 | } |
| 307 | |
| 308 | |
| 309 | #if defined(__MIG_check__Reply__exception_raise_t__defined) |
| 310 | check_result = __MIG_check__Reply__exception_raise_t(Out0P: (__Reply__exception_raise_t *)Out0P); |
| 311 | if (check_result != MACH_MSG_SUCCESS) { |
| 312 | #if __MigKernelSpecificCode |
| 313 | mach_msg_destroy_from_kernel(msg: &Out0P->Head); |
| 314 | #endif /* __MigKernelSpecificCode */ |
| 315 | { return check_result; } |
| 316 | } |
| 317 | #endif /* defined(__MIG_check__Reply__exception_raise_t__defined) */ |
| 318 | |
| 319 | return KERN_SUCCESS; |
| 320 | } |
| 321 | |
| 322 | #if ( __MigTypeCheck ) |
| 323 | #if __MIG_check__Reply__exc_subsystem__ |
| 324 | #if !defined(__MIG_check__Reply__exception_raise_state_t__defined) |
| 325 | #define __MIG_check__Reply__exception_raise_state_t__defined |
| 326 | |
| 327 | mig_internal kern_return_t __MIG_check__Reply__exception_raise_state_t(__Reply__exception_raise_state_t *Out0P) |
| 328 | { |
| 329 | |
| 330 | typedef __Reply__exception_raise_state_t __Reply __attribute__((unused)); |
| 331 | #if __MigTypeCheck |
| 332 | unsigned int msgh_size; |
| 333 | #endif /* __MigTypeCheck */ |
| 334 | |
| 335 | if (Out0P->Head.msgh_id != 2502) { |
| 336 | if (Out0P->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) |
| 337 | { return MIG_SERVER_DIED; } |
| 338 | else |
| 339 | { return MIG_REPLY_MISMATCH; } |
| 340 | } |
| 341 | |
| 342 | #if __MigTypeCheck |
| 343 | msgh_size = Out0P->Head.msgh_size; |
| 344 | |
| 345 | if ((Out0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || |
| 346 | ((msgh_size > (mach_msg_size_t)sizeof(__Reply) || msgh_size < (mach_msg_size_t)(sizeof(__Reply) - 5184)) && |
| 347 | (msgh_size != (mach_msg_size_t)sizeof(mig_reply_error_t) || |
| 348 | Out0P->RetCode == KERN_SUCCESS))) |
| 349 | { return MIG_TYPE_ERROR ; } |
| 350 | #endif /* __MigTypeCheck */ |
| 351 | |
| 352 | #if __MigTypeCheck |
| 353 | if (Out0P->Head.msgh_request_port != MACH_PORT_NULL) { |
| 354 | return MIG_TYPE_ERROR; |
| 355 | } |
| 356 | #endif /* __MigTypeCheck */ |
| 357 | if (Out0P->RetCode != KERN_SUCCESS) { |
| 358 | return ((mig_reply_error_t *)Out0P)->RetCode; |
| 359 | } |
| 360 | |
| 361 | #if __MigTypeCheck |
| 362 | if ( Out0P->new_stateCnt > 1296 ) |
| 363 | return MIG_TYPE_ERROR; |
| 364 | if (((msgh_size - (mach_msg_size_t)(sizeof(__Reply) - 5184)) / 4< Out0P->new_stateCnt) || |
| 365 | (msgh_size != (mach_msg_size_t)(sizeof(__Reply) - 5184) + Out0P->new_stateCnt * 4)) |
| 366 | { return MIG_TYPE_ERROR ; } |
| 367 | #endif /* __MigTypeCheck */ |
| 368 | |
| 369 | return MACH_MSG_SUCCESS; |
| 370 | } |
| 371 | #endif /* !defined(__MIG_check__Reply__exception_raise_state_t__defined) */ |
| 372 | #endif /* __MIG_check__Reply__exc_subsystem__ */ |
| 373 | #endif /* ( __MigTypeCheck ) */ |
| 374 | |
| 375 | |
| 376 | /* Routine exception_raise_state */ |
| 377 | mig_external kern_return_t exception_raise_state |
| 378 | ( |
| 379 | mach_port_t exception_port, |
| 380 | exception_type_t exception, |
| 381 | const exception_data_t code, |
| 382 | mach_msg_type_number_t codeCnt, |
| 383 | int *flavor, |
| 384 | const thread_state_t old_state, |
| 385 | mach_msg_type_number_t old_stateCnt, |
| 386 | thread_state_t new_state, |
| 387 | mach_msg_type_number_t *new_stateCnt |
| 388 | ) |
| 389 | { |
| 390 | |
| 391 | #ifdef __MigPackStructs |
| 392 | #pragma pack(push, 4) |
| 393 | #endif |
| 394 | typedef struct { |
| 395 | mach_msg_header_t Head; |
| 396 | NDR_record_t NDR; |
| 397 | exception_type_t exception; |
| 398 | mach_msg_type_number_t codeCnt; |
| 399 | integer_t code[2]; |
| 400 | int flavor; |
| 401 | mach_msg_type_number_t old_stateCnt; |
| 402 | natural_t old_state[1296]; |
| 403 | } Request __attribute__((unused)); |
| 404 | #ifdef __MigPackStructs |
| 405 | #pragma pack(pop) |
| 406 | #endif |
| 407 | |
| 408 | #ifdef __MigPackStructs |
| 409 | #pragma pack(push, 4) |
| 410 | #endif |
| 411 | typedef struct { |
| 412 | mach_msg_header_t Head; |
| 413 | NDR_record_t NDR; |
| 414 | kern_return_t RetCode; |
| 415 | int flavor; |
| 416 | mach_msg_type_number_t new_stateCnt; |
| 417 | natural_t new_state[1296]; |
| 418 | mach_msg_trailer_t trailer; |
| 419 | } Reply __attribute__((unused)); |
| 420 | #ifdef __MigPackStructs |
| 421 | #pragma pack(pop) |
| 422 | #endif |
| 423 | |
| 424 | #ifdef __MigPackStructs |
| 425 | #pragma pack(push, 4) |
| 426 | #endif |
| 427 | typedef struct { |
| 428 | mach_msg_header_t Head; |
| 429 | NDR_record_t NDR; |
| 430 | kern_return_t RetCode; |
| 431 | int flavor; |
| 432 | mach_msg_type_number_t new_stateCnt; |
| 433 | natural_t new_state[1296]; |
| 434 | } __Reply __attribute__((unused)); |
| 435 | #ifdef __MigPackStructs |
| 436 | #pragma pack(pop) |
| 437 | #endif |
| 438 | /* |
| 439 | * typedef struct { |
| 440 | * mach_msg_header_t Head; |
| 441 | * NDR_record_t NDR; |
| 442 | * kern_return_t RetCode; |
| 443 | * } mig_reply_error_t; |
| 444 | */ |
| 445 | |
| 446 | union exception_raise_stateMessU { |
| 447 | Request In; |
| 448 | Reply Out; |
| 449 | } *Mess = (union exception_raise_stateMessU *) mig_user_allocate(size: sizeof(*Mess)); |
| 450 | |
| 451 | Request *InP = &Mess->In; |
| 452 | Reply *Out0P = &Mess->Out; |
| 453 | |
| 454 | mach_msg_return_t msg_result; |
| 455 | unsigned int msgh_size; |
| 456 | unsigned int msgh_size_delta; |
| 457 | |
| 458 | |
| 459 | #ifdef __MIG_check__Reply__exception_raise_state_t__defined |
| 460 | kern_return_t check_result; |
| 461 | #endif /* __MIG_check__Reply__exception_raise_state_t__defined */ |
| 462 | |
| 463 | __DeclareSendRpc(2402, "exception_raise_state" ) |
| 464 | |
| 465 | InP->NDR = NDR_record; |
| 466 | |
| 467 | InP->exception = exception; |
| 468 | |
| 469 | if (codeCnt > 2) { |
| 470 | { mig_user_deallocate(data: (char *) Mess, size: (mach_msg_size_t)sizeof(*Mess)); return MIG_ARRAY_TOO_LARGE; } |
| 471 | } |
| 472 | (void)memcpy(dst: (char *) InP->code, src: (const char *) code, n: 4 * codeCnt); |
| 473 | |
| 474 | InP->codeCnt = codeCnt; |
| 475 | |
| 476 | msgh_size_delta = (4 * codeCnt); |
| 477 | msgh_size = (mach_msg_size_t)(sizeof(Request) - 5192) + msgh_size_delta; |
| 478 | InP = (Request *) ((pointer_t) InP + msgh_size_delta - 8); |
| 479 | |
| 480 | InP->flavor = *flavor; |
| 481 | |
| 482 | if (old_stateCnt > 1296) { |
| 483 | { mig_user_deallocate(data: (char *) Mess, size: (mach_msg_size_t)sizeof(*Mess)); return MIG_ARRAY_TOO_LARGE; } |
| 484 | } |
| 485 | (void)memcpy(dst: (char *) InP->old_state, src: (const char *) old_state, n: 4 * old_stateCnt); |
| 486 | |
| 487 | InP->old_stateCnt = old_stateCnt; |
| 488 | |
| 489 | msgh_size += (4 * old_stateCnt); |
| 490 | InP = &Mess->In; |
| 491 | InP->Head.msgh_reply_port = mig_get_reply_port(); |
| 492 | InP->Head.msgh_bits = |
| 493 | MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); |
| 494 | /* msgh_size passed as argument */ |
| 495 | InP->Head.msgh_request_port = exception_port; |
| 496 | InP->Head.msgh_id = 2402; |
| 497 | InP->Head.msgh_reserved = 0; |
| 498 | |
| 499 | __BeforeSendRpc(2402, "exception_raise_state" ) |
| 500 | #if (__MigKernelSpecificCode) || (_MIG_KERNELSPECIFIC_CODE_) |
| 501 | msg_result = mach_msg_rpc_from_kernel(msg: &InP->Head, send_size: msgh_size, rcv_size: (mach_msg_size_t)sizeof(Reply)); |
| 502 | #else |
| 503 | msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, msgh_size, (mach_msg_size_t)sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); |
| 504 | #endif /* __MigKernelSpecificCode */ |
| 505 | __AfterSendRpc(2402, "exception_raise_state" ) |
| 506 | if (msg_result != MACH_MSG_SUCCESS) { |
| 507 | __MachMsgErrorWithoutTimeout(msg_result); |
| 508 | } |
| 509 | if (msg_result != MACH_MSG_SUCCESS) { |
| 510 | { mig_user_deallocate(data: (char *) Mess, size: (mach_msg_size_t)sizeof(*Mess)); return msg_result; } |
| 511 | } |
| 512 | |
| 513 | |
| 514 | #if defined(__MIG_check__Reply__exception_raise_state_t__defined) |
| 515 | check_result = __MIG_check__Reply__exception_raise_state_t(Out0P: (__Reply__exception_raise_state_t *)Out0P); |
| 516 | if (check_result != MACH_MSG_SUCCESS) { |
| 517 | #if __MigKernelSpecificCode |
| 518 | mach_msg_destroy_from_kernel(msg: &Out0P->Head); |
| 519 | #endif /* __MigKernelSpecificCode */ |
| 520 | { mig_user_deallocate(data: (char *) Mess, size: (mach_msg_size_t)sizeof(*Mess)); return check_result; } |
| 521 | } |
| 522 | #endif /* defined(__MIG_check__Reply__exception_raise_state_t__defined) */ |
| 523 | |
| 524 | *flavor = Out0P->flavor; |
| 525 | |
| 526 | if (Out0P->new_stateCnt > 1296) { |
| 527 | (void)memcpy(dst: (char *) new_state, src: (const char *) Out0P->new_state, n: 4 * 1296); |
| 528 | *new_stateCnt = Out0P->new_stateCnt; |
| 529 | { mig_user_deallocate(data: (char *) Mess, size: (mach_msg_size_t)sizeof(*Mess)); return MIG_ARRAY_TOO_LARGE; } |
| 530 | } |
| 531 | (void)memcpy(dst: (char *) new_state, src: (const char *) Out0P->new_state, n: 4 * Out0P->new_stateCnt); |
| 532 | |
| 533 | *new_stateCnt = Out0P->new_stateCnt; |
| 534 | |
| 535 | { mig_user_deallocate(data: (char *) Mess, size: sizeof(*Mess)); return KERN_SUCCESS; } |
| 536 | } |
| 537 | |
| 538 | #if ( __MigTypeCheck ) |
| 539 | #if __MIG_check__Reply__exc_subsystem__ |
| 540 | #if !defined(__MIG_check__Reply__exception_raise_state_identity_t__defined) |
| 541 | #define __MIG_check__Reply__exception_raise_state_identity_t__defined |
| 542 | |
| 543 | mig_internal kern_return_t __MIG_check__Reply__exception_raise_state_identity_t(__Reply__exception_raise_state_identity_t *Out0P) |
| 544 | { |
| 545 | |
| 546 | typedef __Reply__exception_raise_state_identity_t __Reply __attribute__((unused)); |
| 547 | #if __MigTypeCheck |
| 548 | unsigned int msgh_size; |
| 549 | #endif /* __MigTypeCheck */ |
| 550 | |
| 551 | if (Out0P->Head.msgh_id != 2503) { |
| 552 | if (Out0P->Head.msgh_id == MACH_NOTIFY_SEND_ONCE) |
| 553 | { return MIG_SERVER_DIED; } |
| 554 | else |
| 555 | { return MIG_REPLY_MISMATCH; } |
| 556 | } |
| 557 | |
| 558 | #if __MigTypeCheck |
| 559 | msgh_size = Out0P->Head.msgh_size; |
| 560 | |
| 561 | if ((Out0P->Head.msgh_bits & MACH_MSGH_BITS_COMPLEX) || |
| 562 | ((msgh_size > (mach_msg_size_t)sizeof(__Reply) || msgh_size < (mach_msg_size_t)(sizeof(__Reply) - 5184)) && |
| 563 | (msgh_size != (mach_msg_size_t)sizeof(mig_reply_error_t) || |
| 564 | Out0P->RetCode == KERN_SUCCESS))) |
| 565 | { return MIG_TYPE_ERROR ; } |
| 566 | #endif /* __MigTypeCheck */ |
| 567 | |
| 568 | #if __MigTypeCheck |
| 569 | if (Out0P->Head.msgh_request_port != MACH_PORT_NULL) { |
| 570 | return MIG_TYPE_ERROR; |
| 571 | } |
| 572 | #endif /* __MigTypeCheck */ |
| 573 | if (Out0P->RetCode != KERN_SUCCESS) { |
| 574 | return ((mig_reply_error_t *)Out0P)->RetCode; |
| 575 | } |
| 576 | |
| 577 | #if __MigTypeCheck |
| 578 | if ( Out0P->new_stateCnt > 1296 ) |
| 579 | return MIG_TYPE_ERROR; |
| 580 | if (((msgh_size - (mach_msg_size_t)(sizeof(__Reply) - 5184)) / 4< Out0P->new_stateCnt) || |
| 581 | (msgh_size != (mach_msg_size_t)(sizeof(__Reply) - 5184) + Out0P->new_stateCnt * 4)) |
| 582 | { return MIG_TYPE_ERROR ; } |
| 583 | #endif /* __MigTypeCheck */ |
| 584 | |
| 585 | return MACH_MSG_SUCCESS; |
| 586 | } |
| 587 | #endif /* !defined(__MIG_check__Reply__exception_raise_state_identity_t__defined) */ |
| 588 | #endif /* __MIG_check__Reply__exc_subsystem__ */ |
| 589 | #endif /* ( __MigTypeCheck ) */ |
| 590 | |
| 591 | |
| 592 | /* Routine exception_raise_state_identity */ |
| 593 | mig_external kern_return_t exception_raise_state_identity |
| 594 | ( |
| 595 | mach_port_t exception_port, |
| 596 | mach_port_t thread, |
| 597 | mach_port_t task, |
| 598 | exception_type_t exception, |
| 599 | exception_data_t code, |
| 600 | mach_msg_type_number_t codeCnt, |
| 601 | int *flavor, |
| 602 | thread_state_t old_state, |
| 603 | mach_msg_type_number_t old_stateCnt, |
| 604 | thread_state_t new_state, |
| 605 | mach_msg_type_number_t *new_stateCnt |
| 606 | ) |
| 607 | { |
| 608 | |
| 609 | #ifdef __MigPackStructs |
| 610 | #pragma pack(push, 4) |
| 611 | #endif |
| 612 | typedef struct { |
| 613 | mach_msg_header_t Head; |
| 614 | /* start of the kernel processed data */ |
| 615 | mach_msg_body_t msgh_body; |
| 616 | mach_msg_port_descriptor_t thread; |
| 617 | mach_msg_port_descriptor_t task; |
| 618 | /* end of the kernel processed data */ |
| 619 | NDR_record_t NDR; |
| 620 | exception_type_t exception; |
| 621 | mach_msg_type_number_t codeCnt; |
| 622 | integer_t code[2]; |
| 623 | int flavor; |
| 624 | mach_msg_type_number_t old_stateCnt; |
| 625 | natural_t old_state[1296]; |
| 626 | } Request __attribute__((unused)); |
| 627 | #ifdef __MigPackStructs |
| 628 | #pragma pack(pop) |
| 629 | #endif |
| 630 | |
| 631 | #ifdef __MigPackStructs |
| 632 | #pragma pack(push, 4) |
| 633 | #endif |
| 634 | typedef struct { |
| 635 | mach_msg_header_t Head; |
| 636 | NDR_record_t NDR; |
| 637 | kern_return_t RetCode; |
| 638 | int flavor; |
| 639 | mach_msg_type_number_t new_stateCnt; |
| 640 | natural_t new_state[1296]; |
| 641 | mach_msg_trailer_t trailer; |
| 642 | } Reply __attribute__((unused)); |
| 643 | #ifdef __MigPackStructs |
| 644 | #pragma pack(pop) |
| 645 | #endif |
| 646 | |
| 647 | #ifdef __MigPackStructs |
| 648 | #pragma pack(push, 4) |
| 649 | #endif |
| 650 | typedef struct { |
| 651 | mach_msg_header_t Head; |
| 652 | NDR_record_t NDR; |
| 653 | kern_return_t RetCode; |
| 654 | int flavor; |
| 655 | mach_msg_type_number_t new_stateCnt; |
| 656 | natural_t new_state[1296]; |
| 657 | } __Reply __attribute__((unused)); |
| 658 | #ifdef __MigPackStructs |
| 659 | #pragma pack(pop) |
| 660 | #endif |
| 661 | /* |
| 662 | * typedef struct { |
| 663 | * mach_msg_header_t Head; |
| 664 | * NDR_record_t NDR; |
| 665 | * kern_return_t RetCode; |
| 666 | * } mig_reply_error_t; |
| 667 | */ |
| 668 | |
| 669 | union exception_raise_state_identityMessU { |
| 670 | Request In; |
| 671 | Reply Out; |
| 672 | } *Mess = (union exception_raise_state_identityMessU *) mig_user_allocate(size: sizeof(*Mess)); |
| 673 | |
| 674 | Request *InP = &Mess->In; |
| 675 | Reply *Out0P = &Mess->Out; |
| 676 | |
| 677 | mach_msg_return_t msg_result; |
| 678 | unsigned int msgh_size; |
| 679 | unsigned int msgh_size_delta; |
| 680 | |
| 681 | |
| 682 | #ifdef __MIG_check__Reply__exception_raise_state_identity_t__defined |
| 683 | kern_return_t check_result; |
| 684 | #endif /* __MIG_check__Reply__exception_raise_state_identity_t__defined */ |
| 685 | |
| 686 | __DeclareSendRpc(2403, "exception_raise_state_identity" ) |
| 687 | |
| 688 | #if UseStaticTemplates |
| 689 | const static mach_msg_port_descriptor_t threadTemplate = { |
| 690 | /* name = */ MACH_PORT_NULL, |
| 691 | /* pad1 = */ 0, |
| 692 | /* pad2 = */ 0, |
| 693 | /* disp = */ 19, |
| 694 | /* type = */ MACH_MSG_PORT_DESCRIPTOR, |
| 695 | }; |
| 696 | #endif /* UseStaticTemplates */ |
| 697 | |
| 698 | #if UseStaticTemplates |
| 699 | const static mach_msg_port_descriptor_t taskTemplate = { |
| 700 | /* name = */ MACH_PORT_NULL, |
| 701 | /* pad1 = */ 0, |
| 702 | /* pad2 = */ 0, |
| 703 | /* disp = */ 19, |
| 704 | /* type = */ MACH_MSG_PORT_DESCRIPTOR, |
| 705 | }; |
| 706 | #endif /* UseStaticTemplates */ |
| 707 | |
| 708 | InP->msgh_body.msgh_descriptor_count = 2; |
| 709 | #if UseStaticTemplates |
| 710 | InP->thread = threadTemplate; |
| 711 | InP->thread.name = thread; |
| 712 | #else /* UseStaticTemplates */ |
| 713 | InP->thread.name = thread; |
| 714 | InP->thread.disposition = 19; |
| 715 | InP->thread.type = MACH_MSG_PORT_DESCRIPTOR; |
| 716 | #endif /* UseStaticTemplates */ |
| 717 | |
| 718 | #if UseStaticTemplates |
| 719 | InP->task = taskTemplate; |
| 720 | InP->task.name = task; |
| 721 | #else /* UseStaticTemplates */ |
| 722 | InP->task.name = task; |
| 723 | InP->task.disposition = 19; |
| 724 | InP->task.type = MACH_MSG_PORT_DESCRIPTOR; |
| 725 | #endif /* UseStaticTemplates */ |
| 726 | |
| 727 | InP->NDR = NDR_record; |
| 728 | |
| 729 | InP->exception = exception; |
| 730 | |
| 731 | if (codeCnt > 2) { |
| 732 | { mig_user_deallocate(data: (char *) Mess, size: (mach_msg_size_t)sizeof(*Mess)); return MIG_ARRAY_TOO_LARGE; } |
| 733 | } |
| 734 | (void)memcpy(dst: (char *) InP->code, src: (const char *) code, n: 4 * codeCnt); |
| 735 | |
| 736 | InP->codeCnt = codeCnt; |
| 737 | |
| 738 | msgh_size_delta = (4 * codeCnt); |
| 739 | msgh_size = (mach_msg_size_t)(sizeof(Request) - 5192) + msgh_size_delta; |
| 740 | InP = (Request *) ((pointer_t) InP + msgh_size_delta - 8); |
| 741 | |
| 742 | InP->flavor = *flavor; |
| 743 | |
| 744 | if (old_stateCnt > 1296) { |
| 745 | { mig_user_deallocate(data: (char *) Mess, size: (mach_msg_size_t)sizeof(*Mess)); return MIG_ARRAY_TOO_LARGE; } |
| 746 | } |
| 747 | (void)memcpy(dst: (char *) InP->old_state, src: (const char *) old_state, n: 4 * old_stateCnt); |
| 748 | |
| 749 | InP->old_stateCnt = old_stateCnt; |
| 750 | |
| 751 | msgh_size += (4 * old_stateCnt); |
| 752 | InP = &Mess->In; |
| 753 | InP->Head.msgh_reply_port = mig_get_reply_port(); |
| 754 | InP->Head.msgh_bits = MACH_MSGH_BITS_COMPLEX| |
| 755 | MACH_MSGH_BITS(19, MACH_MSG_TYPE_MAKE_SEND_ONCE); |
| 756 | /* msgh_size passed as argument */ |
| 757 | InP->Head.msgh_request_port = exception_port; |
| 758 | InP->Head.msgh_id = 2403; |
| 759 | InP->Head.msgh_reserved = 0; |
| 760 | |
| 761 | __BeforeSendRpc(2403, "exception_raise_state_identity" ) |
| 762 | #if (__MigKernelSpecificCode) || (_MIG_KERNELSPECIFIC_CODE_) |
| 763 | msg_result = mach_msg_rpc_from_kernel(msg: &InP->Head, send_size: msgh_size, rcv_size: (mach_msg_size_t)sizeof(Reply)); |
| 764 | #else |
| 765 | msg_result = mach_msg(&InP->Head, MACH_SEND_MSG|MACH_RCV_MSG|MACH_MSG_OPTION_NONE, msgh_size, (mach_msg_size_t)sizeof(Reply), InP->Head.msgh_reply_port, MACH_MSG_TIMEOUT_NONE, MACH_PORT_NULL); |
| 766 | #endif /* __MigKernelSpecificCode */ |
| 767 | __AfterSendRpc(2403, "exception_raise_state_identity" ) |
| 768 | if (msg_result != MACH_MSG_SUCCESS) { |
| 769 | __MachMsgErrorWithoutTimeout(msg_result); |
| 770 | } |
| 771 | if (msg_result != MACH_MSG_SUCCESS) { |
| 772 | { mig_user_deallocate(data: (char *) Mess, size: (mach_msg_size_t)sizeof(*Mess)); return msg_result; } |
| 773 | } |
| 774 | |
| 775 | |
| 776 | #if defined(__MIG_check__Reply__exception_raise_state_identity_t__defined) |
| 777 | check_result = __MIG_check__Reply__exception_raise_state_identity_t(Out0P: (__Reply__exception_raise_state_identity_t *)Out0P); |
| 778 | if (check_result != MACH_MSG_SUCCESS) { |
| 779 | #if __MigKernelSpecificCode |
| 780 | mach_msg_destroy_from_kernel(msg: &Out0P->Head); |
| 781 | #endif /* __MigKernelSpecificCode */ |
| 782 | { mig_user_deallocate(data: (char *) Mess, size: (mach_msg_size_t)sizeof(*Mess)); return check_result; } |
| 783 | } |
| 784 | #endif /* defined(__MIG_check__Reply__exception_raise_state_identity_t__defined) */ |
| 785 | |
| 786 | *flavor = Out0P->flavor; |
| 787 | |
| 788 | if (Out0P->new_stateCnt > 1296) { |
| 789 | (void)memcpy(dst: (char *) new_state, src: (const char *) Out0P->new_state, n: 4 * 1296); |
| 790 | *new_stateCnt = Out0P->new_stateCnt; |
| 791 | { mig_user_deallocate(data: (char *) Mess, size: (mach_msg_size_t)sizeof(*Mess)); return MIG_ARRAY_TOO_LARGE; } |
| 792 | } |
| 793 | (void)memcpy(dst: (char *) new_state, src: (const char *) Out0P->new_state, n: 4 * Out0P->new_stateCnt); |
| 794 | |
| 795 | *new_stateCnt = Out0P->new_stateCnt; |
| 796 | |
| 797 | { mig_user_deallocate(data: (char *) Mess, size: sizeof(*Mess)); return KERN_SUCCESS; } |
| 798 | } |
| 799 | |