static char *accounts_settings_get_string_value(const char *name)
{
	int id;

	id = translate_name(name);
	if (id < 0)
		return NULL;

	return g_strdup(g_accounts.property_values[id]);
}
Example #2
0
struct device *new_chip(struct device *parent, struct device *bus, char *path) {
    struct device *new_chip = new_dev(parent, bus);
    new_chip->chiph_exists = 1;
    new_chip->name = path;
    new_chip->name_underscore = translate_name(new_chip->name, UNSLASH);
    new_chip->type = chip;
    new_chip->chip = new_chip;

    struct stat st;
    char *chip_h = malloc(strlen(path)+18);
    sprintf(chip_h, "src/%s", path);
    if ((stat(chip_h, &st) == -1) && (errno == ENOENT)) {
        if (strstr(path, "/root_complex")) {
            fprintf(stderr, "WARNING: Use of deprecated chip component %s\n",
                    path);
        } else {
            fprintf(stderr, "ERROR: Chip component %s does not exist.\n",
                    path);
            exit(1);
        }
    }

    if (scan_mode == STATIC_MODE)
        sprintf(chip_h, "src/%s/chip.h", path);
    else if (scan_mode == BOOTBLOCK_MODE)
        sprintf(chip_h, "src/%s/bootblock.c", path);

    if ((scan_mode == STATIC_MODE) || (scan_mode == BOOTBLOCK_MODE)) {
        if ((stat(chip_h, &st) == -1) && (errno == ENOENT))
            new_chip->chiph_exists = 0;
    }

    if (parent->latestchild) {
        parent->latestchild->next_sibling = new_chip;
        parent->latestchild->sibling = new_chip;
    }
    parent->latestchild = new_chip;
    if (!parent->children)
        parent->children = new_chip;
    free(chip_h);
    return new_chip;
}
Example #3
0
struct device *new_chip(struct device *parent, struct device *bus, char *path)
{
	struct device *new_chip = new_dev(parent, bus);
	new_chip->chiph_exists = 1;
	new_chip->name = path;
	new_chip->name_underscore = translate_name(new_chip->name, UNSLASH);
	new_chip->type = chip;
	new_chip->chip = new_chip;

	struct stat st;
	char *chip_h = malloc(strlen(path) + 18);
	sprintf(chip_h, "src/%s", path);
	if ((stat(chip_h, &st) == -1) && (errno == ENOENT)) {
		/* root_complex gets away without a separate directory, but
		 * exists on on pretty much all AMD chipsets.
		 */
		if (!strstr(path, "/root_complex")) {
			fprintf(stderr, "ERROR: Chip component %s does not exist.\n",
				path);
			exit(1);
		}
	}

	sprintf(chip_h, "src/%s/chip.h", path);

	if ((stat(chip_h, &st) == -1) && (errno == ENOENT))
		new_chip->chiph_exists = 0;

	if (parent->latestchild) {
		parent->latestchild->next_sibling = new_chip;
		parent->latestchild->sibling = new_chip;
	}
	parent->latestchild = new_chip;
	if (!parent->children)
		parent->children = new_chip;
	free(chip_h);
	return new_chip;
}
Example #4
0
int AudioALSA::open_output()
{
	char pcm_name[BCTEXTLEN];
	snd_pcm_stream_t stream = SND_PCM_STREAM_PLAYBACK;
	int open_mode = 0;
	int err;

	device->out_channels = device->get_ochannels();
	device->out_bits = device->out_config->alsa_out_bits;

	translate_name(pcm_name, device->out_config->alsa_out_device);

	err = snd_pcm_open(&dsp_out, device->out_config->alsa_out_device, stream, open_mode);

	if(err < 0)
	{
		dsp_out = 0;
		printf("AudioALSA::open_output %s: %s\n", pcm_name, snd_strerror(err));
		return 1;
	}

	err = set_params(dsp_out, 
		device->get_ochannels(), 
		device->out_config->alsa_out_bits,
		device->out_samplerate,
		device->out_samples);
	if(err)
	{
		fprintf(stderr, "AudioALSA::open_output: set_params failed.  Aborting playback.\n");
		close_output();
		return 1;
	}

	timer->update();
	return 0;
}
Example #5
0
int AudioALSA::open_input()
{
	char pcm_name[BCTEXTLEN];
	snd_pcm_stream_t stream = SND_PCM_STREAM_CAPTURE;
	int open_mode = 0;
	int err;

	device->in_channels = device->get_ichannels();
	device->in_bits = device->in_config->alsa_in_bits;

	translate_name(pcm_name, device->in_config->alsa_in_device);
//printf("AudioALSA::open_input %s\n", pcm_name);

	err = snd_pcm_open(&dsp_in, device->in_config->alsa_in_device, stream, open_mode);

	if(err < 0)
	{
		dsp_in = 0;
		printf("AudioALSA::open_input: %s\n", snd_strerror(err));
		return 1;
	}

	err = set_params(dsp_in, 
		device->get_ichannels(), 
		device->in_config->alsa_in_bits,
		device->in_samplerate,
		device->in_samples);
	if(err)
	{
		fprintf(stderr, "AudioALSA::open_input: set_params failed.  Aborting sampling.\n");
		close_input();
		return 1;
	}

	return 0;
}
Example #6
0
int main(int argc, char** argv) {
	if (argc < 3)
		usage();

	char *mainboard=argv[1];
	char *outputdir=argv[2];
	char *devtree=malloc(strlen(mainboard)+30);
	sprintf(devtree, "src/mainboard/%s/devicetree.cb", mainboard);
	char *outputc;

	if (argc == 3) {
		scan_mode = STATIC_MODE;
		outputc=malloc(strlen(outputdir)+20);
		sprintf(outputc, "%s/static.c", outputdir);
	} else if ((argc == 5) && (argv[3][0] == '-') && (argv[3][2] == 0)) {

		switch (argv[3][1]) {
		case 's':
			scan_mode = STATIC_MODE;
			break;
		case 'b':
			scan_mode = BOOTBLOCK_MODE;
			break;
		case 'k':
			scan_mode = KCONFIG_MODE;
			break;
		default:
			usage();
			break;
		}
		char *outputfile=argv[4];

		outputc=malloc(strlen(outputdir)+strlen(outputfile)+2);
		sprintf(outputc, "%s/%s", outputdir, outputfile);
	}

	headers.next = 0;
#ifdef MAINBOARDS_HAVE_CHIP_H
	if (scan_mode == STATIC_MODE) {
		headers.next = malloc(sizeof(struct header));
		headers.next->name = malloc(strlen(mainboard)+12);
		headers.next->next = 0;
		sprintf(headers.next->name, "mainboard/%s", mainboard);
	}
#endif

	FILE *filec = fopen(devtree, "r");
	if (!filec) {
		fprintf(stderr, "Could not open file '%s' for reading: ", devtree);
		perror(NULL);
		exit(1);
	}

	yyrestart(filec);

	lastdev = head = &root;

	yyparse();

	fclose(filec);

	if ((head->type == chip) && (!head->chiph_exists)) {
		struct device *tmp = head;
		head = &root;
		while (head->next != tmp) head = head->next;
	}

	FILE *autogen = fopen(outputc, "w");
	if (!autogen) {
		fprintf(stderr, "Could not open file '%s' for writing: ", outputc);
		perror(NULL);
		exit(1);
	}

	struct header *h;
	if (scan_mode == STATIC_MODE) {

		fprintf(autogen, "#include <device/device.h>\n");
		fprintf(autogen, "#include <device/pci.h>\n");
		h = &headers;
		while (h->next) {
			h = h->next;
			if (h->chiph_exists)
				fprintf(autogen, "#include \"%s/chip.h\"\n", h->name);
		}
		fprintf(autogen, "\n#ifndef __PRE_RAM__\n");
		fprintf(autogen, "__attribute__((weak)) struct chip_operations mainboard_ops = {};\n");
		h = &headers;
		while (h->next) {
			h = h->next;
			char *name_underscore = translate_name(h->name, UNSLASH);
			fprintf(autogen, "__attribute__((weak)) struct chip_operations %s_ops = {};\n", name_underscore);
			free(name_underscore);
		}
		fprintf(autogen, "#endif\n");

		walk_device_tree(autogen, &root, inherit_subsystem_ids, NULL);
		fprintf(autogen, "\n/* pass 0 */\n");
		walk_device_tree(autogen, &root, pass0, NULL);
		fprintf(autogen, "\n/* pass 1 */\n"
			    "ROMSTAGE_CONST struct device * ROMSTAGE_CONST last_dev = &%s;\n", lastdev->name);
#ifdef MAINBOARDS_HAVE_CHIP_H
		fprintf(autogen, "static ROMSTAGE_CONST struct mainboard_config ROMSTAGE_CONST mainboard_info_0;\n");
#endif
		walk_device_tree(autogen, &root, pass1, NULL);

	} else if (scan_mode == BOOTBLOCK_MODE) {
		h = &headers;
		while (h->next) {
			h = h->next;
			fprintf(autogen, "#include \"%s/bootblock.c\"\n", h->name);
		}

		fprintf(autogen, "\n#if CONFIG_HAS_MAINBOARD_BOOTBLOCK\n");
		fprintf(autogen, "#include \"mainboard/%s/bootblock.c\"\n", mainboard);
		fprintf(autogen, "#else\n");
		fprintf(autogen, "static unsigned long init_mainboard(int bsp_cpu)\n{\n");
		fprintf(autogen, "\tif (! bsp_cpu) return 0;\n");
		h = &headers;
		while (h->next) {
			h = h->next;
			char * buf = translate_name(h->name, UNSLASH);
			if (buf) {
				fprintf(autogen, "\tinit_%s();\n", buf);
				free(buf);
			}
		}

		fprintf(autogen, "\treturn 0;\n}\n");
		fprintf(autogen, "#endif\n");

	} else if (scan_mode == KCONFIG_MODE) {
		fprintf(autogen, "\nconfig MAINBOARD_DIR\n\tstring\n");
		fprintf(autogen, "\tdefault %s\n", mainboard);

		fprintf(autogen, "\nconfig MAINBOARD_DEVTREE\n\tdef_bool y\n");
		h = &headers;
		while (h->next) {
			h = h->next;
			char * buf = translate_name(h->name, TO_UPPER);
			if (buf) {
				fprintf(autogen, "\tselect %s\n", buf);
				free(buf);
			}
		}
	}

	fclose(autogen);

	return 0;
}
Example #7
0
int main(int argc, char **argv)
{
	if (argc != ARG_COUNT)
		usage();

	char *devtree = argv[DEVICEFILE_ARG];
	char *outputc = argv[OUTPUTFILE_ARG];

	headers.next = 0;

	FILE *filec = fopen(devtree, "r");
	if (!filec) {
		perror(NULL);
		exit(1);
	}

	yyrestart(filec);

	lastdev = head = &root;

	yyparse();

	fclose(filec);

	if ((head->type == chip) && (!head->chiph_exists)) {
		struct device *tmp = head;
		head = &root;
		while (head->next != tmp)
			head = head->next;
	}

	FILE *autogen = fopen(outputc, "w");
	if (!autogen) {
		fprintf(stderr, "Could not open file '%s' for writing: ",
			outputc);
		perror(NULL);
		exit(1);
	}

	struct header *h;
	fprintf(autogen, "#include <device/device.h>\n");
	fprintf(autogen, "#include <device/pci.h>\n");
	h = &headers;
	while (h->next) {
		h = h->next;
		if (h->chiph_exists)
			fprintf(autogen, "#include \"%s/chip.h\"\n", h->name);
	}
	fprintf(autogen, "\n#ifndef __PRE_RAM__\n");
	fprintf(autogen,
		"__attribute__((weak)) struct chip_operations mainboard_ops = {};\n");
	h = &headers;
	while (h->next) {
		h = h->next;
		char *name_underscore = translate_name(h->name, UNSLASH);
		fprintf(autogen,
			"__attribute__((weak)) struct chip_operations %s_ops = {};\n",
			name_underscore);
		free(name_underscore);
	}
	fprintf(autogen, "#endif\n");

	walk_device_tree(autogen, &root, inherit_subsystem_ids, NULL);
	fprintf(autogen, "\n/* pass 0 */\n");
	walk_device_tree(autogen, &root, pass0, NULL);
	fprintf(autogen, "\n/* pass 1 */\n"
		"ROMSTAGE_CONST struct device * ROMSTAGE_CONST last_dev = &%s;\n",
		lastdev->name);
	walk_device_tree(autogen, &root, pass1, NULL);

	fclose(autogen);

	return 0;
}