Skip to content

Commit

Permalink
version v1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Martoni committed Jan 24, 2025
1 parent ada3aed commit 27e2012
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions pci_debug.c
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.
*
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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" \
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 27e2012

Please sign in to comment.