0001
0002
0003
0004
0005
0006
0007
0008 #include <linux/console.h>
0009 #include <linux/delay.h>
0010 #include <linux/err.h>
0011 #include <linux/init.h>
0012 #include <linux/moduleparam.h>
0013 #include <linux/types.h>
0014 #include <linux/irq.h>
0015
0016 #include <asm/udbg.h>
0017
0018 #include "hvc_console.h"
0019
0020 static struct hvc_struct *hvc_udbg_dev;
0021
0022 static int hvc_udbg_put(uint32_t vtermno, const char *buf, int count)
0023 {
0024 int i;
0025
0026 for (i = 0; i < count && udbg_putc; i++)
0027 udbg_putc(buf[i]);
0028
0029 return i;
0030 }
0031
0032 static int hvc_udbg_get(uint32_t vtermno, char *buf, int count)
0033 {
0034 int i, c;
0035
0036 if (!udbg_getc_poll)
0037 return 0;
0038
0039 for (i = 0; i < count; i++) {
0040 if ((c = udbg_getc_poll()) == -1)
0041 break;
0042 buf[i] = c;
0043 }
0044
0045 return i;
0046 }
0047
0048 static const struct hv_ops hvc_udbg_ops = {
0049 .get_chars = hvc_udbg_get,
0050 .put_chars = hvc_udbg_put,
0051 };
0052
0053 static int __init hvc_udbg_init(void)
0054 {
0055 struct hvc_struct *hp;
0056
0057 if (!udbg_putc)
0058 return -ENODEV;
0059
0060 BUG_ON(hvc_udbg_dev);
0061
0062 hp = hvc_alloc(0, 0, &hvc_udbg_ops, 16);
0063 if (IS_ERR(hp))
0064 return PTR_ERR(hp);
0065
0066 hvc_udbg_dev = hp;
0067
0068 return 0;
0069 }
0070 device_initcall(hvc_udbg_init);
0071
0072 static int __init hvc_udbg_console_init(void)
0073 {
0074 if (!udbg_putc)
0075 return -ENODEV;
0076
0077 hvc_instantiate(0, 0, &hvc_udbg_ops);
0078 add_preferred_console("hvc", 0, NULL);
0079
0080 return 0;
0081 }
0082 console_initcall(hvc_udbg_console_init);