主要完成在uc-os2操作系统对dsp的资源控制和调度

源代码在线查看: system.c

软件大小: 195 K
上传用户: lemon_zc1949
关键词: uc-os dsp 操作系统 控制
下载地址: 免注册下载 普通下载 VIP

相关代码

				/*****************************************************************************
				*
				* component   :     
				*
				* module name :     system.c
				* date        :     
				*
				* subcomponent:
				*
				******************************************************************************
				*
				* function    :                                                   
				*               
				*               
				* description :                                                   
				*
				******************************************************************************
				*
				*
				* dependencies:
				*			   
				*               uC/OS-II The Realtime KERNEL by Jean J. Labrosse
				*
				* author      : Kenneth Blake - Oberon Data och Elektronik AB
				*               ken@oberon.se  www.oberon.se
				* history     : 
				*
				*
				******************************************************************************/
				
				
				#include "D:\testUCOS\tic6416\test6416\SOURCE\includes.h"
				//#include 
				
				void minit(void);
				
				
				#pragma DATA_SECTION( ClockTaskStack              ,"STACK_AREA" );
				#pragma DATA_SECTION( ForSystemSupervisorStack    ,"STACK_AREA" );
				#pragma DATA_SECTION( OSTaskIdleStk                 ,"STACK_AREA" );
				
				#pragma DATA_SECTION( TaskOneStack                 ,"STACK_AREA" );
				#pragma DATA_SECTION( TaskTwoStack                 ,"STACK_AREA" );
				#pragma DATA_SECTION( TaskThreeStack                 ,"STACK_AREA" );
				#pragma DATA_SECTION( TaskFourStack                 ,"STACK_AREA" );
				#pragma DATA_SECTION( TaskFiveStack                 ,"STACK_AREA" );
				
				
				
				far  OS_STK      OSTaskIdleStk[OS_TASK_IDLE_STK_SIZE];  /* Idle task stack                          */
				
				INT32U ClockTaskStack                [CLOCK_TASK_STACK_SIZE                  ] ;
				INT32U ForSystemSupervisorStack      [SYSTEM_SUPERVISOR_TASK_STACK_SIZE	 	] ;
				INT32U TaskOneStack                  [TASK_ONE_STACK_SIZE            	 	] ;
				INT32U TaskTwoStack                  [TASK_TWO_STACK_SIZE            	 	] ;
				INT32U TaskThreeStack                 [TASK_THREE_STACK_SIZE            	 	] ;
				INT32U TaskFourStack                  [TASK_FOUR_STACK_SIZE            	 	] ;
				INT32U TaskFiveStack                  [TASK_FIVE_STACK_SIZE            	 	] ;
				
				
				
				KERNEL_S     KERNEL;
				
				volatile unsigned int Volatile_Value_Of_Illegal_Interrupt ;
				   
				volatile unsigned int
				   Always_Enabled_Interrupts  ,
				   Normally_Enabled_Interrupts;
				
				
				SEMAPHORE_S  *Semaphore ;
				MAILBOX_S    *MailBox   ;
				QUEUE_S      *Queue     ;
				
				
				
				
				/******************************************************************************
				*                                                                            
				* function    : TimerOneTick(void ) 
				* description : Timer 1 tick interrupt handler
				*                                                                            
				*               Ticks every millisecond                                                             
				*                                                                            
				* dependencies: Setup in the interrupt vector : c6inthnd.asm
				*                                               os_cpu_a.asm                             
				*                                                                            
				*  Input      : None
				*  Output     : None
				* history     :                                                              
				* return value : 
				* Cost  :                                                                     
				*                                                                            
				******************************************************************************/
				/*------------------------------**
				**  Timer one interrupt handler  **
				**------------------------------*/
				  /* do not declare this with the 
				     ordinary interrupt keyword 
				     or #pragma interrupt () ; */
				     
				void 
				TimerOneTick(void)                          /* Interrupt 15, System Timer One millisecond */
				{
				   CPU_Save()   ; /* CPU runtime saving of task registers */
				   
				   OSIntEnter() ;
				
				   OSMboxPost( MailBox->ForTheClockInterrupt, (void *)1); 
				   OSIntExit()  ;
				   
				/*   CSR = CSR & (unsigned int)-2;*/
				   CPU_Restor() ; /* CPU runtime popping of task registers */
				}
				
				
				
				/******************************************************************************
				*                                                                            
				* function    : System__Hardware__Initialisation
				* description : 
				*                                                                            
				*               Initializes the hardware parts of the system   
				*               So that the KERNEL may be built and started
				*               System activation is the process of bringing a software system 
				*               to its operational state. It includes systematic activities 
				*               such as obtaining operational (configuration) data and 
				*               synchronizing with other components before starting full 
				*               operation. For example,after adding a new node into a computer 
				*               communication network, the node may first have to synchronize 
				*               with other nodes to obtain its routing data. Deactivation of 
				*               the system or individual components also needs to be done 
				*               systematically. For example, the various resources used 
				*               by a component must be returned when the component is 
				*               deactivated.
				*                
				*                   System_activation(void) (start up) 
				*                   Deactivation(void)
				*                   InitialisationCheck(void)
				*                   ColdStart(void)
				*                   WarmStart(void)
				*                   HotStart(void)
				* 
				*                                                                             
				*  dependencies: 
				*   Input      : 
				*   Output     : 
				* history     :                                                              
				* return value : 
				* Cost  :                                                                     
				*                                                                            
				******************************************************************************/
				/*--------------------------------------------**
				**                                            **
				**  S Y S T E M  I N I T I A L I S A T I O N  **
				**                                            **
				**--------------------------------------------*/
				void    System__Hardware__Initialisation(void)   
				{
				    
				    Normally_Enabled_Interrupts  = 0 ;
				    //CPU_Processor_Setup TO set the cpu timer intrupt for producing the TimerOneTick intruption 
					//USER CODE
					//end user code 
				    Always_Enabled_Interrupts   = 0      ;
				
				//    ICR = 0 ; /* Clear all strange interrupts, if any */
				
				    Normally_Enabled_Interrupts  =(1 				                    //to EN the cpu IER register acording to the diffrent cpu
				}
				
				
				
				
				
				/******************************************************************************
				*                                                                            
				* function    : SystemBuild__CreateQueues( )
				* description : 
				*               Builds the necessary Queues                                                             
				*                                                                            
				* dependencies: 
				*  Input      : 
				*  Output     : 
				* history     :                                                              
				* return value : 
				* Cost  :                                                                     
				*                                                                            
				******************************************************************************/
				
				void    SystemBuild__CreateQueues(void)  
				{
				
				/*-----------------------**
				**        M E S S A G E  **
				**        H A N D L E R  **
				**-----------------------*/
				    // user code such as Queue->ForMessageHandler_Input.Event  = 
				       //OSQCreate( &Queue->ForMessageHandler_Input.QueueElement[0],  QUEUE_MAX_SIZE  );   
				       
				}	   
				
				
				/******************************************************************************
				*                                                                            
				* function    : SystemBuild__CreateMailBoxes
				* description : 
				*               Builds the necessary MailBoxes                                                             
				*                                                                            
				* dependencies: 
				*  Input      : 
				*  Output     : 
				* history     :                                                              
				* return value : 
				* Cost  :                                                                     
				*                                                                            
				******************************************************************************/
				
				void    SystemBuild__CreateMailBoxes(void)  
				{
				/*---------------------------------------------------------**
				**     Create the one item Mailbox for the Clock interrupt **
				**---------------------------------------------------------*/
				    // user code such as MailBox->ForTheClockInterrupt               = OSMboxCreate((void *)0);    /* Clock Mailbox               */
				    
					// user code such as MailBox->ForCommunicationBetweenTask4_And_5 = OSMboxCreate((void *)0); 
				}	   
				
				
				/******************************************************************************
				*                                                                            
				* function    : SystemBuild__CreateSemaphores
				* description : 
				*               Builds the necessary Semaphores                                                             
				*                                                                            
				* dependencies: 
				*  Input      : 
				*  Output     : 
				* history     :                                                              
				* return value : 
				* Cost  :                                                                     
				*                                                                            
				******************************************************************************/
				void    SystemBuild__CreateSemaphores(void)   
				{
				 // user code such as    Semaphore->ForTaskThree = OSSemCreate(1) ;
				}
				
				
				/******************************************************************************
				*                                                                            
				* function    : System__KERNEL__Build
				* description : 
				*                                                                            
				*               Initializes the KERNEL with the resources
				*               that are needed.
				*                                                                            
				* dependencies: 
				*  Input      : 
				*  Output     : 
				* history     :                                                              
				* return value : 
				* Cost  :                                                                     
				*                                                                            
				******************************************************************************/
				    
				/**----------------------------
				**                            **
				**    S Y S T E M   B U I L D **
				**                            **
				**----------------------------*/
				void    System__KERNEL__Build(void) 
				{
				/*---------------------------**
				**     Initialize the KERNEL **
				**---------------------------*/
				
				    OSInit();
				    
				
				    Semaphore = &KERNEL.Semaphore ;
				    MailBox   = &KERNEL.MailBox   ;
				    Queue     = &KERNEL.Queue     ;
				    
				    
				   SystemBuild__CreateQueues()     ;  
				   SystemBuild__CreateMailBoxes()  ;  
				   SystemBuild__CreateSemaphores() ;  
				   
				/*--------------------------------------------**
				**           Declare System Tasks (processes) **
				**--------------------------------------------*/
				//user code to create task such as
				//create one
				/*****************************************
				   KERNEL.Stack.ForClock.StackBuffer = &ClockTaskStack[0] ;
				   
				   OSTaskCreate(ClockTask,               
				                       (void *)NO_DATA_POINTER,   
				                       (void *)&KERNEL.Stack.ForClock.StackBuffer[CLOCK_TASK_STACK_SIZE-1], 
				                       CLOCK_TASK_PRIORITY); 
				*******************************************/  
				//create two
				/******************************************
				   KERNEL.Stack.ForSystemSupervisor.StackBuffer = &ForSystemSupervisorStack [0];
				
				   OSTaskCreate(SystemSupervisor, 
				                       (void *)NO_DATA_POINTER, 
				                       (void *) &KERNEL.Stack.ForSystemSupervisor.StackBuffer[SYSTEM_SUPERVISOR_TASK_STACK_SIZE-1], 
				                      SYSTEM_SUPERVISOR_PRIORITY);
				*******************************************/
				//create three   
				    
				    
				}
				
				
				
				/******************************************************************************
				*                                                                            
				* function    : main
				* description : 
				*               System start after the initial assembly code
				*               that sets the first stack.
				*               The system build processes are called in sequence                                                             
				*               and the KERNEL is started.                                                             
				*               The Stack is only used before the KERNEL is started and
				*               is never again used.                                                            
				*               The OSStart never returns here
				*                                                                            
				* dependencies: 
				*  Input      : 
				*  Output     : 
				* history     :                                                              
				* return value : 
				* Cost  :                                                                     
				*                                                                            
				******************************************************************************/
				
				void main(void)             
				{
				    CPU_Register_Initialisation(); // In OS_CPU_A.asmfiles//
				    							   // Initialise the processors registers with the define value
				    //begin user for initilation code such as  dma_reset(  )and so on
				    //USER CODE 
				    //end user code for initilation
				
				    System__Hardware__Initialisation() ;//the main idea of this function is 
				    									//to initalate the sys timertick 
				    System__KERNEL__Build( ) ;
				     
				/*-----------------------**
				**      S Y S T E M      **
				**      S T A R T        **
				**   Start the KERNEL    **
				**   The system will     **
				**   not return to       **
				**   this function       **
				**   again               **
				**-----------------------*/
				    OSStart();////excute the OSStartHighRdy() in this function                                             /* Start multitasking                       */
				}
				
				
				
				
				
				
							

相关资源