remove intermediate buffer (#2668)
* remove define * goodbye intermediate logging buffer * free ram! woo!
This commit is contained in:
parent
3bc268810d
commit
6a060e5cae
|
@ -337,7 +337,6 @@
|
|||
/**
|
||||
* This is the size of the MemoryStream used by chvprintf
|
||||
*/
|
||||
#define INTERMEDIATE_LOGGING_BUFFER_SIZE 2000
|
||||
#define STATUS_LOGGING_BUFFER_SIZE 1800
|
||||
#define SETTINGS_LOGGING_BUFFER_SIZE 1000
|
||||
#define DL_OUTPUT_BUFFER 6500
|
||||
|
|
|
@ -303,7 +303,6 @@
|
|||
/**
|
||||
* This is the size of the MemoryStream used by chvprintf
|
||||
*/
|
||||
#define INTERMEDIATE_LOGGING_BUFFER_SIZE 200 /*2000*/
|
||||
#define STATUS_LOGGING_BUFFER_SIZE 120 /*1800*/
|
||||
#define SETTINGS_LOGGING_BUFFER_SIZE 100 /*1000*/
|
||||
#define DL_OUTPUT_BUFFER 10 /*6500*/
|
||||
|
|
|
@ -321,12 +321,6 @@
|
|||
#define CONFIG_RESET_SWITCH_PIN 6
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This is the size of the MemoryStream used by chvprintf
|
||||
*/
|
||||
#define INTERMEDIATE_LOGGING_BUFFER_SIZE 2000
|
||||
|
||||
|
||||
// Enable file logging (like SD card) logic
|
||||
#define EFI_FILE_LOGGING FALSE
|
||||
|
||||
|
|
|
@ -399,9 +399,4 @@
|
|||
#define CONFIG_RESET_SWITCH_PIN 6
|
||||
#endif
|
||||
|
||||
/**
|
||||
* This is the size of the MemoryStream used by chvprintf
|
||||
*/
|
||||
#define INTERMEDIATE_LOGGING_BUFFER_SIZE 2000
|
||||
|
||||
#define EFI_JOYSTICK TRUE
|
||||
|
|
|
@ -702,7 +702,7 @@ void initEngineContoller(DECLARE_ENGINE_PARAMETER_SUFFIX) {
|
|||
* UNUSED_SIZE constants.
|
||||
*/
|
||||
#ifndef RAM_UNUSED_SIZE
|
||||
#define RAM_UNUSED_SIZE 3900
|
||||
#define RAM_UNUSED_SIZE 5900
|
||||
#endif
|
||||
#ifndef CCM_UNUSED_SIZE
|
||||
#define CCM_UNUSED_SIZE 300
|
||||
|
|
|
@ -40,36 +40,6 @@
|
|||
#include "os_util.h"
|
||||
#endif // EFI_UNIT_TEST
|
||||
|
||||
static uint8_t intermediateLoggingBufferData[INTERMEDIATE_LOGGING_BUFFER_SIZE] CCM_OPTIONAL;
|
||||
|
||||
class IntermediateLogging {
|
||||
public:
|
||||
/**
|
||||
* Class constructors are a great way to have simple initialization sequence
|
||||
*/
|
||||
IntermediateLogging() {
|
||||
#if ! EFI_UNIT_TEST
|
||||
msObjectInit(&intermediateLoggingBuffer, intermediateLoggingBufferData, INTERMEDIATE_LOGGING_BUFFER_SIZE, 0);
|
||||
#endif // EFI_UNIT_TEST
|
||||
}
|
||||
#if ! EFI_UNIT_TEST
|
||||
MemoryStream intermediateLoggingBuffer;
|
||||
#endif // EFI_UNIT_TEST
|
||||
|
||||
// todo: look into chsnprintf once on Chibios 3
|
||||
void vappendPrintfI(Logging *logging, const char *fmt, va_list arg) {
|
||||
#if ! EFI_UNIT_TEST
|
||||
intermediateLoggingBuffer.eos = 0; // reset
|
||||
efiAssertVoid(CUSTOM_ERR_6603, getCurrentRemainingStack() > 128, "lowstck#1b");
|
||||
chvprintf((BaseSequentialStream *) &intermediateLoggingBuffer, fmt, arg);
|
||||
intermediateLoggingBuffer.buffer[intermediateLoggingBuffer.eos] = 0; // need to terminate explicitly
|
||||
logging->append((char *)intermediateLoggingBuffer.buffer);
|
||||
#endif // EFI_UNIT_TEST
|
||||
}
|
||||
};
|
||||
|
||||
static IntermediateLogging intermediateLogging;
|
||||
|
||||
/**
|
||||
* @returns true if data does not fit into this buffer
|
||||
*/
|
||||
|
@ -108,22 +78,6 @@ void Logging::appendFast(const char *text) {
|
|||
linePointer = s - 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* this method acquires system lock to guard the shared intermediateLoggingBuffer memory stream
|
||||
*/
|
||||
void Logging::vappendPrintf(const char *fmt, va_list arg) {
|
||||
#if ! EFI_UNIT_TEST
|
||||
#if EFI_ENABLE_ASSERTS
|
||||
// todo: Kinetis needs real getCurrentRemainingStack or mock
|
||||
if (getCurrentRemainingStack() < 128) {
|
||||
firmwareError(CUSTOM_ERR_6604, "lowstck#5b %s", chThdGetSelfX()->name);
|
||||
}
|
||||
#endif // EFI_ENABLE_ASSERTS
|
||||
chibios_rt::CriticalSectionLocker csl;
|
||||
intermediateLogging.vappendPrintfI(this, fmt, arg);
|
||||
#endif // EFI_UNIT_TEST
|
||||
}
|
||||
|
||||
void Logging::appendPrintf(const char *fmt, ...) {
|
||||
#if EFI_UNIT_TEST
|
||||
va_list ap;
|
||||
|
@ -132,10 +86,20 @@ void Logging::appendPrintf(const char *fmt, ...) {
|
|||
va_end(ap);
|
||||
#else
|
||||
efiAssertVoid(CUSTOM_APPEND_STACK, getCurrentRemainingStack() > 128, "lowstck#4");
|
||||
|
||||
size_t available = remainingSize();
|
||||
|
||||
va_list ap;
|
||||
va_start(ap, fmt);
|
||||
vappendPrintf(fmt, ap);
|
||||
size_t written = chvsnprintf(linePointer, available, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
// chvnsprintf returns how many bytes WOULD HAVE been written if it fit,
|
||||
// so clip it to the available space if necessary
|
||||
linePointer += (written > available) ? available : written;
|
||||
// ensure buffer is always null terminated
|
||||
buffer[bufferSize - 1] = '\0';
|
||||
|
||||
#endif // EFI_UNIT_TEST
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,6 @@ public:
|
|||
|
||||
void reset();
|
||||
|
||||
void vappendPrintf(const char *fmt, va_list arg);
|
||||
void append(const char *text);
|
||||
void appendFast(const char *text);
|
||||
void appendPrintf(const char *fmt, ...);
|
||||
|
|
|
@ -145,10 +145,5 @@
|
|||
|
||||
#define EFI_TUNER_STUDIO TRUE
|
||||
|
||||
/**
|
||||
* This is the size of the MemoryStream used by chvprintf
|
||||
*/
|
||||
#define INTERMEDIATE_LOGGING_BUFFER_SIZE 2000
|
||||
|
||||
#define EFI_BOARD_TEST FALSE
|
||||
#define EFI_JOYSTICK FALSE
|
||||
|
|
|
@ -19,7 +19,6 @@ typedef uint32_t ioportid_t;
|
|||
typedef uint32_t ioportmask_t;
|
||||
|
||||
#define DL_OUTPUT_BUFFER 200
|
||||
#define INTERMEDIATE_LOGGING_BUFFER_SIZE 100
|
||||
|
||||
// just a stub implementation for unit tests
|
||||
#define EXPECTED_REMAINING_STACK 1
|
||||
|
|
Loading…
Reference in New Issue