Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
S
Software for White Rabbit PTP Core
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
32
Issues
32
List
Board
Labels
Milestones
Merge Requests
4
Merge Requests
4
CI / CD
CI / CD
Pipelines
Schedules
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
Software for White Rabbit PTP Core
Commits
d8d04504
Commit
d8d04504
authored
May 06, 2013
by
Alessandro Rubini
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
tools/wrpc-uart-sw: support old spec identifiers too
Signed-off-by:
Alessandro Rubini
<
rubini@gnudd.com
>
parent
ecb40265
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
16 deletions
+24
-16
wrpc-uart-sw.c
tools/wrpc-uart-sw.c
+24
-16
No files found.
tools/wrpc-uart-sw.c
View file @
d8d04504
...
...
@@ -28,8 +28,6 @@
/*
* The following parameters match the spec, but can be changed on env/cmdline
*/
#define DEFAULT_VENDOR 0x10dc
/* CERN */
#define DEFAULT_DEVICE 0x018d
/* SPEC */
#define DEFAULT_BUS -1
/* all */
#define DEFAULT_BAR 0
/* first bar */
#define DEFAULT_RAMADDR 0
/* beginning */
...
...
@@ -37,6 +35,15 @@
#define MAX_DEVICES 8
/* no alloc, me lazy */
static
struct
usw_pci_id
{
unsigned
pci_v
;
unsigned
pci_d
;
}
spec_devices
[]
=
{
{
0x10dc
/* CERN */
,
0x018d
/* SPEC */
},
{
0x1a39
/* Gennum */
,
0x0004
/* GN4124 */
},
{
0
,
},
};
struct
usw_device
{
void
*
mapaddr
;
int
mapsize
;
...
...
@@ -118,13 +125,14 @@ static int usw_access_pci(char *name, int index)
/* Scan PCI space for vendor and device; return number of successes */
static
int
usw_scan_pci
(
int
vendor
,
int
device
,
struct
usw_device
*
arr
,
static
int
usw_scan_pci
(
struct
usw_pci_id
*
id
,
struct
usw_device
*
arr
,
int
alen
)
{
char
path
[
PATH_MAX
];
FILE
*
f
;
struct
dirent
**
namelist
;
int
i
,
n
,
val
,
ndevs
;
int
i
,
j
,
n
,
ndevs
;
unsigned
v
,
d
;
n
=
scandir
(
"/sys/bus/pci/devices"
,
&
namelist
,
0
,
0
);
if
(
n
<
0
)
{
...
...
@@ -145,11 +153,9 @@ static int usw_scan_pci(int vendor, int device, struct usw_device *arr,
strerror
(
errno
));
continue
;
}
if
(
fscanf
(
f
,
"%i"
,
&
v
al
)
!=
1
)
if
(
fscanf
(
f
,
"%i"
,
&
v
)
!=
1
)
continue
;
fclose
(
f
);
if
(
val
!=
vendor
)
continue
;
/* check device */
sprintf
(
path
,
"/sys/bus/pci/devices/%s/device"
,
...
...
@@ -160,15 +166,19 @@ static int usw_scan_pci(int vendor, int device, struct usw_device *arr,
strerror
(
errno
));
continue
;
}
if
(
fscanf
(
f
,
"%i"
,
&
val
)
!=
1
)
if
(
fscanf
(
f
,
"%i"
,
&
d
)
!=
1
)
continue
;
fclose
(
f
);
if
(
val
!=
device
)
continue
;
for
(
j
=
0
;
id
[
j
].
pci_v
;
j
++
)
if
(
id
[
j
].
pci_v
==
v
&&
id
[
j
].
pci_d
==
d
)
break
;
if
(
!
spec_devices
[
j
].
pci_v
)
continue
;
/* not found in whole array */
/* Ok, so this is ours. Celebrate, and open it */
fprintf
(
stderr
,
"%s: found device %s
\n
"
,
prgname
,
namelist
[
i
]
->
d_name
);
fprintf
(
stderr
,
"%s: found device %
04x:%04x: %
s
\n
"
,
prgname
,
v
,
d
,
namelist
[
i
]
->
d_name
);
if
(
ndevs
==
alen
)
{
fprintf
(
stderr
,
"%s: array overflow, ignoring card
\n
"
,
...
...
@@ -249,11 +259,9 @@ int main(int argc, char **argv)
/* FIXME: parse commandline arguments */
ndev
=
usw_scan_pci
(
DEFAULT_VENDOR
,
DEFAULT_DEVICE
,
devs
,
MAX_DEVICES
);
ndev
=
usw_scan_pci
(
spec_devices
,
devs
,
MAX_DEVICES
);
if
(
ndev
<
1
)
{
fprintf
(
stderr
,
"%s: no %04x:%04x devices on PCI
\n
"
,
argv
[
0
],
DEFAULT_VENDOR
,
DEFAULT_DEVICE
);
fprintf
(
stderr
,
"%s: no suitable PCI devices
\n
"
,
argv
[
0
]);
exit
(
1
);
}
...
...
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