Beispiel #1
0
void kmain(multiboot_info_t* mbd, unsigned int magic ) {
    if ( magic != 0x2BADB002 ) {
        // TODO: Hacer un kputs.
        kprint ( "Warning: No se inicializo con GRUB, intentando de todas formas.\n" );
    }

    //Primero tenemos que corregir mbd para que sea una direccion virtual valida
    mbd = (multiboot_info_t*)( PA2KVA( (uint32_t) mbd) );

    //Ahora si, usando mbd que apunta bien a los datos del grub, inicializamos todo
    kinit( mbd );

    kprint("llego\n");
    key_init();

    //Aca asigna Esc a la funcion menu
    key_register(menu, 1);
    //Seteo Fs
    key_register(mostrar_slot,59);
    key_register(mostrar_slot,60);
    key_register(mostrar_slot,61);
    key_register(mostrar_slot,62);
    key_register(mostrar_slot,63);
    key_register(mostrar_slot,64);
    key_register(mostrar_slot,65);
    key_register(mostrar_slot,66);
    key_register(mostrar_slot,67);




    kprint("binding keys done\n");
    if(tty_init(&tty_kernel, menu_in)) {
        panic("fallo  el inicio de las tty");
    }
    //Lanzamos programa para cargar tareas y modificar quantums.
    set_isr_handler( 14, &pf ); // #PF

    // El idle task... siempre listo... :-)
    programs_t idle;
    idle.va_entry = idletask;
    crear_kthread( &idle, 10 );

    //Iniciamos Scheduler
    iniciar_scheduler();

    extern unsigned char ej1[];
    extern unsigned char ej2[];
    extern unsigned char ej3[];
    extern unsigned char ej4[];
    programas[0] = (programs_t *) ej1;
    programas[1]= (programs_t *) ej2;
    programas[2] = (programs_t *) ej3;
    programas[3]= (programs_t *) ej4;
    programas[4]= (programs_t *) ej1;

    set_irq_handler( 0, &timer );
    set_irq_handler( 1, &irq_keyboard );
    menu(1);
    sti();
    //Lanzamos programa menu
    while(1);
}
Beispiel #2
0
asmlinkage void __init start_kernel(void)
{
	char * command_line;
	extern struct kernel_param __start___param[], __stop___param[];

	smp_setup_processor_id();

	/*
	 * Need to run as early as possible, to initialize the
	 * lockdep hash:
	 */
	lockdep_init();
	debug_objects_early_init();

	/*
	 * Set up the the initial canary ASAP:
	 */
	boot_init_stack_canary();

	cgroup_init_early();

	local_irq_disable();
	early_boot_irqs_off();
	early_init_irq_lock_class();

/*
 * Interrupts are still disabled. Do necessary setups, then
 * enable them
 */
	lock_kernel();
	tick_init();
	boot_cpu_init();
	page_address_init();
	printk(KERN_NOTICE "%s", linux_banner);
	setup_arch(&command_line);
	mm_init_owner(&init_mm, &init_task);
	setup_command_line(command_line);
	setup_nr_cpu_ids();
	setup_per_cpu_areas();
	smp_prepare_boot_cpu();	/* arch-specific boot-cpu hooks */

	build_all_zonelists();
	page_alloc_init();

	printk(KERN_NOTICE "Kernel command line: %s\n", boot_command_line);
	parse_early_param();
	parse_args("Booting kernel", static_command_line, __start___param,
		   __stop___param - __start___param,
		   &unknown_bootoption);
	/*
	 * These use large bootmem allocations and must precede
	 * kmem_cache_init()
	 */
	pidhash_init();
	vfs_caches_init_early();
	sort_main_extable();
	trap_init();
	mm_init();
	/*
	 * Set up the scheduler prior starting any interrupts (such as the
	 * timer interrupt). Full topology setup happens at smp_init()
	 * time - but meanwhile we still have a functioning scheduler.
	 */
	sched_init();
	/*
	 * Disable preemption - early bootup scheduling is extremely
	 * fragile until we cpu_idle() for the first time.
	 */
	preempt_disable();
	if (!irqs_disabled()) {
		printk(KERN_WARNING "start_kernel(): bug: interrupts were "
				"enabled *very* early, fixing it\n");
		local_irq_disable();
	}
	rcu_init();
	radix_tree_init();
	/* init some links before init_ISA_irqs() */
	early_irq_init();
	init_IRQ();
	prio_tree_init();
	init_timers();
	hrtimers_init();
	softirq_init();
	timekeeping_init();
	time_init();
	profile_init();
	if (!irqs_disabled())
		printk(KERN_CRIT "start_kernel(): bug: interrupts were "
				 "enabled early\n");
	early_boot_irqs_on();
	local_irq_enable();

	/* Interrupts are enabled now so all GFP allocations are safe. */
	gfp_allowed_mask = __GFP_BITS_MASK;

	kmem_cache_init_late();

	/*
	 * HACK ALERT! This is early. We're enabling the console before
	 * we've done PCI setups etc, and console_init() must be aware of
	 * this. But we do want output early, in case something goes wrong.
	 */
	console_init();
	if (panic_later)
		panic(panic_later, panic_param);

	lockdep_info();

	/*
	 * Need to run this when irqs are enabled, because it wants
	 * to self-test [hard/soft]-irqs on/off lock inversion bugs
	 * too:
	 */
	locking_selftest();

#ifdef CONFIG_BLK_DEV_INITRD
	if (initrd_start && !initrd_below_start_ok &&
	    page_to_pfn(virt_to_page((void *)initrd_start)) < min_low_pfn) {
		printk(KERN_CRIT "initrd overwritten (0x%08lx < 0x%08lx) - "
		    "disabling it.\n",
		    page_to_pfn(virt_to_page((void *)initrd_start)),
		    min_low_pfn);
		initrd_start = 0;
	}
#endif
	page_cgroup_init();
	enable_debug_pagealloc();
	kmemtrace_init();
	kmemleak_init();
	debug_objects_mem_init();
	idr_init_cache();
	setup_per_cpu_pageset();
	numa_policy_init();
	if (late_time_init)
		late_time_init();
	sched_clock_init();
	calibrate_delay();
	pidmap_init();
	anon_vma_init();
#ifdef CONFIG_X86
	if (efi_enabled)
		efi_enter_virtual_mode();
#endif
	thread_info_cache_init();
	cred_init();
	fork_init(totalram_pages);
	proc_caches_init();
	buffer_init();
	key_init();
	security_init();
	vfs_caches_init(totalram_pages);
	signals_init();
	/* rootfs populating might need page-writeback */
	page_writeback_init();
#ifdef CONFIG_PROC_FS
	proc_root_init();
#endif
	cgroup_init();
	cpuset_init();
	taskstats_init_early();
	delayacct_init();

	check_bugs();

	acpi_early_init(); /* before LAPIC and SMP init */
	sfi_init_late();

	ftrace_init();

	/* Do the rest non-__init'ed, we're now alive */
	rest_init();
}
Beispiel #3
0
int main(void)
{
  unsigned int score, high_score;
  char score_s[MAXDIGITNUM+1];

  ROMEMU();
  USE_UI();
  timer_pri_set(0,1);
  random_init();
  lcd_init();
  key_init();
  timer_init();
  sound_init();
  timer_set(1,100);
  timer_start(1);
  ENINT();

  lcd_cursor(0,0);
  lcd_printstr(" 0:Game Start   ");
  lcd_cursor(0,1);
  lcd_printstr(" *:High Score   ");
  high_score = 0;

  lcd_cursor(0,0);

  while(1)
  {
    if (key_check(10) == KEYON){     /* *キー:ハイスコア表示 */
      lcd_cursor(0,0);                   /* LCD にハイスコア表示 */
      lcd_printstr(" High Score is  ");
      lcd_cursor(0,1);
      lcd_printstr("                ");
      lcd_cursor(0,1);
      lcd_printstr(ntos(high_score,score_s));
    }
    if (key_check(10) == KEYOFF){
      lcd_cursor(0,0);
      lcd_printstr(" 0:Game Start   ");
      lcd_cursor(0,1);
      lcd_printstr(" *:High Score   ");
    }
    if (key_check(11) == KEYON){      /* 0キー:ゲームスタート */
	  zanki = 5;
      lcd_cursor(0,0);                   /* LCD に操作方法表示 */
      lcd_printstr("*:Sight  0:Trig.");
      score = game_start();              /* ゲームスタート */
      lcd_cursor(0,1);                   /* 得点表示欄のクリア */
      lcd_printstr("                ");
      if (score > high_score){           /* ハイスコアのとき */
        high_score = score;                /* ハイスコア登録 */
        lcd_cursor(0,0);                   /* ハイスコア表示 */
        lcd_printstr(" High Score !!! ");
        lcd_cursor(0,1);
        lcd_printstr(ntos(high_score,score_s));
      } else {                           /* ハイスコアでないとき*/
        lcd_cursor(0,0);                   /* スコアを表示 */
        lcd_printstr(" Your Score ... ");
        lcd_cursor(0,1);
        lcd_printstr(ntos(score,score_s));
      }
      n_time = 0;
      while (n_time < WAITFEWSEC);       /* 得点表示後にちょっと待つ */
      lcd_cursor(0,0);                     /* LCD にメッセージ表示 */
      lcd_printstr(" 0:Game Start   ");
      lcd_cursor(0,1);
      lcd_printstr(" *:High Score   ");
    }
  }
}
Beispiel #4
0
/******************************************************************************
 * FunctionName : user_init
 * Description  : entry of user application, init user function here
 * Parameters   : none
 * Returns	    : none
 *******************************************************************************/
void ICACHE_FLASH_ATTR user_init(void) {
    system_init_done_cb(user_init_done);

    // UART Devices
#if MOD_RFID_ENABLE
    mod_rfid_init();
#endif
#if MOD_FINGER_ENABLE
    mod_finger_init();
#endif
#if MOD_EMTR_ENABLE
    mod_emtr_init();
#endif
    devices_init();

    debug("\n\nSDK version: %s\n", system_get_sdk_version());
    debug("Firmware: %s\n", config_firmware_bin());
    memory_info();

    user_config_init();
    user_config_load();
#if SSL_ENABLE
    user_config_load_private_key();
    user_config_load_certificate();
#endif

    user_events_init();

    // Scan
    webserver_register_handler_callback(DEVICES_URL,   devices_handler);
    webserver_register_handler_callback(WIFI_SCAN_URL, wifi_scan_handler);

    // Native Devices
#if BUTTON_ENABLE
    user_button_init();
#endif
#if RELAY_ENABLE
    user_relay_init();
#endif
#if ADC_ENABLE
    user_adc_init();
#endif
#if BATTERY_ENABLE
    user_battery_init();
#endif

    // I2C Devices
    i2c_master_gpio_init();
#if MOD_RGB_ENABLE
    mod_rgb_init();
#endif
#if MOD_TC_MK2_ENABLE
    mod_tc_mk2_init();
#endif
#if MOD_IO2_ENABLE
    mod_io2_init();
#endif
#if MOD_IRDA_ENABLE
    mod_irda_init();
#endif

    // SPI Devices
#if MOD_LED_8x8_RGB_ENABLE
    mod_led_8x8_rgb_init();
#endif

    key_init();
    webserver_init();
}
Beispiel #5
0
/***********************************主函数**************************************/
void  main(void)
{
    for(i = 0; i < 110; i++)   //装载摄像头边线初值
    {
        slope.left_initial_value[i] = left_initial[i];
        slope.right_initial_value[i] = right_initial[i];
    }
    camera_init(imgbuff);						//初始化摄像头
    //配置中断服务函数
    set_vector_handler(PORTA_VECTORn , PORTA_IRQHandler);   //设置LPTMR的中断服务函数为 PORTA_IRQHandler
    set_vector_handler(DMA0_VECTORn , DMA0_IRQHandler);     //设置LPTMR的中断服务函数为 PORTA_IRQHandler

    set_vector_handler(PORTE_VECTORn ,PORTE_IRQHandler);    //设置PORTE的中断服务函数为 PORTE_IRQHandler
    enable_irq (PORTE_IRQn);                                //使能PORTE中断

    port_init(PTE2, ALT1 | PULLUP );     //5  蓝牙同时发车
    if(!gpio_get (PTE2))   //蓝牙通讯同时发车
    {
        key_init(KEY_A);
        OLED_Init();
        while(1)
        {
            #if ( CAR_NUMBER == 2 )
                OLED_P6x8Str(0, 6, "Press K6 to start!");
                if(key_check(KEY_A) == KEY_DOWN)   //按K3发车
                {
                    uart_putchar(VCAN_PORT, ch);
                    OLED_P6x8Str(0, 6, "                  ");
                    bluetooth = 1;
                    break;
                }
            #endif
            #if ( CAR_NUMBER == 1 )
                OLED_P6x8Str(0, 6, "Start 2B to start!");
                while(uart_query (VCAN_PORT) == 0);
                OLED_P6x8Str(0, 6, "                  ");
                bluetooth = 1;
                break;
            #endif
        }
    }
    else
    {
        bluetooth = 2;
    }

    mk60int();
	init_PID();

    while(1)
    {
        oled_display();
        camera_get_img();						//摄像头获取图像
        img_extract(img, imgbuff, CAMERA_SIZE);	//解压图像
        get_slope(img, &slope); //获取斜率
        boundary_detection();//扫描图像获取边界
        picture_analysis();//获取中线
        //SetMotorVoltage(0.2,0.2);
        if(!gpio_get (PTE1))
        {
           vcan_sendimg(imgbuff,CAMERA_SIZE);//摄像头看图像
        }

        if(!gpio_get (PTE2))   //蓝牙同时发车
        {
            #if ( CAR_NUMBER == 1 )
                if(uart_querychar (VCAN_PORT, &ch) != 0)
                {
                    if(ch == 's')
                    {
                        stop_done = 1;
                    }
                }
            #endif
            #if ( CAR_NUMBER == 2 )
                if(stop_done)
                {
                    lptmr_delay_ms(500);    //延时确保后车过线
                    while(1)
                    {
                        uart_putchar(VCAN_PORT, ch_stop);
                    }
                }
            #endif
        }

        if(!gpio_get (PTE3))   //速度40
        {
            vPID.Setpoint = 40;
        }
        if(!gpio_get (PTE4))  //速度45
        {
            vPID.Setpoint = 45;
        }
        if(!gpio_get (PTE5))   //速度50
        {
            vPID.Setpoint = 50;
        }
        if(!gpio_get (PTE6))   //速度47
        {
            vPID.Setpoint = 46;
        }
        if(!gpio_get (PTE7))   //速度48
        {
            vPID.Setpoint = 47;
        }
        if(!gpio_get (PTE8))   //速度49
        {
            vPID.Setpoint = 48;
        }
        //ware1[0]=xielv;
        //vcan_sendware(ware1, sizeof(xielv));
        /*
        Display_number(36, 6, ttt);
        Display_number(0, 6, sss);
        printf("%d,", left_diuxian1);
        printf("%d\n",tt-t);
        */
        //printf("%d\n",speed1);

        //printf("%d,",left_diuxian1);

        //printf("%d\n",slope3);

        //printf("%d,",left_chazi);
        //printf("%d\n",right_chazi);
        //printf("%d,",m);
        //printf("%d\n",a);
        // if(!gpio_get (PTE8))
        // {
        //     for(l=0;l<120;l++)
        //     {
        //         printf("%d,",left_bianjie[l]);
        //     }
        //     printf("\n");
        // }
   }
}
Beispiel #6
0
static int
curses_init(const struct sessmgr_sw *sm)
{
    extern int Numrows, Numcols;

    if (!isatty(0))
	return 0;
    if (initted)
    {
#ifdef RAW_SESSMGR
	set_curterm(my_term);
#endif
	refresh();		/* bring curses back to life */
    }
    else
    {
	initscr();			/* be nice to trap errors... */
#ifdef COLOR_SUPPORT
	/*
	 * I assume the curses manpage tells the truth when it claims that
	 * colors are initialized to RGB defaults.  If not, I may need to set
	 * up the colors in question...
	 */
	if (has_colors() && start_color() != ERR && COLORS >= 8)
	{
	    color_pair_map = mallocw(COLOR_PAIRS * sizeof *color_pair_map);
	    memset(color_pair_map, -1, COLOR_PAIRS * sizeof *color_pair_map);
	    map_colors(COLOR_BLACK, COLOR_WHITE); /* default color pair */
            if(!MainColors) MainColors = LIGHTGRAY+(BLACK<<4); /* not high-intensity */
	}
        else MainColors = 0;  /* no colors available */
#endif
	my_term = cur_term;
	noecho();
	nonl();
	raw();
	keys = key_init();
	key_add(key_down, DNARROW);
	key_add(key_f1, -3);
	key_add(key_f2, -4);
	key_add(key_f3, -5);
	key_add(key_f4, -6);
	key_add(key_f5, -7);
	key_add(key_f6, -8);
	key_add(key_f7, -9);
	key_add(key_f8, -10);
	key_add(key_f9, -11);
#ifdef M_UNIX
	/* SCO botches it, as per usual */
	key_add(key_f0, -2);
#else
	key_add(key_f10, -2);
#endif
	key_add(key_left, LTARROW);
	key_add(key_right, RTARROW);
	key_add(key_up, UPARROW);
	key_add("\177", '\b');	/* so DEL behaves as BS */
	initted = 1;
    }
    Suspense = 0;
    Numrows = LINES;
    Numcols = COLS;
    return 1;
}
Beispiel #7
0
asmlinkage void __init start_kernel(void)
{
	char * command_line;

/*
 * Interrupts are still disabled. Do necessary setups, then
 * enable them
 */
	lock_kernel();
	page_address_init();
	printk(KERN_NOTICE);
	printk(linux_banner);
	setup_arch(&command_line);
	setup_per_cpu_areas();

	/*
	 * Mark the boot cpu "online" so that it can call console drivers in
	 * printk() and can access its per-cpu storage.
	 */
	smp_prepare_boot_cpu();

	/*
	 * Set up the scheduler prior starting any interrupts (such as the
	 * timer interrupt). Full topology setup happens at smp_init()
	 * time - but meanwhile we still have a functioning scheduler.
	 */
	sched_init();
	/*
	 * Disable preemption - early bootup scheduling is extremely
	 * fragile until we cpu_idle() for the first time.
	 */
	preempt_disable();
	build_all_zonelists();
	page_alloc_init();
	printk(KERN_NOTICE "Kernel command line: %s\n", saved_command_line);
	parse_early_param();
	parse_args("Booting kernel", command_line, __kernel_param_list_ptr,
		   kparam_list_count(),
		   &unknown_bootoption);
	sort_main_extable();
#ifdef CONFIG_LTT
	ltt_init();
#endif //CONFIG_LTT
	trap_init();
	rcu_init();
	init_IRQ();
	pidhash_init();
	init_timers();
	hrtimers_init();
	softirq_init();
	time_init();

	/*
	 * HACK ALERT! This is early. We're enabling the console before
	 * we've done PCI setups etc, and console_init() must be aware of
	 * this. But we do want output early, in case something goes wrong.
	 */
	console_init();
	if (panic_later)
		panic(panic_later, panic_param);
	profile_init();
	local_irq_enable();
#ifdef CONFIG_BLK_DEV_INITRD
	if (initrd_start && !initrd_below_start_ok &&
			initrd_start < min_low_pfn << PAGE_SHIFT) {
		printk(KERN_CRIT "initrd overwritten (0x%08lx < 0x%08lx) - "
		    "disabling it.\n",initrd_start,min_low_pfn << PAGE_SHIFT);
		initrd_start = 0;
	}
#endif
	vfs_caches_init_early();
	mem_init();
	kmem_cache_init();
	setup_per_cpu_pageset();
	numa_policy_init();
	if (late_time_init)
		late_time_init();
	calibrate_delay();
	pidmap_init();
	pgtable_cache_init();
	prio_tree_init();
	anon_vma_init();
#ifdef CONFIG_X86
	if (efi_enabled)
		efi_enter_virtual_mode();
#endif
	fork_init(num_physpages);
	proc_caches_init();
	buffer_init();
	unnamed_dev_init();
	key_init();
	security_init();
	vfs_caches_init(num_physpages);
	radix_tree_init();
	signals_init();
	/* rootfs populating might need page-writeback */
	page_writeback_init();
#ifdef CONFIG_PROC_FS
	proc_root_init();
#endif
	cpuset_init();

	check_bugs();

	acpi_early_init(); /* before LAPIC and SMP init */

	/* Do the rest non-__init'ed, we're now alive */
	rest_init();
}