Exemple #1
0
adv_error mouseb_load(adv_conf* context)
{
	unsigned i;
	int at_least_one;

	if (mouseb_state.driver_mac == 0) {
		error_set("No mouse driver was compiled in.");
		return -1;
	}

	mouseb_state.is_initialized_flag = 1;
	sncpy(mouseb_state.name, DEVICE_NAME_MAX, conf_string_get_default(context, "device_mouse"));

	/* load specific driver options */
	at_least_one = 0;
	for (i = 0; i < mouseb_state.driver_mac; ++i) {
		const adv_device* dev;

		dev = device_match(mouseb_state.name, (adv_driver*)mouseb_state.driver_map[i], 0);

		if (dev)
			at_least_one = 1;

		if (mouseb_state.driver_map[i]->load(context) != 0)
			return -1;
	}

	if (!at_least_one) {
		device_error("device_mouse", mouseb_state.name, (const adv_driver**)mouseb_state.driver_map, mouseb_state.driver_mac);
		return -1;
	}

	return 0;
}
Exemple #2
0
adv_error mouseb_init(void)
{
	unsigned i;

	assert(mouseb_state.driver_current == 0);
	assert(!mouseb_state.is_active_flag);

	if (!mouseb_state.is_initialized_flag) {
		mouseb_default();
	}

	/* store the error prefix */
	error_nolog_set("Unable to initialize the mouse driver. The errors are:\n");

	for (i = 0; i < mouseb_state.driver_mac; ++i) {
		const adv_device* dev;

		dev = device_match(mouseb_state.name, (const adv_driver*)mouseb_state.driver_map[i], 1);

		error_cat_set(mouseb_state.driver_map[i]->name, 1);

		if (dev && mouseb_state.driver_map[i]->init(dev->id) == 0) {
			mouseb_state.driver_current = mouseb_state.driver_map[i];
			break;
		}
	}

	error_cat_set(0, 0);

	if (!mouseb_state.driver_current)
		return -1;

	error_reset();

	log_std(("mouseb: select driver %s\n", mouseb_state.driver_current->name));

	mouseb_state.is_active_flag = 1;
	mouseb_state.is_enabled_flag = 0;

	for (i = 0; i < mouseb_count_get(); ++i) {
		char name[DEVICE_NAME_MAX];
		if (mouseb_device_name_get(i, name) != 0)
			strcpy(name, DEVICE_NONAME);
		log_std(("mouseb: identifier %u '%s'\n", i, name));
	}

	return 0;
}
Exemple #3
0
adv_error keyb_init(adv_bool disable_special)
{
	unsigned i;

	assert(keyb_state.driver_current == 0);
	assert(!keyb_state.is_active_flag);

	if (!keyb_state.is_initialized_flag) {
		keyb_default();
	}

	/* store the error prefix */
	error_nolog_set("Unable to initialize the keyboard driver. The errors are:\n");

	for (i = 0; i < keyb_state.driver_mac; ++i) {
		const adv_device* dev;

		dev = device_match(keyb_state.name, (const adv_driver*)keyb_state.driver_map[i], 0);

		error_cat_set(keyb_state.driver_map[i]->name, 1);

		if (dev && keyb_state.driver_map[i]->init(dev->id, disable_special) == 0) {
			keyb_state.driver_current = keyb_state.driver_map[i];
			break;
		}
	}

	error_cat_set(0, 0);

	if (!keyb_state.driver_current)
		return -1;

	error_reset();

	log_std(("keyb: select driver %s\n", keyb_state.driver_current->name));

	keyb_state.is_active_flag = 1;
	keyb_state.is_enabled_flag = 0;

	for (i = 0; i < keyb_count_get(); ++i) {
		char name[DEVICE_NAME_MAX];
		if (keyb_device_name_get(i, name) != 0)
			strcpy(name, DEVICE_NONAME);
		log_std(("keyb: identifier %u '%s'\n", i, name));
	}

	return 0;
}
Exemple #4
0
void alias_siblings(struct device *d) {
	while (d) {
		int link = 0;
		struct device *cmp = d->next_sibling;
		while (cmp && (cmp->bus == d->bus) && (cmp->path_a == d->path_a) && (cmp->path_b == d->path_b)) {
			if (cmp->type==device && !cmp->used) {
				if (device_match(d, cmp)) {
					d->multidev = 1;

					cmp->id = d->id;
					cmp->name = d->name;
					cmp->used = 1;
					cmp->link = ++link;
				}
			}
			cmp = cmp->next_sibling;
		}
		d = d->next_sibling;
	}
}
Exemple #5
0
int device_match_of_modalias(struct device_d *dev, struct driver_d *drv)
{
	struct platform_device_id *id = drv->id_table;
	const char *of_modalias = NULL, *p;
	int cplen;
	const char *compat;

	if (!device_match(dev, drv))
		return 0;

	if (!id || !IS_ENABLED(CONFIG_OFDEVICE) || !dev->device_node)
		return -1;

	compat = of_get_property(dev->device_node, "compatible", &cplen);
	if (!compat)
		return -1;

	p = strchr(compat, ',');
	of_modalias = p ? p + 1 : compat;

	while (id->name) {
		if (!strcmp(id->name, dev->name)) {
			dev->id_entry = id;
			return 0;
		}

		if (of_modalias && !strcmp(id->name, of_modalias)) {
			dev->id_entry = id;
			return 0;
		}

		id++;
	}

	return -1;
}
Exemple #6
0
static void pass1(FILE *fil, struct device *ptr)
{
	int pin;
	if (!ptr->used && (ptr->type == device)) {
		if (ptr->id != 0)
			fprintf(fil, "static ");
		fprintf(fil, "ROMSTAGE_CONST struct device %s = {\n", ptr->name);
		fprintf(fil, "#ifndef __PRE_RAM__\n");
		fprintf(fil, "\t.ops = %s,\n", (ptr->ops)?(ptr->ops):"0");
		fprintf(fil, "#endif\n");
		fprintf(fil, "\t.bus = &%s_links[%d],\n", ptr->bus->name, ptr->bus->link);
		fprintf(fil, "\t.path = {");
		fprintf(fil, ptr->path, ptr->path_a, ptr->path_b);
		fprintf(fil, "},\n");
		fprintf(fil, "\t.enabled = %d,\n", ptr->enabled);
		fprintf(fil, "\t.on_mainboard = 1,\n");
		if (ptr->subsystem_vendor > 0)
			fprintf(fil, "\t.subsystem_vendor = 0x%04x,\n", ptr->subsystem_vendor);

		for(pin = 0; pin < 4; pin++) {
			if (ptr->pci_irq_info[pin].ioapic_irq_pin > 0)
				fprintf(fil, "\t.pci_irq_info[%d].ioapic_irq_pin = %d,\n", pin, ptr->pci_irq_info[pin].ioapic_irq_pin);

			if (ptr->pci_irq_info[pin].ioapic_dst_id > 0)
				fprintf(fil, "\t.pci_irq_info[%d].ioapic_dst_id = %d,\n", pin, ptr->pci_irq_info[pin].ioapic_dst_id);
		}

		if (ptr->subsystem_device > 0)
			fprintf(fil, "\t.subsystem_device = 0x%04x,\n", ptr->subsystem_device);

		if (ptr->rescnt > 0) {
			fprintf(fil, "\t.resource_list = &%s_res[0],\n", ptr->name);
		}
		int link = 0;
		if (ptr->children || ptr->multidev)
			fprintf(fil, "\t.link_list = &%s_links[0],\n", ptr->name);
		else
			fprintf(fil, "\t.link_list = NULL,\n");
		if (ptr->sibling)
			fprintf(fil, "\t.sibling = &%s,\n", ptr->sibling->name);
		fprintf(fil, "#ifndef __PRE_RAM__\n");
		fprintf(fil, "\t.chip_ops = &%s_ops,\n", ptr->chip->name_underscore);
		if (ptr->chip->chip == &mainboard)
			fprintf(fil, "\t.name = mainboard_name,\n");
		fprintf(fil, "#endif\n");
		if (ptr->chip->chiph_exists)
			fprintf(fil, "\t.chip_info = &%s_info_%d,\n", ptr->chip->name_underscore, ptr->chip->id);
		if (ptr->nextdev)
			fprintf(fil, "\t.next=&%s\n", ptr->nextdev->name);
		fprintf(fil, "};\n");
	}
	if (ptr->rescnt > 0) {
		int i=1;
		fprintf(fil, "ROMSTAGE_CONST struct resource %s_res[] = {\n",
				ptr->name);
		struct resource *r = ptr->res;
		while (r) {
			fprintf(fil, "\t\t{ .flags=IORESOURCE_FIXED | IORESOURCE_ASSIGNED | IORESOURCE_");
			if (r->type == IRQ) fprintf(fil, "IRQ");
			if (r->type == DRQ) fprintf(fil, "DRQ");
			if (r->type == IO) fprintf(fil, "IO");
			fprintf(fil, ", .index=0x%x, .base=0x%x,", r->index, r->base);
			if (r->next)
				fprintf(fil, ".next=&%s_res[%d]},\n", ptr->name, i++);
			else
				fprintf(fil, ".next=NULL },\n");
			r = r->next;
		}
		fprintf(fil, "\t };\n");
	}
	if (!ptr->used && ptr->type == device && (ptr->children || ptr->multidev)) {
		fprintf(fil, "ROMSTAGE_CONST struct bus %s_links[] = {\n", ptr->name);
		if (ptr->multidev) {
			struct device *d = ptr;
			while (d) {
				if (device_match(d, ptr)) {
					fprintf(fil, "\t\t[%d] = {\n", d->link);
					fprintf(fil, "\t\t\t.link_num = %d,\n", d->link);
					fprintf(fil, "\t\t\t.dev = &%s,\n", d->name);
					if (d->children)
						fprintf(fil, "\t\t\t.children = &%s,\n", d->children->name);
					if (d->next_sibling && device_match(d->next_sibling, ptr))
						fprintf(fil, "\t\t\t.next=&%s_links[%d],\n", d->name, d->link+1);
					else
						fprintf(fil, "\t\t\t.next = NULL,\n");
					fprintf(fil, "\t\t},\n");
				}
				d = d->next_sibling;
			}
		} else {
			if (ptr->children) {
				fprintf(fil, "\t\t[0] = {\n");
				fprintf(fil, "\t\t\t.link_num = 0,\n");
				fprintf(fil, "\t\t\t.dev = &%s,\n", ptr->name);
				fprintf(fil, "\t\t\t.children = &%s,\n", ptr->children->name);
				fprintf(fil, "\t\t\t.next = NULL,\n");
				fprintf(fil, "\t\t},\n");
			}
		}
		fprintf(fil, "\t};\n");
	}
	if ((ptr->type == chip) && (ptr->chiph_exists)) {
		if (ptr->reg) {
			fprintf(fil, "ROMSTAGE_CONST struct %s_config %s_info_%d = {\n",
				ptr->name_underscore, ptr->name_underscore,
				ptr->id);
			struct reg *r = ptr->reg;
			while (r) {
				fprintf(fil, "\t.%s = %s,\n", r->key, r->value);
				r = r->next;
			}
			fprintf(fil, "};\n\n");
		} else {
			fprintf(fil, "ROMSTAGE_CONST struct %s_config %s_info_%d = { };\n",
				ptr->name_underscore, ptr->name_underscore, ptr->id);
		}
	}
}