- else
- halt_all_cpus(!(options & HOST_REBOOT_HALT));
-
- return (KERN_SUCCESS);
-}
-
-/*
- * processor_request_action:
- *
- * Common internals of processor_assign and processor_shutdown.
- * If new_pset is null, this is a shutdown, else it's an assign
- * and caller must donate a reference.
- * For assign operations, it returns an old pset that must be deallocated
- * if it's not NULL.
- * For shutdown operations, it always returns PROCESSOR_SET_NULL.
- */
-processor_set_t
-processor_request_action(
- processor_t processor,
- processor_set_t new_pset)
-{
- processor_set_t pset, old_next_pset;
-
- /*
- * Processor must be in a processor set. Must lock its idle lock to
- * get at processor state.
- */
- pset = processor->processor_set;
- simple_lock(&pset->idle_lock);
-
- /*
- * If the processor is dispatching, let it finish - it will set its
- * state to running very soon.
- */
- while (*(volatile int *)&processor->state == PROCESSOR_DISPATCHING) {
- simple_unlock(&pset->idle_lock);
- simple_lock(&pset->idle_lock);
- }
-
- /*
- * Now lock the action queue and do the dirty work.
- */
- simple_lock(&processor_action_lock);
-
- switch (processor->state) {
-
- case PROCESSOR_IDLE:
- /*
- * Remove from idle queue.
- */
- queue_remove(&pset->idle_queue, processor,
- processor_t, processor_queue);
- pset->idle_count--;
-
- /* fall through ... */
- case PROCESSOR_RUNNING:
- /*
- * Put it on the action queue.
- */
- queue_enter(&processor_action_queue, processor,
- processor_t,processor_queue);
-
- /* Fall through ... */
- case PROCESSOR_ASSIGN:
- /*
- * And ask the action_thread to do the work.
- */
-
- if (new_pset == PROCESSOR_SET_NULL) {
- processor->state = PROCESSOR_SHUTDOWN;
- old_next_pset = PROCESSOR_SET_NULL;
- } else {
- processor->state = PROCESSOR_ASSIGN;
- old_next_pset = processor->processor_set_next;
- processor->processor_set_next = new_pset;
- }
- break;
-
- default:
- printf("state: %d\n", processor->state);
- panic("processor_request_action: bad state");
- }