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
ae5470f8
Commit
ae5470f8
authored
12 years ago
by
Avi Kivity
Browse files
Options
Downloads
Patches
Plain Diff
virtio-driver: unindent
parent
b4f9d646
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
drivers/virtio.cc
+44
-46
44 additions, 46 deletions
drivers/virtio.cc
drivers/virtio.hh
+17
-17
17 additions, 17 deletions
drivers/virtio.hh
with
61 additions
and
63 deletions
drivers/virtio.cc
+
44
−
46
View file @
ae5470f8
...
...
@@ -9,67 +9,65 @@ using namespace pci;
namespace
virtio
{
virtio_driver
::
virtio_driver
(
virtio_device
*
vdev
)
:
hw_driver
()
,
_dev
(
vdev
)
,
_msi
(
&
vdev
->
pci_device
())
{
_dev
->
pci_device
().
set_bus_master
(
true
);
virtio_driver
::
virtio_driver
(
virtio_device
*
vdev
)
:
hw_driver
()
,
_dev
(
vdev
)
,
_msi
(
&
vdev
->
pci_device
())
{
_dev
->
pci_device
().
set_bus_master
(
true
);
_dev
->
pci_device
().
msix_enable
();
_dev
->
pci_device
().
msix_enable
();
//make sure the queue is reset
_dev
->
reset_host_side
();
//make sure the queue is reset
_dev
->
reset_host_side
();
// Acknowledge device
_dev
->
add_dev_status
(
VIRTIO_CONFIG_S_ACKNOWLEDGE
|
VIRTIO_CONFIG_S_DRIVER
);
// Acknowledge device
_dev
->
add_dev_status
(
VIRTIO_CONFIG_S_ACKNOWLEDGE
|
VIRTIO_CONFIG_S_DRIVER
);
// Generic init of virtqueues
_dev
->
probe_virt_queues
();
// Generic init of virtqueues
_dev
->
probe_virt_queues
();
setup_features
();
}
virtio_driver
::~
virtio_driver
()
{
_dev
->
reset_host_side
();
_dev
->
free_queues
();
}
bool
virtio_driver
::
setup_features
(
void
)
{
u32
dev_features
=
_dev
->
get_device_features
();
u32
drv_features
=
this
->
get_driver_features
();
setup_features
();
}
u32
subset
=
dev_features
&
drv_features
;
virtio_driver
::~
virtio_driver
()
{
_dev
->
reset_host_side
();
_dev
->
free_queues
();
}
//notify the host about the features in used according
//to the virtio spec
for
(
int
i
=
0
;
i
<
32
;
i
++
)
if
(
subset
&
(
1
<<
i
))
virtio_d
(
fmt
(
"%s: found feature intersec of bit %d"
)
%
__FUNCTION__
%
i
);
bool
virtio_driver
::
setup_features
(
void
)
{
u32
dev_features
=
_dev
->
get_device_features
();
u32
drv_features
=
this
->
get_driver_features
();
if
(
subset
&
(
1
<<
VIRTIO_RING_F_INDIRECT_DESC
))
_dev
->
set_indirect_buf_cap
(
true
);
u32
subset
=
dev_features
&
drv_features
;
_dev
->
set_guest_features
(
subset
);
//notify the host about the features in used according
//to the virtio spec
for
(
int
i
=
0
;
i
<
32
;
i
++
)
if
(
subset
&
(
1
<<
i
))
virtio_d
(
fmt
(
"%s: found feature intersec of bit %d"
)
%
__FUNCTION__
%
i
);
return
(
subset
!=
0
);
if
(
subset
&
(
1
<<
VIRTIO_RING_F_INDIRECT_DESC
))
_dev
->
set_indirect_buf_cap
(
true
);
}
_dev
->
set_guest_features
(
subset
);
void
virtio_driver
::
dump_config
()
{
u8
B
,
D
,
F
;
_dev
->
pci_device
().
get_bdf
(
B
,
D
,
F
);
return
(
subset
!=
0
);
virtio_d
(
fmt
(
"%s [%x:%x.%x] vid:id= %x:%x"
)
%
get_name
()
%
(
u16
)
B
%
(
u16
)
D
%
(
u16
)
F
%
_dev
->
pci_device
().
get_vendor_id
()
%
_dev
->
pci_device
().
get_device_id
());
}
}
void
virtio_driver
::
dump_config
()
{
u8
B
,
D
,
F
;
_dev
->
pci_device
().
get_bdf
(
B
,
D
,
F
);
virtio_d
(
fmt
(
"%s [%x:%x.%x] vid:id= %x:%x"
)
%
get_name
()
%
(
u16
)
B
%
(
u16
)
D
%
(
u16
)
F
%
_dev
->
pci_device
().
get_vendor_id
()
%
_dev
->
pci_device
().
get_device_id
());
}
}
This diff is collapsed.
Click to expand it.
drivers/virtio.hh
+
17
−
17
View file @
ae5470f8
...
...
@@ -7,28 +7,28 @@
namespace
virtio
{
class
virtio_driver
:
public
hw_driver
{
public:
explicit
virtio_driver
(
virtio_device
*
vdev
);
virtual
~
virtio_driver
();
class
virtio_driver
:
public
hw_driver
{
public:
explicit
virtio_driver
(
virtio_device
*
vdev
);
virtual
~
virtio_driver
();
virtual
const
std
::
string
get_name
(
void
)
=
0
;
virtual
const
std
::
string
get_name
(
void
)
=
0
;
virtual
void
dump_config
(
void
);
virtual
void
dump_config
(
void
);
protected:
// Actual drivers should implement this on top of the basic ring features
virtual
u32
get_driver_features
(
void
)
{
return
(
1
<<
VIRTIO_RING_F_INDIRECT_DESC
);
}
bool
setup_features
(
void
);
protected:
// Actual drivers should implement this on top of the basic ring features
virtual
u32
get_driver_features
(
void
)
{
return
(
1
<<
VIRTIO_RING_F_INDIRECT_DESC
);
}
bool
setup_features
(
void
);
///////////////////
// Device access //
///////////////////
///////////////////
// Device access //
///////////////////
// Virtio device
virtio_device
*
_dev
;
interrupt_manager
_msi
;
};
// Virtio device
virtio_device
*
_dev
;
interrupt_manager
_msi
;
};
}
...
...
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