reboot.c 1.2 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
/* 
 * Copyright (C) 2000 Jeff Dike (jdike@karaya.com)
 * Licensed under the GPL
 */

#include "linux/sched.h"
#include "user_util.h"
#include "kern_util.h"
#include "kern.h"
#include "os.h"

static void kill_off_processes(void)
{
	struct task_struct *p;
	int me;

	me = os_getpid();
	for_each_task(p){
		if(p->thread.extern_pid != me) 
			os_kill_process(p->thread.extern_pid);
	}
	if(init_task.thread.extern_pid != me) 
		os_kill_process(init_task.thread.extern_pid);
}

void uml_cleanup(void)
{
	kill_off_processes();
	do_uml_exitcalls();
}

void machine_restart(char * __unused)
{
	do_uml_exitcalls();
	kill_off_processes();
	tracing_reboot();
	os_kill_process(os_getpid());
}

void machine_power_off(void)
{
	do_uml_exitcalls();
	kill_off_processes();
	tracing_halt();
	os_kill_process(os_getpid());
}

void machine_halt(void)
{
	machine_power_off();
}

/*
 * Overrides for Emacs so that we follow Linus's tabbing style.
 * Emacs will notice this stuff at the end of the file and automatically
 * adjust the settings for this buffer only.  This must remain at the end
 * of the file.
 * ---------------------------------------------------------------------------
 * Local variables:
 * c-file-style: "linux"
 * End:
 */