示例#1
0
void c_entry(void)
{
	int i = 0;
	task_count = 0;
	currentTask = 0;

	/* VIC Configuration */
	VIC_INT_SELECT = 0;
	VIC_ENABLE_INT = 0x00000210;	/* Enable Timer01 Interrupt and UART0 */

	unsigned int user_stacks[TASK_LIMIT][STACK_SIZE];

	/* Task initialization */
	init_task(&task[0], user_stacks[0], &task1_func);
	task_count = task_count + 1;
	init_task(&task[1], user_stacks[1], &task2_func);
	task_count = task_count + 1;
	init_task(&task[2], user_stacks[2], &task3_func);
	task_count = task_count + 1;

	print_uart0("OS: Starting...\n");
	print_uart0("OS: Scheduler implementation : round-robin\n");

	/* Timer1 Configuration */
	TIMER01_disable();
	TIMER01_LOAD_VALUE = 65535;
	TIMER01_enable();

	activate(task[currentTask].sp);

	while (i < 5) {
		TIMER01_disable();
		print_uart0("Kernel gets back control ! \n");
		print_uart0("Kernel can do some stuff...\n");
		print_uart0("Load the next task ! \n");

		/* Scheduler */
		currentTask = currentTask + 1;
		if (currentTask >= 2)
			currentTask = 0; /* We only start the first and second task */

		TIMER01_LOAD_VALUE = 65535;
		TIMER01_enable();

		activate(task[currentTask].sp);
		TIMER01_disable();
		i++;
	}

	print_uart0("Kernel is going to activate Task #3 "
	            "which will call a syscall() to return back "
	            "to kernel mode \n");
	activate(task[2].sp);
	print_uart0("Kernel gets back control ! \n");
	print_uart0("Now, the OS is about to shutdown.");

	while (1)
		/* wait */ ;
}
示例#2
0
void c_entry() {
	
	char timerValue[32];
	int i =0;
	print_uart0("Hello world!\n");
	
	
	// VIC Configuration
	*VIC_INT_SELECT = 0; // All interrupts are IRQ
	*VIC_ENABLE_INT = 0x00000010; // Enable Timer01 Interrupt
	
	// Timer1 Configuration
	TIMER01_disable();
	TIMER01_LOAD_VALUE = 65520;
	TIMER01_enable();
	
	while(1){
		//~ //for(i=0; i<31;i++){
			//~ timerValue[0] = '0'+ (*TIMER01_CURRENT_VALUE);
			//~ print_uart0(&timerValue[0]);
		//~ //}
		//~ print_uart0("\r\n");
		
	} 
}