*** pnpinfo.c.orig Wed Jun 3 10:48:47 1998 --- pnpinfo.c Wed Jun 3 10:48:13 1998 *************** *** 33,38 **** --- 33,39 ---- #include #include #include + #include #include *************** *** 45,63 **** #endif #define DDB(x) x void pnp_write(int d, u_char r) { ! outb (_PNP_ADDRESS, d); ! outb (_PNP_WRITE_DATA, r); } /* The READ_DATA port that we are using currently */ static int rd_port; u_char pnp_read(int d) { ! outb(_PNP_ADDRESS, d); return inb( (rd_port << 2) + 3) & 0xff; } --- 46,67 ---- #endif #define DDB(x) x + static u_int pnp_address, pnp_write_data; + void pnp_write(int d, u_char r) { ! outb (pnp_address, d); ! outb (pnp_write_data, r); } + /* The READ_DATA port that we are using currently */ static int rd_port; u_char pnp_read(int d) { ! outb(pnp_address, d); return inb( (rd_port << 2) + 3) & 0xff; } *************** *** 114,126 **** pnp_write(CONFIG_CONTROL, 0x2); /* Reset the LSFR */ ! outb(_PNP_ADDRESS, 0); ! outb(_PNP_ADDRESS, 0); /* yes, we do need it twice! */ cur = 0x6a; for (i = 0; i < 32; i++) { ! outb(_PNP_ADDRESS, cur); cur = (cur >> 1) | (((cur ^ (cur >> 1)) << 7) & 0xff); } } --- 118,130 ---- pnp_write(CONFIG_CONTROL, 0x2); /* Reset the LSFR */ ! outb(pnp_address, 0); ! outb(pnp_address, 0); /* yes, we do need it twice! */ cur = 0x6a; for (i = 0; i < 32; i++) { ! outb(pnp_address, cur); cur = (cur >> 1) | (((cur ^ (cur >> 1)) << 7) & 0xff); } } *************** *** 168,174 **** int i, j; for (i = 0; i < len; i++) { ! outb(_PNP_ADDRESS, STATUS); for (j = 0; j < 100; j++) { if ((inb((rd_port << 2) | 0x3)) & 0x1) break; --- 172,178 ---- int i, j; for (i = 0; i < len; i++) { ! outb(pnp_address, STATUS); for (j = 0; j < 100; j++) { if ((inb((rd_port << 2) | 0x3)) & 0x1) break; *************** *** 178,184 **** printf("PnP device failed to report resource data\n"); return 0; } ! outb(_PNP_ADDRESS, RESOURCE_DATA); buffer[i] = inb((rd_port << 2) | 0x3); DEB(printf("--- get_resource_info: got 0x%02x\n",(unsigned)buffer[i])); } --- 182,188 ---- printf("PnP device failed to report resource data\n"); return 0; } ! outb(pnp_address, RESOURCE_DATA); buffer[i] = inb((rd_port << 2) | 0x3); DEB(printf("--- get_resource_info: got 0x%02x\n",(unsigned)buffer[i])); } *************** *** 481,487 **** *(int *)&(data[4])); pnp_write(SET_CSN, csn); /* Move this out of this function XXX */ ! outb(_PNP_ADDRESS, STATUS); /* Allows up to 1kb of Resource Info, Should be plenty */ for (i = 0; i < 1024; i++) { --- 485,491 ---- *(int *)&(data[4])); pnp_write(SET_CSN, csn); /* Move this out of this function XXX */ ! outb(pnp_address, STATUS); /* Allows up to 1kb of Resource Info, Should be plenty */ for (i = 0; i < 1024; i++) { *************** *** 569,575 **** logdevs = 0 ; pnp_write(WAKE, 0); pnp_write(SET_RD_DATA, rd_port); ! outb(_PNP_ADDRESS, SERIAL_ISOLATION); DELAY(1000); /* Delay 1 msec */ if (get_serial(data)) --- 573,579 ---- logdevs = 0 ; pnp_write(WAKE, 0); pnp_write(SET_RD_DATA, rd_port); ! outb(pnp_address, SERIAL_ISOLATION); DELAY(1000); /* Delay 1 msec */ if (get_serial(data)) *************** *** 585,590 **** --- 589,611 ---- main() { int num_pnp_devs; + int mib[2]; + size_t len; + char *val; + + mib[0] = CTL_HW; + mib[1] = HW_MACHINE_ARCH; + sysctl(mib, 2, NULL, &len, NULL, 0); + val = (char *)malloc(len); + sysctl(mib, 2, val, &len, NULL, 0); + if (strcmp(val, "pc-98") == 0) { + pnp_address = 0x259; + pnp_write_data = 0xa59; + } else { + pnp_address = _PNP_ADDRESS; + pnp_write_data = _PNP_WRITE_DATA; + } + free(val); /* Hey what about a i386_iopl() call :) */ if (open("/dev/io", O_RDONLY) < 0) {