56 #define TOSH_VERSION "1.11 26/9/2001"
59 #include <linux/module.h>
60 #include <linux/kernel.h>
61 #include <linux/types.h>
62 #include <linux/fcntl.h>
66 #include <asm/uaccess.h>
68 #include <linux/stat.h>
72 #include <linux/toshiba.h>
74 #define TOSH_MINOR_DEV 181
92 static long tosh_ioctl(
struct file *,
unsigned int,
98 .unlocked_ioctl = tosh_ioctl,
111 #ifdef CONFIG_PROC_FS
112 static int tosh_fn_status(
void)
139 eax = regs->
eax & 0xff00;
140 ecx = regs->ecx & 0xffff;
144 if (tosh_id==0xfccb) {
152 regs->ecx = (
unsigned int) (al & 0x01);
154 if ((eax==0xff00) && (ecx==0x0000)) {
160 outb (al | 0x01, 0xe5);
165 if ((eax==0xff00) && (ecx==0x0001)) {
171 outb(al & 0xfe, 0xe5);
180 if (tosh_id==0xfccc) {
188 regs->ecx = al & 0x01;
190 if ((eax==0xff00) && (ecx==0x0000)) {
195 outw(0xe0 | ((al & 0xfe) << 8), 0xe4);
200 if ((eax==0xff00) && (ecx==0x0001)) {
205 outw(0xe0 | ((al | 0x01) << 8), 0xe4);
223 asm (
"# load the values into the registers\n\t" \
225 "movl 0(%%eax),%%edx\n\t" \
227 "movl 4(%%eax),%%ebx\n\t" \
228 "movl 8(%%eax),%%ecx\n\t" \
229 "movl 12(%%eax),%%edx\n\t" \
230 "movl 16(%%eax),%%esi\n\t" \
231 "movl 20(%%eax),%%edi\n\t" \
233 "# call the System Management mode\n\t" \
235 "# fill out the memory with the values in the registers\n\t" \
236 "xchgl %%eax,(%%esp)\n\t"
237 "movl %%ebx,4(%%eax)\n\t" \
238 "movl %%ecx,8(%%eax)\n\t" \
239 "movl %%edx,12(%%eax)\n\t" \
240 "movl %%esi,16(%%eax)\n\t" \
241 "movl %%edi,20(%%eax)\n\t" \
243 "movl %%edx,0(%%eax)\n\t" \
244 "# setup the return value to the carry flag\n\t" \
246 "shrl $8,%%eax\n\t" \
250 :
"%ebx",
"%ecx",
"%edx",
"%esi",
"%edi",
"memory");
257 static long tosh_ioctl(
struct file *
fp,
unsigned int cmd,
unsigned long arg)
261 unsigned short ax,bx;
272 ax = regs.
eax & 0xff00;
273 bx = regs.ebx & 0xffff;
275 if (((ax==0xff00) || (ax==0xfe00)) && (bx>0x0069))
281 if (((ax==0xf300) || (ax==0xf400)) && (bx==0x0004)) {
282 err = tosh_emulate_fan(®s);
297 return (err==0) ? 0:-
EINVAL;
304 #ifdef CONFIG_PROC_FS
305 static int proc_toshiba_show(
struct seq_file *
m,
void *
v)
309 key = tosh_fn_status();
319 seq_printf(m,
"1.1 0x%04x %d.%d %d.%d 0x%04x 0x%02x\n",
321 (tosh_sci & 0xff00)>>8,
323 (tosh_bios & 0xff00)>>8,
337 .open = proc_toshiba_open,
348 static void tosh_set_fn_port(
void)
351 case 0xfc02:
case 0xfc04:
case 0xfc09:
case 0xfc0a:
case 0xfc10:
352 case 0xfc11:
case 0xfc13:
case 0xfc15:
case 0xfc1a:
case 0xfc1b:
356 case 0xfc08:
case 0xfc17:
case 0xfc1d:
case 0xfcd1:
case 0xfce0:
376 unsigned short bx,cx;
379 id = (0x100*(
int)
readb(bios+0xfffe))+((
int)
readb(bios+0xfffa));
391 bx = (
unsigned short) (regs.ebx & 0xffff);
399 printk(
"toshiba: debugging ID ebx=0x%04x\n", regs.ebx);
406 cx =
readw(bios + address);
408 cx =
readw(bios + address);
410 cx =
readw(bios + address);
414 id = ((cx & 0xff)<<8)+((cx & 0xff00)>>8);
428 static int tosh_probe(
void)
431 unsigned char signature[7] = { 0x54,0x4f,0x53,0x48,0x49,0x42,0x41 };
442 if (
readb(bios+0xe010+i)!=signature[i]) {
443 printk(
"toshiba: not a supported Toshiba laptop\n");
458 if ((flag==1) || ((regs.
eax & 0xff00)==0x8600)) {
459 printk(
"toshiba: not a supported Toshiba laptop\n");
466 tosh_sci = regs.edx & 0xffff;
470 tosh_id = tosh_get_machine_id(bios);
474 major =
readb(bios+0xe009)-
'0';
475 minor = ((
readb(bios+0xe00b)-
'0')*10)+(
readb(bios+0xe00c)-
'0');
476 tosh_bios = (major*0x100)+minor;
480 day = ((
readb(bios+0xfff5)-
'0')*10)+(
readb(bios+0xfff6)-
'0');
481 month = ((
readb(bios+0xfff8)-
'0')*10)+(
readb(bios+0xfff9)-
'0');
482 year = ((
readb(bios+0xfffb)-
'0')*10)+(
readb(bios+0xfffc)-
'0');
483 tosh_date = (((year-90) & 0x1f)<<10) | ((month & 0xf)<<6)
496 if ((tosh_id==0xfccb) || (tosh_id==0xfccc))
504 static int __init toshiba_init(
void)
523 #ifdef CONFIG_PROC_FS
527 pde = proc_create(
"toshiba", 0,
NULL, &proc_toshiba_fops);
538 static void __exit toshiba_exit(
void)