1 /* sci.c -- System Configuration Interface
3 * Copyright (c) 1998-2000 Jonathan A. Buzzard (jonathan@buzzard.org.uk)
6 * Revision 1.1 2003/09/18 16:38:27 noberasco
9 * Revision 1.1.1.1 2003/06/05 09:34:03 noberasco
12 * Revision 1.14 2001/10/05 13:07:40 jab
13 * checked in changes for kernel module
15 * Revision 1.13 1999/12/18 14:32:24 jab
16 * fixed some bugs in the assembler
17 * removed the SciGetModel function, not needed now with working MachineID
19 * Revision 1.12 1999/11/17 16:00:42 jab
20 * changed assembler to manually save registers, hopefully this should
21 * make the programs more stable
23 * Revision 1.11 1999/07/25 14:39:49 jab
24 * fixed bugs in SciOpenInterface and SciSetPassword
25 * updated email address
27 * Revision 1.10 1999/03/11 20:22:14 jab
28 * changed get and set routines to use SciRegisters
30 * Revision 1.9 1999/03/06 16:46:30 jab
31 * moved the BiosVersion and MachineID functions to hci.c
33 * Revision 1.8 1998/09/07 18:23:36 jab
34 * removed SciGetMachineID2 as no longer required
35 * added a routine to extract the model string from the BIOS
37 * Revision 1.7 1998/09/04 18:14:31 jab
38 * fixed the compile warning about rcsid
40 * Revision 1.6 1998/08/24 18:05:04 jab
41 * implemented the SciGetBiosVersion function
43 * Revision 1.5 1998/08/23 12:16:45 jab
44 * fixed the SciACPower function so it now works
46 * Revision 1.4 1998/08/19 08:45:10 jab
47 * changed GetMachineId to return SCI_SUCCESS/SCI_FAILURE
49 * Revision 1.3 1998/08/18 16:54:54 jab
50 * fixes to SciGetMachineId curtesy of Patrick Reyonlds <patrick@cs.virgina.edu>
52 * Revision 1.2 1998/08/06 08:27:14 jab
53 * prepended all functions with Sci
55 * Revision 1.1 1998/05/23 08:08:53 jab
59 * This program is free software; you can redistribute it and/or modify
60 * it under the terms of the GNU General Public License as published by
61 * the Free Software Foundation; either version 2 of the License, or
62 * (at your option) any later version.
64 * This program is distributed in the hope that it will be useful,
65 * but WITHOUT ANY WARRANTY; without even the implied warranty of
66 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
67 * GNU General Public License for more details.
69 * You should have received a copy of the GNU General Public License
70 * along with this program; if not, write to the Free Software
71 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
75 static const char rcsid
[]="$Id: sci.c,v 1.1 2003/09/18 16:38:27 noberasco Exp $";
88 * Is this a supported Machine? (ie. is it a Toshiba)
90 int SciSupportCheck(int *version
)
95 if ((fd
=open(TOSH_DEVICE
, O_RDWR
))<0)
98 if (access(TOSH_PROC
, R_OK
)) {
108 if (ioctl(fd
, TOSH_SMM
, ®s
)<0) {
114 *version
= (int) regs
.edx
;
116 return (int) (regs
.eax
& 0xff00)>>8;
121 * Open an interface to the Toshiba hardware.
123 * Note: Set and Get will not work unless an interface has been opened.
125 int SciOpenInterface(void)
130 if ((fd
=open(TOSH_DEVICE
, O_RDWR
))<0)
137 if (ioctl(fd
, TOSH_SMM
, ®s
)<0) {
143 return (int) (regs
.eax
& 0xff00)>>8;
148 * Close any open interface to the hardware
150 int SciCloseInterface(void)
155 if ((fd
=open(TOSH_DEVICE
, O_RDWR
))<0)
162 if (ioctl(fd
, TOSH_SMM
, ®s
)<0) {
168 return (int) (regs
.eax
& 0xff00)>>8;
173 * Get the setting of a given mode of the laptop
175 int SciGet(SMMRegisters
*regs
)
179 if ((fd
=open(TOSH_DEVICE
, O_RDWR
))<0)
184 if (ioctl(fd
, TOSH_SMM
, regs
)<0) {
190 return (int) (regs
->eax
& 0xff00)>>8;
195 * Set the setting of a given mode of the laptop
197 int SciSet(SMMRegisters
*regs
)
201 if ((fd
=open(TOSH_DEVICE
, O_RDWR
))<0)
206 if (ioctl(fd
, TOSH_SMM
, regs
)<0) {
212 return (int) (regs
->eax
& 0xff00)>>8;
217 * Get the status of the AC Power on a Toshiba laptop.
224 if (access(TOSH_PROC
, R_OK
))
227 if ((fd
=open(TOSH_DEVICE
, O_RDWR
))<0)
235 if (ioctl(fd
, TOSH_SMM
, ®s
)<0) {
241 return (int) regs
.ecx
;