2005-09-07 02:19:35

by Miloslav Trmac

[permalink] [raw]
Subject: [PATCH] Wistron laptop button driver

Hello,
attached (as a patch against 2.6.13-git6) is a driver for laptop buttons
on my Fujitsu-Siemens Amilo Pro V2000; it seems quite a few other
laptops use the same interface (with differing sets of buttons).

Thanks,
Mirek


Attachments:
wistron_btns.patch (11.82 kB)

2005-09-08 05:24:16

by Andrew Morton

[permalink] [raw]
Subject: Re: [PATCH] Wistron laptop button driver

Miloslav Trmac <[email protected]> wrote:
>
> +static void call_bios(struct regs *regs)
> +{
> + unsigned long flags;
> +
> + preempt_disable();
> + local_irq_save(flags);
> + asm volatile ("pushl %%ebp;"
> + "movl %[data], %%ebp;"
> + "call *%[routine];"
> + "popl %%ebp"
> + : "=a" (regs->eax), "=b" (regs->ebx), "=c" (regs->ecx)
> + : "0" (regs->eax), "1" (regs->ebx), "2" (regs->ecx),
> + [routine] "m" (bios_entry_point),
> + [data] "m" (bios_data_map_base)
> + : "edx", "edi", "esi", "memory");
> + local_irq_restore(flags);
> + preempt_enable();
> +}
> +

(the preempt_disable/enable isn't needed - local_irq_save() will suffice)

gcc-2.95.x spits the dummy over this [routine] stuff. What compiler does
this require?

Is it necessary to open-code the BIOS call in the driver? Does it make
sense to have some library function to do this?

2005-09-08 06:43:28

by Pekka Enberg

[permalink] [raw]
Subject: Re: [PATCH] Wistron laptop button driver

On 9/7/05, Miloslav Trmac <[email protected]> wrote:
> +static int __init map_bios(void)
> +{
> + static const unsigned char __initdata signature[]
> + = { 0x42, 0x21, 0x55, 0x30 };
> +
> + void __iomem *base;
> + size_t offset;
> + uint32_t entry_point;
> +
> + base = ioremap(0xF0000, 0x10000); /* Can't fail */

How come? ioremap can return NULL if, for example, we run out of memory.

> + for (offset = 0; offset < 0x10000; offset += 0x10) {
> + if (check_signature(base + offset, signature,
> + sizeof(signature)) != 0)
> + goto found;
> + }

Pekka

2005-09-08 09:37:11

by Miloslav Trmac

[permalink] [raw]
Subject: Re: [PATCH] Wistron laptop button driver

Pekka Enberg wrote:
> On 9/7/05, Miloslav Trmac <[email protected]> wrote:
>
>>+static int __init map_bios(void)
>>+{
>>+ static const unsigned char __initdata signature[]
>>+ = { 0x42, 0x21, 0x55, 0x30 };
>>+
>>+ void __iomem *base;
>>+ size_t offset;
>>+ uint32_t entry_point;
>>+
>>+ base = ioremap(0xF0000, 0x10000); /* Can't fail */
>
> How come? ioremap can return NULL if, for example, we run out of memory.
Not with these values:
> /*
> * Don't remap the low PCI/ISA area, it's always mapped..
> */
> if (phys_addr >= ISA_START_ADDRESS && last_addr < ISA_END_ADDRESS)
> return (void __iomem *) phys_to_virt(phys_addr);

Mirek

2005-09-08 09:33:01

by Miloslav Trmac

[permalink] [raw]
Subject: Re: [PATCH] Wistron laptop button driver

Andrew Morton wrote:
> Miloslav Trmac <[email protected]> wrote:
>
>>+static void call_bios(struct regs *regs)
>> +{
>> + unsigned long flags;
>> +
>> + preempt_disable();
>> + local_irq_save(flags);
>> + asm volatile ("pushl %%ebp;"
>> + "movl %[data], %%ebp;"
>> + "call *%[routine];"
>> + "popl %%ebp"
>> + : "=a" (regs->eax), "=b" (regs->ebx), "=c" (regs->ecx)
>> + : "0" (regs->eax), "1" (regs->ebx), "2" (regs->ecx),
>> + [routine] "m" (bios_entry_point),
>> + [data] "m" (bios_data_map_base)
>> + : "edx", "edi", "esi", "memory");
>> + local_irq_restore(flags);
>> + preempt_enable();
>> +}
>> +
>
> gcc-2.95.x spits the dummy over this [routine] stuff. What compiler does
> this require?
(info gcc) says gcc >= 3.1.

> Is it necessary to open-code the BIOS call in the driver? Does it make
> sense to have some library function to do this?
A general library function (handling all registers) would have to be
written in assembler because gcc has trouble allocating registers
otherwise; considering that we should ideally avoid BIOS calls and that
such a function wasn't needed in the last 14 years, I don't think it is
worth the effort.
Mirek

2005-09-25 21:35:36

by Miloslav Trmac

[permalink] [raw]
Subject: Re: [PATCH] Wistron laptop button driver

Hello,
I'm not quite sure what has happened to the original patch, I hope it is
in someone's input tree.

Nevertheless, attached is a patch to add support for Thorsten's hardware.

Thanks,
Mirek


Attachments:
wistron_btns-ms2141.patch (2.19 kB)