blob: 7c3f112904a10e9534a9ced70372852d8de529f5 [file] [log] [blame]
Stefan Reinauer6a5bc462007-01-17 10:57:42 +00001/*
2 * This file is part of the LinuxBIOS project.
3 *
4 * Copyright (C) 2006 Ronald Minnich <rminnich@gmail.com>
Uwe Hermannbd263922007-09-01 19:42:42 +00005 * Copyright (C) 2007 Uwe Hermann <uwe@hermann-uwe.de>
Stefan Reinauer6a5bc462007-01-17 10:57:42 +00006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 */
21
Uwe Hermann0120e1a2007-09-16 18:11:03 +000022#include "superiotool.h"
Ronald G. Minnich394e7c42006-02-22 22:12:21 +000023
Uwe Hermann2046ff92007-09-01 21:02:44 +000024unsigned char regval(unsigned short port, unsigned char reg)
25{
Ronald G. Minnich394e7c42006-02-22 22:12:21 +000026 outb(reg, port);
Carl-Daniel Hailfingerb1786c22007-08-28 10:43:57 +000027 return inb(port + 1);
Ronald G. Minnich394e7c42006-02-22 22:12:21 +000028}
29
Uwe Hermann2046ff92007-09-01 21:02:44 +000030void regwrite(unsigned short port, unsigned char reg, unsigned char val)
31{
Carl-Daniel Hailfinger7a7890a2007-08-27 07:28:28 +000032 outb(reg, port);
Carl-Daniel Hailfingerb1786c22007-08-28 10:43:57 +000033 outb(val, port + 1);
Carl-Daniel Hailfinger7a7890a2007-08-27 07:28:28 +000034}
35
Uwe Hermann2046ff92007-09-01 21:02:44 +000036void probe_superio(unsigned short port)
37{
Stefan Reinauer6a5bc462007-01-17 10:57:42 +000038 probe_idregs_simple(port);
39 probe_idregs_fintek(port);
Carl-Daniel Hailfinger7a7890a2007-08-27 07:28:28 +000040 probe_idregs_ite(port);
Ronald G. Minnich394e7c42006-02-22 22:12:21 +000041}
42
Uwe Hermann2046ff92007-09-01 21:02:44 +000043int main(int argc, char *argv[])
Stefan Reinauer6a5bc462007-01-17 10:57:42 +000044{
Ronald G. Minnich394e7c42006-02-22 22:12:21 +000045 if (iopl(3) < 0) {
46 perror("iopl");
47 exit(1);
48 }
49
Uwe Hermann2046ff92007-09-01 21:02:44 +000050 probe_superio(0x2e); /* Try 0x2e. */
51 probe_superio(0x4e); /* Try 0x4e. */
Stefan Reinauer6a5bc462007-01-17 10:57:42 +000052
53 return 0;
Ronald G. Minnich394e7c42006-02-22 22:12:21 +000054}