From: "Gabriel L. Somlo" <somlo@cmu.edu>
To: rydberg@euromail.se, khali@linux-fr.org, linux@roeck-us.net,
lm-sensors@lm-sensors.org, linux-kernel@vger.kernel.org
Cc: agraf@suse.de, rene@exactcode.com
Subject: [lm-sensors] [PATCH] applesmc: add sysfs file to report OSK
Date: Mon, 10 Dec 2012 14:51:35 +0000 [thread overview]
Message-ID: <20121210145134.GA2097@hedwig.ini.cmu.edu> (raw)
The AppleSMC contains two char[32] keys, OSK0 and OSK1, which are not
reported in the key count and index by default. These keys are used by
the OS X boot sequence, and normally don't matter when running Linux.
This patch creates a sysfs entry which reports the value of these keys
as an ASCII string, to help emulators (such as QEMU) load OS X when
running on genuine Apple hardware.
Signed-off-by: Gabriel L. Somlo <somlo@cmu.edu>
---
For extra context: To boot OS X as a guest, QEMU must (among others)
emulate the AppleSMC. To boot successfully, OS X insists on querying
the (emulated) SMC for the value of OSK0 and OSK1. Currently, these
values must be supplied on the QEMU command line as
-device applesmc,osk="...concatenated values of OSK0 and OSK1..."
With the availability of /sys/devices/platform/applesmc.768/osk, the
emulated QEMU AppleSMC could acquire this string directly from the
(Apple-manufactured) host machine.
Thanks,
Gabriel
drivers/hwmon/applesmc.c | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index b41baff..0c7cc71 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -1013,6 +1013,23 @@ static ssize_t applesmc_key_at_index_store(struct device *dev,
return count;
}
+static ssize_t applesmc_osk_show(struct device *dev,
+ struct device_attribute *attr, char *sysfsbuf)
+{
+ int fail;
+
+ mutex_lock(&smcreg.mutex);
+ fail = read_smc(APPLESMC_READ_CMD, "OSK0", sysfsbuf, 32) ||
+ read_smc(APPLESMC_READ_CMD, "OSK1", sysfsbuf + 32, 32);
+ mutex_unlock(&smcreg.mutex);
+ if (fail)
+ return -1;
+
+ sysfsbuf[64] = '\n';
+ sysfsbuf[65] = '\0';
+ return 65;
+}
+
static struct led_classdev applesmc_backlight = {
.name = "smc::kbd_backlight",
.default_trigger = "nand-disk",
@@ -1027,6 +1044,7 @@ static struct applesmc_node_group info_group[] = {
{ "key_at_index_type", applesmc_key_at_index_type_show },
{ "key_at_index_data_length", applesmc_key_at_index_data_length_show },
{ "key_at_index_data", applesmc_key_at_index_read_show },
+ { "osk", applesmc_osk_show },
{ }
};
--
1.7.7.6
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
WARNING: multiple messages have this Message-ID (diff)
From: "Gabriel L. Somlo" <somlo@cmu.edu>
To: rydberg@euromail.se, khali@linux-fr.org, linux@roeck-us.net,
lm-sensors@lm-sensors.org, linux-kernel@vger.kernel.org
Cc: agraf@suse.de, rene@exactcode.com
Subject: [PATCH] applesmc: add sysfs file to report OSK
Date: Mon, 10 Dec 2012 09:51:35 -0500 [thread overview]
Message-ID: <20121210145134.GA2097@hedwig.ini.cmu.edu> (raw)
The AppleSMC contains two char[32] keys, OSK0 and OSK1, which are not
reported in the key count and index by default. These keys are used by
the OS X boot sequence, and normally don't matter when running Linux.
This patch creates a sysfs entry which reports the value of these keys
as an ASCII string, to help emulators (such as QEMU) load OS X when
running on genuine Apple hardware.
Signed-off-by: Gabriel L. Somlo <somlo@cmu.edu>
---
For extra context: To boot OS X as a guest, QEMU must (among others)
emulate the AppleSMC. To boot successfully, OS X insists on querying
the (emulated) SMC for the value of OSK0 and OSK1. Currently, these
values must be supplied on the QEMU command line as
-device applesmc,osk="...concatenated values of OSK0 and OSK1..."
With the availability of /sys/devices/platform/applesmc.768/osk, the
emulated QEMU AppleSMC could acquire this string directly from the
(Apple-manufactured) host machine.
Thanks,
Gabriel
drivers/hwmon/applesmc.c | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/drivers/hwmon/applesmc.c b/drivers/hwmon/applesmc.c
index b41baff..0c7cc71 100644
--- a/drivers/hwmon/applesmc.c
+++ b/drivers/hwmon/applesmc.c
@@ -1013,6 +1013,23 @@ static ssize_t applesmc_key_at_index_store(struct device *dev,
return count;
}
+static ssize_t applesmc_osk_show(struct device *dev,
+ struct device_attribute *attr, char *sysfsbuf)
+{
+ int fail;
+
+ mutex_lock(&smcreg.mutex);
+ fail = read_smc(APPLESMC_READ_CMD, "OSK0", sysfsbuf, 32) ||
+ read_smc(APPLESMC_READ_CMD, "OSK1", sysfsbuf + 32, 32);
+ mutex_unlock(&smcreg.mutex);
+ if (fail)
+ return -1;
+
+ sysfsbuf[64] = '\n';
+ sysfsbuf[65] = '\0';
+ return 65;
+}
+
static struct led_classdev applesmc_backlight = {
.name = "smc::kbd_backlight",
.default_trigger = "nand-disk",
@@ -1027,6 +1044,7 @@ static struct applesmc_node_group info_group[] = {
{ "key_at_index_type", applesmc_key_at_index_type_show },
{ "key_at_index_data_length", applesmc_key_at_index_data_length_show },
{ "key_at_index_data", applesmc_key_at_index_read_show },
+ { "osk", applesmc_osk_show },
{ }
};
--
1.7.7.6
next reply other threads:[~2012-12-10 14:51 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-12-10 14:51 Gabriel L. Somlo [this message]
2012-12-10 14:51 ` [PATCH] applesmc: add sysfs file to report OSK Gabriel L. Somlo
2012-12-10 16:44 ` [lm-sensors] " Alexander Graf
2012-12-10 16:44 ` Alexander Graf
2012-12-10 19:09 ` [lm-sensors] " Guenter Roeck
2012-12-10 19:09 ` Guenter Roeck
2012-12-10 19:54 ` [lm-sensors] " Henrik Rydberg
2012-12-10 19:54 ` Henrik Rydberg
2012-12-10 20:19 ` [lm-sensors] " Alexander Graf
2012-12-10 20:19 ` Alexander Graf
2012-12-10 20:43 ` [lm-sensors] " Rene Rebe
2012-12-10 20:43 ` Rene Rebe
2012-12-10 21:24 ` [lm-sensors] " Alexander Graf
2012-12-10 21:24 ` Alexander Graf
2012-12-10 21:30 ` [lm-sensors] " Rene Rebe
2012-12-10 21:30 ` Rene Rebe
2012-12-10 22:23 ` [lm-sensors] [PATCH v2] " Gabriel L. Somlo
2012-12-10 22:23 ` Gabriel L. Somlo
2012-12-12 23:01 ` [lm-sensors] " Gabriel L. Somlo
2012-12-12 23:01 ` Gabriel L. Somlo
2012-12-13 7:20 ` [lm-sensors] " Henrik Rydberg
2012-12-13 7:20 ` Henrik Rydberg
2012-12-13 19:07 ` [lm-sensors] " Gabriel L. Somlo
2012-12-13 19:07 ` Gabriel L. Somlo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121210145134.GA2097@hedwig.ini.cmu.edu \
--to=somlo@cmu.edu \
--cc=agraf@suse.de \
--cc=khali@linux-fr.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=lm-sensors@lm-sensors.org \
--cc=rene@exactcode.com \
--cc=rydberg@euromail.se \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.