Exemplo 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 (;;);
}
Exemplo n.º 2
0
void mutex_lock(mutex_t* m)
{
    assert(m);
    assert(m->waiting_queue);
    
    uint8_t old_status = set_interrupts(DISABLED);

    assert(!m->owner || m->owner != current_thread);
    
    if (m->owner) {
        list_enqueue(m->waiting_queue, current_thread);
        thread_sleep();
    } else {
        m->owner = current_thread;
    }

    set_interrupts(old_status);
}
Exemplo n.º 3
0
void main()
{
	INT8 i;
	UINT8 input;

	UFIX16 amount;
	amount.U16 = 0x0000U;


	set_bkg_data(0, 42, roadTiles);
	set_bkg_tiles(0, 0, 32, 32, roadGrid);

	offsetIndex = 0;
	for (i = 0; i < 80; i++)
	{
		roadOffset[i] = 0;
	}

	SPRITES_8x8;
	SHOW_SPRITES;
	SHOW_BKG;
	HIDE_WIN;

	LYC_REG = 0x07U;
	STAT_REG = 0x20U;
	set_interrupts(VBL_IFLAG | LCD_IFLAG);

	add_LCD(HBLANK);
	add_VBL(VBLANK);

	enable_interrupts();

	frameReady = 0;
	while (1)
	{
		if (frameReady == 0)
		{
			input = joypad();
			if (input & J_LEFT)
			{
				amount.U8.intp -= 10;
			}

			if (input & J_RIGHT)
			{
				amount.U8.intp += 10;
			}

			MoveHr(&amount);

			frameReady = 1;
		}
	}
}
Exemplo n.º 4
0
void mutex_unlock(mutex_t* m)
{
    assert(m);
    assert(m->waiting_queue);
    
    thread_t* t = NULL;
    
    uint8_t old_status = set_interrupts(DISABLED);

    assert(m->owner == current_thread);

    if (m->waiting_queue->length != 0) {
        t = (thread_t*)list_dequeue(m->waiting_queue);
        assert(t);
        m->owner = t;
        make_thread_ready(t);
    } else {
        m->owner = NULL;
    }
    
    set_interrupts(old_status);
}
Exemplo n.º 5
0
Arquivo: irq.c Projeto: UraKn0x/gbdk
void main()
{
  /* Ensure mutual exclusion (not really necessary in this example)... */
  disable_interrupts();
  vbl_cnt = tim_cnt = 0;
  add_VBL(vbl);
  add_TIM(tim);
  enable_interrupts();

  /* Set TMA to divide clock by 0x100 */
  TMA_REG = 0x00U;
  /* Set clock to 4096 Hertz */
  TAC_REG = 0x04U;
  /* Handle VBL and TIM interrupts */
  set_interrupts(VBL_IFLAG | TIM_IFLAG);

  while(1) {
    print_counter();
    delay(1000UL);
  }
}