Beispiel #1
0
int kbd_test_leds(unsigned short n, unsigned short *leds) {
    int i = 0;
    unsigned char mask = 0;
    while (i < n) {
        mask ^= BIT(leds[i]);
        kbc_write2(SW_LEDS, mask);
        i++;
        // espera um segundo entre cada elemento do array, utilizando o timer
        timer_test_int(1);
    }
    return 0;
}
Beispiel #2
0
static int proc_args(int argc, char *argv[]) {

  unsigned long seconds, timer, freq;
  char *str;
  long num;

  /*check the function to test: if the first characters match, accept it */
  if (strncmp(argv[1], "timer", strlen("timer")) == 0) {
	  if( argc != 3 ) {
		  printf("wrong no of arguments for test of timer_test_config() \n");
		  return 1;
	  }
	  if( (timer = parse_ulong(argv[2], 10)) == ULONG_MAX )
	  		  return 1;
	  if(timer!=0 && timer!=1 && timer!=2){
		  printf("argument timer ranges from 0 to 2\n");
			  return 1;
	  }
	  printf("timer_test_config(%lu)\n",timer); /* Actually, it was already invoked */
	  timer_test_config(timer);
	  return 0;
  } else if (strncmp(argv[1], "freq", strlen("freq")) == 0) {
	  if( argc != 3 ) {
		  printf("wrong no of arguments for test of timer_test_square() \n");
		  return 1;
	  }
	  if( (freq = parse_ulong(argv[2], 10)) == ULONG_MAX )
	  		  return 1;
	  printf("timer_test_square(%lu)\n",freq);
	  timer_test_square(freq);
	  return 0;
  } else if (strncmp(argv[1], "chronometer", strlen("chronometer")) == 0) {
	  if( argc != 3 ) {
		  printf("wrong no of arguments for test of timer_test_int() \n");
		  return 1;
	  }
	  if( (seconds = parse_ulong(argv[2], 10)) == ULONG_MAX )
	  		  return 1;
	  printf("timer_test_int(%lu)\n",seconds);
	  timer_test_int(seconds);
	  return 0;
  }  else {
	  printf(" non valid function \"%s\" to test\n", argv[1]);
	  return 1;
  }
}
Beispiel #3
0
static int proc_args(int argc, char *argv[]) {

	unsigned long freq, timer, time;
	char *str;
	long num;

	if (strncmp(argv[1], "test_square", strlen("test_square")) == 0) {
		if (argc != 3) {
			printf(
					"lab2: wrong no of arguments for test of timer_test_square() \n");
			return 1;
		}
		if ((freq = parse_ulong(argv[2], 10)) == ULONG_MAX)
			return 1;
		printf("lab2::timer_test_square(%d)\n", (unsigned) freq);
		timer_test_square(freq);
		return 0;
	} else if (strncmp(argv[1], "test_config", strlen("test_config")) == 0) {
		if (argc != 3) {
			printf(
					"lab2: wrong no of arguments for test of timer_test_config() \n");
			return 1;
		}
		if ((timer = parse_ulong(argv[2], 16)) == ULONG_MAX)
			return 1;
		printf("lab2::timer_test_config(0x%X)\n", (unsigned) timer);
		timer_test_config(timer);
		return 0;
	} else if (strncmp(argv[1], "test_int", strlen("test_int")) == 0) {
		if (argc != 3) {
			printf(
					"lab2: wrong no of arguments for test of timer_set_square() \n");
			return 1;
		}
		if ((time = parse_ulong(argv[2], 10)) == ULONG_MAX)
			return 1;
		printf("lab2::timer_set_square(%d)\n", (unsigned) time);
		timer_test_int(time);
		return 0;
	} else {
		printf("lab2: non valid function \"%s\" to test\n", argv[1]);
		return 1;
	}
}
Beispiel #4
0
void *test_init(unsigned short mode, unsigned short delay) {

	char *video_mem;
	vbe_mode_info_t vbe;
	video_mem = vg_init(mode);

	if (vbe_get_mode_info(mode, &vbe) == 1) {
		printf("Failed vbe_get_mode_info().\n");
		return;
	}

	timer_test_int(delay);

	if (vg_exit() == 1) {
		printf("Failed vg_exit().\n");
		return;
	}

	printf("Physical Adress VRAM: 0x%x",vbe.PhysBasePtr);
	return video_mem;
}
Beispiel #5
0
static int proc_args(int argc, char *argv[]) {

  unsigned long freq, time;
  unsigned char conf;

  /* check the function to test: if the first characters match, accept it */
  if (strncmp(argv[1], "display_conf", strlen("display_conf")) == 0) {
	  if( argc != 3 ) {
		  printf("timer: wrong no of arguments for test of timer_display_conf() \n");
		  return 1;
	  }
	  if( (conf = parse_ulong(argv[2], 0)) == ULONG_MAX )
	 		  return 1;
	  printf("timer:: timer_display_conf(%d)\n", conf);
	  timer_display_conf(conf);
	  return 0;
  } else if (strncmp(argv[1], "test_int", strlen("test_int")) == 0) {
	  if( argc != 3 ) {
		  printf("timer: wrong no of arguments for test of timer_test_int() \n");
		  return 1;
	  }
	  if( (time = parse_ulong(argv[2], 16)) == ULONG_MAX )
		  return 1;
	  printf("timer:: timer_test_int(%d)\n", time);
	  timer_test_int(time);
	  return 0;
  } else if (strncmp(argv[1], "test_square", strlen("test_square")) == 0) {
	  if( argc != 3 ) {
		  printf("timer: wrong no of arguments for test of timer_test_square() \n");
		  return 1;
	  }
	  if( (freq = parse_ulong(argv[2], 16)) == ULONG_MAX )
		  return 1;
	  printf("timer:: timer_test_square(%d)\n", freq);
	  return timer_test_square(freq);
  } else {
	  printf("timer: non valid function \"%s\" to test\n", argv[1]);
	  return 1;
  }
}
Beispiel #6
0
void *test_init(unsigned short mode, unsigned short delay) {
	void *ret;
	vbe_mode_info_t vmi_p;

	if ((ret = vg_init(mode)) == NULL)
		return NULL;

	timer_test_int(delay);

	if (vbe_get_mode_info(mode, &vmi_p) != 0)
		return NULL;

	if (vg_exit() != 0)
		return NULL;

	//test to see if vbe_get_mode_info is working
	printf("X res: %d\nY res: %d\nBits per pixel: %d\nPhysical Address: %x",
			vmi_p.XResolution, vmi_p.YResolution, vmi_p.BitsPerPixel,
			vmi_p.PhysBasePtr);

	return ret;
}
Beispiel #7
0
static int proc_args(int argc, char *argv[]) {

  unsigned long timer, freq, time;

  /* check the function to test: if the first characters match, accept it */
  if (strncmp(argv[1], "config", strlen("config")) == 0) {
	  if( argc != 3 ) {
		  printf("timer: wrong no of arguments for test of timer_test_config() \n");
		  return 1;
	  }
	  if( (timer = parse_ulong(argv[2], 10)) == ULONG_MAX )
	  		  return 1;
	  printf("timer:: timer_test_config(%lu)\n", timer);
	  return  timer_test_config(timer);
  } else if (strncmp(argv[1], "square", strlen("square")) == 0) {
	  if( argc != 3 ) {
		  printf("timer: wrong no of arguments for test of timer_test_square() \n");
		  return 1;
	  }
	  if( (freq = parse_ulong(argv[2], 10)) == ULONG_MAX )
		  return 1;
	  printf("timer:: timer_test_square(%lu)\n", freq);
	  return timer_test_square(freq);;
  } else if (strncmp(argv[1], "test_int", strlen("test_int")) == 0) {
	  if( argc != 3 ) {
		  printf("timer: wrong no of arguments for test of timer_test_int() \n");
		  return 1;
	  }
	  if( (time = parse_ulong(argv[2], 10)) == ULONG_MAX )
		  return 1;
	  printf("timer:: timer_test_int(%lu)\n", time);
	  return timer_test_int(time);;
  } else {
	  printf("timer: non valid function \"%s\" to test\n", argv[1]);
	  return 1;
  }
}