/*
 * ======== load.h ========
 *
 *! Revision History
 *! ================
 *! 28-Dec -2006 bf	modified for C64+ with time stamp counter.
 *! 15-June-2001 kw	original.
 */

/*
 * The LOAD module provides an API that returns the
 * current CPU load.  The CPU load is averaged over a period of time as
 * specified by the 'loadWindow'.
 * 
 * You must do the following to use LOAD_getcpuload()
 * 
 * (1) add a IDL object to the BIOS configuration and set the function
 *     to '_LOAD_idlefxn' (don't forget the leading underscore!).
 * or call LOAD_idlefxn anywhere the CPU should be idle
 * 
 * (2) enable time stamp counter of C64+
 * 
 * (3) call 'LOAD_init()' from your application's main() program
 * 
 * (4) call 'LOAD_getcpuload()' to return the CPU load as averaged over
 *     the pre-defined window.  This window can be changed by modifying
 *     the 'loadWindow' value in this file and recompiling load.c.
 * 
 * (5) compile load.c and link it with your application.
 * 
 * 
 * CAVEATS:
 * 
 * (1) This implementation self-calibrates the shortest path through the
 *     IDL loop.  It does this by keeping track of the shortest time between 
 *     invocations of 'LOAD_idlefxn'.  This relies on the fact that the
 *     IDL loop will execute at least 2 times in a row w/o being interrupted!
 *     If this is a problem for your application (unlikely), you can measure
 *     the shortest path through the IDL loop using the profiler and set
 *     'minloop' to this time.  
 */ 

/*
 *  return CPU load in last measured window
 */
extern Int32 LOAD_getCpuLoadInLastWindow(void);

/*
 *  Calculate the CPU load from last memsurement trigger point 
 * to current measurement trigger point 
 */
extern Int32 LOAD_getCpuLoadFromLastTime(void);

/*
 * LOAD_idlefxn() should be configured and called from a DSP/BIOS IDL object.
 * Make sure that 'Include in CPU load calibration' is checked (TRUE).
 * If DSP/BIOS is not used, you should call this function anywhere the CPU should be idle
 */
extern void LOAD_idlefxn(void);

/*
 * LOAD_init() must be called from application's main() function.
 * 	CSL_tscEnable() should be call before use any of LOAD funtions.
 */
extern void LOAD_init(void);

/*
 * set measure window size
 */
extern void LOAD_setWindowSize(Uint32 windowSize);
