/*Begin Function:main********************************************************** Description : The Entrance Of The OS.Must Be Set Here. Input : Void. Output : int-dummy. ******************************************************************************/ int main(void) //The main function will only be run ONCE. { //_Sys_Memory_Init(APP_AVAIL_MEM_START,APP_AVAIL_MEM_END); //Not 0x20005000,Or It Will Cause A Implicit Hard Fault. _Sys_Kernel_Load(0x20004F50); //The Timeslice Is Dummy.The Init Process Use A Different Way of Context Switching. _Sys_Proc_Load(_Sys_Arch,0x20004E00,1,2,(u8*)"Arch"); //The Arch Process,Which Does Some Chores.Its PID is 1,forever. _Sys_Proc_Load(Task1,0x20004C00,2,2,(u8*)"Main_GUI"); //The GUI Process,Normally. _Sys_Proc_Load(Task2,0x20004A00,3,2,(u8*)"Driver_1"); //The Driver Process 1,Normally. //_Sys_Proc_Load(Task3,0x20003900,4,2,(u8*)"Driver_2"); //The Driver Process 2,Normally. _Sys_Systick_Init(0x00010000); //Initialize The System Clock. _Sys_Start(); //Start From The First PID. while(1); //Dead Loop. //return(0); //Unreachable Statement.Commented Out. }
/*Begin Function:_Sys_Scheduler_Init******************************************* Description : The system scheduler initialization function. Input : None. Output : None. Return : None. ******************************************************************************/ void _Sys_Scheduler_Init(void) { cnt_t Count; /* Systemis still booting */ System_Status.Kernel.Boot_Done=FALSE; /* Clear the statistic variable for the kernel */ Sys_Memset((ptr_int_t)(&System_Status),0,sizeof(struct Sys_Status_Struct)); /* Initialize the system clock.*/ _Sys_Systick_Init(MIN_TIMESLICE_TICK); /* Initialize the priority list. We do this to facilitate bidirectional search. * We can get the pointer to this priority level when we have the priority level * number, and vice versa. */ for(Count=0;Count<MAX_PRIO_NUM;Count++) { Prio_List[Count].Priority=Count; Prio_List[Count].Proc_Num=0; Sys_Create_List((struct List_Head*)&(Prio_List[Count].Running_List)); } Sys_Create_List((struct List_Head*)(&Prio_List_Head)); /* Initialize the list for each possible task slot */ for(Count=0;Count<MAX_PROC_NUM;Count++) { PCB[Count].Status.Sleep_Count=1; PCB[Count].Status.Status_Lock_Count=0; Sys_Create_List((struct List_Head*)(&(PCB[Count].Head))); } /* Clear the pending system scheduling count */ Pend_Sched_Cnt=0; }