|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v8 14/26] emul/vuart: add global UART emulator configuration knob
From: Denis Mukhin <dmukhin@xxxxxxxx>
Introduce new command line setting `vuart=domid[:compatible,name]` for
configuring UART emulator per given domain.
Only one domain is supported for now.
Format:
domid - vUART owner domain ID
compatible - vUART compatible string, must match with one of the
registered emulators
name - vUART user-friendly name used for searching for one of
the pre-defined guest I/O resources
compatible string and name are optional, if skipped, platform default
values will be chosen.
Note, documentation update is not covered in this patch.
Signed-off-by: Denis Mukhin <dmukhin@xxxxxxxx>
---
xen/common/emul/vuart/vuart.c | 85 +++++++++++++++++++++++++++++++++++
1 file changed, 85 insertions(+)
diff --git a/xen/common/emul/vuart/vuart.c b/xen/common/emul/vuart/vuart.c
index bd3b756fb4d6..0df29540b1b6 100644
--- a/xen/common/emul/vuart/vuart.c
+++ b/xen/common/emul/vuart/vuart.c
@@ -6,8 +6,10 @@
#include <asm/types.h>
+#include <xen/ctype.h>
#include <xen/err.h>
#include <xen/resource.h>
+#include <xen/param.h>
#include <xen/sched.h>
#include <xen/vuart.h>
#include <xen/xvmalloc.h>
@@ -18,6 +20,89 @@
extern const struct vuart_emulator vuart_array_start[];
extern const struct vuart_emulator vuart_array_end[];
+static domid_t __read_mostly opt_vuart_domid = DOMID_INVALID;
+static const struct vuart_info * __read_mostly opt_vuart_info;
+
+static const struct vuart_info vuart_supported[] = {
+#define VUART(c,n,t,a,s,i) { \
+ .compatible = c, \
+ .name = n, \
+ .flags = VUART_CONSOLE_INPUT, \
+ .base_type = t, \
+ .base_addr = a, \
+ .size = s, \
+ .irq = i, \
+}
+#ifdef CONFIG_VUART_NS16X50
+ VUART("ns16550", "com1", IORESOURCE_IO, 0x3f8u, 8u, 4u),
+ VUART("ns16550", "com2", IORESOURCE_IO, 0x2f8u, 8u, 3u),
+ VUART("ns16550", "com3", IORESOURCE_IO, 0x3feu, 8u, 4u),
+ VUART("ns16550", "com4", IORESOURCE_IO, 0x2feu, 8u, 3u),
+#endif /* CONFIG_VUART_NS16X50 */
+#undef VUART
+};
+
+static int __init cf_check vuart_parse_cmdline(const char *s)
+{
+ const char *compat = "ns16550";
+ size_t compat_len = strlen(compat);
+ const char *name = "com1";
+ size_t name_len = strlen(name);
+ const char *end;
+ domid_t domid;
+ unsigned int i;
+
+ /* vuart=domid:compatible,name */
+ if ( !isdigit(*s) )
+ return -EINVAL;
+
+ domid = simple_strtoul(s, &end, 0);
+ if ( domid >= DOMID_FIRST_RESERVED )
+ return -EINVAL;
+
+ if ( *end == '\0' )
+ goto match_defaults;
+
+ if ( *end != ':' )
+ return -EINVAL;
+
+ compat = end + 1;
+
+ while ( *end && *end != ',' )
+ end++;
+ if ( *end != ',' )
+ return -EINVAL;
+
+ compat_len = end - compat;
+ if ( !compat_len )
+ return -EINVAL;
+
+ name = end + 1;
+ name_len = strlen(name);
+ if ( !name_len )
+ return -EINVAL;
+
+ match_defaults:
+ for ( i = 0; i < ARRAY_SIZE(vuart_supported); i++ )
+ {
+ if ( compat_len != strlen(vuart_supported[i].compatible) ||
+ strncmp(compat, vuart_supported[i].compatible, compat_len) )
+ continue;
+
+ if ( name_len != strlen(vuart_supported[i].name) ||
+ strncmp(name, vuart_supported[i].name, name_len) )
+ continue;
+
+ opt_vuart_info = &vuart_supported[i];
+ opt_vuart_domid = domid;
+
+ return 0;
+ }
+
+ return -EINVAL;
+}
+custom_param("vuart", vuart_parse_cmdline);
+
static const struct vuart_emulator *
vuart_match_by_compatible(const struct domain *d, const char *compat)
{
--
2.56.0
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |