-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathCardInfo.cpp
73 lines (59 loc) · 2.13 KB
/
CardInfo.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include "CardInfo.h"
// utility function to map card name to cardtype index
IoCard::card_t
CardInfo::getCardTypeFromName(const std::string &name)
{
for (auto &ct : IoCard::card_types) {
std::unique_ptr<IoCard> tmp_card(IoCard::makeTmpCard(ct));
assert(tmp_card != nullptr);
std::string this_name = tmp_card->getName();
if (name == this_name) {
return ct;
}
}
return IoCard::card_t::none;
}
// return the name of the card type, eg, "2711b"
std::string
CardInfo::getCardName(IoCard::card_t cardtype)
{
assert(cardtype == IoCard::card_t::none || IoCard::legalCardType(cardtype));
std::unique_ptr<IoCard> tmp_card(IoCard::makeTmpCard(cardtype));
std::string name = tmp_card->getName();
return name;
}
// return the description of the card type, eg, "64x16 CRT controller"
std::string
CardInfo::getCardDesc(IoCard::card_t cardtype)
{
assert(cardtype == IoCard::card_t::none || IoCard::legalCardType(cardtype));
std::unique_ptr<IoCard> tmp_card(IoCard::makeTmpCard(cardtype));
std::string desc = tmp_card->getDescription();
return desc;
}
// return a list of the base addresses the card type can be mapped to
std::vector<int>
CardInfo::getCardBaseAddresses(IoCard::card_t cardtype)
{
assert(cardtype == IoCard::card_t::none || IoCard::legalCardType(cardtype));
std::unique_ptr<IoCard> tmp_card(IoCard::makeTmpCard(cardtype));
std::vector<int> addresses(tmp_card->getBaseAddresses());
return addresses;
}
// is card configurable?
bool
CardInfo::isCardConfigurable(IoCard::card_t cardtype)
{
assert(cardtype == IoCard::card_t::none || IoCard::legalCardType(cardtype));
std::unique_ptr<IoCard> tmp_card(IoCard::makeTmpCard(cardtype));
return tmp_card->isConfigurable();
}
// retrieve a pointer to a CardCfgState specific to a given kind of card
std::shared_ptr<CardCfgState>
CardInfo::getCardCfgState(IoCard::card_t cardtype)
{
assert(cardtype == IoCard::card_t::none || IoCard::legalCardType(cardtype));
std::unique_ptr<IoCard> tmp_card(IoCard::makeTmpCard(cardtype));
return tmp_card->getCfgState();
}
// vim: ts=8:et:sw=4:smarttab