// SPDX-License-Identifier: GPL-2.0-or-later /* toshiba.c -- Linux driver for accessing the SMM on Toshiba laptops * * Copyright (c) 1996-2001 Jonathan A. Buzzard (jonathan@buzzard.org.uk) * * Valuable assistance and patches from: * Tom May <tom@you-bastards.com> * Rob Napier <rnapier@employees.org> * * Fn status port numbers for machine ID's courtesy of * 0xfc02: Scott Eisert <scott.e@sky-eye.com> * 0xfc04: Steve VanDevender <stevev@efn.org> * 0xfc08: Garth Berry <garth@itsbruce.net> * 0xfc0a: Egbert Eich <eich@xfree86.org> * 0xfc10: Andrew Lofthouse <Andrew.Lofthouse@robins.af.mil> * 0xfc11: Spencer Olson <solson@novell.com> * 0xfc13: Claudius Frankewitz <kryp@gmx.de> * 0xfc15: Tom May <tom@you-bastards.com> * 0xfc17: Dave Konrad <konrad@xenia.it> * 0xfc1a: George Betzos <betzos@engr.colostate.edu> * 0xfc1b: Munemasa Wada <munemasa@jnovel.co.jp> * 0xfc1d: Arthur Liu <armie@slap.mine.nu> * 0xfc5a: Jacques L'helgoualc'h <lhh@free.fr> * 0xfcd1: Mr. Dave Konrad <konrad@xenia.it> * * WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING WARNING * * This code is covered by the GNU GPL and you are free to make any * changes you wish to it under the terms of the license. However the * code has the potential to render your computer and/or someone else's * unusable. Please proceed with care when modifying the code. * * Note: Unfortunately the laptop hardware can close the System Configuration * Interface on it's own accord. It is therefore necessary for *all* * programs using this driver to be aware that *any* SCI call can fail at * *any* time. It is up to any program to be aware of this eventuality * and take appropriate steps. * * The information used to write this driver has been obtained by reverse * engineering the software supplied by Toshiba for their portable computers in * strict accordance with the European Council Directive 92/250/EEC on the legal * protection of computer programs, and it's implementation into English Law by * the Copyright (Computer Programs) Regulations 1992 (S.I. 1992 No.3233).
*/
/* * For the Portage 610CT and the Tecra 700CS/700CDT emulate the HCI fan function
*/ staticint tosh_emulate_fan(SMMRegisters *regs)
{ unsignedlong eax,ecx,flags; unsignedchar al;
/* do we need to emulate the fan ? */
mutex_lock(&tosh_mutex); if (tosh_fan==1) { if (((ax==0xf300) || (ax==0xf400)) && (bx==0x0004)) {
err = tosh_emulate_fan(®s);
mutex_unlock(&tosh_mutex); break;
}
}
err = tosh_smm(®s);
mutex_unlock(&tosh_mutex); break; default: return -EINVAL;
}
if (copy_to_user(argp, ®s, sizeof(SMMRegisters))) return -EFAULT;
return (err==0) ? 0:-EINVAL;
}
/* * Print the information for /proc/toshiba
*/ #ifdef CONFIG_PROC_FS staticint proc_toshiba_show(struct seq_file *m, void *v)
{ int key;
key = tosh_fn_status();
/* Arguments 0) Linux driver version (this will change if format changes) 1) Machine ID 2) SCI version 3) BIOS version (major, minor) 4) BIOS date (in SCI date format) 5) Fn Key status
*/
seq_printf(m, "1.1 0x%04x %d.%d %d.%d 0x%04x 0x%02x\n",
tosh_id,
(tosh_sci & 0xff00)>>8,
tosh_sci & 0xff,
(tosh_bios & 0xff00)>>8,
tosh_bios & 0xff,
tosh_date,
key); return 0;
} #endif
/* * Determine which port to use for the Fn key status
*/ staticvoid tosh_set_fn_port(void)
{ switch (tosh_id) { case 0xfc02: case 0xfc04: case 0xfc09: case 0xfc0a: case 0xfc10: case 0xfc11: case 0xfc13: case 0xfc15: case 0xfc1a: case 0xfc1b: case 0xfc5a:
tosh_fn = 0x62; break; case 0xfc08: case 0xfc17: case 0xfc1d: case 0xfcd1: case 0xfce0: case 0xfce2:
tosh_fn = 0x68; break; default:
tosh_fn = 0x00; break;
}
return;
}
/* * Get the machine identification number of the current model
*/ staticint tosh_get_machine_id(void __iomem *bios)
{ int id;
SMMRegisters regs; unsignedshort bx,cx; unsignedlong address;
id = (0x100*(int) readb(bios+0xfffe))+((int) readb(bios+0xfffa));
/* do we have a SCTTable machine identication number on our hands */
/* At this point in the Toshiba routines under MS Windows the bx register holds 0xe6f5. However my code is producing a different value! For the time being I will just fudge the value. This has been verified on a Satellite Pro 430CDT,
Tecra 750CDT, Tecra 780DVD and Satellite 310CDT. */ #if TOSH_DEBUG
pr_debug("toshiba: debugging ID ebx=0x%04x\n", regs.ebx); #endif
bx = 0xe6f5;
/* now construct our machine identification number */
id = ((cx & 0xff)<<8)+((cx & 0xff00)>>8);
}
return id;
}
/* * Probe for the presence of a Toshiba laptop * * returns and non-zero if unable to detect the presence of a Toshiba * laptop, otherwise zero and determines the Machine ID, BIOS version and * date, and SCI version.
*/ staticint tosh_probe(void)
{ int i,major,minor,day,year,month,flag; unsignedchar signature[7] = { 0x54,0x4f,0x53,0x48,0x49,0x42,0x41 };
SMMRegisters regs; void __iomem *bios = ioremap(0xf0000, 0x10000);
if (!bios) return -ENOMEM;
/* extra sanity check for the string "TOSHIBA" in the BIOS because
some machines that are not Toshiba's pass the next test */
for (i=0;i<7;i++) { if (readb(bios+0xe010+i)!=signature[i]) {
pr_err("toshiba: not a supported Toshiba laptop\n");
iounmap(bios); return -ENODEV;
}
}
/* in theory we should check the ports we are going to use for the fn key detection (and the fan on the Portage 610/Tecra700), and then request them to stop other drivers using them. However as the keyboard driver grabs 0x60-0x6f and the pic driver grabs 0xa0-0xbf we can't. We just have to live dangerously and use the
ports anyway, oh boy! */
/* do we need to emulate the fan? */
if ((tosh_id==0xfccb) || (tosh_id==0xfccc))
tosh_fan = 1;
iounmap(bios);
return 0;
}
staticint __init toshiba_init(void)
{ int retval; /* are we running on a Toshiba laptop */
if (tosh_probe()) return -ENODEV;
pr_info("Toshiba System Management Mode driver v" TOSH_VERSION "\n");
/* set the port to use for Fn status if not specified as a parameter */ if (tosh_fn==0x00)
tosh_set_fn_port();
/* register the device file */
retval = misc_register(&tosh_device); if (retval < 0) return retval;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.