static int test_power_button(void)
{
	gpio_set_level(GPIO_POWER_BUTTON_L, 1);
	set_scancode(1);
	test_chipset_on();

	gpio_set_level(GPIO_POWER_BUTTON_L, 0);
	VERIFY_LPC_CHAR_DELAY("\xe0\x5e", 100);

	gpio_set_level(GPIO_POWER_BUTTON_L, 1);
	VERIFY_LPC_CHAR_DELAY("\xe0\xde", 100);

	set_scancode(2);
	write_cmd_byte(read_cmd_byte() & ~I8042_XLATE);

	gpio_set_level(GPIO_POWER_BUTTON_L, 0);
	VERIFY_LPC_CHAR_DELAY("\xe0\x37", 100);

	gpio_set_level(GPIO_POWER_BUTTON_L, 1);
	VERIFY_LPC_CHAR_DELAY("\xe0\xf0\x37", 100);

	test_chipset_off();

	gpio_set_level(GPIO_POWER_BUTTON_L, 0);
	VERIFY_NO_CHAR();

	gpio_set_level(GPIO_POWER_BUTTON_L, 1);
	VERIFY_NO_CHAR();

	return EC_SUCCESS;
}
static int test_sysjump(void)
{
	set_scancode(2);
	enable_keystroke(1);

	system_run_image_copy(SYSTEM_IMAGE_RW);

	/* Shouldn't reach here */
	return EC_ERROR_UNKNOWN;
}
static int test_scancode_set2(void)
{
	set_scancode(2);

	write_cmd_byte(read_cmd_byte() | I8042_XLATE);
	press_key(1, 1, 1);
	VERIFY_LPC_CHAR("\x01");
	press_key(1, 1, 0);
	VERIFY_LPC_CHAR("\x81");

	write_cmd_byte(read_cmd_byte() & ~I8042_XLATE);
	press_key(1, 1, 1);
	VERIFY_LPC_CHAR("\x76");
	press_key(1, 1, 0);
	VERIFY_LPC_CHAR("\xf0\x76");

	return EC_SUCCESS;
}
Example #4
0
void shell(){
	char c;
	char buffer[MAX_CMD_SIZE+1];
	char last_cmd[CMD_MEMORY][MAX_CMD_SIZE+1];
	int i,mem;
	char shell_color=0x09;
	char user_color=0x07;
	
	for(mem=0;mem<CMD_MEMORY;mem++){
		last_cmd[mem][0]=0;
	}													
	while(1){
		__setcolor(&shell_color);
		printf("Shell->: ");
		__setcolor(&user_color);
		i=0;
		mem=-1;
		do{
			c=getchar();
			if(c=='\b'){
				if(i>0){
					i--;
					putchar(c);
				}
			}
			else if(c=='\x11'){
				/*UP*/
				if(mem<CMD_MEMORY-1){
					mem++;
					int j;
					for(j=0;j<i;j++){
						putchar('\b');
					}
					i=strlen(last_cmd[mem]);
					strcpy(buffer,last_cmd[mem]);
					printf("%s",buffer);
				}
			}
			else if(c=='\x13'){
				/*DOWN*/
				if(mem>0){
					mem--;
					int j;
					for(j=0;j<i;j++){
						putchar('\b');
					}
					i=strlen(last_cmd[mem]);
					strcpy(buffer,last_cmd[mem]);
					printf("%s",buffer);
				}
			}
			else if(c=='\x12'){
				//do nothing
			}
			else{
				if(i<MAX_CMD_SIZE||c=='\n'){
				  putchar(c);
				  buffer[i]=c;
				  i++;
				}
			}
		}while(c!='\n');
		buffer[i-1]=0;
		/*GUARDAR COMANDOS ANTERIORES*/
		int k;
		for(k=CMD_MEMORY-2;k>=0;k--){
			strcpy(last_cmd[k+1],last_cmd[k]);
		}
		strcpy(last_cmd[0],buffer);
		
		
		if(strlen(buffer)==0){
			/*VACIO*/
		}
		else if(strcmp("who",buffer)==0){
			printf("\n************\nF Alderete\nF Ramundo\nC Mader Blanco\n************\n\n");
		}
		else if(substr("echo ", buffer)){
			printf("%s\n",buffer+5);
		}
		else if(substr("color ", buffer)){
		  char tmp=color(buffer+6);
		  if(tmp==0){
		    printf("Invalid color name\n");
		  }
		  else{
		    user_color=tmp;
		  }
		}
		else if(strcmp("time",buffer)==0){
			int m, h;
			m=getmin();
			h=gethour();
			if(m<10){
				printf("%d:0%d\n",h,m);
			}else{
				printf("%d:%d\n",h,m);
			}
		}	
		else if(substr("keyboard ", buffer)){
			if(strcmp("ESP", buffer+9)==0){
				set_scancode(1);
			}else if(strcmp("ENG", buffer+9)==0){
				set_scancode(2);
			}else{
				printf("Unsuported layout\n");
			}
		}
		else if(substr("speak ", buffer)){
			speak(buffer+6);
		}
		else if(strcmp("memstat", buffer)==0){
			print_memory();
		}
		else if(substr("memalloc ", buffer)){
			i=atoi(buffer+9);
			if(malloc(i)!=0){
				printf("Memory allocated\n");
			}else{
				printf("Not enough memory\n");
			}
		}
		else if(substr("memcalloc ", buffer)){
			i=atoi(buffer+10);
			if(calloc(i)!=0){
				printf("Memory allocated\n");
			}else{
				printf("Not enough memory\n");
			}
		}
		else if(substr("pageprint ", buffer)){
			i=atoi(buffer+10);
			if(pageprint(i)==0){
				printf("Invalid argument");
			}
		}
		else if(substr("memfree ", buffer)){
			i=atoi(buffer+8);
			if(free((void*)((i+530)*4096))){
				printf("Memory freed\n");
			}
			else{
				printf("Invalid argument\n");
			}
		}
		else if(strcmp("lostquote", buffer)==0){
			printf("%s", get_quote());
		}
		else if(strcmp("mastersword", buffer)==0){
			print_zelda();
		}
		else if(strcmp("mario", buffer)==0){
			print_mario();
		}
		else if(strcmp("help", buffer)==0){
			help();
		}
		else if(strcmp("mastermind",buffer)==0){
			mastermind();
		}
		else{
			printf("Command not found\n");
		}
		
	}
}