1 /* SPDX-License-Identifier: GPL-2.0-or-later */
10 #define POST_DEFAULT_IO_PORT 0x80
12 void usage(char *progname
, const char *error
, ...)
14 printf("Usage: %s <VALUE> [PORT]\n", progname
);
15 printf("The VALUE argument is an integer between 0x00 and 0xff\n");
16 printf("The PORT argument is an integer between 0x00 and 0xffff\n");
21 va_start(args
, error
);
27 void check_int(long val
, int min
, int max
, int err
, char *string
, char *endptr
,
30 if (val
< min
|| val
> max
) {
32 "\nError: The value has to be between 0x%x and 0x%x\n",
37 if (endptr
== string
|| *endptr
!= '\0') {
38 usage(progname
, "\nError: An integer is required\n");
42 if ((err
) && (!val
)) {
48 int main(int argc
, char *argv
[])
51 unsigned long port
= POST_DEFAULT_IO_PORT
;
55 if (argc
!= 2 && argc
!= 3) {
60 val
= strtol(argv
[1], &endptr
, 0);
62 check_int(val
, 0x00, 0xff, err
, argv
[1], endptr
, argv
[0]);
65 port
= strtol(argv
[2], &endptr
, 0);
67 check_int(port
, 0x0000, 0xffff, err
, argv
[2], endptr
, argv
[0]);