⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 stos.h

📁 stos Linux 源码示范程序。 可以移植到其他平台
💻 H
📖 第 1 页 / 共 2 页
字号:
/*****************************************************************************

File name   :  stos.h

Description :  Operating system independence file.


COPYRIGHT (C) STMicroelectronics 2005.

Date               Modification                                          Name
----               ------------                                          ----
04/05/2005         Added support for semaphore calls                     DG
05/01/2005         Created                                               MH

*****************************************************************************/

/*#define STOS_CHECK_PARAMETERS*/

/* Define to prevent recursive inclusion */
#if !defined __STOS_H
#define __STOS_H

/* Includes ----------------------------------------------------------------- */
#include "stddefs.h"

#if !defined __STLITE_H                  /* This part below was taken from stlite.h */

#if defined (ST_OS20)
    #include <interrup.h>
    #include <kernel.h>
    #include <message.h>
    #include <ostime.h>
    #include <partitio.h>
    #include <semaphor.h>
    #include <task.h>
#endif

#if defined (ST_OS21)
    #include <os21.h>
    #include <time.h>
    #if defined (ARCHITECTURE_ST40)
        #include <os21/st40.h>
    #endif /*#if defined ARCHITECTURE_ST40*/
#endif

#endif  /* #if! defined __STLITE_H */    /* This part above was taken from stlite.h */

#ifdef ST_OSLINUX
#include "linuxwrapper.h"
#endif

/* C++ support */
#if defined __cplusplus
    extern "C" {
#endif

/* Types ------------------------------------------------------------------- */
#if defined (ST_OS21)
    typedef void *  tdesc_t;
#endif

/* Defines ----------------------------------------------------------------- */
#if !defined __OS_20TO21_MAP_H      /* This part below was taken from os_20to21_map.h */
#if defined(ST_OS20)
    #define task_flags_no_min_stack_size    0   /* Should be unused: only for compilation */

    #define osclock_t  clock_t
#elif defined(ST_OS21)
	#define semaphore_create_fifo_timeout(count) semaphore_create_fifo(count)
	#define semaphore_create_priority_timeout(count) semaphore_create_priority(count)
	#define interrupt_install(a,b,c,d) interrupt_install(interrupt_handle(a),(interrupt_handler_t )c,d)
	#define interrupt_install_shared(a,b,c,d) interrupt_install_shared(interrupt_handle(a),(interrupt_handler_t )c,d)
	#define interrupt_uninstall(a,b) interrupt_uninstall(interrupt_handle(a))
	#define interrupt_enable_number(number) interrupt_enable(interrupt_handle(number))
	#define interrupt_disable_number(number) interrupt_disable(interrupt_handle(number))
	#define interrupt_clear_number(number) interrupt_clear(interrupt_handle(number))
	#define interrupt_raise_number(number) interrupt_raise(interrupt_handle(number))
	#define task_flags_high_priority_process    0 /* does not exist for ST40 */
	#define clock_t  osclock_t

#elif defined(ST_OSLINUX)
    #define task_flags_no_min_stack_size        0   /* Should be unused: only for compilation */
    #define task_flags_suspended                1   /* Should be unused: only for compilation */
    #define task_flags_high_priority_process    2   /* Should be unused: only for compilation */

#endif  /* ST_OS21 */
#endif  /* #if ! defined __OS_20TO21_MAP_H */

typedef int STOS_Error_t;
#if defined(ST_OSLINUX)
    #define STOS_SUCCESS    (0)
    #define STOS_FAILURE    (-1)

#elif defined(ST_OS20)
    #define STOS_SUCCESS    (0)
    #define STOS_FAILURE    (-1)

#elif defined(ST_OS21)
    #define STOS_SUCCESS    (OS21_SUCCESS)
    #define STOS_FAILURE    (OS21_FAILURE)

#endif

/* Time management */
#if defined(ST_OSLINUX)
#if defined(MODULE)
/* LM: In kernel mode, jiffies is the right clock definition but may
introduce warnings during compilations as long as function are not
ported to stos.c. jiffies are unsigned long */
    #define STOS_Clock_t            unsigned long
#else
    #define STOS_Clock_t            clock_t
#endif

#elif defined(ST_OS20)
    #define STOS_Clock_t            clock_t

#elif defined(ST_OS21)
    #define STOS_Clock_t            osclock_t

#endif


/* Mutex management */
#if defined(ST_OSLINUX)
typedef semaphore_t         STOS_Mutex_t;

#elif defined(ST_OS21)
typedef mutex_t             STOS_Mutex_t;

#elif defined(ST_OS20)
typedef semaphore_t         STOS_Mutex_t;

#endif


/* Message Queue management */
typedef message_queue_t     STOS_MessageQueue_t;



#if !defined __STLITE_H                /* This part below was taken from stlite.h */

#if defined (ARCHITECTURE_ST20)
    /* fix for DCU 1.8.1 - different number of parameters */
    #if OS20_VERSION_MAJOR >= 2 && OS20_VERSION_MINOR >= 7
      #define interrupt_status(a,b) interrupt_status(a,b,0)
    #endif
#endif  /* ARCHITECTURE_ST20 */

/* The following is required for (legacy) PTI and TestTool compatibility,
  which require the identifiers boolean, true, and false */
#if defined __cplusplus
/* true and false are already defined. Define the type the same size
  as under C compilation below (DDTS 18417) */
    typedef int boolean;
    #else
        #if !defined(true) && !defined(false)
            typedef enum {false = 0, true = 1} boolean;
        #endif
#endif  /* __cplusplus */

/***********************************
 Toolset compatibility issues
***********************************/
/* ST20/ST40 __inline compatibility */
#if !defined __inline
    #if defined (ARCHITECTURE_ST40)
        #define __inline __inline__
    #endif
#endif

#endif  /* #if !defined __STLITE_H */    /* This part above was taken from stlite.h */



/* Exported Functions ------------------------------------------------------- */
ST_Revision_t   STOS_GetRevision(void);


/* Tasks related functions */
ST_ErrorCode_t  STOS_TaskCreate (void (*Function)(void* Param),
                                       void* Param,
                                       partition_t* StackPartition,
                                       size_t StackSize,
                                       void** Stack,
                                       partition_t* TaskPartition,
                                       task_t** Task,
                                       tdesc_t* Tdesc,
                                       int Priority,
                                       const char* Name,
                                       task_flags_t Flags );
ST_ErrorCode_t  STOS_TaskWait   ( task_t** Task, const STOS_Clock_t * TimeOutValue_p );
ST_ErrorCode_t  STOS_TaskEnter  ( void * Param );
ST_ErrorCode_t  STOS_TaskExit   ( void * Param );
ST_ErrorCode_t  STOS_TaskDelete (task_t* Task,
                                 partition_t* TaskPartition,
                                 void* Stack,
                                 partition_t* StackPartition );


/* Semaphores related functions */
semaphore_t * STOS_SemaphoreCreateFifo           (partition_t * Partition_p, const int InitialValue);
semaphore_t * STOS_SemaphoreCreateFifoTimeOut    (partition_t * Partition_p, const int InitialValue);
semaphore_t * STOS_SemaphoreCreatePriority       (partition_t * Partition_p, const int InitialValue);
semaphore_t * STOS_SemaphoreCreatePriorityTimeOut(partition_t * Partition_p, const int InitialValue);
int  STOS_SemaphoreDelete(partition_t * Partition_p, semaphore_t * Semaphore_p);
void STOS_SemaphoreSignal(semaphore_t * Semaphore_p);
int  STOS_SemaphoreWait(semaphore_t * Semaphore_p);
int  STOS_SemaphoreWaitTimeOut(semaphore_t * Semaphore_p, const STOS_Clock_t * TimeOutValue);


/* Uncached memory access functions */
void    STOS_memsetUncached(const void* const PhysicalAddress, U8 Pattern, U32 Size);
void    STOS_memcpyUncachedToUncached(const void* const uncached_dest, const void* const uncached_src, U32 Size);
void    STOS_memcpyCachedToUncached(const void* const uncached_dest, const void* const uncached_src, U32 Size);
void    STOS_memcpyUncachedToCached(void* const uncached_dest, const void* const uncached_src, U32 Size);
#define STOS_memcpyCachedToCached(cached_dest, cached_src, Size) memcpy(cached_dest, cached_src, size)


/* Registers Mapping related functions */
#if defined(ST_OSLINUX)
#define STOS_MapRegisters(a,b,c)    STLINUX_MapRegion(a,b,c)
#define STOS_UnmapRegisters(a,b)    STLINUX_UnmapRegion(a,b)

#elif defined(ST_OS20) || defined(ST_OS21)
#define STOS_MapRegisters(a,b,c)    (a)
#define STOS_UnmapRegisters(a,b)
#endif


/* Race conditions Management */
#if defined(ST_OSLINUX)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -