API file template

The content of the AR_API.h file for the 80x86 CPUs is shown below. This kind of file should provide definitions, types and functions as in the given example. Only one modification should be performed by a programmer when defining a new port file. The value of the AR_TICKS_PER_SECOND constant should be specified and the TTaskContext structure should be filled with mandatory fields, to allow context switching. For more details, please look into the detailed description of specified definition, type or function.

/****************************************************************************
 *
 *  AR_API.h - Architecture API
 *  Version 1.00
 *
 *  Copyright 2010 by SpaceShadow
 *  All rights reserved!
 *
 ***************************************************************************/


/***************************************************************************/
#ifndef AR_API_H
#define AR_API_H
/***************************************************************************/


/****************************************************************************
 *
 *  Includes
 *
 ***************************************************************************/

#include "Config.h"
#include "AR_Types.h"


/****************************************************************************
 *
 *  Default configuration
 *
 ***************************************************************************/

/* arDeinit function is enabled at default */
#ifndef AR_USE_DEINIT_FUNC  #define AR_USE_DEINIT_FUNC            1
#endif


/****************************************************************************
 *
 *  Definitions
 *
 ***************************************************************************/

/* Number of ticks per every second for value returned by arGetTickCount */
#define AR_TICKS_PER_SECOND             1000UL


/****************************************************************************
 *
 *  Type definitions
 *
 ***************************************************************************/

/* Task context structure */
struct TTaskContext{
  PVOID TaskContext;
  PVOID StackAddress;
};

/* Function callbacks */
typedef void (CALLBACK *TPreemptiveProc)(struct TTaskContext  FAR *TaskContext);
typedef void (CALLBACK *TTaskStartupProc)(void);


/****************************************************************************
 *
 *  Functions
 *
 ***************************************************************************/

#ifdef __cplusplus
  extern "C" {
#endif

  BOOL arInit(void);

  #if AR_USE_DEINIT_FUNC    void arDeinit(void);
  #endif

  BOOL arLock(void);
  void arRestore(BOOL PreviousLockState);

  TIME arGetTickCount(void);

  #if OS_USED
    BOOL arSetPreemptiveHandler(TPreemptiveProc PreemptiveProc,
      SIZE StackSize);
    void arYield(void);

    BOOL arCreateTaskContext(struct TTaskContext FAR *TaskContext,
      TTaskStartupProc TaskStartupProc, SIZE StackSize);
    BOOL arReleaseTaskContext(struct TTaskContext FAR *TaskContext);

    void arSavePower(void);

  #endif

#ifdef __cplusplus
  };
#endif


/***************************************************************************/
#endif /* AR_API_H */
/***************************************************************************/
SpaceShadow documentation