Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Platform dependent support for HP simulator. |
| 4 | * |
| 5 | * Copyright (C) 1998, 1999, 2002 Hewlett-Packard Co |
| 6 | * David Mosberger-Tang <davidm@hpl.hp.com> |
| 7 | * Copyright (C) 1999 Vijay Chander <vijay@engr.sgi.com> |
| 8 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | |
| 10 | #include <linux/init.h> |
| 11 | #include <linux/kernel.h> |
| 12 | #include <linux/param.h> |
| 13 | #include <linux/string.h> |
| 14 | #include <linux/types.h> |
| 15 | #include <linux/tty.h> |
| 16 | #include <linux/kdev_t.h> |
| 17 | #include <linux/console.h> |
| 18 | |
| 19 | #include <asm/delay.h> |
| 20 | #include <asm/irq.h> |
| 21 | #include <asm/pal.h> |
| 22 | #include <asm/machvec.h> |
| 23 | #include <asm/pgtable.h> |
| 24 | #include <asm/sal.h> |
Peter Chubb | 8b713c6 | 2007-08-21 13:51:45 +1000 | [diff] [blame] | 25 | #include <asm/hpsim.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | |
| 27 | #include "hpsim_ssc.h" |
| 28 | |
| 29 | static int simcons_init (struct console *, char *); |
| 30 | static void simcons_write (struct console *, const char *, unsigned); |
| 31 | static struct tty_driver *simcons_console_device (struct console *, int *); |
| 32 | |
Peter Chubb | 8b713c6 | 2007-08-21 13:51:45 +1000 | [diff] [blame] | 33 | static struct console hpsim_cons = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | .name = "simcons", |
| 35 | .write = simcons_write, |
| 36 | .device = simcons_console_device, |
| 37 | .setup = simcons_init, |
| 38 | .flags = CON_PRINTBUFFER, |
| 39 | .index = -1, |
| 40 | }; |
| 41 | |
| 42 | static int |
| 43 | simcons_init (struct console *cons, char *options) |
| 44 | { |
| 45 | return 0; |
| 46 | } |
| 47 | |
| 48 | static void |
| 49 | simcons_write (struct console *cons, const char *buf, unsigned count) |
| 50 | { |
| 51 | unsigned long ch; |
| 52 | |
| 53 | while (count-- > 0) { |
| 54 | ch = *buf++; |
| 55 | ia64_ssc(ch, 0, 0, 0, SSC_PUTCHAR); |
| 56 | if (ch == '\n') |
| 57 | ia64_ssc('\r', 0, 0, 0, SSC_PUTCHAR); |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | static struct tty_driver *simcons_console_device (struct console *c, int *index) |
| 62 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | *index = c->index; |
| 64 | return hp_simserial_driver; |
| 65 | } |
Peter Chubb | 8b713c6 | 2007-08-21 13:51:45 +1000 | [diff] [blame] | 66 | |
| 67 | int 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 | } |