Skip to content

Commit b640415

Browse files
committed
[cru] Add Register Sequence service for UL configuration
1 parent ab46f2e commit b640415

File tree

6 files changed

+36
-58
lines changed

6 files changed

+36
-58
lines changed

README.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -61,25 +61,28 @@ The services are DIM RPC services. Every RPC is called with a string and expects
6161
* Lines prefixed with `#` are disregarded as comments.
6262

6363
#### CRU
64-
##### REGISTER_READ
65-
* Parameter:
66-
* Register address
67-
* Returns:
68-
* Register value
64+
##### REGISTER_SEQUENCE
65+
* Parameters:
66+
* Operations may be:
67+
* `write` with address and value (e.g. `0x0000f00d,0x0000beef`)
68+
* `read` with address (e.g `0x0000cafe`)
6969

70+
* Returns:
71+
* `write` always retuns `0`
72+
* `read` returns the value read from the register
73+
7074
* Example:
71-
* DIM input: `0x0000f00d`
72-
* DIM output: `0x0000beef`
73-
75+
* DIM input `0xc00004\n0x00c00008, 0x0000beef\n0x00c00008`
76+
* DIM output `0xcafe\n0\n0xbeef\n`
7477
##### REGISTER_WRITE
7578
* Parameters:
76-
* Register address
79+
* Register address (within the range [`0x00c00000-0x00cfffff`])
7780
* Register value
7881
* Returns:
7982
* empty
8083

8184
* Example:
82-
* DIM input: `0x0000f00d,0x0000beef`
85+
* DIM input: `0x00c0f00d,0x0000beef`
8386
* DIM output: ` `
8487

8588
##### SCA_SEQUENCE

apps/AlfClient.cxx

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ class AlfClient : public AliceO2::Common::Program
138138
}
139139

140140
// Only CRU from this point forward
141-
RegisterReadRpc registerReadRpc(names.registerRead());
142-
RegisterWriteRpc registerWriteRpc(names.registerWrite());
141+
RegisterSequenceRpc registerSequence(names.registerSequence());
143142
PatternPlayerRpc patternPlayerRpc(names.patternPlayer());
144143
LlaSessionStartRpc llaSessionStartRpc(names.llaSessionStart());
145144
LlaSessionStopRpc llaSessionStopRpc(names.llaSessionStop());
@@ -149,13 +148,15 @@ class AlfClient : public AliceO2::Common::Program
149148
IcSequenceRpc icSequence(names.icSequence());
150149
IcGbtI2cWriteRpc icGbtI2cWriteRpc(names.icGbtI2cWrite());
151150

152-
// Test register write and read
153-
uint32_t wAddress = 0x00f00078;
154-
uint32_t wValue = 0x4;
155-
uint32_t rAddress = 0x00f0005c;
156-
registerWriteRpc.writeRegister(wAddress, wValue);
157-
uint32_t rValue = registerReadRpc.readRegister(rAddress);
158-
std::cout << "[REGISTER] Wrote: " << Util::formatValue(wValue) << " Read: " << Util::formatValue(rValue) << std::endl;
151+
// Test register sequence
152+
auto regOut = registerSequence.write({ std::make_pair("0x00c00000", ""),
153+
std::make_pair("0x00c00004", ""),
154+
std::make_pair("0x00c00008", ""),
155+
std::make_pair("0x00cfffff", "0x00080000"),
156+
std::make_pair("0x00c00004", "0x00080000"),
157+
std::make_pair("0x00c00004", ""),
158+
std::make_pair("0x0badadd7", "") });
159+
std::cout << "[REGISTER SEQUENCE] output: " << regOut << std::endl;
159160

160161
if (mOptions.swt) {
161162
auto swtOut = swtSequence.write({ std::make_pair("", "lock"),

src/AlfServer.cxx

Lines changed: 12 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -32,32 +32,7 @@ AlfServer::AlfServer() : mRpcServers()
3232
{
3333
}
3434

35-
std::string AlfServer::registerRead(const std::string& parameter, std::shared_ptr<roc::BarInterface> bar)
36-
{
37-
uint32_t address = Util::stringToHex(parameter); // Error from here will get picked up by the StringRpcServer try clause
38-
//Util::checkAddress(address);
39-
40-
uint32_t value = bar->readRegister(address / 4);
41-
return Util::formatValue(value);
42-
}
43-
44-
std::string AlfServer::registerWrite(const std::string& parameter, std::shared_ptr<roc::BarInterface> bar)
45-
{
46-
std::vector<std::string> params = Util::split(parameter, pairSeparator());
47-
48-
if (params.size() != 2) {
49-
BOOST_THROW_EXCEPTION(AlfException() << ErrorInfo::Message("Wrong number of parameters for RPC write call"));
50-
}
51-
52-
uint32_t address = Util::stringToHex(params[0]);
53-
//Util::checkAddress(address);
54-
uint32_t value = Util::stringToHex(params[1]);
55-
56-
bar->writeRegister(address / 4, value);
57-
return "";
58-
}
59-
60-
std::string AlfServer::registerBlobWrite(const std::string& parameter, AlfLink link)
35+
std::string AlfServer::registerBlobWrite(const std::string& parameter, AlfLink link, bool isCru)
6136
{
6237
std::vector<std::string> stringPairs = Util::split(parameter, argumentSeparator());
6338
std::vector<std::vector<uint32_t>> registerPairs = parseStringToRegisterPairs(stringPairs);
@@ -66,6 +41,14 @@ std::string AlfServer::registerBlobWrite(const std::string& parameter, AlfLink l
6641
uint32_t address;
6742
for (const auto& registerPair : registerPairs) {
6843
address = registerPair.at(0);
44+
// If it's a CRU, check address range
45+
if (isCru && (address < 0x00c00000 || address > 0x00cfffff)) {
46+
resultBuffer << "Illegal address 0x" << std::hex << address
47+
<< ", allowed: [0x00c0_0000-0x00cf_ffff]"
48+
<< "\n";
49+
BOOST_THROW_EXCEPTION(AlfException() << ErrorInfo::Message(resultBuffer.str()));
50+
}
51+
6952
if (registerPair.size() == 1) {
7053
value = link.bar->readRegister(address / 4);
7154
resultBuffer << Util::formatValue(value) << "\n";
@@ -588,13 +571,10 @@ void AlfServer::makeRpcServers(std::vector<AlfLink> links)
588571
}
589572

590573
if (link.linkId == 0 && link.serialId.getEndpoint() == 0) { // Services per card
591-
// Register Read
592-
servers.push_back(makeServer(names.registerRead(),
593-
[bar](auto parameter) { return registerRead(parameter, bar); }));
594-
// Register Write
595-
servers.push_back(makeServer(names.registerWrite(),
596-
[bar](auto parameter) { return registerWrite(parameter, bar); }));
597574

575+
// Register Sequence
576+
servers.push_back(makeServer(names.registerSequence(),
577+
[link](auto parameter) { return registerBlobWrite(parameter, link, true); }));
598578
// Pattern Player
599579
servers.push_back(makeServer(names.patternPlayer(),
600580
[bar](auto parameter) { return patternPlayer(parameter, bar); }));

src/AlfServer.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,13 @@ class AlfServer
4949
void makeRpcServers(std::vector<AlfLink> links);
5050

5151
private:
52-
static std::string registerRead(const std::string& parameter, std::shared_ptr<roc::BarInterface>);
53-
static std::string registerWrite(const std::string& parameter, std::shared_ptr<roc::BarInterface>);
5452
std::string scaBlobWrite(const std::string& parameter, AlfLink link);
5553
std::string scaMftPsuBlobWrite(const std::string& parameter, AlfLink link);
5654
std::string swtBlobWrite(const std::string& parameter, AlfLink link);
5755
std::string icBlobWrite(const std::string& parameter, AlfLink link);
5856
std::string icGbtI2cWrite(const std::string& parameter, AlfLink link);
5957
static std::string patternPlayer(const std::string& parameter, std::shared_ptr<roc::BarInterface>);
60-
static std::string registerBlobWrite(const std::string& parameter, AlfLink link);
58+
static std::string registerBlobWrite(const std::string& parameter, AlfLink link, bool isCru = false);
6159
std::string llaSessionStart(const std::string& parameter, roc::SerialId serialId);
6260
std::string llaSessionStop(const std::string& parameter, roc::SerialId serialId);
6361

src/DimServices/ServiceNames.cxx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ namespace alf
3838
DEFCARDSERVICENAME(patternPlayer, "PATTERN_PLAYER")
3939
DEFCARDSERVICENAME(llaSessionStart, "LLA_SESSION_START")
4040
DEFCARDSERVICENAME(llaSessionStop, "LLA_SESSION_STOP")
41-
DEFCARDSERVICENAME(registerRead, "REGISTER_READ")
42-
DEFCARDSERVICENAME(registerWrite, "REGISTER_WRITE")
4341

4442
DEFLINKSERVICENAME(scaSequence, "SCA_SEQUENCE")
4543
DEFLINKSERVICENAME(scaMftPsuSequence, "SCA_MFT_PSU_SEQUENCE")

src/DimServices/ServiceNames.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ class ServiceNames
3333
{
3434
}
3535

36-
std::string registerRead() const;
37-
std::string registerWrite() const;
3836
std::string scaSequence() const;
3937
std::string scaMftPsuSequence() const;
4038
std::string swtSequence() const;

0 commit comments

Comments
 (0)