aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/ABI/testing/sysfs-firmware-efi20
-rw-r--r--arch/x86/platform/efi/efi.c4
-rw-r--r--drivers/firmware/efi/efi.c41
-rw-r--r--include/linux/efi.h3
4 files changed, 67 insertions, 1 deletions
diff --git a/Documentation/ABI/testing/sysfs-firmware-efi b/Documentation/ABI/testing/sysfs-firmware-efi
new file mode 100644
index 000000000000..05874da7ce80
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-firmware-efi
@@ -0,0 +1,20 @@
1What: /sys/firmware/efi/fw_vendor
2Date: December 2013
3Contact: Dave Young <dyoung@redhat.com>
4Description: It shows the physical address of firmware vendor field in the
5 EFI system table.
6Users: Kexec
7
8What: /sys/firmware/efi/runtime
9Date: December 2013
10Contact: Dave Young <dyoung@redhat.com>
11Description: It shows the physical address of runtime service table entry in
12 the EFI system table.
13Users: Kexec
14
15What: /sys/firmware/efi/config_table
16Date: December 2013
17Contact: Dave Young <dyoung@redhat.com>
18Description: It shows the physical address of config table entry in the EFI
19 system table.
20Users: Kexec
diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c
index 4694632ef581..28591072fbb7 100644
--- a/arch/x86/platform/efi/efi.c
+++ b/arch/x86/platform/efi/efi.c
@@ -653,6 +653,10 @@ void __init efi_init(void)
653 653
654 set_bit(EFI_SYSTEM_TABLES, &x86_efi_facility); 654 set_bit(EFI_SYSTEM_TABLES, &x86_efi_facility);
655 655
656 efi.config_table = (unsigned long)efi.systab->tables;
657 efi.fw_vendor = (unsigned long)efi.systab->fw_vendor;
658 efi.runtime = (unsigned long)efi.systab->runtime;
659
656 /* 660 /*
657 * Show what we know for posterity 661 * Show what we know for posterity
658 */ 662 */
diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c
index 2e2fbdec0845..72533af72b98 100644
--- a/drivers/firmware/efi/efi.c
+++ b/drivers/firmware/efi/efi.c
@@ -32,6 +32,9 @@ struct efi __read_mostly efi = {
32 .hcdp = EFI_INVALID_TABLE_ADDR, 32 .hcdp = EFI_INVALID_TABLE_ADDR,
33 .uga = EFI_INVALID_TABLE_ADDR, 33 .uga = EFI_INVALID_TABLE_ADDR,
34 .uv_systab = EFI_INVALID_TABLE_ADDR, 34 .uv_systab = EFI_INVALID_TABLE_ADDR,
35 .fw_vendor = EFI_INVALID_TABLE_ADDR,
36 .runtime = EFI_INVALID_TABLE_ADDR,
37 .config_table = EFI_INVALID_TABLE_ADDR,
35}; 38};
36EXPORT_SYMBOL(efi); 39EXPORT_SYMBOL(efi);
37 40
@@ -71,13 +74,49 @@ static ssize_t systab_show(struct kobject *kobj,
71static struct kobj_attribute efi_attr_systab = 74static struct kobj_attribute efi_attr_systab =
72 __ATTR(systab, 0400, systab_show, NULL); 75 __ATTR(systab, 0400, systab_show, NULL);
73 76
77#define EFI_FIELD(var) efi.var
78
79#define EFI_ATTR_SHOW(name) \
80static ssize_t name##_show(struct kobject *kobj, \
81 struct kobj_attribute *attr, char *buf) \
82{ \
83 return sprintf(buf, "0x%lx\n", EFI_FIELD(name)); \
84}
85
86EFI_ATTR_SHOW(fw_vendor);
87EFI_ATTR_SHOW(runtime);
88EFI_ATTR_SHOW(config_table);
89
90static struct kobj_attribute efi_attr_fw_vendor = __ATTR_RO(fw_vendor);
91static struct kobj_attribute efi_attr_runtime = __ATTR_RO(runtime);
92static struct kobj_attribute efi_attr_config_table = __ATTR_RO(config_table);
93
74static struct attribute *efi_subsys_attrs[] = { 94static struct attribute *efi_subsys_attrs[] = {
75 &efi_attr_systab.attr, 95 &efi_attr_systab.attr,
76 NULL, /* maybe more in the future? */ 96 &efi_attr_fw_vendor.attr,
97 &efi_attr_runtime.attr,
98 &efi_attr_config_table.attr,
99 NULL,
77}; 100};
78 101
102static umode_t efi_attr_is_visible(struct kobject *kobj,
103 struct attribute *attr, int n)
104{
105 umode_t mode = attr->mode;
106
107 if (attr == &efi_attr_fw_vendor.attr)
108 return (efi.fw_vendor == EFI_INVALID_TABLE_ADDR) ? 0 : mode;
109 else if (attr == &efi_attr_runtime.attr)
110 return (efi.runtime == EFI_INVALID_TABLE_ADDR) ? 0 : mode;
111 else if (attr == &efi_attr_config_table.attr)
112 return (efi.config_table == EFI_INVALID_TABLE_ADDR) ? 0 : mode;
113
114 return mode;
115}
116
79static struct attribute_group efi_subsys_attr_group = { 117static struct attribute_group efi_subsys_attr_group = {
80 .attrs = efi_subsys_attrs, 118 .attrs = efi_subsys_attrs,
119 .is_visible = efi_attr_is_visible,
81}; 120};
82 121
83static struct efivars generic_efivars; 122static struct efivars generic_efivars;
diff --git a/include/linux/efi.h b/include/linux/efi.h
index 6c0ca528300c..fb60b10b7bd9 100644
--- a/include/linux/efi.h
+++ b/include/linux/efi.h
@@ -556,6 +556,9 @@ extern struct efi {
556 unsigned long hcdp; /* HCDP table */ 556 unsigned long hcdp; /* HCDP table */
557 unsigned long uga; /* UGA table */ 557 unsigned long uga; /* UGA table */
558 unsigned long uv_systab; /* UV system table */ 558 unsigned long uv_systab; /* UV system table */
559 unsigned long fw_vendor; /* fw_vendor */
560 unsigned long runtime; /* runtime table */
561 unsigned long config_table; /* config tables */
559 efi_get_time_t *get_time; 562 efi_get_time_t *get_time;
560 efi_set_time_t *set_time; 563 efi_set_time_t *set_time;
561 efi_get_wakeup_time_t *get_wakeup_time; 564 efi_get_wakeup_time_t *get_wakeup_time;