Exemple #1
0
bool        initialize_system(void)
{
    if (!initialize_ports()      ||
        !initialize_devices()    ||
        !initialize_interrupts() ||
        !initialize_timers()     ||
        !initialize_menu_tree())
        return (false);
    return (true);
}
Exemple #2
0
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;
}
Exemple #3
0
int main(int argc, char **argv)
{

	int status;
	struct sigaction usr_action;
	struct sigaction term_action;
	sigset_t block_mask;

	int socks_status;

	connections.last_slot = -1;
	connections.running_pid = getpid();

	status = init(argc, argv, &connections);

	if (status == INIT_FAILURE)
	{
		if (to_printhelp == 1)
			print_help(argc, argv);
		exit(EXIT_FAILURE);
	}

	if (status == INIT_SUCCESS && to_printhelp == 1)
	{
		print_help(argc, argv);
		exit(EXIT_SUCCESS);
	}

	if (to_command_mode)
	{
		status = execute_command(&connections);
		exit(status);
	}

	Log(LOG_NOTICE, "Program started by User %d \n", getuid());
	/* Daemon-specific initialization */

	if (to_demonize)
	{

		status = daemonize(&connections);
		switch (status)
		{
			case DAEMONIZE_FAILURE:
				/*something gone wrong exit from parent */
				printf("Failed to daemonize.Check permissions\n");
				exit(EXIT_FAILURE);
				break;
			case DAEMONIZE_SUCCESS:
				/*ok we are the parent, we can exit gracefully */
				Log(LOG_INFO, "Starting as a daemon.Parent exit\n");
				printf("Starting as a daemon.Parent exit\n");
				exit(EXIT_SUCCESS);
				break;
		}

	}

	/* Establish the signal handler.  */
	sigfillset(&block_mask);
	usr_action.sa_handler = sleep_signal;
	usr_action.sa_mask = block_mask;
	usr_action.sa_flags = 0;
	sigaction(SIGUSR1, &usr_action, NULL);
	term_action.sa_handler = term_signal;
	term_action.sa_mask = block_mask;
	term_action.sa_flags = 0;
	sigaction(SIGTERM, &term_action, NULL);

	Log(LOG_INFO, "Init networking\n");

	status = initialize_network(&connections);

	Log(LOG_INFO, "Init timers\n");
	status = initialize_timers(&connections);

	/* The Big Loop */
	while (1)
	{
		Log(LOG_DEBUG, "Main loop\n");
		rebuild_connection_set(&connections);
		socks_status = select(connections.max_socket + 1, &connections.socket_set, NULL, NULL, NULL);
		if (socks_status < 0)
		{
			status = errno;
			/* We had an error, signal it */
			if (status != EINTR)
			{
				Log(LOG_ERR, "Error in select socket (%s) \n", strerror(status));
				exit(EXIT_FAILURE);
			}
		}
		else
			if (socks_status == 0)
			{
				/* Nothing to do probably a staying alive msg in debug mode */
			}
			else
			{
				read_sockets(&connections);
			}
	}
	closelog();
	exit(EXIT_SUCCESS);
}
Exemple #4
0
// 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;
}
Exemple #5
0
/*
 * DANG_BEGIN_FUNCTION time_setting_init
 *
 * description:
 *  Beats me
 *
 * DANG_END_FUNCTION
 */
void time_setting_init(void)
{
  initialize_timers();
}
Exemple #6
0
// Create the handler
// register the handler the first handler of timer
void _schedule_register_timer_irq(){
        interrupt_handler_t *timer=kmalloc(sizeof(interrupt_handler_t));
        timer->handler=&timer_interrupt_handler_1;
        register_interrupt_handler(4,timer);
        initialize_timers();
}
Exemple #7
0
void main(void)
{
	GPIO_InitTypeDef  GPIO_InitStructure;
	/* GPIOD Periph clock enable */
	  RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE);

	  /* Configures the leds and the read/write pin on D1 */
	  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13| GPIO_Pin_14| GPIO_Pin_15 | GPIO_Pin_1;
	  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
	  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
	  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
	  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
	  GPIO_Init(GPIOD, &GPIO_InitStructure); 
	
	initDma();
	
	uint32_t period = initialize_timers(525000, 1);
	
	 /* GPIOD Periph clock enable */
	 RCC_AHB1PeriphClockCmd(USER_BUTTON_GPIO_CLK, ENABLE);

	 /* Configure Button in output pushpull mode */
	 GPIO_InitStructure.GPIO_Pin = USER_BUTTON_PIN;
	 GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN;
	 GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
	 GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
	 GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL;
	 GPIO_Init(USER_BUTTON_GPIO_PORT, &GPIO_InitStructure);
	
	uint8_t button = 0;
	uint8_t value = 0;
	uint8_t thousands = 0;
	while(1)
	{
		
	    TIM3->CCR1 = (period + 1) * ADC3ConvertedValue[0] / 4000 / 4.5;
		
		/*if(ADC3ConvertedValue[0] > 1000)
		{
			GPIO_SetBits(GPIOD, GPIO_Pin_13);
			TIM3->CCR1 = (period + 1) * 50.0 / 100;
		}
		else if(ADC3ConvertedValue[1] > 1000)
		{
			GPIO_SetBits(GPIOD, GPIO_Pin_14);
			TIM3->CCR2 = (period + 1) * 50.0 / 100;
		}
		else if(ADC3ConvertedValue[2] > 1000)
		{
			GPIO_SetBits(GPIOD, GPIO_Pin_15);
			TIM3->CCR3 = (period + 1) * 50.0 / 100;
		}
		else if(ADC3ConvertedValue[3] > 1000)
		{
			GPIO_SetBits(GPIOD, GPIO_Pin_12);
			TIM3->CCR4 = (period + 1) * 50.0 / 100;
		}
		else
		{
			TIM3->CCR1 = (period + 1) * 0 / 100;
			TIM3->CCR2 = (period + 1) * 0 / 100;
			TIM3->CCR3 = (period + 1) * 0 / 100;
			TIM3->CCR4 = (period + 1) * 0 / 100;
		}*/
		
		GPIO_ResetBits(GPIOD, GPIO_Pin_12);
		GPIO_ResetBits(GPIOD, GPIO_Pin_13);
		GPIO_ResetBits(GPIOD, GPIO_Pin_14);
		GPIO_ResetBits(GPIOD, GPIO_Pin_15);
			
	}
}