|
|
1.1 ! root 1: /* biosports.c - report com1-4 and lpt1-3 */ ! 2: ! 3: #include <fcntl.h> ! 4: ! 5: /* a machine-dependent structure */ ! 6: struct bports { ! 7: short com[4]; ! 8: short lpt[3]; ! 9: } bp; ! 10: ! 11: #define MEM_FILE "/dev/mem" ! 12: #define SBP sizeof(bp) ! 13: #define PORTADDR 0x400 ! 14: ! 15: main() ! 16: { ! 17: int fd, i, res; ! 18: ! 19: if ((fd = open(MEM_FILE, O_RDONLY)) < 0) { ! 20: printf("Can't open %s\n", MEM_FILE); ! 21: exit(1); ! 22: } ! 23: ! 24: if (lseek(fd, PORTADDR, 0) != PORTADDR) { ! 25: printf("Can't lseek to offset %d in %s\n", PORTADDR, MEM_FILE); ! 26: exit(1); ! 27: } ! 28: ! 29: if ((res = read(fd, &bp, SBP)) != SBP) { ! 30: printf("Can't read %d bytes from %s\n", SBP, MEM_FILE); ! 31: printf("res = %d "); ! 32: perror("read"); ! 33: exit(1); ! 34: } ! 35: ! 36: for (i = 0; i < 4; i++) ! 37: printf("com%d = 0x%04x\n", i+1, bp.com[i]); ! 38: ! 39: for (i = 0; i < 3; i++) ! 40: printf("lpt%d = 0x%04x\n", i+1, bp.lpt[i]); ! 41: ! 42: close(fd); ! 43: exit(0); ! 44: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.