This source file includes following definitions.
- machine_hang
- machine_restart
- machine_halt
- machine_power_off
1
2
3
4
5
6
7
8
9 #include <linux/kernel.h>
10 #include <linux/export.h>
11 #include <linux/pm.h>
12 #include <linux/types.h>
13 #include <linux/reboot.h>
14 #include <linux/delay.h>
15
16 #include <asm/compiler.h>
17 #include <asm/idle.h>
18 #include <asm/mipsregs.h>
19 #include <asm/reboot.h>
20
21
22
23
24
25
26 void (*_machine_restart)(char *command);
27 void (*_machine_halt)(void);
28 void (*pm_power_off)(void);
29
30 EXPORT_SYMBOL(pm_power_off);
31
32 static void machine_hang(void)
33 {
34
35
36
37
38
39 local_irq_disable();
40
41
42
43
44
45 clear_c0_status(ST0_IM);
46
47 while (true) {
48 if (cpu_has_mips_r) {
49
50
51
52
53
54 asm volatile(
55 ".set push\n\t"
56 ".set " MIPS_ISA_ARCH_LEVEL "\n\t"
57 "wait\n\t"
58 ".set pop");
59 } else if (cpu_wait) {
60
61
62
63
64
65 cpu_wait();
66 local_irq_disable();
67 } else {
68
69
70
71
72
73
74 }
75
76
77
78
79
80
81
82
83 if (cpu_has_counter)
84 write_c0_compare(0);
85 }
86 }
87
88 void machine_restart(char *command)
89 {
90 if (_machine_restart)
91 _machine_restart(command);
92
93 #ifdef CONFIG_SMP
94 preempt_disable();
95 smp_send_stop();
96 #endif
97 do_kernel_restart(command);
98 mdelay(1000);
99 pr_emerg("Reboot failed -- System halted\n");
100 machine_hang();
101 }
102
103 void machine_halt(void)
104 {
105 if (_machine_halt)
106 _machine_halt();
107
108 #ifdef CONFIG_SMP
109 preempt_disable();
110 smp_send_stop();
111 #endif
112 machine_hang();
113 }
114
115 void machine_power_off(void)
116 {
117 if (pm_power_off)
118 pm_power_off();
119
120 #ifdef CONFIG_SMP
121 preempt_disable();
122 smp_send_stop();
123 #endif
124 machine_hang();
125 }