Example #1
0
static void print_instance(const char * outdir, const char * ns, class_entry * ie)
{
	FILE * f;
	char outfile[3000];
	
	strcpy(outfile, outdir);
	strcat(outfile, "/");
	strcat(outfile, ns);
	strcat(outfile, "/");	
	strcat(outfile, ie->class_id);
	
	f = fopen(outfile, "a");

	class_entry * ce = get_class_def_for_instance(ie);

	if(check_for_keys(ce, ie) && check_valid_props(ce, ie)) {
		
		fprintf(f,"Instance %s ",ie -> class_id);
		fprintf(f,"{\n");
        if (ie->instmig)
            fprintf(f, "  From Instance Import/Migration\n");
        else
            fprintf(f, "  From MOF\n");                        
		print_property_chain(f,ie -> class_props);
		fprintf(f,"}\n");
		fprintf(f,"\n");
	}
}
Example #2
0
/**
 * Check the keyboard, and send any keys that are pressed.
 *
 * This is called by input_tstc() and input_getc() when they need more
 * characters
 *
 * @param input		Input configuration
 * @return 1, to indicate that we have something to look at
 */
int cros_ec_kbc_check(struct input_config *input)
{
	static struct key_matrix_key last_keys[KBC_MAX_KEYS];
	static int last_num_keys;
	struct key_matrix_key keys[KBC_MAX_KEYS];
	int keycodes[KBC_MAX_KEYS];
	int num_keys, num_keycodes;
	int irq_pending, sent;
	bool same = false;

	/*
	 * Loop until the EC has no more keyscan records, or we have
	 * received at least one character. This means we know that tstc()
	 * will always return non-zero if keys have been pressed.
	 *
	 * Without this loop, a key release (which generates no new ascii
	 * characters) will cause us to exit this function, and just tstc()
	 * may return 0 before all keys have been read from the EC.
	 */
	do {
		irq_pending = cros_ec_interrupt_pending(config.dev);
		if (irq_pending) {
			num_keys = check_for_keys(&config, keys, KBC_MAX_KEYS,
						  &same);
			if (num_keys < 0)
				return 0;
			last_num_keys = num_keys;
			memcpy(last_keys, keys, sizeof(keys));
		} else {
			/*
			 * EC doesn't want to be asked, so use keys from last
			 * time.
			 */
			num_keys = last_num_keys;
			memcpy(keys, last_keys, sizeof(keys));
		}

		if (num_keys < 0)
			return -1;
		num_keycodes = key_matrix_decode(&config.matrix, keys,
				num_keys, keycodes, KBC_MAX_KEYS);
		sent = input_send_keycodes(input, keycodes, num_keycodes);

		/*
		 * For those ECs without an interrupt, stop scanning when we
		 * see that the scan is the same as last time.
		 */
		if ((irq_pending < 0) && same)
			break;
	} while (irq_pending && !sent);

	return 1;
}