diff options
-rw-r--r-- | Documentation/ABI/testing/sysfs-firmware-acpi | 20 | ||||
-rw-r--r-- | drivers/acpi/Kconfig | 9 | ||||
-rw-r--r-- | drivers/acpi/Makefile | 1 | ||||
-rw-r--r-- | drivers/acpi/bgrt.c | 175 |
4 files changed, 205 insertions, 0 deletions
diff --git a/Documentation/ABI/testing/sysfs-firmware-acpi b/Documentation/ABI/testing/sysfs-firmware-acpi index 4f9ba3c2fca7..dd930c8db41f 100644 --- a/Documentation/ABI/testing/sysfs-firmware-acpi +++ b/Documentation/ABI/testing/sysfs-firmware-acpi | |||
@@ -1,3 +1,23 @@ | |||
1 | What: /sys/firmware/acpi/bgrt/ | ||
2 | Date: January 2012 | ||
3 | Contact: Matthew Garrett <mjg@redhat.com> | ||
4 | Description: | ||
5 | The BGRT is an ACPI 5.0 feature that allows the OS | ||
6 | to obtain a copy of the firmware boot splash and | ||
7 | some associated metadata. This is intended to be used | ||
8 | by boot splash applications in order to interact with | ||
9 | the firmware boot splash in order to avoid jarring | ||
10 | transitions. | ||
11 | |||
12 | image: The image bitmap. Currently a 32-bit BMP. | ||
13 | status: 1 if the image is valid, 0 if firmware invalidated it. | ||
14 | type: 0 indicates image is in BMP format. | ||
15 | version: The version of the BGRT. Currently 1. | ||
16 | xoffset: The number of pixels between the left of the screen | ||
17 | and the left edge of the image. | ||
18 | yoffset: The number of pixels between the top of the screen | ||
19 | and the top edge of the image. | ||
20 | |||
1 | What: /sys/firmware/acpi/interrupts/ | 21 | What: /sys/firmware/acpi/interrupts/ |
2 | Date: February 2008 | 22 | Date: February 2008 |
3 | Contact: Len Brown <lenb@kernel.org> | 23 | Contact: Len Brown <lenb@kernel.org> |
diff --git a/drivers/acpi/Kconfig b/drivers/acpi/Kconfig index 7556913aba45..47768ff87343 100644 --- a/drivers/acpi/Kconfig +++ b/drivers/acpi/Kconfig | |||
@@ -384,6 +384,15 @@ config ACPI_CUSTOM_METHOD | |||
384 | load additional kernel modules after boot, this feature may be used | 384 | load additional kernel modules after boot, this feature may be used |
385 | to override that restriction). | 385 | to override that restriction). |
386 | 386 | ||
387 | config ACPI_BGRT | ||
388 | tristate "Boottime Graphics Resource Table support" | ||
389 | default n | ||
390 | help | ||
391 | This driver adds support for exposing the ACPI Boottime Graphics | ||
392 | Resource Table, which allows the operating system to obtain | ||
393 | data from the firmware boot splash. It will appear under | ||
394 | /sys/firmware/acpi/bgrt/ . | ||
395 | |||
387 | source "drivers/acpi/apei/Kconfig" | 396 | source "drivers/acpi/apei/Kconfig" |
388 | 397 | ||
389 | endif # ACPI | 398 | endif # ACPI |
diff --git a/drivers/acpi/Makefile b/drivers/acpi/Makefile index 1567028d2038..47199e2a9130 100644 --- a/drivers/acpi/Makefile +++ b/drivers/acpi/Makefile | |||
@@ -62,6 +62,7 @@ obj-$(CONFIG_ACPI_SBS) += sbs.o | |||
62 | obj-$(CONFIG_ACPI_HED) += hed.o | 62 | obj-$(CONFIG_ACPI_HED) += hed.o |
63 | obj-$(CONFIG_ACPI_EC_DEBUGFS) += ec_sys.o | 63 | obj-$(CONFIG_ACPI_EC_DEBUGFS) += ec_sys.o |
64 | obj-$(CONFIG_ACPI_CUSTOM_METHOD)+= custom_method.o | 64 | obj-$(CONFIG_ACPI_CUSTOM_METHOD)+= custom_method.o |
65 | obj-$(CONFIG_ACPI_BGRT) += bgrt.o | ||
65 | 66 | ||
66 | # processor has its own "processor." module_param namespace | 67 | # processor has its own "processor." module_param namespace |
67 | processor-y := processor_driver.o processor_throttling.o | 68 | processor-y := processor_driver.o processor_throttling.o |
diff --git a/drivers/acpi/bgrt.c b/drivers/acpi/bgrt.c new file mode 100644 index 000000000000..8cf6c46e99fb --- /dev/null +++ b/drivers/acpi/bgrt.c | |||
@@ -0,0 +1,175 @@ | |||
1 | /* | ||
2 | * Copyright 2012 Red Hat, Inc <mjg@redhat.com> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License version 2 as | ||
6 | * published by the Free Software Foundation. | ||
7 | */ | ||
8 | |||
9 | #include <linux/kernel.h> | ||
10 | #include <linux/module.h> | ||
11 | #include <linux/init.h> | ||
12 | #include <linux/device.h> | ||
13 | #include <linux/sysfs.h> | ||
14 | #include <acpi/acpi.h> | ||
15 | #include <acpi/acpi_bus.h> | ||
16 | |||
17 | static struct acpi_table_bgrt *bgrt_tab; | ||
18 | static struct kobject *bgrt_kobj; | ||
19 | |||
20 | struct bmp_header { | ||
21 | u16 id; | ||
22 | u32 size; | ||
23 | } __attribute ((packed)); | ||
24 | |||
25 | static struct bmp_header bmp_header; | ||
26 | |||
27 | static ssize_t show_version(struct device *dev, | ||
28 | struct device_attribute *attr, char *buf) | ||
29 | { | ||
30 | return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab->version); | ||
31 | } | ||
32 | static DEVICE_ATTR(version, S_IRUGO, show_version, NULL); | ||
33 | |||
34 | static ssize_t show_status(struct device *dev, | ||
35 | struct device_attribute *attr, char *buf) | ||
36 | { | ||
37 | return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab->status); | ||
38 | } | ||
39 | static DEVICE_ATTR(status, S_IRUGO, show_status, NULL); | ||
40 | |||
41 | static ssize_t show_type(struct device *dev, | ||
42 | struct device_attribute *attr, char *buf) | ||
43 | { | ||
44 | return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab->image_type); | ||
45 | } | ||
46 | static DEVICE_ATTR(type, S_IRUGO, show_type, NULL); | ||
47 | |||
48 | static ssize_t show_xoffset(struct device *dev, | ||
49 | struct device_attribute *attr, char *buf) | ||
50 | { | ||
51 | return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab->image_offset_x); | ||
52 | } | ||
53 | static DEVICE_ATTR(xoffset, S_IRUGO, show_xoffset, NULL); | ||
54 | |||
55 | static ssize_t show_yoffset(struct device *dev, | ||
56 | struct device_attribute *attr, char *buf) | ||
57 | { | ||
58 | return snprintf(buf, PAGE_SIZE, "%d\n", bgrt_tab->image_offset_y); | ||
59 | } | ||
60 | static DEVICE_ATTR(yoffset, S_IRUGO, show_yoffset, NULL); | ||
61 | |||
62 | static ssize_t show_image(struct file *file, struct kobject *kobj, | ||
63 | struct bin_attribute *attr, char *buf, loff_t off, size_t count) | ||
64 | { | ||
65 | int size = attr->size; | ||
66 | void __iomem *image = attr->private; | ||
67 | |||
68 | if (off >= size) { | ||
69 | count = 0; | ||
70 | } else { | ||
71 | if (off + count > size) | ||
72 | count = size - off; | ||
73 | |||
74 | memcpy_fromio(buf, image+off, count); | ||
75 | } | ||
76 | |||
77 | return count; | ||
78 | } | ||
79 | |||
80 | static struct bin_attribute image_attr = { | ||
81 | .attr = { | ||
82 | .name = "image", | ||
83 | .mode = S_IRUGO, | ||
84 | }, | ||
85 | .read = show_image, | ||
86 | }; | ||
87 | |||
88 | static struct attribute *bgrt_attributes[] = { | ||
89 | &dev_attr_version.attr, | ||
90 | &dev_attr_status.attr, | ||
91 | &dev_attr_type.attr, | ||
92 | &dev_attr_xoffset.attr, | ||
93 | &dev_attr_yoffset.attr, | ||
94 | NULL, | ||
95 | }; | ||
96 | |||
97 | static struct attribute_group bgrt_attribute_group = { | ||
98 | .attrs = bgrt_attributes, | ||
99 | }; | ||
100 | |||
101 | static int __init bgrt_init(void) | ||
102 | { | ||
103 | acpi_status status; | ||
104 | int ret; | ||
105 | void __iomem *bgrt; | ||
106 | |||
107 | if (acpi_disabled) | ||
108 | return -ENODEV; | ||
109 | |||
110 | status = acpi_get_table("BGRT", 0, | ||
111 | (struct acpi_table_header **)&bgrt_tab); | ||
112 | |||
113 | if (ACPI_FAILURE(status)) | ||
114 | return -ENODEV; | ||
115 | |||
116 | sysfs_bin_attr_init(&image_attr); | ||
117 | |||
118 | bgrt = ioremap(bgrt_tab->image_address, sizeof(struct bmp_header)); | ||
119 | |||
120 | if (!bgrt) { | ||
121 | ret = -EINVAL; | ||
122 | goto out_err; | ||
123 | } | ||
124 | |||
125 | memcpy_fromio(&bmp_header, bgrt, sizeof(bmp_header)); | ||
126 | image_attr.size = bmp_header.size; | ||
127 | iounmap(bgrt); | ||
128 | |||
129 | image_attr.private = ioremap(bgrt_tab->image_address, image_attr.size); | ||
130 | |||
131 | if (!image_attr.private) { | ||
132 | ret = -EINVAL; | ||
133 | goto out_err; | ||
134 | } | ||
135 | |||
136 | |||
137 | bgrt_kobj = kobject_create_and_add("bgrt", acpi_kobj); | ||
138 | if (!bgrt_kobj) { | ||
139 | ret = -EINVAL; | ||
140 | goto out_iounmap; | ||
141 | } | ||
142 | |||
143 | ret = sysfs_create_group(bgrt_kobj, &bgrt_attribute_group); | ||
144 | if (ret) | ||
145 | goto out_kobject; | ||
146 | |||
147 | ret = sysfs_create_bin_file(bgrt_kobj, &image_attr); | ||
148 | if (ret) | ||
149 | goto out_group; | ||
150 | |||
151 | return 0; | ||
152 | |||
153 | out_group: | ||
154 | sysfs_remove_group(bgrt_kobj, &bgrt_attribute_group); | ||
155 | out_kobject: | ||
156 | kobject_put(bgrt_kobj); | ||
157 | out_iounmap: | ||
158 | iounmap(image_attr.private); | ||
159 | out_err: | ||
160 | return ret; | ||
161 | } | ||
162 | |||
163 | static void __exit bgrt_exit(void) | ||
164 | { | ||
165 | iounmap(image_attr.private); | ||
166 | sysfs_remove_group(bgrt_kobj, &bgrt_attribute_group); | ||
167 | sysfs_remove_bin_file(bgrt_kobj, &image_attr); | ||
168 | } | ||
169 | |||
170 | module_init(bgrt_init); | ||
171 | module_exit(bgrt_exit); | ||
172 | |||
173 | MODULE_AUTHOR("Matthew Garrett"); | ||
174 | MODULE_DESCRIPTION("BGRT boot graphic support"); | ||
175 | MODULE_LICENSE("GPL"); | ||