blob: 1ce07a84ffb86831efacaed578746e5c36c0b1fa [file] [log] [blame]
Jeff Garzik32c80372005-10-25 01:56:48 -04001#include <stdio.h>
Michael Chan14004d12005-11-08 12:24:23 -08002#include <string.h>
Jeff Garzik32c80372005-10-25 01:56:48 -04003#include "ethtool-util.h"
4
5#define TG3_MAGIC 0x669955aa
6
7int
8tg3_dump_eeprom(struct ethtool_drvinfo *info, struct ethtool_eeprom *ee)
9{
10 int i;
11
12 if (ee->magic != TG3_MAGIC) {
13 fprintf(stderr, "Magic number 0x%08x does not match 0x%08x\n",
14 ee->magic, TG3_MAGIC);
15 return -1;
16 }
17
18 fprintf(stdout, "Address \tData\n");
19 fprintf(stdout, "----------\t----\n");
20 for (i = 0; i < ee->len; i++)
21 fprintf(stdout, "0x%08x\t0x%02x\n", i + ee->offset, ee->data[i]);
22
23 return 0;
24}
Michael Chan14004d12005-11-08 12:24:23 -080025
26int
27tg3_dump_regs(struct ethtool_drvinfo *info, struct ethtool_regs *regs)
28{
29 int i, j;
30 int reg_boundaries[] = { 0x015c, 0x0200, 0x0400, 0x0400, 0x08f0, 0x0c00,
31 0x0ce0, 0x1000, 0x1004, 0x1400, 0x1480, 0x1800,
32 0x1848, 0x1c00, 0x1c04, 0x2000, 0x225c, 0x2400,
33 0x24c4, 0x2800, 0x2804, 0x2c00, 0x2c20, 0x3000,
34 0x3014, 0x3400, 0x3408, 0x3800, 0x3808, 0x3c00,
35 0x3d00, 0x4000, 0x4010, 0x4400, 0x4458, 0x4800,
36 0x4808, 0x4c00, 0x4c08, 0x5000, 0x5280, 0x5400,
37 0x5680, 0x5800, 0x5a10, 0x5c00, 0x5d20, 0x6000,
38 0x600c, 0x6800, 0x6848, 0x7000, 0x7034, 0x7c00,
39 0x7e40, 0x8000 };
40
41 fprintf(stdout, "Offset\tValue\n");
42 fprintf(stdout, "------\t----------\n");
43 for (i = 0, j = 0; i < regs->len; ) {
44 u32 reg;
45
46 memcpy(&reg, &regs->data[i], 4);
47 fprintf(stdout, "0x%04x\t0x%08x\n", i, reg);
48
49 i += 4;
50 if (i == reg_boundaries[j]) {
51 i = reg_boundaries[j + 1];
52 j += 2;
53 fprintf(stdout, "\n");
54 }
55 }
56 fprintf(stdout, "\n");
57 return 0;
58}