-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
14 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,17 @@ | ||
/* pci_debug.c | ||
* | ||
* Update version:6/21/2021 Léo Dumez [email protected] | ||
* Update version:2025/01/24 Release v1.0 | ||
* Add version option | ||
* | ||
* Update version:2021/06/21 Léo Dumez [email protected] | ||
* Add commands file support. | ||
* Add verbosity level: | ||
* - 0: only error and warning | ||
* - 1: 0 + the current BAR | ||
* - 2: 1 + the sent command | ||
* - 3: Everything | ||
* | ||
* First version :6/21/2010 D. W. Hawkins | ||
* First version :2010/06/21 D. W. Hawkins | ||
* | ||
* PCI debug registers interface. | ||
* | ||
|
@@ -40,9 +43,12 @@ | |
#include <readline/readline.h> | ||
#include <readline/history.h> | ||
|
||
|
||
int quit = 0; | ||
int verbosity = 3; | ||
|
||
#define VERSION "v1.0" | ||
|
||
/* PCI device */ | ||
typedef struct { | ||
/* Base address region */ | ||
|
@@ -145,6 +151,7 @@ static void show_usage() | |
{ | ||
printf("\nUsage: pci_debug -s <device>\n"\ | ||
" -h Help (this message)\n"\ | ||
" -V display version\n"\ | ||
" -s <device> Slot/device (as per lspci)\n" \ | ||
" -b <BAR> Base address region (BAR) to access, eg. 0 for BAR0\n" \ | ||
" -q Quit after send a command file\n" \ | ||
|
@@ -165,12 +172,15 @@ int main(int argc, char *argv[]) | |
/* Clear the structure fields */ | ||
memset(dev, 0, sizeof(device_t)); | ||
|
||
while ((opt = getopt(argc, argv, "b:hs:f:qv:")) != -1) { | ||
while ((opt = getopt(argc, argv, "b:hs:f:qv:V")) != -1) { | ||
switch (opt) { | ||
case 'b': | ||
/* Defaults to BAR0 if not provided */ | ||
dev->bar = atoi(optarg); | ||
break; | ||
case 'V': | ||
printf("pci_debug %s\n", VERSION); | ||
return -1; | ||
case 'h': | ||
show_usage(); | ||
return -1; | ||
|
@@ -343,7 +353,7 @@ void useCmdFile(device_t *dev, char* cmdFilePath) | |
} | ||
firstLine = 0; | ||
}else{ | ||
verbosity>=2?printf("Send: %s", line, len):0; | ||
verbosity>=2?printf("Send: %s (%ld)", line, len):0; | ||
status = process_command(dev, line); | ||
if (status < 0) { | ||
printf("Warning: Command failure - %s", line); | ||
|