diff --git a/firmware/.cproject b/firmware/.cproject
index 9deb24c48c..02d5be253e 100644
--- a/firmware/.cproject
+++ b/firmware/.cproject
@@ -106,7 +106,7 @@
-
+
@@ -167,7 +167,7 @@
-
+
diff --git a/firmware/util/loggingcentral.cpp b/firmware/util/loggingcentral.cpp
index 8a9d282bcd..e1acd5663c 100644
--- a/firmware/util/loggingcentral.cpp
+++ b/firmware/util/loggingcentral.cpp
@@ -8,6 +8,8 @@
#include "main.h"
#include "efilib.h"
+#if ! EFI_UNIT_TEST || defined(__DOXYGEN__)
+
typedef char log_buf_t[DL_OUTPUT_BUFFER];
/**
@@ -63,32 +65,44 @@ void scheduleLogging(Logging *logging) {
resetLogging(logging);
}
+/**
+ * this method should always be invoked from the same thread!
+ */
+char * swapOutputBuffers(int *actualOutputBufferSize) {
+ int expectedOutputSize;
+ { // start of critical section
+ lockOutputBuffer();
+ /**
+ * we cannot output under syslock, we simply rotate which buffer is which
+ */
+ char *temp = outputBuffer;
+
+ expectedOutputSize = accumulatedSize;
+ outputBuffer = accumulationBuffer;
+
+ accumulationBuffer = temp;
+ accumulatedSize = 0;
+ accumulationBuffer[0] = 0;
+
+ unlockOutputBuffer();
+ } // end of critical section
+
+ *actualOutputBufferSize = efiStrlen(outputBuffer);
+ efiAssert(*actualOutputBufferSize == expectedOutputSize, "out constr", NULL);
+ return outputBuffer;
+}
+
/**
* This method actually sends all the pending data to the communication layer.
* This method is invoked by the main thread - that's the only thread which should be sending
* actual data to console in order to avoid concurrent access to serial hardware.
*/
void printPending(void) {
- lockOutputBuffer();
- /**
- * we cannot output under syslock, we simply rotate which buffer is which
- */
- char *temp = outputBuffer;
+ int actualOutputBufferSize;
+ char *output = swapOutputBuffers(&actualOutputBufferSize);
- int expectedOutputSize = accumulatedSize;
- outputBuffer = accumulationBuffer;
-
- accumulationBuffer = temp;
- accumulatedSize = 0;
- accumulationBuffer[0] = 0;
-
- unlockOutputBuffer();
-
- int actualOutputBuffer = efiStrlen(outputBuffer);
- efiAssertVoid(actualOutputBuffer == expectedOutputSize, "out constr");
-
- if (actualOutputBuffer > 0) {
- printWithLength(outputBuffer);
+ if (actualOutputBufferSize > 0) {
+ printWithLength(output);
}
}
@@ -99,3 +113,5 @@ void initLoggingCentral(void) {
outputBuffer = pendingBuffers1;
accumulatedSize = 0;
}
+
+#endif /* EFI_UNIT_TEST */
diff --git a/firmware/util/util.mk b/firmware/util/util.mk
index d27dba66cd..7396075209 100644
--- a/firmware/util/util.mk
+++ b/firmware/util/util.mk
@@ -7,6 +7,7 @@ UTILSRC = $(UTIL_TEST_SRC)
UTILSRC_CPP = $(PROJECT_DIR)/util/cyclic_buffer.cpp \
$(PROJECT_DIR)/console_util/datalogging.cpp \
+ $(PROJECT_DIR)/console_util/loggingcentral.cpp \
$(PROJECT_DIR)/util/listener_array.cpp \
$(PROJECT_DIR)/util/cli_registry.cpp \
$(PROJECT_DIR)/util/efilib.cpp \