AquilaOS documentation
How it works, and its code
Toggle main menu visibility
Loading...
Searching...
No Matches
reboot.c
Go to the documentation of this file.
1
8
9
#include <
core/system.h
>
10
#include <
core/arch.h
>
11
#include <
sys/proc.h
>
12
#include <
sys/signal.h
>
13
#include <
sys/reboot.h
>
14
#include <
dev/dev.h
>
15
16
#include <aquila/errno.h>
17
18
static
int
cad_restarts
= 1;
19
29
int
kernel_reboot
(
unsigned
cmd)
30
{
31
/* nothing may be left in the disks' write caches */
32
if
(cmd == RB_AUTOBOOT || cmd == RB_HALT_SYSTEM || cmd == RB_POWER_OFF)
33
kdev_sync
();
34
35
switch
(cmd) {
36
case
RB_AUTOBOOT:
37
printk
(
"kernel: restarting system\n"
);
38
arch_reboot
();
39
printk
(
"kernel: restart failed, halting\n"
);
40
arch_halt
();
41
case
RB_HALT_SYSTEM:
42
printk
(
"kernel: system halted\n"
);
43
arch_halt
();
44
case
RB_POWER_OFF:
45
printk
(
"kernel: power down\n"
);
46
arch_poweroff
();
47
case
RB_ENABLE_CAD:
48
cad_restarts
= 1;
49
return
0;
50
case
RB_DISABLE_CAD:
51
cad_restarts
= 0;
52
return
0;
53
}
54
55
return
-EINVAL;
56
}
57
62
void
kernel_ctrlaltdel
(
void
)
63
{
64
/* restart right away, as a reset would: writing out the caches would
65
* wait for the disk, which an interrupt can't do */
66
if
(
cad_restarts
) {
67
printk
(
"kernel: restarting system\n"
);
68
arch_reboot
();
69
return
;
70
}
71
72
struct
proc
*init =
proc_pid_find
(1);
73
74
if
(init)
75
signal_proc_send
(init, SIGINT);
76
}
dev.h
arch.h
system.h
kdev_sync
int kdev_sync(void)
Writes what the block cache holds that was written, and what the block devices hold in their write ca...
Definition
kdev.c:587
printk
int printk(const char *fmt,...)
Writes a kernel message, to the message buffer and the consoles.
Definition
printk.c:249
proc.h
proc_pid_find
struct proc * proc_pid_find(pid_t pid)
Finds a process by its ID.
Definition
proc.c:179
arch_reboot
void arch_reboot(void)
Restarts the machine.
Definition
psci.c:25
arch_halt
void arch_halt(void)
Stops the CPU for good, with interrupts off.
Definition
psci.c:38
arch_poweroff
void arch_poweroff(void)
Powers the machine off, or halts it if it can't be powered off.
Definition
psci.c:31
reboot.h
kernel_ctrlaltdel
void kernel_ctrlaltdel(void)
Handles Ctrl+Alt+Del from the keyboard, possibly in an interrupt: it restarts the machine,...
Definition
reboot.c:62
kernel_reboot
int kernel_reboot(unsigned cmd)
Carries out a reboot() command.
Definition
reboot.c:29
signal.h
signal_proc_send
int signal_proc_send(struct proc *proc, int signal)
Sends a signal to a process.
Definition
signal.c:310
proc
A process.
Definition
proc.h:75
cad_restarts
static int cad_restarts
Definition
reboot.c:18
kernel
sys
reboot.c
Generated by
1.18.0