--- Gnu-Mach/kern/exception.c 2020/09/02 04:36:56 1.1.1.1 +++ Gnu-Mach/kern/exception.c 2020/09/02 04:47:27 1.1.1.6 @@ -1,39 +1,38 @@ -/* +/* * Mach Operating System * Copyright (c) 1993,1992,1991,1990,1989,1988,1987 Carnegie Mellon University. * All Rights Reserved. - * + * * Permission to use, copy, modify and distribute this software and its * documentation is hereby granted, provided that both the copyright * notice and this permission notice appear in all copies of the * software, derivative works or modified versions, and any portions * thereof, and that both notices appear in supporting documentation. - * + * * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS" * CONDITION. CARNEGIE MELLON DISCLAIMS ANY LIABILITY OF ANY KIND FOR * ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * + * * Carnegie Mellon requests users of this software to return to - * + * * Software Distribution Coordinator or Software.Distribution@CS.CMU.EDU * School of Computer Science * Carnegie Mellon University * Pittsburgh PA 15213-3890 - * + * * any improvements or extensions that they make and grant Carnegie Mellon * the rights to redistribute these changes. */ -#include -#include - #include #include #include #include #include +#include #include #include +#include #include #include #include @@ -41,29 +40,19 @@ #include #include #include +#include #include #include #include #include #include #include +#include #include - - -extern void exception(); -extern void exception_try_task(); -extern void exception_no_server(); - -extern void exception_raise(); -extern kern_return_t exception_parse_reply(); -extern void exception_raise_continue(); -extern void exception_raise_continue_slow(); -extern void exception_raise_continue_fast(); - #if MACH_KDB -extern void thread_kdb_return(); -extern void db_printf(); +#include +#include boolean_t debug_user_with_kdb = FALSE; #endif /* MACH_KDB */ @@ -76,7 +65,7 @@ boolean_t debug_user_with_kdb = FALSE; * The exception function is expected to return. * So the return statements along the slow paths are important. */ -#endif KEEP_STACKS +#endif /* KEEP_STACKS */ /* * Routine: exception @@ -93,11 +82,13 @@ boolean_t debug_user_with_kdb = FALSE; */ void -exception(_exception, code, subcode) - integer_t _exception, code, subcode; +exception( + integer_t _exception, + integer_t code, + integer_t subcode) { - register ipc_thread_t self = current_thread(); - register ipc_port_t exc_port; + ipc_thread_t self = current_thread(); + ipc_port_t exc_port; if (_exception == KERN_SUCCESS) panic("exception"); @@ -113,7 +104,6 @@ exception(_exception, code, subcode) ith_unlock(self); exception_try_task(_exception, code, subcode); /*NOTREACHED*/ - return; } ip_lock(exc_port); @@ -122,7 +112,6 @@ exception(_exception, code, subcode) ip_unlock(exc_port); exception_try_task(_exception, code, subcode); /*NOTREACHED*/ - return; } /* @@ -165,12 +154,14 @@ exception(_exception, code, subcode) */ void -exception_try_task(_exception, code, subcode) - integer_t _exception, code, subcode; +exception_try_task( + integer_t _exception, + integer_t code, + integer_t subcode) { ipc_thread_t self = current_thread(); - register task_t task = self->task; - register ipc_port_t exc_port; + task_t task = self->task; + ipc_port_t exc_port; /* * Optimized version of retrieve_task_exception. @@ -183,7 +174,6 @@ exception_try_task(_exception, code, sub itk_unlock(task); exception_no_server(); /*NOTREACHED*/ - return; } ip_lock(exc_port); @@ -192,7 +182,6 @@ exception_try_task(_exception, code, sub ip_unlock(exc_port); exception_no_server(); /*NOTREACHED*/ - return; } /* @@ -232,9 +221,9 @@ exception_try_task(_exception, code, sub */ void -exception_no_server() +exception_no_server(void) { - register ipc_thread_t self = current_thread(); + ipc_thread_t self = current_thread(); /* * If this thread is being terminated, cooperate. @@ -244,8 +233,10 @@ exception_no_server() thread_halt_self(); +#if 0 if (thread_suspend (self) == KERN_SUCCESS) thread_exception_return (); +#endif #if MACH_KDB if (debug_user_with_kdb) { @@ -258,7 +249,7 @@ exception_no_server() db_printf("No exception server, calling kdb...\n"); thread_kdb_return(); } -#endif MACH_KDB +#endif /* MACH_KDB */ /* * All else failed; terminate task. @@ -266,6 +257,7 @@ exception_no_server() (void) task_terminate(self->task); thread_halt_self(); + panic("terminating the task didn't kill us"); /*NOTREACHED*/ } @@ -331,12 +323,13 @@ mach_msg_type_t exc_code_proto = { int exception_raise_misses = 0; void -exception_raise(dest_port, thread_port, task_port, - _exception, code, subcode) - ipc_port_t dest_port; - ipc_port_t thread_port; - ipc_port_t task_port; - integer_t _exception, code, subcode; +exception_raise( + ipc_port_t dest_port, + ipc_port_t thread_port, + ipc_port_t task_port, + integer_t _exception, + integer_t code, + integer_t subcode) { ipc_thread_t self = current_thread(); ipc_thread_t receiver; @@ -418,9 +411,6 @@ exception_raise(dest_port, thread_port, } if (!ip_active(dest_port) || -#if NORMA_IPC - IP_NORMA_IS_PROXY(dest_port) || -#endif NORMA_IPC (dest_port->ip_receiver == ipc_space_kernel)) { imq_unlock(reply_mqueue); ip_unlock(dest_port); @@ -432,7 +422,7 @@ exception_raise(dest_port, thread_port, */ { - register ipc_pset_t dest_pset; + ipc_pset_t dest_pset; dest_pset = dest_port->ip_pset; if (dest_pset == IPS_NULL) @@ -494,7 +484,7 @@ exception_raise(dest_port, thread_port, * Release the receiver's reference for his object. */ { - register ipc_object_t object = receiver->ith_object; + ipc_object_t object = receiver->ith_object; io_lock(object); io_release(object); @@ -502,7 +492,7 @@ exception_raise(dest_port, thread_port, } { - register struct mach_exception *exc = + struct mach_exception *exc = (struct mach_exception *) &kmsg->ikm_header; ipc_space_t space = receiver->task->itk_space; @@ -613,9 +603,9 @@ exception_raise(dest_port, thread_port, ip_unlock(reply_port); { - register ipc_entry_t table; - register ipc_entry_t entry; - register mach_port_index_t index; + ipc_entry_t table; + ipc_entry_t entry; + mach_port_index_t index; /* optimized ipc_entry_get */ @@ -630,7 +620,7 @@ exception_raise(dest_port, thread_port, entry->ie_request = 0; { - register mach_port_gen_t gen; + mach_port_gen_t gen; assert((entry->ie_bits &~ IE_BITS_GEN_MASK) == 0); gen = entry->ie_bits + IE_BITS_GEN_ONE; @@ -697,7 +687,7 @@ exception_raise(dest_port, thread_port, ikm_check_initialized(kmsg, kmsg->ikm_size); assert(kmsg->ikm_size == IKM_SAVED_KMSG_SIZE); - if (copyoutmsg((vm_offset_t) &kmsg->ikm_header, (vm_offset_t)receiver->ith_msg, + if (copyoutmsg(&kmsg->ikm_header, receiver->ith_msg, sizeof(struct mach_exception)) || (ikm_cache() != IKM_NULL)) { mr = ipc_kmsg_put(receiver->ith_msg, kmsg, @@ -714,7 +704,7 @@ exception_raise(dest_port, thread_port, #endif slow_exception_raise: { - register struct mach_exception *exc = + struct mach_exception *exc = (struct mach_exception *) &kmsg->ikm_header; ipc_kmsg_t reply_kmsg; mach_port_seqno_t reply_seqno; @@ -759,7 +749,6 @@ exception_raise(dest_port, thread_port, ip_unlock(reply_port); exception_raise_continue_slow(MACH_RCV_PORT_DIED, IKM_NULL, /*dummy*/0); /*NOTREACHED*/ - return; } imq_lock(reply_mqueue); @@ -799,10 +788,9 @@ mach_msg_type_t exc_RetCode_proto = { */ kern_return_t -exception_parse_reply(kmsg) - ipc_kmsg_t kmsg; +exception_parse_reply(ipc_kmsg_t kmsg) { - register mig_reply_header_t *msg = + mig_reply_header_t *msg = (mig_reply_header_t *) &kmsg->ikm_header; kern_return_t kr; @@ -844,7 +832,7 @@ exception_parse_reply(kmsg) */ void -exception_raise_continue() +exception_raise_continue(void) { ipc_thread_t self = current_thread(); ipc_port_t reply_port = self->ith_port; @@ -876,10 +864,10 @@ exception_raise_continue() */ void -exception_raise_continue_slow(mr, kmsg, seqno) - mach_msg_return_t mr; - ipc_kmsg_t kmsg; - mach_port_seqno_t seqno; +exception_raise_continue_slow( + mach_msg_return_t mr, + ipc_kmsg_t kmsg, + mach_port_seqno_t seqno) { ipc_thread_t self = current_thread(); ipc_port_t reply_port = self->ith_port; @@ -934,7 +922,6 @@ exception_raise_continue_slow(mr, kmsg, (mr == MACH_RCV_PORT_DIED)) { thread_exception_return(); /*NOTREACHED*/ - return; } if (self->ith_exc != KERN_SUCCESS) { @@ -942,7 +929,6 @@ exception_raise_continue_slow(mr, kmsg, self->ith_exc_code, self->ith_exc_subcode); /*NOTREACHED*/ - return; } exception_no_server(); @@ -961,9 +947,9 @@ exception_raise_continue_slow(mr, kmsg, */ void -exception_raise_continue_fast(reply_port, kmsg) - ipc_port_t reply_port; - ipc_kmsg_t kmsg; +exception_raise_continue_fast( + ipc_port_t reply_port, + ipc_kmsg_t kmsg) { ipc_thread_t self = current_thread(); kern_return_t kr; @@ -992,7 +978,6 @@ exception_raise_continue_fast(reply_port if (kr == KERN_SUCCESS) { thread_exception_return(); /*NOTREACHED*/ - return; /* help for the compiler */ } if (self->ith_exc != KERN_SUCCESS) {