[nap] Formalise the CPU sleeping API

This commit is contained in:
Michael Brown
2008-10-12 23:34:45 +01:00
parent 658c6dba59
commit c0835339d0
12 changed files with 138 additions and 20 deletions

View File

@@ -1,12 +0,0 @@
#include <realmode.h>
#include <bios.h>
/**************************************************************************
* Save power by halting the CPU until the next interrupt
**************************************************************************/
void cpu_nap ( void ) {
__asm__ __volatile__ ( REAL_CODE ( "sti\n\t"
"hlt\n\t"
"cli\n\t" ) : : );
}

View File

@@ -5,6 +5,4 @@
#define BDA_FBMS 0x0013
#define BDA_NUM_DRIVES 0x0075
extern void cpu_nap ( void );
#endif /* BIOS_H */

View File

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

View File

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

View File

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