blob: 0475a54524043f69ffb04433c228f6f853a904dc [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * Platform dependent support for HP simulator.
3 *
4 * Copyright (C) 1998, 1999, 2002 Hewlett-Packard Co
5 * David Mosberger-Tang <davidm@hpl.hp.com>
6 * Copyright (C) 1999 Vijay Chander <vijay@engr.sgi.com>
7 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07008
9#include <linux/init.h>
10#include <linux/kernel.h>
11#include <linux/param.h>
12#include <linux/string.h>
13#include <linux/types.h>
14#include <linux/tty.h>
15#include <linux/kdev_t.h>
16#include <linux/console.h>
17
18#include <asm/delay.h>
19#include <asm/irq.h>
20#include <asm/pal.h>
21#include <asm/machvec.h>
22#include <asm/pgtable.h>
23#include <asm/sal.h>
Peter Chubb8b713c62007-08-21 13:51:45 +100024#include <asm/hpsim.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070025
26#include "hpsim_ssc.h"
27
28static int simcons_init (struct console *, char *);
29static void simcons_write (struct console *, const char *, unsigned);
30static struct tty_driver *simcons_console_device (struct console *, int *);
31
Peter Chubb8b713c62007-08-21 13:51:45 +100032static struct console hpsim_cons = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070033 .name = "simcons",
34 .write = simcons_write,
35 .device = simcons_console_device,
36 .setup = simcons_init,
37 .flags = CON_PRINTBUFFER,
38 .index = -1,
39};
40
41static int
42simcons_init (struct console *cons, char *options)
43{
44 return 0;
45}
46
47static void
48simcons_write (struct console *cons, const char *buf, unsigned count)
49{
50 unsigned long ch;
51
52 while (count-- > 0) {
53 ch = *buf++;
54 ia64_ssc(ch, 0, 0, 0, SSC_PUTCHAR);
55 if (ch == '\n')
56 ia64_ssc('\r', 0, 0, 0, SSC_PUTCHAR);
57 }
58}
59
60static struct tty_driver *simcons_console_device (struct console *c, int *index)
61{
62 extern struct tty_driver *hp_simserial_driver;
63 *index = c->index;
64 return hp_simserial_driver;
65}
Peter Chubb8b713c62007-08-21 13:51:45 +100066
67int simcons_register(void)
68{
69 if (!ia64_platform_is("hpsim"))
70 return 1;
71
72 if (hpsim_cons.flags & CON_ENABLED)
73 return 1;
74
75 register_console(&hpsim_cons);
76 return 0;
77}