Esempio n. 1
0
void kmain(multiboot_info_t* mbt, unsigned int magic)
{
    if (magic != MULTIBOOT_BOOTLOADER_MAGIC)
        return;

    graphics_init();

    /* Core modules */
    gdt_init();
    idt_init();
    irq_init();
    isr_init();
    
    /* Kernel heap */
    heap_init();
    
    /* Drivers */
    timer_init();
    tasking_init();
    keyboard_init();
    
    /* Let the games begin */
    set_interrupts(ENABLED);
    
    kprintf("Running kernel tests...\n\n");
    test_kmalloc_kfree();
    test_list();
    test_tasking();
    kprintf("\nDone with kernel tests.\n");
    
    for (;;);
}
Esempio n. 2
0
File: main.c Progetto: nielh/dragon
void kmain(s64 magic, s64 info)
{
	//vga_clear(COLOR_BLACK);
    idt_init();
    isr_init();

    serial_init();
	set_debug_traps();
    BREAKPOINT();

	cpuid_print();
	multiboot(magic, info);
	kmem_map();
    page_init();
    kmalloc_init();
    //vesa_init();

    root_init();
    pci_init();
    vm_init();
    syscall_init();
    timer_init();
    kbd_init();
    //mouse_init();

    console_init();

 	create_kthread(NULL, idle_thread, THREAD_PRI_LOW, NULL, NULL);
 	create_kthread(NULL, init_thread, THREAD_PRI_NORMAL, NULL, NULL);

    thread_schedule();
}
Esempio n. 3
0
void arch_entry() { 
  paging_init();
  gdt_init();
  idt_init();
  isr_init();
  pic_init();
  pit_init();
}
Esempio n. 4
0
void idt_init()
{
    ip.limit = sizeof(idt_entry_t) * 256 - 1;
    ip.base = (uint32_t)&ient;

    memset(&ient, 0, sizeof(idt_entry_t) * 256);

    isr_init();
    irq_init();
    idt_flush((uint32_t)&ip);

    printStatusMessage("Loading IDTs...",STATUS_DONE);
}
Esempio n. 5
0
int main()
{
//Start video driver (must always be before loading message)
    mm_init();
    pg_init();
    real_init();
    video_init();
    video_setdriver(video_vgatext_getdriver(),0);

//Put loading message
    cli_puts("ArcaneOS Loading...\n");

//Setup kernel
    gdt_init();
    idt_init();
    isr_init();
    irq_init();
    timer_init();
    kb_init();
    ui_init();
    cpuid_init();
    cmos_init();
    rtc_init();
    acpi_init();
    power_init();
    mt_init();
    syscall_init();
    floppy_init();

    __asm__ __volatile__ ("sti");

//Enable ACPI
    acpi_enable();

//Create thread for ui
    mt_create_thread(mt_kernel_process,test,2);

//Endless loop to prevent bugs when all threads are sleeping
    for(;;)
        __asm__ __volatile__ ("hlt");
}
Esempio n. 6
0
// Starts system
void 
init_system(multiboot_info_t* bi)
{
	// Start display
	vga_init();
	printk(" KiteOS V1.0 --- Initializing \n");
	// PIT-less wait to show user boot
	for(int i=0;i<64821125;i++);
	vga_color(0x3, 0x0);
	printk("-- STARTING LOWLEVEL KERNEL --\n");
	vga_color(0x5, 0x0);
	printk("!* Initiating GDT\n");
	gdt_init();
	printk("!* Initiating IDT\n");
	idt_init();
	printk("!* Installing Exceptions\n");
	isr_init();
	vga_color(0x4, 0x0);
	printk("*** ENTERTED PROTECTED MODE ***\n");
	vga_color(0x5, 0x0);
	printk("!* Initiating IRQ\n");
	irq_init();
	printk("!* Starting PIT\n");
	pit_init();
	printk("!* Starting RTC\n");
	rtc_init();
	printk("!* Restoring Interrupts\n");
	__asm__ __volatile__ ("sti");
	vga_color(0x3, 0x0);	
	printk("-- STARTING LOWLEVEL DRIVERS --\n");
	vga_color(0x5, 0x0);
	printk("!* Starting physical memory manager\n");
	kalloc_init((void*)bi->mmap_addr, (unsigned long)bi->mmap_length);
	printk("!* Starting keyboard driver\n");
	kb_init();
	printk("!* Starting IDE driver\n");
	ide_init(0x1F0, 0x3F6, 0x170, 0x366);
	vga_color(0x4, 0x0);
	printk("*** Initialized system successfully ***\n");
}
Esempio n. 7
0
File: main.c Progetto: Codnect/uniq
void kmain(mboot_info_t *mboot_info,uint32_t mboot_magic,uint32_t stack_ptr){

	
	/* vga konsol */
	init_vga_console();
	time_init();

	debug_print(KERN_INFO,"Stack pointer : \033[1;7m%P",stack_ptr);

	if(mboot_magic != MULTIBOOT_LOADER_MAGIC)
		debug_print(KERN_WARNING,"Invalid the magic number. The magic number is \033[1;31m%P",mboot_magic);
	else
		debug_print(KERN_INFO,"Valid the magic number.The magic number is \033[1;37m%P",mboot_magic);
		
	/*
	 * gdt,idt,isr ve irq
	 */
	gdt_init();	/* global tanimlayici tablosu */
	idt_init();	/* kesme tanimlayici tablosu */
	isr_init();	/* kesme servis istekleri */
	irq_init();	/* donanim kesme istekleri */
#if 0
	__int_test();
#endif
	timer_init();

	/*
	 * memory
	 */
	paging_init(mboot_info->mem_lower + mboot_info->mem_upper);
	paging_final();	
#if 0
	 __page_fault_test();
#endif
	heap_init();
	multitasking_init();

}
Esempio n. 8
0
void uart_open(unsigned long baudRate)
{
    unsigned short baudRateGen;

    // The pins of the Enhanced USART are multiplexed with PORTC. In order to
    // configure RC6/TX/CK and RC7/RX/DT as an EUSART:
    TRISCbits.TRISC7 = 0b1;
    TRISCbits.TRISC6 = 0b1;

    TXSTA = 0x00;
    RCSTA = 0x00;
    BAUDCON = 0x00;

    PIE1bits.TXIE = 0b0; // desabilita interrupção de TX
    PIE1bits.RCIE = 0b0; // desabilita interrupção de RX

    TXSTAbits.TXEN = 0b1; // habilita TX
    TXSTAbits.BRGH = 0b1; // [TODO] - implementar esta opção

    RCSTAbits.CREN = 0b1; // habilita RX

    BAUDCONbits.BRG16 = 0b1; // [TODO] - implementar esta opção

    // [TODO] - implementar mais opções de baud rate
    // Baud Rate = FOSC/[4 (n + 1)]
    baudRateGen = ((FOSC/baudRate)/4) - 1;
    SPBRGH = baudRateGen / 256;
    SPBRG = baudRateGen % 256;

    //PIE1bits.TXIE = 0b1; // habilita interrupção de TX
    //PIE1bits.RCIE = 0b1; // habilita interrupção de RX

    RCSTAbits.SPEN = 0b1; // habilita porta serial (pinos em modo TX e RX)

    isr_init();
}
Esempio n. 9
0
int main(int argc, char **argv)
{
    // Initialize TIC
    isr_init();
    tic_init();
    irq_set_mask(0x000FFFFF);
    //irq_enable();

    // Initialize I2C Core
    i2c_core_init(0x00, 0xC7);
    //MPU6050_Initialize();

    for(;;)
    {
        i2c_write_register(MPU6050_DEFAULT_ADDRESS, MPU6050_RA_WHO_AM_I, 0x00);
    }

    //i2c_test();
    //spi_test();
    //gpio_test();
    //uart_test();
    //timer_test();

}
Esempio n. 10
0
File: idt.c Progetto: jmtoba/Gaia
void idt_init(void)
{
    idt_ptr.limit = sizeof(idt_entry_t) * 256 -1;
    idt_ptr.base  = (u32int)&idt_entries;

    // Remap the irq table.
	outb(0x20, 0x11);
	outb(0xA0, 0x11);
	outb(0x21, 0x20);
	outb(0xA1, 0x28);
	outb(0x21, 0x04);
	outb(0xA1, 0x02);
	outb(0x21, 0x01);
	outb(0xA1, 0x01);
	outb(0x21, 0x0);
	outb(0xA1, 0x0);

    memset((u8int*)&idt_entries, 0, sizeof(idt_entry_t)*256);

    isr_init();	// Interruptions - entries  0-31
    irq_init();	// IRQs          - entries 32-47

    idt_flush((u32int)&idt_ptr);
}
Esempio n. 11
0
// Initialise board
void board_init (void) {

	#ifndef SIMULATE
    io_init(); // Init GPIOs
    uart_init(BAUD_RATE);
    stderr = &uartio;
    printf(str_boot_uart,BAUD_RATE);
    printf(str_boot_start);
	#else
	printf("Skipping UART initialization...\n");
	#endif
	#ifndef SIMULATE
    digital_init();
	#endif
    encoder_init();
	#ifndef SIMULATE
    spi_init();
    motor_init();
    servo_init();
#ifdef LCD_DEBUG
    lcd_init(); //consider wrapping this in an #ifdef LCD_DEBUG tag?
    stdout = &lcdout;
#else
    stdout = &uartio;
    stdin = &uartio;
#endif
    adc_init();
    isr_init();
    memory_init();
	#endif

    // load config, or fail if invalid
    if (!board_load_config())
        board_fail("Bad Config");
    printf(str_boot_conf);
    printf(str_boot_board,
            board_config.version>>8,
            board_config.version&0xFF);
    printf(str_boot_id, board_config.id);

    // print boot text to screen
    printf(str_boot_message, board_config.version>>8, board_config.version&0xFF);

    // check battery, fail if <7.5V
    printf(str_boot_batt,read_battery());
#ifdef CHECK_BATTERY
    if (!(read_battery()>=7200)) {
        // NOTE: in the current 2-battery version of the HappyBoard, the 
        // battery voltage is the motor battery (P+).  Holding GO overrides
        // the check so you can run the HappyBoard without a motor battery.
        if (go_press())
            printf("WARNING: LOW BATTERY\n");
        else 
            board_fail("Low battery");
    } else {
        printf("Battery OK\n");
    }
#endif

	#ifndef SIMULATE
    // initialise FPGA
    if (!fpga_init(FPGA_CONFIG_ADDRESS, board_config.fpga_len))
        board_fail("FPGA failure");
    printf(str_boot_fpga, fpga_get_version_major(), fpga_get_version_minor());
	#else
	printf("Skipping FPGA initialization...\n");
	#endif

    // all ok
#ifndef SIMULATE
#ifdef LCD_DEBUG
    lcd_set_pos(31);
    lcd_print_char('\1', NULL);
#else
	printf("Board init complete.\n");
#endif
#else
    printf("Board init complete.\n");
#endif

#ifndef SIMULATE
    LED_COMM(0);
#endif

}
Esempio n. 12
0
int main()
{
    char test2[] = "Lokalerstr";
    char *str = test2;
    uint32_t i;
    
//    for (i = 0; i < 4; i++)
 //       test2[i] = 'l';
  //  glob[0]  = 'g';
    
 	// Initialize stuff
	uart_init();

	// Say Hello!
	uart_putstr( "** Spike Test Firmware **\n" );

	// Initialize TIC
	isr_init();
	tic_init();
	irq_set_mask( 0x00000002 );
	irq_enable();

	// Say Hello!
	uart_putstr( "Timer Interrupt instelled.\n" );

	// Do some trivial tests
	uart_putstr( "Subroutine-Return Test: " );
	test();
	uart_putchar('\n');    

	uart_putstr( "Local-Pointer Test:" );
	for (;*str; str++) {
	   uart_putchar(*str);
	}
	uart_putchar('\n');    
	
	uart_putstr( "Global-Pointer Test:" );
	str = glob;
	for (;*str; str++) {
	   uart_putchar(*str);
	}
	uart_putchar('\n');    

	uart_putstr( "Stack Pointer : " );
	writeint(get_sp());
	uart_putchar('\n');    

	uart_putstr( "Global Pointer: " );
	writeint(get_gp());
	uart_putchar('\n');    

	uart_putstr( "Timer Test (1s): " );
	for(i=0; i<4; i++) {
		uart_putstr("tic...");    
		msleep(1000);
	}
	uart_putchar('\n');    

	uart_putstr( "Timer Interrupt counter: " );
	writeint( tic_msec );
	uart_putchar('\n');    

	int val = tic_msec;
	uart_putstr( "Shift: " );
	writeint( val );
	uart_putstr(" <-> ");    
	for(i=0; i<32; i++) {
		if (val & 0x80000000)
			uart_putchar( '1' );
		else
			uart_putchar( '0' );
			
		val <<= 1;
	}
	uart_putstr("\r\n");
	
	uart_putstr( "GPIO Test..." );
	gpio0->oe = 0x000000ff;
	for(;;) {
		for(i=0; i<8; i++) {
			uint32_t out1, out2;

			out1 = 0x01 << i;
			out2 = 0x80 >> i;
			gpio0->out = out1 | out2;

			msleep(100);
		}
	}


/*
	uart_putstr( "Memory Dump: " );
	uint32_t *start = (uint32_t *)0x40000000;
	uint32_t *end   = (uint32_t *)0x40000100;
	uint32_t *p;
	for (p=start; p<end; p++) {
		if (((uint32_t)p & 12) == 0) {
			uart_putstr("\r\n[");
			writeint((uint32_t) p);
			uart_putchar(']');    
		}

		uart_putchar(' ');    
		writeint(*p);
	}
*/

	uart_putstr("Entering Echo Test...\n");
	while (1) {
	   uart_putchar(uart_getchar());
	}
}