1 --- linux-2.6.21/drivers/acpi/toshiba_acpi.c.21.orig 2007-04-28 00:49:26.000000000 +0300
2 +++ linux-2.6.21/drivers/acpi/toshiba_acpi.c 2007-05-15 19:23:32.000000000 +0300
4 * Yasushi Nagato - changes for linux kernel 2.4 -> 2.5
5 * Rob Miller - TV out and hotkeys help
9 + * This is an experimental version of toshiba_acpi which includes emulation
10 + * of the original toshiba driver's /proc/toshiba and /dev/toshiba,
11 + * allowing Toshiba userspace utilities to work. The relevant code was
12 + * based on toshiba.c (copyright 1996-2001 Jonathan A. Buzzard) and
13 + * incorporated into this driver with help from Gintautas Miliauskas,
14 + * Charles Schwieters, and Christoph Burger-Scheidlin.
17 + * * hotkey status in /proc/toshiba is not implemented
18 + * * to make accesses to /dev/toshiba load this driver instead of
19 + * the original driver, you will have to modify your module
20 + * auto-loading configuration
26 -#define TOSHIBA_ACPI_VERSION "0.18"
27 +#define TOSHIBA_ACPI_VERSION "experimental-dev-toshiba-test-5"
28 #define PROC_INTERFACE_VERSION 1
30 #include <linux/kernel.h>
32 #include <linux/init.h>
33 #include <linux/types.h>
34 #include <linux/proc_fs.h>
35 +#include <linux/miscdevice.h>
36 +#include <linux/toshiba.h>
38 #include <linux/backlight.h>
40 #include <asm/uaccess.h>
45 +/* /dev/toshiba and /proc/toshiba handlers {{{
47 + * ISSUE: lots of magic numbers and mysterious code
50 +#define TOSH_MINOR_DEV 181
51 +#define OLD_PROC_TOSHIBA "toshiba"
54 +tosh_acpi_bridge(SMMRegisters* regs)
58 + /* assert(sizeof(SMMRegisters) == sizeof(u32)*HCI_WORDS); */
59 + status = hci_raw((u32*)regs, (u32*)regs);
60 + if (status == AE_OK && (regs->eax & 0xff00) == HCI_SUCCESS)
67 +tosh_ioctl(struct inode* ip, struct file* fp, unsigned int cmd,
71 + unsigned short ax,bx;
74 + if ((!arg) || (cmd != TOSH_SMM))
77 + if (copy_from_user(®s, (SMMRegisters*)arg, sizeof(SMMRegisters)))
80 + ax = regs.eax & 0xff00;
81 + bx = regs.ebx & 0xffff;
83 + /* block HCI calls to read/write memory & PCI devices */
84 + if (((ax==HCI_SET) || (ax==HCI_GET)) && (bx>0x0069))
87 + err = tosh_acpi_bridge(®s);
89 + if (copy_to_user((SMMRegisters*)arg, ®s, sizeof(SMMRegisters)))
96 +tosh_get_machine_id(void __iomem *bios)
99 + unsigned short bx,cx;
100 + unsigned long address;
102 + id = (0x100*(int) readb(bios+0xfffe))+((int) readb(bios+0xfffa));
104 + /* do we have a SCTTable machine identication number on our hands */
106 + bx = 0xe6f5; /* cheat */
107 + /* now twiddle with our pointer a bit */
108 + address = 0x00000000 + bx;
109 + cx = readw(bios + address);
110 + address = 0x00000009 + bx + cx;
111 + cx = readw(bios + address);
112 + address = 0x0000000a + cx;
113 + cx = readw(bios + address);
114 + /* now construct our machine identification number */
115 + id = ((cx & 0xff)<<8)+((cx & 0xff00)>>8);
122 +static int tosh_bios;
123 +static int tosh_date;
124 +static int tosh_sci;
126 +static struct file_operations tosh_fops = {
127 + .owner = THIS_MODULE,
128 + .ioctl = tosh_ioctl
131 +static struct miscdevice tosh_device = {
138 +setup_tosh_info(void __iomem *bios)
141 + int day, month, year;
143 + tosh_id = tosh_get_machine_id(bios);
145 + /* get the BIOS version */
146 + major = readb(bios + 0xe009)-'0';
147 + minor = ((readb(bios + 0xe00b)-'0')*10)+(readb(bios + 0xe00c)-'0');
148 + tosh_bios = (major*0x100)+minor;
150 + /* get the BIOS date */
151 + day = ((readb(bios + 0xfff5)-'0')*10)+(readb(bios + 0xfff6)-'0');
152 + month = ((readb(bios + 0xfff8)-'0')*10)+(readb(bios + 0xfff9)-'0');
153 + year = ((readb(bios + 0xfffb)-'0')*10)+(readb(bios + 0xfffc)-'0');
154 + tosh_date = (((year-90) & 0x1f)<<10) | ((month & 0xf)<<6)
155 + | ((day & 0x1f)<<1);
158 +/* /proc/toshiba read handler */
160 +tosh_get_info(char* buffer, char** start, off_t fpos, int length)
162 + char* temp = buffer;
163 + /* TODO: tosh_fn_status() */
167 + * 0) Linux driver version (this will change if format changes)
170 + * 3) BIOS version (major, minor)
171 + * 4) BIOS date (in SCI date format)
175 + temp += sprintf(temp, "1.1 0x%04x %d.%d %d.%d 0x%04x 0x%02x\n",
177 + (tosh_sci & 0xff00)>>8,
179 + (tosh_bios & 0xff00)>>8,
184 + return temp-buffer;
188 +old_driver_emulation_init(void)
191 + void __iomem *bios = ioremap(0xf0000, 0x10000);
195 + if ((status = misc_register(&tosh_device))) {
196 + printk(MY_ERR "failed to register misc device %d (\"%s\")\n",
197 + tosh_device.minor, tosh_device.name);
201 + setup_tosh_info(bios);
202 + create_proc_info_entry(OLD_PROC_TOSHIBA, 0, NULL, tosh_get_info);
210 +old_driver_emulation_exit(void)
212 + remove_proc_entry(OLD_PROC_TOSHIBA, NULL);
213 + misc_deregister(&tosh_device);
216 +/* }}} end of /dev/toshiba and /proc/toshiba handlers */
218 /* proc and module init
222 if (toshiba_proc_dir)
223 remove_proc_entry(PROC_TOSHIBA, acpi_root_dir);
225 + old_driver_emulation_exit();
232 acpi_status status = AE_OK;
239 TOSHIBA_ACPI_VERSION);
240 printk(MY_INFO " HCI method: %s\n", method_hci);
242 + if ((status2 = old_driver_emulation_init()))