mirror of
https://github.com/ipxe/ipxe
synced 2025-12-26 17:42:47 +03:00
[efi] Add "reboot" command for EFI
Abstract out the ability to reboot the system to a separate reboot() function (with platform-specific implementations), add an EFI implementation, and make the existing "reboot" command available under EFI. Signed-off-by: Michael Brown <mcb30@ipxe.org>
This commit is contained in:
14
src/arch/i386/include/bits/reboot.h
Normal file
14
src/arch/i386/include/bits/reboot.h
Normal file
@@ -0,0 +1,14 @@
|
||||
#ifndef _BITS_REBOOT_H
|
||||
#define _BITS_REBOOT_H
|
||||
|
||||
/** @file
|
||||
*
|
||||
* i386-specific reboot API implementations
|
||||
*
|
||||
*/
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER );
|
||||
|
||||
#include <ipxe/bios_reboot.h>
|
||||
|
||||
#endif /* _BITS_REBOOT_H */
|
||||
18
src/arch/i386/include/ipxe/bios_reboot.h
Normal file
18
src/arch/i386/include/ipxe/bios_reboot.h
Normal file
@@ -0,0 +1,18 @@
|
||||
#ifndef _IPXE_BIOS_REBOOT_H
|
||||
#define _IPXE_BIOS_REBOOT_H
|
||||
|
||||
/** @file
|
||||
*
|
||||
* Standard PC-BIOS reboot mechanism
|
||||
*
|
||||
*/
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER );
|
||||
|
||||
#ifdef REBOOT_PCBIOS
|
||||
#define REBOOT_PREFIX_pcbios
|
||||
#else
|
||||
#define REBOOT_PREFIX_pcbios __pcbios_
|
||||
#endif
|
||||
|
||||
#endif /* _IPXE_BIOS_REBOOT_H */
|
||||
@@ -17,51 +17,25 @@
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
#include <realmode.h>
|
||||
#include <ipxe/command.h>
|
||||
#include <ipxe/parseopt.h>
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER );
|
||||
|
||||
/** @file
|
||||
*
|
||||
* Reboot command
|
||||
* Standard PC-BIOS reboot mechanism
|
||||
*
|
||||
*/
|
||||
|
||||
/** "reboot" options */
|
||||
struct reboot_options {};
|
||||
|
||||
/** "reboot" option list */
|
||||
static struct option_descriptor reboot_opts[] = {};
|
||||
|
||||
/** "reboot" command descriptor */
|
||||
static struct command_descriptor reboot_cmd =
|
||||
COMMAND_DESC ( struct reboot_options, reboot_opts, 0, 0, "" );
|
||||
#include <ipxe/reboot.h>
|
||||
#include <realmode.h>
|
||||
|
||||
/**
|
||||
* The "reboot" command
|
||||
* Reboot system
|
||||
*
|
||||
* @v argc Argument count
|
||||
* @v argv Argument list
|
||||
* @ret rc Return status code
|
||||
*/
|
||||
static int reboot_exec ( int argc, char **argv ) {
|
||||
struct reboot_options opts;
|
||||
int rc;
|
||||
static void bios_reboot ( void ) {
|
||||
|
||||
/* Parse options */
|
||||
if ( ( rc = parse_options ( argc, argv, &reboot_cmd, &opts ) ) != 0 )
|
||||
return rc;
|
||||
|
||||
/* Reboot system */
|
||||
/* Jump to system reset vector */
|
||||
__asm__ __volatile__ ( REAL_CODE ( "ljmp $0xf000, $0xfff0" ) : : );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** "reboot" command */
|
||||
struct command reboot_command __command = {
|
||||
.name = "reboot",
|
||||
.exec = reboot_exec,
|
||||
};
|
||||
PROVIDE_REBOOT ( pcbios, reboot, bios_reboot );
|
||||
12
src/arch/x86_64/include/bits/reboot.h
Normal file
12
src/arch/x86_64/include/bits/reboot.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#ifndef _BITS_REBOOT_H
|
||||
#define _BITS_REBOOT_H
|
||||
|
||||
/** @file
|
||||
*
|
||||
* x86_64-specific reboot API implementations
|
||||
*
|
||||
*/
|
||||
|
||||
FILE_LICENCE ( GPL2_OR_LATER );
|
||||
|
||||
#endif /* _BITS_REBOOT_H */
|
||||
Reference in New Issue
Block a user