void kernel_footprint(void)
{
	init();

	// generate code for process
	struct Process *p =
		proc_new(proc1_main, 0, sizeof(proc1_stack), proc1_stack);
	proc_setPri(p, 5);
	proc_yield();

	// generate code for msg
	Msg msg;
	msg_initPort(&in_port, event_createSignal(p, SIG_USER1));
	msg_put(&in_port, &msg);
	msg_peek(&in_port);
	Msg *msg_re = msg_get(&in_port);
	msg_reply(msg_re);

	// generate code for signals
	sig_send(p, SIG_USER0);

	// generate code for msg
	Semaphore sem;
	sem_init(&sem);
	sem_obtain(&sem);
	sem_release(&sem);

	sig_wait(SIG_USER0);
}
Beispiel #2
0
void NORETURN context_switch(void)
{
	IRQ_ENABLE;
	timer_init();
	proc_init();

	#if CONFIG_USE_HP_TIMER
		ser_init(&out, CONFIG_CTX_DEBUG_PORT);
		ser_setbaudrate(&out, CONFIG_CTX_DEBUG_BAUDRATE);
	#endif

	#if CONFIG_USE_LED
		LED_INIT();
	#endif

	proc_forbid();
	hp_proc = proc_new(hp_process, NULL, PROC_STACK_SIZE, hp_stack);
	lp_proc = proc_new(lp_process, NULL, PROC_STACK_SIZE, lp_stack);
	main_proc = proc_current();
	proc_setPri(hp_proc, 2);
	proc_setPri(lp_proc, 1);
	proc_permit();

	while (1)
	{
		timer_delay(100);

		sig_send(lp_proc, SIG_USER0);
		sig_wait(SIG_USER0);

		#if CONFIG_USE_HP_TIMER
			kfile_printf(&out.fd,
				"Switch: %lu.%lu usec\n\r",
				hptime_to_us((end - start)),
				hptime_to_us((end - start) * 1000) % 1000);
		#endif
	}
}
Beispiel #3
0
int main(void)
{
	IRQ_ENABLE;

	kdbg_init();
	LED_INIT();
	timer_init();
	proc_init();

	spi_dma_init(&spi);
	spi_dma_setclock(LCD_SPICLOCK);
	lcd_ili9225_init(&spi.fd);
	LCD_BACKLIGHT_INIT();
	lcd_setBacklight(lcd_brightness);

	gfx_bitmapInit(&lcd_bitmap, raster, LCD_WIDTH, LCD_HEIGHT);
	gfx_setFont(&lcd_bitmap, &font_luBS14);
	lcd_ili9225_blitBitmap(&lcd_bitmap);

	kbd_init();

	hp_proc = proc_new(hp_process, NULL, PROC_STACK_SIZE, hp_stack);
	lp_proc = proc_new(lp_process, NULL, PROC_STACK_SIZE, lp_stack);
	led_proc = proc_new(led_process, NULL, PROC_STACK_SIZE, led_stack);

	proc_setPri(hp_proc, 2);
	proc_setPri(lp_proc, 1);

	lcd_ili9225_blitBitmap24(0, 50, BMP_LOGO_WIDTH, BMP_LOGO_HEIGHT, bmp_logo);
	timer_delay(3000);

	while (1)
	{
		menu_handle(&main_menu);
		cpu_relax();
	}
}