[T106][ZXW-22]7520V3SCV2.01.01.02P42U09_VEC_V0.8_AP_VEC origin source commit

Change-Id: Ic6e05d89ecd62fc34f82b23dcf306c93764aec4b
diff --git a/cp/ps/modem/psbase/inc/base_api.h b/cp/ps/modem/psbase/inc/base_api.h
new file mode 100644
index 0000000..c6e652e
--- /dev/null
+++ b/cp/ps/modem/psbase/inc/base_api.h
@@ -0,0 +1,720 @@
+/************************************************************************

+* °æÈ¨ËùÓÐ (C)2001,ÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£

+* 

+* ÎļþÃû³Æ£º base_api.h

+* Îļþ±êʶ£º 

+* ÄÚÈÝÕªÒª£º 

+*

+* ÐÞ¸ÄÈÕÆÚ     °æ±¾ºÅ     Ð޸ıê¼Ç     ÐÞ¸ÄÈË	     ÐÞ¸ÄÄÚÈÝ      

+* ---------------------------------------------------------------------

+* 2007/11/24	            V0.5	                                      ¹¨Òí	         create

+************************************************************************/

+

+#ifndef BASE_API_H_

+#define	BASE_API_H_

+/**************************************************************************

+ *                        Í·Îļþ°üº¬                                      *

+ **************************************************************************/

+#include "oss_api.h"

+#include "base_pub.h"

+

+

+ /**************************************************************************

+ *                         ³£Á¿                                           *

+ **************************************************************************/

+

+

+/**************************************************************************

+ *                         ºê¶¨Òå                                         *

+ **************************************************************************/

+/*KangShuJie 2008.04.03*/

+#ifndef CLOCK_TICK

+#define CLOCK_TICK       4615385  

+#endif

+

+#define P_many_receiver  126

+#define P_no_receiver    125

+

+

+#define HISR_ENTRY_CONG(HISR_NAME,ENTRY,PRIO,STACK_SIZE) \

+{#HISR_NAME"HISR",ENTRY, &HISR_NAME##_HISR_control,STACK_SIZE,PRIO}

+

+#define PROCESS_ENTRY(PROC_NAME,INSTANCE,ENTRY,PRIO,TIME_SLICE,STACK_SIZE) \

+  #PROC_NAME":"#INSTANCE, ENTRY, &PROC_NAME##INSTANCE##_task, STACK_SIZE, \

+  PRIO, TIME_SLICE, { ( P_##PROC_NAME + INSTANCE - 1 ), (queue_table+P_##PROC_NAME+INSTANCE-1) }

+

+#define SIGNAL_NAME(SIG_NAME, SIG_IDNODE) \

+   (XSIGTYPE)(SIG_NAME & (SIGREFTYPE)0xFFFFFFFF)

+

+#define NU_SUSPEND      0xFFFFFFFFUL     

+

+#define NU_MAX_NAME                     8

+

+#define SDL_pid SDL_PId

+#define SDL_Pid SDL_PId

+

+#define SIGREFTYPE UINT32

+

+#define XINPUTREFTYPE  SIGREFTYPE

+

+#define XSIGTYPE  SIGREFTYPE

+

+#define XSIGNALHEADERTYPE xSignalHeaderRec

+

+/*SDLÈÎÎñ״̬*/

+#define xInput                 (xInputAction)0

+#define xSave                  (xInputAction)1

+#define xDiscard              (xInputAction)2

+#define xEnablCond         (xInputAction)3

+#define xPrioInput           (xInputAction)4

+#define xNotInSignalSet  (xInputAction)5

+

+#define SDL_NULL                (SDL_PId)0

+

+#define STARTUP_SIGNAL_NAME  SIGNAL_NAME(~0, 0)

+

+#define OSS_TASKSELFID_BEGIN  0x00007f00

+

+#define MS_OS_CRITICAL_SECTION_SUPPORT 1

+

+/**************************************************************************

+ *                         Êý¾ÝÀàÐÍ                                       *

+ **************************************************************************/

+/*Ïß³ÌÈë¿Úº¯ÊýÀàÐÍ*/ 

+typedef void (*ENTRY)(unsigned long, void *);

+typedef void (*HISRENTRY)(void);

+

+typedef struct s_queue *QID;

+

+typedef QID        SDL_PId;

+

+typedef struct xSignalHeaderStruct *xSignalHeader;

+typedef struct xTimerHeaderStruct *xTimerHeader;

+

+/**************************************************************************

+*                         Êý¾Ý½á¹¹                                       *

+**************************************************************************/

+/*HISRÈÎÎñ¿ØÖÆ¿é*/ 

+typedef struct NU_HISR_STRUCT{

+    UNSIGNED      words[22];   

+    VOID(*hisrEntry)(VOID);

+    ZOSS_THREAD_ID hisrTaskId;   

+} NU_HISR;

+

+/*Ïß³ÌÈë²Î£¬±£´æÕæÕýµÄÈë¿Úº¯ÊýºÍ²ÎÊý*/

+typedef struct entryCb{

+    ENTRY entry;

+    unsigned long argc;

+    VOID *argv;

+}EntryCB;

+

+/*HISRÏß³ÌÈë²Î£¬±£´æÈë¿Úº¯Êý*/

+typedef struct hisrEntryCb{

+    HISRENTRY entry;

+}HisrEntryCB;

+

+/*´æ·ÅSDLÈÎÎñµÄIDºÍͨѶID*/

+struct args{

+    UINT32   self_id;

+    SDL_PId self;

+};

+

+/*SDLÈÎÎñºÍÏ̵߳ǼDZí*/

+struct process_desc{

+    CHAR     *name;

+    VOID     (*entry)(UNSIGNED, VOID *);

+    ZOSS_THREAD_ID task;

+    UNSIGNED stack_size;

+    UINT32   prio;

+    UNSIGNED time_slice;

+    struct args args;

+}; 

+

+/*HISRÈÎÎñµÇ¼Ç±í*/ 

+struct hisr_desc{

+    CHAR           *name;

+    VOID           (*entry)( VOID );

+    NU_HISR        *hcb;

+    UNSIGNED stack_size;

+    UINT32          prio;   

+};

+

+typedef struct NU_PROTECT_STRUCT

+{

+    UNSIGNED       words[2];

+}NU_PROTECT;

+

+/*ÐźÅÁ¿±êʶ*/

+typedef struct NU_SEMAPHORE_STRUCT{

+    ZOSS_SEMAPHORE_ID sem_id;

+    UNSIGNED initial_count;

+    DATA_ELEMENT sm_fifo_suspend;

+}NU_SEMAPHORE;

+

+/*SDLÈÎÎñÏûϢͷ*/

+typedef struct xSignalHeaderStruct{

+    xSignalHeader pred; 

+    xSignalHeader succ; 

+    SIGREFTYPE    SignalCode; 

+    UINT32  sender_id; 

+    SDL_PId          Sender;

+}xSignalHeaderRec;

+

+/*SDLÈÎÎñͨѶID*/

+typedef struct s_queue{

+#if 0

+    ZOSS_THREAD_ID  thread_id;

+#endif

+    xSignalHeaderRec list;

+    ZOSS_SEMAPHORE_ID  events;

+    ZOSS_MUTEX_ID  mutex;   

+    VOID *ECB;

+}t_queue;

+

+/*SDLÈÎÎñÏêϸÐÅÏ¢£¬Ã¿¸öSDLÈÎÎñ×Ô¼ºÎ¬»¤*/

+typedef struct process_vars{

+    SDL_PId           Offspring; 

+    SDL_PId           Parent; 

+    SDL_PId           Self; 

+    SDL_PId           Sender; 

+    xSignalHeaderRec  *yInSignalPtr; 

+    xSignalHeaderRec  SaveQ; 

+    xSignalHeader     CurrentInSaveQ; 

+    UINT8     xState; 

+    XINPUTREFTYPE     RestartAddress; 

+    UINT32     SelfId;

+}t_process_vars;

+

+/*SDLÈÎÎñ×´Ì¬×ªÒÆ±í*/

+typedef struct s_trans_desc{

+  const xInputAction *ystah;

+  const XINPUTREFTYPE *ystai;

+}t_trans_desc;

+

+/*¶¨Ê±Æ÷¿ØÖƿ飬¿ÉÒÔµ±×÷ÏûϢͷʹÓÃ*/

+typedef struct xTimerHeaderStruct{

+    xTimerHeader ee_succ; 

+    xTimerHeader le_succ; 

+    SIGREFTYPE   SignalCode; 

+    SDL_PId      Sender; 

+    SdlTimeSpec  ee_time; 

+    SdlTimeSpec  le_time;

+    t_timer_param param;

+}xTimerHeaderRec;

+

+#if 0

+#define MAXIMUMTIMER  1024

+typedef struct _TimerContext

+{

+	char timerName[MAX_THREADNAME_LEN];/* ¶¨Ê±Æ÷Ãû³Æ ,×î´óֵͬÏß³ÌÃû*/

+	ZOSS_TIMER_FUN timerFun;	/* ¶¨Ê±Æ÷Ö´Ðлص÷º¯Êý */

+	UINT32 input;		/* »Øµ÷º¯ÊýÈë¿Ú²ÎÊý */

+	UINT32 timer_expire;	/* ¶¨Ê±Æ÷¶¨Ê±³¬Ê±Ê±¼ä */

+	UINT32 auto_activate;	/* ¶¨Ê±Æ÷ÊÇ·ñ¸Õ´´½¨ºÃ¾Í¼¤»î */

+	BOOL active;		/* µ±Ç°¶¨Ê±Æ÷ÊÇ·ñ´¦ÓÚ¼¤»î״̬ */

+	UINT32 index;		/* µ±Ç°ÏîÉÏÏÂÎĵÄË÷Òý */

+	ZOSS_TIMER_ID timerid;	/* ¶¨Ê±Æ÷µÄID */

+	HANDLE threadHandle;	/* ¶¨Ê±Æ÷ËùÔÚÏ̵߳ľä±ú */

+	BOOL isInUse;		/* µ±Ç°ÏîÉÏÏÂÎÄÊÇ·ñÒѾ­±»Ê¹Óà */

+	BOOL cycle;		/* µ±Ç°¶¨Ê±Æ÷ÊÇÖÜÆÚÐԵϹÊÇÖ»Ö´ÐÐÒ»´Î */

+}TimerContext;

+#endif

+

+ /**************************************************************************

+ *                        È«¾Öº¯ÊýÔ­ÐÍ                                     *

+ **************************************************************************/

+ /*===========================================*/

+/*ϵͳ¹ÜÀíÄ£¿é*/

+/*===========================================*/

+/**************************************************************************

+* º¯ÊýÃû³Æ£º nu_is_booting

+* ¹¦ÄÜÃèÊö£º ¼ì²âÊÇ·ñ³õʼ»¯Íê³É

+* ²ÎÊý˵Ã÷£º (IN)

+                               (OUT)

+* ·µ »Ø Öµ£º    TURE: the system is booted

+                               FALSE: not completed

+* ÆäËü˵Ã÷£º 

+**************************************************************************/

+extern SINT32 nu_is_booting(VOID);

+

+/**************************************************************************

+* º¯ÊýÃû³Æ£º SDL_Task_Start

+* ¹¦ÄÜÃèÊö£º Æô¶¯SDL ÈÎÎñ

+* ²ÎÊý˵Ã÷£º (IN)

+                               process:

+                               staticEntry:

+                               (OUT)

+* ·µ »Ø Öµ£º    ³É¹¦·´»ØZOSS_SUCCESS£¬Ê§°Ü·´»ØZOSS_ERROR

+* ÆäËü˵Ã÷£º 

+**************************************************************************/

+extern UINT32 SDL_Task_Start(struct process_desc *process);

+

+/**************************************************************************

+* º¯ÊýÃû³Æ£º Non_SDL_Task_Start

+* ¹¦ÄÜÃèÊö£º Æô¶¯SDL ÈÎÎñ

+* ²ÎÊý˵Ã÷£º (IN)

+                               process:

+                               additionalEntry:

+                               (OUT)

+* ·µ »Ø Öµ£º    ³É¹¦·´»ØZOSS_SUCCESS£¬Ê§°Ü·´»ØZOSS_ERROR

+* ÆäËü˵Ã÷£º 

+**************************************************************************/

+extern UINT32 Non_SDL_Task_Start(struct process_desc *process);

+

+/**************************************************************************

+* º¯ÊýÃû³Æ£º HIRS_Task_Start

+* ¹¦ÄÜÃèÊö£º Æô¶¯HISR ÈÎÎñ

+* ²ÎÊý˵Ã÷£º (IN)

+                               hisr:

+                               (OUT)

+* ·µ »Ø Öµ£º    ³É¹¦·´»ØZOSS_SUCCESS£¬Ê§°Ü·´»ØZOSS_ERROR

+* ÆäËü˵Ã÷£º 

+**************************************************************************/

+extern UINT32 HIRS_Task_Start(struct hisr_desc *hisr);

+

+/*===========================================*/

+/*HISRÈÎÎñ¹ÜÀíÄ£¿é*/

+/*===========================================*/

+/**************************************************************************

+* º¯ÊýÃû³Æ:  NU_Create_HISR

+* ¹¦ÄÜÃèÊö: ´´½¨HISRÏß³Ì

+* ²ÎÊý˵Ã÷: hisr:HISRÖ¸Õë

+                 name:Ïß³ÌÃû³Æ

+                 hisr_entry:Ïß³ÌÈë¿Úº¯Êý

+		priority:ÓÅÏȼ¶

+		stack_address:Õ»µØÖ·

+		stack_size:Õ»´óС

+* ·µ »Ø Öµ:  ÕýÈ··µ»ØZOSS_SUCCESS£¬´íÎó·µ»ØZOSS_ERROR

+* ÆäËü˵Ã÷:  

+**************************************************************************/

+extern UINT32 NU_Create_HISR(NU_HISR *hisr, CHAR *name, VOID (*hisr_entry)(VOID), 

+                                     OPTION priority, VOID *stack_address, UNSIGNED stack_size);

+

+/**************************************************************************

+* º¯ÊýÃû³Æ:  NU_Activate_HISR

+* ¹¦ÄÜÃèÊö: ¼¤»îHISRÏß³Ì

+* ²ÎÊý˵Ã÷: HISRÖ¸Õë

+* ·µ »Ø Öµ:  ÕýÈ··µ»ØZOSS_SUCCESS£¬´íÎó·µ»ØZOSS_ERROR

+* ÆäËü˵Ã÷:  

+**************************************************************************/

+extern UINT32 NU_Activate_HISR(NU_HISR *hisr);

+

+/**************************************************************************

+* º¯ÊýÃû³Æ: NU_Init_HISR_Sem

+* ¹¦ÄÜÃèÊö: ³õʼ»¯HISRÏ̵߳ĿìËÙÐźÅÁ¿

+* ²ÎÊý˵Ã÷: 

+* ·µ »Ø Öµ:  

+* ÆäËü˵Ã÷:  

+**************************************************************************/

+extern VOID NU_Init_HISR_Sem(VOID);

+/**************************************************************************

+* º¯ÊýÃû³Æ: NU_Wait_HISR_Sem

+* ¹¦ÄÜÃèÊö: µÈ´ý¿ìËÙÐźÅÁ¿±»ÊÍ·Å

+* ²ÎÊý˵Ã÷: 

+* ·µ »Ø Öµ:  

+* ÆäËü˵Ã÷:  

+**************************************************************************/

+extern VOID NU_Wait_HISR_Sem(VOID);

+

+/**************************************************************************

+* º¯ÊýÃû³Æ:  NU_Delete_HISR

+* ¹¦ÄÜÃèÊö: ɾ³ýHISR

+* ²ÎÊý˵Ã÷: ÎÞ

+* ·µ »Ø Öµ:  ÕýÈ··µ»ØZOSS_SUCCESS£¬´íÎó·µ»ØZOSS_ERROR

+* ÆäËü˵Ã÷:  

+**************************************************************************/

+// P98C-YXS extern UINT32 NU_Delete_HISR(NU_HISR *hisr);

+

+/**************************************************************************

+* º¯ÊýÃû³Æ:  NU_Current_HISR_Pointer

+* ¹¦ÄÜÃèÊö: »ñµÃµ±Ç°HISRÖ¸Õë

+* ²ÎÊý˵Ã÷: ÎÞ

+* ·µ »Ø Öµ:  »ñµÃµ±Ç°HISRÖ¸Õë

+* ÆäËü˵Ã÷:  

+**************************************************************************/

+// P98C-YXS extern NU_HISR *NU_Current_HISR_Pointer(VOID);

+

+/**************************************************************************

+* º¯ÊýÃû³Æ:  NU_Current_Task_Pointer

+* ¹¦ÄÜÃèÊö: »ñµÃµ±Ç°ÈÎÎñÖ¸Õë

+* ²ÎÊý˵Ã÷: ÎÞ

+* ·µ »Ø Öµ: µ±Ç°ÈÎÎñÖ¸Õë

+* ÆäËü˵Ã÷:  ÖжÏÏ̷߳µ»Ø¿Õ

+**************************************************************************/

+extern VOID *NU_Current_Task_Pointer(VOID);

+

+/**************************************************************************

+* º¯ÊýÃû³Æ:  NU_Create_Semaphore

+* ¹¦ÄÜÃèÊö: ´´½¨ÐźÅÁ¿

+* ²ÎÊý˵Ã÷: semaphore£ºÐźÅÁ¿Ö¸Õë

+                  name:ÐźÅÁ¿Ãû³Æ

+                  initial_count:³õʼֵ

+                  suspend_type:ÀàÐÍ

+* ·µ »Ø Öµ:  ÕýÈ··µ»ØZOSS_SUCCESS£¬´íÎó·µ»ØZOSS_ERROR

+* ÆäËü˵Ã÷:  

+**************************************************************************/

+extern UINT32 NU_Create_Semaphore(NU_SEMAPHORE *semaphore, CHAR *name, 

+                                           UNSIGNED initial_count, OPTION suspend_type);

+

+/**************************************************************************

+* º¯ÊýÃû³Æ:  NU_Delete_Semaphore

+* ¹¦ÄÜÃèÊö: ɾ³ýÐźÅÁ¿

+* ²ÎÊý˵Ã÷: semaphore:ÐźÅÁ¿Ö¸Õë

+* ·µ »Ø Öµ:  ÕýÈ··µ»ØZOSS_SUCCESS£¬´íÎó·µ»ØZOSS_ERROR

+* ÆäËü˵Ã÷:  

+**************************************************************************/

+extern UINT32 NU_Delete_Semaphore(NU_SEMAPHORE *semaphore);

+

+/**************************************************************************

+* º¯ÊýÃû³Æ:  NU_Obtain_Semaphore

+* ¹¦ÄÜÃèÊö: »ñµÃÐźÅÁ¿

+* ²ÎÊý˵Ã÷: semaphore:ÐźÅÁ¿Ö¸Õë

+                  suspend:ÀàÐÍ

+* ·µ »Ø Öµ: ÕýÈ··µ»ØZOSS_SUCCESS£¬´íÎó·µ»ØZOSS_ERROR

+* ÆäËü˵Ã÷:  

+**************************************************************************/

+extern UINT32 NU_Obtain_Semaphore(NU_SEMAPHORE *semaphore, UNSIGNED suspend);

+

+/**************************************************************************

+* º¯ÊýÃû³Æ:  NU_Release_Semaphore

+* ¹¦ÄÜÃèÊö: ÊÍ·ÅÐźÅÁ¿

+* ²ÎÊý˵Ã÷: semaphore:ÐźÅÁ¿Ö¸Õë

+* ·µ »Ø Öµ:  ÕýÈ··µ»ØZOSS_SUCCESS£¬´íÎó·µ»ØZOSS_ERROR

+* ÆäËü˵Ã÷:  

+**************************************************************************/

+extern UINT32 NU_Release_Semaphore(NU_SEMAPHORE *semaphore);

+

+/**************************************************************************

+* º¯ÊýÃû³Æ:  NU_Reset_Semaphore

+* ¹¦ÄÜÃèÊö: ÖØÉèÐźÅÁ¿

+* ²ÎÊý˵Ã÷: semaphore:ÐźÅÁ¿Ö¸Õë

+                 initial_count:³õʼֵ

+* ·µ »Ø Öµ:  ÕýÈ··µ»ØZOSS_SUCCESS£¬´íÎó·µ»ØZOSS_ERROR

+* ÆäËü˵Ã÷:  

+**************************************************************************/

+extern UINT32 NU_Reset_Semaphore(NU_SEMAPHORE *semaphore, UNSIGNED initial_count);

+

+/*===========================================*/

+/*Òì³£´¦ÀíÄ£¿é*/

+/*===========================================*/

+/**************************************************************************

+* º¯ÊýÃû³Æ£ºnu_exception

+* ¹¦ÄÜÃèÊö£º Òì³£´¦Àí

+* ²ÎÊý˵Ã÷£º (IN)

+                               line_number:ÐÐÊý

+                               filename:ÎļþÃû

+                               un_status:״ֵ̬

+                               (OUT)

+* ·µ »Ø Öµ£º    ÎÞ

+* ÆäËü˵Ã÷£º 

+**************************************************************************/

+// P98C-YXS extern VOID nu_exception (SINT32 line_number, CHAR *filename, STATUS nu_status);

+

+/*===========================================*/

+/*ÄÚ´æ¹ÜÀíÄ£¿é*/

+/*===========================================*/

+/**************************************************************************

+* º¯ÊýÃû³Æ: ps_calloc

+* ¹¦ÄÜÃèÊö: ·ÖÅäÒ»×é¿Õ¼ä

+* ²ÎÊý˵Ã÷: (IN)

+                           nel:¿éÊý

+                           size:ÿ¿éµÄ´óС

+                           (OUT)

+* ·µ »Ø Öµ: ÎÞ

+* ÆäËü˵Ã÷: 

+**************************************************************************/

+extern VOID *ps_calloc(size_t nel, size_t size);

+

+/**************************************************************************

+* º¯ÊýÃû³Æ: ps_malloc

+* ¹¦ÄÜÃèÊö: ´Ó¶ÑÖзÖÅä¿Õ¼ä

+* ²ÎÊý˵Ã÷: (IN)

+                           size:´óС                           

+                           (OUT)

+* ·µ »Ø Öµ: ÎÞ

+* ÆäËü˵Ã÷: 

+**************************************************************************/

+extern VOID *ps_malloc(size_t size);

+

+/**************************************************************************

+* º¯ÊýÃû³Æ: zrealloc

+* ¹¦ÄÜÃèÊö: ´ÓзÖÅä¿Õ¼ä

+* ²ÎÊý˵Ã÷: (IN)

+                           block:Ô­ÓÐÄÚ´æÖ¸Õë

+                           newsize:еĴóС

+                           (OUT)

+* ·µ »Ø Öµ: ÎÞ

+* ÆäËü˵Ã÷: 

+**************************************************************************/

+extern VOID *zrealloc(void *block, size_t newsize);

+

+/**************************************************************************

+* º¯ÊýÃû³Æ: ps_free

+* ¹¦ÄÜÃèÊö: Êͷſռä

+* ²ÎÊý˵Ã÷: (IN)

+                           memp:ÄÚ´æÖ¸Õë                          

+                           (OUT)

+* ·µ »Ø Öµ: ÎÞ

+* ÆäËü˵Ã÷: 

+**************************************************************************/

+extern VOID  ps_free(void *memp);

+

+#if 0

+extern VOID *malloc_dma_buffer(size_t size);

+extern VOID  free_dma_buffer(void *ptr);

+#endif

+

+/*===========================================*/

+/*ÏûÏ¢¹ÜÀíÄ£¿é*/

+/*===========================================*/

+/**************************************************************************

+* º¯ÊýÃû³Æ: alloc_sig_loc

+* ¹¦ÄÜÃèÊö: ·ÖÅäÏûÏ¢¿Õ¼ä

+* ²ÎÊý˵Ã÷: (IN)

+                           size:´óС

+                           file:ÎļþÃû

+                           line:³õʼֵ

+                           (OUT)

+* ·µ »Ø Öµ:  ÕýÈ··µ»ØÄÚ´æÖ¸Õ룬´íÎó·µ»ØNULL

+* ÆäËü˵Ã÷:  

+**************************************************************************/

+extern xSignalHeaderRec *alloc_sig_loc(UINT32 size, CHAR *file, SINT32 line);

+#define alloc_sig(_size)      alloc_sig_loc ((_size), __FILE__, __LINE__)

+

+/**************************************************************************

+* º¯ÊýÃû³Æ: free_sig_loc

+* ¹¦ÄÜÃèÊö: ÊÍ·ÅÏûÏ¢¿Õ¼ä

+* ²ÎÊý˵Ã÷: (IN)

+                           signal_ptr:ÒªÊͷŵÄÄÚ´æÖ¸Õë

+                           file:ÎļþÃû

+                           line:³õʼֵ

+                           (OUT)

+* ·µ »Ø Öµ:  ÎÞ

+* ÆäËü˵Ã÷:  

+**************************************************************************/

+extern VOID free_sig_loc(xSignalHeaderRec *signal_ptr, CHAR *file, SINT32 line);

+#define free_sig(_sig_ptr)    free_sig_loc((_sig_ptr), __FILE__, __LINE__)

+

+/**************************************************************************

+* º¯ÊýÃû³Æ: send_sig_loc

+* ¹¦ÄÜÃèÊö: ÏòÒ»¸öSDLÏ̷߳¢ËÍÏûÏ¢

+* ²ÎÊý˵Ã÷: (IN)

+                           signal_ptr:ÏûÏ¢¿é

+                           rec_queue:½ÓÊÕ¶ÓÁÐÍ·Ö¸Õë

+                           sig_name:ÐźÅÃû

+                           file:ÎļþÃû

+                           line:ÐÐÊý

+                           (OUT)

+* ·µ »Ø Öµ:  ÎÞ

+* ÆäËü˵Ã÷:  

+**************************************************************************/

+extern void send_sig_loc(

+    xSignalHeaderRec *signal_ptr, t_queue *rec_queue, char *sig_name, char *file, int line );

+

+#define send_sig(_signal_ptr,_rec_queue ,_sig_name) \

+    send_sig_loc ((_signal_ptr), (_rec_queue),(_sig_name), __FILE__, __LINE__)

+

+/**************************************************************************

+* º¯ÊýÃû³Æ: send_sig_no_to_loc

+* ¹¦ÄÜÃèÊö: ¸ù¾ÝÏûÏ¢ÂëÏòÒ»¸öSDLÏ̷߳¢ËÍÏûÏ¢

+* ²ÎÊý˵Ã÷: (IN)

+                           signal_ptr:ÏûÏ¢¿é

+                           signal_cod:ÏûÏ¢Âë

+                           file:ÎļþÃû

+                           line:ÐÐÊý

+                           (OUT)

+* ·µ »Ø Öµ:  ÎÞ

+* ÆäËü˵Ã÷:  hehaijian  for win debug

+**************************************************************************/

+extern void send_sig_no_to_loc (

+    xSignalHeaderRec *signal_ptr, unsigned signal_code, CHAR *file, SINT32 line );

+

+#define send_sig_no_to(_signal_ptr, _signal_code, _sig_name ) \

+    send_sig_no_to_loc ((_signal_ptr), ( _signal_code), __FILE__, __LINE__)

+

+/**************************************************************************

+* º¯ÊýÃû³Æ: send_startup_sig_loc

+* ¹¦ÄÜÃèÊö: ÏòÒ»¸öSDLÏ̷߳¢ËÍÆô¶¯ÏûÏ¢

+* ²ÎÊý˵Ã÷: (IN)

+                           rec_queue:ÏòÒ»¸öÏ̷߳¢ËÍÆô¶¯ÏûÏ¢

+                           file:ÎļþÃû

+                           line:ÐÐÊý

+                           (OUT)

+* ·µ »Ø Öµ:  ÎÞ

+* ÆäËü˵Ã÷:  

+**************************************************************************/

+extern VOID send_startup_sig_loc (

+    t_queue *rec_queue, CHAR *file, SINT32 line );

+

+#define send_startup_sig(_rec_queue) \

+    send_startup_sig_loc ((_rec_queue), __FILE__, __LINE__)

+

+/**************************************************************************

+* º¯ÊýÃû³Æ: receive_sig_loc

+* ¹¦ÄÜÃèÊö: ½ÓÊÕÏûÏ¢

+* ²ÎÊý˵Ã÷: (IN)

+                           queue:ÏûÏ¢¶ÓÁÐÍ·

+                           file:ÎļþÃû

+                           line:ÐÐÊý

+                           (OUT)

+* ·µ »Ø Öµ:  ÏûÏ¢Ö¸Õë

+* ÆäËü˵Ã÷:  ÓÉSDLÈÎÎñµ÷ÓÃ

+**************************************************************************/

+extern xSignalHeaderRec *receive_sig_loc(t_queue *queue, CHAR *file, SINT32 line);

+#define receive_sig(_queue)   receive_sig_loc ((_queue), __FILE__, __LINE__)

+

+/*===========================================*/

+/*SDL¶¨Ê±Æ÷¹ÜÀíÄ£¿é*/

+/*===========================================*/

+/**************************************************************************

+* º¯ÊýÃû³Æ: SDL_Set_Dur

+* ¹¦ÄÜÃèÊö: ´´½¨Ò»¸öSDL¶¨Ê±Æ÷

+* ²ÎÊý˵Ã÷: (IN)

+                           Tick_Expr:¶¨Ê±Æ÷ÖÜÆÚ

+                           timer_name:¶¨Ê±Æ÷Ãû

+                           timer_param:¶¨Ê±Æ÷²ÎÊý

+                           yVarP:Ïß³ÌÐÅÏ¢Ö¸Õë

+                           (OUT)

+* ·µ »Ø Öµ: ÎÞ

+* ÆäËü˵Ã÷:  ÏÈÕÒ¶¨Ê±Æ÷£¬Èç¹ûÕÒµ½Ôò»Ö¸´£¬·ñÔò´´½¨Ò»¸öеÄ

+**************************************************************************/

+extern VOID SDL_Set_Dur(SDL_Duration Tick_Expr, UINT32 timer_name,

+                   t_timer_param timer_param, t_process_vars *yVarP,BYTE sample_id);

+

+/**************************************************************************

+* º¯ÊýÃû³Æ: SDL_Set_Dur_Ex

+* ¹¦ÄÜÃèÊö: ´´½¨Ò»¸öSDL¶¨Ê±Æ÷

+* ²ÎÊý˵Ã÷: (IN)

+                           Earliest_Tick_Expr:¶¨Ê±Æ÷×îÔçÖÜÆÚ

+                           Latest_Tick_Expr:¶¨Ê±Æ÷×îÍíÖÜÆÚ

+                           timer_name:¶¨Ê±Æ÷Ãû

+                           timer_param:¶¨Ê±Æ÷²ÎÊý

+                           yVarP:Ïß³ÌÐÅÏ¢Ö¸Õë

+                           (OUT)

+* ·µ »Ø Öµ: ÎÞ

+* ÆäËü˵Ã÷:  ÏÈÕÒ¶¨Ê±Æ÷£¬Èç¹ûÕÒµ½ÔòÓÃÐÂÖÜÆÚ»Ö¸´£¬·ñÔò´´½¨Ò»¸öеÄ

+**************************************************************************/

+extern VOID SDL_Set_Dur_Ex(SDL_Duration Earliest_Tick_Expr, SDL_Duration Latest_Tick_Expr,

+                      UINT32 timer_name, t_timer_param timer_param, t_process_vars *yVarP,BYTE sample_id);

+

+/**************************************************************************

+* º¯ÊýÃû³Æ: SDL_Set

+* ¹¦ÄÜÃèÊö: ´´½¨Ò»¸öSDL¶¨Ê±Æ÷

+* ²ÎÊý˵Ã÷: (IN)

+                           Tick_Expr:¶¨Ê±Æ÷ÖÜÆÚ

+                           timer_name:¶¨Ê±Æ÷Ãû

+                           timer_param:¶¨Ê±Æ÷²ÎÊý

+                           yVarP:Ïß³ÌÐÅÏ¢Ö¸Õë

+                           (OUT)

+* ·µ »Ø Öµ: ÎÞ

+* ÆäËü˵Ã÷:  ÏÈÕÒ¶¨Ê±Æ÷£¬Èç¹ûÕÒµ½Ôò»Ö¸´£¬·ñÔò´´½¨Ò»¸öеÄ

+**************************************************************************/

+// P98C-YXS extern VOID SDL_Set(SDL_Time Time, UINT32 timer_name,

+// P98C-YXS                t_timer_param timer_param, t_process_vars *yVarP);

+

+/**************************************************************************

+* º¯ÊýÃû³Æ: SDL_Set_Ex

+* ¹¦ÄÜÃèÊö: ´´½¨Ò»¸öSDL¶¨Ê±Æ÷

+* ²ÎÊý˵Ã÷: (IN)

+                           Earliest_Tick_Expr:¶¨Ê±Æ÷×îÔçÖÜÆÚ

+                           Latest_Tick_Expr:¶¨Ê±Æ÷×îÍíÖÜÆÚ

+                           timer_name:¶¨Ê±Æ÷Ãû

+                           timer_param:¶¨Ê±Æ÷²ÎÊý

+                           yVarP:Ïß³ÌÐÅÏ¢Ö¸Õë

+                           (OUT)

+* ·µ »Ø Öµ: ÎÞ

+* ÆäËü˵Ã÷:  ÏÈÕÒ¶¨Ê±Æ÷£¬Èç¹ûÕÒµ½Ôò»Ö¸´£¬·ñÔò´´½¨Ò»¸öеÄ

+**************************************************************************/

+// P98C-YXS extern VOID SDL_Set_Ex(SDL_Time Earliest_Time, SDL_Time Latest_Time, UINT32 timer_name,

+// P98C-YXS                t_timer_param timer_param, t_process_vars *yVarP);

+

+/**************************************************************************

+* º¯ÊýÃû³Æ: SDL_Reset

+* ¹¦ÄÜÃèÊö: ɾ³ýÒ»¸öSDL¶¨Ê±Æ÷

+* ²ÎÊý˵Ã÷: (IN)

+                           timer_name:¶¨Ê±Æ÷Ãû

+                           timer_param:¶¨Ê±Æ÷²ÎÊý

+                           yVarP:Ïß³ÌÐÅÏ¢Ö¸Õë

+                           (OUT)

+* ·µ »Ø Öµ: ÎÞ

+* ÆäËü˵Ã÷:  

+**************************************************************************/

+extern VOID SDL_Reset (UINT32 TimerName, t_timer_param timer_param,

+                 t_process_vars *yVarP,BYTE sample_id);

+

+/**************************************************************************

+* º¯ÊýÃû³Æ: SDL_Active

+* ¹¦ÄÜÃèÊö: ¼ì²é¶¨Ê±Æ÷ÊÇ·ñ´æÔÚ

+* ²ÎÊý˵Ã÷: (IN)

+                           timer_name:¶¨Ê±Æ÷Ãû

+                           timer_param:¶¨Ê±Æ÷²ÎÊý

+                           yVarP:Ïß³ÌÐÅÏ¢Ö¸Õë

+                           (OUT)

+* ·µ »Ø Öµ: ´æÔÚ·µ»ØTRUE£¬·ñÔò·µ»ØFALSE

+* ÆäËü˵Ã÷:  

+**************************************************************************/

+// P98C-YXS extern SDL_Boolean SDL_Active(UINT32 TimerName, t_timer_param timer_param,

+// P98C-YXS                          t_process_vars *yVarP);

+

+extern SDL_Time RetrieveClock(BYTE sample_id);

+

+extern SDL_Duration SDL_Duration_Lit (SINT32 secs, SINT32 nsecs);

+

+/*===========================================*/

+/*SDLÈÎÎñ¹ÜÀíÄ£¿é*/

+/*===========================================*/

+/**************************************************************************

+* º¯ÊýÃû³Æ: SDL_Create

+* ¹¦ÄÜÃèÊö: ´´½¨Ò»¸öSDLÈÎÎñ

+* ²ÎÊý˵Ã÷: (IN)

+                           task_entry:ÈÎÎñÈë¿Úº¯Êý

+                           stack_size:¶ÑÕ»´óС

+                           self_id:ÈÎÎñID

+                           prio:ÓÅÏȼ¶

+                           task_name:ÈÎÎñÃû

+                           startup_signal:³õʼ»¯ÏûÏ¢

+                           (OUT)

+* ·µ »Ø Öµ: ÎÞ

+* ÆäËü˵Ã÷: 

+**************************************************************************/

+extern SDL_PId SDL_Create (

+     VOID ( *task_entry )( UNSIGNED argc, VOID *argv ),

+     SINT32 stack_size,

+     SINT32 self_id,

+     SINT32 prio,

+     CHAR *task_name,

+     xSignalHeader startup_signal

+    );

+

+/**************************************************************************

+* º¯ÊýÃû³Æ: SDL_Stop

+* ¹¦ÄÜÃèÊö: ɾ³ýÒ»¸öSDLÈÎÎñ

+* ²ÎÊý˵Ã÷: (IN)

+                           varp:Ïß³ÌÐÅÏ¢

+                           yInSignalPtr:ÏûÏ¢Ö¸Õë

+                           self_if:ÈÎÎñID

+                           (OUT)

+* ·µ »Ø Öµ: ÎÞ

+* ÆäËü˵Ã÷: ÔÚÈÎÎñÈë¿ÚÖе÷Óã¬Ò»°ãÓÃÀ´É¾³ý×Ô¼º

+**************************************************************************/

+extern VOID SDL_Stop(t_process_vars *varp, xSignalHeaderRec *yInSignalPtr);

+

+/**************************************************************************

+* º¯ÊýÃû³Æ: SDL_Loop

+* ¹¦ÄÜÃèÊö: Ñ­»·½ÓÊÕÏûÏ¢

+* ²ÎÊý˵Ã÷: (IN)

+                           proc_insig_tab:ÏûϢ״̬Êý×é

+                           trans_tab:×´Ì¬×ªÒÆ¾ØÕó

+                           yVarP:Ïß³ÌÐÅÏ¢½á¹¹ÌåÖ¸Õë

+                           self_id:Ïß³ÌID

+                           (OUT)

+* ·µ »Ø Öµ: ÏûÏ¢Ö¸Õë

+* ÆäËü˵Ã÷: ÓÐÎÊÌâ

+**************************************************************************/

+extern xSignalHeaderRec *SDL_Loop(const XSIGTYPE *proc_insig_tab,

+                                  const t_trans_desc *trans_tab,

+                                  struct process_vars *yVarP,

+                                  char *file, int line);

+

+#endif

+

diff --git a/cp/ps/modem/psbase/inc/base_pub.h b/cp/ps/modem/psbase/inc/base_pub.h
new file mode 100644
index 0000000..13a2710
--- /dev/null
+++ b/cp/ps/modem/psbase/inc/base_pub.h
@@ -0,0 +1,69 @@
+/************************************************************************

+* °æÈ¨ËùÓÐ (C)2001,ÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£

+*

+* ÎļþÃû³Æ£º base_api.h

+* Îļþ±êʶ£º

+* ÄÚÈÝÕªÒª£º

+*

+* ÐÞ¸ÄÈÕÆÚ     °æ±¾ºÅ     Ð޸ıê¼Ç     ÐÞ¸ÄÈË	     ÐÞ¸ÄÄÚÈÝ

+* ---------------------------------------------------------------------

+* 2007/11/24	            V0.5	                                      ¹¨Òí	         create

+************************************************************************/

+

+#ifndef BASE_PUB_H_

+#define BASE_PUB_H_

+/**************************************************************************

+ *                        Í·Îļþ°üº¬                                      *

+ **************************************************************************/

+#include "oss_api.h"

+

+/**************************************************************************

+ *                         ºê¶¨Òå                                         *

+ **************************************************************************/

+#define NU_SUCCESS   ZOSS_SUCCESS

+#define NU_NULL         NULL

+

+#define NU_TASK       ZOSS_THREAD_ID

+#ifdef _OS_WIN

+#define PROCESS       ZOSS_THREAD_ID

+#endif

+

+#define NU_PREEMPT     1

+#define NU_START         1

+#define NU_FIFO            6

+

+/**************************************************************************

+ *                         Êý¾ÝÀàÐÍ                                       *

+ **************************************************************************/

+typedef LONG                         SDL_Duration;

+typedef SDL_Duration           SDL_duration;

+typedef SDL_Duration           SDL_Time;

+typedef SDL_Time                SDL_time;

+typedef unsigned long           UNSIGNED;

+typedef long                         SIGNED;

+typedef SINT32                      DATA_ELEMENT;

+typedef DATA_ELEMENT        OPTION;

+typedef UINT32                    STATUS;

+typedef UINT8                      UNSIGNED_CHAR;

+typedef unsigned long *        UNSIGNED_PTR;

+typedef UINT8   *                 BYTE_PTR;

+//typedef UINT16                    word;

+typedef UINT8                      SDL_Boolean;

+typedef UINT8                      SDL_boolean;

+typedef SINT16                     INT16;

+

+#ifndef _OS_WIN

+typedef long int                     INT32;

+typedef SINT32                    INT;

+//typedef UINT8                      byte;

+#endif

+

+typedef UINT32                     TID;

+typedef UINT8                       xInputAction;

+typedef long                     SdlTimeSpec;

+typedef unsigned long            t_timer_param;

+//typedef unsigned char            ubyte;

+//typedef unsigned short           ushort;

+

+

+#endif

diff --git a/cp/ps/modem/psbase/inc/bastypes.h b/cp/ps/modem/psbase/inc/bastypes.h
new file mode 100644
index 0000000..19f477a
--- /dev/null
+++ b/cp/ps/modem/psbase/inc/bastypes.h
@@ -0,0 +1,151 @@
+#ifndef BASTYPES_H

+

+#define BASTYPES_H 1

+

+#if defined(PCTEST) || defined(SGOLD) || defined (SGOLDLITE) || defined(SGOLD3) || defined(SGOLDRADIO) || defined(_WIN32)

+#define near

+#define xnear

+#define far

+#define huge

+#define bit

+

+#elif defined (STARCORE)

+#define near

+#define bit

+

+#else

+#define near 

+#define xnear 

+#define far  

+#define bit  

+#endif

+

+#ifdef _OS_LINUX

+# undef bit

+#endif

+

+#ifndef TRUE

+#define TRUE 1

+#endif

+

+#ifndef FALSE

+#define FALSE 0

+#endif

+

+#ifndef NULL

+#define NULL    ((void *)0)

+#endif

+

+#define STD_OK    0

+#ifndef STD_ERR

+#define STD_ERR (-1)

+#endif

+

+#include "pub.h"

+#define int16               short

+

+#define int32               long int

+

+typedef unsigned char       ubyte; 

+typedef signed   char       sbyte; 

+typedef signed   int16      sshort;

+typedef signed   int32      slong; 

+

+typedef signed  long    S64;

+#ifndef _OS_WIN

+typedef unsigned long  U64_T;  

+#else

+typedef DWORD64  U64_T;

+#endif

+#ifdef _OS_WIN

+#if !defined ALI_FILE_VER 

+

+typedef signed char         S8;

+typedef signed short        S16;

+typedef unsigned char       U8;

+typedef unsigned short      U16;

+

+typedef signed int          S32;

+typedef unsigned int        U32;

+

+#if !defined SDTENV

+#if defined(UNITEST) && defined(_WIN32)

+typedef __int64             S64;

+typedef __int64             U64;

+#else

+typedef signed  long    S64;

+typedef unsigned  long  U64;

+#endif

+#endif

+#endif

+typedef unsigned  long  U64;

+#endif

+

+#if defined (__arm) || defined (_USE_CMPL_GCC) || defined (_ENTERPRISE_C_) || defined (UNITEST)

+//note: 

+//"Enterprise C" is a compiler 

+//for StarCore by Metrowerks

+typedef unsigned int        uint;

+#endif 

+

+

+

+#if defined(_WIN32)

+

+#undef shuge

+#define shuge

+

+typedef unsigned char       UINT8;

+typedef unsigned short      UINT16;

+

+#if !defined UNITEST

+typedef unsigned char       U8;

+typedef unsigned short      U16;

+#endif

+

+#endif 

+

+

+#ifdef __CYGWIN__

+typedef unsigned long    ulong;

+#elif defined(_Windows)

+typedef unsigned long    ulong;

+typedef unsigned short   ushort;

+#else

+#if !defined X_SCTTYPES_H || defined (__arm) || defined (_USE_CMPL_GCC) || defined (_ENTERPRISE_C_)

+typedef unsigned long    ulong;

+typedef unsigned short ushort;

+#endif

+#endif

+

+#if defined (WIN32) || defined (_Windows)

+typedef __int64 ullong;

+typedef __int64 sllong;

+#define  LL(a) (a)

+#define ULL(a) (a)

+#elif defined (__arm) || defined (_USE_CMPL_GCC) || defined (_ENTERPRISE_C_) || \

+      (defined (__GNUC__) && !defined (__STRICT_ANSI__)) || \

+      (defined (SUN5_ANSICC) && (__STDC__ == 0) && !defined(_POSIX_C_SOURCE) && !defined(_XOPEN_SOURCE))

+typedef unsigned long long ullong;

+typedef   signed long long sllong;

+#define  LL(a) (a##LL)

+#define ULL(a) (a##ULL)

+#else

+#define LONGLONG_EMUL 1

+typedef struct

+{

+  slong hi;

+  ulong lo;

+} sllong;

+typedef struct

+{

+  ulong hi;

+  ulong lo;

+} ullong;

+#endif

+

+#ifndef MS_UNUSED_VAR

+#define MS_UNUSED_VAR(a)  {if(sizeof(a)){}}

+#endif

+

+#endif

diff --git a/cp/ps/modem/psbase/inc/cpu_intlock.h b/cp/ps/modem/psbase/inc/cpu_intlock.h
new file mode 100644
index 0000000..9de5f9c
--- /dev/null
+++ b/cp/ps/modem/psbase/inc/cpu_intlock.h
@@ -0,0 +1,27 @@
+/* COPYRIGHT-ENEA-SRC-R1 *

+ **************************************************************************

+ * Copyright (C) 2004 by Enea Embedded Technology AB.

+ * All rights reserved.

+ *

+ * This Software is furnished under a software license agreement and

+ * may be used only in accordance with the terms of such agreement.

+ * Any other use or reproduction is prohibited. No title to and

+ * ownership of the Software is hereby transferred.

+ *

+ * PROPRIETARY NOTICE

+ * This Software consists of confidential information.

+ * Trade secret law and copyright law protect this Software.

+ * The above notice of copyright on this Software does not indicate

+ * any actual or intended publication of such Software.

+ **************************************************************************

+ * COPYRIGHT-END */

+/**

+ * @toc CPU_Dependent:

+ * @file ose_spi/arm/cpu_intlock.h

+ *

+ * @brief Interrupt lock functions for ARM.

+ *

+ * @long The lock functions must only be called from supervisor mode. 

+ *       The effect of calls from other modes is unspecified.

+ */

+

diff --git a/cp/ps/modem/psbase/inc/ctypes.h b/cp/ps/modem/psbase/inc/ctypes.h
new file mode 100644
index 0000000..c59a094
--- /dev/null
+++ b/cp/ps/modem/psbase/inc/ctypes.h
@@ -0,0 +1,127 @@
+#ifndef CTYPES_H
+#define CTYPES_H
+
+
+#define XSCT_CBASIC
+
+#ifndef XX_ctypes_H
+#define XX_ctypes_H
+
+
+extern XCONST struct xPackageIdStruct yPacR_ctypes;
+
+extern void yInit_ctypes (void);
+
+
+               
+typedef short int ShortInt;
+
+
+
+#ifndef XTNOUSE_LongInt
+extern tSDLTypeInfo ySDL_LongInt;
+#endif
+                
+typedef long int LongInt;
+
+
+
+                
+typedef unsigned short UnsignedShortInt;
+typedef unsigned UnsignedInt;
+typedef unsigned long UnsignedLongInt;
+typedef char * Charstar;
+typedef void * Voidstar;
+typedef void ** Voidstarstar;
+
+#define yAssF_ShortInt(V,E,A)  yAssF_SDL_Integer(V,E,A)
+#define yEqF_ShortInt(Expr1,Expr2)  yEqF_SDL_Integer(Expr1,Expr2)
+#define yNEqF_ShortInt(Expr1,Expr2)  yNEqF_SDL_Integer(Expr1,Expr2)
+#define yMkAddr_ShortInt(V,R) (*(R) = V, (void *)R)
+#ifndef ANY_ShortInt
+#define ANY_ShortInt
+#endif
+
+#define yAssF_LongInt(V,E,A)  yAssF_SDL_Integer(V,E,A)
+#define yEqF_LongInt(Expr1,Expr2)  yEqF_SDL_Integer(Expr1,Expr2)
+#define yNEqF_LongInt(Expr1,Expr2)  yNEqF_SDL_Integer(Expr1,Expr2)
+#define yMkAddr_LongInt(V,R) (*(R) = V, (void *)R)
+#ifndef ANY_LongInt
+#define ANY_LongInt
+#endif
+
+#define yAssF_UnsignedShortInt(V,E,A)  yAssF_SDL_Integer(V,E,A)
+#define yEqF_UnsignedShortInt(Expr1,Expr2)  yEqF_SDL_Integer(Expr1,Expr2)
+#define yNEqF_UnsignedShortInt(Expr1,Expr2)  yNEqF_SDL_Integer(Expr1,Expr2)
+#define yMkAddr_UnsignedShortInt(V,R) (*(R) = V, (void *)R)
+#ifndef ANY_UnsignedShortInt
+#define ANY_UnsignedShortInt
+#endif
+
+#define yAssF_UnsignedInt(V,E,A)  yAssF_SDL_Integer(V,E,A)
+#define yEqF_UnsignedInt(Expr1,Expr2)  yEqF_SDL_Integer(Expr1,Expr2)
+#define yNEqF_UnsignedInt(Expr1,Expr2)  yNEqF_SDL_Integer(Expr1,Expr2)
+#define yMkAddr_UnsignedInt(V,R) (*(R) = V, (void *)R)
+#ifndef ANY_UnsignedInt
+#define ANY_UnsignedInt
+#endif
+
+#define yAssF_UnsignedLongInt(V,E,A)  yAssF_SDL_Integer(V,E,A)
+#define yEqF_UnsignedLongInt(Expr1,Expr2)  yEqF_SDL_Integer(Expr1,Expr2)
+#define yNEqF_UnsignedLongInt(Expr1,Expr2)  yNEqF_SDL_Integer(Expr1,Expr2)
+#define yMkAddr_UnsignedLongInt(V,R) (*(R) = V, (void *)R)
+#ifndef ANY_UnsignedLongInt
+#define ANY_UnsignedLongInt
+#endif
+                
+#define Null()       0
+#define cstar2vstar(P) ((Voidstar)P)
+#define vstar2cstar(P) ((Charstar)P)
+#define cstar2vstarstar(P) ((Voidstarstar)&P)
+
+
+
+#define yAssF_Charstar(V,E,A)  (V = E)
+#define yEqF_Charstar(Expr1,Expr2)  ((Expr1) == (Expr2))
+#define yNEqF_Charstar(Expr1,Expr2)  ((Expr1) != (Expr2))
+#define yMkAddr_Charstar(V,R) (*(R) = V, (void *)R)
+#ifndef ANY_Charstar
+#define ANY_Charstar
+#endif
+                
+#define Null()       0
+
+
+#define yAssF_Voidstar(V,E,A)  (V = E)
+#define yEqF_Voidstar(Expr1,Expr2)  ((Expr1) == (Expr2))
+#define yNEqF_Voidstar(Expr1,Expr2)  ((Expr1) != (Expr2))
+#define yMkAddr_Voidstar(V,R) (*(R) = V, (void *)R)
+#ifndef ANY_Voidstar
+#define ANY_Voidstar
+#endif
+                
+#define yExtr_Voidstarstar(yVar)  (*(yVar))
+#define yAddr_Voidstarstar(yVar)  (*(yVar))
+#define Null()       0
+#define vstarstar2vstar(P) ((Voidstar)P)
+#define vstar2vstarstar(P) ((Voidstarstar)P)
+
+
+#define yAssF_Voidstarstar(V,E,A)  (V = E)
+#define yEqF_Voidstarstar(Expr1,Expr2)  ((Expr1) == (Expr2))
+#define yNEqF_Voidstarstar(Expr1,Expr2)  ((Expr1) != (Expr2))
+#define yMkAddr_Voidstarstar(V,R) (*(R) = V, (void *)R)
+#ifndef ANY_Voidstarstar
+#define ANY_Voidstarstar
+#endif
+
+
+                
+#ifdef XVALIDATOR_LIB
+#define XXFREE(p) XFREE_REF_VAL(p,0)
+#else
+#define XXFREE(p) XFREE(p,0)
+#endif
+
+#endif
+#endif
diff --git a/cp/ps/modem/psbase/inc/icu_irq.h b/cp/ps/modem/psbase/inc/icu_irq.h
new file mode 100644
index 0000000..88c03ec
--- /dev/null
+++ b/cp/ps/modem/psbase/inc/icu_irq.h
@@ -0,0 +1,37 @@
+/*******************************************************************************

+ * Copyright (C) 2007, ZTE Corporation.

+ *

+ * File Name: icu_irq.h    

+ * File Mark:    

+ * Description:  

+ * Others:        

+ * Version:       v0.5

+ * Author:        wangxia

+ * Date:          2008-1-5

+ * History 1:      

+ *     Date: 

+ *     Version:

+ *     Author: 

+ *     Modification:  

+ * History 2: 

+  ********************************************************************************/

+

+#if !defined (_ICU_IRQ_H)

+#define _ICU_IRQ_H

+

+#ifndef _OS_WIN

+#include "cpu_intlock.h" /* intrruput enable/disable */

+/*

+#define ICU_Disable_IRQ()            unsigned long msr;\

+	                                 LOCK_SAVE(msr);*/

+                               

+#define ICU_Disable_IRQ()  LOCK_SAVE(msr);

+

+#define ICU_Enable_IRQ()    LOCK_RESTORE(msr);

+

+#else

+#define ICU_Disable_IRQ()

+#define ICU_Enable_IRQ()

+

+#endif

+#endif /* _ICU_IRQ_H*/
diff --git a/cp/ps/modem/psbase/inc/ms_crit.h b/cp/ps/modem/psbase/inc/ms_crit.h
new file mode 100644
index 0000000..bab28eb
--- /dev/null
+++ b/cp/ps/modem/psbase/inc/ms_crit.h
@@ -0,0 +1,25 @@
+#include "base_api.h"

+

+#if MS_OS_CRITICAL_SECTION_SUPPORT > 0

+

+int os_enter_critical_section_sem(NU_SEMAPHORE *sem);

+

+int os_leave_critical_section_sem(NU_SEMAPHORE *sem);

+

+int os_sem_is_custom_style(OPTION sema_style);

+

+int os_sem_is_custom(NU_SEMAPHORE *sem_p);

+

+VOID os_sem_set_custom(NU_SEMAPHORE *sem, OPTION sema_style);

+

+UINT32 os_sem_create_custom(
+    NU_SEMAPHORE *sem_p,
+    const char *name,
+    int i,
+    OPTION sema_style);

+

+STATUS os_sem_kill_custom(NU_SEMAPHORE *sem_p);

+

+

+// P98C-YXS VOID os_sem_preset_crit_sect(NU_SEMAPHORE *sem, NU_TASK task_ptr);

+#endif

diff --git a/cp/ps/modem/psbase/inc/ms_hisr.h b/cp/ps/modem/psbase/inc/ms_hisr.h
new file mode 100644
index 0000000..d736850
--- /dev/null
+++ b/cp/ps/modem/psbase/inc/ms_hisr.h
@@ -0,0 +1,162 @@
+/************************************************************************
+* °æÈ¨ËùÓÐ (C)2007,ÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£
+* 
+* ÎļþÃû³Æ£º ps_hisr.h
+* Îļþ±êʶ£º 
+* ÄÚÈÝÕªÒª£º Ö÷ÒªÌæ»»nucleus½Ó¿ÚΪOSSÏà¹ØµÄ½Ó¿Ú
+*
+* ÐÞ¸ÄÈÕÆÚ     °æ±¾ºÅ     Ð޸ıê¼Ç     ÐÞ¸ÄÈË	     ÐÞ¸ÄÄÚÈÝ      
+* -----------------------------------------------------------------------
+* 2008/06/27  	    V0.5		                                ¹¨Òí               ´´½¨
+************************************************************************/
+
+#ifndef MS_HISR
+#define MS_HISR
+
+/**************************************************************************
+ *                        Í·Îļþ°üº¬                                      *
+ **************************************************************************/
+ #include "base_api.h"
+
+/*****************************************************************************
+* Typedef hisr_type_f
+*****************************************************************************/
+typedef VOID (*hisr_type_f) (VOID);
+
+/*****************************************************************************
+* Typedef ms_hisr_t
+*****************************************************************************/
+typedef struct ms_hisr_s
+{
+    /* hisr handling */
+    volatile UINT32   event;   /* event staring the hisr */
+    volatile UINT8     active;  /* hisr is active */
+    
+    NU_HISR   hisr_cb;      /* receive HISR structure */
+    VOID     *hisr_device;  /* must be placed directly after hisr_cb */
+    VOID     *hisr_stack;   /* enable with size */ 
+} ms_hisr_t;
+
+
+/*****************************************************************************
+ * Function:     ms_hisr_create
+ *-----------------------------------------------------------------------------
+ * Purpose:   create a new hisr   
+ *
+ * Parameters:  mshisr pointer to hisrtype
+ *              name  name
+ *              size  of the new hisr
+ *              priority hisr priority
+ *              hisr_type_f hisr function 
+ *              hisr_device device to call
+ *
+ * Returns:     void
+ *
+ * Remarks:     
+ *****************************************************************************/
+
+extern  VOID  ms_hisr_create(ms_hisr_t *mshisr, CHAR *name, SINT32 size,
+                               SINT32 priority,  hisr_type_f used_hisr,
+                               VOID *hisr_device);
+
+
+/*****************************************************************************
+ * Function:     ms_hisr_free
+ *-----------------------------------------------------------------------------
+ * Purpose:      frees an created hisr
+ *
+ * Parameters:   mshisr
+ *
+ * Returns:      
+ *
+ * Remarks:      
+ *****************************************************************************/
+
+// P98C-YXS extern  VOID  ms_hisr_free(ms_hisr_t *mshisr);
+
+
+/*****************************************************************************
+ * Function:     ms_hisr_get_io_associated_to_hisr
+ *-----------------------------------------------------------------------------
+ * Purpose:      Determines the io descriptor which contains the active HISR
+ *
+ * Parameters:   None
+ *
+ * Returns:      The UART descriptor
+ *
+ * Remarks:      - NU_Current_HISR_Pointer() is a very simple Nucleus function
+ *****************************************************************************/
+
+// P98C-YXS extern  VOID  *ms_hisr_get_associated(VOID);
+
+
+/*****************************************************************************
+ * Function:     ms_hisr_activate
+ *-----------------------------------------------------------------------------
+ * Purpose:   activates the hisr    
+ *
+ * Parameters:  mshisr pointer to hisrtype
+ *
+ * Returns:    void  
+ *
+ * Remarks:    none  
+ *****************************************************************************/
+
+extern  VOID  ms_hisr_activate(ms_hisr_t *mshisr);
+
+/*****************************************************************************
+ * Function:     ms_hisr_start
+ *-----------------------------------------------------------------------------
+ * Purpose:    starts the hisr according to the settings of 
+ *               event and hisr_active. The event will be set
+ *
+ * Parameters:  mshisr pointer to hisrtype
+ *              event event which has been set
+ *
+ * Returns:    void  
+ *
+ * Remarks:    none  
+ *****************************************************************************/
+
+// P98C-YXS extern  VOID  ms_hisr_start(ms_hisr_t *mshisr, UINT32 event);
+
+
+/*****************************************************************************
+ * Function:    ms_hisr_reset_event
+ *-----------------------------------------------------------------------------
+ * Purpose:     resets the hisr event int the hisr 
+ *             
+ *
+ * Parameters:  mshisr pointer to hisrtype
+ *              event event which has been reset
+ *
+ * Returns:    void  
+ *
+ * Remarks:    none  
+ *****************************************************************************/
+
+// P98C-YXS extern  VOID  ms_hisr_reset_event(ms_hisr_t *mshisr, UINT32 event);
+
+
+/*****************************************************************************
+ * Function:    ms_hisr_active
+ *-----------------------------------------------------------------------------
+ * Purpose:     sets the hisr active flag according to the 
+ *              status of the hisr             
+ *
+ * Parameters:  mshisr pointer to hisrtype
+ *              active  1 hisr is running
+ *                      0 hisr is stopped
+ *
+ * Returns:    void  
+ *
+ * Remarks:    none  
+ *****************************************************************************/
+
+// P98C-YXS extern  VOID  ms_hisr_active(ms_hisr_t *mshisr, UINT8 active); 
+
+extern  VOID ms_hisr_wait_sem(ms_hisr_t *mshisr);
+
+#endif 
+
+
diff --git a/cp/ps/modem/psbase/inc/ms_hwtrc.h b/cp/ps/modem/psbase/inc/ms_hwtrc.h
new file mode 100644
index 0000000..689c0e8
--- /dev/null
+++ b/cp/ps/modem/psbase/inc/ms_hwtrc.h
@@ -0,0 +1,48 @@
+/************************************************************************
+* °æÈ¨ËùÓÐ (C)2007,ÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£
+* 
+* ÎļþÃû³Æ£º ms_hwtrc.h
+* Îļþ±êʶ£º 
+* ÄÚÈÝÕªÒª£º LLT Trace.
+*
+* ÐÞ¸ÄÈÕÆÚ     °æ±¾ºÅ     Ð޸ıê¼Ç     ÐÞ¸ÄÈË	     ÐÞ¸ÄÄÚÈÝ      
+* -----------------------------------------------------------------------
+* 2008/08/27  	    V0.5		                                ¹¨Òí               ´´½¨
+************************************************************************/
+
+#ifndef MS_HWTRC_H
+#define MS_HWTRC_H
+
+
+typedef enum
+{
+    HWTRC_PROT_BTM,      /* Byte stuffing trace protocol (16 bit). */
+    HWTRC_PROT_DTM,      /* Direct Trace Method (16 bit). */
+    HWTRC_PROT_EXT_BTM,  /* Extended byte stuffing trace protocol (16 bit). */
+    HWTRC_PROT_EXT_DTM   /* Extended direct Trace Method (16 bit). */
+    
+} hwtrc_prot_t;
+
+ /**************************************************************************
+* º¯ÊýÃû³Æ: hwtrc_start
+* ¹¦ÄÜÃèÊö: ´ò¿ªLLT¸ú×Ù
+* ²ÎÊý˵Ã÷: (IN)
+                           fd
+                           (OUT)
+* ·µ »Ø Öµ:  ÎÞ
+* ÆäËü˵Ã÷:  
+**************************************************************************/
+// P98C-YXS extern VOID hwtrc_start(SINT32 fd);
+
+/**************************************************************************
+* º¯ÊýÃû³Æ: hwtrc_put_llt
+* ¹¦ÄÜÃèÊö: Êä³öLLTÏûÏ¢
+* ²ÎÊý˵Ã÷: (IN)                        
+                           (OUT)
+* ·µ »Ø Öµ:  ÎÞ
+* ÆäËü˵Ã÷:  
+**************************************************************************/
+extern VOID hwtrc_put_llt(VOID);
+
+#endif
+
diff --git a/cp/ps/modem/psbase/inc/ms_os.h b/cp/ps/modem/psbase/inc/ms_os.h
new file mode 100644
index 0000000..9a37a13
--- /dev/null
+++ b/cp/ps/modem/psbase/inc/ms_os.h
@@ -0,0 +1,1147 @@
+/************************************************************************
+* °æÈ¨ËùÓÐ (C)2007,ÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£
+* 
+* ÎļþÃû³Æ£º ms_os.h
+* Îļþ±êʶ£º 
+* ÄÚÈÝÕªÒª£º External declarations of interface routines to the operation system.
+*
+* ÐÞ¸ÄÈÕÆÚ     °æ±¾ºÅ     Ð޸ıê¼Ç     ÐÞ¸ÄÈË	     ÐÞ¸ÄÄÚÈÝ      
+* -----------------------------------------------------------------------
+* 2008/06/27  	    V0.5		                                ¹¨Òí               ´´½¨
+************************************************************************/
+
+#ifndef _MS_OS_H_
+#define _MS_OS_H_
+
+#include <stddef.h>
+#include "base_api.h"
+/*#include "ms_hwtrc.h"*/   /* Trace interface as standard out, hwtrc_print(). */
+
+#if MS_OS_CRITICAL_SECTION_SUPPORT > 0
+#include "ms_crit.h"
+#endif
+
+
+/*===========================================================================
+Exported Type Declarations
+===========================================================================*/
+
+/**B*************************************************************************
+ * Macro:        OS_pid_t
+ *---------------------------------------------------------------------------
+ * Purpose:      PID of an operation system process.
+ *
+ * Parameters:   None.
+ *
+ * Returns:      None.
+ ***E************************************************************************/
+
+#define OS_pid_t     SDL_PId
+#define OS_SDL_NULL  SDL_NULL
+
+
+/**B*************************************************************************
+ * Macro:        OS_no_sig_params_t
+ *---------------------------------------------------------------------------
+ * Purpose:      Used to allocate a signal without parameters.
+ *
+ * Parameters:   None.
+ *
+ * Returns:      None.
+ ***E************************************************************************/
+
+#define OS_no_sig_params_t  XSIGNALHEADERTYPE
+
+
+/*===========================================================================
+Exported Macro Declarations
+===========================================================================*/
+
+/**B*************************************************************************
+ * Macro:        os_mem_xalloc
+ *----------------------------------------------------------------------------
+ * Purpose:      mallocs dynamic memory
+ *
+ * Parameters:   size: number of bytes to be malloced
+ *
+ * Returns:      pointer to first byte of memory
+ *
+ * Remarks:
+ ***E************************************************************************/
+/**B*************************************************************************
+ * Macro:        os_mem_xfree
+ *----------------------------------------------------------------------------
+ * Purpose:      frees dynamic memory
+ *
+ * Parameters:   ptr:  pointer to memory to be returned
+ *
+ * Returns:      nothing
+ *
+ * Remarks:
+ ***E************************************************************************/
+
+#define os_mem_xalloc(ptr_, size_)  (ptr_) = ps_malloc(size_);
+#define os_mem_xfree(ptr_)          {ps_free( *((void **)&(ptr_))); *((void **)&(ptr_)) = NULL;}
+
+
+/**B*************************************************************************
+ * Macro:        os_msleep
+ *---------------------------------------------------------------------------
+ * Purpose:      see below os_sleep_ms
+ *
+ * Parameters:   see below.
+ *
+ * Returns:      see below.
+ ***E************************************************************************/
+
+#define os_msleep(millisec_)    os_sleep_ms(millisec_)
+
+
+/**B*************************************************************************
+ * Macro:        os_next_state
+ *---------------------------------------------------------------------------
+ * Purpose:      Go back to the read entry point of the process.
+ *
+ * Parameters:   None.
+ *
+ * Returns:      None.
+ ***E************************************************************************/
+
+#define os_next_state(p_var_, state_)  goto os_process_loop_l
+
+
+/**B*************************************************************************
+ * Macro:        os_now
+ *---------------------------------------------------------------------------
+ * Purpose:      Return the number of ticks since system start.
+ *
+ * Parameters:   None.
+ *
+ * Returns:      None.
+ ***E************************************************************************/
+
+#define os_now(sample_id)    RetrieveClock(sample_id)
+
+
+
+/**B*************************************************************************
+ * Macro:        os_outsig_declare
+ *---------------------------------------------------------------------------
+ * Purpose:      Declaration of an output signal.
+ *
+ * Parameters:   None.
+ *
+ * Returns:      None.
+ ***E************************************************************************/
+
+#define os_outsig_declare  xSignalHeaderRec  *yOutputSignalPtr;
+
+
+/**B*************************************************************************
+ * Macro:        os_outsig_get
+ *---------------------------------------------------------------------------
+ * Purpose:      Get the pointer to the output signal.
+ *
+ * Parameters:   None.
+ *
+ * Returns:      Pointer to the output signal.
+ ***E************************************************************************/
+
+#define os_outsig_get()  (void *)(yOutputSignalPtr)
+
+
+/**B*************************************************************************
+ * Macro:        OS_PROCESS
+ *---------------------------------------------------------------------------
+ * Purpose:      Declaration of an operating system task.
+ *
+ * Parameters:   x: task name.
+ *
+ * Returns:      None.
+ ***E************************************************************************/
+#ifdef OS_PROCESS
+#undef OS_PROCESS
+#endif
+#define OS_PROCESS(x) void x(UNSIGNED argc, VOID *argv)
+#define OS_PROCESS_RETURN(value_)  return;
+
+
+/**B*************************************************************************
+ * Macro:        os_process_begin
+ *---------------------------------------------------------------------------
+ * Purpose:      Define the startup of an operting system process with
+ *               input queue.
+ *
+ * Parameters:   Process variables with the generic header os_process_var.
+ *
+ * Returns:      None.
+ ***E************************************************************************/
+/*
+// P98C-YXS #if 0
+// P98C-YXS //#ifdef _OS_WIN
+// P98C-YXS #if defined UNITEST
+// P98C-YXS #define os_process_begin(var_, self_id_) \
+// P98C-YXS    unsigned char SelfId = self_id_; \
+// P98C-YXS    memset ( (void *) yVarP, 0, sizeof ( var_ ) ); \
+// P98C-YXS    yVarP->Self = ( (struct args *) argv ) -> self; \
+// P98C-YXS    yVarP->SelfId = (unsigned char)( ( (struct args *) argv ) -> self_id ); \
+// P98C-YXS    yVarP->Offspring = SDL_NULL; \
+// P98C-YXS    yVarP->SaveQ.succ = &(yVarP->SaveQ); \
+// P98C-YXS    yVarP->SaveQ.pred = &(yVarP->SaveQ); \
+// P98C-YXS    yVarP->CurrentInSaveQ = &(yVarP->SaveQ); \
+// P98C-YXS    yVarP->yInSignalPtr = 0; 
+// P98C-YXS #else
+// P98C-YXS #define os_process_begin(var_, self_id_) \
+// P98C-YXS    unsigned char SelfId = self_id_; \
+// P98C-YXS    (void) argc; \
+// P98C-YXS    memset ( (void *) yVarP, 0, sizeof ( var_ ) ); \
+// P98C-YXS    yVarP->Self = ( (struct args *) argv ) -> self; \
+// P98C-YXS    yVarP->SelfId = (unsigned char)( ( (struct args *) argv ) -> self_id ); \
+// P98C-YXS    yVarP->Offspring = SDL_NULL; \
+// P98C-YXS    yVarP->SaveQ.succ = &(yVarP->SaveQ); \
+// P98C-YXS    yVarP->SaveQ.pred = &(yVarP->SaveQ); \
+// P98C-YXS    yVarP->CurrentInSaveQ = &(yVarP->SaveQ); \
+// P98C-YXS    yVarP->yInSignalPtr = 0; 
+// P98C-YXS #endif
+// P98C-YXS //#endif
+// P98C-YXS //#else
+// P98C-YXS #endif
+*/
+
+#if defined UNITEST
+#define os_process_begin(var_) \
+   TID            SelfId; \
+   memset ( (void *) yVarP, 0, sizeof ( var_ ) ); \
+   yVarP->Self = ( (struct args *) argv ) -> self; \
+   yVarP->SelfId = (unsigned char)( ( (struct args *) argv ) -> self_id ); \
+   yVarP->Offspring = SDL_NULL; \
+   yVarP->SaveQ.succ = &(yVarP->SaveQ); \
+   yVarP->SaveQ.pred = &(yVarP->SaveQ); \
+   yVarP->CurrentInSaveQ = &(yVarP->SaveQ); \
+   yVarP->yInSignalPtr = 0; 
+#else
+#define os_process_begin(var_) \
+   TID            SelfId; \
+   (void) argc; \
+   memset ( (void *) yVarP, 0, sizeof ( var_ ) ); \
+   yVarP->Self = ( (struct args *) argv ) -> self; \
+   yVarP->SelfId = (unsigned char)( ( (struct args *) argv ) -> self_id ); \
+   yVarP->Offspring = SDL_NULL; \
+   yVarP->SaveQ.succ = &(yVarP->SaveQ); \
+   yVarP->SaveQ.pred = &(yVarP->SaveQ); \
+   yVarP->CurrentInSaveQ = &(yVarP->SaveQ); \
+   yVarP->yInSignalPtr = 0; 
+#endif
+//#endif
+
+/**B*************************************************************************
+ * Macro:        os_process_loop
+ *---------------------------------------------------------------------------
+ * Purpose:      Free the consumed signal and wait for the next signal on the
+ *               input queue with the blocked method.
+ *
+ * Parameters:   None.
+ *
+ * Returns:      None.
+ ***E************************************************************************/
+
+#define os_process_loop(var_) \
+    os_process_loop_l: \
+        os_signal_free (var_##.yInSignalPtr); \
+        var_##.yInSignalPtr = os_signal_receive (var_##.Self);
+
+
+/**B*************************************************************************
+ * Macro:        os_process_vars
+ *---------------------------------------------------------------------------
+ * Purpose:      Generic header of the process variables.
+ *
+ * Parameters:   None.
+ *
+ * Returns:      None.
+ ***E************************************************************************/
+
+#define os_process_vars   PROCESS_VARS
+
+
+/**B*************************************************************************
+ * Macro:        OS_PROCESS_ID
+ *---------------------------------------------------------------------------
+ * Purpose:      Process Id of the current process
+ *
+ * Parameters:   None.
+ *
+ * Returns:      None.
+ ***E************************************************************************/
+
+#define os_current_process()  (yVarP->Self)
+
+
+/**B*************************************************************************
+ * Macro:        os_is_booting
+ *---------------------------------------------------------------------------
+ * Purpose:      Return 1 if the OS executes the boot procedure otherwise 0.
+ *
+ * Parameters:   None.
+ *
+ * Returns:      None.
+ ***E************************************************************************/
+
+extern SINT32 nu_is_booting(VOID);
+#define os_is_booting()   nu_is_booting()
+
+
+/**B*************************************************************************
+ * Macro:        os_sem_t
+ *---------------------------------------------------------------------------
+ * Purpose:      Semaphore data type
+ *
+ * Parameters:   None.
+ *
+ * Returns:      None.
+ ***E************************************************************************/
+
+typedef NU_SEMAPHORE os_sem_t;
+
+
+/**B*************************************************************************
+ * Macro:        os_sem_p
+ *---------------------------------------------------------------------------
+ * Purpose:      Semaphore pointer declaration
+ *
+ * Parameters:   None.
+ *
+ * Returns:      None.
+ ***E************************************************************************/
+
+typedef NU_SEMAPHORE *os_sem_p;
+
+
+/**B*************************************************************************
+ * Macro:        os_protect_t
+ *---------------------------------------------------------------------------
+ * Purpose:      Semaphore data type
+ *               This can oly be used in HISR context for Tasks use
+ *               os_sem_t
+ *
+ * Parameters:   None.
+ *
+ * Returns:      None.
+ ***E************************************************************************/
+
+typedef NU_PROTECT os_protect_t;
+
+
+/**B*************************************************************************
+ * Macro:        os_sem_addr
+ *---------------------------------------------------------------------------
+ * Purpose:      Address of a semaphore
+ *
+ * Parameters:   None.
+ *
+ * Returns:      None.
+ ***E************************************************************************/
+
+#define os_sem_addr(sem_)  &sem_
+
+
+/**B*************************************************************************
+ * Macros:        OS_SEM_[TYPE]
+ *---------------------------------------------------------------------------
+ * Purpose:      Define several styles of semaphores
+ *               order of pending task execution.
+ *               semaphore obtainer task acceleration
+ *               task preemption deactivation
+ *
+ * Parameters:   None.
+ *
+ * Returns:      None.
+ ***E************************************************************************/
+
+#define OS_SEM_FIFO 1
+#define OS_SEM_PRIORITY 2
+#define OS_SEM_CUSTOM_TYPES 3
+#define OS_SEM_CRIT_SECT OS_SEM_CUSTOM_TYPES
+#define OS_SEM_NO_PREEMPT (OS_SEM_CUSTOM_TYPES+1)
+#define OS_SEM_IRQ_LOCK (OS_SEM_CUSTOM_TYPES+2)
+#define OS_SEM_CRIT_SECT_SIMPLE (OS_SEM_CUSTOM_TYPES+3)
+#define OS_SEM_CS_DEFAULT OS_SEM_CRIT_SECT
+
+
+/**B*************************************************************************
+ * Macro:        os_sem_create, os_ssem_create, os_protect_create
+ *---------------------------------------------------------------------------
+ * Purpose:      Create a (static) semaphore and define the initial state. 1 means
+ *               do not block after the first call, otherwise use 0.
+ *
+ * Parameters:   sem_:           Pointer to the semaphore.
+ *               name_pref_:     Prefix of the semaphore's name.
+ *               name_no_:       Postfix of the name to make the name unique.
+ *               initial_count_: Initial semaphore count.
+ *
+ * Returns:      None.
+ ***E************************************************************************/
+
+#define os_ssem_create  os_sem_create
+#define os_protect_create(sem_, name_pref_, name_no_, initial_count_) 
+
+#if MS_OS_CRITICAL_SECTION_SUPPORT > 0
+extern VOID os_sem_create_t_func(NU_SEMAPHORE *sem_p, CHAR const*name_pref,
+                                         SINT32 name_no, SINT32 initial_count_, SINT32 sema_style);
+
+#define os_sem_create_t(sem_, name_pref_, name_no_, initial_count_, sema_style) \
+os_sem_create_t_func(&(sem_), name_pref_, name_no_, initial_count_, sema_style)
+
+#define os_sem_create(sem_, name_pref_, name_no_, initial_count_) \
+ os_sem_create_t(sem_, name_pref_, name_no_, initial_count_, OS_SEM_FIFO)
+
+#else
+
+#define os_sem_create(sem_, name_pref_, name_no_, initial_count_) \
+do { \
+    UINT32  status; \
+    status = NU_Create_Semaphore( &(sem_), name_pref_, (initial_count_), NU_FIFO); \
+    if (status != ZOSS_SUCCESS) \
+        zOss_ASSERT(0); \
+} while (0)
+
+
+#endif
+
+
+/**B*************************************************************************
+ * Macro:        os_sem_reset
+ *---------------------------------------------------------------------------
+ * Purpose:      Set the semaphore counter to the initial value.
+ *
+ * Parameters:   sem_:           Pointer to the semaphore.
+ *
+ * Returns:      None.
+ ***E************************************************************************/
+
+#define os_sem_reset(sem_)  \
+do { \
+    STATUS  status = NU_Reset_Semaphore ( &(sem_), 0 ); \
+    if (status != NU_SUCCESS) \
+        zOss_ASSERT(0); \
+} while (0)
+
+
+/**B*************************************************************************
+ * Macro:        os_sem_signal, os_protect
+ *---------------------------------------------------------------------------
+ * Purpose:      Releases a previously obtained semaphore. If one or 
+ *               more tasks are waiting, the first task is given the released
+ *               instance of the semaphore.  Otherwise, the semaphore instance
+ *               counter is simply incremented.
+ *
+ * Parameters:   sem_:           Pointer to the semaphore.
+ *
+ * Returns:      None.
+ ***E************************************************************************/
+
+#define os_protect(sem_)  
+
+#if MS_OS_CRITICAL_SECTION_SUPPORT > 0
+
+extern VOID os_sem_signal_func(NU_SEMAPHORE *sem_p);
+#define os_sem_signal(sem_)  \
+os_sem_signal_func(&(sem_))
+
+#else
+
+#define os_sem_signal(sem_)  \
+do { \
+    UINT32  status = NU_Release_Semaphore(&(sem_)); \
+    if (status != ZOSS_SUCCESS) \
+        zOss_ASSERT(0); \
+} while (0)
+
+#endif
+
+
+/**B*************************************************************************
+ * Macro:        os_sem_wait, os_unprotect
+ *---------------------------------------------------------------------------
+ * Purpose:      Decrement the semphore counter by 1. If the counter is
+ *               greater than zero at the time of this call, this function can
+ *               be completed immediately, otherwise suspension.
+ *
+ * Parameters:   sem_:           Pointer to the semaphore.
+ *
+ * Returns:      None.
+ ***E************************************************************************/
+
+
+#define os_unprotect(sem_)  
+
+#if MS_OS_CRITICAL_SECTION_SUPPORT > 0
+
+extern VOID os_sem_wait_func (NU_SEMAPHORE *sem_p);
+#define os_sem_wait(sem_)  os_sem_wait_func(&(sem_))
+
+#else
+#define os_sem_wait(sem_)  \
+do { \
+    UINT32 status = NU_Obtain_Semaphore ( &(sem_), NU_SUSPEND ); \
+    if (status != ZOSS_SUCCESS) \
+        zOss_ASSERT(0); \
+} while (0)
+#endif
+
+
+/**B*************************************************************************
+ * Macro:        os_sem_kill, os_ssem_kill,  os_protect_kill
+
+ *---------------------------------------------------------------------------
+ * Purpose:      Destroy a (static) semphore.
+ *
+ * Parameters:   sem_:           Pointer to the semaphore.
+ *
+ * Returns:      None.
+ ***E************************************************************************/
+
+#define os_protect_kill
+#define os_ssem_kill  os_sem_kill
+
+
+#if MS_OS_CRITICAL_SECTION_SUPPORT > 0
+
+extern VOID os_sem_kill_func(NU_SEMAPHORE *sem_p);
+
+#define os_sem_kill(sem_)  \
+os_sem_kill_func(&(sem_))
+
+#else
+#define os_sem_kill(sem_)  \
+do { \
+    STATUS status = NU_Delete_Semaphore ( &(sem_) ); \
+    if (status != NU_SUCCESS) \
+        zOss_ASSERT(0); \
+} while (0)
+#endif
+
+
+
+/**B*************************************************************************
+ * Macro:        os_signal_t
+ *---------------------------------------------------------------------------
+ * Purpose:      Generic part of an I/O signal.
+ *
+ * Parameters:   None.
+ *
+ * Returns:      None.
+ ***E************************************************************************/
+
+typedef xSignalHeaderRec os_signal_t;
+
+
+/**B*************************************************************************
+ * Macro:        os_print
+ *---------------------------------------------------------------------------
+ * Purpose:      Prints strings to the trace output.
+ *
+ * Parameters:   str_: String to be printed.
+ *
+ * Returns:      None
+ ***E************************************************************************/
+#if 0
+#define os_print(str_)    hwtrc_print (str_)
+#define os_task_info(state_, self_id_, sig_cod_, msg_, len_)  \
+            hwtrc_task_info(state_, self_id_, sig_cod_, msg_, len_) 
+
+    
+/**B*************************************************************************
+ * Macro:        os_nprint
+ *---------------------------------------------------------------------------
+ * Purpose:      Prints the first n chars of a string to the trace output.
+ *
+ * Parameters:   str_: string
+ *               n_:   number of chars in str_
+ *
+ * Returns:      None
+ ***E************************************************************************/
+
+#define os_nprint(str_, n_)    hwtrc_write (str_, n_)
+
+    
+/**B*************************************************************************
+ * Macro:        os_write
+ *---------------------------------------------------------------------------
+ * Purpose:      Send n bytes to the trace output.
+ *
+ * Parameters:   buf_: char sequence
+ *               n_: number of chars in buf_
+ *
+ * Returns:      None
+ ***E************************************************************************/
+
+#define os_write(buf_, n_)    hwtrc_write (buf_, n_)
+#endif
+    
+/**B*************************************************************************
+ * Macro:        os_signal_alloc
+ *---------------------------------------------------------------------------
+ * Purpose:      Allocation of a message buffer for a signal from the 
+ *               specified partition pool.
+ *
+ * Parameters:   signal_id_:   Corresponding ID (process index + message id)
+ *                             to the message type.
+ *               signal_type_: Message type used to allocate a message buffer.
+ *
+ * Returns:      Pointer to the allocated message buffer.
+ ***E************************************************************************/
+
+#define os_signal_alloc(signal_id_, signal_type_) \
+     { xSignalHeader yOutputSignalPtr = \
+       alloc_sig( sizeof (signal_type_) ); \
+       yOutputSignalPtr->Sender = 0; \
+       yOutputSignalPtr->SignalCode = (signal_id_);
+    
+    
+/**B*************************************************************************
+ * Macro:        os_signal_alloc_from
+ *---------------------------------------------------------------------------
+ * Purpose:      Allocation of a message buffer for a signal from the 
+ *               specified partition pool.
+ *
+ * Parameters:   sender_pid_:  Used to send back signals.
+ *               signal_id_:   Corresponding ID (process index + message id)
+ *                             to the message type.
+ *               signal_type_: Message type used to allocate a message buffer.
+ *
+ * Returns:      Pointer to the allocated message buffer.
+ ***E************************************************************************/
+
+#define os_signal_alloc_from(sender_pid_, signal_id_, signal_type_) \
+     { xSignalHeader yOutputSignalPtr = \
+       alloc_sig( sizeof (signal_type_) ); \
+       yOutputSignalPtr->Sender = (sender_pid_); \
+       yOutputSignalPtr->SignalCode = (signal_id_);
+    
+
+/**B*************************************************************************
+ * Macro:        os_signal_alloc_from_to
+ *---------------------------------------------------------------------------
+ * Purpose:      Allocation of a message buffer for a signal from the 
+ *               specified partition pool with generic receiver.
+ *
+ * Parameters:   signal_id_:   Corresponding ID (process index + message id)
+ *                             to the message type.
+ *               signal_type_: Message type used to allocate a message buffer.
+ *               receiver_:    PID of the receiver process.*
+ *               
+ * Returns:      Pointer to the allocated message buffer.
+ ***E************************************************************************/
+
+#define os_signal_alloc_from_to(sender_pid_, receiver_, signal_id_, signal_type_) \
+     yOutputSignalPtr = \
+       alloc_sig(sizeof(signal_type_)); \
+       yOutputSignalPtr->Sender = (sender_pid_); \
+       yOutputSignalPtr->SignalCode = (signal_id_); 
+    
+
+/**B*************************************************************************
+ * Macro:        os_signal_alloc_to
+ *---------------------------------------------------------------------------
+ * Purpose:      Allocation of a message buffer for a signal from the 
+ *               specified partition pool with generic receiver.
+ *
+ * Parameters:   signal_id_:   Corresponding ID (process index + message id)
+ *                             to the message type.
+ *               signal_type_: Message type used to allocate a message buffer.
+ *               receiver_:    PID of the receiver process.*
+ *               
+ * Returns:      Pointer to the allocated message buffer.
+ ***E************************************************************************/
+
+#define os_signal_alloc_to(receiver_, signal_id_, signal_type_) \
+     yOutputSignalPtr = \
+       alloc_sig(sizeof(signal_type_)); \
+       yOutputSignalPtr->SignalCode = (signal_id_); 
+
+
+/**B*************************************************************************
+ * Macro:        os_signal_paramassign
+ *---------------------------------------------------------------------------
+ * Purpose:      Set a scalar paramter value.
+ *
+ * Parameters:   sig_:      Pointer to the signal header.
+ *
+ *               param_no_: Number of the parameter to be set.
+ *
+ *               value_:    Source value.
+ *
+ * Returns:      None
+ ***E************************************************************************/
+
+#define os_signal_paramassign(sig_, param_no_, value_) \
+  ((yPDef_##sig_ *) OUTSIGNAL_DATA_PTR)->Param##param_no_ = (value_)
+
+ 
+/**B*************************************************************************
+ * Macro:        os_signal_paramcopy
+ *---------------------------------------------------------------------------
+ * Purpose:      Copies parameter values into a signal message buffer.
+ *
+ * Parameters:   sig_:      Pointer to the signal header.
+ *
+ *               param_no_: Number of the parameter to be set
+ *
+ *               src_adr_:  Source address
+ *
+ *               size_t:    Parameter size
+ *
+ * Returns:      None
+ ***E************************************************************************/
+
+#define os_signal_paramcopy(sig_, param_no_, src_adr_, size_) \
+ memcpy( (void *) &(((yPDP_##sig_)(OUTSIGNAL_DATA_PTR))->Param##param_no_), \
+         (void *)(src_adr_), \
+         (size_) );
+
+ 
+/**B*************************************************************************
+ * Macro:        os_signal_paramreset
+ *---------------------------------------------------------------------------
+ * Purpose:      Resets parameter values of a signal message buffer.
+ *
+ * Parameters:   sig_:      Pointer to the signal header.
+ *
+ *               param_no_: Number of the parameter to be reset
+ *
+ *               size_t:    Parameter size
+ *
+ * Returns:      None
+ ***E************************************************************************/
+
+#define os_signal_paramreset(sig_, param_no_, size_)
+    
+ 
+/**B*************************************************************************
+ * Macro:        os_signal_free
+ *---------------------------------------------------------------------------
+ * Purpose:      Deallocation of a message buffer for a signal. 
+ *
+ * Parameters:   signal_ptr: pointer to the signal allocated with
+ *               os_signal_alloc().
+ *
+ * Returns:      None.
+ ***E************************************************************************/
+ 
+#define os_signal_free  free_sig
+
+
+/**B*************************************************************************
+ * Macro:        os_signal_id
+ *---------------------------------------------------------------------------
+ * Purpose:      Extract the signal id from the received input signal
+ *
+ * Parameters:   signal_ptr:: pointer to the received signal.
+ *
+ * Returns:      None.
+ ***E************************************************************************/
+
+#define os_signal_id(signal_ptr_)  SIGNAL_NAME (signal_ptr_->SignalCode, 0)
+
+
+/**B*************************************************************************
+ * Macro:        os_signal_receive
+ *---------------------------------------------------------------------------
+ * Purpose:      Wait for a signal to arrive. After having performed a
+ *               transition,
+ *               each process waits here for the next signal to arrive. Once
+ *               a signal is available, it is taken out of the queue and the 
+ *               next transition takes place.
+ *
+ * Parameters:   None.
+ *
+ * Returns:      Pointer to message buffer.
+ ***E************************************************************************/
+
+#define os_signal_receive(self_)  receive_sig(self_)
+
+
+/**B*************************************************************************
+ * Macro:        os_signal_route
+ *---------------------------------------------------------------------------
+ * Purpose:      Route and send signal according to signal code.
+ *               The signal code is an element of the generic signal header.
+ *               This element is set in os_signal_alloc().
+ *
+ * Parameters:   None.
+ *
+ * Returns:      None.
+ ***E************************************************************************/
+
+#define os_signal_route(signal_id_, signal_name_) \
+    send_sig_no_to (yOutputSignalPtr, signal_id_, signal_name_); }
+
+
+/**B*************************************************************************
+ * Macro:        os_signal_send
+ *---------------------------------------------------------------------------
+ * Purpose:      The given signal is send to the specified task queue.
+ *
+ * Parameters:   receiver_: PID of the receiver process.
+ *
+ * Returns:      None.
+ ***E************************************************************************/
+
+#define os_signal_send(receiver_, signal_name_) \
+    SEND_SIG (yOutputSignalPtr, receiver_, signal_name_ );
+
+
+/**B*************************************************************************
+ * Macro:        os_signal_vars
+ *---------------------------------------------------------------------------
+ * Purpose:      Generic signal header.
+ *
+ * Parameters:   None.
+ *
+ * Returns:      None.
+ ***E************************************************************************/
+
+#define os_signal_vars   SIGNAL_VARS
+
+
+/**B*************************************************************************
+ * Macro:        os_timer_t
+ *---------------------------------------------------------------------------
+ * Purpose:      Type definition of a timer mapped to an input signal.
+ *
+ * Parameters:   None.
+ *
+ * Returns:      None.
+ ***E************************************************************************/
+
+typedef char  os_timer_t;  /* It is a dummy type. */
+
+
+/**B*************************************************************************
+ * Macro:        os_timer_start
+ *---------------------------------------------------------------------------
+ * Purpose:      A timer is started with an expiry time relative to the 
+ *               current system time. The call of os_timer_start()
+ *               causes an implicit stop of the timer.
+ *               The timer queue, the processes' save and input queues are
+ *               searched for the timer signal.
+ *               If the timer signal can be found there, it is taken from the
+ *               queue and the timer is started anew. If the timer is neither
+ *               running nor can the timer signal be found in the process
+ *               queues, a message buffer for the timer signal is allocated.
+ *               This block (re-used or newly allocated) is
+ *               then enqueued at the proper place in the timer queue.
+ *
+ * Parameters:   Import of the process variables as yVarP with the generic 
+ *               header (os_process_var).
+ *               t_name_: name of the timer variable, must be an element of 
+ *               the process variables.
+ *               t_id_: timer id, used as input signal.
+ *               secs_: number of seconds (long).
+ *               nano_secs_: nano seconds (long).
+ *
+ * Returns:      None.
+ ***E************************************************************************/
+
+#define os_timer_start(t_name_, t_id_, tick_expr_,sample_id) \
+do { \
+    SDL_SET_DUR (0, tick_expr_, t_id_, 0, t_name_, "",sample_id); \
+} while (0)
+
+
+/**B*************************************************************************
+ * Macro:        os_timer_stop
+ *---------------------------------------------------------------------------
+ * Purpose:      A timer is stopped.
+ *               The timer queue, the processes' save and input queues are
+ *               searched for the timer signal. 
+ *               If the timer signal can be found there, it is removed from
+ *               the queue, and the timer signal (i. e. the message buffer)
+ *               is freed.
+ *
+ * Parameters:   Import of the process variables as yVarP with the generic
+ *               header (os_process_var).
+ *               t_name_: name of the timer variable,
+ *                        must be an element of the process variables.
+ *               t_id_: timer id, used as input signal.
+ *
+ * Returns:      None.
+ ***E************************************************************************/
+
+#define os_timer_stop(t_name_, t_id_) \
+do { \
+    SDL_RESET (t_id_, 0, t_name_, ""); \
+} while (0)
+
+
+/**B*************************************************************************
+ * Macro:        os_timer_stop_with_para
+ *---------------------------------------------------------------------------
+ * Purpose:      A timer is stopped.
+ *               The timer queue, the processes' save and input queues are
+ *               searched for the timer signal. 
+ *               If the timer signal can be found there, it is removed from
+ *               the queue, and the timer signal (i. e. the message buffer)
+ *               is freed.
+ *
+ * Parameters:   Import of the process variables as yVarP with the generic
+ *               header (os_process_var).
+ *               t_name_: name of the timer variable,
+ *                        must be an element of the process variables.
+ *               t_id_: timer id, used as input signal.
+ *
+ * Returns:      None.
+ ***E************************************************************************/
+
+#define os_timer_stop_with_para(t_name_, t_id_, t_param,sample_id) \
+do { \
+    SDL_Reset (t_id_, t_param, (t_process_vars *) yVarP,sample_id); \
+} while (0)
+
+
+/**B*************************************************************************
+ * Macro:        os_timer_start_with_para
+ *---------------------------------------------------------------------------
+ * Purpose:      A timer is started with an expiry time relative to the 
+ *               current system time. The call of os_timer_start()
+ *               causes an implicit stop of the timer.
+ *               The timer queue, the processes' save and input queues are
+ *               searched for the timer signal.
+ *               If the timer signal can be found there, it is taken from the
+ *               queue and the timer is started anew. If the timer is neither
+ *               running nor can the timer signal be found in the process
+ *               queues, a message buffer for the timer signal is allocated.
+ *               This block (re-used or newly allocated) is
+ *               then enqueued at the proper place in the timer queue.
+ *
+ * Parameters:   Import of the process variables as yVarP with the generic 
+ *               header (os_process_var).
+ *               t_name_: name of the timer variable, must be an element of 
+ *               the process variables.
+ *               t_id_: timer id, used as input signal.
+ *               secs_: number of seconds (long).
+ *               nano_secs_: nano seconds (long).
+ *
+ * Returns:      None.
+ ***E************************************************************************/
+
+#if defined (SDL_SET_DUR_EX)
+ 
+#define os_timer_soft_start_with_para(t_name_, t_id_, t_param, earliest_tick_expr_, latest_tick_expr_,sample_id) \
+do { \
+    SDL_Set_Dur_Ex (earliest_tick_expr_, latest_tick_expr_, t_id_, t_param, (t_process_vars *) yVarP,sample_id); \
+} while (0)
+
+#define os_timer_start_with_para(t_name_, t_id_, t_param, tick_expr_,sample_id) \
+do { \
+    SDL_Set_Dur (tick_expr_, t_id_, t_param, (t_process_vars *) yVarP,sample_id); \
+} while (0)
+
+#else
+ 
+#define os_timer_start_with_para(t_name_, t_id_, t_param, tick_expr_,sample_id) \
+do { \
+    SDL_Set_Dur (tick_expr_, t_id_, t_param, (t_process_vars *) yVarP,sample_id); \
+} while (0)
+
+#define os_timer_soft_start_with_para(t_name_, t_id_, t_param, earliest_tick_expr_, latest_tick_expr_,sample_id) \
+do { \
+    SDL_Set_Dur (earliest_tick_expr_, t_id_, t_param, (t_process_vars *) yVarP,sample_id); \
+} while (0)
+ 
+#endif
+
+
+/**B*************************************************************************
+ * Macro:        os_is_task_call
+ *---------------------------------------------------------------------------
+ * Purpose:    Nucleus often crashes if a TASK functions are called 
+ *             from HISR and LISR  context     
+ *             
+ *
+ * Parameters: NONE
+ *
+ * Returns:   0 if it is a HISR or LISR context  
+ *            1 if it is a TASK context
+ ***E************************************************************************/
+
+#define os_is_task_call() (NU_Current_Task_Pointer() != NULL)
+
+
+/*===========================================================================
+EXPORTED TYPE DECLARATIONS
+===========================================================================*/
+
+typedef void (* os_timeout_handler) (void *arg);
+
+
+/*============================================================================
+EXPORTED FUNCTIONS
+============================================================================*/
+
+/**B************************************************************************
+ * Function:     os_init
+ *--------------------------------------------------------------------------
+ * Purpose:      Module initialization for MS OS abstraction layer.
+ *
+ * Parameters:   None
+ *
+ * Returns:      None
+ ***E***********************************************************************/
+
+extern VOID os_init(VOID);
+
+
+/**B*************************************************************************
+ * Function:     os_sdlpid_current
+ *---------------------------------------------------------------------------
+ * Purpose:      Return the SDL pid of the current task.
+ *
+ * Parameters:   None
+ *
+ * Returns:      SDL pid.
+ ***E************************************************************************/
+
+extern OS_pid_t os_sdlpid_current(VOID);
+
+ 
+/**B*************************************************************************
+ * Function:     os_sdlpid_deregister
+ *---------------------------------------------------------------------------
+ * Purpose:      Remove the pid of an SDL process.
+ *
+ * Parameters:   None
+ *
+ * Returns:      None
+ ***E************************************************************************/
+
+extern VOID os_sdlpid_deregister(VOID);
+
+ 
+/**B*************************************************************************
+ * Function:     os_sdlpid_register
+ *---------------------------------------------------------------------------
+ * Purpose:      os_sdlpid_current
+ *---------------------------------------------------------------------------
+ * Purpose:      Return the SDL pid of the current task.
+ *
+ * Parameters:   None
+ *
+ * Returns:      SDL pid.
+ ***E************************************************************************/
+
+extern OS_pid_t os_sdlpid_current(VOID);
+ 
+ 
+/**B*************************************************************************
+ * Function:     os_sdlpid_deregister
+ *---------------------------------------------------------------------------
+ * Purpose:      Save the pid of an SDL process.
+ *
+ * Parameters:   SDL pid
+ *
+ * Returns:      None
+ ***E************************************************************************/
+
+// P98C-YXS extern VOID os_sdlpid_register(OS_pid_t sdl_pid);
+
+ 
+/**B*************************************************************************
+ * Macro:        os_sleep_ms
+ *---------------------------------------------------------------------------
+ * Purpose:      os_sleep_ms() makes the current process sleep until ms
+ *               milliseconds have  elapsed.
+ *
+ * Parameters:   unsigned long ms: # of milliseconds
+ *
+ * Returns:      None.
+ ***E************************************************************************/
+
+extern VOID os_sleep_ms(UNSIGNED ms); 
+
+
+/**B*************************************************************************
+ * Macro:        os_task_create
+ *---------------------------------------------------------------------------
+ * Purpose:      This procedure creates an application task. 
+ *
+ * Parameters:
+ * task        Pointer to th user-supplied task control block.
+ * name        Pointer to an 8 character name for the task.
+ * entry       Specifies the entry function of the task.
+ * stack       Designates the starting memory location of the tasks
+ *             stack area.
+ * stack_size  Specifies the number of bytes in the stack.
+ * priority    Specifies a priority value between 0 and 255. The lower
+ *             numeric value, the higher the tasks priority.
+ *
+ * Returns:    1 indicates successful completion of the service,
+ *             otherwise 0 or soft crash..
+ ***E************************************************************************/
+typedef NU_TASK *os_task_id_t;
+typedef VOID    *os_task_stack_t;
+typedef VOID (*os_task_func_t)(SINT32);
+typedef OPTION  os_task_prio_t;
+
+// P98C-YXS extern SINT32 os_task_create (os_task_id_t     *id,
+// P98C-YXS 			   CHAR             *name,
+// P98C-YXS 			   os_task_func_t    entry,
+// P98C-YXS 			   os_task_stack_t  *stack,
+// P98C-YXS 			   UNSIGNED            stack_size,
+// P98C-YXS 			   os_task_prio_t    priority);
+
+/**B*************************************************************************
+ * Macro:        os_timeout
+ *---------------------------------------------------------------------------
+ * Purpose:      Schedule a timeout a specified amount of seconds in the
+ *               future. When the timeout occurs, the specified timeout
+ *               handler will be called. The handler will be passed the
+ *               "arg" argument when called.
+ *
+ * Parameters:   unsigned char secs:    # of seconds
+ *               os_timeout_handler h:  timer handler.
+ *               void *arg:             argument of the timer handler.
+ *
+ * Returns:      None.
+ ***E************************************************************************/
+
+// P98C-YXS extern VOID os_timeout(UINT8 secs, os_timeout_handler h, VOID *arg);
+
+
+/**B*************************************************************************
+ * Macro:        os_timeout_ms
+ *---------------------------------------------------------------------------
+ * Purpose:      Schedule a timeout a specified amount of milliseconds in the
+ *               future. When the timeout occurs, the specified timeout
+ *               handler will be called. The handler will be passed the
+ *               "arg" argument when called.
+ *
+ * Parameters:   unsigned long ms:      # of seconds
+ *               os_timeout_handler h:  timer handler.
+ *               void *arg:             argument of the timer handler.
+ *
+ * Returns:      None.
+ ***E************************************************************************/
+ 
+// P98C-YXS extern VOID os_timeout_ms(UNSIGNED ms, os_timeout_handler h, VOID *arg);
+ 
+
+/**B*************************************************************************
+ * Macro:        os_untimeout
+ *---------------------------------------------------------------------------
+ * Purpose:      Deinstall the timeout handler activated about os_timeout or
+ *               about os_timeout_ms.
+ *
+ * Parameters:   os_timeout_handler h:  timer handler.
+ *               void *arg:             argument of the timer handler.
+ *
+ * Returns:      None.
+ ***E************************************************************************/
+
+// P98C-YXS extern VOID os_untimeout(os_timeout_handler h, VOID *arg);
+ 
+#endif 
+
+/* ms_os.h ends here. */
+
diff --git a/cp/ps/modem/psbase/inc/msexport.h b/cp/ps/modem/psbase/inc/msexport.h
new file mode 100644
index 0000000..4310739
--- /dev/null
+++ b/cp/ps/modem/psbase/inc/msexport.h
@@ -0,0 +1,8 @@
+
+#ifndef __MSEXPORT__
+#define __MSEXPORT__
+
+#undef  GLOBAL
+#define GLOBAL
+
+#endif /* __MSEXPORT__ */
diff --git a/cp/ps/modem/psbase/inc/msimport.h b/cp/ps/modem/psbase/inc/msimport.h
new file mode 100644
index 0000000..d998f1a
--- /dev/null
+++ b/cp/ps/modem/psbase/inc/msimport.h
@@ -0,0 +1,7 @@
+#ifndef __MSIMPORT__
+#define __MSIMPORT__
+
+#define GLOBAL extern
+
+#endif /* __MSIMPORT__ */
+
diff --git a/cp/ps/modem/psbase/inc/proc_id.h b/cp/ps/modem/psbase/inc/proc_id.h
new file mode 100644
index 0000000..d28ed87
--- /dev/null
+++ b/cp/ps/modem/psbase/inc/proc_id.h
@@ -0,0 +1,149 @@
+/* --------------------------------------------------------------- */
+/* This document contains proprietary information belonging to     */
+/* debis Systemhaus GEI. Passing on and copying of this document,  */
+/* use and communication of its contents is not permitted without  */
+/* prior written authorisation.                                    */
+/* --------------------------------------------------------------- */
+
+/* ===========================================================================
+** Project:              Mobile Station (MS)
+**
+** Revision Information:
+**    File name: proc_id.h
+**    Version:   /main/system/12
+**    Date:   2007-07-04    9:48:23
+** ===========================================================================
+** Contents:
+**
+** ===========================================================================
+** History:
+**
+** Date         Author          Comment
+** 06-08-02     MLY             adapted for NAS+AS+L1 system, release 2
+** 30-09-02     MLY             removed P_snp
+**
+** ===========================================================================
+*/
+
+#ifndef PROC_ID_H
+#define PROC_ID_H
+
+
+/*** statically created processes ***/
+
+/* ===================== */
+/*  GPRS Access Stratum  */
+/* ===================== */
+
+/* L1G */
+#define P_l1g   1
+
+#ifdef Z_SEND_TO_SIMPHY 
+#define P_l1g_single   ( P_l1g + 1 )
+/* AUD */
+#define P_aud    ( P_l1g_single + 1 )
+#else
+#define P_l1g_single  ( P_l1g + 1 )
+
+#define P_aud    ( P_l1g_single + 1 )
+#endif
+
+#define P_tic   ( P_aud + 1 )
+
+/******ÆÕͨÈÎÎñ*********/
+/* mmia */
+/* #define P_mmia  ( 0xff00 + 1 ) */
+
+/* gsma */
+/* #define P_gsma  ( P_mmia + 1 ) */
+/* ӦЭÒéÕ»ÐèÇóÐÞ¸Ä2010-6-10 */
+#define P_gsma  ( 0x7f00 + 1 )
+
+/* taf */
+#define P_taf   ( P_gsma + 1 )
+
+/* LAPDm */
+#define P_dll   ( P_taf + 1 )
+#define P_dll_inst ( P_dll + 1 )
+
+/* LL */
+#define P_llc  ( P_dll_inst + 1 )
+
+/* MA */
+#define P_mac  ( P_llc + 1 )
+
+/* RL */
+#define P_rlc  ( P_mac + 1 )
+
+/* GRRC */
+#define P_rrc  ( P_rlc + 1 )
+
+/* GRRC */
+#define P_grr  ( P_rrc + 1 )
+
+/* SNDCP */
+#define P_snp  ( P_grr + 1 )
+
+
+/* CBS */
+#define P_cbs   ( P_snp + 1 )
+
+/* urrc */
+#define P_urrc  ( P_cbs + 1 )
+
+/* l1t */
+#define P_l1t  ( P_urrc + 1 )
+
+/* td phy */
+#define P_tdPhy ( P_l1t + 1 )
+
+/* l1e */
+#define P_l1e  ( P_tdPhy + 1 )
+
+/* lte phy */
+#define P_ltePhy ( P_l1e + 1 )
+
+/* l1w */
+#define P_l1w  ( P_ltePhy + 1 )
+
+/* wphy */
+#define P_wPhy ( P_l1w + 1 )
+/* TC */
+#define P_tc   ( P_wPhy + 1 )
+
+/* gsma_2 */
+#define P_gsma_2  ( P_tc + 1 )
+
+/* taf_2 */
+#define P_taf_2   ( P_gsma_2 + 1 )
+
+/* LAPDm_2 */
+#define P_dll_2   ( P_taf_2 + 1 )
+#define P_dll_inst_2 ( P_dll_2 + 1 )
+
+/* LL_2 */
+#define P_llc_2  ( P_dll_inst_2 + 1 )
+
+/* MA_2*/
+#define P_mac_2  ( P_llc_2 + 1 )
+
+/* RL_2 */
+#define P_rlc_2  ( P_mac_2 + 1 )
+
+/* GRRC_2 */
+#define P_rrc_2  ( P_rlc_2 + 1 )
+
+/* GRRC_2 */
+#define P_grr_2  ( P_rrc_2 + 1 )
+
+/* SNDCP_2 */
+#define P_snp_2  ( P_grr_2 + 1 )
+
+/* TC_2 */
+#define P_tc_2  ( P_snp_2 + 1 )
+
+#define P_last   P_tic
+
+
+#endif /* PROC_ID_H */
+
diff --git a/cp/ps/modem/psbase/inc/ps_os.h b/cp/ps/modem/psbase/inc/ps_os.h
new file mode 100644
index 0000000..f27883c
--- /dev/null
+++ b/cp/ps/modem/psbase/inc/ps_os.h
@@ -0,0 +1,40 @@
+/************************************************************************

+* °æÈ¨ËùÓÐ (C)2001,ÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£

+* 

+* ÎļþÃû³Æ£º nu_os.h

+* Îļþ±êʶ£º 

+* ÄÚÈÝÕªÒª£º 

+*

+* ÐÞ¸ÄÈÕÆÚ     °æ±¾ºÅ     Ð޸ıê¼Ç     ÐÞ¸ÄÈË	     ÐÞ¸ÄÄÚÈÝ      

+* ---------------------------------------------------------------------

+* 2007/11/24	            V0.5	                                      ¹¨Òí	         create

+************************************************************************/

+

+

+/**************************************************************************

+ *                        Í·Îļþ°üº¬                                      *

+ **************************************************************************/

+

+ 

+#include "base_api.h"

+

+#ifndef PS_OS_H

+#define PS_OS_H

+

+#define SDL_STARTUP_SIGNAL   (SIGREFTYPE) ~0

+

+#define enqueue( list, elem ) \

+  (elem)->succ = (list)->succ; \

+  (elem)->pred = (list);		   \

+  (list)->succ->pred = (elem); \

+  (list)->succ = (elem);

+

+#define dequeue(  elem ) \

+  (elem)->succ->pred = (elem)->pred; \

+  (elem)->pred->succ = (elem)->succ;

+

+

+extern UINT32 create_queue (t_queue *queue);

+extern VOID free_queue(xSignalHeader list);

+

+#endif 

diff --git a/cp/ps/modem/psbase/inc/ptf.h b/cp/ps/modem/psbase/inc/ptf.h
new file mode 100644
index 0000000..98d8890
--- /dev/null
+++ b/cp/ps/modem/psbase/inc/ptf.h
@@ -0,0 +1,53 @@
+/*******************************************************************************

+* °æÈ¨ËùÓÐ (C)2011, ÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£

+* 

+* ÎļþÃû³Æ:     ptf.h

+* Îļþ±êʶ:     ptf.h

+* ÄÚÈÝÕªÒª:     ptf stands for platform£¬¸ÃÍ·Îļþ°üº¬ºÍ²Ù×÷ϵͳƽ̨Ïà¹ØµÄÖжϱ£´æ

+                ºÍÖжϻָ´ºê¶¨ÒåÒÔ¼°Ò»Ð©ÖжϱêÖ¾Öµ

+* ʹÓ÷½·¨:     #include "ptf.h"

+* 

+* ÐÞ¸ÄÈÕÆÚ        °æ±¾ºÅ      Ð޸ıê¼Ç        ÐÞ¸ÄÈË          ÐÞ¸ÄÄÚÈÝ

+* ------------------------------------------------------------------------------

+* 2011/12/09      V1.0        Create          ÁõÑÇÄÏ          ´´½¨

+* 

+*******************************************************************************/

+

+#ifndef _PTF_H

+#define _PTF_H

+

+/*******************************************************************************

+*                                   Í·Îļþ                                     *

+*******************************************************************************/

+#include "oss_api.h"

+

+

+/*******************************************************************************

+*                                   ºê¶¨Òå                                     *

+*******************************************************************************/

+#define ENABLE_INT   (0x1000)

+#define DISABLE_INT  (~ENABLE_INT)

+#define CLEAR_INT    (0x4000)

+#define PENDING_INT  (0x2000)

+

+# define PTF_IRQ_DISABLE        ZOSS_DISABLE_IRQ()

+# define PTF_IRQ_ENABLE         ZOSS_ENABLE_IRQ()

+# define PTF_IRQ_DISABLE_QUICK  ZOSS_DISABLE_IRQ_FAST()

+# define PTF_IRQ_ENABLE_QUICK   ZOSS_ENABLE_IRQ_FAST()

+

+/*******************************************************************************

+*                                Êý¾ÝÀàÐͶ¨Òå                                  *

+*******************************************************************************/

+

+

+/*******************************************************************************

+*                                È«¾Ö±äÁ¿ÉùÃ÷                                  *

+*******************************************************************************/

+

+

+/*******************************************************************************

+*                                È«¾Öº¯ÊýÉùÃ÷                                  *

+*******************************************************************************/

+

+#endif	// #ifndef _PTF_H

+

diff --git a/cp/ps/modem/psbase/inc/sctpred.h b/cp/ps/modem/psbase/inc/sctpred.h
new file mode 100644
index 0000000..c03b1c5
--- /dev/null
+++ b/cp/ps/modem/psbase/inc/sctpred.h
@@ -0,0 +1,3076 @@
+/* ANP: Assumption: host system defines 'XENV' and 'SDL_SIMULATION'. This is true in UMTS case. */
+/* To find the 'else' and 'endif' clause search for: 'SDTENV && SDL_SIMULATION'                   */
+
+/******************************************************************************
+*
+*                               (C) Danish Wireless Design
+*
+* $RCSfile: sctpred.h,v $
+*
+* $Author: pbo $
+* $Revision: 1.4 $
+* $Date: 2001/07/18 13:01:54 $
+*
+* Description:
+*
+*******************************************************************************/
+
+#ifndef X_SCTPRED_H
+#define X_SCTPRED_H
+
+
+/* This file contains implementation of the predefined data types
+   except PId. The functions defined here can be found in the file
+   sctpred.c.
+*/
+
+/*
+FILE INDEX
+00   Some utility macros
+01   Typedef, Default value, Literals
+02   Prototypes and macros for the operators of the data types
+03   Read and Write functions
+04   Generator String
+05   Generator Array  (array that cannot become array in C)
+06   Generator Powerset  (limited and discrete component type)
+07   Generator Powerset  (general component type)
+*/
+
+/****+***************************************************************
+00   Some utility macros
+********************************************************************/
+
+/* Macros used in the generator implementations */
+
+#ifndef XENUM_TYPE
+#define XENUM_TYPE int
+#endif
+
+#ifndef XNOUSE_OPFUNCS
+#define T_SDL_OPFUNCS(P) , P
+#else
+#define T_SDL_OPFUNCS(P)
+#endif
+
+
+#ifdef XECSOP
+#define xReportStringError(S1,S2)   xSDLOpError(S1,S2);
+#else
+#define xReportStringError(S1,S2)
+#endif
+
+
+/****+***************************************************************
+01   Typedef, Default value, Literals
+********************************************************************/
+/****+***************************************************************
+     NEW FOR TAU 4.2
+********************************************************************/
+/*
+FILE INDEX
+01   Assignment macros
+02   SDL predefined data types
+03   Utility functions
+04   Read and Write functions
+*/
+
+#ifndef xOffsetOf
+#define xOffsetOf(type, field)  ((xptrint) &((type *) 0)->field)
+#endif
+
+/****+***************************************************************
+     Type info nodes
+********************************************************************/
+/*---+---------------------------------------------------------------
+     Boolean
+-------------------------------------------------------------------*/
+/*xlb20080717
+#if !defined(X_COMPACT_BOOL)
+typedef int     SDL_boolean;
+#else
+typedef unsigned char     SDL_boolean;
+#endif
+*/
+#define xDef_SDL_Boolean(V)       (*(V) = (SDL_Boolean)0)
+#define yDef_SDL_Boolean(V)       xDef_SDL_Boolean(V)
+#define yAssF_SDL_Boolean(V,E,A)  (V = E)
+#define yEqF_SDL_Boolean(E1,E2)   ((E1) == (E2))
+#define yNEqF_SDL_Boolean(E1,E2)  ((E1) != (E2))
+#define ySrtN_SDL_Boolean         xSrtN_SDL_Boolean
+
+#define SDL_False 0
+#define SDL_false 0
+#define SDL_True  1
+#define SDL_true  1
+
+
+/*---+---------------------------------------------------------------
+     Character
+-------------------------------------------------------------------*/
+
+typedef char    SDL_Character;
+typedef char    SDL_character;
+
+#define xDef_SDL_Character(V)       (*(V) = '\000')
+#define yDef_SDL_Character(V)       xDef_SDL_Character(V)
+#define yAssF_SDL_Character(V,E,A)  (V = E)
+#define yEqF_SDL_Character(E1,E2)   ((E1) == (E2))
+#define yNEqF_SDL_Character(E1,E2)  ((E1) != (E2))
+#define ySrtN_SDL_Character         xSrtN_SDL_Character
+
+/* predefined literals for non-printable characters,
+   other literals as in C */
+#define SDL_NUL '\000'
+#define SDL_SOH '\001'
+#define SDL_STX '\002'
+#define SDL_ETX '\003'
+#define SDL_EOT '\004'
+#define SDL_ENQ '\005'
+#define SDL_ACK '\006'
+#define SDL_BEL '\007'
+#define SDL_BS  '\010'
+#define SDL_HT  '\011'
+#define SDL_LF  '\012'
+#define SDL_VT  '\013'
+#define SDL_FF  '\014'
+#define SDL_CR  '\015'
+#define SDL_SO  '\016'
+#define SDL_SI  '\017'
+#define SDL_DLE '\020'
+#define SDL_DC1 '\021'
+#define SDL_DC2 '\022'
+#define SDL_DC3 '\023'
+#define SDL_DC4 '\024'
+#define SDL_NAK '\025'
+#define SDL_SYN '\026'
+#define SDL_ETB '\027'
+#define SDL_CAN '\030'
+#define SDL_EM  '\031'
+#define SDL_SUB '\032'
+#define SDL_ESC '\033'
+#define SDL_IS4 '\034'
+#define SDL_IS3 '\035'
+#define SDL_IS2 '\036'
+#define SDL_IS1 '\037'
+#define SDL_DEL '\177'
+#define SDL_E_NUL '\200'
+#define SDL_E_SOH '\201'
+#define SDL_E_STX '\202'
+#define SDL_E_ETX '\203'
+#define SDL_E_EOT '\204'
+#define SDL_E_ENQ '\205'
+#define SDL_E_ACK '\206'
+#define SDL_E_BEL '\207'
+#define SDL_E_BS  '\210'
+#define SDL_E_HT  '\211'
+#define SDL_E_LF  '\212'
+#define SDL_E_VT  '\213'
+#define SDL_E_FF  '\214'
+#define SDL_E_CR  '\215'
+#define SDL_E_SO  '\216'
+#define SDL_E_SI  '\217'
+#define SDL_E_DLE '\220'
+#define SDL_E_DC1 '\221'
+#define SDL_E_DC2 '\222'
+#define SDL_E_DC3 '\223'
+#define SDL_E_DC4 '\224'
+#define SDL_E_NAK '\225'
+#define SDL_E_SYN '\226'
+#define SDL_E_ETB '\227'
+#define SDL_E_CAN '\230'
+#define SDL_E_EM  '\231'
+#define SDL_E_SUB '\232'
+#define SDL_E_ESC '\233'
+#define SDL_E_IS4 '\234'
+#define SDL_E_IS3 '\235'
+#define SDL_E_IS2 '\236'
+#define SDL_E_IS1 '\237'
+
+
+/*---+---------------------------------------------------------------
+     Null
+-------------------------------------------------------------------*/
+
+typedef LONG     SDL_Null;
+
+#define xDef_SDL_Null(V)       (*(V) = (SDL_Null)0)
+#define yDef_SDL_Null(V)       xDef_SDL_Null(V)
+#define yAssF_SDL_Null(V,E,A)  (V = E)
+#define yEqF_SDL_Null(E1,E2)   ((E1) == (E2))
+#define yNEqF_SDL_Null(E1,E2)  ((E1) != (E2))
+#define ySrtN_SDL_Null         xSrtN_SDL_Null
+
+#define SDL_NullValue  0
+
+#ifndef ANY_SDL_Null
+#define ANY_SDL_Null           (SDL_Null)0
+#endif
+
+
+
+
+/*---+---------------------------------------------------------------
+     Charstring
+-------------------------------------------------------------------*/
+
+typedef CHAR   *SDL_Charstring;
+typedef CHAR   *SDL_charstring;
+
+
+#define xDef_SDL_Charstring(V)       (*(V) = (SDL_Charstring)0)
+#define yDef_SDL_Charstring(V)       xDef_SDL_Charstring(V)
+#define yAssF_SDL_Charstring(V,E,A) (V = E)
+#define yEqF_SDL_Charstring(E1,E2)   xEq_SDL_Charstring(E1,E2)
+#define yNEqF_SDL_Charstring(E1,E2)  (! xEq_SDL_Charstring(E1,E2))
+#define ySrtN_SDL_Charstring         xSrtN_SDL_Charstring
+
+#define SDL_CHARSTRING_LIT(P1, P2)   P1
+
+
+/*---+---------------------------------------------------------------
+     Duration
+-------------------------------------------------------------------*/
+#if 0
+#ifndef _TIMESPEC_
+#define _TIMESPEC_
+typedef long      timespec;
+#endif
+#endif
+//typedef SDL_Duration  SDL_duration;
+
+/*Name:KangShuJie Date:2008.01.25 Reason:windows±àÒëÖÐWaringÌ«¶à*/
+#ifdef _OS_WIN
+extern SDL_Duration SDL_Duration_Lit(SINT32 s, SINT32 ns);
+#endif
+/*End KangShuJie*/
+#define xDef_SDL_Duration(V)      ( *(V) = 0)
+#define yDef_SDL_Duration(V)       xDef_SDL_Duration(V)
+#define yAssF_SDL_Duration(V,E,A) (V = E)
+#define yEqF_SDL_Duration(E1,E2)   xEq_SDL_Duration(E1,E2)
+#define yNEqF_SDL_Duration(E1,E2)  (! xEq_SDL_Duration(E1,E2))
+#define ySrtN_SDL_Duration         xSrtN_SDL_Duration
+
+#define SDL_DURATION_LIT(R,I,D)    SDL_Duration_Lit(I,D)
+
+/*Date:2008-2-19  Name: Dongzhi  Reason:½«GSMµÄTU¸ÄΪUMTSµÄTU*/
+//xlb20080717#define CLOCK_TICK       10000000
+//#define CLOCK_TICK       4615385      /* TDMA frame duration in ns */
+#define TDMA_CLOCK_TICK  4615385      /* TDMA frame duration in ns */
+#define SDT_TICKPERSEC   217          /* well, actually: 216,66664861111261574061535494872 */
+
+
+/*---+---------------------------------------------------------------
+     Integer
+-------------------------------------------------------------------*/
+
+#if !defined(X_LONG_INT)
+typedef LONG  SDL_Integer;
+typedef LONG  SDL_integer;
+#else
+typedef LONG  SDL_Integer;
+typedef LONG  SDL_integer;
+#endif
+
+#define xDef_SDL_Integer(V)       (*(V) = (SDL_Integer)0)
+#define yDef_SDL_Integer(V)       xDef_SDL_Integer(V)
+#define yAssF_SDL_Integer(V,E,A)  (V = E)
+#define yEqF_SDL_Integer(E1,E2)   ((E1) == (E2))
+#define yNEqF_SDL_Integer(E1,E2)  ((E1) != (E2))
+#define ySrtN_SDL_Integer         xSrtN_SDL_Integer
+
+#define SDL_INTEGER_LIT(I)        I
+/* Literals as in C */
+
+#ifdef XVALIDATOR
+#define xMax_SDL_Integer 2147483647
+#endif
+
+
+/*---+---------------------------------------------------------------
+     Natural
+-------------------------------------------------------------------*/
+
+#if !defined(X_LONG_INT)
+typedef LONG  SDL_Natural;
+typedef LONG  SDL_natural;
+#else
+typedef LONG  SDL_Natural;
+typedef LONG  SDL_natural;
+#endif
+
+#define xDef_SDL_Natural(V)       (*(V) = (SDL_Natural)0)
+#define yDef_SDL_Natural(V)       xDef_SDL_Natural(V)
+#define yAssF_SDL_Natural(V,E,A)  (V = E)
+#define yEqF_SDL_Natural(E1,E2)   ((E1) == (E2))
+#define yNEqF_SDL_Natural(E1,E2)  ((E1) != (E2))
+#define ySrtN_SDL_Natural         xSrtN_SDL_Natural
+
+
+/*---+---------------------------------------------------------------
+     PId
+-------------------------------------------------------------------*/
+
+#define ySrtN_SDL_PId             xSrtN_SDL_PId
+/* see sctsdl.c and scttypes.h for implementation of PId */
+
+
+#ifndef XNOUSEOFREAL
+/*---+---------------------------------------------------------------
+     Real
+-------------------------------------------------------------------*/
+
+typedef double   SDL_Real;
+typedef double   SDL_real;
+
+#define xDef_SDL_Real(V)       (*(V) = 0.0)
+#define yDef_SDL_Real(V)       xDef_SDL_Real(V)
+#define yAssF_SDL_Real(V,E,A)  (V = E)
+#define yEqF_SDL_Real(E1,E2)   ((E1) == (E2))
+#define yNEqF_SDL_Real(E1,E2)  ((E1) != (E2))
+#define ySrtN_SDL_Real         xSrtN_SDL_Real
+
+#define SDL_REAL_LIT(R,I,D)    R
+/* Literals as in C */
+#endif
+
+
+/*---+---------------------------------------------------------------
+     Time
+-------------------------------------------------------------------*/
+
+
+//typedef SDL_Time  SDL_time;
+
+#define xDef_SDL_Time(V)       (*(V) = SDL_Time_Lit(0, 0))
+#define yDef_SDL_Time(V)       xDef_SDL_Time(V)
+#define yAssF_SDL_Time(V,E,A)  (V = E)
+#define yEqF_SDL_Time(E1,E2)   xEq_SDL_Time(E1,E2)
+#define yNEqF_SDL_Time(E1,E2)  (! xEq_SDL_Time(E1,E2))
+#define ySrtN_SDL_Time         xSrtN_SDL_Time
+
+#define SDL_TIME_LIT(R,I,D)    SDL_Duration_Lit(I,D)
+#define SDL_Time_Lit(I,D)      SDL_Duration_Lit(I,D)
+
+#ifdef XVALIDATOR
+extern SDL_Time xMaxTime;
+#endif
+
+
+
+
+/*---+---------------------------------------------------------------
+     ASN1 coder and generic data model
+-------------------------------------------------------------------*/
+
+/* These types are used by the generic data model, but also by the SDL
+   encoders/decoders in the old data model */
+
+typedef enum
+{
+  /*SDL - standard types*/
+  type_SDL_Integer=128,
+  type_SDL_Real=129,
+  type_SDL_Natural=130,
+  type_SDL_Boolean=131,
+  type_SDL_Character=132,
+  type_SDL_Time=133,
+  type_SDL_Duration=134,
+  type_SDL_Pid=135,
+  type_SDL_Charstring=136,
+  type_SDL_Bit=137,
+  type_SDL_Bit_string=138,
+  type_SDL_Octet=139,
+  type_SDL_Octet_string=140,
+  type_SDL_IA5String=141,
+  type_SDL_NumericString=142,
+  type_SDL_PrintableString=143,
+  type_SDL_VisibleString=144,
+  type_SDL_NULL=145,
+  type_SDL_Object_identifier=146,
+
+  /* SDL - standard ctypes */
+  type_SDL_ShortInt=150,
+  type_SDL_LongInt=151,
+  type_SDL_UnsignedShortInt=152,
+  type_SDL_UnsignedInt=153,
+  type_SDL_UnsignedLongInt=154,
+  type_SDL_Float=155,
+  type_SDL_Charstar=156,
+  type_SDL_Voidstar=157,
+  type_SDL_Voidstarstar=158,
+
+  /* SDL - user defined types */
+  type_SDL_Syntype=170,
+  type_SDL_Inherits=171,
+  type_SDL_Enum=172,
+  type_SDL_Struct=173,
+  type_SDL_Union=174,
+  type_SDL_UnionC=175,
+  type_SDL_Choice=176,
+  type_SDL_ChoicePresent=177,
+  type_SDL_Powerset=178,
+  type_SDL_GPowerset=179,
+  type_SDL_Bag=180,
+  type_SDL_String=181,
+  type_SDL_LString=182,
+  type_SDL_Array=183,
+  type_SDL_Carray=184,
+  type_SDL_GArray=185,
+  type_SDL_Own=186,
+  type_SDL_Oref=187,
+  type_SDL_Ref=188,
+  type_SDL_Userdef=189,
+  type_SDL_EmptyType=190,
+  type_SDL_ComBuf=191,
+
+  /* SDL - signals */
+  type_SDL_Signal=200,
+  type_SDL_SignalId=201
+
+} tSDLTypeClass;
+
+
+
+
+#ifndef T_CONST
+#define T_CONST const
+#endif
+
+#ifndef T_SDL_EXTRA_COMP
+#define T_SDL_EXTRA_COMP
+#define T_SDL_EXTRA_VALUE
+#endif
+
+#ifndef T_SDL_USERDEF_COMP
+#define T_SDL_USERDEF_COMP
+#endif
+
+#ifdef T_SDL_NAMES
+#define T_SDL_Names(P) , P
+#else
+#define T_SDL_Names(P)
+#endif
+
+#ifdef T_SIGNAL_SDL_NAMES
+#define T_Signal_SDL_Names(P) , P
+#else
+#define T_Signal_SDL_Names(P)
+#endif
+
+#ifdef T_SDL_INFO
+#define T_SDL_Info(P) , P
+#else
+#define T_SDL_Info(P)
+#endif
+
+#define NEEDSFREE(P)    (((tSDLTypeInfo *)(P))->OpNeeds & (unsigned char)1)
+#define NEEDSEQUAL(P)   (((tSDLTypeInfo *)(P))->OpNeeds & (unsigned char)2)
+#define NEEDSASSIGN(P)  (((tSDLTypeInfo *)(P))->OpNeeds & (unsigned char)4)
+
+
+/* Types used to represent a general String and GPowerset. */
+typedef struct xString_ystruct  *xString_yptr;
+typedef struct xString_ystruct {
+  xString_yptr  Suc;
+  int           Data;
+} xString_yrec;
+typedef struct {
+  xString_yptr  First;
+  xString_yptr  Last;
+  int           Length;
+  int           IsAssigned;
+} xString_Type;
+
+struct tSDLFuncInfo;
+
+/* ------- General type information for SDL types ------- */
+typedef T_CONST struct tSDLTypeInfoS {
+  tSDLTypeClass   TypeClass;
+  unsigned char   OpNeeds;
+  xptrint         SortSize;
+#ifndef XNOUSE_OPFUNCS
+  struct tSDLFuncInfo *OpFuncs;
+#endif
+  T_SDL_EXTRA_COMP
+#ifdef T_SDL_NAMES
+  char           *Name;
+#endif
+#ifdef XREADANDWRITEF
+  xIdNode         FatherScope;
+  xSortIdNode     SortIdNode;
+#endif
+} tSDLTypeInfo;
+
+
+/* ------------------ Enumeration type ------------------ */
+
+typedef T_CONST struct {
+  int             LiteralValue;
+  char           *LiteralName;
+} tSDLEnumLiteralInfo;
+
+typedef T_CONST struct tSDLEnumInfoS {
+  tSDLTypeClass   TypeClass;
+  unsigned char   OpNeeds;
+  xptrint         SortSize;
+#ifndef XNOUSE_OPFUNCS
+  struct tSDLFuncInfo *OpFuncs;
+#endif
+  T_SDL_EXTRA_COMP
+#ifdef T_SDL_NAMES
+  char           *Name;
+#endif
+#ifdef XREADANDWRITEF
+  xIdNode         FatherScope;
+  xSortIdNode     SortIdNode;
+#endif
+  tSDLTypeInfo   *CompOrFatherSort;
+#ifdef XREADANDWRITEF
+  int             NoOfLiterals;
+  tSDLEnumLiteralInfo *LiteralList;
+#endif
+} tSDLEnumInfo;
+
+/* ---------- Syntype, Inherits, Own, Oref, Ref --------- */
+typedef T_CONST struct tSDLGenInfoS {
+  tSDLTypeClass   TypeClass;
+  unsigned char   OpNeeds;
+  xptrint         SortSize;
+  struct tSDLFuncInfo *OpFuncs;
+  T_SDL_EXTRA_COMP
+#ifdef T_SDL_NAMES
+  char           *Name;
+#endif
+  tSDLTypeInfo   *CompOrFatherSort;
+} tSDLGenInfo;
+
+
+/* ---------------------- Powerset ---------------------- */
+typedef T_CONST struct tSDLPowersetInfoS {
+  tSDLTypeClass   TypeClass;
+  unsigned char   OpNeeds;
+  xptrint         SortSize;
+  struct tSDLFuncInfo *OpFuncs;
+  T_SDL_EXTRA_COMP
+#ifdef T_SDL_NAMES
+  char           *Name;
+#endif
+  tSDLTypeInfo   *CompSort;
+  int             Length;
+  int             LowestValue;
+} tSDLPowersetInfo;
+
+
+/* ----------------------- Struct ----------------------- */
+typedef int (*tGetFunc) XPP((void *));
+typedef void (*tAssFunc) XPP((void *, int));
+
+typedef T_CONST struct {
+  xptrint         OffsetPresent; /* 0 if not optional */
+  void           *DefaultValue;
+} tSDLFieldOptInfo;
+
+typedef T_CONST struct {
+  tGetFunc        GetTag;
+  tAssFunc        AssTag;
+} tSDLFieldBitFInfo;
+
+
+typedef T_CONST struct {
+  tSDLTypeInfo   *CompSort;
+#ifdef T_SDL_NAMES
+  char           *Name;
+#endif
+  xptrint         Offset;        /* ~0 for bitfield */
+  tSDLFieldOptInfo *ExtraInfo;
+} tSDLFieldInfo;
+
+typedef T_CONST struct tSDLStructInfoS {
+  tSDLTypeClass   TypeClass;
+  unsigned char   OpNeeds;
+  xptrint         SortSize;
+  struct tSDLFuncInfo *OpFuncs;
+  T_SDL_EXTRA_COMP
+#ifdef T_SDL_NAMES
+  char           *Name;
+#endif
+  tSDLFieldInfo  *Components;
+  int             NumOfComponents;
+} tSDLStructInfo;
+
+
+/* -------------------- Choice, Union ------------------- */
+typedef T_CONST struct {
+  tSDLTypeInfo        *CompSort;
+#ifdef T_SDL_NAMES
+  char                *Name;
+#endif
+} tSDLChoiceFieldInfo;
+
+typedef T_CONST struct tSDLChoiceInfoS {
+  tSDLTypeClass   TypeClass;
+  unsigned char   OpNeeds;
+  xptrint         SortSize;
+  struct tSDLFuncInfo *OpFuncs;
+  T_SDL_EXTRA_COMP
+#ifdef T_SDL_NAMES
+  char           *Name;
+#endif
+  tSDLChoiceFieldInfo *Components;
+  int                  NumOfComponents;
+  xptrint              OffsetToUnion;
+  xptrint              TagSortSize;
+} tSDLChoiceInfo;
+
+
+/* ------------------- Array, CArray -------------------- */
+typedef T_CONST struct tSDLArrayInfoS {
+  tSDLTypeClass   TypeClass;
+  unsigned char   OpNeeds;
+  xptrint         SortSize;
+  struct tSDLFuncInfo *OpFuncs;
+  T_SDL_EXTRA_COMP
+#ifdef T_SDL_NAMES
+  char           *Name;
+#endif
+  tSDLTypeInfo   *CompSort;
+  int             Length;
+} tSDLArrayInfo;
+
+
+/* ----------------------- GArray ----------------------- */
+typedef T_CONST struct tSDLGArrayInfoS {
+  tSDLTypeClass   TypeClass;
+  unsigned char   OpNeeds;
+  xptrint         SortSize;
+  struct tSDLFuncInfo *OpFuncs;
+  T_SDL_EXTRA_COMP
+#ifdef T_SDL_NAMES
+  char           *Name;
+#endif
+  tSDLTypeInfo   *IndexSort;
+  tSDLTypeInfo   *CompSort;
+  xptrint         yrecSize;
+  xptrint         yrecIndexOffset;
+  xptrint         yrecDataOffset;
+  xptrint         arrayDataOffset;
+} tSDLGArrayInfo;
+
+
+/* ----- GPowerset, Bag, String, Object_Identifier ------ */
+typedef T_CONST struct tSDLGenListInfoS {
+  tSDLTypeClass   TypeClass;
+  unsigned char   OpNeeds;
+  xptrint         SortSize;
+  struct tSDLFuncInfo *OpFuncs;
+  T_SDL_EXTRA_COMP
+#ifdef T_SDL_NAMES
+  char           *Name;
+#endif
+  tSDLTypeInfo   *CompSort;
+  xptrint         yrecSize;
+  xptrint         yrecDataOffset;
+} tSDLGenListInfo;
+
+
+/* ---------------------- LString ----------------------- */
+typedef T_CONST struct tSDLLStringInfoS {
+  tSDLTypeClass   TypeClass;
+  unsigned char   OpNeeds;
+  xptrint         SortSize;
+  struct tSDLFuncInfo *OpFuncs;
+  T_SDL_EXTRA_COMP
+#ifdef T_SDL_NAMES
+  char           *Name;
+#endif
+  tSDLTypeInfo   *CompSort;
+  int             MaxLength;
+  xptrint         DataOffset;
+} tSDLLStringInfo;
+
+
+/* ---------------------- Userdef ----------------------- */
+/* used for user defined types #ADT(T(h)) */
+typedef T_CONST struct tSDLUserdefInfoS {
+  tSDLTypeClass   TypeClass;
+  unsigned char   OpNeeds;
+  xptrint         SortSize;
+  struct tSDLFuncInfo *OpFuncs;
+  T_SDL_EXTRA_COMP
+#ifdef T_SDL_NAMES
+  char           *Name;
+#endif
+  T_SDL_USERDEF_COMP
+} tSDLUserdefInfo;
+
+
+/* ----------------------- Signal ----------------------- */
+typedef T_CONST struct {
+  tSDLTypeInfo       *ParaSort;
+  xptrint             Offset;
+} tSDLSignalParaInfo;
+
+typedef T_CONST struct tSDLSignalInfoS {
+  tSDLTypeClass   TypeClass;
+  unsigned char   OpNeeds;
+  xptrint         SortSize;
+  struct tSDLFuncInfo *OpFuncs;
+  T_SDL_EXTRA_COMP
+#ifdef T_SIGNAL_SDL_NAMES
+  char           *Name;
+#endif
+  tSDLSignalParaInfo *Param;
+  int             NoOfPara;
+} tSDLSignalInfo;
+
+typedef struct tSDLFuncInfo {
+  void *(*AssFunc) XPP((void *, void *, int));
+  SDL_Boolean (*EqFunc) XPP((void *, void *));
+  void (*FreeFunc) XPP((void **));
+} tSDLFuncInfo;
+
+
+/* Types used to represent a general Bag. */
+typedef struct xBag_ystruct  *xBag_yptr;
+typedef struct xBag_ystruct {
+  xBag_yptr     Suc;
+  int           NoOfItems;
+  int           Data;
+} xBag_yrec;
+typedef struct {
+  xBag_yptr     First;
+  xBag_yptr     Last;
+  int           Length;
+  int           IsAssigned;
+} xBag_Type;
+
+
+extern tSDLTypeInfo ySDL_SDL_Integer;
+extern tSDLTypeInfo ySDL_SDL_Real;
+extern tSDLTypeInfo ySDL_SDL_Natural;
+extern tSDLTypeInfo ySDL_SDL_Boolean;
+extern tSDLTypeInfo ySDL_SDL_Character;
+extern tSDLTypeInfo ySDL_SDL_Time;
+extern tSDLTypeInfo ySDL_SDL_Duration;
+extern tSDLTypeInfo ySDL_SDL_PId;
+extern tSDLTypeInfo ySDL_SDL_Charstring;
+extern tSDLTypeInfo ySDL_SDL_Bit;
+extern tSDLTypeInfo ySDL_SDL_Bit_String;
+extern tSDLTypeInfo ySDL_SDL_Octet;
+extern tSDLTypeInfo ySDL_SDL_Octet_String;
+extern tSDLTypeInfo ySDL_SDL_IA5String;
+extern tSDLTypeInfo ySDL_SDL_NumericString;
+extern tSDLTypeInfo ySDL_SDL_PrintableString;
+extern tSDLTypeInfo ySDL_SDL_VisibleString;
+extern tSDLTypeInfo ySDL_SDL_Null;
+extern tSDLGenListInfo ySDL_SDL_Object_Identifier;
+
+/* End section with type info nodes */
+
+extern LONG         GenericGetValue   XPP((DWORD, VOID *));
+extern VOID        GenericSetValue   XPP((DWORD, VOID *, LONG));
+
+
+/****+***************************************************************
+01
+********************************************************************/
+
+/* Macros used in assign functions */
+
+/* XASS_1_2_3 should be read:
+1 = AC  : always copy
+1 = MR  : may reuse (take pointer if temporary object)
+1 = AR  : always reuse (take pointer)
+2 = ASS : new object assigned to "variable"
+2 = TMP : new object temporary
+3 = FR  : call free for old value refered to by variable
+3 = NF  : do not call free for old value
+*/
+#define XASS_AC_ASS_FR  (int)25  /* 1+8+16 */
+#define XASS_MR_ASS_FR  (int)26  /* 2+8+16 */  /* = XASS */
+#define XASS_AR_ASS_FR  (int)28  /* 4+8+16 */
+
+#define XASS_AC_TMP_FR  (int)17  /* 1+0+16 */
+#define XASS_MR_TMP_FR  (int)18  /* 2+0+16 */  /* = XASSMAKE */
+#define XASS_AR_TMP_FR  (int)20  /* 4+0+16 */
+
+#define XASS_AC_ASS_NF  (int)9   /* 1+8+0  */
+#define XASS_MR_ASS_NF  (int)10  /* 2+8+0  */
+#define XASS_AR_ASS_NF  (int)12  /* 4+8+0  */
+
+#define XASS_AC_TMP_NF  (int)1   /* 1+0+0  */  /* = XASS2MAKE */
+#define XASS_MR_TMP_NF  (int)2   /* 2+0+0  */  /* = XASSMAKE */
+#define XASS_AR_TMP_NF  (int)4   /* 4+0+0  */
+
+#define SHOULD_COPY(P)          (P & (int)1)
+#define MAY_REUSE(P)            (P & (int)2)
+#define SHOULD_REUSE(P)         (P & (int)4)
+#define SHOULD_RESULT_BE_ASS(P) (P & (int)8)
+#define SHOULD_FREE_OLD(P)      (P & (int)16)
+
+#define SET_ASS_NF(P)           ((P & (int)15) | (int)8)
+#define SET_NF(P)               (P & (int)15)
+
+
+
+/*---+---------------------------------------------------------------
+     Bit
+-------------------------------------------------------------------*/
+
+typedef BYTE SDL_Bit;
+
+#define yAssF_SDL_Bit(V,E,A)  (V = E)
+#define yEqF_SDL_Bit(E1,E2)   ((E1) == (E2))
+#define yNEqF_SDL_Bit(E1,E2)  ((E1) != (E2))
+#define ySrtN_SDL_Bit         xSrtN_SDL_Bit
+
+#define SDL_BIT_LIT(I)        I
+
+#define xNot_SDL_Bit(B)       (!(B))
+#define xAnd_SDL_Bit(B1,B2)   ((B1)&(B2))
+#define xOr_SDL_Bit(B1,B2)    ((B1)|(B2))
+#define xXor_SDL_Bit(B1,B2)   ((B1)^(B2))
+#define xImpl_SDL_Bit(B1,B2)  ((B1)<=(B2))
+
+#ifndef ANY_SDL_Bit
+#define ANY_SDL_Bit           (SDL_Bit)(GETINTRAND % 2)
+#endif
+
+
+/*---+---------------------------------------------------------------
+     Octet
+-------------------------------------------------------------------*/
+
+typedef BYTE SDL_Octet;
+
+#define xDef_SDL_Octet(V)       (*(V) = (SDL_Octet)0)
+#define yAssF_SDL_Octet(V,E,A)  (V = E)
+#define yEqF_SDL_Octet(E1,E2)   ((E1) == (E2))
+#define yNEqF_SDL_Octet(E1,E2)  ((E1) != (E2))
+#define ySrtN_SDL_Octet         xSrtN_SDL_Octet
+
+extern SDL_Bit *yAddr_SDL_Octet XPP((SDL_Octet *, SDL_Integer));
+extern SDL_Bit xExtr_SDL_Octet XPP((SDL_Octet, SDL_Integer));
+
+#define xLT_SDL_Octet(B1,B2)  ((B1)<(B2))
+#define xLE_SDL_Octet(B1,B2)  ((B1)<=(B2))
+#define xGT_SDL_Octet(B1,B2)  ((B1)>(B2))
+#define xGE_SDL_Octet(B1,B2)  ((B1)>=(B2))
+
+#define xNot_SDL_Octet(B)       (SDL_Octet)(~(B))
+#define xAnd_SDL_Octet(B1,B2)   ((B1)&(B2))
+#define xOr_SDL_Octet(B1,B2)    ((B1)|(B2))
+#define xXor_SDL_Octet(B1,B2)   ((B1)^(B2))
+#define xImpl_SDL_Octet(B1,B2)  xNot_SDL_Octet(xAnd_SDL_Octet((B1),xNot_SDL_Octet(B2)))
+#define xShiftL_SDL_Octet(B,I)  (SDL_Octet)(((B)<<(I)) & 0xFF)
+#define xShiftR_SDL_Octet(B,I)  ((B)>>(I))
+#define xPlus_SDL_Octet(B1,B2)  (SDL_Octet)(((B1)+(B2)) & 0xFF)
+#define xMinus_SDL_Octet(B1,B2) (SDL_Octet)((B1)-(B2))
+#define xMult_SDL_Octet(B1,B2)  (SDL_Octet)(((B1)*(B2)) & 0xFF)
+#define xI2O_SDL_Octet(I)       (SDL_Octet)(I)
+#define xO2I_SDL_Octet(B)       (SDL_Integer)(B)
+
+#ifndef XEINTDIV
+#define xDiv_SDL_Octet(B1,B2)   ((B1)/(B2))
+#define xMod_SDL_Octet(B1,B2)   ((B1)%(B2))
+#define xRem_SDL_Octet(B1,B2)   ((B1)%(B2))
+#else
+extern SDL_Octet xDiv_SDL_Octet XPP((SDL_Octet, SDL_Octet));
+extern SDL_Octet xMod_SDL_Octet XPP((SDL_Octet, SDL_Octet));
+extern SDL_Octet xRem_SDL_Octet XPP((SDL_Octet, SDL_Octet));
+#endif
+
+extern SDL_Octet xBitStr_SDL_Octet XPP((SDL_Charstring));
+extern SDL_Octet xHexStr_SDL_Octet XPP((SDL_Charstring));
+
+#ifndef ANY_SDL_Octet
+#define ANY_SDL_Octet           (SDL_Octet)(GETINTRAND % 256)
+#endif
+
+
+
+#ifndef XNOUSEOFOCTETBITSTRING
+/*---+---------------------------------------------------------------
+     Bit_String
+-------------------------------------------------------------------*/
+
+typedef struct {
+  int             Length;
+  xbool           IsAssigned;
+  unsigned char * Bits;
+} SDL_Bit_String;
+
+#define xDef_SDL_Bit_String(V) \
+  {(*V).Length = 0; (*V).IsAssigned = (xbool)1; (*V).Bits = 0;}
+#define yDef_SDL_Bit_String(V)       xDef_SDL_Bit_String(V)
+#define yAssF_SDL_Bit_String(V,E,A)  xAss_SDL_Bit_String(&(V),E,A)
+#define yEqF_SDL_Bit_String(E1,E2)   xEq_SDL_Bit_String(E1,E2)
+#define yNEqF_SDL_Bit_String(E1,E2)  (! xEq_SDL_Bit_String(E1,E2))
+#define ySrtN_SDL_Bit_String         xSrtN_SDL_Bit_String
+
+#define yFree_SDL_Bit_String(P)  xFree_SDL_Bit_String(P)
+extern void xAss_SDL_Bit_String XPP((SDL_Bit_String *, SDL_Bit_String, int));
+extern SDL_Boolean xEq_SDL_Bit_String XPP((SDL_Bit_String, SDL_Bit_String));
+extern void xFree_SDL_Bit_String XPP((void **));
+extern SDL_Bit * yAddr_SDL_Bit_String XPP((SDL_Bit_String *, SDL_Integer));
+extern SDL_Bit xExtr_SDL_Bit_String XPP((SDL_Bit_String, SDL_Integer));
+extern SDL_Bit_String xNot_SDL_Bit_String XPP((SDL_Bit_String));
+extern SDL_Bit_String xAnd_SDL_Bit_String XPP((SDL_Bit_String, SDL_Bit_String));
+extern SDL_Bit_String xOr_SDL_Bit_String XPP((SDL_Bit_String, SDL_Bit_String));
+extern SDL_Bit_String xXor_SDL_Bit_String XPP((SDL_Bit_String, SDL_Bit_String));
+extern SDL_Bit_String xImpl_SDL_Bit_String XPP((SDL_Bit_String, SDL_Bit_String));
+extern SDL_Bit_String xMkString_SDL_Bit_String XPP((SDL_Bit));
+extern SDL_Integer xLength_SDL_Bit_String XPP((SDL_Bit_String));
+extern SDL_Bit xFirst_SDL_Bit_String XPP((SDL_Bit_String));
+extern SDL_Bit xLast_SDL_Bit_String XPP((SDL_Bit_String));
+extern SDL_Bit_String xConcat_SDL_Bit_String XPP((SDL_Bit_String, SDL_Bit_String));
+extern SDL_Bit_String xSubString_SDL_Bit_String XPP((SDL_Bit_String, SDL_Integer, SDL_Integer));
+extern SDL_Bit_String xBitStr_SDL_Bit_String XPP((SDL_Charstring));
+
+SDL_Bit_String xHexStr_SDL_Bit_String XPP((SDL_Charstring));
+
+
+
+#ifndef ANY_SDL_Bit_String
+#define ANY_SDL_Bit_String \
+   xConcat_SDL_Bit_String \
+     (xMkString_SDL_Bit_String(((unsigned char)(GETINTRAND%2))), \
+      xMkString_SDL_Bit_String(((unsigned char)(GETINTRAND%2))) \
+     )
+#endif
+
+#endif  /* XNOUSEOFOCTETBITSTRING */
+
+
+#ifndef XNOUSEOFOCTETBITSTRING
+/*---+---------------------------------------------------------------
+     Octet_String
+-------------------------------------------------------------------*/
+
+/* An error in the implementation of Octet_String was introduced
+   in SDT 3.2, when Octet_String was first supported.
+   Octet_Strings should be indexed from 1, not from 0 as the
+   SDL Suite implementation assumes. Note that Bit_Strings are indexed
+   from 0. The inconsistancy between Octet_Strings and Bit_Strings
+   in SDL is inherited from ASN.1.
+   In SDT 3.6 this indexing error for Octet_Strings is corrected.
+   To obtain the Octet_String behaviour from SDT3.2 - SDT3.5,
+   OCTET_STRING_START_INDEX_0 should be defined, for example by
+   uncommenting the #define below. It is not necessary to recompile
+   the kernel for this to take effect.
+   This change will effect the behaviour of indexing of
+   Octet_Strings and the start parameter in operator SubString.
+*/
+/* #define OCTET_STRING_START_INDEX_0 */
+
+typedef SDL_Bit_String SDL_Octet_String;
+
+#define xDef_SDL_Octet_String(V) \
+  {(*V).Length = 0; (*V).IsAssigned = (xbool)1; (*V).Bits = 0;}
+#define yDef_SDL_Octet_String(V)       xDef_SDL_Octet_String(V)
+#define yAssF_SDL_Octet_String(V,E,A)  xAss_SDL_Bit_String(&(V),E,A)
+#define yEqF_SDL_Octet_String(E1,E2)   xEq_SDL_Bit_String(E1,E2)
+#define yNEqF_SDL_Octet_String(E1,E2)  (! xEq_SDL_Bit_String(E1,E2))
+#define ySrtN_SDL_Octet_String         xSrtN_SDL_Octet_String
+
+#define yFree_SDL_Octet_String(P)  xFree_SDL_Bit_String(P)
+#define xFree_SDL_Octet_String(P)  xFree_SDL_Bit_String(P)
+#define xAss_SDL_Octet_String(V,E,A)  xAss_SDL_Bit_String(V,E,A)
+#define xEq_SDL_Octet_String(V,E,A)  xEq_SDL_Bit_String(V,E,A)
+#ifdef OCTET_STRING_START_INDEX_0
+#define yAddr_SDL_Octet_String(B1,B2) yAddr_SDL_Bit_String(B1,B2)
+#define xExtr_SDL_Octet_String(B1,B2) xExtr_SDL_Bit_String(B1,B2)
+#else
+#define yAddr_SDL_Octet_String(B1,B2) yAddr_SDL_Bit_String(B1,B2-1)
+#define xExtr_SDL_Octet_String(B1,B2) xExtr_SDL_Bit_String(B1,B2-1)
+#endif
+#define xMkString_SDL_Octet_String(B)  xMkString_SDL_Bit_String(B)
+#define xLength_SDL_Octet_String(B)  xLength_SDL_Bit_String(B)
+#define xFirst_SDL_Octet_String(B)  xFirst_SDL_Bit_String(B)
+#define xLast_SDL_Octet_String(B)  xLast_SDL_Bit_String(B)
+#define xConcat_SDL_Octet_String(B1,B2)  xConcat_SDL_Bit_String(B1,B2)
+#ifdef OCTET_STRING_START_INDEX_0
+#define xSubString_SDL_Octet_String(B1,B2,B3)  xSubString_SDL_Bit_String(B1,B2,B3)
+#else
+#define xSubString_SDL_Octet_String(B1,B2,B3)  xSubString_SDL_Bit_String(B1,B2-1,B3)
+#endif
+extern SDL_Octet_String xBitStr_SDL_Octet_String XPP((SDL_Charstring));
+extern SDL_Octet_String xHexStr_SDL_Octet_String XPP((SDL_Charstring));
+extern SDL_Bit_String xBit_String_SDL_Octet_String XPP((SDL_Octet_String));
+extern SDL_Octet_String xOctet_String_SDL_Octet_String XPP((SDL_Bit_String));
+
+#ifndef ANY_SDL_Octet_String
+#define ANY_SDL_Octet_String \
+   xConcat_SDL_Octet_String \
+     (xMkString_SDL_Octet_String(((unsigned char)(GETINTRAND%256))), \
+      xMkString_SDL_Octet_String(((unsigned char)(GETINTRAND%256))) \
+     )
+#endif
+
+#endif  /* XNOUSEOFOCTETBITSTRING */
+
+
+
+/*---+---------------------------------------------------------------
+     Object_Identifier
+-------------------------------------------------------------------*/
+
+typedef struct SDL_Object_Identifier_ystruct *SDL_Object_Identifier_yptr;
+typedef struct SDL_Object_Identifier_ystruct {
+  SDL_Object_Identifier_yptr Suc;
+  SDL_Natural Data;
+} SDL_Object_Identifier_yrec;
+typedef struct {
+  SDL_Object_Identifier_yptr First;
+  SDL_Object_Identifier_yptr Last;
+  int Length;
+  int IsAssigned;
+} SDL_Object_Identifier;
+
+#define xDef_SDL_Object_Identifier(V) \
+  {(*V).First = 0; (*V).Last = 0; (*V).Length = 0; (*V).IsAssigned = (xbool)1;}
+#define yDef_SDL_Object_Identifier(V)       xDef_SDL_Object_Identifier(V)
+#define yAssF_SDL_Object_Identifier(V,E,A)  yAss_SDL_Object_Identifier(&(V),E,A)
+#define yEqF_SDL_Object_Identifier(E1,E2)   yEq_SDL_Object_Identifier(E1,E2)
+#define yNEqF_SDL_Object_Identifier(E1,E2)  (! yEq_SDL_Object_Identifier(E1,E2))
+#define ySrtN_SDL_Object_Identifier         xSrtN_SDL_Object_Identifier
+
+extern SDL_Object_Identifier yEmptystring_SDL_Object_Identifier XPP((void));
+extern SDL_Object_Identifier yMkString_SDL_Object_Identifier XPP((SDL_Natural));
+extern SDL_Integer yLength_SDL_Object_Identifier XPP((SDL_Object_Identifier));
+extern SDL_Natural yFirst_SDL_Object_Identifier XPP((SDL_Object_Identifier));
+extern SDL_Natural yLast_SDL_Object_Identifier XPP((SDL_Object_Identifier));
+extern SDL_Object_Identifier yConcat_SDL_Object_Identifier
+    XPP((SDL_Object_Identifier, SDL_Object_Identifier));
+extern SDL_Object_Identifier ySubString_SDL_Object_Identifier
+    XPP((SDL_Object_Identifier, SDL_Integer, SDL_Integer));
+extern SDL_Natural yExtr_SDL_Object_Identifier
+    XPP((SDL_Object_Identifier, SDL_Integer));
+extern SDL_Natural *yAddr_SDL_Object_Identifier
+    XPP((SDL_Object_Identifier *, SDL_Integer));
+
+extern void yAss_SDL_Object_Identifier
+    XPP((SDL_Object_Identifier *, SDL_Object_Identifier, int));
+extern SDL_Boolean yEq_SDL_Object_Identifier
+    XPP((SDL_Object_Identifier, SDL_Object_Identifier));
+extern void yFree_SDL_Object_Identifier XPP((void **));
+
+#ifndef ANY_SDL_Object_Identifier
+#define ANY_SDL_Object_Identifier  \
+   yConcat_SDL_Object_Identifier(yMkString_SDL_Object_Identifier(ANY_SDL_Natural), \
+     yMkString_SDL_Object_Identifier(ANY_SDL_Natural))
+#endif
+
+
+/*---+---------------------------------------------------------------
+     GenericAssignSort
+-------------------------------------------------------------------*/
+
+extern void        GenericFreeSort   XPP((void **, tSDLTypeInfo *));
+extern SDL_Boolean GenericEqualSort  XPP((void *, void *, tSDLTypeInfo *));
+extern VOID *      GenericAssignSort XPP((VOID *, VOID *, LONG, tSDLTypeInfo *));
+// #define GenericAssignSort(Addr,Expr,AssName,dummy)  *(Addr) = *(Expr)
+
+
+
+
+
+
+
+
+/****+***************************************************************
+02   Prototypes and macros for the operators of the data types
+********************************************************************/
+
+/*---+---------------------------------------------------------------
+     yInit_Predefined
+-------------------------------------------------------------------*/
+
+#ifndef XOPTSORT
+extern void yInit_Predefined XPP((void));
+#endif
+
+
+/*---+---------------------------------------------------------------
+     Boolean
+-------------------------------------------------------------------*/
+
+#define xNot_SDL_Boolean(B)       (!(B))
+#define xAnd_SDL_Boolean(B1,B2)   ((B1)&&(B2))
+#define xOr_SDL_Boolean(B1,B2)    ((B1)||(B2))
+#define xXor_SDL_Boolean(B1,B2)   ((B1)!=(B2))
+#define xImpl_SDL_Boolean(B1,B2)  ((B1)<=(B2))
+#define ANY_SDL_Boolean           (SDL_Boolean)(GETINTRAND % 2)
+
+/*---+---------------------------------------------------------------
+     Character
+-------------------------------------------------------------------*/
+
+#define xLT_SDL_Character(C1,C2)  ((C1)<(C2))
+#define xLE_SDL_Character(C1,C2)  ((C1)<=(C2))
+#define xGT_SDL_Character(C1,C2)  ((C1)>(C2))
+#define xGE_SDL_Character(C1,C2)  ((C1)>=(C2))
+#define xChr_SDL_Character(I)  ((SDL_Character)xMod_SDL_Integer(I,128))
+#define xNum_SDL_Character(C)  ((SDL_Integer)C)
+#define ANY_SDL_Character         xChr_SDL_Character(GETINTRAND)
+
+
+/*---+---------------------------------------------------------------
+     Charstring
+-------------------------------------------------------------------*/
+
+/*-- yFree_SDL_Charstring -----------------------------------------*/
+#define yFree_SDL_Charstring(P)  xFree_SDL_Charstring(P)
+extern void xFree_SDL_Charstring XPP((void **));
+/* function in sctos.c */
+
+/*-- xAss_SDL_Charstring ------------------------------------------*/
+extern void xAss_SDL_Charstring  XPP((
+  SDL_Charstring *CVar,
+  SDL_Charstring  CExpr,
+  int             AssType ));
+
+/*-- xEq_SDL_Charstring -------------------------------------------*/
+extern SDL_Boolean xEq_SDL_Charstring  XPP((
+  SDL_Charstring C1,
+  SDL_Charstring C2 ));
+
+/*-- xMod_SDL_Charstring ------------------------------------------*/
+/* No longer used by generated code */
+extern SDL_Charstring xMod_SDL_Charstring XPP((
+  SDL_Charstring  C,
+  SDL_Integer     Index,
+  SDL_Character   Value ));
+
+/*-- yAddr_SDL_Charstring ------------------------------------------*/
+extern SDL_Character * yAddr_SDL_Charstring XPP((
+  SDL_Charstring *C,
+  SDL_Integer     Index ));
+
+/*-- xExtr_SDL_Charstring -----------------------------------------*/
+extern SDL_Character xExtr_SDL_Charstring XPP((
+  SDL_Charstring  C,
+  SDL_Integer     Index ));
+
+/*-- xMkString_SDL_Charstring -------------------------------------*/
+extern SDL_Charstring xMkString_SDL_Charstring XPP((
+  SDL_Character C ));
+
+/*-- xLength_SDL_Charstring ---------------------------------------*/
+extern SDL_Integer xLength_SDL_Charstring XPP((
+  SDL_Charstring  C ));
+
+/*-- xFirst_SDL_Charstring ----------------------------------------*/
+extern SDL_Character xFirst_SDL_Charstring XPP((
+  SDL_Charstring  C ));
+
+/*-- xLast_SDL_Charstring -----------------------------------------*/
+extern SDL_Character xLast_SDL_Charstring XPP((
+  SDL_Charstring  C ));
+
+/*-- xConcat_SDL_Charstring ---------------------------------------*/
+extern SDL_Charstring xConcat_SDL_Charstring XPP((
+  SDL_Charstring  C1,
+  SDL_Charstring  C2 ));
+
+/*-- xSubString_SDL_Charstring ------------------------------------*/
+extern SDL_Charstring xSubString_SDL_Charstring XPP((
+  SDL_Charstring  C,
+  SDL_Integer     Start,
+  SDL_Integer     SubLength ));
+
+#define ANY_SDL_Charstring \
+   xConcat_SDL_Charstring \
+     (xMkString_SDL_Charstring( ((SDL_Character)(1+GETINTRAND%127)) ), \
+      xMkString_SDL_Charstring( ((SDL_Character)(1+GETINTRAND%127)) ) \
+     )
+
+
+/*---+---------------------------------------------------------------
+     Duration
+-------------------------------------------------------------------*/
+
+/*-- xPlus_SDL_Duration -------------------------------------------*/
+
+#define xPlus_SDL_Duration(D1,D2) ((D1) + (D2))
+
+/*-- xMinus_SDL_Duration ------------------------------------------*/
+
+#define xMinus_SDL_Duration(D1,D2) ((D1) - (D2))
+
+/*-- xMonMinus_SDL_Duration ---------------------------------------*/
+
+#define xMonMinus_SDL_Duration(D) (-(D))
+
+/*-- xMult_SDL_Duration -------------------------------------------*/
+#ifndef XNOUSEOFREAL
+extern SDL_Duration xMult_SDL_Duration  XPP((
+  SDL_Duration D,
+  SDL_Real     R ));
+#endif
+
+/*-- xMultRD_SDL_Duration -----------------------------------------*/
+#define xMultRD_SDL_Duration(R,D) xMult_SDL_Duration(D, R)
+
+/*-- xDiv_SDL_Duration --------------------------------------------*/
+#ifndef XNOUSEOFREAL
+extern SDL_Duration xDiv_SDL_Duration  XPP((
+  SDL_Duration D,
+  SDL_Real     R ));
+#endif
+
+#define xGT_SDL_Duration(P1, P2)  xLT_SDL_Time(P2, P1)
+#define xGE_SDL_Duration(P1, P2)  xLE_SDL_Time(P2, P1)
+#define xLT_SDL_Duration(P1, P2)  xLT_SDL_Time(P1, P2)
+#define xLE_SDL_Duration(P1, P2)  xLE_SDL_Time(P1, P2)
+
+/*-- xEq_SDL_Duration ---------------------------------------------*/
+
+#define xEq_SDL_Duration(D1,D2) ((D1) == (D2))
+
+#define ANY_SDL_Duration \
+   SDL_Duration_Lit(GETINTRAND, GETINTRAND % 1000000000)
+
+
+/*---+---------------------------------------------------------------
+     Integer
+-------------------------------------------------------------------*/
+
+#define xMonMinus_SDL_Integer(I)   (-(I))
+#define xPlus_SDL_Integer(I1,I2)   ((I1)+(I2))
+#define xMinus_SDL_Integer(I1,I2)  ((I1)-(I2))
+#define xMult_SDL_Integer(I1,I2)   ((I1)*(I2))
+
+/*-- xDiv_SDL_Integer ---------------------------------------------*/
+#ifdef XEINTDIV
+extern SDL_Integer xDiv_SDL_Integer XPP((
+  SDL_Integer  i,
+  SDL_Integer  k ));
+#else
+#define xDiv_SDL_Integer(i,k) ((i)/(k))
+#endif
+
+/*-- xMod_SDL_Integer ---------------------------------------------*/
+#define xMod_SDL_Integer(i_, k_) ((i_) % (k_))
+
+
+/*-- xRem_SDL_Integer ---------------------------------------------*/
+#ifdef XEINTDIV
+extern SDL_Integer xRem_SDL_Integer XPP((
+  SDL_Integer  i,
+  SDL_Integer  k ));
+#else
+#define xRem_SDL_Integer(i,k) ((i)%(k))
+#endif
+
+#define xLT_SDL_Integer(I1,I2)  ((I1)<(I2))
+#define xLE_SDL_Integer(I1,I2)  ((I1)<=(I2))
+#define xGT_SDL_Integer(I1,I2)  ((I1)>(I2))
+#define xGE_SDL_Integer(I1,I2)  ((I1)>=(I2))
+
+/*-- xFix_SDL_Integer ---------------------------------------------*/
+#ifdef XEFIXOF
+extern SDL_Integer xFix_SDL_Integer XPP((
+  SDL_Real     Re ));
+#else
+#define xFix_SDL_Integer(Re)   ((SDL_Integer)Re)
+#endif
+
+/* -- xFloat_SDL_Integer ------------------------------------------*/
+#ifndef XNOUSEOFREAL
+#define xFloat_SDL_Integer(I)   ((SDL_Real)I)
+#endif
+
+#define ANY_SDL_Integer         (SDL_Integer)(GETINTRAND - GETINTRAND_MAX/2)
+
+
+/*---+---------------------------------------------------------------
+     Natural
+-------------------------------------------------------------------*/
+
+/*-- xTest_SDL_Natural --------------------------------------------*/
+#ifdef XTESTF
+extern xbool xTest_SDL_Natural  XPP((
+  void * N ));
+#endif
+
+/*-- xTstA_SDL_Natural --------------------------------------------*/
+#ifdef XERANGE
+extern SDL_Natural xTstA_SDL_Natural XPP(( SDL_Natural  N ));
+#define yTstA_SDL_Natural(N)  xTstA_SDL_Natural(N)
+#else
+#define xTstA_SDL_Natural(N)  N
+#define yTstA_SDL_Natural(N)  N
+#endif
+
+/*-- xTstI_SDL_Natural --------------------------------------------*/
+#ifdef XEINDEX
+extern SDL_Natural xTstI_SDL_Natural XPP(( SDL_Natural  N ));
+#define yTstI_SDL_Natural(N)  xTstI_SDL_Natural(N)
+#else
+#define xTstI_SDL_Natural(N)  N
+#define yTstI_SDL_Natural(N)  N
+#endif
+
+#define ANY_SDL_Natural         (SDL_Natural)(GETINTRAND)
+
+
+/*---+---------------------------------------------------------------
+     PId
+-------------------------------------------------------------------*/
+
+#define ANY_SDL_PId             SDL_NULL
+
+
+/*---+---------------------------------------------------------------
+     Real
+-------------------------------------------------------------------*/
+
+#define xMonMinus_SDL_Real(R)   (-(R))
+#define xPlus_SDL_Real(R1,R2)   ((R1)+(R2))
+#define xMinus_SDL_Real(R1,R2)  ((R1)-(R2))
+#define xMult_SDL_Real(R1,R2)   ((R1)*(R2))
+
+/*-- xDiv_SDL_Real ------------------------------------------------*/
+#ifndef XNOUSEOFREAL
+#ifdef XEREALDIV
+extern SDL_Real xDiv_SDL_Real XPP((
+  SDL_Real     i,
+  SDL_Real     k ));
+#else
+#define xDiv_SDL_Real(i,k) ((i)/(k))
+#endif
+#endif
+
+#define xLT_SDL_Real(R1,R2)  ((R1)<(R2))
+#define xLE_SDL_Real(R1,R2)  ((R1)<=(R2))
+#define xGT_SDL_Real(R1,R2)  ((R1)>(R2))
+#define xGE_SDL_Real(R1,R2)  ((R1)>=(R2))
+
+#define ANY_SDL_Real         (SDL_Real)(GETINTRAND - GETINTRAND_MAX/2)
+
+
+/*---+---------------------------------------------------------------
+     Time
+-------------------------------------------------------------------*/
+
+/*-- xPlus_SDL_Time -----------------------------------------------*/
+#define xPlus_SDL_Time(P1, P2)  ((P1) + (P2))
+
+/*-- xPlusDT_SDL_Time ---------------------------------------------*/
+#define xPlusDT_SDL_Time(P1, P2)  ((P1) + (P2))
+
+/*-- xMinusD_SDL_Time ---------------------------------------------*/
+#define xMinusD_SDL_Time(P1, P2) ((P1) - (P2))
+
+/*-- xMinusT_SDL_Time ---------------------------------------------*/
+#define xMinusT_SDL_Time(P1, P2) ((P1) - (P2))
+
+/*-- xEq_SDL_Time -------------------------------------------------*/
+#define xEq_SDL_Time(P1, P2) ((P1) == (P2))
+
+/*-- xLT_SDL_Time -------------------------------------------------*/
+#define xLT_SDL_Time(T1, T2) ((T1) < (T2))
+
+/*-- xLE_SDL_Time -------------------------------------------------*/
+#define xLE_SDL_Time(T1, T2) ((T1) <= (T2))
+
+/*-- xGT_SDL_Time -------------------------------------------------*/
+#define xGT_SDL_Time(P1, P2) ((P1) > (P2))
+
+/*-- xGE_SDL_Time -------------------------------------------------*/
+#define xGE_SDL_Time(P1, P2) ((P1) >= (P2))
+
+#define ANY_SDL_Time \
+   SDL_Time_Lit(GETINTRAND, GETINTRAND % 1000000000)
+
+
+/****+***************************************************************
+03   Read and Write functions
+********************************************************************/
+#ifdef XREADANDWRITEF
+
+/*-- xRead_SDL_Boolean --------------------------------------------*/
+#define xRead_SDL_Boolean(Addr)  xReadSort(Addr, xSrtN_SDL_Boolean)
+
+/*-- xWri_SDL_Boolean ---------------------------------------------*/
+#define xWri_SDL_Boolean(Value)  xWriteSort(Value, xSrtN_SDL_Boolean)
+
+/*-- xRead_SDL_Character ------------------------------------------*/
+extern int xRead_SDL_Character XPP((void *));
+
+/*-- xWri_SDL_Character -------------------------------------------*/
+extern char * xWri_SDL_Character XPP((void *));
+
+/*-- xRead_SDL_Charstring -----------------------------------------*/
+extern int xRead_SDL_Charstring XPP((void *));
+
+/*-- xWri_SDL_Charstring ------------------------------------------*/
+extern char * xWri_SDL_Charstring XPP((void *));
+
+/*-- xRead_SDL_Duration -------------------------------------------*/
+extern int xRead_SDL_Duration XPP((void *));
+
+/*-- xWri_SDL_Duration --------------------------------------------*/
+extern char * xWri_SDL_Duration XPP((void *));
+
+/*-- xRead_SDL_Integer --------------------------------------------*/
+extern int xRead_SDL_Integer XPP((void *));
+
+/*-- xWri_SDL_Integer ---------------------------------------------*/
+extern char * xWri_SDL_Integer XPP((void *));
+
+/*-- xRead_SDL_Real -----------------------------------------------*/
+extern int xRead_SDL_Real XPP((void *));
+
+/*-- xWri_SDL_Real ------------------------------------------------*/
+extern char * xWri_SDL_Real XPP((void *));
+
+/*-- xRead_SDL_Time -----------------------------------------------*/
+extern int xRead_SDL_Time XPP((void *));
+
+/*-- xWri_SDL_Time ------------------------------------------------*/
+extern char * xWri_SDL_Time XPP((void *));
+
+
+
+/* Help functions, also used by sctutil.c and sctmon.c */
+/*-- xReadSDL_Time ------------------------------------------------*/
+extern int xReadSDL_Time XPP((SDL_Time *));
+
+/*-- xWriteSDL_Time -----------------------------------------------*/
+extern char * xWriteSDL_Time XPP((SDL_Time, int));
+
+
+#endif
+   /* XREADANDWRITEF */
+
+
+
+#ifndef XNO_LONG_MACROS
+
+/****+***************************************************************
+04   Generator String
+********************************************************************/
+
+/* typedef for String type ----------------------------------------*/
+
+#define String_Type(SORT, COMPONENTSORT) \
+   typedef struct XCAT(SORT,_ystruct)  * XCAT(SORT,_yptr); \
+   typedef struct XCAT(SORT,_ystruct) { \
+     XCAT(SORT,_yptr)   Suc; \
+     COMPONENTSORT      Data; \
+   } XCAT(SORT,_yrec); \
+   typedef struct { \
+     XCAT(SORT,_yptr) First; \
+     XCAT(SORT,_yptr) Last; \
+     int              Length; \
+     xbool            IsAssigned; \
+   } SORT;
+
+
+/* String operator prototypes -------------------------------------*/
+
+#define String_prototypes(SORT, COMPONENTSORT) \
+  extern SORT XCAT(yEmptystring_,SORT) XPP((void)); \
+  extern SORT XCAT(yMkString_,SORT) XPP((COMPONENTSORT)); \
+  extern SDL_Integer XCAT(yLength_,SORT) XPP((SORT)); \
+  extern COMPONENTSORT XCAT(yFirst_,SORT) XPP((SORT)); \
+  extern COMPONENTSORT XCAT(yLast_,SORT) XPP((SORT)); \
+  extern SORT XCAT(yConcat_,SORT) XPP((SORT, SORT)); \
+  extern SORT XCAT(ySubString_,SORT) \
+     XPP((SORT, SDL_Integer, SDL_Integer)); \
+  extern COMPONENTSORT XCAT(yExtr_,SORT) XPP((SORT, SDL_Integer)); \
+  extern COMPONENTSORT *XCAT(yAddr_,SORT) XPP((SORT *, SDL_Integer)); \
+  \
+  extern XCAT(SORT,_yptr)  XCAT(yGetAvail_,SORT) XPP((void)); \
+  extern void XCAT(yAppend_,SORT) XPP((SORT *result, SORT S)); \
+  \
+  extern char * XCAT(yWri_,SORT) XPP((void * S)); \
+  extern int XCAT(yRead_,SORT) XPP((void * Result));
+
+
+
+/* String operator implementations --------------------------------*/
+
+/*-- yEmptystring_SORT (String)------------------------------------*/
+#define String_Emptystring(SORT, COMPONENTSORT) \
+  extern SORT XCAT(yEmptystring_,SORT) XPP((void)) \
+  { \
+    SORT Result; \
+    Result.First = (XCAT(SORT,_yptr))0; \
+    Result.Last = (XCAT(SORT,_yptr))0; \
+    Result.Length = 0; \
+    Result.IsAssigned = (xbool)0; \
+    return Result; \
+  }
+
+
+/*-- yMkString_SORT (String)---------------------------------------*/
+#define String_MkString(SORT, COMPONENTSORT) \
+  extern XCAT(SORT,_yptr) XCAT(yGetAvail_,SORT) XPP((void)) \
+  { \
+    XCAT(SORT,_yptr) Item; \
+    if (XCAT(yAvail_,SORT) != (XCAT(SORT,_yptr))0) { \
+      Item = XCAT(yAvail_,SORT); \
+      XCAT(yAvail_,SORT) = XCAT(yAvail_,SORT)->Suc; \
+    } else { \
+      Item = (XCAT(SORT,_yptr))xAlloc((unsigned)sizeof(XCAT(SORT,_yrec))); \
+    } \
+    Item->Suc = (XCAT(SORT,_yptr))0; \
+    XCAT(yDef_,COMPONENTSORT)(&Item->Data); \
+    return Item; \
+  } \
+  \
+  extern SORT XCAT(yMkString_,SORT) \
+    XPP_PROTO( (COMPONENTSORT Component) ) \
+    XPP_NOPROTO( (Component) COMPONENTSORT Component; ) \
+  { \
+    SORT Result; \
+    Result.First = XCAT(yGetAvail_,SORT)(); \
+    Result.Last = Result.First; \
+    Result.Length = 1; \
+    Result.IsAssigned = (xbool)0; \
+    XCAT(yAssF_,COMPONENTSORT)(Result.First->Data, Component, XASS); \
+    return Result; \
+  }
+
+
+/*-- yLength_SORT (String)-----------------------------------------*/
+#define String_Length(SORT, COMPONENTSORT) \
+  extern SDL_Integer XCAT(yLength_,SORT) \
+    XPP_PROTO( (SORT S) ) \
+    XPP_NOPROTO( (S) SORT S; ) \
+  { \
+    if (! S.IsAssigned && S.First != (XCAT(SORT,_yptr))0) { \
+      XCAT(yFree_,SORT)((void **)&S); \
+    } \
+    return S.Length; \
+  }
+
+/*-- yFirst_SORT (String)------------------------------------------*/
+#define String_First(SORT, COMPONENTSORT) \
+  extern COMPONENTSORT XCAT(yFirst_,SORT) \
+    XPP_PROTO( (SORT S) ) \
+    XPP_NOPROTO( (S) SORT S; ) \
+  { \
+    COMPONENTSORT Result; \
+    if (S.Length > 0) { \
+      Result = S.First->Data; \
+      if (! S.IsAssigned) { \
+        XCAT(yFree_,SORT)((void **)&S); \
+      } \
+    } else { \
+      xReportStringError("First in String sort", "Length is zero") \
+      (void)memset((void *)(&Result), 0, sizeof(COMPONENTSORT)); \
+      XCAT(yDef_,COMPONENTSORT)(&Result); \
+    } \
+    return Result; \
+  }
+
+
+/*-- yLast_SORT (String)-------------------------------------------*/
+#define String_Last(SORT, COMPONENTSORT) \
+  extern COMPONENTSORT XCAT(yLast_,SORT) \
+    XPP_PROTO( (SORT S) ) \
+    XPP_NOPROTO( (S) SORT S; ) \
+  { \
+    COMPONENTSORT Result; \
+    if (S.Length > 0) { \
+      Result = S.Last->Data; \
+      if (! S.IsAssigned) { \
+        XCAT(yFree_,SORT)((void **)&S); \
+      } \
+    } else { \
+      xReportStringError("Last in String sort", "Length is zero") \
+      (void)memset((void *)(&Result), 0, sizeof(COMPONENTSORT)); \
+      XCAT(yDef_,COMPONENTSORT)(&Result); \
+    } \
+    return Result; \
+  }
+
+
+/*-- yConcat_SORT (String)-----------------------------------------*/
+#define String_Concat(SORT, COMPONENTSORT) \
+  extern void XCAT(yAppend_,SORT) \
+    XPP_PROTO( (SORT *result, SORT S) ) \
+    XPP_NOPROTO( (result, S) SORT *result; SORT S; ) \
+  { \
+    XCAT(SORT,_yptr)  TempSVar, TempExpr; \
+    \
+    (*result).Length = (*result).Length + S.Length; \
+    if (S.IsAssigned) { \
+      TempExpr = S.First; \
+      TempSVar = XCAT(yGetAvail_,SORT)(); \
+      if ((*result).First == (XCAT(SORT,_yptr))0) \
+        (*result).First = TempSVar; \
+      else \
+        (*result).Last->Suc = TempSVar; \
+      XCAT(yAssF_,COMPONENTSORT)(TempSVar->Data, TempExpr->Data, XASS); \
+      \
+      while (TempExpr->Suc != (XCAT(SORT,_yptr))0) { \
+        TempExpr = TempExpr->Suc; \
+        TempSVar->Suc = XCAT(yGetAvail_,SORT)(); \
+        TempSVar = TempSVar->Suc; \
+        XCAT(yAssF_,COMPONENTSORT)(TempSVar->Data, TempExpr->Data, XASS); \
+      } \
+      (*result).Last = TempSVar; \
+    } else { \
+      if ((*result).First == (XCAT(SORT,_yptr))0) \
+        (*result).First = S.First; \
+      else \
+        (*result).Last->Suc = S.First; \
+      (*result).Last = S.Last; \
+    } \
+  } \
+  \
+  \
+  extern SORT XCAT(yConcat_,SORT) \
+    XPP_PROTO( (SORT S1, SORT S2) ) \
+    XPP_NOPROTO( (S1, S2) SORT S1; SORT S2; ) \
+  { \
+    SORT result; \
+    \
+    result.First = (XCAT(SORT,_yptr))0; \
+    result.Last = (XCAT(SORT,_yptr))0; \
+    result.Length = 0; \
+    result.IsAssigned = (xbool)0; \
+    if (S1.Length == 0) { \
+      if (S2.Length == 0) \
+        return result; \
+      else if (! S2.IsAssigned) \
+        return S2; \
+      else { \
+        XCAT(yAppend_,SORT)(&result, S2); \
+      } \
+    } else if (S2.Length == 0) { \
+      if (! S1.IsAssigned) \
+        return S1; \
+      else { \
+        XCAT(yAppend_,SORT)(&result, S1);  \
+      } \
+    } else { \
+      XCAT(yAppend_,SORT)(&result, S1); \
+      XCAT(yAppend_,SORT)(&result, S2); \
+    } \
+    \
+    return result; \
+  }
+
+
+/*-- ySubstring_SORT (String)--------------------------------------*/
+#define String_Substring(SORT, COMPONENTSORT) \
+  extern SORT XCAT(ySubString_,SORT) \
+    XPP_PROTO( (SORT S, SDL_Integer Start, SDL_Integer SubLength) ) \
+    XPP_NOPROTO( (S, Start, SubLength) SORT S; SDL_Integer Start; SDL_Integer SubLength; ) \
+  { \
+    SORT result; \
+    XCAT(SORT,_yptr)  TempSVar, TempExpr; \
+    int I; \
+    \
+    result.First = (XCAT(SORT,_yptr))0; \
+    result.Last = (XCAT(SORT,_yptr))0; \
+    result.Length = 0; \
+    result.IsAssigned = (xbool)0; \
+    if ( S.Length <= 0 ) { \
+      xReportStringError("SubString in string sort", "Length is zero" ) \
+    } else if ( Start <= 0 ) { \
+      xReportStringError("SubString in string sort", \
+                         "Start is less than or equal to zero" ) \
+    } else if ( SubLength <= 0 ) { \
+      xReportStringError("SubString in string sort", \
+                         "SubLength is less than or equal to zero" ) \
+    } else if ( Start+SubLength-1 > S.Length ) { \
+      xReportStringError("SubString in string sort", \
+        "Start+Substring-1 length is greater than string length" ) \
+    } else { \
+      TempExpr = S.First; \
+      for (I=1; I<Start; I++) TempExpr = TempExpr->Suc; \
+      TempSVar = XCAT(yGetAvail_,SORT)(); \
+      result.First = TempSVar; \
+      XCAT(yAssF_,COMPONENTSORT)(TempSVar->Data, TempExpr->Data, XASS); \
+      \
+      for (I=2; I<=SubLength; I++) { \
+        TempExpr = TempExpr->Suc; \
+        TempSVar->Suc = XCAT(yGetAvail_,SORT)(); \
+        TempSVar = TempSVar->Suc; \
+        XCAT(yAssF_,COMPONENTSORT)(TempSVar->Data, TempExpr->Data, XASS); \
+      } \
+      result.Last = TempSVar; \
+      result.Length = SubLength; \
+    } \
+    if (! S.IsAssigned && S.First != (XCAT(SORT,_yptr))0) { \
+      XCAT(yFree_,SORT)((void **)&S); \
+    } \
+    return result; \
+  }
+
+
+
+/*-- yModify_SORT (String)-----------------------------------------*/
+#define String_Modify(SORT, COMPONENTSORT) \
+  extern COMPONENTSORT *XCAT(yAddr_,SORT) \
+    XPP_PROTO( (SORT *S, SDL_Integer Index) ) \
+    XPP_NOPROTO( (S, Index) SORT *S; SDL_Integer Index; ) \
+  { \
+    COMPONENTSORT *result; \
+    XCAT(SORT,_yptr) Temp; \
+    if ((*S).Length == 0) { \
+      xReportStringError("Modify of component of string sort", \
+                         "String is empty. Returns default value" ) \
+      result = (COMPONENTSORT *)xAlloc((xptrint)sizeof(COMPONENTSORT)); \
+      XCAT(yDef_,COMPONENTSORT)(result); \
+      return result; \
+    } else { \
+      if (Index > (*S).Length) { \
+        xReportStringError("Modify of component of string sort", \
+                           "Index > string length. Index set to 1" ) \
+        Index = 1; \
+      } \
+      if (Index <= (SDL_Integer)0) { \
+        xReportStringError("Modify of component of string sort", \
+                           "Index <= 0. Index set to 1" ) \
+        Index = 1; \
+      } \
+      Temp = (*S).First; \
+      for (; Index>1; Index--) Temp = Temp->Suc; \
+      if (! (*S).IsAssigned && (*S).First != (XCAT(SORT,_yptr))0) { \
+        XCAT(yFree_,SORT)((void **)S); \
+      } \
+      return &Temp->Data; \
+    } \
+  }
+
+
+/*-- yExtr_SORT (String)--------------------------------------------*/
+#define String_Extract(SORT, COMPONENTSORT) \
+  extern COMPONENTSORT XCAT(yExtr_,SORT) \
+    XPP_PROTO( (SORT S, SDL_Integer Index) ) \
+    XPP_NOPROTO( (S, Index) SORT S; SDL_Integer Index; ) \
+  { \
+    COMPONENTSORT result; \
+    XCAT(SORT,_yptr) Temp; \
+    if (S.Length == 0) { \
+      xReportStringError("Extract in string sort", \
+                         "String is empty. Returns default value" ) \
+      (void)memset((void *)(&result), 0, sizeof(COMPONENTSORT)); \
+      XCAT(yDef_,COMPONENTSORT)(&result); \
+      return result; \
+    } else { \
+      if (Index > S.Length) { \
+        xReportStringError("Extract in string sort", \
+                           "Index > string length. Index set to 1" ) \
+        Index = 1; \
+      } \
+      if (Index <= (SDL_Integer)0) { \
+        xReportStringError("Extract in string sort", \
+                           "Index <= 0. Index set to 1" ) \
+        Index = 1; \
+      } \
+      Temp = S.First; \
+      for (; Index>1; Index--) Temp = Temp->Suc; \
+      if (! S.IsAssigned && S.First != (XCAT(SORT,_yptr))0) { \
+        XCAT(yFree_,SORT)((void **)&S); \
+      } \
+      return Temp->Data; \
+    } \
+  }
+
+
+/*-- yAss_SORT (String)--------------------------------------------*/
+#define String_Assign(SORT, COMPONENTSORT) \
+  static XCAT(SORT,_yptr)  XCAT(yAvail_,SORT) = (XCAT(SORT,_yptr))0; \
+  extern void XCAT(yAss_,SORT) \
+    XPP_PROTO( (SORT * SVar, SORT SExpr, int AssType) ) \
+    XPP_NOPROTO( (SVar, SExpr, AssType)  SORT * SVar; SORT SExpr; int AssType; ) \
+  { \
+    XCAT(SORT,_yptr)  TempSVar, TempExpr; \
+    \
+    if ((*SVar).First == SExpr.First) \
+      return; \
+    if (AssType == XASS && (*SVar).First != (XCAT(SORT,_yptr))0) { \
+      XCAT(yFree_,SORT)((void **)SVar); \
+    } \
+    if ( (SExpr.IsAssigned || AssType == XASS2MAKE) && \
+         SExpr.First != (XCAT(SORT,_yptr))0) { \
+      TempExpr = SExpr.First; \
+      TempSVar = XCAT(yGetAvail_,SORT)(); \
+      (*SVar).First = TempSVar; \
+      XCAT(yAssF_,COMPONENTSORT)(TempSVar->Data, TempExpr->Data, XASS); \
+      \
+      TempExpr = TempExpr->Suc; \
+      while (TempExpr != (XCAT(SORT,_yptr))0) { \
+        TempSVar->Suc = XCAT(yGetAvail_,SORT)(); \
+        TempSVar = TempSVar->Suc; \
+        XCAT(yAssF_,COMPONENTSORT)(TempSVar->Data, TempExpr->Data, XASS); \
+        TempExpr = TempExpr->Suc; \
+      } \
+      (*SVar).Last = TempSVar; \
+    } else { \
+      (*SVar).First = SExpr.First; \
+      (*SVar).Last = SExpr.Last; \
+    } \
+    (*SVar).Length = SExpr.Length; \
+    (*SVar).IsAssigned = (xbool)1; \
+  }
+
+
+/*-- yEq_SORT (String)---------------------------------------------*/
+#define String_Equal(SORT, COMPONENTSORT) \
+  extern SDL_Boolean XCAT(yEq_,SORT) \
+    XPP_PROTO( (SORT Expr1, SORT Expr2) ) \
+    XPP_NOPROTO( (Expr1, Expr2) SORT Expr1; SORT Expr2; ) \
+  { \
+    XCAT(SORT,_yptr)  Temp1, Temp2; \
+    SDL_Boolean  Result; \
+    \
+    Result = SDL_True; \
+    if (Expr1.Length != Expr2.Length) \
+      Result = SDL_False; \
+    Temp1 = Expr1.First; \
+    Temp2 = Expr2.First; \
+    while (Result && Temp1 != (XCAT(SORT,_yptr))0) { \
+      if (XCAT(yNEqF_,COMPONENTSORT)(Temp1->Data, Temp2->Data) ) \
+        Result = SDL_False; \
+      Temp1 = Temp1->Suc; \
+      Temp2 = Temp2->Suc; \
+    } \
+    if (! Expr1.IsAssigned && Expr1.First != (XCAT(SORT,_yptr))0) { \
+      XCAT(yFree_,SORT)((void **)&Expr1); \
+    } \
+    if (! Expr2.IsAssigned && Expr2.First != (XCAT(SORT,_yptr))0) { \
+      XCAT(yFree_,SORT)((void **)&Expr2); \
+    } \
+    return Result; \
+  }
+
+/*-- yDef_SORT (String)--------------------------------------------*/
+#define String_Default(SORT, COMPONENTSORT) \
+  extern void XCAT(yDef_,SORT) \
+    XPP_PROTO( (SORT *S) ) \
+    XPP_NOPROTO( (S) SORT *S; ) \
+  { \
+    (*S).First = (XCAT(SORT,_yptr))0; \
+    (*S).Last = (XCAT(SORT,_yptr))0; \
+    (*S).Length = 0; \
+    (*S).IsAssigned = (xbool)1; \
+  }
+
+
+/*-- yFree_SORT (String)-------------------------------------------*/
+#ifdef XFREEFUNCS
+#define String_Free(SORT, COMPONENTSORT, HASCOMPFREE) \
+  extern void XCAT(yFree_,SORT) \
+    XPP_PROTO( (void ** C) ) \
+    XPP_NOPROTO( (C) void ** C; ) \
+  { \
+    XCAT(SORT,_yptr)  Temp; \
+    if (HASCOMPFREE) { \
+      for (Temp =  (*(SORT *)C).First; \
+           Temp != (XCAT(SORT,_yptr))0; \
+           Temp =  Temp->Suc) { \
+        XCAT(yFree_,COMPONENTSORT)((void **)&Temp->Data); \
+      } \
+    } \
+    if ((*(SORT *)C).First != (XCAT(SORT,_yptr))0) { \
+      (*(SORT *)C).Last->Suc = XCAT(yAvail_,SORT); \
+      XCAT(yAvail_,SORT) = (*(SORT *)C).First; \
+    } \
+  }
+#else
+#define String_Free(SORT, COMPONENTSORT, HASCOMPFREE) \
+  extern void XCAT(yFree_,SORT) \
+    XPP_PROTO( (void ** C) ) \
+    XPP_NOPROTO( (C) void ** C; ) \
+  { \
+    if ((*(SORT *)C).First != (XCAT(SORT,_yptr))0) { \
+      (*(SORT *)C).Last->Suc = XCAT(yAvail_,SORT); \
+      XCAT(yAvail_,SORT) = (*(SORT *)C).First; \
+    } \
+  }
+#endif
+
+
+/*-- yWri_SORT (String)-------------------------------------------*/
+#define String_Write(SORT, COMPONENTSORT) \
+  extern char * XCAT(yWri_,SORT) \
+    XPP_PROTO( (void * S) ) \
+    XPP_NOPROTO( (S) void * S; ) \
+  { \
+    XCAT(SORT,_yptr) Temp, TempLast; \
+  static  char       CTemp[MAX_WRI_LENGTH]; \
+    \
+    strcpy(CTemp, "(. "); \
+    TempLast = (*(SORT *)S).Last; \
+    for (Temp = (*(SORT *)S).First; \
+         Temp != (XCAT(SORT,_yptr))0; \
+         Temp = Temp->Suc) { \
+      xSafeStrcat(CTemp, \
+             xWriteSort((void *)(&Temp->Data), XCAT(ySrtN_,COMPONENTSORT))); \
+      if (strlen(CTemp) == MAX_WRI_LENGTH - 1) \
+        return CTemp; \
+      if (Temp != TempLast) \
+        xSafeStrcat(CTemp, ", "); \
+    } \
+    xSafeStrcat(CTemp, " .)"); \
+    return CTemp; \
+  }
+
+
+/*-- yRead_SORT (String)------------------------------------------*/
+#define String_Read(SORT, COMPONENTSORT) \
+  extern int XCAT(yRead_,SORT) \
+    XPP_PROTO( (void * Result) ) \
+    XPP_NOPROTO( (Result) void * Result; ) \
+  { \
+    COMPONENTSORT Item; \
+    xxToken       Token; \
+    char          strVar[256]; \
+    int           Res; \
+    \
+    (*(SORT *)Result).First = (XCAT(SORT,_yptr))0; \
+    (*(SORT *)Result).Last = (XCAT(SORT,_yptr))0; \
+    (*(SORT *)Result).Length = 0; \
+    (*(SORT *)Result).IsAssigned = (int)0; \
+    Token = xScanToken(strVar); \
+    if (Token != xxLParDot && Token != xxQuestionMark && Token != xxEoln) { \
+      xPrintString("String value should start with (.\n"); \
+      return 0; \
+    } \
+    if (Token != xxLParDot) xUngetToken(Token, strVar); \
+    \
+    while (Token != xxRParDot) { \
+      sprintf(strVar, " (%s) : ", XCAT(ySrtN_,COMPONENTSORT)->Name); \
+      (void)memset((void *)(&Item), 0, sizeof(COMPONENTSORT)); \
+      Res = xReadOneParameter(XCAT(ySrtN_,COMPONENTSORT), strVar, (void *)&Item); \
+      if (Res == 0) return 0; \
+      if (Res == 2) { \
+        Token = xScanToken(strVar); \
+        if (Token == xxRParDot) break; \
+        return 0; \
+      } \
+      XCAT(yAppend_,SORT)((SORT *)Result, XCAT(yMkString_,SORT)(Item)); \
+      Token = xScanToken(strVar); \
+      if (Token != xxRParDot) xUngetToken(Token, strVar); \
+    } \
+    (*(SORT *)Result).IsAssigned = (int)1; \
+    return 1; \
+  }
+
+/****+***************************************************************
+05   Generator Array  (array that cannot become array in C)
+********************************************************************/
+
+/* typedef for Array type -----------------------------------------*/
+
+#define Array_Type(SORT, INDEXSORT, COMPONENTSORT) \
+   typedef struct XCAT(SORT,_ystruct)  * XCAT(SORT,_yptr); \
+   typedef struct XCAT(SORT,_ystruct) { \
+     XCAT(SORT,_yptr)   Suc; \
+     INDEXSORT          Index; \
+     COMPONENTSORT      Data; \
+   } XCAT(SORT,_yrec); \
+   typedef struct { \
+     XCAT(SORT,_yptr) First; \
+     XCAT(SORT,_yptr) Last; \
+     xbool            IsAssigned; \
+     COMPONENTSORT    Data; \
+   } SORT;
+
+
+/* Array operator prototypes --------------------------------------*/
+
+#define Array_prototypes(SORT, INDEXSORT, COMPONENTSORT) \
+  extern SORT XCAT(yMake_,SORT) XPP((COMPONENTSORT)); \
+  extern COMPONENTSORT XCAT(yExtr_,SORT) XPP((SORT, INDEXSORT)); \
+  extern COMPONENTSORT *XCAT(yAddr_,SORT) XPP((SORT *, INDEXSORT)); \
+  \
+  extern XCAT(SORT,_yptr) XCAT(yGetAvail_,SORT) XPP((void)); \
+  extern COMPONENTSORT XCAT(yExtrInner_,SORT) \
+         XPP((SORT S, INDEXSORT Index)); \
+  \
+  extern char * XCAT(yWri_,SORT) XPP((void * S)); \
+  extern int XCAT(yRead_,SORT) XPP((void * Result));
+
+
+/* Array operator implementations ---------------------------------*/
+
+/*-- yMake_SORT (Array)--------------------------------------------*/
+#define Array_Make(SORT, INDEXSORT, COMPONENTSORT) \
+  extern SORT XCAT(yMake_,SORT) \
+    XPP_PROTO( (COMPONENTSORT Component) ) \
+    XPP_NOPROTO( (Component) COMPONENTSORT Component; ) \
+  { \
+    SORT Result; \
+    Result.First = (XCAT(SORT,_yptr))0; \
+    Result.Last = (XCAT(SORT,_yptr))0; \
+    Result.IsAssigned = (xbool)0; \
+    XCAT(yAssF_,COMPONENTSORT)(Result.Data, Component, XASSMAKE); \
+    return Result; \
+  }
+
+
+/*-- yModify_SORT (Array)------------------------------------------*/
+#define Array_Modify(SORT, INDEXSORT, COMPONENTSORT) \
+  extern XCAT(SORT,_yptr) XCAT(yGetAvail_,SORT) XPP((void)) \
+  { \
+    XCAT(SORT,_yptr) Item; \
+    if (XCAT(yAvail_,SORT) != (XCAT(SORT,_yptr))0) { \
+      Item = XCAT(yAvail_,SORT); \
+      XCAT(yAvail_,SORT) = XCAT(yAvail_,SORT)->Suc; \
+    } else { \
+      Item = (XCAT(SORT,_yptr))xAlloc((unsigned)sizeof(XCAT(SORT,_yrec))); \
+    } \
+    Item->Suc = (XCAT(SORT,_yptr))0; \
+    return Item; \
+  } \
+  \
+  extern COMPONENTSORT *XCAT(yAddr_,SORT) \
+    XPP_PROTO( (SORT *S, INDEXSORT Index) ) \
+    XPP_NOPROTO( (S, Index) SORT *S; INDEXSORT Index; ) \
+  { \
+    XCAT(SORT,_yptr) Temp; \
+    Temp = (*S).First; \
+    while ( Temp != (XCAT(SORT,_yptr))0  && \
+            XCAT(yNEqF_,INDEXSORT)(Temp->Index, Index) ) \
+      Temp = Temp->Suc; \
+    if (Temp != (XCAT(SORT,_yptr))0) \
+      return &Temp->Data; \
+    if ((*S).First == (XCAT(SORT,_yptr))0) { \
+      (*S).First = XCAT(yGetAvail_,SORT)(); \
+      (*S).Last = (*S).First; \
+    } else { \
+      (*S).Last->Suc = XCAT(yGetAvail_,SORT)(); \
+      (*S).Last = (*S).Last->Suc; \
+    } \
+    XCAT(yAssF_,INDEXSORT)((*S).Last->Index, Index, XASS); \
+    XCAT(yAssF_,COMPONENTSORT)((*S).Last->Data, (*S).Data, XASS); \
+    return &(*S).Last->Data; \
+  }
+
+
+/*-- yExtr_SORT (Array)---------------------------------------------*/
+#define Array_Extract(SORT, INDEXSORT, COMPONENTSORT) \
+  \
+  extern COMPONENTSORT XCAT(yExtrInner_,SORT) \
+    XPP_PROTO( (SORT S, INDEXSORT Index) ) \
+    XPP_NOPROTO( (S, Index) SORT S; INDEXSORT Index; ) \
+  { \
+    XCAT(SORT,_yptr) Temp; \
+    Temp = S.First; \
+    while ( Temp != (XCAT(SORT,_yptr))0  && \
+            XCAT(yNEqF_,INDEXSORT)(Temp->Index, Index) ) \
+      Temp = Temp->Suc; \
+    if (Temp != (XCAT(SORT,_yptr))0) \
+      return Temp->Data; \
+    else \
+      return S.Data; \
+  } \
+  \
+  extern COMPONENTSORT XCAT(yExtr_,SORT) \
+    XPP_PROTO( (SORT S, INDEXSORT Index) ) \
+    XPP_NOPROTO( (S, Index) SORT S; INDEXSORT Index; ) \
+  { \
+    COMPONENTSORT result; \
+    result = XCAT(yExtrInner_,SORT)(S, Index); \
+    if (! S.IsAssigned && S.First != (XCAT(SORT,_yptr))0) \
+      XCAT(yFree_,SORT)((void **)&S); \
+    return result; \
+  }
+
+
+/*-- yAss_SORT (Array)---------------------------------------------*/
+#define Array_Assign(SORT, INDEXSORT, COMPONENTSORT) \
+  static XCAT(SORT,_yptr)  XCAT(yAvail_,SORT) = (XCAT(SORT,_yptr))0; \
+  extern void XCAT(yAss_,SORT) \
+    XPP_PROTO( (SORT * SVar, SORT SExpr, int AssType) ) \
+    XPP_NOPROTO( (SVar, SExpr, AssType)  SORT * SVar; SORT SExpr; int AssType; ) \
+  { \
+    XCAT(SORT,_yptr)  TempSVar, TempExpr, PrevExpr; \
+    \
+    if ((*SVar).First != SExpr.First) {\
+      if (AssType == XASS && (*SVar).First != (XCAT(SORT,_yptr))0) \
+        XCAT(yFree_,SORT)((void **)SVar); \
+      if ( (SExpr.IsAssigned || AssType == XASS2MAKE) && \
+           SExpr.First != (XCAT(SORT,_yptr))0) { \
+        TempExpr = SExpr.First; \
+        TempSVar = XCAT(yGetAvail_,SORT)(); \
+        (*SVar).First = TempSVar; \
+        XCAT(yAssF_,INDEXSORT)(TempSVar->Index, TempExpr->Index, XASS); \
+        XCAT(yAssF_,COMPONENTSORT)(TempSVar->Data, TempExpr->Data, XASS); \
+        \
+        TempExpr = TempExpr->Suc; \
+        while (TempExpr != (XCAT(SORT,_yptr))0) { \
+          TempSVar->Suc = XCAT(yGetAvail_,SORT)(); \
+          TempSVar = TempSVar->Suc; \
+          XCAT(yAssF_,INDEXSORT)(TempSVar->Index, TempExpr->Index, XASS); \
+          XCAT(yAssF_,COMPONENTSORT)(TempSVar->Data, TempExpr->Data, XASS); \
+          TempExpr = TempExpr->Suc; \
+        } \
+        (*SVar).Last = TempSVar; \
+      } else { \
+        (*SVar).First = SExpr.First; \
+        (*SVar).Last = SExpr.Last; \
+      } \
+    } \
+    XCAT(yAssF_,COMPONENTSORT)((*SVar).Data, SExpr.Data, XASS); \
+    (*SVar).IsAssigned = (xbool)1; \
+    \
+    PrevExpr = (*SVar).First; \
+    while ( PrevExpr != (XCAT(SORT,_yptr))0 && \
+            XCAT(yEqF_,COMPONENTSORT)(PrevExpr->Data, (*SVar).Data) ) { \
+      (*SVar).First = PrevExpr->Suc; \
+      PrevExpr->Suc = XCAT(yAvail_,SORT); \
+      XCAT(yAvail_,SORT) = PrevExpr; \
+      PrevExpr = (*SVar).First; \
+    } \
+    if ( PrevExpr != (XCAT(SORT,_yptr))0 ) { \
+      while ( PrevExpr->Suc != (XCAT(SORT,_yptr))0 ) { \
+        TempExpr = PrevExpr->Suc; \
+        if ( XCAT(yEqF_,COMPONENTSORT)(TempExpr->Data, (*SVar).Data) ) { \
+          PrevExpr->Suc = TempExpr->Suc; \
+          TempExpr->Suc = XCAT(yAvail_,SORT); \
+          XCAT(yAvail_,SORT) = TempExpr; \
+        } else { \
+          PrevExpr = TempExpr; \
+        } \
+      } \
+    } \
+    (*SVar).Last = PrevExpr; \
+  }
+
+
+/*-- yEq_SORT (Array)----------------------------------------------*/
+#define Array_Equal(SORT, INDEXSORT, COMPONENTSORT) \
+  extern SDL_Boolean XCAT(yEq_,SORT) \
+    XPP_PROTO( (SORT Expr1, SORT Expr2) ) \
+    XPP_NOPROTO( (Expr1, Expr2) SORT Expr1; SORT Expr2; ) \
+  { \
+    XCAT(SORT,_yptr)  Temp; \
+    SDL_Boolean  Result; \
+    \
+    Result = XCAT(yEqF_,COMPONENTSORT)(Expr1.Data, Expr2.Data); \
+    if (Result) { \
+      Temp = Expr1.First; \
+      while (Result && Temp != (XCAT(SORT,_yptr))0) { \
+        if (XCAT(yNEqF_,COMPONENTSORT) \
+             (Temp->Data, XCAT(yExtrInner_,SORT)(Expr2, Temp->Index)) ) \
+          Result = SDL_False; \
+        Temp = Temp->Suc; \
+      } \
+      Temp = Expr2.First; \
+      while (Result && Temp != (XCAT(SORT,_yptr))0) { \
+        if (XCAT(yNEqF_,COMPONENTSORT) \
+             (Temp->Data, XCAT(yExtrInner_,SORT)(Expr1, Temp->Index)) ) \
+          Result = SDL_False; \
+        Temp = Temp->Suc; \
+      } \
+    } \
+    \
+    if (! Expr1.IsAssigned) \
+      XCAT(yFree_,SORT)((void **)&Expr1); \
+    if (! Expr2.IsAssigned) \
+      XCAT(yFree_,SORT)((void **)&Expr2); \
+    return Result; \
+  }
+
+/*-- yDef_SORT (Array)---------------------------------------------*/
+#define Array_Default(SORT, INDEXSORT, COMPONENTSORT) \
+  extern void XCAT(yDef_,SORT) \
+    XPP_PROTO( (SORT *S) ) \
+    XPP_NOPROTO( (S) SORT *S; ) \
+  { \
+    (*S).First = (XCAT(SORT,_yptr))0; \
+    (*S).Last = (XCAT(SORT,_yptr))0; \
+    XCAT(yDef_,COMPONENTSORT)(&(*S).Data); \
+    (*S).IsAssigned = (xbool)1; \
+  }
+
+
+/*-- yFree_SORT (Array)--------------------------------------------*/
+#ifdef XFREEFUNCS
+#define Array_Free(SORT, INDEXSORT, HASINDEXFREE, COMPONENTSORT, HASCOMPFREE) \
+  extern void XCAT(yFree_,SORT) \
+    XPP_PROTO( (void ** C) ) \
+    XPP_NOPROTO( (C) void ** C; ) \
+  { \
+    XCAT(SORT,_yptr)  Temp; \
+    if (HASCOMPFREE || HASINDEXFREE) { \
+      for (Temp =  (*(SORT *)C).First; \
+           Temp != (XCAT(SORT,_yptr))0; \
+           Temp =  Temp->Suc) { \
+        if (HASCOMPFREE) \
+          XCAT(yFree_,COMPONENTSORT)((void **)&Temp->Data); \
+        if (HASINDEXFREE) \
+          XCAT(yFree_,INDEXSORT)((void **)&Temp->Index); \
+      } \
+      if (HASCOMPFREE) \
+        XCAT(yFree_,COMPONENTSORT)((void **)&(*(SORT *)C).Data); \
+    } \
+    if ((*(SORT *)C).First != (XCAT(SORT,_yptr))0) { \
+      (*(SORT *)C).Last->Suc = XCAT(yAvail_,SORT); \
+      XCAT(yAvail_,SORT) = (*(SORT *)C).First; \
+    } \
+  }
+#else
+#define Array_Free(SORT, INDEXSORT, HASINDEXFREE, COMPONENTSORT, HASCOMPFREE) \
+  extern void XCAT(yFree_,SORT) \
+    XPP_PROTO( (void ** C) ) \
+    XPP_NOPROTO( (C) void ** C; ) \
+  { \
+    if ((*(SORT *)C).First != (XCAT(SORT,_yptr))0) { \
+      (*(SORT *)C).Last->Suc = XCAT(yAvail_,SORT); \
+      XCAT(yAvail_,SORT) = (*(SORT *)C).First; \
+    } \
+  }
+#endif
+
+
+/*-- yWri_SORT (Array)---------------------------------------------*/
+#define Array_Write(SORT, INDEXSORT, COMPONENTSORT) \
+  extern char * XCAT(yWri_,SORT) \
+    XPP_PROTO( (void * S) ) \
+    XPP_NOPROTO( (S) void * S; ) \
+  { \
+    XCAT(SORT,_yptr) ArrPtr; \
+  static  char       CTemp[MAX_WRI_LENGTH]; \
+    \
+    strcpy(CTemp, "(: (others:"); \
+    xSafeStrcat(CTemp, \
+       xWriteSort((void *)(&(*(SORT *)S).Data), XCAT(ySrtN_,COMPONENTSORT))); \
+    xSafeStrcat(CTemp, ")"); \
+    for (ArrPtr =  (*(SORT *)S).First; \
+         ArrPtr != (XCAT(SORT,_yptr))0; \
+         ArrPtr =  ArrPtr->Suc) { \
+      xSafeStrcat(CTemp, ", ("); \
+      xSafeStrcat(CTemp, \
+               xWriteSort((void *)(&ArrPtr->Index), XCAT(ySrtN_,INDEXSORT))); \
+      xSafeStrcat(CTemp, ":"); \
+      xSafeStrcat(CTemp, \
+            xWriteSort((void *)(&ArrPtr->Data), XCAT(ySrtN_,COMPONENTSORT))); \
+      xSafeStrcat(CTemp, ")"); \
+    } \
+    xSafeStrcat(CTemp, " :)"); \
+    return CTemp; \
+  }
+
+
+/*-- yRead_SORT (Array)--------------------------------------------*/
+#define Array_Read(SORT, INDEXSORT, COMPONENTSORT) \
+  extern int XCAT(yRead_,SORT) \
+    XPP_PROTO( (void * Result) ) \
+    XPP_NOPROTO( (Result) void * Result; ) \
+  { \
+    INDEXSORT     Index; \
+    COMPONENTSORT Item; \
+    xxToken       Token; \
+    char          strVar[256]; \
+    xbool         IsOthers; \
+    int           Res; \
+    \
+    XCAT(yDef_,SORT)((SORT *)Result); \
+    Token = xScanToken(strVar); \
+    if (Token != xxLParColon && Token != xxQuestionMark && Token != xxEoln) { \
+      xPrintString("Array value should start with (:\n"); \
+      return 0; \
+    } \
+    if (Token != xxLParColon) xUngetToken(Token, strVar); \
+    \
+    IsOthers = (xbool)1; \
+    while (Token != xxRParColon) { \
+      Token = xScanToken(strVar); \
+      if (Token == xxLPar) Token = xScanToken(strVar); \
+      if (! IsOthers) { \
+        if (Token == xxEoln || Token == xxQuestionMark) { \
+          sprintf(strVar, " Index (%s) : ", XCAT(ySrtN_,INDEXSORT)->Name); \
+          xPrintString(strVar); \
+          Token = xScanToken(strVar); \
+        } \
+        if (Token == xxRParColon) break; \
+        xUngetToken(Token, strVar); \
+        (void)memset((void *)(&Index), 0, sizeof(INDEXSORT)); \
+        if ( ! xReadSort((void *)&Index, XCAT(ySrtN_,INDEXSORT))) { \
+          xPrintString("Illegal index value\n"); \
+          return 0; \
+        } \
+        Token = xScanToken(strVar); \
+      } else { \
+        if (Token == xxEoln || Token == xxQuestionMark) { \
+          xPrintString(" others"); \
+        } else if (Token == xxId) { \
+          if (xfEqualIdString(strVar, "others") != 2) { \
+            xPrintString("others expected\n"); \
+            return 0; \
+          } \
+          Token = xScanToken(strVar); \
+        } else { \
+          xPrintString("others expected\n"); \
+          return 0; \
+        } \
+      } \
+      if (Token != xxColon) xUngetToken(Token, strVar); \
+      if (IsOthers) \
+        sprintf(strVar, " Others component (%s) : ", XCAT(ySrtN_,COMPONENTSORT)->Name); \
+      else \
+        sprintf(strVar, " Component (%s) : ", XCAT(ySrtN_,COMPONENTSORT)->Name); \
+      (void)memset((void *)(&Item), 0, sizeof(COMPONENTSORT)); \
+      Res = xReadOneParameter(XCAT(ySrtN_,COMPONENTSORT), strVar, (void *)&Item); \
+      if (Res == 0) { \
+        xPrintString("Illegal component value\n"); \
+        return 0; \
+      } \
+      if (IsOthers) \
+        XCAT(yAss_,SORT)((SORT *)Result, XCAT(yMake_,SORT)(Item), XASS); \
+      else \
+        XCAT(yAssF_,COMPONENTSORT)( \
+            (* XCAT(yAddr_,SORT)((SORT *)Result, Index)) , Item, XASS); \
+      \
+      Token = xScanToken(strVar); \
+      if (Token == xxRPar) Token = xScanToken(strVar); \
+      if (Token == xxComma) Token = xScanToken(strVar); \
+      if (Token != xxRParColon) xUngetToken(Token, strVar); \
+      IsOthers = (xbool)0; \
+    } \
+    (*(SORT *)Result).IsAssigned = (int)1; \
+    return 1; \
+  }
+
+
+/****+***************************************************************
+06   Generator Powerset  (limited and discrete component type)
+********************************************************************/
+
+/* typedef for Powerset type --------------------------------------*/
+
+#define Powerset_Type(SORT, COMPONENTSORT, LOW, HIGH) \
+  typedef struct { \
+    unsigned long A[(HIGH-LOW)/32+1]; \
+  } SORT;
+
+  /* unsigned long is assumed to be 32 bits */
+
+
+#define Powerset_prototypes(SORT, COMPONENTSORT, LOW, HIGH) \
+  extern SORT XCAT(yEmpty_,SORT) XPP((void)); \
+  extern SDL_Boolean XCAT(yIn_,SORT) XPP((COMPONENTSORT, SORT)); \
+  extern SORT XCAT(yIncl_,SORT) XPP((COMPONENTSORT, SORT)); \
+  extern SORT XCAT(yDel_,SORT) XPP((COMPONENTSORT, SORT)); \
+  extern SDL_Boolean XCAT(yLT_,SORT) XPP((SORT, SORT)); \
+  extern SDL_Boolean XCAT(yGT_,SORT) XPP((SORT, SORT)); \
+  extern SDL_Boolean XCAT(yLE_,SORT) XPP((SORT, SORT)); \
+  extern SDL_Boolean XCAT(yGE_,SORT) XPP((SORT, SORT)); \
+  extern SORT XCAT(yAnd_,SORT) XPP((SORT, SORT)); \
+  extern SORT XCAT(yOr_,SORT) XPP((SORT, SORT)); \
+  \
+  extern SDL_Integer XCAT(yCard_,SORT) XPP((SORT)); \
+  extern COMPONENTSORT XCAT(yElement_,SORT) XPP((SORT, SDL_Integer));
+
+
+/*-- yEmpty_SORT (Powerset)----------------------------------------*/
+#define Powerset_Empty(SORT, COMPONENTSORT, LOW, HIGH) \
+  extern SORT XCAT(yEmpty_,SORT) XPP((void)) \
+  { \
+    SORT PS; \
+    int Item; \
+    for (Item=0; Item<=(HIGH-LOW)/32; Item++) \
+      PS.A[Item] = 0; \
+    return PS; \
+  }
+
+
+/*-- yIn_SORT (Powerset)-------------------------------------------*/
+#define Powerset_In(SORT, COMPONENTSORT, LOW, HIGH) \
+  extern SDL_Boolean XCAT(yIn_,SORT) \
+    XPP_PROTO( (COMPONENTSORT Item, SORT PS) ) \
+    XPP_NOPROTO( (Item, PS)  COMPONENTSORT Item; SORT PS; ) \
+  { \
+    if (Item < LOW || Item > HIGH) return SDL_False; \
+    Item = Item - LOW; \
+    if ( ((unsigned long)1 << Item%32) & PS.A[Item/32] ) \
+      return SDL_True; \
+    return SDL_False; \
+  }
+
+
+/*-- yIncl_SORT (Powerset)-----------------------------------------*/
+#define Powerset_Incl(SORT, COMPONENTSORT, LOW, HIGH) \
+  extern SORT XCAT(yIncl_,SORT) \
+    XPP_PROTO( (COMPONENTSORT Item, SORT PS) ) \
+    XPP_NOPROTO( (Item, PS)  COMPONENTSORT Item; SORT PS; ) \
+  { \
+    if (Item < LOW || Item > HIGH) return PS; \
+    Item = Item - LOW; \
+    PS.A[Item/32] = ((unsigned long)1 << Item%32) | PS.A[Item/32]; \
+    return PS; \
+  }
+
+
+/*-- yDel_SORT (Powerset)------------------------------------------*/
+#define Powerset_Del(SORT, COMPONENTSORT, LOW, HIGH) \
+  extern SORT XCAT(yDel_,SORT) \
+    XPP_PROTO( (COMPONENTSORT Item, SORT PS) ) \
+    XPP_NOPROTO( (Item, PS)  COMPONENTSORT Item; SORT PS; ) \
+  { \
+    if (Item < LOW || Item > HIGH) return PS; \
+    Item = Item - LOW; \
+    PS.A[Item/32] = ~((unsigned long)1 << Item%32) & PS.A[Item/32]; \
+    return PS; \
+  }
+
+
+/*-- yAnd_SORT (Powerset)------------------------------------------*/
+#define Powerset_And(SORT, COMPONENTSORT, LOW, HIGH) \
+  extern SORT XCAT(yAnd_,SORT) \
+    XPP_PROTO( (SORT PS1, SORT PS2) ) \
+    XPP_NOPROTO( (PS1, PS2)  SORT PS1; SORT PS2; ) \
+  { \
+    SORT PS; \
+    int Item; \
+    \
+    for (Item=0; Item<=(HIGH-LOW)/32; Item++) \
+      PS.A[Item] = PS1.A[Item] & PS2.A[Item]; \
+    return PS; \
+  }
+
+
+/*-- yOr_SORT (Powerset)-------------------------------------------*/
+#define Powerset_Or(SORT, COMPONENTSORT, LOW, HIGH) \
+  extern SORT XCAT(yOr_,SORT) \
+    XPP_PROTO( (SORT PS1, SORT PS2) ) \
+    XPP_NOPROTO( (PS1, PS2)  SORT PS1; SORT PS2; ) \
+  { \
+    SORT PS; \
+    int Item; \
+    \
+    for (Item=0; Item<=(HIGH-LOW)/32; Item++) \
+      PS.A[Item] = PS1.A[Item] | PS2.A[Item]; \
+    return PS; \
+  }
+
+
+/*-- yLE_SORT (Powerset)-------------------------------------------*/
+#define Powerset_LE(SORT, COMPONENTSORT, LOW, HIGH) \
+  extern SDL_Boolean XCAT(yLE_,SORT) \
+    XPP_PROTO( (SORT PS1, SORT PS2) ) \
+    XPP_NOPROTO( (PS1, PS2)  SORT PS1; SORT PS2; ) \
+  { \
+    int Item; \
+    \
+    for (Item=0; Item<=(HIGH-LOW)/32; Item++) { \
+      if ( (PS2.A[Item] | PS1.A[Item]) ^ PS2.A[Item] ) \
+        return SDL_False; \
+    } \
+    return SDL_True; \
+  }
+
+
+/*-- yLT_SORT (Powerset)-------------------------------------------*/
+#define Powerset_LT(SORT, COMPONENTSORT, LOW, HIGH) \
+  extern SDL_Boolean XCAT(yLT_,SORT) \
+    XPP_PROTO( (SORT PS1, SORT PS2) ) \
+    XPP_NOPROTO( (PS1, PS2)  SORT PS1; SORT PS2; ) \
+  { \
+    int Item; \
+    for (Item=0; Item<=(HIGH-LOW)/32; Item++) { \
+      if ( (PS2.A[Item] | PS1.A[Item]) ^ PS2.A[Item] ) \
+        return SDL_False; \
+    } \
+    for (Item=0; Item<=(HIGH-LOW)/32; Item++) { \
+      if ( PS2.A[Item] ^ PS1.A[Item] ) \
+        return SDL_True; \
+    } \
+    return SDL_False; \
+  }
+
+
+/*-- yGE_SORT (Powerset)-------------------------------------------*/
+#define Powerset_GE(SORT, COMPONENTSORT, LOW, HIGH) \
+  extern SDL_Boolean XCAT(yGE_,SORT) \
+    XPP_PROTO( (SORT PS1, SORT PS2) ) \
+    XPP_NOPROTO( (PS1, PS2)  SORT PS1; SORT PS2; ) \
+  { \
+    int Item; \
+    for (Item=0; Item<=(HIGH-LOW)/32; Item++) { \
+      if ( (PS1.A[Item] | PS2.A[Item]) ^ PS1.A[Item] ) \
+        return SDL_False; \
+    } \
+    return SDL_True; \
+  }
+
+
+/*-- yGT_SORT (Powerset)-------------------------------------------*/
+#define Powerset_GT(SORT, COMPONENTSORT, LOW, HIGH) \
+  extern SDL_Boolean XCAT(yGT_,SORT) \
+    XPP_PROTO( (SORT PS1, SORT PS2) ) \
+    XPP_NOPROTO( (PS1, PS2)  SORT PS1; SORT PS2; ) \
+  { \
+    int Item; \
+    for (Item=0; Item<=(HIGH-LOW)/32; Item++) { \
+      if ( (PS1.A[Item] | PS2.A[Item]) ^ PS1.A[Item] ) \
+        return SDL_False; \
+    } \
+    for (Item=0; Item<=(HIGH-LOW)/32; Item++) { \
+      if ( PS1.A[Item] ^ PS2.A[Item] ) \
+        return SDL_True; \
+    } \
+    return SDL_False; \
+  }
+
+
+/*-- yEq_SORT (Powerset)-------------------------------------------*/
+#define Powerset_Equal(SORT, COMPONENTSORT, LOW, HIGH) \
+  extern SDL_Boolean XCAT(yEq_,SORT) \
+    XPP_PROTO( (SORT Expr1, SORT Expr2) ) \
+    XPP_NOPROTO( (Expr1, Expr2) SORT Expr1; SORT Expr2; ) \
+  { \
+    int Item; \
+    for (Item=0; Item<=(HIGH-LOW)/32; Item++) { \
+      if ( Expr1.A[Item] ^ Expr2.A[Item] ) \
+        return SDL_False; \
+    } \
+    return SDL_True; \
+  }
+
+
+/*-- yDef_SORT (Powerset)------------------------------------------*/
+#define Powerset_Default(SORT, COMPONENTSORT, LOW, HIGH) \
+  extern void XCAT(yDef_,SORT) \
+    XPP_PROTO( (SORT *S) ) \
+    XPP_NOPROTO( (S) SORT *S; ) \
+  { \
+    int Item; \
+    for (Item=0; Item<=(HIGH-LOW)/32; Item++) \
+      (*S).A[Item] = (unsigned long)0; \
+  }
+
+
+
+/****+***************************************************************
+07   Generator Powerset  (general component type)
+********************************************************************/
+
+/* typedef for GPowerset type -------------------------------------*/
+
+#define GPowerset_Type(SORT, COMPONENTSORT) \
+   typedef struct XCAT(SORT,_ystruct)  * XCAT(SORT,_yptr); \
+   typedef struct XCAT(SORT,_ystruct) { \
+     XCAT(SORT,_yptr)   Suc; \
+     COMPONENTSORT      Data; \
+   } XCAT(SORT,_yrec); \
+   typedef struct { \
+     XCAT(SORT,_yptr) First; \
+     XCAT(SORT,_yptr) Last; \
+     int              Length; \
+     xbool            IsAssigned; \
+   } SORT;
+
+
+#define GPowerset_prototypes(SORT, COMPONENTSORT) \
+  extern SORT XCAT(yEmpty_,SORT) XPP((void)); \
+  extern SDL_Boolean XCAT(yIn_,SORT) XPP((COMPONENTSORT, SORT)); \
+  extern SORT XCAT(yIncl_,SORT) XPP((COMPONENTSORT, SORT)); \
+  extern SORT XCAT(yDel_,SORT) XPP((COMPONENTSORT, SORT)); \
+  extern SDL_Boolean XCAT(yLT_,SORT) XPP((SORT, SORT)); \
+  extern SDL_Boolean XCAT(yGT_,SORT) XPP((SORT, SORT)); \
+  extern SDL_Boolean XCAT(yLE_,SORT) XPP((SORT, SORT)); \
+  extern SDL_Boolean XCAT(yGE_,SORT) XPP((SORT, SORT)); \
+  extern SORT XCAT(yAnd_,SORT) XPP((SORT, SORT)); \
+  extern SORT XCAT(yOr_,SORT) XPP((SORT, SORT)); \
+  extern SDL_Integer XCAT(yCard_,SORT) XPP((SORT)); \
+  extern COMPONENTSORT XCAT(yElement_,SORT) XPP((SORT, SDL_Integer)); \
+  \
+  extern SORT XCAT(yCopyList_,SORT) XPP((SORT PS)); \
+  extern SDL_Boolean XCAT(yInInner_,SORT) \
+            XPP((COMPONENTSORT Item, SORT PS)); \
+  extern XCAT(SORT,_yptr) XCAT(yGetAvail_,SORT) XPP((void)); \
+  \
+  extern char * XCAT(yWri_,SORT) XPP((void * PS)); \
+  extern int XCAT(yRead_,SORT) XPP((void * Result));
+
+
+/*-- yEmpty_SORT (GPowerset)---------------------------------------*/
+#define GPowerset_Empty(SORT, COMPONENTSORT) \
+  extern XCAT(SORT,_yptr) XCAT(yGetAvail_,SORT) XPP((void)) \
+  { \
+    XCAT(SORT,_yptr) Item; \
+    if (XCAT(yAvail_,SORT) != (XCAT(SORT,_yptr))0) { \
+      Item = XCAT(yAvail_,SORT); \
+      XCAT(yAvail_,SORT) = XCAT(yAvail_,SORT)->Suc; \
+    } else { \
+      Item = (XCAT(SORT,_yptr))xAlloc((unsigned)sizeof(XCAT(SORT,_yrec))); \
+    } \
+    Item->Suc = (XCAT(SORT,_yptr))0; \
+    return Item; \
+  } \
+  \
+  extern SORT XCAT(yEmpty_,SORT) XPP((void)) \
+  { \
+    SORT Result; \
+    Result.First = (XCAT(SORT,_yptr))0; \
+    Result.Last = (XCAT(SORT,_yptr))0; \
+    Result.Length = 0; \
+    Result.IsAssigned = (xbool)0; \
+    return Result; \
+  }
+
+
+/*-- yIn_SORT (GPowerset)------------------------------------------*/
+#define GPowerset_In(SORT, COMPONENTSORT) \
+  extern SDL_Boolean XCAT(yInInner_,SORT) \
+    XPP_PROTO( (COMPONENTSORT Item, SORT PS) ) \
+    XPP_NOPROTO( (Item, PS)  COMPONENTSORT Item; SORT PS; ) \
+  { \
+    XCAT(SORT,_yptr) Temp; \
+    SDL_Boolean Result; \
+    Result = SDL_False; \
+    for (Temp=PS.First; \
+         Temp!=(XCAT(SORT,_yptr))0 && !Result; \
+         Temp=Temp->Suc) \
+      if ( XCAT(yEqF_,COMPONENTSORT)(Temp->Data, Item) ) \
+        Result = SDL_True; \
+    return Result; \
+  } \
+  \
+  extern SDL_Boolean XCAT(yIn_,SORT) \
+    XPP_PROTO( (COMPONENTSORT Item, SORT PS) ) \
+    XPP_NOPROTO( (Item, PS)  COMPONENTSORT Item; SORT PS; ) \
+  { \
+    SDL_Boolean Result; \
+    Result = XCAT(yInInner_,SORT)(Item, PS); \
+    if (! PS.IsAssigned) \
+      XCAT(yFree_,SORT)((void **)&PS); \
+    return Result; \
+  }
+
+
+/*-- yIncl_SORT (GPowerset)----------------------------------------*/
+#define GPowerset_Incl(SORT, COMPONENTSORT) \
+  extern SORT XCAT(yCopyList_,SORT) \
+    XPP_PROTO( (SORT PS) ) \
+    XPP_NOPROTO( (PS)  SORT PS; ) \
+  { \
+    XCAT(SORT,_yptr) TempPS, TempRes; \
+    SORT Result; \
+    Result = PS; \
+    Result.IsAssigned = (xbool)0; \
+    if (PS.First != (XCAT(SORT,_yptr))0 ) { \
+      TempPS = PS.First; \
+      TempRes = XCAT(yGetAvail_,SORT)(); \
+      XCAT(yAssF_,COMPONENTSORT)(TempRes->Data, TempPS->Data, XASS); \
+      Result.First = TempRes; \
+      while (TempPS->Suc != (XCAT(SORT,_yptr))0) { \
+        TempPS = TempPS->Suc; \
+        TempRes->Suc = XCAT(yGetAvail_,SORT)(); \
+        TempRes = TempRes->Suc; \
+        XCAT(yAssF_,COMPONENTSORT)(TempRes->Data, TempPS->Data, XASS); \
+      } \
+      Result.Last = TempRes; \
+    } \
+    return Result; \
+  } \
+  \
+  extern SORT XCAT(yIncl_,SORT) \
+    XPP_PROTO( (COMPONENTSORT Item, SORT PS) ) \
+    XPP_NOPROTO( (Item, PS)  COMPONENTSORT Item; SORT PS; ) \
+  { \
+    SORT Result; \
+    if (PS.IsAssigned) \
+      Result = XCAT(yCopyList_,SORT)(PS); \
+    else \
+      Result = PS; \
+    if (! XCAT(yInInner_,SORT)(Item, Result) ) { \
+      if (Result.Last == (XCAT(SORT,_yptr))0) { \
+        Result.Last = XCAT(yGetAvail_,SORT)(); \
+        Result.First = Result.Last; \
+      } else { \
+        Result.Last->Suc = XCAT(yGetAvail_,SORT)(); \
+        Result.Last = Result.Last->Suc; \
+      } \
+      XCAT(yAssF_,COMPONENTSORT)(Result.Last->Data, Item, XASS); \
+      Result.Length++; \
+    } \
+    return Result; \
+  }
+
+
+/*-- yDel_SORT (GPowerset)-----------------------------------------*/
+#define GPowerset_Del(SORT, COMPONENTSORT) \
+  extern SORT XCAT(yDel_,SORT) \
+    XPP_PROTO( (COMPONENTSORT Item, SORT PS) ) \
+    XPP_NOPROTO( (Item, PS)  COMPONENTSORT Item; SORT PS; ) \
+  { \
+    SORT Result; \
+    XCAT(SORT,_yptr) Temp, Prev; \
+    if (PS.IsAssigned) \
+      Result = XCAT(yCopyList_,SORT)(PS); \
+    else \
+      Result = PS; \
+    if ( Result.First != (XCAT(SORT,_yptr))0 ) { \
+      Prev = Result.First; \
+      if ( XCAT(yEqF_,COMPONENTSORT)(Prev->Data, Item) ) { \
+        Result.First = Prev->Suc; \
+        if (Result.Last == Prev) Result.Last = (XCAT(SORT,_yptr))0; \
+        Prev->Suc = XCAT(yAvail_,SORT); \
+        XCAT(yAvail_,SORT) = Prev; \
+        Result.Length--; \
+        return Result; \
+      } \
+      for (Temp=Prev->Suc; \
+           Temp!=(XCAT(SORT,_yptr))0; \
+           Temp=Temp->Suc) { \
+        if ( XCAT(yEqF_,COMPONENTSORT)(Temp->Data, Item) ) {\
+          Prev->Suc = Temp->Suc; \
+          if (Result.Last == Temp) Result.Last = Prev; \
+          Temp->Suc = XCAT(yAvail_,SORT); \
+          XCAT(yAvail_,SORT) = Temp; \
+          Result.Length--; \
+          return Result; \
+        } \
+        Prev = Temp; \
+      } \
+    } \
+    return Result; \
+  }
+
+
+/*-- yAnd_SORT (GPowerset)-----------------------------------------*/
+#define GPowerset_And(SORT, COMPONENTSORT) \
+  extern SORT XCAT(yAnd_,SORT) \
+    XPP_PROTO( (SORT PS1, SORT PS2) ) \
+    XPP_NOPROTO( (PS1, PS2)  SORT PS1; SORT PS2; ) \
+  { \
+    SORT Result; \
+    XCAT(SORT,_yptr) Temp; \
+    Result = XCAT(yEmpty_,SORT)(); \
+    for (Temp=PS1.First; Temp!=(XCAT(SORT,_yptr))0; Temp=Temp->Suc) \
+      if ( XCAT(yInInner_,SORT)(Temp->Data, PS2) ) { \
+        if (Result.First == (XCAT(SORT,_yptr))0) { \
+          Result.First = XCAT(yGetAvail_,SORT)(); \
+          Result.Last = Result.First; \
+        } else { \
+          Result.Last->Suc = XCAT(yGetAvail_,SORT)(); \
+          Result.Last = Result.Last->Suc; \
+        } \
+        XCAT(yAssF_,COMPONENTSORT)(Result.Last->Data, Temp->Data, XASS); \
+        Result.Length++; \
+      } \
+    if (! PS1.IsAssigned) \
+      XCAT(yFree_,SORT)((void **)&PS1); \
+    if (! PS2.IsAssigned) \
+      XCAT(yFree_,SORT)((void **)&PS2); \
+    return Result; \
+  }
+
+
+/*-- yOr_SORT (GPowerset)------------------------------------------*/
+#define GPowerset_Or(SORT, COMPONENTSORT) \
+  extern SORT XCAT(yOr_,SORT) \
+    XPP_PROTO( (SORT PS1, SORT PS2) ) \
+    XPP_NOPROTO( (PS1, PS2)  SORT PS1; SORT PS2; ) \
+  { \
+    SORT Result; \
+    XCAT(SORT,_yptr) Temp; \
+    if (PS2.IsAssigned) \
+      Result = XCAT(yCopyList_,SORT)(PS2); \
+    else \
+      Result = PS2; \
+    for (Temp=PS1.First; Temp!=(XCAT(SORT,_yptr))0; Temp=Temp->Suc) \
+      if ( ! XCAT(yInInner_,SORT)(Temp->Data, Result) ) { \
+        if (Result.First == (XCAT(SORT,_yptr))0) { \
+          Result.First = XCAT(yGetAvail_,SORT)(); \
+          Result.Last = Result.First; \
+        } else { \
+          Result.Last->Suc = XCAT(yGetAvail_,SORT)(); \
+          Result.Last = Result.Last->Suc; \
+        } \
+        XCAT(yAssF_,COMPONENTSORT)(Result.Last->Data, Temp->Data, XASS); \
+        Result.Length++; \
+      } \
+    if (! PS1.IsAssigned) \
+      XCAT(yFree_,SORT)((void **)&PS1); \
+    return Result; \
+  }
+
+
+/*-- yLE_SORT (GPowerset)------------------------------------------*/
+#define GPowerset_LE(SORT, COMPONENTSORT) \
+  extern SDL_Boolean XCAT(yLE_,SORT) \
+    XPP_PROTO( (SORT PS1, SORT PS2) ) \
+    XPP_NOPROTO( (PS1, PS2)  SORT PS1; SORT PS2; ) \
+  { \
+    XCAT(SORT,_yptr) Temp; \
+    SDL_Boolean Result; \
+    Result = PS1.Length <= PS2.Length; \
+    for (Temp=PS1.First; \
+         Temp!=(XCAT(SORT,_yptr))0 && Result; \
+         Temp=Temp->Suc) \
+      if ( ! XCAT(yInInner_,SORT)(Temp->Data, PS2) ) \
+        Result = SDL_False; \
+    if (! PS1.IsAssigned) \
+      XCAT(yFree_,SORT)((void **)&PS1); \
+    if (! PS2.IsAssigned) \
+      XCAT(yFree_,SORT)((void **)&PS2); \
+    return Result; \
+  }
+
+
+/*-- yLT_SORT (GPowerset)------------------------------------------*/
+#define GPowerset_LT(SORT, COMPONENTSORT) \
+  extern SDL_Boolean XCAT(yLT_,SORT) \
+    XPP_PROTO( (SORT PS1, SORT PS2) ) \
+    XPP_NOPROTO( (PS1, PS2)  SORT PS1; SORT PS2; ) \
+  { \
+    XCAT(SORT,_yptr) Temp; \
+    SDL_Boolean Result; \
+    Result = PS1.Length < PS2.Length; \
+    for (Temp=PS1.First; \
+         Temp!=(XCAT(SORT,_yptr))0 && Result; \
+         Temp=Temp->Suc) \
+      if ( ! XCAT(yInInner_,SORT)(Temp->Data, PS2) ) \
+        Result = SDL_False; \
+    if (! PS1.IsAssigned) \
+      XCAT(yFree_,SORT)((void **)&PS1); \
+    if (! PS2.IsAssigned) \
+      XCAT(yFree_,SORT)((void **)&PS2); \
+    return Result; \
+  }
+
+
+/*-- yGE_SORT (GPowerset)------------------------------------------*/
+#define GPowerset_GE(SORT, COMPONENTSORT) \
+  extern SDL_Boolean XCAT(yGE_,SORT) \
+    XPP_PROTO( (SORT PS1, SORT PS2) ) \
+    XPP_NOPROTO( (PS1, PS2)  SORT PS1; SORT PS2; ) \
+  { \
+    return XCAT(yLE_,SORT)(PS2, PS1); \
+  }
+
+
+/*-- yGT_SORT (GPowerset)------------------------------------------*/
+#define GPowerset_GT(SORT, COMPONENTSORT) \
+  extern SDL_Boolean XCAT(yGT_,SORT) \
+    XPP_PROTO( (SORT PS1, SORT PS2) ) \
+    XPP_NOPROTO( (PS1, PS2)  SORT PS1; SORT PS2; ) \
+  { \
+    return XCAT(yLT_,SORT)(PS2, PS1); \
+  }
+
+
+/*-- yAss_SORT (GPowerset)-----------------------------------------*/
+#define GPowerset_Assign(SORT, COMPONENTSORT) \
+  static XCAT(SORT,_yptr)  XCAT(yAvail_,SORT) = (XCAT(SORT,_yptr))0; \
+  extern void XCAT(yAss_,SORT) \
+    XPP_PROTO( (SORT * SVar, SORT SExpr, int AssType) ) \
+    XPP_NOPROTO( (SVar, SExpr, AssType)  SORT * SVar; SORT SExpr; int AssType; ) \
+  { \
+    if ((*SVar).First == SExpr.First) { \
+      (*SVar).IsAssigned = (xbool)1; \
+      return; \
+    } \
+    if (AssType == XASS && (*SVar).First != (XCAT(SORT,_yptr))0) { \
+      XCAT(yFree_,SORT)((void **)SVar); \
+    } \
+    if ( (SExpr.IsAssigned || AssType == XASS2MAKE) && \
+         SExpr.First != (XCAT(SORT,_yptr))0) { \
+      *SVar = XCAT(yCopyList_,SORT)(SExpr); \
+    } else { \
+      (*SVar).First = SExpr.First; \
+      (*SVar).Last = SExpr.Last; \
+      (*SVar).Length = SExpr.Length; \
+    } \
+    (*SVar).IsAssigned = (xbool)1; \
+  }
+
+
+/*-- yEq_SORT (GPowerset)------------------------------------------*/
+#define GPowerset_Equal(SORT, COMPONENTSORT) \
+  extern SDL_Boolean XCAT(yEq_,SORT) \
+    XPP_PROTO( (SORT Expr1, SORT Expr2) ) \
+    XPP_NOPROTO( (Expr1, Expr2) SORT Expr1; SORT Expr2; ) \
+  { \
+    XCAT(SORT,_yptr) Temp; \
+    SDL_Boolean Result; \
+    Result = Expr1.Length == Expr2.Length; \
+    for (Temp=Expr1.First; \
+         Temp!=(XCAT(SORT,_yptr))0 && Result; \
+         Temp=Temp->Suc) \
+      if ( ! XCAT(yInInner_,SORT)(Temp->Data, Expr2) ) \
+        Result = SDL_False; \
+    if (! Expr1.IsAssigned) \
+      XCAT(yFree_,SORT)((void **)&Expr1); \
+    if (! Expr2.IsAssigned) \
+      XCAT(yFree_,SORT)((void **)&Expr2); \
+    return Result; \
+  }
+
+
+/*-- yDef_SORT (GPowerset)-----------------------------------------*/
+#define GPowerset_Default(SORT, COMPONENTSORT) \
+  extern void XCAT(yDef_,SORT) \
+    XPP_PROTO( (SORT *S) ) \
+    XPP_NOPROTO( (S) SORT *S; ) \
+  { \
+    (*S).First = (XCAT(SORT,_yptr))0; \
+    (*S).Last = (XCAT(SORT,_yptr))0; \
+    (*S).Length = 0; \
+    (*S).IsAssigned = (xbool)1; \
+  }
+
+
+/*-- yFree_SORT (GPowerset)---------------------------------------*/
+#ifdef XFREEFUNCS
+#define GPowerset_Free(SORT, COMPONENTSORT, HASCOMPFREE) \
+  extern void XCAT(yFree_,SORT) \
+    XPP_PROTO( (void ** C) ) \
+    XPP_NOPROTO( (C) void ** C; ) \
+  { \
+    XCAT(SORT,_yptr)  Temp; \
+    if (HASCOMPFREE) { \
+      for (Temp =  (*(SORT *)C).First; \
+           Temp != (XCAT(SORT,_yptr))0; \
+           Temp =  Temp->Suc) { \
+        XCAT(yFree_,COMPONENTSORT)((void **)&Temp->Data); \
+      } \
+    } \
+    if ((*(SORT *)C).First != (XCAT(SORT,_yptr))0) { \
+      (*(SORT *)C).Last->Suc = XCAT(yAvail_,SORT); \
+      XCAT(yAvail_,SORT) = (*(SORT *)C).First; \
+    } \
+  }
+#else
+#define GPowerset_Free(SORT, COMPONENTSORT, HASCOMPFREE) \
+  extern void XCAT(yFree_,SORT) \
+    XPP_PROTO( (void ** C) ) \
+    XPP_NOPROTO( (C) void ** C; ) \
+  { \
+    if ((*(SORT *)C).First != (XCAT(SORT,_yptr))0) { \
+      (*(SORT *)C).Last->Suc = XCAT(yAvail_,SORT); \
+      XCAT(yAvail_,SORT) = (*(SORT *)C).First; \
+    } \
+  }
+#endif
+
+
+/*-- yCard_SORT (GPowerset)---------------------------------------*/
+#define GPowerset_Card(SORT, COMPONENTSORT) \
+  extern SDL_Integer XCAT(yCard_,SORT) \
+    XPP_PROTO( (SORT PS) ) \
+    XPP_NOPROTO( (PS)  SORT PS; ) \
+  { \
+    return PS.Length; \
+  }
+
+
+/*-- yElement_SORT (GPowerset)------------------------------------*/
+#define GPowerset_Element(SORT, COMPONENTSORT) \
+  extern COMPONENTSORT XCAT(yElement_,SORT) \
+    XPP_PROTO( (SORT PS, SDL_Integer Index) ) \
+    XPP_NOPROTO( (PS, Index)  SORT PS; SDL_Integer Index; ) \
+  { \
+    XCAT(SORT,_yptr) Temp; \
+    int Number = 0; \
+    COMPONENTSORT Result; \
+    for (Temp=PS.First; \
+         Temp!=(XCAT(SORT,_yptr))0 && ++Number<Index; \
+         Temp=Temp->Suc) ; \
+    if (Number == Index && Temp != (XCAT(SORT,_yptr))0) \
+      return Temp->Data; \
+    xReportStringError("Element in Powerset sort", "Index out of range") \
+    (void)memset((void *)(&Result), 0, sizeof(COMPONENTSORT)); \
+    XCAT(yDef_,COMPONENTSORT)(&Result); \
+    return Result; \
+  }
+
+
+/*-- yWri_SORT (GPowerset)----------------------------------------*/
+#define GPowerset_Write(SORT, COMPONENTSORT) \
+  extern char * XCAT(yWri_,SORT) \
+    XPP_PROTO( (void * PS) ) \
+    XPP_NOPROTO( (PS) void * PS; ) \
+  { \
+    XCAT(SORT,_yptr) Temp, TempLast; \
+  static  char       CTemp[MAX_WRI_LENGTH]; \
+    \
+    strcpy(CTemp, "[ "); \
+    TempLast = (*(SORT *)PS).Last; \
+    for (Temp = (*(SORT *)PS).First; \
+         Temp != (XCAT(SORT,_yptr))0; \
+         Temp = Temp->Suc) { \
+      xSafeStrcat(CTemp, \
+             xWriteSort((void *)(&Temp->Data), XCAT(ySrtN_,COMPONENTSORT))); \
+      if (strlen(CTemp) == MAX_WRI_LENGTH - 1) \
+        return CTemp; \
+      if (Temp != TempLast) \
+        xSafeStrcat(CTemp, ", "); \
+    } \
+    xSafeStrcat(CTemp, " ]"); \
+    return CTemp; \
+  }
+
+
+/*-- yRead_SORT (GPowerset)---------------------------------------*/
+#define GPowerset_Read(SORT, COMPONENTSORT) \
+  extern int XCAT(yRead_,SORT) \
+    XPP_PROTO( (void * Result) ) \
+    XPP_NOPROTO( (Result) void * Result; ) \
+  { \
+    COMPONENTSORT Item; \
+    xxToken       Token; \
+    char          strVar[256]; \
+    int           Res; \
+    \
+    (*(SORT *)Result).First = (XCAT(SORT,_yptr))0; \
+    (*(SORT *)Result).Last = (XCAT(SORT,_yptr))0; \
+    (*(SORT *)Result).Length = 0; \
+    (*(SORT *)Result).IsAssigned = (int)0; \
+    Token = xScanToken(strVar); \
+    if (Token != xxLBracket && Token != xxQuestionMark && Token != xxEoln) { \
+      xPrintString("Powerset value should start with [\n"); \
+      return 0; \
+    } \
+    if (Token != xxLBracket) xUngetToken(Token, strVar); \
+    \
+    while (Token != xxRBracket) { \
+      sprintf(strVar, " (%s) : ", XCAT(ySrtN_,COMPONENTSORT)->Name); \
+      (void)memset((void *)(&Item), 0, sizeof(COMPONENTSORT)); \
+      Res = xReadOneParameter(XCAT(ySrtN_,COMPONENTSORT), strVar, (void *)&Item); \
+      if (Res == 0) return 0; \
+      if (Res == 2) { \
+        Token = xScanToken(strVar); \
+        if (Token == xxRBracket) break; \
+        return 0; \
+      } \
+      *(SORT *)Result = XCAT(yIncl_,SORT)(Item, *(SORT *)Result); \
+      Token = xScanToken(strVar); \
+      if (Token != xxRBracket) xUngetToken(Token, strVar); \
+    } \
+    (*(SORT *)Result).IsAssigned = (int)1; \
+    return 1; \
+  }
+#endif
+   /* XNO_LONG_MACROS */
+
+
+
+
+#endif
+   /* X_SCTPRED_H */
+
+/*******************************************************************************
+* History log:
+*===============================================================================
+* $Log: sctpred.h,v $
+* Revision 1.4  2001/07/18 13:01:54  pbo
+* New Release UGLOBE_2
+*
+* Revision 3.0  2001/07/18 11:29:36  pbo
+* DUM_2
+*
+* Revision 2.0  2001/06/12 11:52:25  pbo
+* DUM_1
+*
+* Revision 1.1.1.1  2001/03/28 13:37:25  pbo
+* Initial version
+*
+*******************************************************************************/
+
diff --git a/cp/ps/modem/psbase/inc/scttypes.h b/cp/ps/modem/psbase/inc/scttypes.h
new file mode 100644
index 0000000..642c842
--- /dev/null
+++ b/cp/ps/modem/psbase/inc/scttypes.h
@@ -0,0 +1,1178 @@
+#ifndef _SCTTYPES_H

+#define _SCTTYPES_H

+

+#ifdef _OS_LINUX

+#include <linux/string.h>

+#else

+#include <string.h>

+#endif

+#include "oss_api.h"  /* ƽ̨¼Ü¹¹OS×Óϵͳ */

+#ifdef _OS_OSE

+#include "ose.h"         /* ose API set_pri() */

+#endif

+

+#include "pub.h"  

+#include "base_api.h"

+#include "proc_id.h"

+#include "sig_code.h"

+//#include "ms_cfg.h"

+

+

+extern VOID * ps_calloc ( size_t, size_t );

+extern VOID * ps_malloc ( size_t );

+extern VOID * zrealloc( void *, size_t );

+extern VOID   ps_free   ( void * );

+

+#define xAlloc(_size)   ps_malloc( (_size) )

+#define xFreeBlock(_mem)     ps_free( (_mem) )

+#define xFree(_mem)                                                         \

+    {                                                                       \

+        barrier();                                                          \

+        ps_free( *((void **)(_mem)) );                                      \

+        *((void **)(_mem)) = NULL;                                          \

+    }

+#define xCAlloc(_size)  ps_calloc( 1, (_size) )

+#define xReAlloc(_mem, _size)  zrealloc( ((void *)_mem), (_size) )

+

+/*Name:KangShuJie Date:2007.01.28 Reason:ϵͳÊÊÅä*/

+#ifdef _OS_WIN

+#define set_pri(pri) zOss_SetThreadPri(zOss_GetCurThreadID(),pri)

+#endif

+/*End KangShuJie*/

+

+

+#define ICU_set_current_prio(pri)    zDrv_MaskIntByPri(pri)   /*set_pri(pri)*/

+

+

+#ifndef MAX

+#define MAX(A,B) ( (A) > (B) ? (A) : (B) )

+#endif

+

+#define UNSIGNED_PER_PTR ( sizeof ( UNSIGNED ) / sizeof ( void * ) )

+#ifndef NULL

+#define NULL ( (void *) 0 )

+#endif

+

+#ifndef Null

+#define Null()  0

+#endif

+

+

+#define Ref2VStarStar(P)  ((VoidStarStar)P)

+#define XXMALLOC(_size)  xAlloc(_size)

+

+#define XALLOC(SIZE,SORTIDNODE)  xAlloc(SIZE)

+#define XFREE(P,SIZE)            xFree(P)

+#define XCALLOC(SIZE,SORTIDNODE) xCAlloc(SIZE)

+

+#if defined(NEAR)

+#undef NEAR

+#endif

+

+#if defined(FAR)

+#undef FAR

+#endif

+

+//#if defined(_C166)

+//#define NEAR near

+//#define FAR  far

+//#else

+#define NEAR

+#define FAR

+

+#define huge

+#define shuge

+#define stackparm

+#define _at(A)

+#ifdef _USE_CMPL_GCC

+#define _nop()  asm("nop"); 

+#else

+#define _nop() __asm{ NOP }

+#endif

+//#endif

+

+

+

+#define SDL_TIMER_WITH_PARA

+

+#define XNOSTATICSTRUCTURE

+#define XNOUSEOFREAL

+#define XNOUSEOFSERVICE

+

+#define X_COMPACT_BOOL

+

+

+/*----------------------------------------------------------------------------

+ * MACRO: DEBUG

+ * USGAE: ENABLE DEBUGGING PRINTING FROM EACH SDL CONCEPT MAPPING ENTITY

+ * DATE:  9-1-93

+ *--------------------------------------------------------------------------*/

+/* #define XOS_TRACE  */

+#define XOS_INCLUDE

+

+

+/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

+ *      General macros

+ *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

+

+/*---------------------------------------------------------------------------

+ * If ANSI function prototypes

+ *      then XPP(x) defined as x

+ * else If old style functions

+ *      then define XPP(X) as () and

+ *      XNOPROTO should be defined

+ *--------------------------------------------------------------------------*/

+/* #define XPP(x) () */

+/* #define XNOPROTO */

+#define XPP(x)  x

+#define XPQ(x)

+

+#define XCONST const

+#define XCONST_NOPART const

+#define XCONST_COMP const

+#define COMMENT(COMMENT)

+

+/*---------------------------------------------------------------------------

+ * xptrint should be the same length as a pointer

+ * xint32 should be 32-bits int type

+ * xIdNode is a dummy type

+ *--------------------------------------------------------------------------*/

+#define xptrint unsigned

+#define xint32  unsigned long

+

+typedef struct xPrsStruct  *xPrsNode;

+typedef struct xIdStruct   *xIdNode;

+

+

+/*---------------------------------------------------------------------------

+ *  Define following macros to strip off all debugging code

+ *  Note: 9-9-93/

+ *        XNOSIGNALIDNODE NEEDS TO BE REMOVED FOR GUARDED IDNODE VARIABLES

+ *--------------------------------------------------------------------------*/

+#ifdef XNOSTATICSTRUCTURE

+#define XNOBLOCKIDNODE

+#define XNOSUBSTRIDNODE

+#define XOPTCHAN

+#define XNOPRSIDNODE

+#endif

+

+#define XNOPRDIDNODE

+#define XNOSIGNALIDNODE

+#define XNOSTARTUPIDNODE

+#define XNOIMPORTEDIDNODE

+#define XNOEXPORTEDIDNODE

+#define XNOSTATEIDNODE

+#define XOPTSIGPARA

+#define XOPTDCL

+#define XOPTFPAR

+#define XOPTSTRUCT

+#define XOPTLIT

+#define XOPTSORT

+

+#define XNOPROCATSTARTUP

+#define XNOCONTSIGFUNC

+#define XNOENABCONDFUNC

+

+#define XNOMAIN

+

+

+#define xPrsPrioPar(p) p,

+#define xPrsPrioParS(p) p;

+#define xSigPrioPar(p) p,

+#define xSigPrioParS(p) p;

+#define xReent(p)

+#define xReentE(p)

+#define xReentS(p)

+

+#define xTestF(p)

+#define xTestFS(p)

+#define xRaWF(p)

+#define xRaWFS(p)

+#define xFreF(p)

+#define xFreFS(p)

+#define xFreS(p)

+#define xFreSS(p)

+#define xAssF(p)

+#define xEqF(p)

+#ifdef XIDNAMES

+#define xIdNames(p) p,

+#define xIdNamesS(p) p;

+#else

+#define xIdNames(p)

+#define xIdNamesS(p)

+#endif

+#define xeView(p)

+#define xeViewS(p)

+#define xCTrace(p)

+#define xCTraceS(p)

+#ifndef XOPTCHAN

+#define xOptChan(p)  p,

+#define xOptChanS(p) p;

+#else

+#define xOptChan(p)

+#define xOptChanS(p)

+#endif

+#define xGRTrace(p)

+#define xGRTraceS(p)

+

+#ifndef xDefaultPrioProcess

+#define xDefaultPrioProcess      128

+#endif

+

+#ifndef xDefaultPrioSignal

+#define xDefaultPrioSignal       1

+#endif

+

+#ifndef xDefaultPrioTimerSignal

+#define xDefaultPrioTimerSignal  1

+#endif

+

+#ifndef xDefaultPrioContSignal

+#define xDefaultPrioContSignal   1

+#endif

+

+#ifndef xDefaultPrioCreate

+#define xDefaultPrioCreate       1

+#endif

+

+#define xbool int

+#define XASS        0

+#define XASSMAKE    1

+#define XASS2MAKE   2

+

+

+/*---------------------------------------------------------------------------

+ * Execution Trace Info

+ *

+ *-------------------------------------------------------------------------*/

+

+#define YPRSNAME_VAR(PRS_NAME_STRING)

+#define YPRDNAME_VAR(PRD_NAME_STRING)

+#define XOS_TRACE_OUTPUT(SIG_NAME_STRING)

+#define XOS_TRACE_CREATE(PROC_NAME_STRING)

+#define XOS_TRACE_STATIC_CREATE(PROC_NAME_STRING)

+#define XOS_TRACE_STOP

+#define XOS_TRACE_CALL

+#define XOS_TRACE_RETURN

+#define XOS_TRACE_SET(TIMER_NAME_STRING, DUR_EXPR)

+#define XOS_TRACE_SET_TICKS(TIMER_NAME_STRING, DUR_EXPR)

+#define XOS_TRACE_SET_DELTA_TIMER(TIMERPTR)

+#define XOS_TRACE_RESET(TIMER_NAME_STRING)

+#define XOS_TRACE_ACTIVE(TIMER_IDNODE)

+#define XOS_TRACE_REMOVE_TIMER(TIMERPTR)

+#define XOS_TRACE_NEXTSTATE(STATE_NAME_STRING)

+#define XOS_TRACE_DASH_NEXTSTATE

+#define XOS_TRACE_INPUT(SIG_NAME_STRING)

+#define XOS_TRACE_SAVE(SIG_NAME_STRING)

+#define XOS_TRACE_SAVE_ENABLING_C

+#define XOS_TRACE_DISCARD

+#define XOS_TRACE_DISCARD_SIG(SIG_CODE)

+#define XOS_TRACE_TIMER_TIMEOUTSIG(TIMERPTR)

+#define XOS_TRACE_CHECK_TIMER(SYS_TICKS)

+

+

+#define XAT_FIRST_SYMBOL(SYMB_NO)

+#define XBETWEEN_SYMBOLS(SYMB_NO, C_LINE_NO)

+#define XBETWEEN_SYMBOLS_PRD(SYMB_NO, C_LINE_NO)

+#define XAT_LAST_SYMBOL

+

+#define XDEBUG_LABEL(L)

+

+#define XBETWEEN_STMTS(SYMB_NO, C_LINE_NO)

+#define XBETWEEN_STMTS_PRD(SYMB_NO, C_LINE_NO)

+

+

+/* msala 27.06.01 */

+#define XCHECK_REF(VALUE,REF_SORTIDNODE,REF_SORT)

+#define XCHECK_CHOICE_USAGE(TAG,VALUE,NEQTAG,COMPNAME,CURR_VALUE)

+#define XSET_CHOICE_TAG(TAG,VALUE,ASSTAG,NEQTAG,COMPNAME,CURR_VALUE,TYPEINFO) \

+TAG = (VALUE);

+

+

+#define XAFTER_VALUE_RET_PRDCALL(A)

+/* end msala 27.06.01 */

+

+/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

+ *      Macros to Implement SDL

+ *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

+

+#ifdef NOT_INCLUDE_SDL_HEAD

+#define SIGNAL_VARS

+#else

+#define SIGNAL_VARS \

+    xSignalHeader pred; \

+    xSignalHeader succ; \

+    SIGREFTYPE    SignalCode; \

+    unsigned int  sender_id;\

+   SDL_PId       Sender; 

+#endif

+

+#ifdef UNITEST

+#define HEADER_REC(REC_TYPE) \

+   x##REC_TYPE##Header pred; \

+   x##REC_TYPE##Header succ; \

+   SIGREFTYPE     SignalCode; \

+   unsigned char  sender_id; \

+   SDL_PId        Sender;

+#endif

+/*

+ *  soft timers implementation:

+ *  ee_succ: earliest expiry (single linked list)

+ *  le_succ: latest expiry (single linked list)

+ */

+

+#define TIMER_VARS \

+    xTimerHeader ee_succ; \

+    xTimerHeader le_succ; \

+    SIGREFTYPE   SignalCode; \

+    SDL_PId      Sender; \

+    SdlTimeSpec  ee_time; \

+SdlTimeSpec      le_time;

+

+#define TIMER_PARA_VARS TIMER_VARS /*add by gongyi 080203*/

+

+/*---------------------------------------------------------------------------

+ *   PId

+ *   SDL_PId <-> QID

+ *   9-8-93 : Define xDef_SDL_PId() for default PId variable

+ *--------------------------------------------------------------------------*/

+

+

+

+

+

+

+

+

+

+/* hba 25-05-94 */

+

+

+

+#define xDef_SDL_PId(V)       (*(V) = SDL_NULL)

+#define yDef_SDL_PId(V)       xDef_SDL_PId(V)

+#define xEq_SDL_PId(A,B)      ((A)==(B))

+#define yAssF_SDL_PId(V,E,A)  (V = E)

+#define yEqF_SDL_PId(E1,E2)   xEq_SDL_PId(E1,E2)

+#define yNEqF_SDL_PId(E1,E2)  (! xEq_SDL_PId(E1,E2))

+

+#define xNotDefPId            0

+

+#define XPID_LIT1(A)          &queue_table[P_##A]

+#define XPID_LIT2(A,I)        &queue_table[P_##A+I]

+#define XPID_LIT3(A)          &queue_table[P_##A]

+#define XASS_PIDLIST(V,E,A)

+#define XEXTR_PIDLIST(v,i) &queue_table[P_##v+i-1]

+

+/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

+ * Signal implementation and SDL Save

+ *+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

+

+

+

+

+

+

+

+

+

+/****+***************************************************************

+10   Signal Set

+********************************************************************/

+

+

+

+

+

+

+

+/*--------------------------------------------------------------------------

+ *  SDL Timers and Now

+ *------------------------------------------------------------------------*/

+//typedef struct process_vars t_process_vars;

+

+

+/* Message header of timer signals is the same as for ordinary signals */

+

+

+

+

+

+/*--------------------------------------------------------------------------

+ * Pointer to signal parameters

+ *------------------------------------------------------------------------*/

+

+#define SIGNAL_DATA_PTR(SIGNAL_PTR) \

+   (void NEAR *)(SIGNAL_PTR)

+

+#define INSIGNAL_DATA_PTR SIGNAL_DATA_PTR(yVarP->yInSignalPtr)

+#define OUTSIGNAL_DATA_PTR SIGNAL_DATA_PTR(yOutputSignalPtr)

+#define STARTUP_DATA_PTR OUTSIGNAL_DATA_PTR

+

+

+/*--------------------------------------------------------------------------

+ * SDL-trace

+ *------------------------------------------------------------------------*/

+

+/* moved to mk_inc.h

+#define EXTERNAL_SDL_DEBUG */

+

+#ifdef EXTERNAL_SDL_DEBUG  /*change by gongyi 080203*/

+

+extern void  hwtrc_putsig_ext  (xSignalHeader  yInSignalPtr, 

+		unsigned       xState,

+		unsigned char  sender_id,

+		unsigned char sender_instance,

+		unsigned char receiver_id,

+		unsigned char receiver_instance,

+		unsigned char xInputAction);

+

+#endif /*#ifdef EXTERNAL_SDL_DEBUG*/

+

+#define CLEAR_BUF_ALLOC_SIG(SIG_PAR_SIZE) /*add by gongyi 080203*/

+#define CLEAR_BUF_TRANSFER(SIG_PAR_SIZE)  /*add by gongyi 080203*/

+

+

+/****+***************************************************************

+08   SDL predefined types (except SDL_PId)

+********************************************************************/

+

+/*#include "sctpred.h"*/

+/*

+#ifndef UNITEST

+#include "nu_os.h"

+#else

+#include "er_os.h"

+#endif*/

+

+/*---------------------------------------------------------------------------

+ *      Variables in the PAD function

+ *--------------------------------------------------------------------------*/

+#ifdef XNOSTATICSTRUCTURE

+#define PROCESS_VARS \

+    SDL_PId           Offspring; \

+    SDL_PId           Parent; \

+    SDL_PId           Self; \

+    SDL_PId           Sender; \

+    xSignalHeaderRec  NEAR *yInSignalPtr; \

+    xSignalHeaderRec  SaveQ; \

+    xSignalHeader     CurrentInSaveQ; \

+    unsigned char     xState; \

+    XINPUTREFTYPE     RestartAddress; \

+unsigned char     SelfId;

+#else

+#define PROCESS_VARS \

+    SDL_PId           Offspring; \

+    SDL_PId           Parent; \

+    SDL_PId           Self; \

+    SDL_PId           Sender; \

+    xSignalHeader     yInSignalPtr; \

+    xSignalHeaderRec  SaveQ; \

+    xSignalHeader     CurrentInSaveQ; \

+    xPrsNode          PrsNode; \

+    int               xState; \

+int RestartAddress;

+#endif

+

+/* #define PROCEDURE_VARS byte dummy; */

+#define PROCEDURE_VARS void *yvarp;

+

+typedef struct procedure_vars t_procedure_vars;

+

+

+#define XSYSTEMVARS

+#define XSYSTEMVARS_H

+#define XPROCESSDEF_C(PROC_NAME, PROC_NAME_STRING, PREFIX_PROC_NAME, PAD_FUNCTION, VDEF_TYPE) \

+static XCONST XSIGTYPE * const insig_table = yPrsS_##PREFIX_PROC_NAME;

+

+#define XPROCESSDEF_H(PROC_NAME, PROC_NAME_STRING, PREFIX_PROC_NAME, PAD_FUNCTION, VDEF_TYPE)

+

+#define XSIGTYPE  SIGREFTYPE /*add by gongyi 080203*/

+

+#define xSigCode(P)

+#define XTHISPRS 0

+#define SIGCODE(P)

+#define STARTUPSIGNAL   0

+

+#define YINITPARAMDEF(P) void

+#define YINITPARAM(P)

+#define XPROCESSMAIN(PAD)

+#define SDL_Charstring_Lit(P1, P2)   P1

+

+

+

+/* #define PROCEDURE_VARS byte dummy; */

+#define PROCEDURE_VARS void *yvarp;

+

+

+

+struct procedure_vars

+{

+    PROCEDURE_VARS

+};

+

+#if 0

+#define YPAD_TEMP_VARS \

+   SIGREFTYPE     SignalCode; \

+   xSignalHeader  ySVarP;

+

+#define YPRD_TEMP_VARS \

+   xSignalHeaderRec NEAR *yOutputSignalPtr; \

+   struct { prd_u prd; } yVarPVar;

+

+#else /* __BORLANDC__ */

+

+#define YPAD_TEMP_VARS \

+   xSignalHeaderRec NEAR *yOutputSignalPtr; \

+   SIGREFTYPE     SignalCode[2]; \

+	xSignalHeaderRec NEAR *ySVarP[2];

+

+#define YPRD_TEMP_VARS \

+   xSignalHeaderRec NEAR *yOutputSignalPtr; \

+   struct { prd_u prd; } yVarPVar[2];

+

+#endif /* __BORLANDC__ */

+

+#define YPAD_YSVARP

+

+#define YPAD_YVARP(VDEF_TYPE) \

+   VDEF_TYPE yVarPVar[2]; \

+   VDEF_TYPE *yVarP[2] = {&yVarPVar[0],&yVarPVar[1]};

+

+

+/*--------------------------------------------------------------------------

+ * Timer variables

+ * 9-10-1993 :

+ *        (1) typedef TMID in Nucleus Environment

+ *------------------------------------------------------------------------*/

+

+#define DEF_TIMER_VAR(NAME)

+#define INIT_TIMER_VAR(NAME)

+#define RELEASE_TIMER_VAR(NAME)

+

+/* EMPTY in Nucleus */

+#define INPUT_TIMER_VAR(NAME)

+

+#define DEF_TIMER_VAR_PARA(TIMER_VAR)

+#define INIT_TIMER_VAR_PARA(TIMER_VAR)

+#define INPUT_TIMER_VAR_PARA(TIMER_VAR)

+#define RELEASE_TIMER_VAR_PARA(TIMER_VAR)

+

+/* Now */

+#define SDL_NOW(sample_id)           SDL_Now(sample_id)

+#define SDL_Now(sample_id)         (RetrieveClock (sample_id))

+

+

+/*

+** MHO 13.03.00

+*/

+#ifdef NUCLEUS_HISR

+#define SDL_SELF(index)                0

+#endif

+

+#ifndef SDL_SELF

+#define SDL_SELF(index)                (yVarP[index]->Self)

+#endif

+

+#undef SDL_VARS

+

+#define SDL_UNKNOWN_SENDER      255

+

+#define SDL_PARENT              yVarP->Parent

+#define SDL_OFFSPRING           yVarP->Offspring

+#define SDL_SENDER              yVarP->Sender

+#define CURRENT_STATE           yVarP->xState

+#define CURRENT_STATE_PRD       0

+#define XSTATEDEF(STATE_IDNODE, STATE_NUMBER)

+

+

+/* -------------------------------------------------------------------------

+ * Structure of PAD function

+ *-------------------------------------------------------------------------*/

+#ifndef UNITEST

+#define YPAD_RESULT_TYPE        extern VOID

+#else

+#define YPAD_RESULT_TYPE        extern void

+#endif

+

+/* Process args */

+#ifndef UNITEST

+#define YPAD_ANSI_PARAM         UNSIGNED argc, VOID *argv

+#else

+#define YPAD_ANSI_PARAM         long argc, void *argv

+#endif 

+

+#define YPAD_KR_PARAM           argc, argv

+#define YPAD_KR_DEF             UNSIGNED argc; VOID *argv;

+

+

+#define YPRD_RESULT_TYPE        extern VOID

+

+#define YPRD_ANSI_PARAM         (void *P)

+

+#define YPRD_KR_PARAM           P

+

+#define YPRD_KR_DEF             void *P;

+

+

+#define YPAD_PROTOTYPE(PAD) \

+   YPAD_RESULT_TYPE PAD XPP((YPAD_ANSI_PARAM));

+#define YPRD_PROTOTYPE(PRD) \

+   YPRD_RESULT_TYPE PRD XPP((YPRD_ANSI_PARAM));

+

+#define YPAD_FUNCTION(PAD)      YPAD_RESULT_TYPE PAD XPP((YPAD_ANSI_PARAM))

+#define YPRD_FUNCTION(PAD)      YPAD_RESULT_TYPE PAD XPP((YPRD_ANSI_PARAM))

+

+#define YPRD_YVARP(VDEF_TYPE) \

+   VDEF_TYPE *yVarP = (VDEF_TYPE *) ( (t_procedure_vars *) P ) -> yvarp;

+

+#ifdef INIT_PRD_YVARP

+#define ASSIGN_PRD_YVARP(sample_id) yVarPVar[sample_id].prd.dummy.yvarp = yVarP[sample_id];

+#else

+#define ASSIGN_PRD_YVARP

+#endif

+

+/*-------------------------------------------------------------------------

+ * MACRO: BEGIN_PAD

+ *

+ *        Process startup and initialisation of SDL runtime system

+ *-------------------------------------------------------------------------*/

+

+#define BEGIN_PAD(VDEF_TYPE,sample_id) \

+	   memset ( (void *) yVarP[sample_id], 0, sizeof ( VDEF_TYPE ) ); \

+	   yVarP[sample_id]->Self = ( (struct args *) argv ) -> self; \

+	   yVarP[sample_id]->SelfId = (unsigned char)( ( (struct args *) argv ) -> self_id ); \

+	   yVarP[sample_id]->Offspring = SDL_NULL; \

+	   yVarP[sample_id]->SaveQ.succ = &(yVarP[sample_id]->SaveQ); \

+	   yVarP[sample_id]->SaveQ.pred = &(yVarP[sample_id]->SaveQ); \

+	   yVarP[sample_id]->CurrentInSaveQ = &(yVarP[sample_id]->SaveQ); \

+	   yVarP[sample_id]->yInSignalPtr = 0; \

+	   ASSIGN_PRD_YVARP(sample_id)

+

+/*---------------------------------------------------------------------------

+ * MACRO: LOOP_LABEL

+ *

+ *        SDL loop; waiting for input signals, consumption of input signals,

+ *        consumption of saved signals

+ *--------------------------------------------------------------------------*/

+

+#define LOOP_LABEL(sample_id)     \

+   Label_New_Transition : \

+     ySVarP[sample_id] = SDL_Loop ( insig_table, trans_table, \

+                         (t_process_vars *) yVarP[sample_id], \

+	                 __FILE__, __LINE__ ); \

+     SignalCode[sample_id] = SIGNAL_NAME ( ySVarP[sample_id] -> SignalCode, 0 );

+

+#define LOOP_LABEL_PRD_NOSTATE \

+     XOS_TRACE_CALL

+

+#define BEGIN_START_TRANSITION(STARTUP_PAR_TYPE,sample_id) \

+   yVarP[sample_id]->Parent = yVarP[sample_id]->Sender; \

+   yVarP[sample_id]->Sender = SDL_NULL;

+

+#define STATE_NAME(STATE_NAME, STATE_IDNODE) STATE_NAME

+

+/*----------------------------------------------------------------------------

+ * MACRO: SIGNAL_NAME ( )

+ *--------------------------------------------------------------------------*/

+

+

+

+

+

+#define START_STATE                                0

+

+#define START_STATE_PRD                            0

+

+#define INSIGNAL_NAME           ( SignalCode )

+

+

+/*---------------------------------------------------------------------------

+ * ENABLING CONDITION

+ *-------------------------------------------------------------------------*/

+#define ENABL_COND(EXPR) \

+   ERROR_Enabling_Condition_not_implemented

+

+

+/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

+ *      Actions within transitions

+ *

+ *++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

+

+

+/*---------------------------------------------------------------------------

+ *     Outputs

+ *--------------------------------------------------------------------------*/

+

+#define XSIGNALHEADERTYPE xSignalHeaderRec

+

+extern t_queue queue_table[];

+

+#define TO_PROCESS(PROC_NAME, PROC_IDNODE) XEXTR_PIDLIST(PROC_NAME,1)

+

+#if !defined(_OS_WIN) && !defined(__arm) && !defined(_USE_CMPL_GCC) && !defined(UNITEST)

+

+#define DEF_OUTSIG_PTR

+

+#define ALLOC_SIGNAL(SIG_NAME, SIG_IDNODE, RECEIVER, SIG_PAR_TYPE,sample_id) \

+  xSignalHeader yOutputSignalPtr = \

+       alloc_sig( sizeof (SIG_PAR_TYPE) ); \

+   yOutputSignalPtr->Sender = SDL_SELF(sample_id); \

+   CLEAR_BUF_ALLOC_SIG(SIG_PAR_TYPE)

+

+#define TRANSFER_SIGNAL(SIG_NAME, SIG_IDNODE, RECEIVER, SIG_PAR_TYPE,sample_id) \

+   xSignalHeader yOutputSignalPtr = yVarP[sample_id]->yInSignalPtr; \

+   yVarP[sample_id]->yInSignalPtr = 0; \

+   yOutputSignalPtr->Sender = SDL_SELF(sample_id); \

+   CLEAR_BUF_TRANSFER(SIG_PAR_TYPE)

+

+#else /* __BORLANDC__ */

+

+#define DEF_OUTSIG_PTR xSignalHeaderRec *yOutputSignalPtr;

+

+#ifdef SDL_VARS

+

+#define ALLOC_SIGNAL(SIG_NAME, SIG_IDNODE, RECEIVER, SIG_PAR_TYPE,sample_id) \

+   yOutputSignalPtr = \

+       alloc_sig( sizeof (SIG_PAR_TYPE) ); \

+   yOutputSignalPtr->Sender = SDL_SELF(sample_id); \

+       yOutputSignalPtr -> sender_id = SDL_VARS->SelfId; \

+   CLEAR_BUF_ALLOC_SIG(SIG_PAR_TYPE)

+

+

+#define TRANSFER_SIGNAL(SIG_NAME, SIG_IDNODE, RECEIVER, SIG_PAR_TYPE,sample_id) \

+   yOutputSignalPtr = yVarP[sample_id]->yInSignalPtr; \

+   yVarP[sample_id]->yInSignalPtr = 0; \

+   yOutputSignalPtr->Sender = SDL_SELF(sample_id); \

+       yOutputSignalPtr -> sender_id = SDL_VARS->SelfId; \

+   CLEAR_BUF_TRANSFER(SIG_PAR_TYPE)

+

+

+#else

+

+#define ALLOC_SIGNAL(SIG_NAME, SIG_IDNODE, RECEIVER, SIG_PAR_TYPE,sample_id) \

+   yOutputSignalPtr = \

+       alloc_sig( sizeof (SIG_PAR_TYPE) ); \

+   yOutputSignalPtr->Sender = SDL_SELF(sample_id); \

+       yOutputSignalPtr -> sender_id = SDL_UNKNOWN_SENDER; \

+   CLEAR_BUF_ALLOC_SIG(SIG_PAR_TYPE)

+

+#define TRANSFER_SIGNAL(SIG_NAME, SIG_IDNODE, RECEIVER, SIG_PAR_TYPE,sample_id) \

+   yOutputSignalPtr = yVarP[sample_id]->yInSignalPtr; \

+   yVarP[sample_id]->yInSignalPtr = 0; \

+   yOutputSignalPtr->Sender = SDL_SELF(sample_id); \

+       yOutputSignalPtr -> sender_id = SDL_UNKNOWN_SENDER; \

+   CLEAR_BUF_TRANSFER(SIG_PAR_TYPE)

+

+#endif /* ! __BORLANDC__ */

+

+

+#define ALLOC_SIGNAL_PAR(SIG_NAME, SIG_IDNODE, RECEIVER, SIG_PAR_TYPE,sample_id) \

+   ALLOC_SIGNAL(SIG_NAME, SIG_IDNODE, RECEIVER, SIG_PAR_TYPE,sample_id)

+

+#define TRANSFER_SIGNAL_PAR(SIG_NAME, SIG_IDNODE, RECEIVER, SIG_PAR_TYPE,sample_id) \

+   TRANSFER_SIGNAL(SIG_NAME, SIG_IDNODE, RECEIVER, SIG_PAR_TYPE,sample_id)

+

+#define SIGNAL_ALLOC_ERROR

+

+#define SIGNAL_ALLOC_ERROR_END

+

+/* #ifdef NUCLEUS_HISR */

+#if 0

+#define SEND_SIG send_sig_no_susp

+#define SEND_SIG_NO_TO send_sig_no_to_no_susp

+#else

+#define SEND_SIG send_sig

+#define SEND_SIG_NO_TO send_sig_no_to

+#endif

+

+

+#define SDL_2OUTPUT_COMPUTED_TO(PRIO, VIA, SIG_NAME, SIG_IDNODE, RECEIVER, SIG_PAR_SIZE, SIG_NAME_STRING) \

+   SDL_2OUTPUT(PRIO, VIA, SIG_NAME, SIG_IDNODE, RECEIVER, SIG_PAR_SIZE, SIG_NAME_STRING)

+

+#if !defined(_OS_WIN) && !defined(__arm) && !defined(_USE_CMPL_GCC) &&  !defined(UNITEST)

+

+

+#define SDL_2OUTPUT(PRIO, VIA, SIG_NAME, SIG_IDNODE, RECEIVER, SIG_PAR_SIZE, SIG_NAME_STRING) \

+   XOS_TRACE_OUTPUT(SIG_NAME_STRING) \

+   yOutputSignalPtr->SignalCode = SIG_NAME; \

+   SEND_SIG ( yOutputSignalPtr, RECEIVER ); }

+

+#define SDL_2OUTPUT_NO_TO(PRIO, VIA, SIG_NAME, SIG_IDNODE, RECEIVER, SIG_PAR_SIZE, SIG_NAME_STRING) \

+   XOS_TRACE_OUTPUT(SIG_NAME_STRING) \

+   SEND_SIG_NO_TO ( yOutputSignalPtr, SIG_NAME ); }

+

+

+#define SDL_ALT2OUTPUT(PRIO, VIA, SIG_NAME, SIG_IDNODE, RECEIVER, SIG_PAR_SIZE, SIG_NAME_STRING) \

+   build_##SIG_NAME ( OUTSIGNAL_DATA_PTR ); \

+   yOutputSignalPtr->SignalCode = SIG_NAME; \

+   SEND_SIG ( yOutputSignalPtr, RECEIVER ); }

+

+#define SDL_ALT2OUTPUT_NO_TO(PRIO, VIA, SIG_NAME, SIG_IDNODE, RECEIVER, SIG_PAR_SIZE, SIG_NAME_STRING) \

+   build_##SIG_NAME ( OUTSIGNAL_DATA_PTR ); \

+   SEND_SIG_NO_TO ( yOutputSignalPtr, SIG_NAME ); }

+

+#else /* __BORLANDC__ */

+

+#define SDL_2OUTPUT(PRIO, VIA, SIG_NAME, SIG_IDNODE, RECEIVER, SIG_PAR_SIZE, SIG_NAME_STRING) \

+   XOS_TRACE_OUTPUT(SIG_NAME_STRING) \

+   yOutputSignalPtr->SignalCode = SIG_NAME; \

+   SEND_SIG ( yOutputSignalPtr, RECEIVER, SIG_NAME_STRING );

+

+#define SDL_2OUTPUT_NO_TO(PRIO, VIA, SIG_NAME, SIG_IDNODE, RECEIVER, SIG_PAR_SIZE, SIG_NAME_STRING) \

+   XOS_TRACE_OUTPUT(SIG_NAME_STRING) \

+   SEND_SIG_NO_TO ( yOutputSignalPtr, SIG_NAME, SIG_NAME_STRING );

+

+#define SDL_ALT2OUTPUT(PRIO, VIA, SIG_NAME, SIG_IDNODE, RECEIVER, SIG_PAR_SIZE, SIG_NAME_STRING) \

+   build_##SIG_NAME ( OUTSIGNAL_DATA_PTR ); \

+   yOutputSignalPtr->SignalCode = SIG_NAME; \

+   SEND_SIG ( yOutputSignalPtr, RECEIVER, SIG_NAME_STRING );

+

+#define SDL_ALT2OUTPUT_NO_TO(PRIO, VIA, SIG_NAME, SIG_IDNODE, RECEIVER, SIG_PAR_SIZE, SIG_NAME_STRING) \

+   build_##SIG_NAME ( OUTSIGNAL_DATA_PTR ); \

+   SEND_SIG_NO_TO ( yOutputSignalPtr, SIG_NAME, SIG_NAME_STRING );

+

+#endif /* __BORLANDC__ */

+

+

+

+/*----------------------------------------------------------------------------

+ *      SDL Process Create

+ *---------------------------------------------------------------------------*/

+

+#ifdef XNOSTATICSTRUCTURE

+#define STARTUP_VARS

+#else

+#define STARTUP_VARS \

+   xPrsNode PrsNode;

+#endif

+

+/*

+** msges 7.10.97: inserted "(SIGREFTYPE)".

+*/

+

+#define ALLOC_STARTUP(PROC_NAME, STARTUP_IDNODE, STARTUP_PAR_TYPE) \

+   { xSignalHeader yOutputSignalPtr = alloc_sig( sizeof (STARTUP_PAR_TYPE) ); \

+   yOutputSignalPtr->SignalCode = STARTUP_SIGNAL_NAME; \

+   yOutputSignalPtr->Sender = yVarP->Self;

+

+#define ALLOC_STARTUP_PAR(PROC_NAME, STARTUP_IDNODE, STARTUP_PAR_TYPE) \

+  ALLOC_STARTUP(PROC_NAME, STARTUP_IDNODE, STARTUP_PAR_TYPE)

+

+#define STARTUP_ALLOC_ERROR

+#define STARTUP_ALLOC_ERROR_END

+

+#ifdef XNOSTATICSTRUCTURE

+#define SDL_CREATE(PROC_NAME, PROC_IDNODE, PROC_NAME_STRING) \

+    yVarP -> Offspring = \

+      SDL_Create ( yPAD_##PROC_NAME, PROC_NAME##_STACK_SIZE, P_##PROC_NAME, \

+                   PROC_NAME##_PRIO, PROC_NAME_STRING, yOutputSignalPtr ); }

+#else

+#define SDL_CREATE(PROC_NAME, PROC_IDNODE, PROC_NAME_STRING, STARTUP_IDNODE, STARTUP_PAR_TYPE, VDEF_TYPE, PRIO, PAD_FUNCTION) \

+   SDL_CREATE STATIC STRUCTURE not implemented

+#endif

+

+

+#define YINIT_TEMP_VARS

+#define EnvPId Temp

+#define xEnv_Var 0

+#define XSYSD

+

+

+/*---------------------------------------------------------------------------

+ *      MACRO: BEGIN_YINIT

+ *      USAGE: INITIALIZE SDL SYSTEM, I.E. INIT_TIMERS FOR NOW.

+ *      DATE:  8-29-93

+ *-------------------------------------------------------------------------*/

+#define BEGIN_YINIT

+

+#define XINIT_SYSTEMIDNODE(A)

+#define XCREATE_ENV_PROCESS

+

+

+/*---------------------------------------------------------------------------

+ *      MACRO: END_YINIT

+ *      USAGE: None

+ *-------------------------------------------------------------------------*/

+#define END_YINIT

+

+

+/*----------------------------------------------------------------------------

+ * MACRO: INIT_PROCESS_TYPE ( )

+ *

+ * USAGE: NOTIFY THE OS ABOUT THE PROCESS TYPE AND STATIC INSTANCE INFORMATION

+ *        SUCH AS STATIC PROCESS PAD FUNCTION NAME, PROCESS TYPE NAME, AND ETC.

+ *

+ *        (not used)

+ *

+ *---------------------------------------------------------------------------*/

+

+#define INIT_PROCESS_TYPE(PROC_NAME, PREFIX_PROC_NAME, PROC_IDNODE, PROC_NAME_STRING, MAX_NO_OF_INST, STATIC_INST, PRIV_DATA_TYPE, PRIO, PAD_FUNCTION)

+

+

+/*----------------------------------------------------------------------------

+ * MACRO: SDL_STATIC_CREATE

+ *--------------------------------------------------------------------------*/

+#define SDL_STATIC_CREATE(PROC_NAME, PREFIX_PROC_NAME, PROC_IDNODE, PROC_NAME_STRING, STARTUP_IDNODE, STARTUP_PAR_TYPE, PRIV_DATA_TYPE, PRIO, PAD_FUNCTION, BLOCK_INST_NUMBER) \

+   send_startup_sig( queue_table + P_##PROC_NAME );

+

+

+/*---------------------------------------------------------------------------

+ * MACRO: SDL_STOP

+ *--------------------------------------------------------------------------*/

+#define SDL_STOP \

+   XOS_TRACE_STOP \

+   SDL_Stop ( (t_process_vars *) yVarP, yVarP->yInSignalPtr, SelfId );

+

+

+

+/*---------------------------------------------------------------------------

+ *  Timers

+ *--------------------------------------------------------------------------*/

+

+

+/* Disable clock ticking while manipulating timer queue */

+/* Mask out all interrupts lower than or eq to this level */

+/*#define ENABLE_INTERRUPTS 0

+#define DISABLE_NEARLY_ALL_INTERRUPTS 12

+#define DISABLE_ALL_INTERRUPTS 15  !!! ??? */

+

+#define ENABLE_INTERRUPTS 0

+#define DISABLE_NEARLY_ALL_INTERRUPTS  8  //12//0         //32

+#define DISABLE_ALL_INTERRUPTS         0  //15         //32

+//#define DISABLE_ALL_PROCCESS           0

+

+

+

+

+/*  en/disable all interrupt defined ICU_funct.h */

+/*#define ICU_Disable_IRQ()            unsigned long msr;\

+	                                 LOCK_SAVE(msr)

+#define ICU_Enable_IRQ               LOCK_RESTORE(msr)*/

+#if 0

+#define DISABLE_CLOCK { unsigned long msr;\

+                        ushort old_level = get_pri(current_process ());\

+	                    set_pri(0);\

+	                    LOCK_SAVE(msr);

+                        

+#define ENABLE_CLOCK   LOCK_RESTORE(msr);\

+                       set_pri(old_level); }

+

+#define ATOMIC_BEGIN   status = zOss_GetMutex( timer_mutex,  ZOSS_WAIT_FOREVER);\

+		                     if( status == ZOSS_ERROR ) return 0;

+#define ATOMIC_END     status = zOss_PutMutex( timer_mutex);\

+		                     if( status == ZOSS_ERROR ) return 0;               

+			               

+#endif

+#ifdef _OS_WIN

+#define DISABLE_CLOCK 

+#define ENABLE_CLOCK 

+

+#define ATOMIC_BEGIN  

+#define ATOMIC_END  

+#else

+#define DISABLE_CLOCK   ZOSS_DISABLE_IRQ();

+#define ENABLE_CLOCK    ZOSS_ENABLE_IRQ();

+

+#define ATOMIC_BEGIN    ZOSS_DISABLE_IRQ();

+#define ATOMIC_END      ZOSS_ENABLE_IRQ();

+#endif

+

+/* Suspension and resumption of timers (not SDL standard) */

+

+#define SDL_DISABLE_TIMER(TIMER_ID) \

+  disable_timer ( TIMER_ID, 0, yVarP -> Self,sample_id );

+

+#define SDL_ENABLE_TIMER(TIMER_ID) \

+  enable_timer ( TIMER_ID, 0, yVarP -> Self,sample_id );

+

+/* SET without parameters */

+

+#define SDL_SET_DUR(TIME_EXPR, DUR_EXPR, TIMER_NAME, TIMER_IDNODE, TIMER_VAR, TIMER_NAME_STRING,sample_id) \

+do { \

+    SDL_Duration soft_time_offset; /* time offset */ \

+    \

+    SDL_Duration latest_time;      /* latest time */ \

+    SDL_Duration early_time;       /* early time := latest time - time offset */ \

+    \

+    /* soft time offset := 0 */ \

+    xDef_SDL_Duration (&soft_time_offset); \

+    \

+    /* latest time := soft_time (time, offset, &soft_time_offset) */ \

+    yAssF_SDL_Duration (latest_time, (DUR_EXPR), XASS); \

+    \

+    /* early time := latest time - time offset */ \

+    yAssF_SDL_Duration (early_time, xMinus_SDL_Duration (latest_time, soft_time_offset), XASS); \

+    \

+    SDL_Set_Dur_Ex(early_time, latest_time, TIMER_NAME, 0, (t_process_vars *) yVarP[sample_id],sample_id ); \

+} while (0);

+

+#define SDL_SET_TICKS(TIME_EXPR, DUR_EXPR, TIMER_NAME, TIMER_IDNODE, TIMER_VAR, TIMER_NAME_STRING) \

+   SDL_SET_DUR(TIME_EXPR, DUR_EXPR, TIMER_NAME, TIMER_IDNODE, TIMER_VAR, TIMER_NAME_STRING,sample_id)

+

+/* Soft SET without parameters */

+

+#define SDL_SET_DUR_EX(EARLIEST_TIME_EXPR, LATEST_TIME_EXPR, EARLIEST_DUR_EXPR, LATEST_DUR_EXPR, \

+                       TIMER_NAME, TIMER_IDNODE, TIMER_VAR, TIMER_NAME_STRING,sample_id) \

+   SDL_Set_Dur_Ex( EARLIEST_DUR_EXPR, LATEST_DUR_EXPR, TIMER_NAME, 0, (t_process_vars *) yVarP,sample_id );

+

+#define SDL_SET_TICKS_EX(EARLIEST_TIME_EXPR, LATEST_TIME_EXPR, EARLIEST_DUR_EXPR, LATEST_DUR_EXPR, \

+                         TIMER_NAME, TIMER_IDNODE, TIMER_VAR, TIMER_NAME_STRING,sample_id) \

+   SDL_SET_DUR_EX(EARLIEST_TIME_EXPR, LATEST_TIME_EXPR, EARLIEST_DUR_EXPR, LATEST_DUR_EXPR, \

+                  TIMER_NAME, TIMER_IDNODE, TIMER_VAR, TIMER_NAME_STRING,sample_id)

+

+/* SET with parameters */

+

+#define ALLOC_TIMER_SIGNAL_PAR(TIMER_NAME, TIMER_IDNODE, TIMER_PAR_TYPE) \

+  { t_timer_param timer_param = 0; \

+    SIGREFTYPE timer_name = TIMER_NAME;

+

+#define ALLOC_TIMER_SIGNAL(TIMER_NAME, TIMER_IDNODE, TIMER_PAR_TYPE)

+

+#define TIMER_SIGNAL_ALLOC_ERROR

+#define TIMER_SIGNAL_ALLOC_ERROR_END

+#define TIMER_DATA_PTR \

+  ( (char *) &timer_param - (int)( &( (xTimerHeader) 0 ) -> param ) )

+

+#define SDL_SET_DUR_WITH_PARA(TIME_EXPR, DUR_EXPR, TIMER_NAME, TIMER_IDNODE, TIMER_PAR_TYPE, EQ_FUNC, TIMER_VAR, TIMER_NAME_STRING) \

+do { \

+    SDL_Duration soft_time_offset; /* time offset */ \

+    \

+    SDL_Duration latest_time;      /* latest time */ \

+    SDL_Duration early_time;       /* early time := latest time - time offset */ \

+    \

+    /* soft time offset := 0 */ \

+    xDef_SDL_Duration (&soft_time_offset); \

+    \

+    /* latest time := soft_time (time, offset, &soft_time_offset) */ \

+    yAssF_SDL_Duration (latest_time, (DUR_EXPR), XASS); \

+    \

+    /* early time := latest time - time offset */ \

+    yAssF_SDL_Duration (early_time, xMinus_SDL_Duration (latest_time, soft_time_offset), XASS); \

+    \

+    SDL_Set_Dur_Ex(early_time, latest_time, TIMER_NAME, timer_param, (t_process_vars *) yVarP,sample_id); \

+} while (0); }

+

+#define SDL_SET_TICKS_WITH_PARA(TIME_EXPR, DUR_EXPR, TIMER_NAME, TIMER_IDNODE, TIMER_PAR_TYPE, EQ_FUNC, TIMER_VAR, TIMER_NAME_STRING) \

+   SDL_SET_DUR_WITH_PARA(TIME_EXPR, DUR_EXPR, TIMER_NAME, TIMER_IDNODE, TIMER_PAR_TYPE, EQ_FUNC, TIMER_VAR, TIMER_NAME_STRING) \

+

+/* Soft SET with parameters */

+

+#define SDL_SET_DUR_WITH_PARA_EX(EARLIEST_TIME_EXPR, LATEST_TIME_EXPR, EARLIEST_DUR_EXPR, LATEST_DUR_EXPR, \

+                                 TIMER_NAME, TIMER_IDNODE, TIMER_PAR_TYPE, EQ_FUNC, TIMER_VAR, TIMER_NAME_STRING) \

+   SDL_Set_Dur_Ex( EARLIEST_DUR_EXPR, LATEST_DUR_EXPR, TIMER_NAME, timer_param, (t_process_vars *) yVarP,sample_id); }

+

+#define SDL_SET_TICKS_WITH_PARA_EX(EARLIEST_TIME_EXPR, LATEST_TIME_EXPR, EARLIEST_DUR_EXPR, LATEST_DUR_EXPR, \

+                                   TIMER_NAME, TIMER_IDNODE, TIMER_PAR_TYPE, EQ_FUNC, TIMER_VAR, TIMER_NAME_STRING) \

+   SDL_SET_DUR_WITH_PARA_EX(EARLIEST_TIME_EXPR, LATEST_TIME_EXPR, EARLIEST_DUR_EXPR, LATEST_DUR_EXPR, \

+                            TIMER_NAME, TIMER_IDNODE, TIMER_PAR_TYPE, EQ_FUNC, TIMER_VAR, TIMER_NAME_STRING) \

+

+

+/* Reset without parameters */

+#define SDL_RESET(TIMER_NAME, TIMER_IDNODE, TIMER_VAR, TIMER_NAME_STRING)\

+   XOS_TRACE_RESET(TIMER_NAME_STRING)\

+   SDL_Reset(TIMER_NAME, 0, (t_process_vars *) yVarP,sample_id);

+

+/* Reset with parameters */

+#define SDL_RESET_WITH_PARA(EQ_FUNC, TIMER_VAR, TIMER_NAME_STRING) \

+   XOS_TRACE_RESET(TIMER_NAME_STRING)\

+   SDL_Reset( timer_name, timer_param, (t_process_vars *) yVarP,sample_id); }

+

+

+/* Active (timer active) */

+

+/*--------------------------------------------------------------------------

+ *  Procedure call

+ *-------------------------------------------------------------------------*/

+#define ALLOC_PROCEDURE(PROC_NAME, PROC_IDNODE, VAR_SIZE) \

+

+

+#define PROCEDURE_ALLOC_ERROR

+#define PROCEDURE_ALLOC_ERROR_END

+

+#define PROC_DATA_PTR \

+   ( &yVarPVar.prd )

+

+#define CALL_PROCEDURE(PRD_NAME, PRD_IDNODE, LEVELS, RESTARTADDR) \

+   PRD_NAME( (void *) &yVarPVar.prd.##PRD_NAME );

+

+#define CALL_PROCEDURE_IN_PRD(PRD_NAME, PRD_IDNODE, LEVELS, RESTARTADDR) \

+   yVarPVar.prd.dummy.yvarp = yVarP; \

+   PRD_NAME( (void *) &yVarPVar.prd.##PRD_NAME );

+

+

+#define CALL_PROCEDURE_STARTUP

+

+

+/*----------------------------------------------------------------------------

+ *      Procedure return

+ *--------------------------------------------------------------------------*/

+

+#define SDL_RETURN \

+   XOS_TRACE_RETURN \

+   return;

+

+#define XEND_PRD

+

+

+/*----------------------------------------------------------------------------

+ *      NextState

+ *--------------------------------------------------------------------------*/

+

+#define SDL_NEXTSTATE(STATE_NAME, STATE_IDNODE, STATE_NAME_STRING,sample_id) \

+   yVarPVar[sample_id].xState = STATE_IDNODE; \

+   goto Label_New_Transition;

+

+#define SDL_DASH_NEXTSTATE \

+   XOS_TRACE_DASH_NEXTSTATE \

+   goto Label_New_Transition;

+

+#define SDL_NEXTSTATE_PRD(STATE_NAME, STATE_IDNODE, STATE_NAME_STRING) \

+   xState = STATE_IDNODE; \

+   XOS_TRACE_NEXTSTATE(STATE_NAME_STRING) \

+   goto Label_New_Transition;

+

+#define SDL_DASH_NEXTSTATE_PRD \

+   XOS_TRACE_DASH_NEXTSTATE \

+   goto Label_New_Transition;

+

+

+/*---------------------------------------------------------------------------

+ *      View

+ *-------------------------------------------------------------------------*/

+

+#define XCHECKVIEW(PID_EXPR, VAR_NAME_STRING, PROCESS_IDNODE, PROCESS_NAME) \

+   ERROR__View_not_implemented

+#define XGETVARP(PID_EXPR) \

+   ERROR__View_not_implemented

+

+

+/*---------------------------------------------------------------------------

+ * Error Messaging

+ * 9-9-93 : Change Return code format as hex value instead of decimal!!

+ *-------------------------------------------------------------------------*/

+#define XOS_ERROR(STRING1, STRING2, RETCODE)

+

+

+/*--------------------------------------------------------------------------

+ * Forward declaration of functions

+ *------------------------------------------------------------------------*/

+

+/*-------------------------------------------------------------------------

+ * General Timer Interfaces

+ *-----------------------------------------------------------------------*/

+ 

+

+

+

+/*extern void SDL_Stop ( t_process_vars *yVarP, xSignalHeaderRec near *yInSignalPtr, int self_id );

+!!*/

+

+#include "sctpred.h"

+

+#endif 

+

+#endif /* _SCTTYPES_H */

+

+

+

diff --git a/cp/ps/modem/psbase/inc/sio_irq.h b/cp/ps/modem/psbase/inc/sio_irq.h
new file mode 100644
index 0000000..2a4aae4
--- /dev/null
+++ b/cp/ps/modem/psbase/inc/sio_irq.h
@@ -0,0 +1,51 @@
+/*******************************************************************************

+* °æÈ¨ËùÓÐ (C)2011, ÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£

+* 

+* ÎļþÃû³Æ:     sio_irq.h

+* Îļþ±êʶ:     sio_irq.h

+* ÄÚÈÝÕªÒª:     sio stands for Serial IO, irq stands for Interrupt Request

+* ʹÓ÷½·¨:     #include "sio_irq.h"

+* 

+* ÐÞ¸ÄÈÕÆÚ        °æ±¾ºÅ      Ð޸ıê¼Ç        ÐÞ¸ÄÈË          ÐÞ¸ÄÄÚÈÝ

+* ------------------------------------------------------------------------------

+* 2012/01/09      V1.0        Create          ÁõÑÇÄÏ          ´´½¨

+* 

+*******************************************************************************/

+

+#ifndef _SIO_IRQ_H

+#define _SIO_IRQ_H

+

+/*******************************************************************************

+*                                   Í·Îļþ                                     *

+*******************************************************************************/

+#include "cpu_intlock.h"

+

+

+/*******************************************************************************

+*                                   ºê¶¨Òå                                     *

+*******************************************************************************/

+#ifdef _OS_WIN

+# define GLOBAL_INT_DISABLE(int_state)

+# define GLOBAL_INT_ENABLE(int_state)

+#else

+# define GLOBAL_INT_DISABLE(int_state)  ZOSS_SAVE_IRQ(int_state)

+# define GLOBAL_INT_ENABLE(int_state)   ZOSS_RESTORE_IRQ(int_state)

+#endif

+

+

+/*******************************************************************************

+*                                Êý¾ÝÀàÐͶ¨Òå                                  *

+*******************************************************************************/

+

+

+/*******************************************************************************

+*                                È«¾Ö±äÁ¿ÉùÃ÷                                  *

+*******************************************************************************/

+

+

+/*******************************************************************************

+*                                È«¾Öº¯ÊýÉùÃ÷                                  *

+*******************************************************************************/

+

+#endif	// #ifndef _SIO_IRQ_H

+

diff --git a/cp/ps/modem/psbase/inc/tic.h b/cp/ps/modem/psbase/inc/tic.h
new file mode 100644
index 0000000..1adac21
--- /dev/null
+++ b/cp/ps/modem/psbase/inc/tic.h
@@ -0,0 +1,135 @@
+/* ============================================================================

+** Copyright (C) 2002-2006 COMNEON GmbH & Co. OHG. All rights reserved.

+** ============================================================================

+**

+** ============================================================================

+**

+** This document contains proprietary information belonging to COMNEON.

+** Passing on and copying of this document, use and communication of its

+** contents is not permitted without prior written authorisation.

+**

+** ============================================================================

+** Revision Information :

+**    File name: tic.h

+**    Version: /main/6

+**    Date: 2006-01-11    9:53:32

+**

+** ============================================================================

+** Project:              Mobile Station (MS)

+** Block:                -

+** Process:              TIC

+**

+** ============================================================================

+** Contents:    This file contains the interfaces for the timer management

+**              component.

+**

+** ============================================================================

+** History: 

+** 

+** Date      Author  Comment

+**

+** 13.02.02  ges   created.

+**

+** ============================================================================

+*/

+

+#ifndef TIC_H

+#define TIC_H

+

+/*============================================================================

+Exported Type Declarations

+============================================================================*/

+

+/* External representation of the timer control block data type.*/

+typedef struct tic_timer_s *tic_timer_t;

+

+

+/* TIC control ids.

+ *

+ * TIC_INFO:

+ *    Get timer information.

+ *

+ * TIC_TRACE: 0/1 = disable/enable the tic trace.

+ * tic_ctrl_trace_t  trace;

+ * trace.stat = 1;

+ * tic_timer_control (TIC_CTRL_TRACE, &trace, sizeof (tic_ctrl_trace_t));

+ */

+typedef enum

+{

+    TIC_CTRL_INFO,

+    TIC_CTRL_TRACE    

+}tic_req_t;

+

+typedef struct tic_ctrl_info_s

+{

+    UINT16  max_number;  /* Max. number of available timers. */

+    UINT16  installed;   /* Number of installed timers. */    

+} tic_ctrl_info_t;

+

+

+typedef struct tic_ctrl_trace_s

+{

+    UINT8  stat;  /* 0/1 = disable/enable the tic trace. */    

+} tic_ctrl_trace_t;

+

+

+/*============================================================================

+Exported Function Declarations

+============================================================================*/

+/**B**************************************************************************

+ * Function:     tic_timer_create

+ *----------------------------------------------------------------------------

+ * Purpose:      This function creates a timer and places it on the

+ *               list of created timers. The timer is activated by

+ *               tic_timer_start(). Upon timer expiration the

+ *               expiration_routine is called.

+ *

+ * Parameters:   expfunc: timer expiration routine.

+ *               arg: argument of the expiration routine.

+ *

+ * Returns:      Timer handle.

+ ***E*************************************************************************/

+extern  tic_timer_t  tic_timer_create(VOID (*expfunc)(VOID *arg), VOID *arg);

+

+

+/**B**************************************************************************

+ * Function:     tic_timer_free

+ *----------------------------------------------------------------------------

+ * Purpose:      This function is responsible for freeing a timer.

+ *

+ * Parameters:   timer: timer handle.

+ *

+ * Returns:      1 means during dealloction the timer handler was executed,

+ *               otherwise 0.

+ ***E*************************************************************************/

+extern  SINT32 tic_timer_free(tic_timer_t timer);

+

+

+/**B**************************************************************************

+ * Function:     tic_timer_start

+ *----------------------------------------------------------------------------

+ * Purpose:      This function is responsible for starting a timer.

+ *

+ * Parameters:   timer: timer handle.

+ *               secs: number of seconds.

+ *               nano_secs: nano seconds.

+ *

+ * Returns:      None.

+ ***E*************************************************************************/

+extern  VOID tic_timer_start(tic_timer_t timer, UNSIGNED secs, UNSIGNED nano_secs);

+

+

+/**B**************************************************************************

+ * Function:     tic_timer_stop

+ *----------------------------------------------------------------------------

+ * Purpose:      This function is responsible for stopping a timer.

+ *

+ * Parameters:   timer: timer handle.

+ *

+ * Returns:      1 means during stopping the timer handler was executed,

+ *               otherwise 0.

+ ***E*************************************************************************/

+extern  SINT32  tic_timer_stop(tic_timer_t timer);

+

+#endif /* TIC_H */

+

diff --git a/cp/ps/modem/psbase/inc/zx2802.h b/cp/ps/modem/psbase/inc/zx2802.h
new file mode 100644
index 0000000..97ce46e
--- /dev/null
+++ b/cp/ps/modem/psbase/inc/zx2802.h
@@ -0,0 +1,228 @@
+/*********************************************************************

+ °æÈ¨ËùÓÐ (C)2003, ÉîÛÚÊÐÖÐÐËͨѶ¹É·ÝÓÐÏÞ¹«Ë¾¡£

+ 

+ ÎļþÃû³Æ£º zx2802.a

+ ÄÚÈÝÕªÒª£º ¶¨Òåinit.sʹÓõij£Á¿

+ ×÷    Õߣº ÖÐÐËͨѶ £º¹Ù»ª²®

+ Íê³ÉÈÕÆÚ£º 2006Äê04ÔÂ02ÈÕ

+**********************************************************************/

+

+/*ÐÞ¸ÄÀúÊ·£º

+2003-06-30: hbguan,´´½¨

+2003-12-22: hbguan,Ôö¼ÓSDRAM¿ØÖÆÆ÷¼Ä´æÆ÷µØÖ·µÄ¶¨Òå¡£

+2006.04.02  hbguan, Ð޸ģ¬ÓÃÓÚÖ§³Özx2802µÄ²âÊÔ¹¦ÄÜ

+2007.04.02  hbguan, Ð޸ģ¬Ö§³Özx2802 ´Ónor flashÖÐboot

+*/

+

+

+

+/*------- Stacks config ------------------------------------

+TOTAL_STACK_LEN                EQU        0x10000            ; stack length in bytes

+

+STACK_SIZE_UNDEF                EQU        24

+STACK_SIZE_ABORT                EQU        48

+STACK_SIZE_IRQ                    EQU        0x1000

+STACK_SIZE_FIQ                    EQU        0x1000

+STACK_SIZE_SVC                    EQU        (TOTAL_STACK_LEN -STACK_SIZE_UNDEF -STACK_SIZE_ABORT -STACK_SIZE_IRQ -STACK_SIZE_FIQ)

+

+

+

+ARM926E-J CP15 control register 1

+Register    Function

+bit

+----------------------------------------------------------

+[31:19] -     Reserved.

+            When read returns an UNPREDICTABLE value.

+            When written SHOULD BE ZERO, or a value read from bits [31:19] on

+            the same processor.Using a read-modify-write sequence when modifying 

+            this register provides the greatest future compatibility.

+[18]     -     Reserved, SBO. Read = 1, write = 1.

+[17]     -     Reserved, SBZ. Read = 0, write = 0.

+[16]     -     Reserved, SBO. Read = 1, write = 1.

+[15] L4 bit Determines if the T bit is set when load instructions change the PC:

+            0 = loads to PC set the T bit

+            1 = loads to PC do not set T bit (ARMv4 behavior).

+            For more details see the ARM Architecture Reference Manual.

+[14] RR bit Replacement strategy for ICache and DCache:

+            0 = Random replacement

+            1 = Round-robin replacement.

+[13] V bit Location of exception vectors:

+            0 = Normal exception vectors selected, address range = 0x0000 0000 to

+                0x0000 001C

+            1 = High exception vectors selected, address range = 0xFFFF 0000 to

+                0xFFFF 001C.

+            Set to the value of VINITHI on reset.

+[12] I bit ICache enable/disable:

+            0 = ICache disabled

+            1 = ICache enabled.

+[11:10] - SBZ.

+[9] R bit ROM protection.

+            This bit modifies the ROM protection system. See Domain access

+            control on page 3-23.

+[8] S bit System protection.

+            This bit modifies the MMU protection system. See Domain access

+            control register r3 on page 2-17.

+[7] B bit Endianness: 0 = Little-endian operation 1 = Big-endian operation. Set to

+            the value of BIGENDINIT on reset.

+[6:3] - Reserved. SBO.

+[2] C bit DCache enable/disable: 0 = Cache disabled 1 = Cache enabled.

+[1] A bit Alignment fault enable/disable: 0 = Data address alignment fault

+            checking disabled 1 = Data address alignment fault checking enabled.

+[0] M bit MMU enable/disable: 0 = disabled 1 = enabled.

+*/

+

+#ifndef _ZX2802_H

+#define _ZX2802_H

+

+#define DONT_SET_T              (0x1<<15)

+#define ROUND_ROBIN             (0x1<<14)

+#define HIGH_VECTOR             (0x1<<13)

+#define ICACHE_ENABLE           (0x1<<12)

+#ifndef LITTLE_ENDIAN

+#define LITTLE_ENDIAN           (0x0<<7)

+#endif

+#define BIG_ENDIAN              (0x1<<7)

+

+#define DCACHE_ENABLE           (0x1<<2)    /*bit2*/

+#define MMU_ENABLE              (0x1)    /*bit0*/

+

+

+/*Pre-defined constants*/

+#define MODEMASK                0x1f

+#define USERMODE                0x10

+#define FIQMODE                 0x11

+#define IRQMODE                 0x12

+#define SVCMODE                 0x13

+#define ABORTMODE               0x17

+#define UNDEFMODE               0x1b

+#define SYSMODE                 0x1f

+#define NOINT                   0xc0

+#define I_BIT                   0x80

+#define F_BIT                   0x40

+#define MMU_I                   0x1000            /*I-cache enable/disable*/

+

+/*Clock configure regs*/

+#define    ARM_CONTROL_BASE     (0x6000C000)

+

+#define ARM_CLK_CONFIG          (ARM_CONTROL_BASE +4)

+#define ARM_PLL_CONFIG          (ARM_CONTROL_BASE +8)

+#define ARM_RST_CONFIG          (ARM_CONTROL_BASE +0x18)

+#define ZSP_SVT_ADDRESS         (ARM_CONTROL_BASE +0x20)

+

+/*ARM_CLK_CONFIG*/

+#define CORE_CLOCK_DIV_MASK     (0x3 <<6)

+#define CORE_CLOCK_DIV_1        (0x0 <<6)

+#define CORE_CLOCK_DIV_2        (0x1 <<6)

+#define CORE_CLOCK_DIV_3        (0x2 <<6)

+#define CORE_CLOCK_DIV_4        (0x3 <<6)

+

+#define BUS_CLOCK_DIV_MASK      (0x3 <<4)

+#define BUS_CLOCK_DIV_1         (0x0 <<4)

+#define BUS_CLOCK_DIV_2         (0x1 <<4)

+#define BUS_CLOCK_DIV_3         (0x2 <<4)

+#define BUS_CLOCK_DIV_4         (0x3 <<4)

+

+#define CORE_CLOCK_SELECT_MASK  (0x1 <<2)

+#define CORE_CLOCK_SELECT_MAIN  (0x0 <<2)

+#define CORE_CLOCK_SELECT_32KHZ (0x1 <<2)

+#define CORE_CLOCK_SELECT_PLL   (0x2 <<2)

+#define CORE_CLOCK_SELECT_RESERVED  (0x3 <<2)

+

+#define UART_CLOCK_MASK         (0x1 <<1)

+#define UART_CLOCK_MAIN_CLOCK   (0x0 <<1)

+#define UART_CLOCK_BUS_CLOCK    (0x1 <<1)

+

+#define TC_CLOCK_MASK           (0x1 <<0)

+#define TC_CLOCK_MAIN_CLOCK     (0x0 <<0)

+#define TC_CLOCK_BUS_CLOCK      (0x1 <<0)

+

+

+/*interrupt controller register*/

+#define IC_BASE                 (0x60005000)

+#define INT_REQ_REG_ADDR        (IC_BASE +0x00)    /*ÖжÏÇëÇó¼Ä´æ*/

+#define INT_VEC_REG_ADDR        (IC_BASE +0x04)    /*ÆÕͨÖжÏÏòÁ¿¼Ä´æÆ÷*/

+#define INT_FIQ_VEC_REG_ADDR    (IC_BASE +0x08)    /*ÖжÏÏÖ³¡¼Ä´æ*/

+

+#define INT_STA_REG_ADDR        (IC_BASE +0x10)    /*ÖжÏ״̬¼Ä´æÆ÷*/

+#define INT_MASK_REG_ADDR       (IC_BASE +0x14)    /*ÖÐ¶ÏÆÁ±Î¼Ä´æÆ÷(1:¿ª·ÅÖжϣ¬0£ºÆÁ±ÎÖжÏ)*/

+#define INT_TEST_REG_ADDR       (IC_BASE +0x18)    /*ÖжϲâÊԼĴæÆ÷*/

+#define INT_EN_REG_ADDR         (IC_BASE +0x1c)    /*ÖжÏʹÄܼĴæ*/

+

+#define INT_DIS_EN_REG_ADDR     (IC_BASE +0x20)    /*ÖжÏȥʹÄܼĴæÆ÷*/

+#define INT_SET_REG_ADDR        (IC_BASE +0x24)        /*ÖжÏÖÃλ¼Ä´æÆ÷*/

+#define INT_CLEAR_REG_ADDR      (IC_BASE +0x28)        /*ÖжÏÇåλ¼Ä´æ*/

+

+#define NEST_BIT                (0x1 <<10)

+

+/*CS configure*/

+#define SMC_BASE                (0x40000000)

+#define SMC_CS0                 (SMC_BASE + 0x200)

+#define SMC_CS1                 (SMC_BASE + 0x220)    

+#define SMC_CS2                 (SMC_BASE + 0x240)

+

+/*nand flash*/

+#define SMC_CS0_VALUE           (0x00)        /* write enable &8bits*/

+/*nor flash*/

+#define SMC_CS1_VALUE           (0x81)        /* write enable &8 bits*/

+/*SDRAM*/

+#define SMC_CS2_VALUE           (0x0081)    /*write enable &16 bits*/

+

+#define SDRAM0_BASEADDR         (0x10000000)

+

+#define REMAP_ADDR              (0x40000000)

+#define REMAP_DEFAULT_VALUE     (0x11)

+#define REMAP_SDRAM_TO_0x0      (0x31)

+

+

+/*GPIO regs*/

+#define ARMIO_BASE              (0x60007000)

+#define GPIOADATA               (ARMIO_BASE +0x0)    /*0xc002ec00*/

+#define GPIOBDATA               (ARMIO_BASE +0x4)    /*0xc002ec04*/

+#define GPIODIRECTA             (ARMIO_BASE +0x8)    /*0xC002EC08*/

+#define GPIODIRECTB             (ARMIO_BASE +0xc)    /*0xC002EC0c*/

+

+

+/*watchdog configure*/

+#define WD_BASE                 0x60000000  

+#define WD_CTRL_REG             (WD_BASE + 0x00000000)    /* watchdog timer Control register */

+#define WD_LOAD_REG             (WD_BASE + 0x00000004)   /* Watchdog timer load register */ 

+#define WD_COUNTER_REG          (WD_BASE + 0x00000008)   /* Watchdog timer counter register */ 

+#define WD_STATE_REG            (WD_BASE + 0x0000000C)   /* Watchdog timer state register */

+

+#define WD_ST_FILL              (0x01<<0)   /*Æô¶¯¶¨Ê±Æ÷¹¤*/

+#define WD_PTV_FILL             (0xff<<8)  /* ÍⲿʱÖÓ·ÖÆµÏµÊý*/

+

+/*write key:µ±¿ØÖƼĴæÆ÷µÄ¸ß16λΪ16'h1234£¬¶Ô¸Ã¼Ä´æÆ÷дÓÐЧ£¬¶ÁʱΪ0 */

+#define WD_WRITE_KEY            (0x1234<<16)   

+

+#define WD_ST_POS               0   /* Æô¶¯¶¨Ê±Æ÷¹¤×÷*/

+#define WD_PTV_POS              8   /* ÍⲿʱÖÓ·ÖÆµ*/

+

+

+/*Òý½Å¸´ÓÃ*/

+#define ARM_PMM_IOCONF1         (0x6000b000)

+#define ARM_PMM_IOCONF2         (0x6000b004)

+

+/*ARM_PMM_IOCONF1*/

+#define USED_ARM_UART2_PINS     (0x3 <<14)

+#define USED_ARM_UART1_PINS     (0xf <<10)

+/*ARM_PMM_IOCONF2*/

+#define USED_DSP_UART_PINS      (0x3 <<14)

+

+

+/*Mode_Stack_Area                EQU        (0x100000)*/

+

+#define reg(addr)               (*(volatile unsigned *)(addr))

+#define reg8(addr)              (*(volatile unsigned char*)(addr))

+#define reg16(addr)             (*(volatile unsigned short*)(addr))

+#define reg32(addr)             (*(volatile unsigned long*)(addr))

+

+#ifndef ERROR

+#define ERROR                   (-1)

+#endif

+

+

+#define READ_DEFAULT_WORDS      8

+

+#endif/*_ZX2802_H*/

+