2 * This file is part of the LinuxBIOS project.
4 * Copyright (C) 2006 Ronald Minnich <rminnich@gmail.com>
5 * Copyright (C) 2007 Uwe Hermann <uwe@hermann-uwe.de>
6 * Copyright (C) 2007 Carl-Daniel Hailfinger
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
23 #include "superiotool.h"
25 uint8_t regval(uint16_t port, uint8_t reg)
31 void regwrite(uint16_t port, uint8_t reg, uint8_t val)
37 void dump_superio(const char *vendor, const struct superio_registers reg_table[],
38 uint16_t port, uint16_t id)
43 for (i = 0; /* Nothing */; i++) {
44 if (reg_table[i].superio_id == EOT)
47 if ((uint16_t)reg_table[i].superio_id != id)
52 for (j = 0; /* Nothing */; j++) {
53 if (reg_table[i].ldn[j].ldn == EOT)
56 printf("%s %s\n", vendor, reg_table[i].name);
59 if (reg_table[i].ldn[j].ldn != NOLDN) {
60 printf("Switching to LDN 0x%02x\n",
61 reg_table[i].ldn[j].ldn);
62 regwrite(port, 0x07, reg_table[i].ldn[j].ldn);
65 idx = reg_table[i].ldn[j].idx;
68 for (k = 0; /* Nothing */; k++) {
71 printf("%02x ", idx[k]);
75 for (k = 0; /* Nothing */; k++) {
78 printf("%02x ", regval(port, idx[k]));
82 idx = reg_table[i].ldn[j].def;
83 for (k = 0; /* Nothing */; k++) {
86 else if (idx[k] == NANA)
88 else if (idx[k] == RSVD)
91 printf("%02x ", idx[k]);
97 printf("No dump for %s %s\n", vendor, reg_table[i].name);
101 int main(int argc, char *argv[])
110 for (i = 0; i < ARRAY_SIZE(superio_ports_table); i++) {
111 for (j = 0; superio_ports_table[i].ports[j] != EOT; j++)
112 superio_ports_table[i].probe_idregs(
113 superio_ports_table[i].ports[j]);