2007-01-17 11:57:42 +01:00
|
|
|
/*
|
|
|
|
* This file is part of the LinuxBIOS project.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2006 Ronald Minnich <rminnich@gmail.com>
|
2007-09-01 21:42:42 +02:00
|
|
|
* Copyright (C) 2007 Uwe Hermann <uwe@hermann-uwe.de>
|
2007-09-16 22:59:01 +02:00
|
|
|
* Copyright (C) 2007 Carl-Daniel Hailfinger
|
2007-01-17 11:57:42 +01:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2007-09-16 20:11:03 +02:00
|
|
|
#include "superiotool.h"
|
2006-02-22 23:12:21 +01:00
|
|
|
|
2007-09-19 02:03:14 +02:00
|
|
|
uint8_t regval(uint16_t port, uint8_t reg)
|
2007-09-01 23:02:44 +02:00
|
|
|
{
|
2006-02-22 23:12:21 +01:00
|
|
|
outb(reg, port);
|
2007-08-28 12:43:57 +02:00
|
|
|
return inb(port + 1);
|
2006-02-22 23:12:21 +01:00
|
|
|
}
|
|
|
|
|
2007-09-19 02:03:14 +02:00
|
|
|
void regwrite(uint16_t port, uint8_t reg, uint8_t val)
|
2007-09-01 23:02:44 +02:00
|
|
|
{
|
2007-08-27 09:28:28 +02:00
|
|
|
outb(reg, port);
|
2007-08-28 12:43:57 +02:00
|
|
|
outb(val, port + 1);
|
2007-08-27 09:28:28 +02:00
|
|
|
}
|
|
|
|
|
2007-09-19 02:48:42 +02:00
|
|
|
void dump_superio(const char *vendor, const struct superio_registers reg_table[],
|
2007-09-19 02:03:14 +02:00
|
|
|
uint16_t port, uint16_t id)
|
2007-09-16 22:59:01 +02:00
|
|
|
{
|
2007-09-19 02:48:42 +02:00
|
|
|
int i, j, k, nodump;
|
2007-09-19 02:03:14 +02:00
|
|
|
int *idx;
|
2007-09-16 22:59:01 +02:00
|
|
|
|
|
|
|
for (i = 0; /* Nothing */; i++) {
|
|
|
|
if (reg_table[i].superio_id == EOT)
|
|
|
|
break;
|
|
|
|
|
2007-09-19 02:03:14 +02:00
|
|
|
if ((uint16_t)reg_table[i].superio_id != id)
|
2007-09-16 22:59:01 +02:00
|
|
|
continue;
|
|
|
|
|
2007-09-19 02:48:42 +02:00
|
|
|
nodump = 1;
|
2007-09-16 22:59:01 +02:00
|
|
|
|
2007-09-19 02:03:14 +02:00
|
|
|
for (j = 0; /* Nothing */; j++) {
|
2007-09-16 22:59:01 +02:00
|
|
|
if (reg_table[i].ldn[j].ldn == EOT)
|
|
|
|
break;
|
|
|
|
|
2007-09-19 02:48:42 +02:00
|
|
|
printf("%s %s\n", vendor, reg_table[i].name);
|
|
|
|
nodump = 0;
|
|
|
|
|
2007-09-16 22:59:01 +02:00
|
|
|
if (reg_table[i].ldn[j].ldn != NOLDN) {
|
2007-09-19 02:03:14 +02:00
|
|
|
printf("Switching to LDN 0x%02x\n",
|
2007-09-16 22:59:01 +02:00
|
|
|
reg_table[i].ldn[j].ldn);
|
2007-09-19 02:03:14 +02:00
|
|
|
regwrite(port, 0x07, reg_table[i].ldn[j].ldn);
|
2007-09-16 22:59:01 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
idx = reg_table[i].ldn[j].idx;
|
|
|
|
|
|
|
|
printf("idx ");
|
2007-09-19 02:03:14 +02:00
|
|
|
for (k = 0; /* Nothing */; k++) {
|
2007-09-16 22:59:01 +02:00
|
|
|
if (idx[k] == EOT)
|
|
|
|
break;
|
|
|
|
printf("%02x ", idx[k]);
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\nval ");
|
2007-09-19 02:03:14 +02:00
|
|
|
for (k = 0; /* Nothing */; k++) {
|
2007-09-16 22:59:01 +02:00
|
|
|
if (idx[k] == EOT)
|
|
|
|
break;
|
|
|
|
printf("%02x ", regval(port, idx[k]));
|
|
|
|
}
|
|
|
|
|
|
|
|
printf("\ndef ");
|
|
|
|
idx = reg_table[i].ldn[j].def;
|
2007-09-19 02:03:14 +02:00
|
|
|
for (k = 0; /* Nothing */; k++) {
|
2007-09-16 22:59:01 +02:00
|
|
|
if (idx[k] == EOT)
|
|
|
|
break;
|
2007-09-19 00:24:34 +02:00
|
|
|
else if (idx[k] == NANA)
|
2007-09-16 22:59:01 +02:00
|
|
|
printf("NA ");
|
2007-09-19 00:24:34 +02:00
|
|
|
else if (idx[k] == RSVD)
|
|
|
|
printf("RR ");
|
2007-09-16 22:59:01 +02:00
|
|
|
else
|
|
|
|
printf("%02x ", idx[k]);
|
|
|
|
}
|
|
|
|
printf("\n");
|
|
|
|
}
|
2007-09-19 02:48:42 +02:00
|
|
|
|
|
|
|
if (nodump)
|
|
|
|
printf("No dump for %s %s\n", vendor, reg_table[i].name);
|
2007-09-16 22:59:01 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-09-01 23:02:44 +02:00
|
|
|
int main(int argc, char *argv[])
|
2007-01-17 11:57:42 +01:00
|
|
|
{
|
2007-09-19 01:30:24 +02:00
|
|
|
int i, j;
|
|
|
|
|
2006-02-22 23:12:21 +01:00
|
|
|
if (iopl(3) < 0) {
|
|
|
|
perror("iopl");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
2007-09-19 01:30:24 +02:00
|
|
|
for (i = 0; i < ARRAY_SIZE(superio_ports_table); i++) {
|
|
|
|
for (j = 0; superio_ports_table[i].ports[j] != EOT; j++)
|
|
|
|
superio_ports_table[i].probe_idregs(
|
|
|
|
superio_ports_table[i].ports[j]);
|
|
|
|
}
|
2007-01-17 11:57:42 +01:00
|
|
|
|
|
|
|
return 0;
|
2006-02-22 23:12:21 +01:00
|
|
|
}
|