#line 1 "..\\..\\..\\..\\uipkernel\\uip_kernel_common.c"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

#line 1 "..\\..\\..\\..\\uipkernel\\uip_kernel_api.h"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 


















 






 





  
#line 90 "..\\..\\..\\..\\uipkernel\\uip_kernel_api.h"






#line 105 "..\\..\\..\\..\\uipkernel\\uip_kernel_api.h"

 
 


 




 


 






 



















 





















                         



 


 


 


 
 


 


  

typedef signed char                 UIP_CHAR;
typedef unsigned char               UIP_UCHAR;
typedef signed char                 UIP_INT8;
typedef unsigned char               UIP_UINT8;
typedef signed short                UIP_INT16;
typedef unsigned short              UIP_UINT16;
typedef signed int                  UIP_INT;
typedef unsigned int                UIP_UINT;
typedef signed long                 UIP_INT32;
typedef unsigned long               UIP_UINT32;


typedef signed char *               UIP_CHAR_PTR;
typedef unsigned char *             UIP_UCHAR_PTR;
typedef signed char *               UIP_INT8_PTR;
typedef unsigned char *             UIP_UINT8_PTR;
typedef signed short *              UIP_INT16_PTR;
typedef unsigned short *            UIP_UINT16_PTR;
typedef signed int *                UIP_INT_PTR;
typedef unsigned int *              UIP_UINT_PTR;
typedef signed long *               UIP_INT32_PTR;
typedef unsigned long *             UIP_UINT32_PTR;
typedef void *                      UIP_VOID_PTR;
 
typedef UIP_INT32                   TaskType;
typedef UIP_INT32_PTR               TaskRefType;
typedef UIP_UCHAR                   TaskStateType;
typedef UIP_UCHAR_PTR               TaskStateRefType;
typedef UIP_UCHAR                   TaskNumberType;                         

typedef UIP_UCHAR                   StatusType;
typedef UIP_UINT                    PointerType;                    

typedef UIP_UCHAR *                 AppDataRef;
typedef UIP_UCHAR                   FlagType;
typedef UIP_UCHAR                   AppModeType;                    

typedef UIP_UINT                    ResourceType;
typedef UIP_UCHAR                   ResNumberType;                          


typedef UIP_UINT                    EventMaskType;
typedef EventMaskType *             EventMaskRefType;

typedef UIP_UCHAR                   AlarmType;
typedef UIP_UCHAR_PTR               AlarmRefType;
typedef UIP_UINT                    TickType;
typedef UIP_UINT_PTR                TickRefType;
typedef UIP_UCHAR                   AlarmNumberType;

typedef UIP_UCHAR                   MsgType;
typedef UIP_UCHAR                   MsgNumberType;                          

 
typedef struct uip_RESOURCE_STRUCT 
{
    struct uip_TSK_STRUCT    
                      *uipTaskPtr;                      
    struct uip_RESOURCE_STRUCT    
                      *uipNextRes;                      
    UIP_UINT          uipResCeilingGrpBit;             
 
    UIP_UCHAR         uipCeilingPrio;                   
    UIP_UCHAR         uipResCeilingGrpArrayIndex;      
 
    UIP_UCHAR         uipResCeilingGrpArrayBit;        
 
    UIP_UCHAR         uipTaskPrio;                      
    UIP_UCHAR         uipLock;                         

 
    UIP_UCHAR         padding_1;                        
    UIP_UCHAR         padding_2;                        
    UIP_UCHAR         padding_3;                        
} uipRes; 

typedef uipRes *                       uipResPtr;

 
 
typedef struct uip_TSK_STRUCT
{
    UIP_UCHAR         uipTaskID;                        
    UIP_UCHAR         uipTaskState;                     
    UIP_UCHAR         uipReadyPrio;                     

    UIP_UCHAR         uipDispatchPrio;                  



    struct uip_RESOURCE_STRUCT  
                      *uipResources;                    
    void              (*uipTaskEntry)(void);            
    UIP_VOID_PTR      uipStackPtr;                      
    UIP_UINT          uipStackSize;                     
    EventMaskType     UIP_WaitEvent;                    
    EventMaskType     UIP_SetEvent;                     
    UIP_UINT          uipRdyPrioGrpBit;                
 
    UIP_UCHAR         uipRdyPrioGrpArrayIndex;         
 
    UIP_UCHAR         uipRdyPrioGrpArrayBit;           
 
    UIP_UCHAR         uipActivatedNumber;               
    UIP_UCHAR         padding_2;                            

    UIP_UINT          uipDispPrioGrpBit;               
 
    UIP_UCHAR         uipDispPrioGrpArrayIndex;        
 
    UIP_UCHAR         uipDispPrioGrpArrayBit;          
 
    UIP_UCHAR         padding_3;                            
    UIP_UCHAR         padding_4;                            

     
    UIP_UINT          IsInited;
} uipTask; 

typedef uipTask *                      uipTaskPtr;

typedef struct uip_ALARMBASE_STRUCT
{
    TickType          maxAllowedValue;                 
 
    TickType          ticksPerBase;                    
 
    TickType          minCycle;                        

 
} AlarmBaseType; 

typedef AlarmBaseType *                AlarmBaseRefType;

 
typedef struct uip_CTR_STRUCT
{
    TickType          uipCtrValue;                       
    TickType          uipTick;
    struct uip_ALARMBASE_STRUCT  
                      *uipCtrBase;
} uipCounter; 

typedef uipCounter *                   uipCounterPtr;

 
typedef struct uip_ALARM_STRUCT
{
    TickType          uipAlarmValue;    
    UIP_UINT          uipCycle;         
    UIP_UINT          uipEvent;
    struct uip_CTR_STRUCT    
                      *uipCounterPtr;       
    void              (*uipCallBack)(void);
    UIP_UCHAR         uipAlarmActTaskID;
    UIP_UCHAR         uipAlarmState;            
    UIP_UCHAR         padding_1;                            
    UIP_UCHAR         padding_2;                            
} uipAlarm;

typedef uipAlarm *                     uipAlarmPtr;

 
typedef struct uip_MSG_STRUCT
{
    UIP_UCHAR         uipMsgId;                          
    UIP_UCHAR         uipMsgStatus;                     
 
    UIP_UCHAR         uipMsgType;                        
    UIP_UCHAR         uipMsgFlag;                        
    UIP_UCHAR_PTR     uipMsgPtr;                          
    UIP_UCHAR_PTR     uipQueueWriteHead;                  
    UIP_UCHAR_PTR     uipQueueEnd;                        
    UIP_UCHAR_PTR     uipQueueReadHead;                  
    UIP_UINT          uipMsgSize;                        
    UIP_UINT          uipMsgEvent;                       
    void              (*uipMsgCallBack)(void);           
    UIP_UCHAR         uipMsgNotifyTaskID;                
    UIP_UCHAR         uipMsgNotifyType;                      
    UIP_UCHAR         padding_2;                             
    UIP_UCHAR         padding_3;                             
} uipMsg; 
 
typedef uipMsg *                       uipMsgPtr;

 
 
typedef struct uip_INT_STRUCT
{
    UIP_UINT32        uipIntId;                          
    UIP_UINT32        uipIntExcepted;                    
    UIP_UINT32        uipIntOutcome;                     
    void              *uipInfo;                          
    UIP_UINT32        (*uipIntCallBack)(struct uip_INT_STRUCT *uipIntContorl);  
                                                        
 
    void              *uipIntReserved;                   
} uipInt; 

typedef uipInt *                       uipIntPtr;

typedef UIP_UINT32 (*uipIntCallBackFunction)(struct uip_INT_STRUCT *uipIntContorl);

 
 
 
 
  
 
StatusType      UIP_GetAlarmBase(AlarmType AlarmID, AlarmBaseRefType Info);

 
 
  
 
StatusType      UIP_GetAlarm(AlarmType AlarmID, TickRefType Tick);

 
 
 
 
 
  
 
StatusType      UIP_SetRelAlarm(AlarmType AlarmID, TickType increment, TickType cycle);

 
 
 
 
 
 
StatusType      UIP_SetAbsAlarm(AlarmType AlarmID, TickType start, TickType cycle);

 
  
 
StatusType      UIP_CancelAlarm(AlarmType AlarmID);

 
  
 
void            uipSystemCounterHandler(void);

 
  
 
void            uipAlarmHandler(UIP_UINT alarm_index);

 
  
 
void            uipGeneralCounterHandler(AlarmType AlarmID);

 
 
 
void            HardFault_Handler(void);
void            UsageFault_Handler(void);
 
  
 
StatusType      uipGetCtrCurrentValue(AlarmType AlarmID, TickRefType Tick);







 
extern UIP_CHAR                              uipLowPowerMode;

 
extern UIP_CHAR                              uipSchedulerLock; 
 
 
extern UIP_UINT                              uipNestedInterrupts;

extern AppModeType                           uipSystemMode;



 
extern UIP_UINT                              uipPrioGroup;



 
extern UIP_UCHAR                             uipPrioGrpArray[(16/8)];

 
extern UIP_UCHAR                             uipLowHalfByteValue[]; 

extern UIP_UCHAR                             uipHighHalfByteValue[];  

 
extern uipTask                               *uipCurrentTaskTCBPtr;


 
extern uipTask                               *uipNextRunningTaskTCBPtr;

extern void                                  *uipSystemStackPtr; 

 
extern UIP_UCHAR                             uipCurrentTaskPriority;                

 
extern UIP_UCHAR                             uipNextRunningTaskPriority;           

 
extern UIP_UCHAR                             uipIdleTaskID;

extern uipTask                               *uipIdleTaskTCBPtr;

extern void                                  uipArmIntHandlerGate(void);

extern UIP_INT32                             uipIntTableID;

extern UIP_UINT32                            uipInSchedulerLoop;


 
void                           uipResetPrioGrpAndArrayBit(void);


 
void                           uipClearPrioGrpAndArrayBit(uipTaskPtr suspendTaskPtr);

 
extern void            uipGetNextTask(void);

 
UIP_UCHAR                      uipGetNextPriority(void);
 
 
void                           uipClearPrioGrpAndArrayBit(uipTaskPtr suspendTaskPtr);

 
 

 

unsigned int            uipDisableAllInterrupts(void);   
        
void                           uipIntMaskStateRestore(unsigned int cpuStateRegister);


 
 
 
  
 
StatusType      UIP_GetResource(ResourceType ID);

 
 
 
  
 
StatusType      UIP_ReleaseResource(ResourceType ID);


 
 
 
  
 
StatusType      UIP_SendMessage(MsgType MsgID, AppDataRef DataRef);

 
 
 
 
  
 
StatusType      UIP_ReceiveMessage(MsgType MsgID, AppDataRef DataRef);

 
 
  
 
StatusType      UIP_GetMessageStatus(MsgType MsgID);

 
 
  
 
FlagType        UIP_ReadFlag(MsgType MsgID);

 
  
 
StatusType      UIP_ResetFlag(MsgType MsgID);

 
 
  
 
StatusType      UIP_StartCOM(void);

 
  
 
StatusType      UIP_CloseCOM(void);

 
 
 
  
 
StatusType      UIP_StopCOM(UIP_UCHAR ShutdownMode);








       
extern uipTaskPtr                            uipTCBArray;  

extern UIP_UCHAR                             uipPriorityToTaskID[16];

extern UIP_UINT                              uipInitTaskStackPtr[16];

extern TaskNumberType                        uipTaskNumber;                               

extern TaskNumberType                        uipTaskIDNumber;                       

       
extern uipResPtr                             uipRCBArray;  

extern ResNumberType                         uipResNumber;                                

 
extern uipAlarmPtr                           uipACBArray;

extern AlarmNumberType                       uipAlarmNumber;                             

extern AlarmType                             uipAlarmID;

 
extern uipMsgPtr                             uipMCBArray;

extern MsgNumberType                         uipMsgNumber;                           

extern uipCounter                            uipSystemCounter;

 
extern AlarmBaseType                         uipSystemAlarmBase;

extern StatusType                            uipCOMInit(void);
 
 
 
 
void            StartOS(AppModeType mode);

 
 
 
void            ShutdownOS(StatusType status);

 
 
 
void            uipTaskInfoInit(uipTaskPtr appTCBArray, TaskNumberType taskNumber);

 
 
 
void            uipResInfoInit(uipResPtr appRCBArray, ResNumberType resNumber);

 
 
 
void            uipMsgInfoInit(uipMsgPtr appMCBArray, MsgNumberType mcbNumber);

 
 
 
void            uipAlarmInfoInit(uipAlarmPtr appACBArray, AlarmNumberType acbNumber);

 
 
 
 
UIP_VOID_PTR    uipTaskStackInit(void *taskEntry, UIP_UINT stackInitialAdress);

 
 
  
 
StatusType      uipTaskInitialize(uipTaskPtr appTCBArray, TaskNumberType tcbNumber);

void            uipKernelInitialize(void);

 
 
  
 
StatusType      uipResInitialize(uipResPtr appRCBArray, ResNumberType rcbNumber);

 
 
  
 
StatusType      uipMsgInitialize(uipMsgPtr appMCBArray, MsgNumberType mcbNumber);

 
 
  
 
StatusType      uipAlarmInitialize(uipAlarmPtr appACBArray, AlarmNumberType acbNumber);


 
 
  
 
void            uipAppInitialize(void);


 
 
 
 
  
 
StatusType      UIP_SetEvent(TaskType TaskID, EventMaskType Mask);

 
 
  
 
StatusType      UIP_ClearEvent(EventMaskType Mask);

 
 
 
 
  
 
StatusType      UIP_GetEvent(TaskType TaskID, EventMaskRefType Mask);

 
 
 
  
 
StatusType      UIP_WaitEvent(EventMaskType Mask);


 
 
 
  
 
StatusType      UIP_ActivateTask(TaskType TaskID);

 
 
 
 
 
StatusType      UIP_TerminateTask(void);

 
 
 
 
 
  
 
StatusType      UIP_ChainTask(TaskType TaskID);

 
 
 
 
  
 
StatusType      UIP_Schedule(void); 

 
 
  
 
StatusType      UIP_GetTaskID(TaskRefType TaskID);

 
 
  
 
StatusType      UIP_GetTaskState(TaskType TaskID, TaskStateRefType State); 

void            uipIRQIntContextSave(void);
void            uipSystemCounterHandler(void);
void            uipIRQIntContextRestore(void);
void            HardFault_Handler(void);

void            uipPreContexSwitch(void);
void            uipPendSVHandler(void);
void            uipInterruptServiceEngine(void);
void            uipInterruptHandlingCallback(void);
 

 






#line 812 "..\\..\\..\\..\\uipkernel\\uip_kernel_api.h"












#line 832 "..\\..\\..\\..\\uipkernel\\uip_kernel_api.h"






 

StatusType      UIP_ActivateTask(TaskType TaskID);
StatusType      UIP_TerminateTask(void);
StatusType      UIP_ChainTask(TaskType TaskID);
StatusType      UIP_Schedule(void); 
StatusType      UIP_GetTaskID(TaskRefType TaskID);
StatusType      UIP_GetTaskState(TaskType TaskID, TaskStateRefType State); 

StatusType      UIP_GetAlarmBase(AlarmType AlarmID, AlarmBaseRefType Info);
StatusType      UIP_GetAlarm(AlarmType AlarmID, TickRefType Tick);
StatusType      UIP_SetRelAlarm(AlarmType AlarmID, TickType increment, TickType cycle);
StatusType      UIP_SetAbsAlarm(AlarmType AlarmID, TickType start, TickType cycle);
StatusType      UIP_CancelAlarm(AlarmType AlarmID);

StatusType      UIP_SetEvent(TaskType TaskID, EventMaskType Mask);
StatusType      UIP_ClearEvent(EventMaskType Mask);
StatusType      UIP_GetEvent(TaskType TaskID, EventMaskRefType Mask);
StatusType      UIP_WaitEvent(EventMaskType Mask);

StatusType      UIP_SendMessage(MsgType MsgID, AppDataRef DataRef);
StatusType      UIP_ReceiveMessage(MsgType MsgID, AppDataRef DataRef);
StatusType      UIP_GetMessageStatus(MsgType MsgID);
FlagType        UIP_ReadFlag(MsgType MsgID);
StatusType      UIP_ResetFlag(MsgType MsgID);
StatusType      UIP_StartCOM(void);
StatusType      UIP_CloseCOM(void);
StatusType      UIP_StopCOM(UIP_UCHAR ShutdownMode);

StatusType      UIP_GetResource(ResourceType ID);
StatusType      UIP_ReleaseResource(ResourceType ID);







 
 
 
#line 46 "..\\..\\..\\..\\uipkernel\\uip_kernel_common.c"

       
 
UIP_CHAR                              uipLowPowerMode;

uipTaskPtr                            uipTCBArray;  

UIP_UCHAR                             uipPriorityToTaskID[16];

UIP_UINT                              uipInitTaskStackPtr[16];

TaskNumberType                        uipTaskNumber;                               

TaskNumberType                        uipTaskIDNumber;                       

       
uipResPtr                             uipRCBArray;  

ResNumberType                         uipResNumber;                                

 
uipAlarmPtr                           uipACBArray;

AlarmNumberType                       uipAlarmNumber;                             

AlarmType                             uipAlarmID;

 
uipMsgPtr                             uipMCBArray;

MsgNumberType                         uipMsgNumber;                           

uipCounter                            uipSystemCounter;

AlarmBaseType                         uipSystemAlarmBase;

UIP_UCHAR                             uipOSSurport;

UIP_UCHAR                             uipIdleTaskID;

uipTask                               *uipIdleTaskTCBPtr;

UIP_INT32                             uipIntTableID;

UIP_UINT32                            uipInSchedulerLoop;

  
  
  
  
  
  
  
  
  
  
  
  
 
 
  
  
  
 
  
  
  
  
  
  
  
 
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
void StartOS(AppModeType mode)
{
    unsigned int uipInterruptStateSaved;;

     
    {uipInterruptStateSaved = uipDisableAllInterrupts();};
    
     
    uipKernelInitialize();
    
    uipAppInitialize();

    uipSystemMode = mode;

     
    *((unsigned int *)0xE000ED04) = 0x10000000;
    
     
    {uipIntMaskStateRestore(uipInterruptStateSaved);};    
}  

  
  
  
  
  
  
  
  
  
  
  
  
 
  
  
  
 
  
  
  
  
  
  
  
 
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
void ShutdownOS(StatusType status)
{
     
    ;
}  

  
  
  
  
  
  
  
  
  
  
  
  
 
  
  
  
 
  
                                                                  
  
  
  
  
  
  
  
 
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
void uipTaskInfoInit(uipTaskPtr appTCBArray, TaskNumberType taskNumber)
{
     
    uipTaskNumber = taskNumber;	
    
     
    uipTCBArray = (uipTaskPtr)appTCBArray;    	
}  

  
  
  
  
  
  
  
  
  
  
  
  
 
  
  
  
 
  
                                                                  
  
  
  
  
  
  
  
 
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
void uipResInfoInit(uipResPtr appRCBArray, ResNumberType resNumber)
{
     
    uipResNumber= resNumber;	
    
     
    uipRCBArray = (uipResPtr)appRCBArray;    	
}  

  
  
  
  
  
  
  
  
  
  
  
  
 
  
  
  
 
  
                                                                  
  
  
  
  
  
  
  
 
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
void uipMsgInfoInit(uipMsgPtr appMCBArray, MsgNumberType mcbNumber)
{
     
    uipMsgNumber = mcbNumber;
    
     
    uipMCBArray = (uipMsgPtr)appMCBArray;    	
}  

  
  
  
  
  
  
  
  
  
  
  
  
 
  
  
  
 
  
                                                                  
  
  
  
  
  
  
  
 
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
void uipAlarmInfoInit(uipAlarmPtr appACBArray, AlarmNumberType acbNumber)
{
     
    uipAlarmNumber = acbNumber;
    
     
    uipACBArray = (uipAlarmPtr)appACBArray;    	
}  

  
  
  
  
  
  
  
  
  
  
  
  
 
  
  
  
                                                                  
  
  
  
  
  
  
  
 
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
void uipKernelInitialize(void)
{
    UIP_UINT            i, val;
    
    uipTCBArray = 0x00;  

    for(i=0; i<16; i++)
    {
    	uipPriorityToTaskID[i] = 0x00;
    	uipInitTaskStackPtr[i] = 0x00;
    }

    for(i=0; i<(16/8); i++)
    {
    	uipPrioGrpArray[i] = 0x00;
    }
     
    val = sizeof(TickType) - 1;
    uipSystemAlarmBase.maxAllowedValue = 0xFF;
    for(i = 0; i < val; i++)
    {
         
        uipSystemAlarmBase.maxAllowedValue = uipSystemAlarmBase.maxAllowedValue << 8 | (~0x00);  
    }
    uipSystemAlarmBase.ticksPerBase = 1;
    uipSystemAlarmBase.minCycle = 1;
    
    uipSystemCounter.uipCtrBase = &uipSystemAlarmBase;
    uipSystemCounter.uipCtrValue = 0;
    uipSystemCounter.uipTick = 0;        
    
    uipTaskNumber = 0x00;                               
    uipTaskIDNumber = 0x00;                       
    uipRCBArray = 0x00;  
    uipResNumber = 0x00;                                
    uipACBArray = 0x00;
    uipAlarmNumber = 0x00;                             
    uipAlarmID = 0x00;
    uipMCBArray = 0x00;
    uipMsgNumber = 0x00;
    uipLowPowerMode = 0x00;                           
    uipSchedulerLock = 0x00;
    uipNestedInterrupts = 0x00;
    uipSystemMode = 0x00;
    uipPrioGroup = 0x00;
    uipCurrentTaskTCBPtr = 0x00;
    uipNextRunningTaskTCBPtr = 0x00;
    uipSystemStackPtr = 0x00;
    uipCurrentTaskPriority = (16-1);
    uipNextRunningTaskPriority = (16-1);
    uipInSchedulerLoop = 0x00;

    uipIntTableID = 0x00;
}

  
  
  
  
  
  
  
  
  
  
  
  
 
 
  
  
  
 
  
                                                                  
  
  
  
  
  
  
  
 
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
UIP_VOID_PTR uipTaskStackInit(void *taskEntry, UIP_UINT stackInitialAdress)
{
    UIP_UINT    *taskStack;

    taskStack = (UIP_UINT *)stackInitialAdress;            

    taskStack--;                  
    *taskStack = (UIP_UINT)0x01000000UL;                   
    taskStack--;                  
    *taskStack = (UIP_UINT)(taskEntry);                    
    taskStack--;                  
    *taskStack = (UIP_UINT)0x00000000L;                    
    taskStack--;                  
    *taskStack = (UIP_UINT)0x00000000L;                    
    taskStack--;                  
    *taskStack = (UIP_UINT)0x00000000L;                    
    taskStack--;                  
    *taskStack = (UIP_UINT)0x00000000L;                    
    taskStack--;                  
    *taskStack = (UIP_UINT)0x00000000L;                    
    taskStack--;                  
    *taskStack = (UIP_UINT)0x00000000L;                    
                                                                                                                
    taskStack--;                  
    *taskStack = (UIP_UINT)0x00000000L;                    
    taskStack--;                  
    *taskStack = (UIP_UINT)0x00000000L;                    
    taskStack--;                  
    *taskStack = (UIP_UINT)0x00000000L;                    
    taskStack--;                  
    *taskStack = (UIP_UINT)0x00000000L;                    
    taskStack--;                  
    *taskStack = (UIP_UINT)0x00000000L;                    
    taskStack--;                  
    *taskStack = (UIP_UINT)0x00000000L;                    
    taskStack--;                  
    *taskStack = (UIP_UINT)0x00000000L;                    
    taskStack--;                  
    *taskStack = (UIP_UINT)0x00000000L;                    

    return taskStack;
}  

  
  
  
  
  
  
  
  
  
  
  
  
 
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
StatusType uipTaskInitialize(uipTaskPtr appTCBArray, TaskNumberType tcbNumber)
{
    TaskNumberType        number;
    uipTaskPtr            taskPtr;
    
     
    if (tcbNumber > (16-1))
    {
         return (0x08); 
    }
    else
    {
         
        uipTaskNumber = tcbNumber;
    }	  

     
    uipTCBArray = (uipTaskPtr)appTCBArray;    	

     
    for (number = 0; number < tcbNumber; number++)
    {    	 
    	taskPtr = (uipTaskPtr)((UIP_UINT)uipTCBArray + number*sizeof(uipTask));
    	  
    	uipInitTaskStackPtr[number] = (UIP_UINT)(taskPtr -> uipStackPtr);
        
        uipPriorityToTaskID[taskPtr -> uipReadyPrio] = taskPtr -> uipTaskID;


        uipPriorityToTaskID[taskPtr -> uipDispatchPrio] = taskPtr -> uipTaskID;

        taskPtr -> uipRdyPrioGrpArrayIndex = (UIP_UCHAR)(taskPtr -> uipReadyPrio >> 3);
        taskPtr -> uipRdyPrioGrpBit = (UIP_UINT)((UIP_UINT)1 << 
                                         (taskPtr -> uipRdyPrioGrpArrayIndex));
        taskPtr -> uipRdyPrioGrpArrayBit = (UIP_UCHAR) ((UIP_UCHAR)1 << 
                                         (taskPtr -> uipReadyPrio & 0x07));

        taskPtr -> uipDispPrioGrpArrayIndex = (UIP_UCHAR)(taskPtr -> uipDispatchPrio >> 3);
        taskPtr -> uipDispPrioGrpBit = (UIP_UINT)((UIP_UINT)1 << 
                                         (taskPtr -> uipDispPrioGrpArrayIndex));
        taskPtr -> uipDispPrioGrpArrayBit = (UIP_UCHAR) ((UIP_UCHAR)1 << 
                                         (taskPtr -> uipDispatchPrio & 0x07));


        taskPtr -> uipStackPtr = uipTaskStackInit((void *)(taskPtr -> uipTaskEntry),
                                                   (UIP_UINT)(taskPtr -> uipStackPtr));
    	taskPtr -> IsInited = 0;
        taskPtr -> UIP_SetEvent = 0x0;
        taskPtr -> uipResources = (uipResPtr)0x0;
         
         
         
        if (((taskPtr -> uipTaskState) & 0x0F) == 0x4)
        { 
            uipPrioGroup |= (taskPtr -> uipRdyPrioGrpBit);

             
            uipPrioGrpArray[taskPtr -> uipRdyPrioGrpArrayIndex] |= taskPtr -> uipRdyPrioGrpArrayBit;
              
            if(uipNextRunningTaskPriority != (16-1))
            {
                if(taskPtr -> uipReadyPrio < uipNextRunningTaskPriority)
                {
                	uipNextRunningTaskPriority = taskPtr -> uipReadyPrio;
                    uipNextRunningTaskTCBPtr = taskPtr;
                }
            }
            else
            {
                uipNextRunningTaskPriority = taskPtr -> uipReadyPrio;
                uipNextRunningTaskTCBPtr = taskPtr;
            } 
        }        
    }
    
    return (0x00);    
}  

  
  
  
  
  
  
  
  
  
  
  
  
 
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
StatusType uipResInitialize(uipResPtr appRCBArray, ResNumberType rcbNumber)
{
    ResNumberType        number;
    uipResPtr            resPtr;
    
     
    if(rcbNumber > 8)
    {
        return (0x08); 
    }
    else
    {
         
        uipResNumber= rcbNumber;	    	
    }

     
    uipRCBArray = (uipResPtr)appRCBArray;    	
     
     
    for(number = 0; number < rcbNumber; number++)
    {
    	resPtr = (uipResPtr)((UIP_UINT)uipRCBArray + number*sizeof(uipRes));  
        resPtr -> uipResCeilingGrpArrayIndex = (UIP_UCHAR)(resPtr -> uipCeilingPrio >> 3);
        resPtr -> uipResCeilingGrpBit = (UIP_UINT)((UIP_UINT)1 << 
                                         (resPtr -> uipResCeilingGrpArrayIndex));
        resPtr -> uipResCeilingGrpArrayBit = (UIP_UCHAR) ((UIP_UCHAR)1 << 
                                         (resPtr -> uipCeilingPrio & 0x07));
    }
    
    return (0x00);    
}  

  
  
  
  
  
  
  
  
  
  
  
  
 
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
StatusType uipMsgInitialize(uipMsgPtr appMCBArray, MsgNumberType mcbNumber)
{
    MsgNumberType        number;
    uipMsgPtr            msgPtr;
    
     
    if(mcbNumber > 8)
    {
        return (0x08); 
    }
    else
    {
    	 
    	uipMsgNumber = mcbNumber;	
    }

     
    uipMCBArray = (uipMsgPtr)appMCBArray;    	
     
     
    for(number = 0; number < uipMsgNumber; number++)
    {
    	msgPtr = (uipMsgPtr)((UIP_UINT)uipMCBArray + number*sizeof(uipMsg));  
        msgPtr -> uipQueueWriteHead = msgPtr -> uipMsgPtr;
        msgPtr -> uipQueueReadHead = msgPtr -> uipMsgPtr;
    }
    
    return (0x00);    
}  

  
  
  
  
  
  
  
  
  
  
  
  
 
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
StatusType uipAlarmInitialize(uipAlarmPtr appACBArray, AlarmNumberType acbNumber)
{
    ResNumberType        number;
    
     
    if(acbNumber > 8)
    {
        return (0x08); 
    }
    else
    {
         
        uipAlarmNumber = acbNumber;	
    }

     
    uipACBArray = (uipAlarmPtr)appACBArray;    	

     
    for(number = 0; number < acbNumber; number++)
    {
         
    	;
    }
    
    return (0x00);    
}  

 
 
 
