Пример #1
0
void _optimsoc_vmm_init(void) {
    // Register exception handlers
    or1k_exception_handler_add(0x9, _optimsoc_dtlb_miss);
    or1k_exception_handler_add(0xA, _optimsoc_itlb_miss);
    or1k_exception_handler_add(0x3, _optimsoc_dpage_fault);
    or1k_exception_handler_add(0x4, _optimsoc_ipage_fault);
}
Пример #2
0
void vmm_init() {
    page_pool = list_init(NULL);

    /* Get page pool size */
    void *start_page = (void*) ((PHYSMEM_START + PAGESIZE) & ~PAGEMASK);
    void *end_page   = (void*) (PHYSMEM_END   & ~PAGEMASK);

    /* Setup page pool */
    for(void* page = start_page; page <= end_page; page += PAGESIZE) {
        list_add_tail(page_pool, page);
    }

    or1k_exception_handler_add(0x9, dtlb_miss);
    or1k_exception_handler_add(0xA, itlb_miss);
}
Пример #3
0
/* --------------------------------------------------------------------------*/
int
or1k_timer_init(unsigned int hz)
{
	uint32_t upr = or1k_mfspr(OR1K_SPR_SYS_UPR_ADDR);
	if (OR1K_SPR_SYS_UPR_TTP_GET(upr) == 0) {
		return -1;
	}

	/* Set this, for easy access when reloading */
	uint32_t period = (_or1k_board_clk_freq/hz) & OR1K_SPR_TICK_TTMR_TP_MASK;
	OR1K_REENT.or1k_timer_period = period;
	or1k_mtspr(OR1K_SPR_TICK_TTMR_ADDR, period);

	/* Reset timer tick counter */
	OR1K_REENT.or1k_timer_ticks = 0;

	/* Install handler */
	or1k_exception_handler_add(0x5, _or1k_timer_interrupt_handler);
	OR1K_REENT.or1k_timer_mode = OR1K_SPR_TICK_TTMR_MODE_RESTART;

	/* Reset counter register */
	or1k_mtspr(OR1K_SPR_TICK_TTCR_ADDR, 0);

	return 0;
}
Пример #4
0
int main(void)
{

  printf("\r\n");
  printf("Timer + UART demo\r\n");
  printf("Press any key to increment the LED counter, except backspace which will\r\n");
  printf("cause it to decrement\r\n");

  /* Set the GPIO to all out */
  char dir = 0xff;
  *(gpio_base+1) = dir;
  /* Initialise with the first data value */
  *(gpio_base+0) = dat;

  /* Initialise the counter at 1Hz, it won't start yet */
  or1k_timer_init(1);

  /* Install a custom timer handler */
  or1k_exception_handler_add(0x5,or1k_timer_interrupt_handler_new);
  
  /* OK, start the timer now */
  or1k_timer_enable();

  /* Now loop and check for UART input */
  while (1)
    {
      char c = __uart_getc();

      /* If it was backspace, decrement the LEDs */
      if (c==0x7f)
	dat-=2;

      /* Update the GPIO LED output on any keypress, just like the timer had
	 gone off */
      or1k_timer_user_handler();
      
    }

  return 0;
}
Пример #5
0
void
or1k_timer_set_handler(void (*handler)(void))
{
	or1k_exception_handler_add(0x5, handler);
}
Пример #6
0
int main(int arcg,char * argv[]){ 

	
	int i = or1k_mfspr(17);

	char * newline = "\n";
	//_cust_print_int((int)newline);

	*(volatile char*)0x80000000 = 'm';
	*(volatile char*)0x80000000 = 'a';
	*(volatile char*)0x80000000 = 'i';
	*(volatile char*)0x80000000 = 'n';
	*(volatile char*)0x80000000 = ' ';
	*(volatile char*)0x80000000 = 'c';
	*(volatile char*)0x80000000 = 'a';
	*(volatile char*)0x80000000 = 'l';
	*(volatile char*)0x80000000 = 'l';
	*(volatile char*)0x80000000 = 'e';
	*(volatile char*)0x80000000 = 'd';
	*(volatile char*)0x80000000 = '\n';


	for (int i = 0;i<32;i++)
		global_irqhandler[i] = 0;

	global_irqhandler[2] = irq2;
	or1k_exception_handler_add (0x8, &interrupt_handler);
	or1k_interrupt_enable(2);
	/*__asm__(
		".byte 0x7C,0x00,0x00,0x00"
	);*/

	// Timer interrupt
	int or1k_timer_period = 40000;
	or1k_exception_handler_add(0x5, &timer_isr); 			// Install handler for Timer interrupt
	or1k_mtspr(10<<11, 0x00<<24 | or1k_timer_period);		// Set Timer Mode Register
	or1k_mtspr(17, or1k_mfspr(17) | 2 );				// Set Special Purpose Register: Enable Timer interrupt
	or1k_mtspr((10<<11) + 1, 0);                             	// reset counter register (qemu bug: automatic counter reset does not work)




	for (int i = 1;i<10000; i = i * 2){
		_cust_print_int(i);
		_cust_print(newline);
	}





	//or1k_exception_handler_add (0x8, &or1k_interrupt_handler);
	//or1k_interrupt_handler_add(11, &irq2);
	//or1k_interrupt_enable(10);

	/*

	float x = 0;



	for (int j = 0;j<(1<<16);j++){
		for (int i = 0;i<(100);i++){
			x += 0.1;
		}
		*((int*)0x0000A000) = (int) x;
	}

	*((int*)0x10000000) = 0;
	*/


	float p = 2 * F(1);

	_cust_print("pi 1: ");
	_cust_print_float(p);
	_cust_print("\n");

	
	_cust_print("pi 2: ");
	_cust_print_float(pi());
	_cust_print("\n");
	

	//if (pi > 0.0)
		//_cust_print("\n\n3-pi > 0\n\n\n");



	//float c = 0;
	//for (int i = 0;i < 10000000;i++){
	//	c+=0.1;
	//}


	//return (int)c;
	return 0;
}
Пример #7
0
void _optimsoc_runtime_syscalls_init(void) {
    or1k_exception_handler_add(0xc, _optimsoc_runtime_syscall_exception_handler);
}