move boards to arch/<architecure>/boards
[barebox-mini2440.git] / arch / sandbox / board / console.c
blob2959e85c7a57f80fec7f6e7461b0825763bdf072
1 /*
2 * console.c - register a console device
4 * Copyright (c) 2007 Sascha Hauer <s.hauer@pengutronix.de>, Pengutronix
6 * See file CREDITS for list of people who contributed to this
7 * project.
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License version 2
11 * as published by the Free Software Foundation.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23 #include <common.h>
24 #include <driver.h>
25 #include <mach/linux.h>
26 #include <xfuncs.h>
28 int barebox_register_console(char *name, int stdinfd, int stdoutfd)
30 struct device_d *dev;
31 struct linux_console_data *data;
33 dev = xzalloc(sizeof(struct device_d) + sizeof(struct linux_console_data));
35 data = (struct linux_console_data *)(dev + 1);
37 dev->platform_data = data;
38 strcpy(dev->name, name);
40 strcpy(dev->name, "console");
42 if (stdinfd >= 0)
43 data->flags = CONSOLE_STDIN;
44 if (stdoutfd >= 0)
45 data->flags |= CONSOLE_STDOUT | CONSOLE_STDERR;
47 data->stdoutfd = stdoutfd;
48 data->stdinfd = stdinfd;
50 return register_device(dev);