xref: /linux-6.15/arch/um/kernel/reboot.c (revision 77bf4400)
1 /*
2  * Copyright (C) 2000, 2002 Jeff Dike ([email protected])
3  * Licensed under the GPL
4  */
5 
6 #include "linux/module.h"
7 #include "linux/sched.h"
8 #include "asm/smp.h"
9 #include "kern_util.h"
10 #include "kern.h"
11 #include "os.h"
12 #include "skas.h"
13 
14 void (*pm_power_off)(void);
15 
16 static void kill_off_processes(void)
17 {
18 	if(proc_mm)
19 		/*
20 		 * FIXME: need to loop over userspace_pids
21 		 */
22 		os_kill_ptraced_process(userspace_pid[0], 1);
23 	else {
24 		struct task_struct *p;
25 		int pid, me;
26 
27 		me = os_getpid();
28 		for_each_process(p){
29 			if(p->mm == NULL)
30 				continue;
31 
32 			pid = p->mm->context.skas.id.u.pid;
33 			os_kill_ptraced_process(pid, 1);
34 		}
35 	}
36 }
37 
38 void uml_cleanup(void)
39 {
40         kmalloc_ok = 0;
41 	do_uml_exitcalls();
42 	kill_off_processes();
43 }
44 
45 void machine_restart(char * __unused)
46 {
47         uml_cleanup();
48 	reboot_skas();
49 }
50 
51 void machine_power_off(void)
52 {
53         uml_cleanup();
54 	halt_skas();
55 }
56 
57 void machine_halt(void)
58 {
59 	machine_power_off();
60 }
61