ISA utility to dump address/register type adderss spaces.

Usage: isadump <ADDR-REG> <DATA-REG>
For the default LM78, this would be `isadump 0x295 0x296' (addresses may be
specified as decimal, octal or hexadecimal).


git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@144 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
Frodo Looijaard committed 1999-01-01 00:41:46 +00:00
1 parent ac942d1a09
commit dfc74d0f39
3 files changed
+157 -1

No files matched your search

+1 -1
View File
@@ -102,7 +102,7 @@ LIBINCLUDEDIR := $(INCLUDEDIR)/sensors
# to do this.
# The subdirectories we need to build things in
SRCDIRS := src lib prog/sensors etc
SRCDIRS := src lib prog/sensors prog/dump etc
ifeq ($(I2C),1)
SRCDIRS += i2c i2c/detect i2c/drivers i2c/eeprom
endif
+38
View File
@@ -0,0 +1,38 @@
# Module.mk - Makefile for a Linux module for reading sensor data.
# Copyright (c) 1998 Frodo Looijaard <frodol@dds.nl>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
# Note that MODULE_DIR (the directory in which this file resides) is a
# 'simply expanded variable'. That means that its value is substituted
# verbatim in the rules, until it is redefined.
MODULE_DIR := prog/dump
# Regrettably, even 'simply expanded variables' will not put their currently
# defined value verbatim into the command-list of rules...
PROGDUMPTARGETS := $(MODULE_DIR)/isadump
PROGDUMPSOURCES := $(MODULE_DIR)/isadump.c
# Include all dependency files. We use '.rd' to indicate this will create
# executables.
INCLUDEFILES += $(PROGDUMPSOURCES:.c=.rd)
all-prog-dump: $(PROGDUMPTARGETS)
all :: all-prog-dump
clean-prog-dump:
$(RM) $(PROGDUMPSOURCES:.c=.rd) $(PROGDUMPSOURCES:.c=.ro) \
$(PROGDUMPTARGETS)
clean :: clean-prog-dump
+118
View File
@@ -0,0 +1,118 @@
/*
isadump.c - Part of isadump, a user-space program to dump ISA registers
Copyright (c) 1999 Frodo Looijaard <frodol@dds.nl>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <asm/io.h>
char hexchar(int i)
{
if ((i >= 0) && (i <= 9))
return '0' + i;
else if (i <= 15)
return 'a' - 10 + i;
else
return 'X';
}
void help(void)
{
fprintf(stderr,"Syntax: isadump ADDRREG DATAREG\n");
}
int main(int argc, char *argv[])
{
int addrreg, datareg;
char *end;
int i,j,res;
if (argc < 2) {
fprintf(stderr,"Error: No address register specified!\n");
help();
exit(1);
}
addrreg = strtol(argv[1],&end,0);
if (*end) {
fprintf(stderr,"Error: First argument not a number!\n");
help();
exit(1);
}
if ((addrreg < 0) || (addrreg > 0xfff)) {
fprintf(stderr,"Error: Address register out of range!\n");
help();
}
if (argc < 3) {
fprintf(stderr,"Error: No data register specified!\n");
help();
exit(1);
}
datareg = strtol(argv[2],&end,0);
if (*end) {
fprintf(stderr,"Error: Second argument not a number!\n");
help();
exit(1);
}
if ((datareg < 0) || (datareg > 0xfff)) {
fprintf(stderr,"Error: Data register out of range!\n");
help();
}
if (getuid()) {
fprintf(stderr,"Error: Can only be run as root (or make it suid root)\n");
exit(1);
}
fprintf(stderr," WARNING! Running this program can cause system crashes, "
"data loss and worse!\n");
fprintf(stderr," I will probe address register 0x%04x and "
"data register 0x%04x.\n",addrreg,datareg);
fprintf(stderr," You have five seconds to reconsider and press CTRL-C!\n\n");
sleep(5);
if ((datareg < 0x400) && (datareg < 0x400)) {
if(ioperm(datareg,1,1)) {
fprintf(stderr,"Error: Could not ioperm() data register!\n");
exit(1);
}
if(ioperm(addrreg,1,1)) {
fprintf(stderr,"Error: Could not ioperm() address register!\n");
exit(1);
}
} else {
if(iopl(3)) {
fprintf(stderr,"Error: Could not do iopl(3)!\n");
exit(1);
}
}
printf(" 0 1 2 3 4 5 6 7 8 9 a b c d e f\n");
for (i = 0; i < 256; i+=16) {
printf("%c0: ",hexchar(i/16));
for(j = 0; j < 16; j++) {
outb(i+j,addrreg);
res = inb(datareg);
printf("%c%c ",hexchar(res/16),hexchar(res%16));
}
printf("\n");
}
exit(0);
}