10 #include <linux/slab.h>
11 #include <linux/kernel.h>
12 #include <linux/module.h>
16 #include <asm/xen/hypervisor.h>
17 #include <asm/xen/hypercall.h>
24 #define HYPERVISOR_ATTR_RO(_name) \
25 static struct hyp_sysfs_attr _name##_attr = __ATTR_RO(_name)
27 #define HYPERVISOR_ATTR_RW(_name) \
28 static struct hyp_sysfs_attr _name##_attr = \
29 __ATTR(_name, 0644, _name##_show, _name##_store)
40 return sprintf(buffer,
"xen\n");
45 static int __init xen_sysfs_type_init(
void)
50 static void xen_sysfs_type_destroy(
void)
60 return sprintf(buffer,
"%d\n", version >> 16);
70 return sprintf(buffer,
"%d\n", version & 0xff);
85 ret =
sprintf(buffer,
"%s\n", extra);
94 static struct attribute *version_attrs[] = {
103 .attrs = version_attrs,
106 static int __init xen_sysfs_version_init(
void)
111 static void xen_sysfs_version_destroy(
void)
124 if (!xenstored_ready)
134 ret =
sprintf(buffer,
"%s\n", val);
145 return uuid_show_fallback(attr, buffer);
146 ret =
sprintf(buffer,
"%pU\n", uuid);
152 static int __init xen_sysfs_uuid_init(
void)
157 static void xen_sysfs_uuid_destroy(
void)
218 static struct attribute *xen_compile_attrs[] = {
220 &compiled_by_attr.attr,
221 &compile_date_attr.attr,
226 .name =
"compilation",
227 .attrs = xen_compile_attrs,
230 static int __init xen_compilation_init(
void)
235 static void xen_compilation_destroy(
void)
251 ret =
sprintf(buffer,
"%s\n", caps);
269 ret =
sprintf(buffer,
"%s\n", cset);
304 ret =
sprintf(buffer,
"%x\n", ret);
311 static ssize_t xen_feature_show(
int index,
char *buffer)
316 info.submap_idx =
index;
319 ret =
sprintf(buffer,
"%08x", info.submap);
331 int ret = xen_feature_show(i, buffer + len);
340 buffer[len++] =
'\n';
347 static struct attribute *xen_properties_attrs[] = {
348 &capabilities_attr.attr,
349 &changeset_attr.attr,
350 &virtual_start_attr.attr,
357 .name =
"properties",
358 .attrs = xen_properties_attrs,
361 static int __init xen_properties_init(
void)
366 static void xen_properties_destroy(
void)
371 static int __init hyper_sysfs_init(
void)
378 ret = xen_sysfs_type_init();
381 ret = xen_sysfs_version_init();
384 ret = xen_compilation_init();
387 ret = xen_sysfs_uuid_init();
390 ret = xen_properties_init();
397 xen_sysfs_uuid_destroy();
399 xen_compilation_destroy();
401 xen_sysfs_version_destroy();
403 xen_sysfs_type_destroy();
408 static void __exit hyper_sysfs_exit(
void)
410 xen_properties_destroy();
411 xen_compilation_destroy();
412 xen_sysfs_uuid_destroy();
413 xen_sysfs_version_destroy();
414 xen_sysfs_type_destroy();
427 return hyp_attr->
show(hyp_attr, buffer);
439 return hyp_attr->
store(hyp_attr, buffer, len);
443 static const struct sysfs_ops hyp_sysfs_ops = {
444 .show = hyp_sysfs_show,
445 .store = hyp_sysfs_store,
448 static struct kobj_type hyp_sysfs_kobj_type = {
449 .sysfs_ops = &hyp_sysfs_ops,
452 static int __init hypervisor_subsys_init(
void)