[LinuxBIOS] r2782 - trunk/util/superiotool
svn at openbios.org
svn at openbios.org
Wed Sep 19 01:30:24 CEST 2007
Author: uwe
Date: 2007-09-19 01:30:24 +0200 (Wed, 19 Sep 2007)
New Revision: 2782
Modified:
trunk/util/superiotool/Makefile
trunk/util/superiotool/smsc.c
trunk/util/superiotool/superiotool.c
trunk/util/superiotool/superiotool.h
Log:
Make the code a bit more generic (trivial). Different Super I/Os
use different config ports.
Signed-off-by: Uwe Hermann <uwe at hermann-uwe.de>
Acked-by: Uwe Hermann <uwe at hermann-uwe.de>
Modified: trunk/util/superiotool/Makefile
===================================================================
--- trunk/util/superiotool/Makefile 2007-09-18 22:24:34 UTC (rev 2781)
+++ trunk/util/superiotool/Makefile 2007-09-18 23:30:24 UTC (rev 2782)
@@ -32,7 +32,7 @@
all: $(PROGRAM)
-$(PROGRAM): $(OBJS)
+$(PROGRAM): $(OBJS) superiotool.h
$(CC) $(CFLAGS) -o $(PROGRAM) $(OBJS)
install: $(PROGRAM)
Modified: trunk/util/superiotool/smsc.c
===================================================================
--- trunk/util/superiotool/smsc.c 2007-09-18 22:24:34 UTC (rev 2781)
+++ trunk/util/superiotool/smsc.c 2007-09-18 23:30:24 UTC (rev 2782)
@@ -53,7 +53,7 @@
}
}
-void probe_idregs_smsc(uint32_t port)
+void probe_idregs_smsc(unsigned short port)
{
uint16_t id, rev;
Modified: trunk/util/superiotool/superiotool.c
===================================================================
--- trunk/util/superiotool/superiotool.c 2007-09-18 22:24:34 UTC (rev 2781)
+++ trunk/util/superiotool/superiotool.c 2007-09-18 23:30:24 UTC (rev 2782)
@@ -97,22 +97,18 @@
int main(int argc, char *argv[])
{
+ int i, j;
+
if (iopl(3) < 0) {
perror("iopl");
exit(1);
}
- probe_idregs_simple(0x2e);
- probe_idregs_simple(0x4e);
+ 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]);
+ }
- probe_idregs_fintek(0x2e);
- probe_idregs_fintek(0x4e);
-
- probe_idregs_ite(0x2e);
- probe_idregs_ite(0x4e);
-
- probe_idregs_smsc(0x3f0);
- probe_idregs_smsc(0x370);
-
return 0;
}
Modified: trunk/util/superiotool/superiotool.h
===================================================================
--- trunk/util/superiotool/superiotool.h 2007-09-18 22:24:34 UTC (rev 2781)
+++ trunk/util/superiotool/superiotool.h 2007-09-18 23:30:24 UTC (rev 2782)
@@ -27,6 +27,8 @@
#include <stdint.h>
#include <sys/io.h>
+#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
+
#define EOT -1 /* End Of Table */
#define NOLDN -2 /* NO LDN needed */
#define NANA -3 /* Not Available */
@@ -36,6 +38,7 @@
#define LDNSIZE (MAXLDN + 3) /* Biggest LDN + 0 + NOLDN + EOT */
#define MAXNUMIDX 70 /* Maximum number of indexes */
#define IDXSIZE (MAXNUMIDX + 1)
+#define MAXNUMPORTS (2 + 1) /* Maximum number of Super I/O ports */
struct superio_registers {
/* Yes, superio_id should be unsigned, but EOT has to be negative. */
@@ -69,6 +72,17 @@
/* smsc.c */
void dump_smsc(uint32_t port, uint32_t id);
-void probe_idregs_smsc(uint32_t port);
+void probe_idregs_smsc(unsigned short port);
+/** Table of which config ports to probe on each Super I/O. */
+const static struct {
+ void (*probe_idregs) (unsigned short port);
+ signed short ports[MAXNUMPORTS]; /* Signed, as we need EOT. */
+} superio_ports_table[] = {
+ {probe_idregs_simple, {0x2e, 0x4e, EOT}},
+ {probe_idregs_fintek, {0x2e, 0x4e, EOT}},
+ {probe_idregs_ite, {0x2e, 0x4e, EOT}},
+ {probe_idregs_smsc, {0x3f0, 0x370, EOT}},
+};
+
#endif
More information about the coreboot
mailing list