Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Simple PCIe FMC carrier SPEC
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
50
Issues
50
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
Simple PCIe FMC carrier SPEC
Commits
5eaf8a08
Commit
5eaf8a08
authored
Oct 30, 2020
by
Federico Vaga
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
sw:tool: print both metadata spec-(base|app)
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
dedcf334
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
97 additions
and
28 deletions
+97
-28
Makefile
software/tools/Makefile
+3
-2
spec-firmware-version.c
software/tools/spec-firmware-version.c
+94
-26
No files found.
software/tools/Makefile
View file @
5eaf8a08
...
@@ -11,7 +11,8 @@ DESTDIR ?= /usr/local/
...
@@ -11,7 +11,8 @@ DESTDIR ?= /usr/local/
TOOLS
=
spec-firmware-version
TOOLS
=
spec-firmware-version
CFLAGS
=
-ggdb
-I
.
-I
../include/uapi
-Wall
-Werror
$(EXTRACFLAGS)
INCLUDE
:=
-I
.
-I
../kernel
-I
../include/uapi
CFLAGS
=
-ggdb
$(INCLUDE)
-Wall
-Werror
$(EXTRACFLAGS)
GIT_VERSION
:=
$(
shell
git describe
--dirty
--long
--tags
)
GIT_VERSION
:=
$(
shell
git describe
--dirty
--long
--tags
)
CFLAGS
+=
-DGIT_VERSION
=
"
\"
$(GIT_VERSION)
\"
"
CFLAGS
+=
-DGIT_VERSION
=
"
\"
$(GIT_VERSION)
\"
"
...
@@ -31,6 +32,6 @@ install:
...
@@ -31,6 +32,6 @@ install:
install
-D
$(TOOLS)
$(DESTDIR)
/bin
install
-D
$(TOOLS)
$(DESTDIR)
/bin
cppcheck
:
cppcheck
:
$(CPPCHECK)
-q
-I
.
-I
../include/uapi
--suppress
=
missingIncludeSystem
--enable
=
all
*
.c
*
.h
--error-exitcode
=
1
$(CPPCHECK)
-q
$(INCLUDE)
--suppress
=
missingIncludeSystem
--enable
=
all
*
.c
*
.h
--error-exitcode
=
1
.PHONY
=
cppcheck
.PHONY
=
cppcheck
software/tools/spec-firmware-version.c
View file @
5eaf8a08
...
@@ -7,6 +7,7 @@
...
@@ -7,6 +7,7 @@
#include <stdlib.h>
#include <stdlib.h>
#include <stdio.h>
#include <stdio.h>
#include <unistd.h>
#include <unistd.h>
#include <stdbool.h>
#include <string.h>
#include <string.h>
#include <getopt.h>
#include <getopt.h>
#include <libgen.h>
#include <libgen.h>
...
@@ -17,6 +18,7 @@
...
@@ -17,6 +18,7 @@
#include <fcntl.h>
#include <fcntl.h>
#include <linux/spec.h>
#include <linux/spec.h>
#include <spec-core-fpga.h>
static
const
char
git_version
[]
=
"git version: "
GIT_VERSION
;
static
const
char
git_version
[]
=
"git version: "
GIT_VERSION
;
...
@@ -27,6 +29,8 @@ static void help(void)
...
@@ -27,6 +29,8 @@ static void help(void)
fprintf
(
stderr
,
"%s [options]
\n
"
fprintf
(
stderr
,
"%s [options]
\n
"
"
\t
Print the firmware version
\n
"
"
\t
Print the firmware version
\n
"
"
\t
-p <PCIID>
\n
"
"
\t
-p <PCIID>
\n
"
"
\t
-b print spec-base
\n
"
"
\t
-a print spec-application
\n
"
"
\t
-V print version
\n
"
"
\t
-V print version
\n
"
"
\t
-h print help
\n
"
,
"
\t
-h print help
\n
"
,
name
);
name
);
...
@@ -43,11 +47,88 @@ static void cleanup(void)
...
@@ -43,11 +47,88 @@ static void cleanup(void)
free
(
name
);
free
(
name
);
}
}
#define PCIID_STR_LEN 16
static
void
print_meta_id
(
struct
spec_meta_id
*
rom
)
{
fprintf
(
stdout
,
" vendor : 0x%08x
\n
"
,
rom
->
vendor
);
fprintf
(
stdout
,
" device : 0x%08x
\n
"
,
rom
->
device
);
fprintf
(
stdout
,
" version : %u.%u.%u
\n
"
,
SPEC_META_VERSION_MAJ
(
rom
->
version
),
SPEC_META_VERSION_MIN
(
rom
->
version
),
SPEC_META_VERSION_PATCH
(
rom
->
version
));
if
((
rom
->
bom
&
SPEC_META_BOM_END_MASK
)
==
SPEC_META_BOM_LE
)
fputs
(
" byte-order : little-endian
\n
"
,
stdout
);
else
fputs
(
" byte-order : wrong or unknown
\n
"
,
stdout
);
fprintf
(
stdout
,
" sources : %08x%08x%08x%08x
\n
"
,
rom
->
src
[
0
],
rom
->
src
[
1
],
rom
->
src
[
2
],
rom
->
src
[
3
]);
fprintf
(
stdout
,
" capabilities : 0x%08x
\n
"
,
rom
->
cap
);
fprintf
(
stdout
,
" UUID : %08x%08x%08x%08x
\n
"
,
rom
->
uuid
[
0
],
rom
->
uuid
[
1
],
rom
->
uuid
[
2
],
rom
->
uuid
[
3
]);
}
int
main
(
int
argc
,
char
*
argv
[]
)
static
int
print_base_meta_id
(
int
fd
)
{
{
struct
spec_meta_id
*
rom
;
struct
spec_meta_id
*
rom
;
rom
=
mmap
(
NULL
,
sizeof
(
*
rom
),
PROT_READ
,
MAP_SHARED
,
fd
,
SPEC_BASE_REGS_METADATA
);
if
((
long
)
rom
==
-
1
)
{
fputs
(
"Failed while reading SPEC-BASE FPGA ROM
\n
"
,
stderr
);
return
-
1
;
}
fputs
(
"spec-base:
\n
"
,
stdout
);
print_meta_id
(
rom
);
munmap
(
rom
,
sizeof
(
*
rom
));
return
0
;
}
static
off_t
app_meta_id_offset
(
int
fd
)
{
off_t
offset
;
void
*
regs
;
regs
=
mmap
(
NULL
,
0x100
,
PROT_READ
,
MAP_SHARED
,
fd
,
0
);
if
((
long
)
regs
==
-
1
)
return
-
1
;
offset
=
*
((
uint32_t
*
)(
regs
+
SPEC_BASE_REGS_CSR_APP_OFFSET
));
munmap
(
regs
,
0x100
);
return
offset
;
}
static
int
print_app_meta_id
(
int
fd
)
{
struct
spec_meta_id
*
rom
;
off_t
offset
;
offset
=
app_meta_id_offset
(
fd
);
if
(
offset
<
0
)
{
fputs
(
"Can't get spec-app offset
\n
"
,
stderr
);
return
-
1
;
}
if
(
offset
==
0
)
{
fputs
(
"spec-application:
\n
None
\n
"
,
stderr
);
return
0
;
}
rom
=
mmap
(
NULL
,
sizeof
(
*
rom
),
PROT_READ
,
MAP_SHARED
,
fd
,
offset
);
if
((
long
)
rom
==
-
1
)
{
fputs
(
"Failed while reading SPEC-APP FPGA ROM
\n
"
,
stderr
);
return
-
1
;
}
fputs
(
"spec-application:
\n
"
,
stdout
);
print_meta_id
(
rom
);
munmap
(
rom
,
sizeof
(
*
rom
));
return
0
;
}
#define PCIID_STR_LEN 16
int
main
(
int
argc
,
char
*
argv
[])
{
bool
base
=
false
,
app
=
false
;
int
err
;
int
err
;
int
fd
;
int
fd
;
char
path
[
128
];
char
path
[
128
];
...
@@ -61,7 +142,7 @@ int main(int argc, char *argv[])
...
@@ -61,7 +142,7 @@ int main(int argc, char *argv[])
if
(
err
)
if
(
err
)
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
while
((
opt
=
getopt
(
argc
,
argv
,
"h?Vvp:"
))
!=
-
1
)
{
while
((
opt
=
getopt
(
argc
,
argv
,
"h?Vvp:
ba
"
))
!=
-
1
)
{
switch
(
opt
)
{
switch
(
opt
)
{
case
'h'
:
case
'h'
:
case
'?'
:
case
'?'
:
...
@@ -73,6 +154,12 @@ int main(int argc, char *argv[])
...
@@ -73,6 +154,12 @@ int main(int argc, char *argv[])
case
'p'
:
case
'p'
:
strncpy
(
pciid_str
,
optarg
,
PCIID_STR_LEN
);
strncpy
(
pciid_str
,
optarg
,
PCIID_STR_LEN
);
break
;
break
;
case
'a'
:
app
=
true
;
break
;
case
'b'
:
base
=
true
;
break
;
}
}
}
}
if
(
strlen
(
pciid_str
)
==
0
)
{
if
(
strlen
(
pciid_str
)
==
0
)
{
...
@@ -87,29 +174,10 @@ int main(int argc, char *argv[])
...
@@ -87,29 +174,10 @@ int main(int argc, char *argv[])
path
,
strerror
(
errno
));
path
,
strerror
(
errno
));
exit
(
EXIT_FAILURE
);
exit
(
EXIT_FAILURE
);
}
}
if
(
base
)
rom
=
mmap
(
NULL
,
sizeof
(
*
rom
),
PROT_READ
,
MAP_SHARED
,
fd
,
0
);
err
=
print_base_meta_id
(
fd
);
if
((
long
)
rom
==
-
1
)
{
if
(
app
)
fputs
(
"Failed while reading SPEC FPGA ROM
\n
"
,
stderr
);
err
=
print_app_meta_id
(
fd
);
}
else
{
fprintf
(
stdout
,
"vendor : 0x%08x
\n
"
,
rom
->
vendor
);
fprintf
(
stdout
,
"device : 0x%08x
\n
"
,
rom
->
device
);
fprintf
(
stdout
,
"version : %u.%u.%u
\n
"
,
SPEC_META_VERSION_MAJ
(
rom
->
version
),
SPEC_META_VERSION_MIN
(
rom
->
version
),
SPEC_META_VERSION_PATCH
(
rom
->
version
));
if
((
rom
->
bom
&
SPEC_META_BOM_END_MASK
)
==
SPEC_META_BOM_LE
)
fputs
(
"byte-order : little-endian
\n
"
,
stdout
);
else
fputs
(
"byte-order : wrong or unknown
\n
"
,
stdout
);
fprintf
(
stdout
,
"sources : %08x%08x%08x%08x
\n
"
,
rom
->
src
[
0
],
rom
->
src
[
1
],
rom
->
src
[
2
],
rom
->
src
[
3
]);
fprintf
(
stdout
,
"capabilities : 0x%08x
\n
"
,
rom
->
vendor
);
fprintf
(
stdout
,
"UUID : %08x%08x%08x%08x
\n
"
,
rom
->
uuid
[
0
],
rom
->
uuid
[
1
],
rom
->
uuid
[
2
],
rom
->
uuid
[
3
]);
}
munmap
(
rom
,
sizeof
(
*
rom
));
close
(
fd
);
close
(
fd
);
exit
(
err
?
EXIT_FAILURE
:
EXIT_SUCCESS
);
exit
(
err
?
EXIT_FAILURE
:
EXIT_SUCCESS
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment