Ronald G. Minnich | 394e7c4 | 2006-02-22 22:12:21 +0000 | [diff] [blame^] | 1 | #include <stdio.h> |
| 2 | #include <sys/io.h> |
| 3 | |
| 4 | /* well, they really thought this throught, eh? Family is 8 bits!!!! */ |
| 5 | char *familyid[] = { |
| 6 | [0xf1] = "pc8374 (winbond, was NS)" |
| 7 | }; |
| 8 | |
| 9 | /* eventually, if you care, break this out into a file. For now, I don't know |
| 10 | * if we need this. |
| 11 | */ |
| 12 | |
| 13 | unsigned char regval(unsigned short port, unsigned short reg) { |
| 14 | outb(reg, port); |
| 15 | return inb(port+1); |
| 16 | } |
| 17 | |
| 18 | void |
| 19 | dump_ns8374(unsigned short port) { |
| 20 | printf("Enables: 21=%02x, 22=%02x, 23=%02x, 24=%02x, 26=%02x\n", |
| 21 | regval(port,0x21), regval(port,0x22), |
| 22 | regval(port,0x23), regval(port,0x24), regval(port,0x26)); |
| 23 | /* check COM1. This is all we care about at present. */ |
| 24 | printf("COM 1 is Globally %s\n", regval(port,0x26)&8 ? "disabled" : "enabled"); |
| 25 | /* select com1 */ |
| 26 | outb(0x7, port); |
| 27 | outb(3, port+1); |
| 28 | printf("COM 1 is locally %s\n", regval(port, 0x30) & 1 ? "enabled" : "disabled"); |
| 29 | printf("COM1 60=%02x, 61=%02x, 70=%02x, 71=%02x, 74=%02x, 75=%02x, f0=%02x\n", |
| 30 | regval(port, 0x60), regval(port, 0x61), regval(port, 0x70), regval(port, 0x71), |
| 31 | regval(port, 0x74), regval(port, 0x75), regval(port, 0xf0)); |
| 32 | |
| 33 | } |
| 34 | |
| 35 | void |
| 36 | probe_idregs(unsigned short port){ |
| 37 | unsigned char id; |
| 38 | int i; |
| 39 | outb(0x20, port); |
| 40 | if (inb(port) != 0x20) { |
| 41 | printf("probing 0x%04x, failed (0x%02x), data returns 0x%02x\n", |
| 42 | port, inb(port), inb(port+1)); |
| 43 | return; |
| 44 | } |
| 45 | id = inb(port+1); |
| 46 | printf("Probe of id returns %02x\n", id); |
| 47 | if (id == 0xff) |
| 48 | return; |
| 49 | |
| 50 | printf("%s\n", familyid[id]); |
| 51 | switch(id) { |
| 52 | case 0xf1: |
| 53 | dump_ns8374(port); |
| 54 | break; |
| 55 | default: |
| 56 | printf("no dump for 0x%02x\n", id); |
| 57 | break; |
| 58 | } |
| 59 | } |
| 60 | |
| 61 | void |
| 62 | probe_superio(unsigned short port) { |
| 63 | probe_idregs(port); |
| 64 | } |
| 65 | |
| 66 | int |
| 67 | main(int argc, char *argv[]){ |
| 68 | unsigned short port; |
| 69 | |
| 70 | if (iopl(3) < 0) { |
| 71 | perror("iopl"); |
| 72 | exit(1); |
| 73 | } |
| 74 | |
| 75 | /* try the 2e */ |
| 76 | probe_superio(0x2e); |
| 77 | /* now try the 4e */ |
| 78 | probe_superio(0x4e); |
| 79 | } |