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
e2595249
Commit
e2595249
authored
12 years ago
by
Guy Zana
Browse files
Options
Downloads
Patches
Plain Diff
Now able to register to devices with the same device_id
parent
204b09eb
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/device.cc
+16
-9
16 additions, 9 deletions
drivers/device.cc
drivers/device.hh
+3
-2
3 additions, 2 deletions
drivers/device.hh
with
19 additions
and
11 deletions
drivers/device.cc
+
16
−
9
View file @
e2595249
...
@@ -22,22 +22,29 @@ namespace hw {
...
@@ -22,22 +22,29 @@ namespace hw {
bool
device_manager
::
register_device
(
hw_device
*
dev
)
bool
device_manager
::
register_device
(
hw_device
*
dev
)
{
{
if
(
get_device
(
dev
->
get_id
())
!=
nullptr
)
{
return
(
false
);
}
_devices
.
insert
(
std
::
make_pair
(
dev
->
get_id
(),
dev
));
_devices
.
insert
(
std
::
make_pair
(
dev
->
get_id
(),
dev
));
return
(
true
);
return
(
true
);
}
}
hw_device
*
device_manager
::
get_device
(
hw_device_id
id
)
hw_device
*
device_manager
::
get_device
(
hw_device_id
id
,
unsigned
idx
)
{
{
auto
it
=
_devices
.
find
(
id
);
auto
ppp
=
_devices
.
equal_range
(
id
);
if
(
it
==
_devices
.
end
())
{
return
(
nullptr
);
unsigned
cnt
=
0
;
for
(
auto
it
=
ppp
.
first
;
it
!=
ppp
.
second
;
++
it
)
{
if
(
cnt
==
idx
)
{
return
((
*
it
).
second
);
}
cnt
++
;
}
}
return
(
it
->
second
);
return
(
nullptr
);
}
unsigned
device_manager
::
get_num_devices
(
hw_device_id
id
)
{
return
_devices
.
count
(
id
);
}
}
void
device_manager
::
list_devices
(
void
)
void
device_manager
::
list_devices
(
void
)
...
...
This diff is collapsed.
Click to expand it.
drivers/device.hh
+
3
−
2
View file @
e2595249
...
@@ -60,7 +60,8 @@ namespace hw {
...
@@ -60,7 +60,8 @@ namespace hw {
bool
register_device
(
hw_device
*
dev
);
bool
register_device
(
hw_device
*
dev
);
// Retrieves from dictionary
// Retrieves from dictionary
hw_device
*
get_device
(
hw_device_id
id
);
hw_device
*
get_device
(
hw_device_id
id
,
unsigned
idx
=
0
);
unsigned
get_num_devices
(
hw_device_id
id
);
// System wide operations
// System wide operations
void
list_devices
(
void
);
void
list_devices
(
void
);
...
@@ -68,7 +69,7 @@ namespace hw {
...
@@ -68,7 +69,7 @@ namespace hw {
private
:
private
:
static
device_manager
*
_instance
;
static
device_manager
*
_instance
;
std
::
map
<
hw_device_id
,
hw_device
*>
_devices
;
std
::
multi
map
<
hw_device_id
,
hw_device
*>
_devices
;
};
};
}
}
...
...
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