コード例 #1
0
ファイル: console_simple.c プロジェクト: cpdesign/barebox
int console_register(struct console_device *newcdev)
{
	if (!console) {
		console = newcdev;
		console_list.prev = console_list.next = &newcdev->list;
		newcdev->list.prev = newcdev->list.next = &console_list;

		barebox_banner();
	}
	return 0;
}
コード例 #2
0
ファイル: console.c プロジェクト: bluecmd/barebox
static int console_std_set(struct device_d *dev, struct param_d *param,
		const char *val)
{
	struct console_device *cdev = to_console_dev(dev);
	char active[4];
	unsigned int flag = 0, i = 0;

	if (val) {
		if (strchr(val, 'i') && cdev->getc) {
			active[i++] = 'i';
			flag |= CONSOLE_STDIN;
		}

		if (cdev->putc) {
			if (strchr(val, 'o')) {
				active[i++] = 'o';
				flag |= CONSOLE_STDOUT;
			}

			if (strchr(val, 'e')) {
				active[i++] = 'e';
				flag |= CONSOLE_STDERR;
			}
		}
	}

	if (flag && !cdev->f_active) {
		/* The device is being activated, set its baudrate */
		if (cdev->setbrg)
			cdev->setbrg(cdev, cdev->baudrate);
	}

	active[i] = 0;
	cdev->f_active = flag;

	dev_param_set_generic(dev, param, active);

	if (initialized < CONSOLE_INIT_FULL) {
		char ch;
		initialized = CONSOLE_INIT_FULL;
		puts_ll("Switch to console [");
		puts_ll(dev_name(dev));
		puts_ll("]\n");
		barebox_banner();
		while (kfifo_getc(console_output_fifo, &ch) == 0)
			console_putc(CONSOLE_STDOUT, ch);
	}

	return 0;
}
コード例 #3
0
ファイル: console.c プロジェクト: Reggi3/mini210s-barebox
static int console_std_set(struct device_d *dev, struct param_d *param,
		const char *val)
{
	struct console_device *cdev = to_console_dev(dev);
	char active[4];
	unsigned int flag = 0, i = 0;

	if (!val)
		dev_param_set_generic(dev, param, NULL);

	if (strchr(val, 'i') && cdev->f_caps & CONSOLE_STDIN) {
		active[i++] = 'i';
		flag |= CONSOLE_STDIN;
	}

	if (strchr(val, 'o') && cdev->f_caps & CONSOLE_STDOUT) {
		active[i++] = 'o';
		flag |= CONSOLE_STDOUT;
	}

	if (strchr(val, 'e') && cdev->f_caps & CONSOLE_STDERR) {
		active[i++] = 'e';
		flag |= CONSOLE_STDERR;
	}

	active[i] = 0;
	cdev->f_active = flag;

	dev_param_set_generic(dev, param, active);

	if (initialized < CONSOLE_INIT_FULL) {
		char ch;
		initialized = CONSOLE_INIT_FULL;
		PUTS_LL("Switch to console [");
		PUTS_LL(dev_name(dev));
		PUTS_LL("]\n");
		barebox_banner();
		while (kfifo_getc(console_output_fifo, &ch) == 0)
			console_putc(CONSOLE_STDOUT, ch);
	}

	return 0;
}
コード例 #4
0
ファイル: console.c プロジェクト: caicry/mini2440-barebox
int console_register(struct console_device *newcdev)
{
	struct device_d *dev = &newcdev->class_dev;
	int first = 0;
	char ch;

	if (initialized == CONSOLE_UNINITIALIZED)
		console_init_early();

	dev->id = DEVICE_ID_DYNAMIC;
	strcpy(dev->name, "cs");
	if (newcdev->dev)
		dev_add_child(newcdev->dev, dev);
	register_device(dev);

	if (newcdev->setbrg) {
		dev_add_param(dev, "baudrate", console_baudrate_set, NULL, 0);
		dev_set_param(dev, "baudrate", __stringify(CONFIG_BAUDRATE));
	}

	dev_add_param(dev, "active", console_std_set, NULL, 0);

	initialized = CONSOLE_INIT_FULL;
#ifdef CONFIG_CONSOLE_ACTIVATE_ALL
	dev_set_param(dev, "active", "ioe");
#endif
#ifdef CONFIG_CONSOLE_ACTIVATE_FIRST
	if (list_empty(&console_list)) {
		first = 1;
		dev_set_param(dev, "active", "ioe");
	}
#endif

	list_add_tail(&newcdev->list, &console_list);

	while (kfifo_getc(console_output_fifo, &ch) == 0)
		console_putc(CONSOLE_STDOUT, ch);
	if (first)
		barebox_banner();

	return 0;
}