mirror of
https://github.com/lm-sensors/lm-sensors.git
synced 2026-11-12 16:50:15 +00:00
Wait for user input to continue (as opposed to 5 sec delay).
Can be skipped using -y. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@2663 7894878c-1315-0410-8ee3-d5d059ff63e0
This commit is contained in:
1 parent
ed81aef459
commit
89deecca35
4 files changed
+134
-69
No files matched your search
+15
-2
@@ -1,15 +1,17 @@
|
||||
.TH ISADUMP 8 "July 2004"
|
||||
.TH ISADUMP 8 "August 2004"
|
||||
.SH NAME
|
||||
isadump \- examine ISA registers
|
||||
|
||||
.SH SYNOPSIS
|
||||
.B isadump
|
||||
.RB [ -y ]
|
||||
.I addrreg
|
||||
.I datareg
|
||||
.RI [ "bank " [ bankreg ]]
|
||||
#for I2C-like access
|
||||
.br
|
||||
.B isadump
|
||||
.RB [ -y ]
|
||||
.BI "-f " address
|
||||
.RI [ "range " [ "bank " [ bankreg ]]]
|
||||
#for flat address space
|
||||
@@ -20,6 +22,17 @@ bus. It is intended to probe any chip that lives on the ISA bus working with an
|
||||
address register and a data register (I2C-like access) or a flat range (of up
|
||||
to 256 bytes).
|
||||
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B -f
|
||||
Enable flat address space mode.
|
||||
.TP
|
||||
.B -y
|
||||
Disable interactive mode. By default, isadump will wait for a confirmation
|
||||
from the user before messing with the ISA bus. When this flag is used, it
|
||||
will perform the operation directly. This is mainly meant to be used in
|
||||
scripts.
|
||||
|
||||
.SH OPTIONS (I2C-like access mode)
|
||||
At least two options must be provided to isadump. \fIaddrreg\fR contains the
|
||||
ISA address of the address register for the chip to probe; \fIdatareg\fR
|
||||
@@ -39,7 +52,7 @@ for Super-I/O chips). The W83781D datasheet has more information on bank
|
||||
selection.
|
||||
|
||||
.SH OPTIONS (flat address space mode)
|
||||
In flat mode (triggered by the \fB-f\fR flag), only one parameter is
|
||||
In flat mode, only one parameter is
|
||||
mandatory. \fIaddress\fR contains the ISA address of the chip to probe;
|
||||
it is an integer between 0x0000 and 0xFFFF.
|
||||
If provided, \fIrange\fR is how many bytes should be read (must be a
|
||||
|
||||
+54
-30
@@ -59,9 +59,9 @@ void help(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Syntax for I2C-like access:\n"
|
||||
" isadump ADDRREG DATAREG [BANK [BANKREG]]\n"
|
||||
" isadump [-y] ADDRREG DATAREG [BANK [BANKREG]]\n"
|
||||
"Syntax for flat address space:\n"
|
||||
" isadump -f ADDRESS [RANGE [BANK [BANKREG]]]\n");
|
||||
" isadump [-y] -f ADDRESS [RANGE [BANK [BANKREG]]]\n");
|
||||
}
|
||||
|
||||
int default_bankreg(int flat, int addrreg, int datareg)
|
||||
@@ -104,19 +104,32 @@ int main(int argc, char *argv[])
|
||||
int bankreg;
|
||||
int oldbank = 0;
|
||||
int i, j, res;
|
||||
int flat = 0;
|
||||
int flags = 0;
|
||||
int flat = 0, yes = 0;
|
||||
char *end;
|
||||
|
||||
if (argc < 3) {
|
||||
/* handle (optional) flags first */
|
||||
while (1+flags < argc && argv[1+flags][0] == '-') {
|
||||
switch (argv[1+flags][1]) {
|
||||
case 'f': flat = 1; break;
|
||||
case 'y': yes = 1; break;
|
||||
default:
|
||||
fprintf(stderr, "Warning: Unsupported flag "
|
||||
"\"-%c\"!\n", argv[1+flags][1]);
|
||||
help();
|
||||
exit(1);
|
||||
}
|
||||
flags++;
|
||||
}
|
||||
|
||||
/* verify that the argument count is correct */
|
||||
if ((!flat && argc < 1+flags+2)
|
||||
|| (flat && argc < 1+flags+1)) {
|
||||
help();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!strcmp(argv[1], "-f")) {
|
||||
flat = 1;
|
||||
}
|
||||
|
||||
addrreg = strtol(argv[1+flat], &end, 0);
|
||||
addrreg = strtol(argv[1+flags], &end, 0);
|
||||
if (*end) {
|
||||
fprintf(stderr, "Error: Invalid address!\n");
|
||||
help();
|
||||
@@ -130,8 +143,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
if (flat) {
|
||||
if (argc > 3) {
|
||||
range = strtol(argv[3], &end, 0);
|
||||
if (1+flags+1 < argc) {
|
||||
range = strtol(argv[1+flags+1], &end, 0);
|
||||
if (*end || range <= 0 || range > 0x100
|
||||
|| range & 0xf) {
|
||||
fprintf(stderr, "Error: Invalid range!\n"
|
||||
@@ -144,7 +157,7 @@ int main(int argc, char *argv[])
|
||||
addrreg &= 0xff00; /* Force alignment */
|
||||
}
|
||||
} else {
|
||||
datareg = strtol(argv[2], &end, 0);
|
||||
datareg = strtol(argv[1+flags+1], &end, 0);
|
||||
if (*end) {
|
||||
fprintf(stderr, "Error: Invalid data register!\n");
|
||||
help();
|
||||
@@ -160,8 +173,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
bankreg = default_bankreg(flat, addrreg, datareg);
|
||||
|
||||
if (argc > 3+flat) {
|
||||
bank = strtol(argv[3+flat], &end, 0);
|
||||
if (1+flags+2 < argc) {
|
||||
bank = strtol(argv[1+flags+2], &end, 0);
|
||||
if (*end) {
|
||||
fprintf(stderr, "Error: Invalid bank number!\n");
|
||||
help();
|
||||
@@ -173,8 +186,8 @@ int main(int argc, char *argv[])
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (argc > 4+flat) {
|
||||
bankreg = strtol(argv[4+flat], &end, 0);
|
||||
if (1+flags+3 < argc) {
|
||||
bankreg = strtol(argv[1+flags+3], &end, 0);
|
||||
if (*end) {
|
||||
fprintf(stderr, "Error: Invalid bank "
|
||||
"register!\n");
|
||||
@@ -196,20 +209,31 @@ int main(int argc, char *argv[])
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fprintf(stderr, "WARNING! Running this program can cause system "
|
||||
"crashes, data loss and worse!\n");
|
||||
if (flat)
|
||||
fprintf(stderr, "I will probe address range 0x%04x to "
|
||||
"0x%04x.\n", addrreg, addrreg + range - 1);
|
||||
else
|
||||
fprintf(stderr, "I will probe address register 0x%04x and "
|
||||
"data register 0x%04x.\n", addrreg, datareg);
|
||||
if (bank>=0)
|
||||
fprintf(stderr, "Probing bank %d using bank register "
|
||||
"0x%02x.\n", bank, bankreg);
|
||||
fprintf(stderr, "You have five seconds to reconsider and press "
|
||||
"CTRL-C!\n\n");
|
||||
sleep(5);
|
||||
if (!yes) {
|
||||
char s[2];
|
||||
|
||||
fprintf(stderr, "WARNING! Running this program can cause "
|
||||
"system crashes, data loss and worse!\n");
|
||||
|
||||
if (flat)
|
||||
fprintf(stderr, "I will probe address range 0x%x to "
|
||||
"0x%x.\n", addrreg, addrreg + range - 1);
|
||||
else
|
||||
fprintf(stderr, "I will probe address register 0x%x "
|
||||
"and data register 0x%x.\n", addrreg, datareg);
|
||||
|
||||
if (bank>=0)
|
||||
fprintf(stderr, "Probing bank %d using bank register "
|
||||
"0x%02x.\n", bank, bankreg);
|
||||
|
||||
fprintf(stderr, "Continue? [Y/n] ");
|
||||
fflush(stderr);
|
||||
fgets(s, 2, stdin);
|
||||
if (s[0] != '\n' && s[0] != 'y' && s[0] != 'Y') {
|
||||
fprintf(stderr, "Aborting on user request.\n");
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef __powerpc__
|
||||
if ((datareg < 0x400) && (addrreg < 0x400) && !flat) {
|
||||
|
||||
+15
-2
@@ -1,9 +1,10 @@
|
||||
.TH ISASET 8 "July 2004"
|
||||
.TH ISASET 8 "August 2004"
|
||||
.SH "NAME"
|
||||
i2cset \- set ISA registers
|
||||
|
||||
.SH SYNOPSIS
|
||||
.B isaset
|
||||
.RB [ -y ]
|
||||
.I addrreg
|
||||
.I datareg
|
||||
.I address
|
||||
@@ -11,6 +12,7 @@ i2cset \- set ISA registers
|
||||
#for I2C-like access
|
||||
.br
|
||||
.B isaset
|
||||
.RB [ -y ]
|
||||
.BI "-f " address
|
||||
.I value
|
||||
#for flat address space
|
||||
@@ -19,6 +21,17 @@ i2cset \- set ISA registers
|
||||
isaset is a small helper program to set registers visible through the ISA
|
||||
bus.
|
||||
|
||||
.SH OPTIONS
|
||||
.TP
|
||||
.B -f
|
||||
Enable flat address space mode.
|
||||
.TP
|
||||
.B -y
|
||||
Disable interactive mode. By default, isaset will wait for a confirmation
|
||||
from the user before messing with the ISA bus. When this flag is used, it
|
||||
will perform the operation directly. This is mainly meant to be used in
|
||||
scripts.
|
||||
|
||||
.SH OPTIONS (I2C-like access mode)
|
||||
Exactly four options must be provided to isaset. \fIaddrreg\fR contains the
|
||||
ISA address of the address register for the chip to probe; \fIdatareg\fR
|
||||
@@ -33,7 +46,7 @@ The \fIaddress\fR and \fIvalue\fR parameters are two integers between
|
||||
0x00 and 0xFF. isaset will write value \fIvalue\fR to address \fIaddress\fR.
|
||||
|
||||
.SH OPTIONS (flat address space mode)
|
||||
In flat mode (triggered by the \fB-f\fR flag), exactly two parameters must
|
||||
In flat mode, exactly two parameters must
|
||||
be provided. \fIaddress\fR contains the ISA address of the register to
|
||||
write to; it is an integer between 0x0000 and 0xFFFF. Basically, it is
|
||||
the sum of the chip's base address and the chip register's address. isaset
|
||||
|
||||
+50
-35
@@ -46,33 +46,41 @@ void help(void)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Syntax for I2C-like access:\n"
|
||||
" isaset ADDRREG DATAREG ADDRESS VALUE\n"
|
||||
" isaset [-y] ADDRREG DATAREG ADDRESS VALUE\n"
|
||||
"Syntax for flat address space:\n"
|
||||
" isaset -f ADDRESS VALUE\n");
|
||||
" isaset [-y] -f ADDRESS VALUE\n");
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int addrreg, datareg = 0, value, addr = 0;
|
||||
unsigned char res;
|
||||
int flat = 0;
|
||||
int flags = 0;
|
||||
int flat = 0, yes = 0;
|
||||
char *end;
|
||||
|
||||
if (argc < 4) {
|
||||
/* handle (optional) flags first */
|
||||
while (1+flags < argc && argv[1+flags][0] == '-') {
|
||||
switch (argv[1+flags][1]) {
|
||||
case 'f': flat = 1; break;
|
||||
case 'y': yes = 1; break;
|
||||
default:
|
||||
fprintf(stderr, "Warning: Unsupported flag "
|
||||
"\"-%c\"!\n", argv[1+flags][1]);
|
||||
help();
|
||||
exit(1);
|
||||
}
|
||||
flags++;
|
||||
}
|
||||
|
||||
/* verify that the argument count is correct */
|
||||
if ((!flat && argc != 1+flags+4)
|
||||
|| (flat && argc != 1+flags+2)) {
|
||||
help();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
if (!strcmp(argv[1], "-f")) {
|
||||
flat = 1;
|
||||
}
|
||||
|
||||
if (argc != 5-flat) {
|
||||
help();
|
||||
exit(1);
|
||||
}
|
||||
|
||||
addrreg = strtol(argv[1+flat], &end, 0);
|
||||
addrreg = strtol(argv[1+flags], &end, 0);
|
||||
if (*end) {
|
||||
fprintf(stderr, "Error: Invalid address!\n");
|
||||
help();
|
||||
@@ -87,7 +95,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
if (!flat) {
|
||||
datareg = strtol(argv[2], &end, 0);
|
||||
datareg = strtol(argv[1+flags+1], &end, 0);
|
||||
if (*end) {
|
||||
fprintf(stderr, "Error: Invalid data register!\n");
|
||||
help();
|
||||
@@ -100,7 +108,7 @@ int main(int argc, char *argv[])
|
||||
exit(1);
|
||||
}
|
||||
|
||||
addr = strtol(argv[3], &end, 0);
|
||||
addr = strtol(argv[1+flags+2], &end, 0);
|
||||
if (*end) {
|
||||
fprintf(stderr, "Error: Invalid address!\n");
|
||||
help();
|
||||
@@ -114,7 +122,7 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
|
||||
value = strtol(argv[4-flat], &end, 0);
|
||||
value = strtol(argv[flat?1+flags+1:1+flags+3], &end, 0);
|
||||
if (*end) {
|
||||
fprintf(stderr, "Error: Invalid value!\n");
|
||||
help();
|
||||
@@ -133,19 +141,29 @@ int main(int argc, char *argv[])
|
||||
exit(1);
|
||||
}
|
||||
|
||||
fprintf(stderr, "WARNING! Running this program can cause "
|
||||
"system crashes, data loss and worse!\n");
|
||||
if (flat)
|
||||
fprintf(stderr, "I will write value 0x%02x to address "
|
||||
"0x%04x\n", value, addrreg);
|
||||
else
|
||||
fprintf(stderr, "I will write value 0x%02x to address "
|
||||
"0x%02x of chip with address register 0x%04x\n"
|
||||
"and data register 0x%04x.\n",
|
||||
value, addr, addrreg, datareg);
|
||||
fprintf(stderr, "You have five seconds to reconsider and press "
|
||||
"CTRL-C!\n\n");
|
||||
sleep(5);
|
||||
if (!yes) {
|
||||
char s[2];
|
||||
|
||||
fprintf(stderr, "WARNING! Running this program can cause "
|
||||
"system crashes, data loss and worse!\n");
|
||||
|
||||
if (flat)
|
||||
fprintf(stderr, "I will write value 0x%02x to address "
|
||||
"0x%x.\n", value, addrreg);
|
||||
else
|
||||
fprintf(stderr, "I will write value 0x%02x to address "
|
||||
"0x%02x of chip with address register 0x%x\n"
|
||||
"and data register 0x%x.\n",
|
||||
value, addr, addrreg, datareg);
|
||||
|
||||
fprintf(stderr, "Continue? [Y/n] ");
|
||||
fflush(stderr);
|
||||
fgets(s, 2, stdin);
|
||||
if (s[0] != '\n' && s[0] != 'y' && s[0] != 'Y') {
|
||||
fprintf(stderr, "Aborting on user request.\n");
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef __powerpc__
|
||||
if (!flat && datareg < 0x400 && addrreg < 0x400) {
|
||||
@@ -184,11 +202,8 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
if (res != value) {
|
||||
fprintf(stderr, "Warning: Data mismatch, wrote 0x%02x, "
|
||||
"read back 0x%02x\n", value, res);
|
||||
} else {
|
||||
fprintf(stderr, "Value 0x%02x written, readback matched\n",
|
||||
value);
|
||||
fprintf(stderr, "Data mismatch, wrote 0x%02x, "
|
||||
"read 0x%02x back.\n", value, res);
|
||||
}
|
||||
|
||||
exit(0);
|
||||
|
||||
Reference in new issue
Block a user