forked from pool/acpica
- Add possibility to see changes via new -s param: -r [ -s sleep ]
OBS-URL: https://build.opensuse.org/package/show/hardware/acpica?expand=0&rev=22
This commit is contained in:
parent
177de706e6
commit
74ab343264
@ -1,3 +1,8 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Thu Feb 24 15:31:07 UTC 2011 - trenn@novell.com
|
||||||
|
|
||||||
|
- Add possibility to see changes via new -s param: -r [ -s sleep ]
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Fri Jan 14 15:01:06 UTC 2011 - trenn@novell.com
|
Fri Jan 14 15:01:06 UTC 2011 - trenn@novell.com
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# spec file for package acpica (Version 20101013)
|
# spec file for package acpica
|
||||||
#
|
#
|
||||||
# Copyright (c) 2010 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
# Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||||
#
|
#
|
||||||
# All modifications and additions to the file contributed by third parties
|
# All modifications and additions to the file contributed by third parties
|
||||||
# remain the property of their copyright owners, unless otherwise agreed
|
# remain the property of their copyright owners, unless otherwise agreed
|
||||||
|
74
ec_access.c
74
ec_access.c
@ -28,6 +28,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
static int read_mode = -1;
|
static int read_mode = -1;
|
||||||
|
static int sleep_time;
|
||||||
static int write_byte_offset = -1;
|
static int write_byte_offset = -1;
|
||||||
static int read_byte_offset = -1;
|
static int read_byte_offset = -1;
|
||||||
static uint8_t write_value = -1;
|
static uint8_t write_value = -1;
|
||||||
@ -35,16 +36,18 @@ static uint8_t write_value = -1;
|
|||||||
void usage(char progname[], int exit_status)
|
void usage(char progname[], int exit_status)
|
||||||
{
|
{
|
||||||
printf("Usage:\n");
|
printf("Usage:\n");
|
||||||
printf("1) %s -r\n", basename(progname));
|
printf("1) %s -r [-s sleep]\n", basename(progname));
|
||||||
printf("2) %s -b byte_offset\n", basename(progname));
|
printf("2) %s -b byte_offset\n", basename(progname));
|
||||||
printf("3) %s -w byte_offset -v value\n\n", basename(progname));
|
printf("3) %s -w byte_offset -v value\n\n", basename(progname));
|
||||||
|
|
||||||
puts("\t-r or --read -- Dump EC registers");
|
puts("\t-r [-s sleep] : Dump EC registers");
|
||||||
puts("\t-b or --byte byte_offset -- Read value "
|
puts("\t If sleep is given, sleep x seconds,");
|
||||||
|
puts("\t re-read EC registers and show changes");
|
||||||
|
puts("\t-b offset : Read value"
|
||||||
" at byte_offset (in hex)");
|
" at byte_offset (in hex)");
|
||||||
puts("\t-w or --write byte_offset -v or --value value -- "
|
puts("\t-w offset -v value : "
|
||||||
"Write value at byte_offset");
|
"Write value at byte_offset");
|
||||||
puts("\t-h or --help -- Print this help\n\n");
|
puts("\t-h : Print this help\n\n");
|
||||||
puts("Offsets and values are in hexadecimal number sytem.");
|
puts("Offsets and values are in hexadecimal number sytem.");
|
||||||
puts("The offset and value must be between 0 and 0xff.");
|
puts("The offset and value must be between 0 and 0xff.");
|
||||||
exit(exit_status);
|
exit(exit_status);
|
||||||
@ -53,21 +56,8 @@ void usage(char progname[], int exit_status)
|
|||||||
void parse_opts(int argc, char *argv[])
|
void parse_opts(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
struct option long_options[] = {
|
|
||||||
{"read", 0, 0, 'r'},
|
|
||||||
{"byte", 0, 0, 'b'},
|
|
||||||
{"write", 1, 0, 'w'},
|
|
||||||
{"value", 1, 0, 'v'},
|
|
||||||
{"help", 0, 0, 'h'},
|
|
||||||
{0, 0, 0, 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
while (1) {
|
while ((c = getopt(argc, argv, "rs:b:w:v:h")) != -1) {
|
||||||
c = getopt_long(argc, argv, "rb:w:v:h",
|
|
||||||
long_options, NULL);
|
|
||||||
|
|
||||||
if (c == -1)
|
|
||||||
break;
|
|
||||||
|
|
||||||
switch (c) {
|
switch (c) {
|
||||||
case 'r':
|
case 'r':
|
||||||
@ -75,6 +65,17 @@ void parse_opts(int argc, char *argv[])
|
|||||||
usage (argv[0], EXIT_FAILURE);
|
usage (argv[0], EXIT_FAILURE);
|
||||||
read_mode = 1;
|
read_mode = 1;
|
||||||
break;
|
break;
|
||||||
|
case 's':
|
||||||
|
if (read_mode != -1 && read_mode != 1)
|
||||||
|
usage (argv[0], EXIT_FAILURE);
|
||||||
|
|
||||||
|
sleep_time = atoi(optarg);
|
||||||
|
if (sleep_time <= 0) {
|
||||||
|
sleep_time = 0;
|
||||||
|
usage(argv[0], EXIT_FAILURE);
|
||||||
|
printf("Bad sleep time: %s\n", optarg);
|
||||||
|
}
|
||||||
|
break;
|
||||||
case 'b':
|
case 'b':
|
||||||
if (read_mode != -1)
|
if (read_mode != -1)
|
||||||
usage (argv[0], EXIT_FAILURE);
|
usage (argv[0], EXIT_FAILURE);
|
||||||
@ -127,6 +128,7 @@ void parse_opts(int argc, char *argv[])
|
|||||||
void dump_ec(int fd)
|
void dump_ec(int fd)
|
||||||
{
|
{
|
||||||
char buf[EC_SPACE_SIZE];
|
char buf[EC_SPACE_SIZE];
|
||||||
|
char buf2[EC_SPACE_SIZE];
|
||||||
int byte_off, bytes_read;
|
int byte_off, bytes_read;
|
||||||
|
|
||||||
bytes_read = read(fd, buf, EC_SPACE_SIZE);
|
bytes_read = read(fd, buf, EC_SPACE_SIZE);
|
||||||
@ -137,14 +139,40 @@ void dump_ec(int fd)
|
|||||||
if (bytes_read != EC_SPACE_SIZE)
|
if (bytes_read != EC_SPACE_SIZE)
|
||||||
fprintf(stderr, "Could only read %d bytes\n", bytes_read);
|
fprintf(stderr, "Could only read %d bytes\n", bytes_read);
|
||||||
|
|
||||||
printf("\t00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F\n");
|
printf(" 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F");
|
||||||
for (byte_off = 0; byte_off < bytes_read; byte_off++) {
|
for (byte_off = 0; byte_off < bytes_read; byte_off++) {
|
||||||
if ((byte_off % 16) == 0)
|
if ((byte_off % 16) == 0)
|
||||||
printf("\n%.2X: \t", byte_off);
|
printf("\n%.2X: ", byte_off);
|
||||||
printf("%.2x ", (uint8_t)buf[byte_off]);
|
printf(" %.2x ", (uint8_t)buf[byte_off]);
|
||||||
|
}
|
||||||
|
printf("\n");
|
||||||
|
|
||||||
|
if (!sleep_time)
|
||||||
|
return;
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
lseek(fd, 0, SEEK_SET);
|
||||||
|
sleep(sleep_time);
|
||||||
|
|
||||||
|
bytes_read = read(fd, buf2, EC_SPACE_SIZE);
|
||||||
|
|
||||||
|
if (bytes_read == -1)
|
||||||
|
err(EXIT_FAILURE, "Could not read from %s\n", SYSFS_PATH);
|
||||||
|
|
||||||
|
if (bytes_read != EC_SPACE_SIZE)
|
||||||
|
fprintf(stderr, "Could only read %d bytes\n", bytes_read);
|
||||||
|
|
||||||
|
printf(" 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F");
|
||||||
|
for (byte_off = 0; byte_off < bytes_read; byte_off++) {
|
||||||
|
if ((byte_off % 16) == 0)
|
||||||
|
printf("\n%.2X: ", byte_off);
|
||||||
|
|
||||||
|
if (buf[byte_off] == buf2[byte_off])
|
||||||
|
printf(" %.2x ", (uint8_t)buf2[byte_off]);
|
||||||
|
else
|
||||||
|
printf("*%.2x ", (uint8_t)buf2[byte_off]);
|
||||||
}
|
}
|
||||||
printf("\n");
|
printf("\n");
|
||||||
sync();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void read_ec_val(int fd, int byte_offset)
|
void read_ec_val(int fd, int byte_offset)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user