Пример #1
0
void user_init(void) {	
#else
void app_main(void) {	
#endif
	_sys_init();

	#if LED_ACT
    	// Init leds
		gpio_pin_output(LED_ACT);
    	gpio_pin_clr(LED_ACT);
	#endif

    pthread_attr_t attr;
    pthread_t thread;
    int res;
	
	debug_free_mem_begin(lua_main_thread);
    
	pthread_attr_init(&attr);
    pthread_attr_setstacksize(&attr, luaTaskStack);

    res = pthread_create(&thread, &attr, lua_start, NULL);
    if (res) {
		panic("Cannot start lua");
	}
	
	debug_free_mem_end(lua_main_thread, NULL);	
}
Пример #2
0
void _init( void ) {
	pcb_t *pcb;

	/*
	** BOILERPLATE CODE - taken from basic framework
	**
	** Initialize interrupt stuff.
	*/

	__init_interrupts();	// IDT and PIC initialization
	// Ignore the 0x2A interrupt which happens when removing or inserting a
	// flash drive.
	__install_isr( 0x2A,  _ignore_isr );

	/*
	** Console I/O system.
	*/

	c_io_init();
	c_clearscreen();
#ifdef ISR_DEBUGGING_CODE
	c_setscroll( 0, 7, 99, 99 );
	c_puts_at( 0, 6, "================================================================================" );
#endif

	/*
	** 20123-SPECIFIC CODE STARTS HERE
	*/

	/*
	** Initialize various OS modules
	**
	** Note:  the clock, SIO, and syscall modules also install
	** their ISRs.
	*/

	c_puts( "Module init: " );

	_q_init();		// must be first
	_pcb_init();
	_stack_init();
	_sio_init();
	_sys_init();
	_sched_init();
	_clock_init();
	_pci_init();
	_disk_init();
	_net_init();

	c_puts( "\n" );
	c_puts("Launching the shell. Please be patient\n");
	__delay(1000);
	c_clearscreen();

	/*
	** Create the initial system ESP
	**
	** This will be the address of the next-to-last
	** longword in the system stack.
	*/

	_system_esp = ((uint32_t *) ( (&_system_stack) + 1)) - 2;

	/*
	** Create the initial process
	**
	** Code mostly stolen from _sys_fork(); if that routine
	** changes, SO MUST THIS!!!
	*/

	// allocate a PCB and stack

	pcb = _create_process( NULL );
	if( pcb == NULL ) {
		_kpanic( "_init", "init() creation failed", FAILURE );
	}

	// initialize the stack with the standard context

	pcb->context = _create_stack( pcb->stack );
	if( pcb->context == NULL ) {
		_kpanic( "_init", "init() stack setup failed", FAILURE );
	}

	// define the entry point for init()

	pcb->context->eip = (uint32_t) init;

	// set up various PCB fields

	pcb->pid = pcb->ppid = PID_INIT;	// next PID is initially 1
	pcb->prio = PRIO_HIGH;
	pcb->children = 1000;

	// remember this PCB for use in reparenting orphan processes

	_init_pcb = pcb;

	// make it the first process

	_schedule( pcb );
	_dispatch();

	/*
	** Turn on the SIO receiver (the transmitter will be turned
	** on/off as characters are being sent)
	*/

	_sio_enable( SIO_RX );

	/*
	** END OF 20123-SPECIFIC CODE
	**
	** Finally, report that we're all done.
	*/

	c_puts( "System initialization complete.\n" );

}