Exemplo n.º 1
0
int main() {
	init_mem();
	memory_test();
//  gcollector_test();
	leak_msg();
	getchar();
	return 0;
}
Exemplo n.º 2
0
/* bed of nails test routine */
void bon_test(void)
{
	

	ulong address;
	int result = 0;
	if (bontestmode() == 1)		/* test if bon should run */
	{	
		setenv("bootdelay","15"); // delay kernal boot for 15 sec after test
		//putled(LEDOFF);		// turn off the leds
		putled(STATUSLED);		//turn on green led

	/*	do tests */
		if (0 != memory_test (MEMTESTSTART, MEMTESTSTOP, MEMTESTPAT)) {		/* memory test */
		/*	red_LED_on();	*/	/* warn bad memory */
			result = 1;
			printf("Memory Test Failed\n");
		}
		else
			printf("Memory test passed\n");
		
		//Memory Address test
		address = memory_addr_test (ADDRTESTSTART, ADDRTESTPAT, ADDRANTITESTPAT);
		if (0 != address) {		/* memory test */
		/*	red_LED_on();	*/	/* warn bad memory */
			result = 1;
			printf("Memory Address Test Failed at: %x\n",(unsigned int)address);
		}
		else
			printf("Memory Address test passed\n");
// kernel checksum test
		if (0 != kernel_crc_test ()) { 	/* flash test */
		/*	red_LED_on();	*/	/* warn bad memory */
			result = 1;
			printf("Kernel Test Failed\n");
		}
		else
			printf("Kernel test passed\n");


		udelay(1000000UL);//rld debug
		result ? putled(STATUSOFF) : bonPASS_flashLED() ;	// if passed all tests(result =0) flash led, if failed a test turn off status LED.
	}
	else {
		// putled (GREENLED);		// no test is a good test
		return;
	}
}
Exemplo n.º 3
0
/***********************************************************************
 *
 * Function: cmd_memtst
 *
 * Purpose: Performs memory tests
 *
 * Processing:
 *     See function.
 *
 * Parameters: None
 *
 * Outputs: None
 *
 * Returns: TRUE if the command was good, otherwise FALSE
 *
 * Notes:
 *     memtst [hex address][bytes to test][1, 2, or 4 bytes][0(all) - 5][iterations]
 *
 **********************************************************************/
static BOOL_32 cmd_memtst(void) {
    UNS_32 iters, hexaddr, bytes, width, tstnum;

    /* Get arguments */
    hexaddr = cmd_get_field_val(1);
    bytes = cmd_get_field_val(2);
    width = cmd_get_field_val(3);
    tstnum = cmd_get_field_val(4);
    iters = cmd_get_field_val(5);
    if (tstnum == 0)
    {
        tstnum = MTST_ALL;
    }
    else
    {
        tstnum--;
    }

    memory_test(hexaddr, bytes, width, tstnum, iters);

    return TRUE;
}
Exemplo n.º 4
0
void 
HariMain(void)
{
  boot_info_t* binfo = (boot_info_t*)ADR_BOOTINFO;
  fifo32_t fifo, keycmd;
  int  fifobuf[128], keycmd_buf[32];
  char debug_info[64];
  int mouse_x, mouse_y, cursor_x, cursor_c;
  int data;
  mouse_dec_t mdec;
  unsigned int memory_total;
  mem_mgr_t* mem_mgr = (mem_mgr_t*)MEMMGR_ADDR;
  layer_mgr_t* layer_mgr;
  layer_t* back_layer;
  layer_t* mouse_layer;
  layer_t* win_layer;
  layer_t* cons_layer;
  unsigned char* back_buf;
  unsigned char  mouse_buf[256];
  unsigned char* win_buf;
  unsigned char* cons_buf;
  static char s_keytable[0x80] = {
    0,   0,   '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=',
    0,   0,   'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '[', ']', 
    0,   0,   'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ';', '\'','`', 
    0,   '\\','Z', 'X', 'C', 'V', 'B', 'N', 'M', ',', '.', '/', 0,   '*', 
    0,   ' ', 0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 
    0,   '7', '8', '9', '-', '4', '5', '6', '+', '1', '2', '3', '0', '.', 
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
    0,   0
  };
  static char s_keytable_shift[0x80] = {
    0,   0,   '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+',
    0,   0,   'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', 
    0,   0,   'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '\"','~', 
    0,   '|', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?', 0,   '*', 
    0,   ' ', 0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 
    0,   '7', '8', '9', '-', '4', '5', '6', '+', '1', '2', '3', '0', '.', 
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
    0,   0
  };
  task_t* task_a;
  task_t* task_cons;
  timer_t* timer;
  int key_to = 0, key_shift = 0;
  int key_leds = (binfo->leds >> 4) & 7;  /* CapsLock state */
  int keycmd_wait = -1;
  console_t* console;
  int j, x, y;
  int movemode_x = -1, movemode_y = -1;
  layer_t* layer = 0;


  init_gdt_idt();
  init_pic();
  io_sti();   /* after initialize IDT/PIC, allow all CPU's interruptors */

  fifo_init(&fifo, fifobuf, 128, 0);
  init_pit(); /* initialize programmable interval timer */
  init_keyboard(&fifo, 256);
  enable_mouse(&fifo, 512, &mdec);
  io_out8(PIC0_IMR, 0xf8);  /* set PIT/PIC1/keyboard permission 11111000 */
  io_out8(PIC1_IMR, 0xef);  /* set mouse permission 11101111 */
  fifo_init(&keycmd, keycmd_buf, 32, 0);

  memory_total = memory_test(0x00400000, 0xbfffffff);
  mem_mgr_init(mem_mgr);
  mem_mgr_free(mem_mgr, 0x00001000, 0x0009e000);  /*0x00001000~0x0009e000*/
  mem_mgr_free(mem_mgr, 0x00400000, memory_total - 0x00400000);

  init_palette();
  layer_mgr = layer_mgr_init(mem_mgr, binfo->vram, 
      binfo->screen_x, binfo->screen_y);
  task_a = task_init(mem_mgr);
  fifo.task = task_a;
  task_run(task_a, 1, 2);
  *((int*)0x0fe4) = (int)layer_mgr;

  /* back layer */
  back_layer = layer_alloc(layer_mgr);
  back_buf = (unsigned char*)mem_mgr_alloc_4k(mem_mgr, 
      binfo->screen_x * binfo->screen_y);
  layer_setbuf(back_layer, back_buf, 
      binfo->screen_x, binfo->screen_y, -1);
  init_screen(back_buf, binfo->screen_x, binfo->screen_y);

  /* console task */
  cons_layer = layer_alloc(layer_mgr);
  cons_buf = (unsigned char*)mem_mgr_alloc_4k(mem_mgr, 256 * 165);
  layer_setbuf(cons_layer, cons_buf, 256, 165, -1); /* transparent */
  make_window8(cons_buf, 256, 165, "Console", 0);
  make_text8(cons_layer, 8, 28, 240, 128, COLOR8_000000);
  task_cons = task_alloc();
  task_cons->tss.esp = 
    mem_mgr_alloc_4k(mem_mgr, 64 * 1024) + 64 * 1024 - 12;
  task_cons->tss.eip = (int)&console_task;
  task_cons->tss.es  = 1 * 8;
  task_cons->tss.cs  = 2 * 8;
  task_cons->tss.ss  = 1 * 8;
  task_cons->tss.ds  = 1 * 8;
  task_cons->tss.fs  = 1 * 8;
  task_cons->tss.gs  = 1 * 8;
  *((int*)(task_cons->tss.esp + 4)) = (int)cons_layer;
  *((int*)(task_cons->tss.esp + 8)) = memory_total;
  task_run(task_cons, 2, 2);  /* level = 2, priority = 2 */
  
  /* window layer */
  win_layer = layer_alloc(layer_mgr);
  win_buf = (unsigned char*)mem_mgr_alloc_4k(mem_mgr, 160 * 52);
  layer_setbuf(win_layer, win_buf, 144, 52, -1);
  make_window8(win_buf, 144, 52, "TASK-A", 1);
  make_text8(win_layer, 8, 28, 128, 16, COLOR8_FFFFFF);
  cursor_x = 8;
  cursor_c = COLOR8_FFFFFF;
  timer = timer_alloc();
  timer_init(timer, &fifo, 1);
  timer_settimer(timer, 50);

  /* mouse layer */
  mouse_layer = layer_alloc(layer_mgr);
  layer_setbuf(mouse_layer, mouse_buf, 16, 16, 99);
  init_mouse_cursor8(mouse_buf, 99);
  mouse_x = (binfo->screen_x - 16) / 2;
  mouse_y = (binfo->screen_y - 28 - 16) / 2;

  layer_slide(back_layer, 0, 0);
  layer_slide(cons_layer, 32, 4);
  layer_slide(win_layer, 64, 56);
  layer_slide(mouse_layer, mouse_x, mouse_y);
  layer_updown(back_layer, 0);
  layer_updown(cons_layer, 1);
  layer_updown(win_layer, 2);
  layer_updown(mouse_layer, 3);


  fifo_put(&keycmd, KEYCMD_LED);
  fifo_put(&keycmd, key_leds);

  for ( ; ; ) {
    if (fifo_size(&keycmd) > 0 && keycmd_wait < 0) {
      /* send it when send data to keyboard controller */
      keycmd_wait = fifo_get(&keycmd);
      wait_kbc_sendready();
      io_out8(PORT_KEYDATA, keycmd_wait);
    }

    io_cli();

    if (0 == fifo_size(&fifo)) {
      task_sleep(task_a);
      io_sti();
    }
    else {
      data = fifo_get(&fifo);
      io_sti();

      if (256 <= data && data <= 511) {
        if (data < (256 + 0x80)) {
          /* translation character */
          if (0 == key_shift)
            debug_info[0] = s_keytable[data - 256];
          else 
            debug_info[0] = s_keytable_shift[data - 256];
        }
        else 
          debug_info[0] = 0;
        if ('A' <= debug_info[0] && debug_info[0] <= 'Z') {
          /* it's an english character */
          if ((0 == (key_leds & 4) && 0 == key_shift) 
            || (0 != (key_leds & 4) && 0 != key_shift))
            debug_info[0] += 0x20;  /* character lower ('A' -> 'a') */
        }
        if (0 != debug_info[0]) {
          /* general character */
          if (0 == key_to) {
            /* send character data to TASK-A */
            if (cursor_x < 128) {
              /* display one character and cursor move backward one */
              debug_info[1] = 0;
              drawstring_and_refresh(win_layer, cursor_x, 28, 
                  COLOR8_000000, COLOR8_FFFFFF, debug_info, 1);
              cursor_x += 8;
            }
          }
          else  /* send character data to console window */
            fifo_put(&task_cons->fifo, debug_info[0] + 256);
        }

        if ((256 + 0x0e) == data) {
          /* backspace, recover cursor by sapce, move back cursor 1 time */
          if (0 == key_to) {
            if (cursor_x > 8) {
              drawstring_and_refresh(win_layer, cursor_x, 28, 
                  COLOR8_000000, COLOR8_FFFFFF, " ", 1);
              cursor_x -= 8;
            }
          }
          else 
            fifo_put(&task_cons->fifo, 8 + 256);
        }
        if ((256 + 0x1c) == data) {
          /* Enter Key */
          if (0 != key_to)  /* send to Console window */
            fifo_put(&task_cons->fifo, 10 + 256);
        }

        if ((256 + 0x0f) == data) {
          /* TAB */
          if (0 == key_to) {
            key_to = 1;
            make_title8(win_buf, win_layer->w_size, "TASK-A", 0);
            make_title8(cons_buf, cons_layer->w_size, "Console", 1);
            cursor_c = -1;  /* don't show the cursor */
            fill_box8(win_layer->buf, win_layer->w_size, 
                COLOR8_FFFFFF, cursor_x, 28, cursor_x + 7, 43);

            fifo_put(&task_cons->fifo, 2);  /* console cursor -> ON */
          }
          else {
            key_to = 0;
            make_title8(win_buf, win_layer->w_size, "TASK-A", 1);
            make_title8(cons_buf, cons_layer->w_size, "Console", 0);
            cursor_c = COLOR8_000000; /* show the cursor */

            fifo_put(&task_cons->fifo, 3);  /* console cursor -> OFF */
          }
          layers_refresh(win_layer, 0, 0, win_layer->w_size, 21);
          layers_refresh(cons_layer, 0, 0, cons_layer->w_size, 21);
        }
        if ((256 + 0x2a) == data) /* left shift down */
          key_shift |= 1;
        if ((256 + 0x36) == data) /* right shift down */
          key_shift |= 2;
        if ((256 + 0xaa) == data) /* left shift up */
          key_shift &= ~1;
        if ((256 + 0xb6) == data) /* right shift up */
          key_shift &= ~2;
        if ((256 + 0x3a) == data) { /* CapsLock */
          key_leds ^= 4;
          fifo_put(&keycmd, KEYCMD_LED);
          fifo_put(&keycmd, key_leds);
        }
        if ((256 + 0x45) == data) { /* NumLock */
          key_leds ^= 2;
          fifo_put(&keycmd, KEYCMD_LED);
          fifo_put(&keycmd, key_leds);
        }
        if ((256 + 0x46) == data) { /* ScrollLock */
          key_leds ^= 1;
          fifo_put(&keycmd, KEYCMD_LED);
          fifo_put(&keycmd, key_leds);
        }
        if (((256 + 0x3e) == data) 
            && (0 != key_shift) 
            && (0 != task_cons->tss.ss0)) {
          /* Shift + F4 force to stop user application */
          console = (console_t*)*((int*)0x0fec);
          console_putstr0(console, "\nbreak(key) :\n");
          io_cli();
          task_cons->tss.eax = (int)&(task_cons->tss.esp0);
          task_cons->tss.eip = (int)asm_stop_user_app;
          io_sti();
        }
        if (((256 + 0x57) == data) && (layer_mgr->top > 2)) {
          /* F11 switch window */
          layer_updown(layer_mgr->layers_addr[1], layer_mgr->top - 1);
        }
        if ((256 + 0xfa) == data)   /* keyboard recevie data success */
          keycmd_wait = -1;
        if ((256 + 0xfe) == data) { /* keyboard recevie data failed */
          wait_kbc_sendready();
          io_out8(PORT_KEYDATA, keycmd_wait);
        }

        /* show cursor again */
        if (cursor_c >= 0) {
          fill_box8(win_layer->buf, win_layer->w_size, 
              cursor_c, cursor_x, 28, cursor_x + 7, 43);
        }
        layers_refresh(win_layer, cursor_x, 28, cursor_x + 8, 44);
      }
      else if (512 <= data && data <= 767) {
        if (0 != mouse_decode(&mdec, data - 512)) {
          mouse_x += mdec.x;
          mouse_y += mdec.y;

          if (mouse_x < 0)
            mouse_x = 0;
          if (mouse_y < 0)
            mouse_y = 0;
          if (mouse_x > binfo->screen_x - 1)
            mouse_x = binfo->screen_x - 1;
          if (mouse_y > binfo->screen_y - 1)
            mouse_y = binfo->screen_y - 1;

          layer_slide(mouse_layer, mouse_x, mouse_y);

          if (0 != (mdec.state & 0x01)) {
            /* left click button down */
            if (movemode_x < 0) {
              /* down left click, move window */
              /* find the layer of mouse on */
              for (j = layer_mgr->top - 1; j > 0; --j) {
                layer = layer_mgr->layers_addr[j];
                x = mouse_x - layer->x;
                y = mouse_y - layer->y;
                if (0 <= x && x < layer->w_size 
                    && 0 <= y && y < layer->h_size) {
                  if (layer->buf[y * layer->w_size + x] != layer->alpha) {
                    layer_updown(layer, layer_mgr->top - 1);
                    if (3 <= x 
                        && x < layer->w_size - 3 && 3 <= y && y < 21) {
                      movemode_x = mouse_x;
                      movemode_y = mouse_y;
                    }
                    if (layer->w_size - 21 <= x && x < layer->w_size - 5 
                        && 5 <= y && y < 19) {
                      /* click close button of the window */
                      if (0 != layer->task) {
                        /* whether it's the window of application */
                        console = (console_t*)*((int*)0x0fec);
                        console_putstr0(console, "\nbreak(mouse) : \n");
                        io_cli();
                        task_cons->tss.eax = (int)&task_cons->tss.esp0;
                        task_cons->tss.eip = (int)asm_stop_user_app;
                        io_sti();
                      }
                    }
                    break;
                  }
                }
              }
            }
            else {
              /* on move mode */
              x = mouse_x - movemode_x;
              y = mouse_y - movemode_y;
              layer_slide(layer, layer->x + x, layer->y + y);
              movemode_x = mouse_x;
              movemode_y = mouse_y;
            }
          }
          else 
            movemode_x = -1;  /* return to normal mode */
        }
      }
      else if (data <= 1) { /* timer by cursor */
        if (0 != data) {
          timer_init(timer, &fifo, 0);
          if (cursor_c >= 0)
            cursor_c = COLOR8_000000;
        }
        else {
          timer_init(timer, &fifo, 1);
          if (cursor_c >= 0)
            cursor_c = COLOR8_FFFFFF;
        }
        timer_settimer(timer, 50);
        
        if (cursor_c >= 0) {
          fill_box8(win_layer->buf, win_layer->w_size, 
              cursor_c, cursor_x, 28, cursor_x + 7, 43);
          layers_refresh(win_layer, cursor_x, 28, cursor_x + 8, 44);
        }
      }
    }
  }
}
Exemplo n.º 5
0
void 
HariMain(void)
{
  boot_info_t* binfo = (boot_info_t*)ADR_BOOTINFO;
  char debug_info[64], keybuf[32], mousebuf[128];
  int mouse_x, mouse_y;
  int data;
  mouse_dec_t mdec;
  unsigned int memory_total;
  mem_mgr_t* mem_mgr = (mem_mgr_t*)MEMMGR_ADDR;
  layer_mgr_t* layer_mgr;
  layer_t* back_layer;
  layer_t* mouse_layer;
  unsigned char* back_buf;
  unsigned char  mouse_buf[256];

  init_gdt_idt();
  init_pic();
  io_sti();

  fifo_init(&g_keybuf, keybuf, 32);
  fifo_init(&g_mousebuf, mousebuf, 128);
  io_out8(PIC0_IMR, 0xf9);
  io_out8(PIC1_IMR, 0xef);

  init_keyboard();      /* initialize keyboard */
  enable_mouse(&mdec);  /* enabled mouse */

  memory_total = memory_test(0x00400000, 0xbfffffff);
  mem_mgr_init(mem_mgr);
  mem_mgr_free(mem_mgr, 0x00001000, 0x0009e000);  /*0x00001000~0x0009e000*/
  mem_mgr_free(mem_mgr, 0x00400000, memory_total - 0x00400000);

  init_palette();
  layer_mgr = layer_mgr_init(mem_mgr, binfo->vram, 
      binfo->screen_x, binfo->screen_y);
  back_layer = layer_alloc(layer_mgr);
  mouse_layer = layer_alloc(layer_mgr);
  back_buf = (unsigned char*)mem_mgr_alloc_4k(mem_mgr, 
      binfo->screen_x * binfo->screen_y);
  layer_setbuf(back_layer, back_buf, 
      binfo->screen_x, binfo->screen_y, -1);
  layer_setbuf(mouse_layer, mouse_buf, 16, 16, 99);
  init_screen(back_buf, binfo->screen_x, binfo->screen_y);
  init_mouse_cursor8(mouse_buf, 99);
  layer_slide(layer_mgr, back_layer, 0, 0);
  mouse_x = (binfo->screen_x - 16) / 2;
  mouse_y = (binfo->screen_y - 28 - 16) / 2;
  layer_slide(layer_mgr, mouse_layer, mouse_x, mouse_y);
  layer_updown(layer_mgr, back_layer, 0);
  layer_updown(layer_mgr, mouse_layer, 1);
  sprintf(debug_info, "(%3d, %3d)", mouse_x, mouse_y);
  draw_font8_asc(back_buf, binfo->screen_x, 0, 0, 
      COLOR8_FFFFFF, debug_info);

  sprintf(debug_info, "memory total: %dMB, free space: %dKB", 
      memory_total / (1024 * 1024), mem_mgr_total(mem_mgr) / 1024);
  draw_font8_asc(back_buf, binfo->screen_x, 
      0, 32, COLOR8_FFFFFF, debug_info);

  layers_refresh(layer_mgr, back_layer, 0, 0, binfo->screen_x, 48);

  for ( ; ; ) {
    io_cli();

    if (0 == fifo_size(&g_keybuf) && 0 == fifo_size(&g_mousebuf)) 
      io_stihlt();
    else {
      if (0 != fifo_size(&g_keybuf)) {
          data = fifo_get(&g_keybuf);

          io_sti();
          sprintf(debug_info, "%02X", data);
          fill_box8(back_buf, binfo->screen_x, 
            COLOR8_848484, 0, 16, 15, 31);
          draw_font8_asc(back_buf, binfo->screen_x, 
            0, 16, COLOR8_FFFFFF, debug_info);

          layers_refresh(layer_mgr, back_layer, 0, 16, 16, 32);
      }
      else if (0 != fifo_size(&g_mousebuf)) {
        data = fifo_get(&g_mousebuf);
        io_sti();

        if (0 != mouse_decode(&mdec, data)) {
          /* show all mouse bytes code */
          sprintf(debug_info, "[lcr %4d %4d]", mdec.x, mdec.y);
          if (0 != (mdec.state & 0x01)) 
            debug_info[1] = 'L';
          if (0 != (mdec.state & 0x02))
            debug_info[3] = 'R';
          if (0 != (mdec.state & 0x04))
            debug_info[2] = 'C';
          fill_box8(back_buf, binfo->screen_x, 
              COLOR8_848484, 32, 16, 32 + 15 * 8 - 1, 31);
          draw_font8_asc(back_buf, binfo->screen_x, 
              32, 16, COLOR8_FFFFFF, debug_info);
          layers_refresh(layer_mgr, back_layer, 32, 16, 32 + 15 * 8, 32);

          mouse_x += mdec.x;
          mouse_y += mdec.y;

          if (mouse_x < 0)
            mouse_x = 0;
          if (mouse_y < 0)
            mouse_y = 0;
          if (mouse_x > binfo->screen_x - 1)
            mouse_x = binfo->screen_x - 1;
          if (mouse_y > binfo->screen_y - 1)
            mouse_y = binfo->screen_y - 1;

          sprintf(debug_info, "(%3d, %3d)", mouse_x, mouse_y);
          fill_box8(back_buf, binfo->screen_x, 
              COLOR8_848484, 0, 0, 79, 15);     /* hide mouse position */
          draw_font8_asc(back_buf, binfo->screen_x, 
              0, 0, COLOR8_FFFFFF, debug_info); /* show mouse position */

          layers_refresh(layer_mgr, back_layer, 0, 0, 80, 16);
          layer_slide(layer_mgr, mouse_layer, mouse_x, mouse_y);
        }
      }
    }
  }
}
Exemplo n.º 6
0
uint32_t mtsp_test(uintptr_t addr,  uint32_t size, uint32_t pattern,
		uint32_t pre_read)
{
	uint32_t cur_pattern = 0;
	uint32_t index = 0x1;
	int i;
	uint8_t  mtsp_rc = MTSP_OPERATION_OK;
	uint32_t tmsec = 0;

	mtsp_total_error = 0;
	if (bit_byte_check) {
		for (i = 0; i < sizeof(byte_err_sta)/sizeof(uint32_t); i++)
			byte_err_sta[i] = 0;
		for (i = 0; i < sizeof(bit_err_sta)/sizeof(uint32_t); i++)
			bit_err_sta[i] = 0;
	}
	if (logout_mode == FULL_MODE) {
		/*Need to add many prints to the user - OR*/
		printf("MTSP test starts from:");
		printw((uint32_t)addr & 0xFFFFFFFF);
		printf(" to :");
		printw(((uint32_t)addr & 0xFFFFFFFF) + size);
		printf("\n");
		tmsec = get_timer(0);
	}
	for (i = 0; i < 32; i++) {
		cur_pattern = pattern & (index << i);
		if (cur_pattern) {
			mtsp_rc = memory_test(addr, size, i,
					ACCESS_TYPE_WORD, 1);
			if (mtsp_rc)
				break;
		}

	}
	if (logout_mode == FULL_MODE) {
		tmsec = get_timer(0) - tmsec;
		printf("Elapsed time: %d msec\n", tmsec);
		if (mtsp_total_error)
			printf("mtsp mem test finished and %d errors occur\n",
					mtsp_total_error);
		else
			printf("mtsp memory test finished successfully.\n");
	} else if (logout_mode == SIGN_MODE)
		printf("\n");

	if (logout_mode >= MINIMAL_MODE && logout_mode < FULL_MODE &&
			mtsp_total_error)
		printf("mstp-->  Test failed\n");
	if (mtsp_total_error) {
		if (bit_byte_check) {
			printf("*** MTSP BYTE & BIT error statistics ***\n");
			for (i = 0; i < sizeof(byte_err_sta)/sizeof(uint32_t);
					i++)
				printf("BYTE %d error: %d\n",
						i, byte_err_sta[i]);
			printf("----------\n");
			for (i = 0; i < sizeof(bit_err_sta)/sizeof(uint32_t);
					i++)
				printf("BIT %d error: %d\n",
						i, bit_err_sta[i]);
		}
		return MTSP_READ_FAIL;
	}
	return mtsp_rc;
}
Exemplo n.º 7
0
void 
HariMain(void)
{
  boot_info_t* binfo = (boot_info_t*)ADR_BOOTINFO;
  fifo8_t timerfifo;
  char debug_info[64], keybuf[32], mousebuf[128], timerbuf[8];
  int mouse_x, mouse_y;
  int data;
  mouse_dec_t mdec;
  unsigned int memory_total;
  mem_mgr_t* mem_mgr = (mem_mgr_t*)MEMMGR_ADDR;
  layer_mgr_t* layer_mgr;
  layer_t* back_layer;
  layer_t* mouse_layer;
  layer_t* win_layer;
  unsigned char* back_buf;
  unsigned char  mouse_buf[256];
  unsigned char* win_buf;

  init_gdt_idt();
  init_pic();
  io_sti();   /* after initialize IDT/PIC, allow all CPU's interruptors */

  fifo_init(&g_keybuf, keybuf, 32);
  fifo_init(&g_mousebuf, mousebuf, 128);
  init_pit(); /* initialize programmable interval timer */
  io_out8(PIC0_IMR, 0xf8);  /* set PIT/PIC1/keyboard permission 11111000 */
  io_out8(PIC1_IMR, 0xef);  /* set mouse permission 11101111 */

  fifo_init(&timerfifo, timerbuf, 8);
  set_timer(1000, &timerfifo, 1);

  init_keyboard();      /* initialize keyboard */
  enable_mouse(&mdec);  /* enabled mouse */

  memory_total = memory_test(0x00400000, 0xbfffffff);
  mem_mgr_init(mem_mgr);
  mem_mgr_free(mem_mgr, 0x00001000, 0x0009e000);  /*0x00001000~0x0009e000*/
  mem_mgr_free(mem_mgr, 0x00400000, memory_total - 0x00400000);

  init_palette();
  layer_mgr = layer_mgr_init(mem_mgr, binfo->vram, 
      binfo->screen_x, binfo->screen_y);
  back_layer = layer_alloc(layer_mgr);
  mouse_layer = layer_alloc(layer_mgr);
  win_layer = layer_alloc(layer_mgr);
  back_buf = (unsigned char*)mem_mgr_alloc_4k(mem_mgr, 
      binfo->screen_x * binfo->screen_y);
  win_buf = (unsigned char*)mem_mgr_alloc_4k(mem_mgr, 160 * 52);
  layer_setbuf(back_layer, back_buf, 
      binfo->screen_x, binfo->screen_y, -1);
  layer_setbuf(mouse_layer, mouse_buf, 16, 16, 99);
  layer_setbuf(win_layer, win_buf, 160, 52, -1);
  init_screen(back_buf, binfo->screen_x, binfo->screen_y);
  init_mouse_cursor8(mouse_buf, 99);
  make_window8(win_buf, 160, 52, "Counter");
  layer_slide(back_layer, 0, 0);
  mouse_x = (binfo->screen_x - 16) / 2;
  mouse_y = (binfo->screen_y - 28 - 16) / 2;
  layer_slide(mouse_layer, mouse_x, mouse_y);
  layer_slide(win_layer, 80, 72);
  layer_updown(back_layer, 0);
  layer_updown(win_layer, 1);
  layer_updown(mouse_layer, 2);
  sprintf(debug_info, "(%3d, %3d)", mouse_x, mouse_y);
  draw_font8_asc(back_buf, binfo->screen_x, 0, 0, 
      COLOR8_FFFFFF, debug_info);

  sprintf(debug_info, "memory total: %dMB, free space: %dKB", 
      memory_total / (1024 * 1024), mem_mgr_total(mem_mgr) / 1024);
  draw_font8_asc(back_buf, binfo->screen_x, 
      0, 32, COLOR8_FFFFFF, debug_info);

  layers_refresh(back_layer, 0, 0, binfo->screen_x, 48);

  for ( ; ; ) {
    sprintf(debug_info, "%010d", g_timerctl.count);
    fill_box8(win_buf, 160, COLOR8_C6C6C6, 40, 28, 119, 43);
    draw_font8_asc(win_buf, 160, 40, 28, COLOR8_000000, debug_info);
    layers_refresh(win_layer, 40, 28, 120, 44);

    io_cli();
    if (0 == fifo_size(&g_keybuf) 
        && 0 == fifo_size(&g_mousebuf)
        && 0 == fifo_size(&timerfifo)) 
      io_stihlt();
    else {
      if (0 != fifo_size(&g_keybuf)) {
          data = fifo_get(&g_keybuf);

          io_sti();
          sprintf(debug_info, "%02X", data);
          fill_box8(back_buf, binfo->screen_x, 
            COLOR8_848484, 0, 16, 15, 31);
          draw_font8_asc(back_buf, binfo->screen_x, 
            0, 16, COLOR8_FFFFFF, debug_info);

          layers_refresh(back_layer, 0, 16, 16, 32);
      }
      else if (0 != fifo_size(&g_mousebuf)) {
        data = fifo_get(&g_mousebuf);
        io_sti();

        if (0 != mouse_decode(&mdec, data)) {
          /* show all mouse bytes code */
          sprintf(debug_info, "[lcr %4d %4d]", mdec.x, mdec.y);
          if (0 != (mdec.state & 0x01)) 
            debug_info[1] = 'L';
          if (0 != (mdec.state & 0x02))
            debug_info[3] = 'R';
          if (0 != (mdec.state & 0x04))
            debug_info[2] = 'C';
          fill_box8(back_buf, binfo->screen_x, 
              COLOR8_848484, 32, 16, 32 + 15 * 8 - 1, 31);
          draw_font8_asc(back_buf, binfo->screen_x, 
              32, 16, COLOR8_FFFFFF, debug_info);
          layers_refresh(back_layer, 32, 16, 32 + 15 * 8, 32);

          mouse_x += mdec.x;
          mouse_y += mdec.y;

          if (mouse_x < 0)
            mouse_x = 0;
          if (mouse_y < 0)
            mouse_y = 0;
          if (mouse_x > binfo->screen_x - 1)
            mouse_x = binfo->screen_x - 1;
          if (mouse_y > binfo->screen_y - 1)
            mouse_y = binfo->screen_y - 1;

          sprintf(debug_info, "(%3d, %3d)", mouse_x, mouse_y);
          fill_box8(back_buf, binfo->screen_x, 
              COLOR8_848484, 0, 0, 79, 15);     /* hide mouse position */
          draw_font8_asc(back_buf, binfo->screen_x, 
              0, 0, COLOR8_FFFFFF, debug_info); /* show mouse position */

          layers_refresh(back_layer, 0, 0, 80, 16);
          layer_slide(mouse_layer, mouse_x, mouse_y);
        }
      }
      else if (0 != fifo_size(&timerfifo)) {
        data = fifo_get(&timerfifo);
        io_sti();

        draw_font8_asc(back_buf, binfo->screen_x, 
            0, 64, COLOR8_FFFFFF, "10[sec]");
        layers_refresh(back_layer, 0, 64, 56, 80);
      }
    }
  }
}
Exemplo n.º 8
0
void 
HariMain(void)
{
  boot_info_t* binfo = (boot_info_t*)ADR_BOOTINFO;
  fifo32_t fifo, keycmd;
  int  fifobuf[128], keycmd_buf[32];
  char debug_info[64];
  int mouse_x, mouse_y, cursor_x, cursor_c;
  int data;
  mouse_dec_t mdec;
  unsigned int memory_total;
  mem_mgr_t* mem_mgr = (mem_mgr_t*)MEMMGR_ADDR;
  layer_mgr_t* layer_mgr;
  layer_t* back_layer;
  layer_t* mouse_layer;
  layer_t* win_layer;
  layer_t* cons_layer;
  unsigned char* back_buf;
  unsigned char  mouse_buf[256];
  unsigned char* win_buf;
  unsigned char* cons_buf;
  static char s_keytable[0x80] = {
    0,   0,   '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=',
    0,   0,   'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '[', ']', 
    0,   0,   'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ';', '\'','`', 
    0,   '\\','Z', 'X', 'C', 'V', 'B', 'N', 'M', ',', '.', '/', 0,   '*', 
    0,   ' ', 0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 
    0,   '7', '8', '9', '-', '4', '5', '6', '+', '1', '2', '3', '0', '.', 
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
    0,   0
  };
  static char s_keytable_shift[0x80] = {
    0,   0,   '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '_', '+',
    0,   0,   'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '{', '}', 
    0,   0,   'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ':', '\"','~', 
    0,   '|', 'Z', 'X', 'C', 'V', 'B', 'N', 'M', '<', '>', '?', 0,   '*', 
    0,   ' ', 0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 
    0,   '7', '8', '9', '-', '4', '5', '6', '+', '1', '2', '3', '0', '.', 
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
    0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,
    0,   0
  };
  task_t* task_a;
  task_t* task_cons;
  timer_t* timer;
  int key_to = 0, key_shift = 0;
  int key_leds = (binfo->leds >> 4) & 7;  /* CapsLock state */
  int keycmd_wait = -1;


  init_gdt_idt();
  init_pic();
  io_sti();   /* after initialize IDT/PIC, allow all CPU's interruptors */

  fifo_init(&fifo, fifobuf, 128, 0);
  init_pit(); /* initialize programmable interval timer */
  init_keyboard(&fifo, 256);
  enable_mouse(&fifo, 512, &mdec);
  io_out8(PIC0_IMR, 0xf8);  /* set PIT/PIC1/keyboard permission 11111000 */
  io_out8(PIC1_IMR, 0xef);  /* set mouse permission 11101111 */
  fifo_init(&keycmd, keycmd_buf, 32, 0);

  memory_total = memory_test(0x00400000, 0xbfffffff);
  mem_mgr_init(mem_mgr);
  mem_mgr_free(mem_mgr, 0x00001000, 0x0009e000);  /*0x00001000~0x0009e000*/
  mem_mgr_free(mem_mgr, 0x00400000, memory_total - 0x00400000);

  init_palette();
  layer_mgr = layer_mgr_init(mem_mgr, binfo->vram, 
      binfo->screen_x, binfo->screen_y);
  task_a = task_init(mem_mgr);
  fifo.task = task_a;
  task_run(task_a, 1, 2);

  /* back layer */
  back_layer = layer_alloc(layer_mgr);
  back_buf = (unsigned char*)mem_mgr_alloc_4k(mem_mgr, 
      binfo->screen_x * binfo->screen_y);
  layer_setbuf(back_layer, back_buf, 
      binfo->screen_x, binfo->screen_y, -1);
  init_screen(back_buf, binfo->screen_x, binfo->screen_y);

  /* console task */
  cons_layer = layer_alloc(layer_mgr);
  cons_buf = (unsigned char*)mem_mgr_alloc_4k(mem_mgr, 256 * 165);
  layer_setbuf(cons_layer, cons_buf, 256, 165, -1); /* transparent */
  make_window8(cons_buf, 256, 165, "Console", 0);
  make_text8(cons_layer, 8, 28, 240, 128, COLOR8_000000);
  task_cons = task_alloc();
  task_cons->tss.esp = mem_mgr_alloc_4k(mem_mgr, 64 * 1024) + 64 * 1024 - 8;
  task_cons->tss.eip = (int)&console_task;
  task_cons->tss.es  = 1 * 8;
  task_cons->tss.cs  = 2 * 8;
  task_cons->tss.ss  = 1 * 8;
  task_cons->tss.ds  = 1 * 8;
  task_cons->tss.fs  = 1 * 8;
  task_cons->tss.gs  = 1 * 8;
  *((int*)(task_cons->tss.esp + 4)) = (int)cons_layer;
  task_run(task_cons, 2, 2);  /* level = 2, priority = 2 */
  
  /* window layer */
  win_layer = layer_alloc(layer_mgr);
  win_buf = (unsigned char*)mem_mgr_alloc_4k(mem_mgr, 160 * 52);
  layer_setbuf(win_layer, win_buf, 144, 52, -1);
  make_window8(win_buf, 144, 52, "TASK-A", 1);
  make_text8(win_layer, 8, 28, 128, 16, COLOR8_FFFFFF);
  cursor_x = 8;
  cursor_c = COLOR8_FFFFFF;
  timer = timer_alloc();
  timer_init(timer, &fifo, 1);
  timer_settimer(timer, 50);

  /* mouse layer */
  mouse_layer = layer_alloc(layer_mgr);
  layer_setbuf(mouse_layer, mouse_buf, 16, 16, 99);
  init_mouse_cursor8(mouse_buf, 99);
  mouse_x = (binfo->screen_x - 16) / 2;
  mouse_y = (binfo->screen_y - 28 - 16) / 2;

  layer_slide(back_layer, 0, 0);
  layer_slide(cons_layer, 32, 4);
  layer_slide(win_layer, 64, 56);
  layer_slide(mouse_layer, mouse_x, mouse_y);
  layer_updown(back_layer, 0);
  layer_updown(cons_layer, 1);
  layer_updown(win_layer, 2);
  layer_updown(mouse_layer, 3);
  sprintf(debug_info, "(%3d, %3d)", mouse_x, mouse_y);
  drawstring_and_refresh(back_layer, 0, 0, 
      COLOR8_FFFFFF, COLOR8_848484, debug_info, 10);

  sprintf(debug_info, "memory total: %dMB, free space: %dKB", 
      memory_total / (1024 * 1024), mem_mgr_total(mem_mgr) / 1024);
  drawstring_and_refresh(back_layer, 0, 32, 
      COLOR8_FFFFFF, COLOR8_848484, debug_info, 40);


  fifo_put(&keycmd, KEYCMD_LED);
  fifo_put(&keycmd, key_leds);

  for ( ; ; ) {
    if (fifo_size(&keycmd) > 0 && keycmd_wait < 0) {
      /* send it when send data to keyboard controller */
      keycmd_wait = fifo_get(&keycmd);
      wait_kbc_sendready();
      io_out8(PORT_KEYDATA, keycmd_wait);
    }

    io_cli();

    if (0 == fifo_size(&fifo)) {
      task_sleep(task_a);
      io_sti();
    }
    else {
      data = fifo_get(&fifo);
      io_sti();

      if (256 <= data && data <= 511) {
        sprintf(debug_info, "%02X", data - 256);
        drawstring_and_refresh(back_layer, 0, 16, 
            COLOR8_FFFFFF, COLOR8_848484, debug_info, 2);

        if (data < (256 + 0x80)) {
          /* translation character */
          if (0 == key_shift)
            debug_info[0] = s_keytable[data - 256];
          else 
            debug_info[0] = s_keytable_shift[data - 256];
        }
        else 
          debug_info[0] = 0;
        if ('A' <= debug_info[0] && debug_info[0] <= 'Z') {
          /* it's an english character */
          if ((0 == (key_leds & 4) && 0 == key_shift) 
            || (0 != (key_leds & 4) && 0 != key_shift))
            debug_info[0] += 0x20;  /* character lower ('A' -> 'a') */
        }
        if (0 != debug_info[0]) {
          /* general character */
          if (0 == key_to) {
            /* send character data to TASK-A */
            if (cursor_x < 128) {
              /* display one character and cursor move backward one */
              debug_info[1] = 0;
              drawstring_and_refresh(win_layer, cursor_x, 28, 
                  COLOR8_000000, COLOR8_FFFFFF, debug_info, 1);
              cursor_x += 8;
            }
          }
          else  /* send character data to console window */
            fifo_put(&task_cons->fifo, debug_info[0] + 256);
        }

        if ((256 + 0x0e) == data) {
          /* backspace, recover cursor by sapce, move back cursor 1 time */
          if (0 == key_to) {
            if (cursor_x > 8) {
              drawstring_and_refresh(win_layer, cursor_x, 28, 
                  COLOR8_000000, COLOR8_FFFFFF, " ", 1);
              cursor_x -= 8;
            }
          }
          else 
            fifo_put(&task_cons->fifo, 8 + 256);
        }

        if ((256 + 0x0f) == data) {
          /* TAB */
          if (0 == key_to) {
            key_to = 1;
            make_title8(win_buf, win_layer->w_size, "TASK-A", 0);
            make_title8(cons_buf, cons_layer->w_size, "Console", 1);
            cursor_c = -1;  /* don't show the cursor */
            fill_box8(win_layer->buf, win_layer->w_size, 
                COLOR8_FFFFFF, cursor_x, 28, cursor_x + 7, 43);
          }
          else {
            key_to = 0;
            make_title8(win_buf, win_layer->w_size, "TASK-A", 1);
            make_title8(cons_buf, cons_layer->w_size, "Console", 0);
            cursor_c = COLOR8_000000; /* show the cursor */
          }
          layers_refresh(win_layer, 0, 0, win_layer->w_size, 21);
          layers_refresh(cons_layer, 0, 0, cons_layer->w_size, 21);
        }
        if ((256 + 0x2a) == data) /* left shift down */
          key_shift |= 1;
        if ((256 + 0x36) == data) /* right shift down */
          key_shift |= 2;
        if ((256 + 0xaa) == data) /* left shift up */
          key_shift &= ~1;
        if ((256 + 0xb6) == data) /* right shift up */
          key_shift &= ~2;
        if ((256 + 0x3a) == data) { /* CapsLock */
          key_leds ^= 4;
          fifo_put(&keycmd, KEYCMD_LED);
          fifo_put(&keycmd, key_leds);
        }
        if ((256 + 0x45) == data) { /* NumLock */
          key_leds ^= 2;
          fifo_put(&keycmd, KEYCMD_LED);
          fifo_put(&keycmd, key_leds);
        }
        if ((256 + 0x46) == data) { /* ScrollLock */
          key_leds ^= 1;
          fifo_put(&keycmd, KEYCMD_LED);
          fifo_put(&keycmd, key_leds);
        }
        if ((256 + 0xfa) == data)   /* keyboard recevie data success */
          keycmd_wait = -1;
        if ((256 + 0xfe) == data) { /* keyboard recevie data failed */
          wait_kbc_sendready();
          io_out8(PORT_KEYDATA, keycmd_wait);
        }

        /* show cursor again */
        if (cursor_c >= 0) {
          fill_box8(win_layer->buf, win_layer->w_size, 
              cursor_c, cursor_x, 28, cursor_x + 7, 43);
        }
        layers_refresh(win_layer, cursor_x, 28, cursor_x + 8, 44);
      }
      else if (512 <= data && data <= 767) {
        if (0 != mouse_decode(&mdec, data - 512)) {
          /* show all mouse bytes code */
          sprintf(debug_info, "[lcr %4d %4d]", mdec.x, mdec.y);
          if (0 != (mdec.state & 0x01)) 
            debug_info[1] = 'L';
          if (0 != (mdec.state & 0x02))
            debug_info[3] = 'R';
          if (0 != (mdec.state & 0x04))
            debug_info[2] = 'C';
          drawstring_and_refresh(back_layer, 32, 16, 
              COLOR8_FFFFFF, COLOR8_848484, debug_info, 15);

          mouse_x += mdec.x;
          mouse_y += mdec.y;

          if (mouse_x < 0)
            mouse_x = 0;
          if (mouse_y < 0)
            mouse_y = 0;
          if (mouse_x > binfo->screen_x - 1)
            mouse_x = binfo->screen_x - 1;
          if (mouse_y > binfo->screen_y - 1)
            mouse_y = binfo->screen_y - 1;

          sprintf(debug_info, "(%3d, %3d)", mouse_x, mouse_y);
          drawstring_and_refresh(back_layer, 0, 0, 
              COLOR8_FFFFFF, COLOR8_848484, debug_info, 10);
          layer_slide(mouse_layer, mouse_x, mouse_y);

          if (0 != (mdec.state & 0x01)) {
            /* down left click, move window */
            layer_slide(win_layer, mouse_x - 80, mouse_y - 8);
          }
        }
      }
      else if (data <= 1) { /* timer by cursor */
        if (0 != data) {
          timer_init(timer, &fifo, 0);
          if (cursor_c >= 0)
            cursor_c = COLOR8_000000;
        }
        else {
          timer_init(timer, &fifo, 1);
          if (cursor_c >= 0)
            cursor_c = COLOR8_FFFFFF;
        }
        timer_settimer(timer, 50);
        
        if (cursor_c >= 0) {
          fill_box8(win_layer->buf, win_layer->w_size, 
              cursor_c, cursor_x, 28, cursor_x + 7, 43);
          layers_refresh(win_layer, cursor_x, 28, cursor_x + 8, 44);
        }
      }
    }
  }
}
Exemplo n.º 9
0
void 
HariMain(void)
{
  boot_info_t* binfo = (boot_info_t*)ADR_BOOTINFO;
  fifo32_t fifo;
  int  fifobuf[128];
  char debug_info[64];
  timer_t* timer1;
  timer_t* timer2;
  timer_t* timer3;
  int mouse_x, mouse_y;
  int data;
  mouse_dec_t mdec;
  unsigned int memory_total;
  mem_mgr_t* mem_mgr = (mem_mgr_t*)MEMMGR_ADDR;
  layer_mgr_t* layer_mgr;
  layer_t* back_layer;
  layer_t* mouse_layer;
  layer_t* win_layer;
  unsigned char* back_buf;
  unsigned char  mouse_buf[256];
  unsigned char* win_buf;
  unsigned int count = 0;

  init_gdt_idt();
  init_pic();
  io_sti();   /* after initialize IDT/PIC, allow all CPU's interruptors */

  fifo_init(&fifo, fifobuf, 128);
  init_pit(); /* initialize programmable interval timer */
  init_keyboard(&fifo, 256);
  enable_mouse(&fifo, 512, &mdec);
  io_out8(PIC0_IMR, 0xf8);  /* set PIT/PIC1/keyboard permission 11111000 */
  io_out8(PIC1_IMR, 0xef);  /* set mouse permission 11101111 */

  timer1 = timer_alloc();
  timer_init(timer1, &fifo, 10);
  timer_settimer(timer1, 1000);

  timer2 = timer_alloc();
  timer_init(timer2, &fifo, 3);
  timer_settimer(timer2, 300);

  timer3 = timer_alloc();
  timer_init(timer3, &fifo, 1);
  timer_settimer(timer3, 50);

  memory_total = memory_test(0x00400000, 0xbfffffff);
  mem_mgr_init(mem_mgr);
  mem_mgr_free(mem_mgr, 0x00001000, 0x0009e000);  /*0x00001000~0x0009e000*/
  mem_mgr_free(mem_mgr, 0x00400000, memory_total - 0x00400000);

  init_palette();
  layer_mgr = layer_mgr_init(mem_mgr, binfo->vram, 
      binfo->screen_x, binfo->screen_y);
  back_layer = layer_alloc(layer_mgr);
  mouse_layer = layer_alloc(layer_mgr);
  win_layer = layer_alloc(layer_mgr);
  back_buf = (unsigned char*)mem_mgr_alloc_4k(mem_mgr, 
      binfo->screen_x * binfo->screen_y);
  win_buf = (unsigned char*)mem_mgr_alloc_4k(mem_mgr, 160 * 52);
  layer_setbuf(back_layer, back_buf, 
      binfo->screen_x, binfo->screen_y, -1);
  layer_setbuf(mouse_layer, mouse_buf, 16, 16, 99);
  layer_setbuf(win_layer, win_buf, 160, 52, -1);
  init_screen(back_buf, binfo->screen_x, binfo->screen_y);
  init_mouse_cursor8(mouse_buf, 99);
  make_window8(win_buf, 160, 52, "Counter");
  layer_slide(back_layer, 0, 0);
  mouse_x = (binfo->screen_x - 16) / 2;
  mouse_y = (binfo->screen_y - 28 - 16) / 2;
  layer_slide(mouse_layer, mouse_x, mouse_y);
  layer_slide(win_layer, 80, 72);
  layer_updown(back_layer, 0);
  layer_updown(win_layer, 1);
  layer_updown(mouse_layer, 2);
  sprintf(debug_info, "(%3d, %3d)", mouse_x, mouse_y);
  drawstring_and_refresh(back_layer, 0, 0, 
      COLOR8_FFFFFF, COLOR8_848484, debug_info, 10);

  sprintf(debug_info, "memory total: %dMB, free space: %dKB", 
      memory_total / (1024 * 1024), mem_mgr_total(mem_mgr) / 1024);
  drawstring_and_refresh(back_layer, 0, 32, 
      COLOR8_FFFFFF, COLOR8_848484, debug_info, 40);

  for ( ; ; ) {
    /*
    sprintf(debug_info, "%010d", g_timerctl.count);
    drawstring_and_refresh(win_layer, 40, 28, 
        COLOR8_000000, COLOR8_C6C6C6, debug_info, 10);
     */
    ++count;

    io_cli();
    if (0 == fifo_size(&fifo))
      io_sti();
    else {
      data = fifo_get(&fifo);
      io_sti();

      if (256 <= data && data <= 511) {
          sprintf(debug_info, "%02X", data - 256);
          drawstring_and_refresh(back_layer, 0, 16, 
              COLOR8_FFFFFF, COLOR8_848484, debug_info, 2);
      }
      else if (512 <= data && data <= 767) {
        if (0 != mouse_decode(&mdec, data - 512)) {
          /* show all mouse bytes code */
          sprintf(debug_info, "[lcr %4d %4d]", mdec.x, mdec.y);
          if (0 != (mdec.state & 0x01)) 
            debug_info[1] = 'L';
          if (0 != (mdec.state & 0x02))
            debug_info[3] = 'R';
          if (0 != (mdec.state & 0x04))
            debug_info[2] = 'C';
          drawstring_and_refresh(back_layer, 32, 16, 
              COLOR8_FFFFFF, COLOR8_848484, debug_info, 15);

          mouse_x += mdec.x;
          mouse_y += mdec.y;

          if (mouse_x < 0)
            mouse_x = 0;
          if (mouse_y < 0)
            mouse_y = 0;
          if (mouse_x > binfo->screen_x - 1)
            mouse_x = binfo->screen_x - 1;
          if (mouse_y > binfo->screen_y - 1)
            mouse_y = binfo->screen_y - 1;

          sprintf(debug_info, "(%3d, %3d)", mouse_x, mouse_y);
          drawstring_and_refresh(back_layer, 0, 0, 
              COLOR8_FFFFFF, COLOR8_848484, debug_info, 10);
          layer_slide(mouse_layer, mouse_x, mouse_y);
        }
      }
      else if (10 == data) {
        drawstring_and_refresh(back_layer, 0, 64, 
            COLOR8_FFFFFF, COLOR8_848484, "10[sec]", 7);

        sprintf(debug_info, "%010d", count);
        drawstring_and_refresh(win_layer, 40, 28, 
            COLOR8_000000, COLOR8_C6C6C6, debug_info, 10);
      }
      else if (3 == data) {
        drawstring_and_refresh(back_layer, 0, 80, 
            COLOR8_FFFFFF, COLOR8_848484, "03[sec]", 7);

        count = 0;
      }
      else if (1 == data) {
        timer_init(timer3, &fifo, 0);
        fill_box8(back_buf, binfo->screen_x, 
            COLOR8_FFFFFF, 8, 96, 15, 111);
        timer_settimer(timer3, 50);
        layers_refresh(back_layer, 8, 96, 16, 112);
      }
      else if (0 == data) {
        timer_init(timer3, &fifo, 1);
        fill_box8(back_buf, binfo->screen_x, 
            COLOR8_848484, 8, 96, 15, 111);
        timer_settimer(timer3, 50);
        layers_refresh(back_layer, 8, 96, 16, 112);
      }
    }
  }
}
Exemplo n.º 10
0
void 
HariMain(void)
{
  boot_info_t* binfo = (boot_info_t*)ADR_BOOTINFO;
  fifo32_t fifo;
  int  fifobuf[128];
  char debug_info[64];
  int mouse_x, mouse_y, cursor_x, cursor_c;
  int data;
  int i;
  mouse_dec_t mdec;
  unsigned int memory_total;
  mem_mgr_t* mem_mgr = (mem_mgr_t*)MEMMGR_ADDR;
  layer_mgr_t* layer_mgr;
  layer_t* back_layer;
  layer_t* mouse_layer;
  layer_t* win_layer;
  layer_t* win_layer_b[3];
  unsigned char* back_buf;
  unsigned char  mouse_buf[256];
  unsigned char* win_buf;
  unsigned char* win_buf_b;
  static char s_keytable[0x54] = {
    0,   0,   '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=',
    0,   0,   'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '[', ']', 
    0,   0,   'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ';', '\'','`', 
    0,   '\\','Z', 'X', 'C', 'V', 'B', 'N', 'M', ',', '.', '/', 0,   '*', 
    0,   ' ', 0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 
    0,   '7', '8', '9', '-', '4', '5', '6', '+', '1', '2', '3', '0', '.'
  };
  task_t* task_a;
  task_t* task_b[3];
  timer_t* timer;


  init_gdt_idt();
  init_pic();
  io_sti();   /* after initialize IDT/PIC, allow all CPU's interruptors */

  fifo_init(&fifo, fifobuf, 128, 0);
  init_pit(); /* initialize programmable interval timer */
  init_keyboard(&fifo, 256);
  enable_mouse(&fifo, 512, &mdec);
  io_out8(PIC0_IMR, 0xf8);  /* set PIT/PIC1/keyboard permission 11111000 */
  io_out8(PIC1_IMR, 0xef);  /* set mouse permission 11101111 */

  memory_total = memory_test(0x00400000, 0xbfffffff);
  mem_mgr_init(mem_mgr);
  mem_mgr_free(mem_mgr, 0x00001000, 0x0009e000);  /*0x00001000~0x0009e000*/
  mem_mgr_free(mem_mgr, 0x00400000, memory_total - 0x00400000);

  init_palette();
  layer_mgr = layer_mgr_init(mem_mgr, binfo->vram, 
      binfo->screen_x, binfo->screen_y);
  task_a = task_init(mem_mgr);
  fifo.task = task_a;
  task_run(task_a, 1, 2);

  /* back layer */
  back_layer = layer_alloc(layer_mgr);
  back_buf = (unsigned char*)mem_mgr_alloc_4k(mem_mgr, 
      binfo->screen_x * binfo->screen_y);
  layer_setbuf(back_layer, back_buf, 
      binfo->screen_x, binfo->screen_y, -1);
  init_screen(back_buf, binfo->screen_x, binfo->screen_y);

  /* window layer b */
  for (i = 0; i < 3; ++i) {
    win_layer_b[i] = layer_alloc(layer_mgr);
    win_buf_b = (unsigned char*)mem_mgr_alloc_4k(mem_mgr, 144 * 52);
    layer_setbuf(win_layer_b[i], win_buf_b, 144, 52, -1); /* transparent */
    sprintf(debug_info, "TASK-B%d", i);
    make_window8(win_buf_b, 144, 52, debug_info, 0);
    task_b[i] = task_alloc();
    task_b[i]->tss.esp = 
      mem_mgr_alloc_4k(mem_mgr, 64 * 1024) + 64 * 1024 - 8;
    task_b[i]->tss.eip = (int)&task_b_main;
    task_b[i]->tss.es  = 1 * 8;
    task_b[i]->tss.cs  = 2 * 8;
    task_b[i]->tss.ss  = 1 * 8;
    task_b[i]->tss.ds  = 1 * 8;
    task_b[i]->tss.fs  = 1 * 8;
    task_b[i]->tss.gs  = 1 * 8;
    *((int*)(task_b[i]->tss.esp + 4)) = (int)win_layer_b[i];
    task_run(task_b[i], 2, i + 1);
  }
  
  /* window layer */
  win_layer = layer_alloc(layer_mgr);
  win_buf = (unsigned char*)mem_mgr_alloc_4k(mem_mgr, 160 * 52);
  layer_setbuf(win_layer, win_buf, 144, 52, -1);
  make_window8(win_buf, 144, 52, "TASK-A", 1);
  make_text8(win_layer, 8, 28, 128, 16, COLOR8_FFFFFF);
  cursor_x = 8;
  cursor_c = COLOR8_FFFFFF;
  timer = timer_alloc();
  timer_init(timer, &fifo, 1);
  timer_settimer(timer, 50);

  /* mouse layer */
  mouse_layer = layer_alloc(layer_mgr);
  layer_setbuf(mouse_layer, mouse_buf, 16, 16, 99);
  init_mouse_cursor8(mouse_buf, 99);
  mouse_x = (binfo->screen_x - 16) / 2;
  mouse_y = (binfo->screen_y - 28 - 16) / 2;

  layer_slide(back_layer, 0, 0);
  layer_slide(win_layer_b[0], 168, 56);
  layer_slide(win_layer_b[1], 8, 116);
  layer_slide(win_layer_b[2], 168, 116);
  layer_slide(win_layer, 8, 56);
  layer_slide(mouse_layer, mouse_x, mouse_y);
  layer_updown(back_layer, 0);
  layer_updown(win_layer_b[0], 1);
  layer_updown(win_layer_b[1], 2);
  layer_updown(win_layer_b[2], 3);
  layer_updown(win_layer, 4);
  layer_updown(mouse_layer, 5);
  sprintf(debug_info, "(%3d, %3d)", mouse_x, mouse_y);
  drawstring_and_refresh(back_layer, 0, 0, 
      COLOR8_FFFFFF, COLOR8_848484, debug_info, 10);

  sprintf(debug_info, "memory total: %dMB, free space: %dKB", 
      memory_total / (1024 * 1024), mem_mgr_total(mem_mgr) / 1024);
  drawstring_and_refresh(back_layer, 0, 32, 
      COLOR8_FFFFFF, COLOR8_848484, debug_info, 40);


  for ( ; ; ) {
    io_cli();

    if (0 == fifo_size(&fifo)) {
      task_sleep(task_a);
      io_sti();
    }
    else {
      data = fifo_get(&fifo);
      io_sti();

      if (256 <= data && data <= 511) {
        sprintf(debug_info, "%02X", data - 256);
        drawstring_and_refresh(back_layer, 0, 16, 
            COLOR8_FFFFFF, COLOR8_848484, debug_info, 2);

        if (data < (256 + 0x54)) {
          if (0 != s_keytable[data - 256] && cursor_x < 128) {
            /* normal character, show 1 character, move cursor 1 time */
            debug_info[0] = s_keytable[data - 256];
            debug_info[1] = 0;
            drawstring_and_refresh(win_layer, cursor_x, 28, 
                COLOR8_000000, COLOR8_FFFFFF, debug_info, 1);
            cursor_x += 8;
          }
        }
        if ((256 + 0x0e) == data && cursor_x > 8) {
          /* backspace, recover cursor by sapce, move back cursor 1 time */
          drawstring_and_refresh(win_layer, cursor_x, 28, 
              COLOR8_000000, COLOR8_FFFFFF, " ", 1);
          cursor_x -= 8;
        }
        /* show cursor again */
        fill_box8(win_layer->buf, win_layer->w_size, 
            cursor_c, cursor_x, 28, cursor_x + 7, 43);
        layers_refresh(win_layer, cursor_x, 28, cursor_x + 8, 44);
      }
      else if (512 <= data && data <= 767) {
        if (0 != mouse_decode(&mdec, data - 512)) {
          /* show all mouse bytes code */
          sprintf(debug_info, "[lcr %4d %4d]", mdec.x, mdec.y);
          if (0 != (mdec.state & 0x01)) 
            debug_info[1] = 'L';
          if (0 != (mdec.state & 0x02))
            debug_info[3] = 'R';
          if (0 != (mdec.state & 0x04))
            debug_info[2] = 'C';
          drawstring_and_refresh(back_layer, 32, 16, 
              COLOR8_FFFFFF, COLOR8_848484, debug_info, 15);

          mouse_x += mdec.x;
          mouse_y += mdec.y;

          if (mouse_x < 0)
            mouse_x = 0;
          if (mouse_y < 0)
            mouse_y = 0;
          if (mouse_x > binfo->screen_x - 1)
            mouse_x = binfo->screen_x - 1;
          if (mouse_y > binfo->screen_y - 1)
            mouse_y = binfo->screen_y - 1;

          sprintf(debug_info, "(%3d, %3d)", mouse_x, mouse_y);
          drawstring_and_refresh(back_layer, 0, 0, 
              COLOR8_FFFFFF, COLOR8_848484, debug_info, 10);
          layer_slide(mouse_layer, mouse_x, mouse_y);

          if (0 != (mdec.state & 0x01)) {
            /* down left click, move window */
            layer_slide(win_layer, mouse_x - 80, mouse_y - 8);
          }
        }
      }
      else if (data <= 1) { /* timer by cursor */
        if (0 != data) {
          timer_init(timer, &fifo, 0);
          cursor_c = COLOR8_000000;
        }
        else {
          timer_init(timer, &fifo, 1);
          cursor_c = COLOR8_FFFFFF;
        }
        timer_settimer(timer, 50);
        fill_box8(win_layer->buf, win_layer->w_size, 
            cursor_c, cursor_x, 28, cursor_x + 7, 43);
        layers_refresh(win_layer, cursor_x, 28, cursor_x + 8, 44);
      }
    }
  }
}
Exemplo n.º 11
0
/* do_testd_ram 
 * args
 *  cmd_tbl_t: not used
 *  flag: not used
 *  argc: number of arguments passed on command line
 *  argv: array of arguments passed on command line
 * This function tests the ram according to arguments passed on
 * the command line: start_addr end_addr pattern iterations
 * The arguments are optional as they all have defaults. */
int do_testd_ram(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
   vu_long start_addr, end_addr, pattern;
   int    iterations;
   int    result = TESTD_PASS;
   int    i;
   char   c;

   if(argc < 2) {
       start_addr = RamArray[0].start_addr;
   }
   else {
       start_addr = simple_strtoul(argv[1], NULL, 16);
   }

   if(argc < 3) {
       /* Set default */
       end_addr = RamArray[0].end_addr;
   }
   else {
       end_addr = simple_strtoul(argv[2], NULL, 16);
   }

   if(argc < 4) {
      /* Use the default pattern */
      pattern = PatternArray[0];
   } 
   else {
      pattern = simple_strtoul(argv[3], NULL, 16);
   }
   /* Default to 1 iteration if iterations is not passed */
   if(argc < 5) {
      iterations = 1;
   }
   else {
      iterations = simple_strtoul(argv[4], NULL, 10);
   }

   /* Range check start_addr end_addr */
   if(start_addr < RamArray[1].start_addr || start_addr > RamArray[1].end_addr) {
      printf("start_addr %.08x outside of range [%.08x:%.08x]\n", 
            (unsigned int)start_addr, (unsigned int)RamArray[1].start_addr, (unsigned int)RamArray[1].end_addr);
      return 0;
   }
   if(end_addr < RamArray[1].start_addr || end_addr > RamArray[1].end_addr) {
      printf("end_addr %.08x outside of range [%.08x:%.08x]\n", 
            (unsigned int)end_addr, (unsigned int)RamArray[1].start_addr, (unsigned int)RamArray[1].end_addr);
   }
   if(end_addr < start_addr) {
      printf("end_addr %.08x must be greater than start_addr %.08x\n", 
            (unsigned int)end_addr, (unsigned int)start_addr);
      return TESTD_FAIL;
   }

   /* Run Test iterations */
   printf("ROM test from %.08x to %.08x with pattern %.08x for %d iterations\n", 
         (unsigned int)start_addr, (unsigned int)end_addr, (unsigned int)pattern, (unsigned int)iterations);
   if(iterations > 1) {
      printf("Press ESC to exit\n");
   }
   for(i = 0; i < iterations; i++) {
     result = memory_test(start_addr, end_addr, pattern);
     /* check for escape character */
     c = tstc() ? getc() : '\0';
     if((result == TESTD_FAIL) || (c == 0x1B)) {
         break;
     }
   }
   if(result == TESTD_PASS) {
      printf("completed %d iterations successfully\n", i);
   }
   else {
      printf("completed %d iterations test failed\n", i);
   }
   return result;
}
Exemplo n.º 12
0
//int main(int argc, char * argv)
int test_diags(cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
{
    int result;
    int loopCount;
    int failCount;
    int stopLoop;
    int done     = 0;
    char c;

    r_index  = 0;
    p_index  = 0;
    fl_index = 0;
    sd_index = 0;
    Testd_status[0] = '\0';

    do {
        display_testd_menu();
        switch(testd_get_input()) {
            case '1':
                failCount = loopCount = 0;
                stopLoop = !Testd_loop;
                do {
                    result = memory_test(RamArray[r_index].start_addr, 
                        RamArray[r_index].end_addr, 
                        PatternArray[p_index]);
                    loopCount++;
                    if(result == TESTD_FAIL) {
                        failCount++;
                    }
                   /* if necessary process the character is it an ESC */
                   if(!stopLoop && tstc()) {
                       c = getc();
                       if(c == 0x1B) {
                           stopLoop = 1;
                       }
                   }
                } while(!stopLoop);
                if(failCount) {
                    sprintf(Testd_status, 
                            "Status: RAM TEST FAIL failed %d of %d\n", 
                            failCount, loopCount );
                }
                else {
                   sprintf(Testd_status, 
                           "Status: RAM TEST PASS %d iterations\n", 
                           loopCount );
                }
                break;
            case 'a':
            case 'A':
                r_index++;
                r_index %= NUM_RAM_ADDRS;
                break;
            case '2':
                failCount = loopCount = 0;
                stopLoop = !Testd_loop;
                do {
                    result = testd_flash_test(FlArray[fl_index].start_addr, 
                            FlArray[fl_index].end_addr,
                            PatternArray[p_index]);
                    loopCount++;
                    if(result == TESTD_FAIL) {
                        failCount++;
                    }
                   /* if necessary process the character is it an ESC */
                   if(!stopLoop && tstc()) {
                       c = getc();
                       if(c == 0x1B) {
                           stopLoop = 1;
                       }
                   }
                } while(!stopLoop);
                if(failCount) {
                    sprintf(Testd_status, 
                            "Status: ROM TEST FAIL failed %d of %d\n", 
                            failCount, loopCount );
                }
                else {
                   sprintf(Testd_status, 
                           "Status: ROM TEST PASS %d iterations\n", 
                           loopCount );
                }
                break;
            case 'f':
            case 'F':
                fl_index = ++fl_index % NUM_FL_ADDRS;
                break;
            case 'p':
            case 'P':
                p_index++;
                p_index %= NUM_PATTERNS;
                break;
            case 'L':
            case 'l':
                testd_toggle_loop();
                break;
            case 'q':
            case 'Q':
                done = 1; // exit loop
                break;
            default:
                testd_print_inv();
                break;
        }
    }
    while(!done);
    printf("\n");
    return 0;
}
void wlan_mac_util_init( u32 type, u32 eth_dev_num ){
	int            Status;
    u32            i;
	u32            gpio_read;
	u32            queue_len;
	u64            timestamp;
	u32            log_size;
	tx_frame_info* tx_mpdu;

    // Initialize callbacks
	eth_rx_callback         = (function_ptr_t)nullCallback;
	mpdu_rx_callback        = (function_ptr_t)nullCallback;
	fcs_bad_rx_callback     = (function_ptr_t)nullCallback;
	mpdu_tx_done_callback   = (function_ptr_t)nullCallback;
	pb_u_callback           = (function_ptr_t)nullCallback;
	pb_m_callback           = (function_ptr_t)nullCallback;
	pb_d_callback           = (function_ptr_t)nullCallback;
	uart_callback           = (function_ptr_t)nullCallback;
	ipc_rx_callback         = (function_ptr_t)nullCallback;
	check_queue_callback    = (function_ptr_t)nullCallback;
	mpdu_tx_accept_callback = (function_ptr_t)nullCallback;

	wlan_mac_ipc_init();

	for(i=0;i < NUM_TX_PKT_BUFS; i++){
		tx_mpdu = (tx_frame_info*)TX_PKT_BUF_TO_ADDR(i);
		tx_mpdu->state = TX_MPDU_STATE_EMPTY;
	}

	tx_pkt_buf = 0;

#ifdef _DEBUG_
	xil_printf("locking tx_pkt_buf = %d\n", tx_pkt_buf);
#endif

	if(lock_pkt_buf_tx(tx_pkt_buf) != PKT_BUF_MUTEX_SUCCESS){
		warp_printf(PL_ERROR,"Error: unable to lock pkt_buf %d\n",tx_pkt_buf);
	}

	tx_mpdu = (tx_frame_info*)TX_PKT_BUF_TO_ADDR(tx_pkt_buf);
	tx_mpdu->state = TX_MPDU_STATE_TX_PENDING;

	//Initialize the central DMA (CDMA) driver
	XAxiCdma_Config *cdma_cfg_ptr;
	cdma_cfg_ptr = XAxiCdma_LookupConfig(XPAR_AXI_CDMA_0_DEVICE_ID);
	Status = XAxiCdma_CfgInitialize(&cdma_inst, cdma_cfg_ptr, cdma_cfg_ptr->BaseAddress);
	if (Status != XST_SUCCESS) {
		warp_printf(PL_ERROR,"Error initializing CDMA: %d\n", Status);
	}
	XAxiCdma_IntrDisable(&cdma_inst, XAXICDMA_XR_IRQ_ALL_MASK);


	Status = XGpio_Initialize(&Gpio, GPIO_DEVICE_ID);
	gpio_timestamp_initialize();

	if (Status != XST_SUCCESS) {
		warp_printf(PL_ERROR, "Error initializing GPIO\n");
		return;
	}

	Status = XUartLite_Initialize(&UartLite, UARTLITE_DEVICE_ID);
	if (Status != XST_SUCCESS) {
		warp_printf(PL_ERROR, "Error initializing XUartLite\n");
		return;
	}


	gpio_read = XGpio_DiscreteRead(&Gpio, GPIO_INPUT_CHANNEL);
	if(gpio_read&GPIO_MASK_DRAM_INIT_DONE){
		xil_printf("DRAM SODIMM Detected\n");
		if(memory_test()==0){
			queue_dram_present(1);
			dram_present = 1;
		} else {
			queue_dram_present(0);
			dram_present = 0;
		}
	} else {
		queue_dram_present(0);
		dram_present = 0;
		timestamp = get_usec_timestamp();

		while((get_usec_timestamp() - timestamp) < 100000){
			if((XGpio_DiscreteRead(&Gpio, GPIO_INPUT_CHANNEL)&GPIO_MASK_DRAM_INIT_DONE)){
				xil_printf("DRAM SODIMM Detected\n");
				if(memory_test()==0){
					queue_dram_present(1);
					dram_present = 1;
				} else {
					queue_dram_present(0);
					dram_present = 0;
				}
				break;
			}
		}
	}

	queue_len = queue_init();

	if( dram_present ) {
		//The event_list lives in DRAM immediately following the queue payloads.
		if(MAX_EVENT_LOG == -1){
			log_size = (DDR3_SIZE - queue_len);
		} else {
			log_size = min( (DDR3_SIZE - queue_len), MAX_EVENT_LOG );
		}

		event_log_init( (void*)(DDR3_BASEADDR + queue_len), log_size );

	} else {
		log_size = 0;
	}

#ifdef USE_WARPNET_WLAN_EXP
	// Communicate the log size to WARPNet
	node_info_set_event_log_size( log_size );
#endif

	wlan_eth_init();

	//Set direction of GPIO channels
	XGpio_SetDataDirection(&Gpio, GPIO_INPUT_CHANNEL, 0xFFFFFFFF);
	XGpio_SetDataDirection(&Gpio, GPIO_OUTPUT_CHANNEL, 0);


	Status = XTmrCtr_Initialize(&TimerCounterInst, TMRCTR_DEVICE_ID);
	if (Status != XST_SUCCESS) {
		xil_printf("XTmrCtr failed to initialize\n");
		return;
	}

	//Set the handler for Timer
	XTmrCtr_SetHandler(&TimerCounterInst, timer_handler, &TimerCounterInst);

	//Enable interrupt of timer and auto-reload so it continues repeatedly
	XTmrCtr_SetOptions(&TimerCounterInst, TIMER_CNTR_FAST, XTC_DOWN_COUNT_OPTION | XTC_INT_MODE_OPTION);
	XTmrCtr_SetOptions(&TimerCounterInst, TIMER_CNTR_SLOW, XTC_DOWN_COUNT_OPTION | XTC_INT_MODE_OPTION);

	timer_running[TIMER_CNTR_FAST] = 0;
	timer_running[TIMER_CNTR_SLOW] = 0;
    
    // Get the type of node from the input parameter
    hw_info.type              = type;
    hw_info.wn_exp_eth_device = eth_dev_num;
    
#ifdef USE_WARPNET_WLAN_EXP
    // We cannot initialize WARPNet until after the lower CPU sends all the HW information to us through the IPC call
    warpnet_initialized = 0;
#endif
    
    wlan_mac_ltg_sched_init();

}
Exemplo n.º 14
0
int main()
{ int menu_option=0;
  srand(time(NULL));
  time_t rawtime;
  struct tm * timeinfo;
  time ( &rawtime );
  timeinfo = localtime ( &rawtime );

      time (&start);
      while(1)
      {   single.error=0;
          system("cls");  
          printf("Fidei Engine v0.96 - Beta\n"
		         "-------------------------\n\n"); 
          printf("Enter 1 to check contact list is correct.\n"
                 "Enter 2 to convert contact list into the rating list.\n"
                 "Enter 3 to perform centrality calculation and save centrality results.\n"
                 "Enter 4 to perform stages 1 - 3 automatically.\n"
                 "Enter 5 to find a user's own rating score.\n"
                 "Enter 6 to find a company's score.\n"
                 "Enter 99 to exit.\n");
          scanf("%d",&menu_option);
          switch(menu_option)
          {
              case 1: check_contact_list ();
                   break;
              case 2: convert_contact_list();
                   break;
              case 3: 
                   find_m_n();
                   memory_input();   
                   memory_test();   
                   memory_control();
                    
                    if (single.harddrive_flag==0)
                    {memory_matrix();
                    }//end if loop
                    if (single.harddrive_flag==1)
                    {harddrive_matrix();
                    }//end if loop
                    export_results();
              
                  time (&end);
                  single.time_taken = difftime (end, start);
                  printf("Processing time was: %4.0f seconds. \n",single.time_taken);
            	  getchar();
            	  free_memory();	
                   //insert functions
                   break;
              case 4: 
                   //insert case 1 and 2 functions
                   check_contact_list ();
                   convert_contact_list();
                   find_m_n();
                   memory_input();
                   memory_test();        
                   memory_control();
                    
                    if (single.harddrive_flag==0)
                    {memory_matrix();
                    }//end if loop
                    if (single.harddrive_flag==1)
                    {harddrive_matrix();
                    }//end if loop
                    export_results();
              
                  time (&end);
                  single.time_taken = difftime (end, start);
                  printf("Processing time was: %4.0f seconds. \n",single.time_taken);
            	  getchar();
            	  free_memory();	
                   break;
              case 5: find_users_score();
                   break;
              case 6: company_rating();
                   break;
              case 99: exit(1);
              
              default: printf("\n\nYou have not chosen a valid selection. Please re-try.\n\n");
                       getchar();
                       system("cls");
                       break; 
          }//end switch
       }//end while loop
};//end main
Exemplo n.º 15
0
void 
HariMain(void)
{
  boot_info_t* binfo = (boot_info_t*)ADR_BOOTINFO;
  fifo32_t fifo;
  int  fifobuf[128];
  char debug_info[64];
  timer_t* timer1;
  timer_t* timer2;
  timer_t* timer3;
  int mouse_x, mouse_y, cursor_x, cursor_c, task_b_esp;
  int data;
  mouse_dec_t mdec;
  unsigned int memory_total;
  mem_mgr_t* mem_mgr = (mem_mgr_t*)MEMMGR_ADDR;
  layer_mgr_t* layer_mgr;
  layer_t* back_layer;
  layer_t* mouse_layer;
  layer_t* win_layer;
  unsigned char* back_buf;
  unsigned char  mouse_buf[256];
  unsigned char* win_buf;
  static char s_keytable[0x54] = {
    0,   0,   '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '-', '=',
    0,   0,   'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', '[', ']', 
    0,   0,   'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', ';', '\'','`', 
    0,   '\\','Z', 'X', 'C', 'V', 'B', 'N', 'M', ',', '.', '/', 0,   '*', 
    0,   ' ', 0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0,   0, 
    0,   '7', '8', '9', '-', '4', '5', '6', '+', '1', '2', '3', '0', '.'
  };
  tss32_t tss_a, tss_b;
  segment_descriptor_t* gdt = (segment_descriptor_t*)ADR_GDT;


  init_gdt_idt();
  init_pic();
  io_sti();   /* after initialize IDT/PIC, allow all CPU's interruptors */

  fifo_init(&fifo, fifobuf, 128);
  init_pit(); /* initialize programmable interval timer */
  init_keyboard(&fifo, 256);
  enable_mouse(&fifo, 512, &mdec);
  io_out8(PIC0_IMR, 0xf8);  /* set PIT/PIC1/keyboard permission 11111000 */
  io_out8(PIC1_IMR, 0xef);  /* set mouse permission 11101111 */

  set490(&fifo, 1);
  timer1 = timer_alloc();
  timer_init(timer1, &fifo, 10);
  timer_settimer(timer1, 1000);

  timer2 = timer_alloc();
  timer_init(timer2, &fifo, 3);
  timer_settimer(timer2, 300);

  timer3 = timer_alloc();
  timer_init(timer3, &fifo, 1);
  timer_settimer(timer3, 50);

  memory_total = memory_test(0x00400000, 0xbfffffff);
  mem_mgr_init(mem_mgr);
  mem_mgr_free(mem_mgr, 0x00001000, 0x0009e000);  /*0x00001000~0x0009e000*/
  mem_mgr_free(mem_mgr, 0x00400000, memory_total - 0x00400000);

  init_palette();
  layer_mgr = layer_mgr_init(mem_mgr, binfo->vram, 
      binfo->screen_x, binfo->screen_y);
  back_layer = layer_alloc(layer_mgr);
  mouse_layer = layer_alloc(layer_mgr);
  win_layer = layer_alloc(layer_mgr);
  back_buf = (unsigned char*)mem_mgr_alloc_4k(mem_mgr, 
      binfo->screen_x * binfo->screen_y);
  win_buf = (unsigned char*)mem_mgr_alloc_4k(mem_mgr, 160 * 52);
  layer_setbuf(back_layer, back_buf, 
      binfo->screen_x, binfo->screen_y, -1);
  layer_setbuf(mouse_layer, mouse_buf, 16, 16, 99);
  layer_setbuf(win_layer, win_buf, 160, 52, -1);
  init_screen(back_buf, binfo->screen_x, binfo->screen_y);
  init_mouse_cursor8(mouse_buf, 99);
  make_window8(win_buf, 160, 52, "Window");
  make_text8(win_layer, 8, 28, 144, 16, COLOR8_FFFFFF);
  cursor_x = 8;
  cursor_c = COLOR8_FFFFFF;
  layer_slide(back_layer, 0, 0);
  mouse_x = (binfo->screen_x - 16) / 2;
  mouse_y = (binfo->screen_y - 28 - 16) / 2;
  layer_slide(mouse_layer, mouse_x, mouse_y);
  layer_slide(win_layer, 80, 72);
  layer_updown(back_layer, 0);
  layer_updown(win_layer, 1);
  layer_updown(mouse_layer, 2);
  sprintf(debug_info, "(%3d, %3d)", mouse_x, mouse_y);
  drawstring_and_refresh(back_layer, 0, 0, 
      COLOR8_FFFFFF, COLOR8_848484, debug_info, 10);

  sprintf(debug_info, "memory total: %dMB, free space: %dKB", 
      memory_total / (1024 * 1024), mem_mgr_total(mem_mgr) / 1024);
  drawstring_and_refresh(back_layer, 0, 32, 
      COLOR8_FFFFFF, COLOR8_848484, debug_info, 40);


  tss_a.ldtr = 0;
  tss_a.iomap = 0x40000000;
  tss_b.ldtr = 0;
  tss_b.iomap = 0x40000000;
  set_segment_descriptor(gdt + 3, 103, (int)&tss_a, AR_TSS32);
  set_segment_descriptor(gdt + 4, 103, (int)&tss_b, AR_TSS32);
  load_tr(3 * 8);
  task_b_esp = mem_mgr_alloc_4k(mem_mgr, 64 * 1024) + 64 * 1024 - 8;
  tss_b.eip = (int)&task_b_main;
  tss_b.eflags = 0x00000202;  /* IF = 1 */
  tss_b.eax = 0;
  tss_b.ecx = 0;
  tss_b.edx = 0;
  tss_b.ebx = 0;
  tss_b.esp = task_b_esp;
  tss_b.ebp = 0;
  tss_b.esi = 0;
  tss_b.edi = 0;
  tss_b.es = 1 * 8;
  tss_b.cs = 2 * 8;
  tss_b.ss = 1 * 8;
  tss_b.ds = 1 * 8;
  tss_b.fs = 1 * 8;
  tss_b.gs = 1 * 8;
  *((int*)(task_b_esp + 4)) = (int)back_layer;
  mt_init();

  for ( ; ; ) {
    io_cli();

    if (0 == fifo_size(&fifo))
      io_stihlt();
    else {
      data = fifo_get(&fifo);
      io_sti();

      if (256 <= data && data <= 511) {
        sprintf(debug_info, "%02X", data - 256);
        drawstring_and_refresh(back_layer, 0, 16, 
            COLOR8_FFFFFF, COLOR8_848484, debug_info, 2);

        if (data < (256 + 0x54)) {
          if (0 != s_keytable[data - 256] && cursor_x < 144) {
            /* normal character, show 1 character, move cursor 1 time */
            debug_info[0] = s_keytable[data - 256];
            debug_info[1] = 0;
            drawstring_and_refresh(win_layer, cursor_x, 28, 
                COLOR8_000000, COLOR8_FFFFFF, debug_info, 1);
            cursor_x += 8;
          }
        }
        if ((256 + 0x0e) == data && cursor_x > 8) {
          /* backspace, recover cursor by sapce, move back cursor 1 time */
          drawstring_and_refresh(win_layer, cursor_x, 28, 
              COLOR8_000000, COLOR8_FFFFFF, " ", 1);
          cursor_x -= 8;
        }
        /* show cursor again */
        fill_box8(win_layer->buf, win_layer->w_size, 
            cursor_c, cursor_x, 28, cursor_x + 7, 43);
        layers_refresh(win_layer, cursor_x, 28, cursor_x + 8, 44);
      }
      else if (512 <= data && data <= 767) {
        if (0 != mouse_decode(&mdec, data - 512)) {
          /* show all mouse bytes code */
          sprintf(debug_info, "[lcr %4d %4d]", mdec.x, mdec.y);
          if (0 != (mdec.state & 0x01)) 
            debug_info[1] = 'L';
          if (0 != (mdec.state & 0x02))
            debug_info[3] = 'R';
          if (0 != (mdec.state & 0x04))
            debug_info[2] = 'C';
          drawstring_and_refresh(back_layer, 32, 16, 
              COLOR8_FFFFFF, COLOR8_848484, debug_info, 15);

          mouse_x += mdec.x;
          mouse_y += mdec.y;

          if (mouse_x < 0)
            mouse_x = 0;
          if (mouse_y < 0)
            mouse_y = 0;
          if (mouse_x > binfo->screen_x - 1)
            mouse_x = binfo->screen_x - 1;
          if (mouse_y > binfo->screen_y - 1)
            mouse_y = binfo->screen_y - 1;

          sprintf(debug_info, "(%3d, %3d)", mouse_x, mouse_y);
          drawstring_and_refresh(back_layer, 0, 0, 
              COLOR8_FFFFFF, COLOR8_848484, debug_info, 10);
          layer_slide(mouse_layer, mouse_x, mouse_y);

          if (0 != (mdec.state & 0x01)) {
            /* down left click, move window */
            layer_slide(win_layer, mouse_x - 80, mouse_y - 8);
          }
        }
      }
      else if (10 == data) {
        drawstring_and_refresh(back_layer, 0, 64, 
            COLOR8_FFFFFF, COLOR8_848484, "10[sec]", 7);
      }
      else if (3 == data) {
        drawstring_and_refresh(back_layer, 0, 80, 
            COLOR8_FFFFFF, COLOR8_848484, "03[sec]", 7);
      }
      else if (data <= 1) { /* timer by cursor */
        if (0 != data) {
          timer_init(timer3, &fifo, 0);
          cursor_c = COLOR8_000000;
        }
        else {
          timer_init(timer3, &fifo, 1);
          cursor_c = COLOR8_FFFFFF;
        }
        timer_settimer(timer3, 50);
        fill_box8(win_layer->buf, win_layer->w_size, 
            cursor_c, cursor_x, 28, cursor_x + 7, 43);
        layers_refresh(win_layer, cursor_x, 28, cursor_x + 8, 44);
      }
    }
  }
}