- thread_t cur_thread;
- boolean_t funnel_state_prev;
- int curfnl;
- funnel_t * curflock;
- funnel_t * oldflock;
- funnel_t * newflock;
- funnel_t * exist_funnel;
- extern int disable_funnel;
-
-
- if (disable_funnel)
- return(TRUE);
-
- if(oldfnl == newfnl) {
- panic("thread_funnel_switch: can't switch to same funnel");
- }
-
- if ((oldfnl != NETWORK_FUNNEL) && (oldfnl != KERNEL_FUNNEL))
- {
- panic("thread_funnel_switch: invalid oldfunnel");
- }
- if ((newfnl != NETWORK_FUNNEL) && (newfnl != KERNEL_FUNNEL))
- {
- panic("thread_funnel_switch: invalid oldfunnel");
- }
-
- if((curflock = thread_funnel_get()) == THR_FUNNEL_NULL) {
- panic("thread_funnel_switch: no funnel held");
- }
-
- cur_thread = current_thread();
-
- if ((oldfnl == NETWORK_FUNNEL) && (curflock != network_flock))
- panic("thread_funnel_switch: network funnel not held");
-
- if ((oldfnl == KERNEL_FUNNEL) && (curflock != kernel_flock))
- panic("thread_funnel_switch: network funnel not held");
-
- if(oldfnl == NETWORK_FUNNEL) {
- oldflock = network_flock;
- newflock = kernel_flock;
- } else {
- oldflock = kernel_flock;
- newflock = network_flock;
- }
- KERNEL_DEBUG(0x603242c | DBG_FUNC_NONE, oldflock, 1, 0, 0, 0);
- thread_funnel_set(oldflock, FALSE);
- KERNEL_DEBUG(0x6032428 | DBG_FUNC_NONE, newflock, 1, 0, 0, 0);
- thread_funnel_set(newflock, TRUE);
- KERNEL_DEBUG(0x6032434 | DBG_FUNC_NONE, newflock, 1, 0, 0, 0);
-
- return(TRUE);