Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
drivers
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MLA98
drivers
Commits
c11736f7
Unverified
Commit
c11736f7
authored
Dec 06, 2017
by
Jeremy Soller
Committed by
GitHub
Dec 06, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #21 from ghatdev/master
pcid: fix error E0133
parents
b7fe49cc
dd5f83cd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
31 deletions
+39
-31
pcid/src/main.rs
pcid/src/main.rs
+38
-30
pcid/src/pci/header.rs
pcid/src/pci/header.rs
+1
-1
No files found.
pcid/src/main.rs
View file @
c11736f7
...
...
@@ -41,11 +41,13 @@ fn main() {
if
let
Some
(
header
)
=
func
.header
()
{
let
pci_class
=
PciClass
::
from
(
header
.class
);
let
mut
string
=
format!
(
"PCI {:>02X}/{:>02X}/{:>02X} {:>04X}:{:>04X} {:>02X}.{:>02X}.{:>02X}.{:>02X} {:?}"
,
bus
.num
,
dev
.num
,
func
.num
,
header
.vendor_id
,
header
.device_id
,
header
.class
,
header
.subclass
,
header
.interface
,
header
.revision
,
pci_class
);
let
mut
string
=
unsafe
{
format!
(
"PCI {:>02X}/{:>02X}/{:>02X} {:>04X}:{:>04X} {:>02X}.{:>02X}.{:>02X}.{:>02X} {:?}"
,
bus
.num
,
dev
.num
,
func
.num
,
header
.vendor_id
,
header
.device_id
,
header
.class
,
header
.subclass
,
header
.interface
,
header
.revision
,
pci_class
)
};
match
pci_class
{
PciClass
::
Storage
=>
match
header
.subclass
{
...
...
@@ -78,14 +80,16 @@ fn main() {
_
=>
()
}
for
i
in
0
..
header
.bars
.len
()
{
match
PciBar
::
from
(
header
.bars
[
i
])
{
PciBar
::
None
=>
(),
PciBar
::
Memory
(
address
)
=>
string
.push_str
(
&
format!
(
" {}={:>08X}"
,
i
,
address
)),
PciBar
::
Port
(
address
)
=>
string
.push_str
(
&
format!
(
" {}={:>04X}"
,
i
,
address
))
unsafe
{
for
i
in
0
..
header
.bars
.len
()
{
match
PciBar
::
from
(
header
.bars
[
i
])
{
PciBar
::
None
=>
(),
PciBar
::
Memory
(
address
)
=>
string
.push_str
(
&
format!
(
" {}={:>08X}"
,
i
,
address
)),
PciBar
::
Port
(
address
)
=>
string
.push_str
(
&
format!
(
" {}={:>04X}"
,
i
,
address
))
}
}
}
string
.push
(
'\n'
);
print!
(
"{}"
,
string
);
...
...
@@ -124,27 +128,31 @@ fn main() {
let
mut
command
=
Command
::
new
(
program
);
for
arg
in
args
{
let
bar_arg
=
|
i
|
->
String
{
match
PciBar
::
from
(
header
.bars
[
i
])
{
PciBar
::
None
=>
String
::
new
(),
PciBar
::
Memory
(
address
)
=>
format!
(
"{:>08X}"
,
address
),
PciBar
::
Port
(
address
)
=>
format!
(
"{:>04X}"
,
address
)
unsafe
{
match
PciBar
::
from
(
header
.bars
[
i
])
{
PciBar
::
None
=>
String
::
new
(),
PciBar
::
Memory
(
address
)
=>
format!
(
"{:>08X}"
,
address
),
PciBar
::
Port
(
address
)
=>
format!
(
"{:>04X}"
,
address
)
}
}
};
let
arg
=
match
arg
.as_str
()
{
"$BUS"
=>
format!
(
"{:>02X}"
,
bus
.num
),
"$DEV"
=>
format!
(
"{:>02X}"
,
dev
.num
),
"$FUNC"
=>
format!
(
"{:>02X}"
,
func
.num
),
"$NAME"
=>
format!
(
"pci-{:>02X}.{:>02X}.{:>02X}"
,
bus
.num
,
dev
.num
,
func
.num
),
"$BAR0"
=>
bar_arg
(
0
),
"$BAR1"
=>
bar_arg
(
1
),
"$BAR2"
=>
bar_arg
(
2
),
"$BAR3"
=>
bar_arg
(
3
),
"$BAR4"
=>
bar_arg
(
4
),
"$BAR5"
=>
bar_arg
(
5
),
"$IRQ"
=>
format!
(
"{}"
,
header
.interrupt_line
),
"$VENID"
=>
format!
(
"{:>04X}"
,
header
.vendor_id
),
"$DEVID"
=>
format!
(
"{:>04X}"
,
header
.device_id
),
_
=>
arg
.clone
()
let
arg
=
unsafe
{
match
arg
.as_str
()
{
"$BUS"
=>
format!
(
"{:>02X}"
,
bus
.num
),
"$DEV"
=>
format!
(
"{:>02X}"
,
dev
.num
),
"$FUNC"
=>
format!
(
"{:>02X}"
,
func
.num
),
"$NAME"
=>
format!
(
"pci-{:>02X}.{:>02X}.{:>02X}"
,
bus
.num
,
dev
.num
,
func
.num
),
"$BAR0"
=>
bar_arg
(
0
),
"$BAR1"
=>
bar_arg
(
1
),
"$BAR2"
=>
bar_arg
(
2
),
"$BAR3"
=>
bar_arg
(
3
),
"$BAR4"
=>
bar_arg
(
4
),
"$BAR5"
=>
bar_arg
(
5
),
"$IRQ"
=>
format!
(
"{}"
,
header
.interrupt_line
),
"$VENID"
=>
format!
(
"{:>04X}"
,
header
.vendor_id
),
"$DEVID"
=>
format!
(
"{:>04X}"
,
header
.device_id
),
_
=>
arg
.clone
()
}
};
command
.arg
(
&
arg
);
}
...
...
pcid/src/pci/header.rs
View file @
c11736f7
use
std
::
ops
::{
Deref
,
DerefMut
};
use
std
::{
slice
,
mem
};
#[derive(De
bug,
De
fault)]
#[derive(Default)]
#[repr(packed)]
pub
struct
PciHeader
{
pub
vendor_id
:
u16
,
...
...
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