コード例 #1
0
ファイル: timer.c プロジェクト: VladislavManoylo/course_os
void timer_test(){
	

//	enable_interrupt(ALL_INTERRUPT_MASK);

	/*interrupt_handler_t *tmr_handler = kmalloc(sizeof(interrupt_handler_t));
	tmr_handler->handler = simple_timer_handler;
	os_printf("fn ptr: %X\n", simple_timer_handler);
	register_interrupt_handler(4, tmr_handler);*/

	os_printf("FIQ status: %X\n", mmio_read(VIC_FIQ_STATUS));
	initialize_timers();
	start_timer_interrupts(0,10);
	//print_control_status(1);

	// Wait forever...
/*	os_printf("\n");
	int cnt = 0;
	os_printf("Timer: %d\n", timer_pointers[0]->timer_actual_value);
	os_printf("Timer: %d\n", timer_pointers[0]->timer_actual_value);
	os_printf("Timer: %d\n", timer_pointers[0]->timer_actual_value);
	while (!(timer_pointers[0]->masked_interrupt_status&1)) {
		cnt++;
		//os_printf("%X\n", timer_pointers[1]->timer_actual_value);
		int i;
		for (i=0; i<1000; i++);
	}
	os_printf("%d\n", cnt);
	os_printf("%X\n", mmio_read(PIC_ADDRESS+0x8));
	os_printf("%X\n", mmio_read(VIC_IRQ_STATUS));
	os_printf("%X\n", mmio_read(VIC_FIQ_STATUS));
	os_printf("Timer: %d\n", timer_pointers[0]->timer_actual_value);
	os_printf("Timer: %d\n", timer_pointers[0]->timer_actual_value);
	os_printf("Timer: %d\n", timer_pointers[0]->timer_actual_value);
	while(1);
*/
	return;
}
コード例 #2
0
ファイル: start.c プロジェクト: georgereason/CS439P4
// This start is what starts the kernel. Note that virtual memory is enabled
// at this point (And running, also, in the kernel's VAS).
void start2(uint32_t *p_bootargs)
{
	// Setup all of the exception handlers... (hrm, interaction with VM?)
	init_vector_table();

	// Setup kmalloc...
	init_heap();

	print_uart0("\nCourseOS!\n");

	// Test stuff...
	/*int *p = (int*)0xFFFFFFF0;
	 p[0] = 1;
	 os_printf("0x%x == 1?\n", p[0]);*/

	//run_vm_tests();
	//INFO("There are %d free frames.\n", vm_count_free_frames());
	//run_mem_alloc_tests();
	//INFO("There are %d free frames.\n", vm_count_free_frames());
	//run_prq_tests();
	//run_hmap_tests();

	kfs_init(0, 0, 0);


	/*
	 4-15-15: 	#Prakash: 	What happens if we let the program load here?
	 Let's make argparse_process() do its thing

	 Note: As of 4-15-15 this fails horribly with hello.o not being
	 recognized as an ELF file and DATA ABORT HANDLER being syscalled			   
	 */

	// enable interrupt handling
	enable_interrupts();

	// initialize the timers
	initialize_timers();
	
	//assert(1==2 && "Test assert please ignore");

	init_all_processes();


	// FIXME: temporary
	os_printf("Programming the timer interrupt\n");
	start_timer_interrupts(0, 5);
	sched_init();

	argparse_process(p_bootargs);

	print_uart0("done parsing atag list\n");


	//init_kheap(31 * 0x100000);
	//init_uheap(0x100000);

	//initialize pcb table and PID
	/* init_all_processes(); */
	//print_process_state(0);
	//run_process_tests();
	//print_PID();
	// init_q();
	//main();


	SLEEP;
}
コード例 #3
0
ファイル: timer.c プロジェクト: VladislavManoylo/course_os
void timer_interrupt_handler_q( void (*callback_function)(void *args),int time)
{
        function=callback_function;
        start_timer_interrupts(0,time);
}
コード例 #4
0
//General method to recalculate driver operating tables
static int process_update(void){
	int reg_size = 0;
	unsigned char is_active_pwm = FALSE;
	unsigned char is_interrupted = FALSE;
	int i  = 0;
	reset_drv_table();
	drv_timing.tm_size = 0;
	//Here we have sorted map of GPIO pins;
	//Lets build driver table;
	//Building task tables;
	//Initial Element
	for (i = 0; i < MAX_PWM_NUMBER; i++){
		if (pwmpins_pool[i].duty !=0 && pwmpins_pool[i].duty != 0xff && pwmpins_pool[i].pin != 0xff){
			is_active_pwm = TRUE;
		}
		if (pwmpins_pool[i].duty == 0){
		    if (pwmpins_pool[i].pin != 0xFF) gpio_reset_task(drv_queue[0], pwmpins_pool[i].pin);
		} else {
		    if (pwmpins_pool[i].pin != 0xFF) gpio_set_task(drv_queue[0], pwmpins_pool[i].pin);
		}
		dbg_print("pool[%d]={%x,%x}\r\n", i, pwmpins_pool[i].pin, pwmpins_pool[i].duty);
	}
	reg_size = 0;
	//the rest of elements
	for (i = 0; i < MAX_PWM_NUMBER - 1; i++){
		if (pwmpins_pool[i].pin != 0xFF) gpio_reset_task(drv_queue[drv_timing.tm_size + 1], pwmpins_pool[i].pin);
		if (pwmpins_pool[i].duty != pwmpins_pool[i + 1].duty){
			//drv_timing.time[drv_timing.tm_size++] = (pwmpins_pool[i].duty*TIMER_FREQ*swpwm_period)/255;
			drv_timing.time[drv_timing.tm_size++] = TIMER_FREQ*(PPM_MIN/1000) + (TIMER_FREQ*((PPM_MAX - PPM_MIN)/1000)*pwmpins_pool[i].duty)/255;
			reg_size = 0;
			if (pwmpins_pool[i + 1].duty == 0xff){ i++;  is_interrupted = TRUE; break;}
		}
	}
	if (pwmpins_pool[i].pin != 0xFF){
		gpio_reset_task(drv_queue[drv_timing.tm_size + 1], pwmpins_pool[i].pin);
		if (!is_interrupted) {
		    //drv_timing.time[drv_timing.tm_size++] = (pwmpins_pool[i].duty*TIMER_FREQ*swpwm_period)/255;
		    //drv_timing.time[drv_timing.tm_size++] = (unsigned long) TIMER_FREQ*PPM_MIN + (TIMER_FREQ*(PPM_MAX - PPM_MIN)*pwmpins_pool[i].duty)/255;
		    drv_timing.time[drv_timing.tm_size++] = TIMER_FREQ*(PPM_MIN/1000) + (TIMER_FREQ*((PPM_MAX - PPM_MIN)/1000)*pwmpins_pool[i].duty)/255;

		}
	}
	drv_timing.time[drv_timing.tm_size++] = TIMER_FREQ*swpwm_period;
	//Here we have drv_timing and drv_queue valid values and these values may be copied
	//One more pass to get deltas of time
	for (i = drv_timing.tm_size - 1; i >= 1; i--){
		drv_timing.time[i] = drv_timing.time[i] - drv_timing.time[i-1];
	}
	g_UpdateFlag = TRUE;
	for (i = 0; i < drv_timing.tm_size; i++){
		int j = 0;
		REG_VAL* regs = drv_queue[i];
		//dbg_print("-->> drv_timing[%d]=%.8d----------------------------------------\r\n", i, drv_timing.time[i]);
		while(regs[j].reg != 0){
			//dbg_print("    %s reg=%x val=%x\r\n", regs[j].set ? "set" : "reset", regs[j].reg, regs[j].val);
			j++;
		}
		//dbg_print("-----------------------------------------------------------------\r\n");
	}
	if (is_active_pwm && !g_IsActivePWM){//There were no interrupts and now we get it
		g_IsActivePWM = is_active_pwm;
		start_timer_interrupts();
	}
	if (g_IsActivePWM && !is_active_pwm){//There were interrupts but after update we do not need it any more
		g_IsActivePWM = is_active_pwm;
		stop_timer_interrupts();
	}
	if (!g_IsActivePWM && !is_active_pwm){//Stub to initialize GPIO when interrupts are not enabled
		stop_timer_interrupts();
	}
	return SWPWM_OK;
}