Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[nap] Formalise the CPU sleeping API
- Loading branch information
Michael Brown
committed
Oct 12, 2008
1 parent
658c6db
commit c083533
Showing
12 changed files
with
138 additions
and
20 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
|
@@ -5,6 +5,4 @@ | |
#define BDA_FBMS 0x0013 | ||
#define BDA_NUM_DRIVES 0x0075 | ||
|
||
extern void cpu_nap ( void ); | ||
|
||
#endif /* BIOS_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,12 @@ | ||
#ifndef _BITS_NAP_H | ||
#define _BITS_NAP_H | ||
|
||
/** @file | ||
* | ||
* i386-specific CPU sleeping API implementations | ||
* | ||
*/ | ||
|
||
#include <gpxe/bios_nap.h> | ||
|
||
#endif /* _BITS_MAP_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,16 @@ | ||
#ifndef _GPXE_BIOS_NAP_H | ||
#define _GPXE_BIOS_NAP_H | ||
|
||
/** @file | ||
* | ||
* BIOS CPU sleeping | ||
* | ||
*/ | ||
|
||
#ifdef NAP_PCBIOS | ||
#define NAP_PREFIX_pcbios | ||
#else | ||
#define NAP_PREFIX_pcbios __pcbios_ | ||
#endif | ||
|
||
#endif /* _GPXE_BIOS_NAP_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,14 @@ | ||
#include <gpxe/nap.h> | ||
#include <realmode.h> | ||
|
||
/** | ||
* Save power by halting the CPU until the next interrupt | ||
* | ||
*/ | ||
static void bios_cpu_nap ( void ) { | ||
__asm__ __volatile__ ( REAL_CODE ( "sti\n\t" | ||
"hlt\n\t" | ||
"cli\n\t" ) : : ); | ||
} | ||
|
||
PROVIDE_NAP ( pcbios, cpu_nap, bios_cpu_nap ); |
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,15 @@ | ||
#ifndef CONFIG_NAP_H | ||
#define CONFIG_NAP_H | ||
|
||
/** @file | ||
* | ||
* CPU sleeping | ||
* | ||
*/ | ||
|
||
#include <config/defaults.h> | ||
|
||
//#undef NAP_PCBIOS | ||
//#define NAP_NULL | ||
|
||
#endif /* CONFIG_NAP_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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#include <gpxe/nap.h> | ||
|
||
PROVIDE_NAP_INLINE ( null, cpu_nap ); |
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,54 @@ | ||
#ifndef _GPXE_NAP_H | ||
#define _GPXE_NAP_H | ||
|
||
/** @file | ||
* | ||
* CPU sleeping | ||
* | ||
*/ | ||
|
||
#include <gpxe/api.h> | ||
#include <config/nap.h> | ||
|
||
/** | ||
* Calculate static inline CPU sleeping API function name | ||
* | ||
* @v _prefix Subsystem prefix | ||
* @v _api_func API function | ||
* @ret _subsys_func Subsystem API function | ||
*/ | ||
#define NAP_INLINE( _subsys, _api_func ) \ | ||
SINGLE_API_INLINE ( NAP_PREFIX_ ## _subsys, _api_func ) | ||
|
||
/** | ||
* Provide an CPU sleeping API implementation | ||
* | ||
* @v _prefix Subsystem prefix | ||
* @v _api_func API function | ||
* @v _func Implementing function | ||
*/ | ||
#define PROVIDE_NAP( _subsys, _api_func, _func ) \ | ||
PROVIDE_SINGLE_API ( NAP_PREFIX_ ## _subsys, _api_func, _func ) | ||
|
||
/** | ||
* Provide a static inline CPU sleeping API implementation | ||
* | ||
* @v _prefix Subsystem prefix | ||
* @v _api_func API function | ||
*/ | ||
#define PROVIDE_NAP_INLINE( _subsys, _api_func ) \ | ||
PROVIDE_SINGLE_API_INLINE ( NAP_PREFIX_ ## _subsys, _api_func ) | ||
|
||
/* Include all architecture-independent I/O API headers */ | ||
#include <gpxe/null_nap.h> | ||
|
||
/* Include all architecture-dependent I/O API headers */ | ||
#include <bits/nap.h> | ||
|
||
/** | ||
* Sleep until next CPU interrupt | ||
* | ||
*/ | ||
void cpu_nap ( void ); | ||
|
||
#endif /* _GPXE_NAP_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,21 @@ | ||
#ifndef _GPXE_NULL_NAP_H | ||
#define _GPXE_NULL_NAP_H | ||
|
||
/** @file | ||
* | ||
* Null CPU sleeping | ||
* | ||
*/ | ||
|
||
#ifdef NAP_NULL | ||
#define NAP_PREFIX_null | ||
#else | ||
#define NAP_PREFIX_null __null_ | ||
#endif | ||
|
||
static inline __always_inline void | ||
NAP_INLINE ( null, cpu_nap ) ( void ) { | ||
/* Do nothing */ | ||
} | ||
|
||
#endif /* _GPXE_NULL_NAP_H */ |