x86_reboot.h
2.59 KB
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
/*
* Copyright (C) 2014 René Kijewski <rene.kijewski@fu-berlin.de>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
* Rebooting x86 boards.
*
* @ingroup x86
* @{
* @file
* @author René Kijewski <rene.kijewski@fu-berlin.de>
*/
#ifndef X86_REBOOT_H
#define X86_REBOOT_H
#include <stdbool.h>
#include "kernel_defines.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief Prototype for a x86 reboot function.
*
* The function may return, then a naive reboot is tried.
* It is safe to call x86_kbc_reboot() inside the handler,
* then a naive reboot will be done immediately.
*
* The handler is called with interrupts disabled.
* You should keep the interrupts disabled and use busy loops.
*/
typedef void (*x86_reboot_t)(void);
/**
* @brief Reboots the system.
*
* First the function supplied if x86_set_reboot_fun() is called (iff applies).
* Then a reboot using the keyboard controller is tried.
* And if everything fails, a tripple fault is provoked.
*/
void NORETURN x86_kbc_reboot(void);
/**
* @brief Set specialized reboot function.
*
* This function should be utilized by the ACPI subsystem.
*/
void x86_set_reboot_fun(x86_reboot_t fun);
/**
* @brief Loads an empty interrupt descriptor table.
*
* Any interrupt that will occur causes a tripple fault, i.e. a reboot.
* Must be called with interrupts disabled.
*/
void x86_load_empty_idt(void);
/**
* @brief Prototype of the board specific x86 shutdown function.
* @returns `false` if the shutdown could not be scheduled.
*/
typedef bool (*x86_shutdown_t)(void);
/**
* @brief Shutdown and power off
* @details May return. The shutdown only gets scheduled.
* @returns `false` if shutting down is not possible at this moment.
*/
bool x86_shutdown(void);
/**
* @brief Function to call on x86_shutdown()
*/
void x86_set_shutdown_fun(x86_shutdown_t fun);
#ifdef __cplusplus
}
#endif
#endif /* X86_REBOOT_H */
/** @} */