PDEC evil fix
This commit is contained in:
parent
f7e59edaf2
commit
557fe5a9a2
@ -132,6 +132,7 @@ ReturnValue_t PdecHandler::polledOperation() {
|
|||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// See https://yurovsky.github.io/2014/10/10/linux-uio-gpio-interrupt.html for more information.
|
||||||
ReturnValue_t PdecHandler::irqOperation() {
|
ReturnValue_t PdecHandler::irqOperation() {
|
||||||
ReturnValue_t result = returnvalue::OK;
|
ReturnValue_t result = returnvalue::OK;
|
||||||
int fd = open(uioNames.irq, O_RDWR);
|
int fd = open(uioNames.irq, O_RDWR);
|
||||||
@ -141,15 +142,17 @@ ReturnValue_t PdecHandler::irqOperation() {
|
|||||||
return returnvalue::FAILED;
|
return returnvalue::FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
struct pollfd fds = {.fd = fd, .events = POLLIN, .revents = 0};
|
|
||||||
// Used to unmask IRQ
|
// Used to unmask IRQ
|
||||||
uint32_t info = 1;
|
uint32_t info = 1;
|
||||||
ssize_t nb = 0;
|
ssize_t nb = 0;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
// Clear interrupts with dummy read before unmasking the interrupt
|
// Clear interrupts with dummy read before unmasking the interrupt. Use a volatile to prevent
|
||||||
ret = *(registerBaseAddress + PDEC_PIR_OFFSET);
|
// read being optimized away.
|
||||||
|
volatile uint32_t dummy = *(registerBaseAddress + PDEC_PIR_OFFSET);
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
// Default value to unmask IRQ on the write call.
|
||||||
|
info = 1;
|
||||||
readCommandQueue();
|
readCommandQueue();
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case State::INIT:
|
case State::INIT:
|
||||||
@ -166,9 +169,12 @@ ReturnValue_t PdecHandler::irqOperation() {
|
|||||||
nb = write(fd, &info, sizeof(info));
|
nb = write(fd, &info, sizeof(info));
|
||||||
if (nb != static_cast<ssize_t>(sizeof(info))) {
|
if (nb != static_cast<ssize_t>(sizeof(info))) {
|
||||||
sif::error << "PdecHandler::irqOperation: Unmasking IRQ failed" << std::endl;
|
sif::error << "PdecHandler::irqOperation: Unmasking IRQ failed" << std::endl;
|
||||||
|
triggerEvent(WRITE_SYSCALL_ERROR_PDEC, errno);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
state = State::INIT;
|
||||||
|
return returnvalue::FAILED;
|
||||||
}
|
}
|
||||||
|
struct pollfd fds = {.fd = fd, .events = POLLIN, .revents = 0};
|
||||||
ret = poll(&fds, 1, IRQ_TIMEOUT_MS);
|
ret = poll(&fds, 1, IRQ_TIMEOUT_MS);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
// No TCs for timeout period
|
// No TCs for timeout period
|
||||||
@ -195,12 +201,15 @@ ReturnValue_t PdecHandler::irqOperation() {
|
|||||||
lockCheckCd.resetTimer();
|
lockCheckCd.resetTimer();
|
||||||
}
|
}
|
||||||
// Clear interrupts with dummy read
|
// Clear interrupts with dummy read
|
||||||
ret = *(registerBaseAddress + PDEC_PIR_OFFSET);
|
dummy = *(registerBaseAddress + PDEC_PIR_OFFSET);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
sif::error << "PdecHandler::irqOperation: Poll error with errno " << errno << ": "
|
sif::error << "PdecHandler::irqOperation: Poll error with errno " << errno << ": "
|
||||||
<< strerror(errno) << std::endl;
|
<< strerror(errno) << std::endl;
|
||||||
triggerEvent(POLL_ERROR_PDEC, errno);
|
triggerEvent(POLL_SYSCALL_ERROR_PDEC, errno);
|
||||||
|
close(fd);
|
||||||
|
state = State::INIT;
|
||||||
|
return returnvalue::FAILED;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -211,6 +220,8 @@ ReturnValue_t PdecHandler::irqOperation() {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// To avoid compiler warning
|
||||||
|
static_cast<void>(dummy);
|
||||||
return returnvalue::OK;
|
return returnvalue::OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,7 +87,8 @@ class PdecHandler : public SystemObject, public ExecutableObjectIF, public HasAc
|
|||||||
static const Event LOST_CARRIER_LOCK_PDEC = MAKE_EVENT(5, severity::INFO);
|
static const Event LOST_CARRIER_LOCK_PDEC = MAKE_EVENT(5, severity::INFO);
|
||||||
//! [EXPORT] : [COMMENT] Lost bit lock
|
//! [EXPORT] : [COMMENT] Lost bit lock
|
||||||
static const Event LOST_BIT_LOCK_PDEC = MAKE_EVENT(6, severity::INFO);
|
static const Event LOST_BIT_LOCK_PDEC = MAKE_EVENT(6, severity::INFO);
|
||||||
static constexpr Event POLL_ERROR_PDEC = event::makeEvent(SUBSYSTEM_ID, 7, severity::MEDIUM);
|
static constexpr Event POLL_SYSCALL_ERROR_PDEC = event::makeEvent(SUBSYSTEM_ID, 7, severity::MEDIUM);
|
||||||
|
static constexpr Event WRITE_SYSCALL_ERROR_PDEC = event::makeEvent(SUBSYSTEM_ID, 8, severity::MEDIUM);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static const uint8_t INTERFACE_ID = CLASS_ID::PDEC_HANDLER;
|
static const uint8_t INTERFACE_ID = CLASS_ID::PDEC_HANDLER;
|
||||||
|
2
tmtc
2
tmtc
@ -1 +1 @@
|
|||||||
Subproject commit 94a82b84e86177d122f4ac12eff6e06528f6290b
|
Subproject commit 33da498ea8aeb2e8b328d040b3cd0720aa12f50c
|
Loading…
Reference in New Issue
Block a user