📄 system.c
字号:
INT32U idle;
INT32U usageInPromille;
INT32U MaxusageInPromille;
INT32U ContextSwitches;
} v;
v.MaxusageInPromille = 0 ;
data = data; /* Prevent compiler warning */
OSTimeDly(10); /* Synchronize to clock tick */
OS_ENTER_CRITICAL();
OSIdleCtr = 0L; /* Determine MAX. idle counter value */
OS_EXIT_CRITICAL();
OSTimeDly(1000); /* Wait 1 one second */
v.max = OSIdleCtr; /* Get max number of iterations during one second */
OS_EXIT_CRITICAL();
SystemBuild__CreateTasks() ;
OS_ENTER_CRITICAL();
OSIdleCtr = 0L; /* Determine MAX. idle counter value */
OSCtxSwCtr = 0L;
OS_EXIT_CRITICAL();
while (1) {
OSTimeDly(1000);
OS_ENTER_CRITICAL();
v.ContextSwitches = OSCtxSwCtr;
v.idle = OSIdleCtr;
OSCtxSwCtr = 0; /* Reset statistics counters */
OSIdleCtr = 0L;
OS_EXIT_CRITICAL();
v.usageInPromille = 10*(100.0 - (100.0 * (double)v.idle / v.max)); /* Compute and display statistics */
if( v.usageInPromille > v.MaxusageInPromille) v.MaxusageInPromille = v.usageInPromille ;
}
}
/******************************************************************************
*
* 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 **
**-----------------------*/
Queue->ForMessageHandler_Input.Event =
OSQCreate( &Queue->ForMessageHandler_Input.QueueElement[0], QUEUE_MAX_SIZE );
Queue->ForMessagesToHost.Event =
OSQCreate( &Queue->ForMessagesToHost.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 **
**---------------------------------------------------------*/
MailBox->ForTheClockInterrupt = OSMboxCreate((void *)0); /* Clock Mailbox */
MailBox->ForCommunicationBetweenTask4_And_5 = OSMboxCreate((void *)0);
MailBox->ForTheHostPortInterrupt = OSMboxCreate((void *)0);
}
/******************************************************************************
*
* function : SystemBuild__CreateSemaphores
* description :
* Builds the necessary Semaphores
*
* dependencies:
* Input :
* Output :
* history :
* return value :
* Cost :
*
******************************************************************************/
void SystemBuild__CreateSemaphores(void)
{
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) **
**--------------------------------------------*/
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);
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);
}
/******************************************************************************
*
* 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 ;
C6201_Processor_Setup( );
Always_Enabled_Interrupts = 0 ;
ICR = 0 ; /* Clear all strange interrupts, if any */
Normally_Enabled_Interrupts = (1 << CPU_INT_NMI ) ;
}
/******************************************************************************
*
* 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)
{
C6201_Register_Initialisation(); /* In asmfiles*/
dma_reset( ) ;
System__Hardware__Initialisation() ;
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(); /* Start multitasking */
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -