Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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>
- Loading branch information
Showing
14 changed files
with
286 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright (C) 2010 Michael Brown <mbrown@fensystems.co.uk>. | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License as | ||
* published by the Free Software Foundation; either version 2 of the | ||
* License, or any later version. | ||
* | ||
* This program 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 | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
* 02110-1301, USA. | ||
*/ | ||
|
||
FILE_LICENCE ( GPL2_OR_LATER ); | ||
|
||
/** @file | ||
* | ||
* Standard PC-BIOS reboot mechanism | ||
* | ||
*/ | ||
|
||
#include <ipxe/reboot.h> | ||
#include <realmode.h> | ||
|
||
/** | ||
* Reboot system | ||
* | ||
*/ | ||
static void bios_reboot ( void ) { | ||
|
||
/* Jump to system reset vector */ | ||
__asm__ __volatile__ ( REAL_CODE ( "ljmp $0xf000, $0xfff0" ) : : ); | ||
} | ||
|
||
PROVIDE_REBOOT ( pcbios, reboot, bios_reboot ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#ifndef CONFIG_REBOOT_H | ||
#define CONFIG_REBOOT_H | ||
|
||
/** @file | ||
* | ||
* Reboot API configuration | ||
* | ||
*/ | ||
|
||
FILE_LICENCE ( GPL2_OR_LATER ); | ||
|
||
#include <config/defaults.h> | ||
|
||
#include <config/local/reboot.h> | ||
|
||
#endif /* CONFIG_REBOOT_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Copyright (C) 2013 Michael Brown <mbrown@fensystems.co.uk>. | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License as | ||
* published by the Free Software Foundation; either version 2 of the | ||
* License, or any later version. | ||
* | ||
* This program 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 | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
* 02110-1301, USA. | ||
*/ | ||
|
||
FILE_LICENCE ( GPL2_OR_LATER ); | ||
|
||
/** | ||
* @file | ||
* | ||
* Null reboot mechanism | ||
* | ||
*/ | ||
|
||
#include <stdio.h> | ||
#include <ipxe/reboot.h> | ||
|
||
/** | ||
* Reboot system | ||
* | ||
*/ | ||
static void null_reboot ( void ) { | ||
|
||
printf ( "Cannot reboot; not implemented\n" ); | ||
while ( 1 ) {} | ||
} | ||
|
||
PROVIDE_REBOOT ( null, reboot, null_reboot ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef _IPXE_EFI_REBOOT_H | ||
#define _IPXE_EFI_REBOOT_H | ||
|
||
/** @file | ||
* | ||
* iPXE reboot API for EFI | ||
* | ||
*/ | ||
|
||
FILE_LICENCE ( GPL2_OR_LATER ); | ||
|
||
#ifdef REBOOT_EFI | ||
#define REBOOT_PREFIX_efi | ||
#else | ||
#define REBOOT_PREFIX_efi __efi_ | ||
#endif | ||
|
||
#endif /* _IPXE_EFI_REBOOT_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef _IPXE_NULL_REBOOT_H | ||
#define _IPXE_NULL_REBOOT_H | ||
|
||
/** @file | ||
* | ||
* iPXE do-nothing reboot API | ||
* | ||
*/ | ||
|
||
FILE_LICENCE ( GPL2_OR_LATER ); | ||
|
||
#ifdef REBOOT_NULL | ||
#define REBOOT_PREFIX_null | ||
#else | ||
#define REBOOT_PREFIX_null __null_ | ||
#endif | ||
|
||
#endif /* _IPXE_NULL_REBOOT_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
#ifndef _IPXE_REBOOT_H | ||
#define _IPXE_REBOOT_H | ||
|
||
/** @file | ||
* | ||
* iPXE reboot API | ||
* | ||
*/ | ||
|
||
FILE_LICENCE ( GPL2_OR_LATER ); | ||
|
||
#include <ipxe/api.h> | ||
#include <config/reboot.h> | ||
|
||
/** | ||
* Calculate static inline reboot API function name | ||
* | ||
* @v _prefix Subsystem prefix | ||
* @v _api_func API function | ||
* @ret _subsys_func Subsystem API function | ||
*/ | ||
#define REBOOT_INLINE( _subsys, _api_func ) \ | ||
SINGLE_API_INLINE ( REBOOT_PREFIX_ ## _subsys, _api_func ) | ||
|
||
/** | ||
* Provide an reboot API implementation | ||
* | ||
* @v _prefix Subsystem prefix | ||
* @v _api_func API function | ||
* @v _func Implementing function | ||
*/ | ||
#define PROVIDE_REBOOT( _subsys, _api_func, _func ) \ | ||
PROVIDE_SINGLE_API ( REBOOT_PREFIX_ ## _subsys, _api_func, _func ) | ||
|
||
/** | ||
* Provide a static inline reboot API implementation | ||
* | ||
* @v _prefix Subsystem prefix | ||
* @v _api_func API function | ||
*/ | ||
#define PROVIDE_REBOOT_INLINE( _subsys, _api_func ) \ | ||
PROVIDE_SINGLE_API_INLINE ( REBOOT_PREFIX_ ## _subsys, _api_func ) | ||
|
||
/* Include all architecture-independent reboot API headers */ | ||
#include <ipxe/null_reboot.h> | ||
#include <ipxe/efi/efi_reboot.h> | ||
|
||
/* Include all architecture-dependent reboot API headers */ | ||
#include <bits/reboot.h> | ||
|
||
/** | ||
* Reboot system | ||
* | ||
*/ | ||
void reboot ( void ); | ||
|
||
#endif /* _IPXE_REBOOT_H */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/* | ||
* Copyright (C) 2013 Michael Brown <mbrown@fensystems.co.uk>. | ||
* | ||
* This program is free software; you can redistribute it and/or | ||
* modify it under the terms of the GNU General Public License as | ||
* published by the Free Software Foundation; either version 2 of the | ||
* License, or any later version. | ||
* | ||
* This program 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 | ||
* General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Public License | ||
* along with this program; if not, write to the Free Software | ||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA | ||
* 02110-1301, USA. | ||
*/ | ||
|
||
FILE_LICENCE ( GPL2_OR_LATER ); | ||
|
||
/** | ||
* @file | ||
* | ||
* EFI reboot mechanism | ||
* | ||
*/ | ||
|
||
#include <ipxe/efi/efi.h> | ||
#include <ipxe/reboot.h> | ||
|
||
/** | ||
* Reboot system | ||
* | ||
*/ | ||
static void efi_reboot ( void ) { | ||
EFI_RUNTIME_SERVICES *rs = efi_systab->RuntimeServices; | ||
|
||
/* Use runtime services to reset system */ | ||
rs->ResetSystem ( EfiResetCold, 0, 0, NULL ); | ||
} | ||
|
||
PROVIDE_REBOOT ( efi, reboot, efi_reboot ); |