Skip to contentSkip to conversation

I8K: Allow i8k driver to be built on x86_64 systems

PATCH In review Bradley Smith 4 participants 6 messages Oct 28, 2007 – Oct 29, 2007 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 I8K: Allow i8k driver to be built on x86_64 systems

From: Bradley Smith <[email protected]>

Adds #if clause and additional inline assembly so that the driver builds on x86_64 systems.

---

drivers/char/i8k.c renamed from drivers/char/i8k.c.orig +28 -1
@@ -113,6 +113,33 @@ static int i8k_smm(struct smm_regs *regs
 	int rc;
 	int eax = regs->eax;
 
+#if defined(__x86_64__)
+	asm("pushq %%rax\n\t"
+		"movl 0(%%rax),%%edx\n\t"
+		"pushq %%rdx\n\t"
+		"movl 4(%%rax),%%ebx\n\t"
+		"movl 8(%%rax),%%ecx\n\t"
+		"movl 12(%%rax),%%edx\n\t"
+		"movl 16(%%rax),%%esi\n\t"
+		"movl 20(%%rax),%%edi\n\t"
+		"popq %%rax\n\t"
+		"out %%al,$0xb2\n\t"
+		"out %%al,$0x84\n\t"
+		"xchgq %%rax,(%%rsp)\n\t"
+		"movl %%ebx,4(%%rax)\n\t"
+		"movl %%ecx,8(%%rax)\n\t"
+		"movl %%edx,12(%%rax)\n\t"
+		"movl %%esi,16(%%rax)\n\t"
+		"movl %%edi,20(%%rax)\n\t"
+		"popq %%rdx\n\t"
+		"movl %%edx,0(%%rax)\n\t"
+		"lahf\n\t"
+		"shrl $8,%%eax\n\t"
+		"andl $1,%%eax\n"
+		:"=a"(rc)
+		:    "a"(regs)
+		:    "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory");
+#else
 	asm("pushl %%eax\n\t"
 	    "movl 0(%%eax),%%edx\n\t"
 	    "push %%edx\n\t"
@@ -137,7 +164,7 @@ static int i8k_smm(struct smm_regs *regs
 	    "andl $1,%%eax\n":"=a"(rc)
 	    :    "a"(regs)
 	    :    "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory");
-
+#endif
 	if (rc != 0 || (regs->eax & 0xffff) == 0xffff || regs->eax == eax)
 		return -EINVAL;
 
#1 lore raw
Quoted 12 lines · Bradley Smith

From: Bradley Smith <[email protected]>

Adds #if clause and additional inline assembly so that the driver builds on x86_64 systems.

---

drivers/char/i8k.c static int i8k_smm(struct smm_regs *regs · line 116

Quoted 5 lines
drivers/char/i8k.c renamed from drivers/char/i8k.c.orig +1 -0
@@ -113,6 +113,33 @@ static int i8k_smm(struct smm_regs *regs
 	int rc;
 	int eax = regs->eax;
 
+#if defined(__x86_64__)
...

Please use CONFIG_X86_64.

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
#2 lore raw
Quoted 6 lines · On Sun, 28 Oct 2007 18:37:24 +0100 Adrian Bunk <[email protected]> wrote:

Please use CONFIG_X86_64.

cu
Adrian

Now uses CONFIG_X86_64.

Brad.

drivers/char/i8k.c renamed from drivers/char/i8k.c.orig +28 -1
@@ -113,6 +113,33 @@ static int i8k_smm(struct smm_regs *regs
 	int rc;
 	int eax = regs->eax;
 
+#if defined(CONFIG_X86_64)
+	asm("pushq %%rax\n\t"
+		"movl 0(%%rax),%%edx\n\t"
+		"pushq %%rdx\n\t"
+		"movl 4(%%rax),%%ebx\n\t"
+		"movl 8(%%rax),%%ecx\n\t"
+		"movl 12(%%rax),%%edx\n\t"
+		"movl 16(%%rax),%%esi\n\t"
+		"movl 20(%%rax),%%edi\n\t"
+		"popq %%rax\n\t"
+		"out %%al,$0xb2\n\t"
+		"out %%al,$0x84\n\t"
+		"xchgq %%rax,(%%rsp)\n\t"
+		"movl %%ebx,4(%%rax)\n\t"
+		"movl %%ecx,8(%%rax)\n\t"
+		"movl %%edx,12(%%rax)\n\t"
+		"movl %%esi,16(%%rax)\n\t"
+		"movl %%edi,20(%%rax)\n\t"
+		"popq %%rdx\n\t"
+		"movl %%edx,0(%%rax)\n\t"
+		"lahf\n\t"
+		"shrl $8,%%eax\n\t"
+		"andl $1,%%eax\n"
+		:"=a"(rc)
+		:    "a"(regs)
+		:    "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory");
+#else
 	asm("pushl %%eax\n\t"
 	    "movl 0(%%eax),%%edx\n\t"
 	    "push %%edx\n\t"
@@ -137,7 +164,7 @@ static int i8k_smm(struct smm_regs *regs
 	    "andl $1,%%eax\n":"=a"(rc)
 	    :    "a"(regs)
 	    :    "%ebx", "%ecx", "%edx", "%esi", "%edi", "memory");
-
+#endif
 	if (rc != 0 || (regs->eax & 0xffff) == 0xffff || regs->eax == eax)
 		return -EINVAL;
 
#4 lore raw
Quoted 12 lines · On Sun, 28 Oct 2007 13:59:22 -0400 Jeff Garzik <[email protected]> wrote:
Quoted 6 lines · Bradley Smith

From: Bradley Smith <[email protected]>

Adds #if clause and additional inline assembly so that the driver builds on x86_64 systems.

Is this actually known to be working on a Dell laptop?

Jeff

Yes, I have a dell laptop, and it works. (I have been using it for quite a while).

Brad.

#5 lore raw
In reply to Jeff Garzik

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Quoted 11 lines · Jeff Garzik
Quoted 6 lines · Bradley Smith

From: Bradley Smith <[email protected]>

Adds #if clause and additional inline assembly so that the driver builds on x86_64 systems.

Is this actually known to be working on a Dell laptop?

Jeff

Yes, the patch works well on my Dell, and I've got several follow-up patches to Brad's. During the last i8k refresh
(http://lkml.org/lkml/2005/2/24/11), not everything made it into mainline, so i8k is due for another facelift.

Needs the following in order to work correctly on my Inspiron E1705:

Add DMI Product name to i8k for Dell MP061 hardware (Inspiron 9400/E1705)

- ---

 drivers/char/i8k.c |    7 +++++++
 1 file changed, 7 insertions(+)

Index: linux-2.6.24-rc1/drivers/char/i8k.c
===================================================================
- --- linux-2.6.24-rc1.orig/drivers/char/i8k.c 2007-10-29 00:27:21.000000000 -0500
+++ linux-2.6.24-rc1/drivers/char/i8k.c 2007-10-29 00:30:05.000000000 -0500
@@ -468,6 +468,13 @@
DMI_MATCH(DMI_PRODUCT_NAME, "Latitude"),
},
},
+ {
+ .ident = "Dell Inspiron 3",
+ .matches = {
+ DMI_MATCH(DMI_SYS_VENDOR, "Dell Inc."),
+ DMI_MATCH(DMI_PRODUCT_NAME, "MP061"),
+ },
+ },
{ }
};

Frank
- --
Frank Sorenson - KD7TZK
Linux Systems Engineer, DSS Engineering, UBS AG [email protected]

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.7 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org

iD8DBQFHJXnUaI0dwg4A47wRApQrAKDKb0Zq+QrG+CUsXrpfoxVxLyM+PQCg5uZc kvUjuY3a1F7MIx0Z9DSrYbg=
=IcmN
-----END PGP SIGNATURE-----