[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:
Michael Brown
2013-03-22 13:42:16 +00:00
parent 11ad0bafbf
commit 71cd508838
14 changed files with 286 additions and 2 deletions

View 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 */

View 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 */

View File

@@ -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 );

View 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 */