Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
osv
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Verlässliche Systemsoftware
projects
osv
Commits
8a7d7f35
Commit
8a7d7f35
authored
12 years ago
by
Dor Laor
Browse files
Options
Downloads
Patches
Plain Diff
Read the entire virtio-config from the pci space
parent
64859d6d
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
drivers/virtio-blk.cc
+30
-4
30 additions, 4 deletions
drivers/virtio-blk.cc
drivers/virtio-blk.hh
+1
-0
1 addition, 0 deletions
drivers/virtio-blk.hh
with
31 additions
and
4 deletions
drivers/virtio-blk.cc
+
30
−
4
View file @
8a7d7f35
...
...
@@ -106,10 +106,7 @@ struct driver virtio_blk_driver = {
{
virtio_driver
::
load
();
_dev
->
virtio_conf_read
(
offsetof
(
struct
virtio_blk_config
,
capacity
)
+
VIRTIO_PCI_CONFIG
(
_dev
),
&
_config
.
capacity
,
sizeof
(
_config
.
capacity
));
virtio_i
(
fmt
(
"capacity of the device is %x"
)
%
(
u64
)
_config
.
capacity
);
read_config
();
_dev
->
add_dev_status
(
VIRTIO_CONFIG_S_DRIVER_OK
);
...
...
@@ -148,6 +145,35 @@ struct driver virtio_blk_driver = {
return
(
true
);
}
bool
virtio_blk
::
read_config
()
{
//read all of the block config (including size, mce, topology,..) in one shot
_dev
->
virtio_conf_read
(
_dev
->
virtio_pci_config_offset
(),
&
_config
,
sizeof
(
_config
));
virtio_i
(
fmt
(
"The capacity of the device is %d"
)
%
(
u64
)
_config
.
capacity
);
if
(
_dev
->
get_guest_feature_bit
(
VIRTIO_BLK_F_SIZE_MAX
))
virtio_i
(
fmt
(
"The size_max of the device is %d"
)
%
(
u32
)
_config
.
size_max
);
if
(
_dev
->
get_guest_feature_bit
(
VIRTIO_BLK_F_SEG_MAX
))
virtio_i
(
fmt
(
"The seg_size of the device is %d"
)
%
(
u32
)
_config
.
seg_max
);
if
(
_dev
->
get_guest_feature_bit
(
VIRTIO_BLK_F_GEOMETRY
))
{
virtio_i
(
fmt
(
"The cylinders count of the device is %d"
)
%
(
u16
)
_config
.
geometry
.
cylinders
);
virtio_i
(
fmt
(
"The heads count of the device is %d"
)
%
(
u32
)
_config
.
geometry
.
heads
);
virtio_i
(
fmt
(
"The sector count of the device is %d"
)
%
(
u32
)
_config
.
geometry
.
sectors
);
}
if
(
_dev
->
get_guest_feature_bit
(
VIRTIO_BLK_F_BLK_SIZE
))
virtio_i
(
fmt
(
"The block size of the device is %d"
)
%
(
u32
)
_config
.
blk_size
);
if
(
_dev
->
get_guest_feature_bit
(
VIRTIO_BLK_F_TOPOLOGY
))
{
virtio_i
(
fmt
(
"The physical_block_exp of the device is %d"
)
%
(
u32
)
_config
.
physical_block_exp
);
virtio_i
(
fmt
(
"The alignment_offset of the device is %d"
)
%
(
u32
)
_config
.
alignment_offset
);
virtio_i
(
fmt
(
"The min_io_size of the device is %d"
)
%
(
u16
)
_config
.
min_io_size
);
virtio_i
(
fmt
(
"The opt_io_size of the device is %d"
)
%
(
u32
)
_config
.
opt_io_size
);
}
if
(
_dev
->
get_guest_feature_bit
(
VIRTIO_BLK_F_CONFIG_WCE
))
virtio_i
(
fmt
(
"The write cache enable of the device is %d"
)
%
(
u32
)
_config
.
wce
);
return
true
;
}
//temporal hack for the local version of virtio tests
extern
"C"
{
static
void
blk_bio_done
(
struct
bio
*
bio
)
{
...
...
This diff is collapsed.
Click to expand it.
drivers/virtio-blk.hh
+
1
−
0
View file @
8a7d7f35
...
...
@@ -156,6 +156,7 @@ namespace virtio {
virtual
const
std
::
string
get_name
(
void
)
{
return
_driver_name
;
}
virtual
bool
load
(
void
);
virtual
bool
unload
(
void
);
bool
read_config
();
virtual
u32
get_driver_features
(
void
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment