moving method
This commit is contained in:
parent
95117bcfdc
commit
49a301d57a
|
@ -110,10 +110,10 @@ static void vappendPrintfI(Logging *logging, const char *fmt, va_list arg) {
|
||||||
/**
|
/**
|
||||||
* this method acquires system lock to guard the shared intermediateLoggingBuffer memory stream
|
* this method acquires system lock to guard the shared intermediateLoggingBuffer memory stream
|
||||||
*/
|
*/
|
||||||
static void vappendPrintf(Logging *logging, const char *fmt, va_list arg) {
|
void Logging::vappendPrintf(const char *fmt, va_list arg) {
|
||||||
efiAssertVoid(CUSTOM_ERR_6604, getRemainingStack(chThdGetSelfX()) > 128, "lowstck#5b");
|
efiAssertVoid(CUSTOM_ERR_6604, getRemainingStack(chThdGetSelfX()) > 128, "lowstck#5b");
|
||||||
int wasLocked = lockAnyContext();
|
int wasLocked = lockAnyContext();
|
||||||
vappendPrintfI(logging, fmt, arg);
|
vappendPrintfI(this, fmt, arg);
|
||||||
if (!wasLocked) {
|
if (!wasLocked) {
|
||||||
unlockAnyContext();
|
unlockAnyContext();
|
||||||
}
|
}
|
||||||
|
@ -124,7 +124,7 @@ void appendPrintf(Logging *logging, const char *fmt, ...) {
|
||||||
efiAssertVoid(CUSTOM_ERR_6607, getRemainingStack(chThdGetSelfX()) > 128, "lowstck#4");
|
efiAssertVoid(CUSTOM_ERR_6607, getRemainingStack(chThdGetSelfX()) > 128, "lowstck#4");
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
vappendPrintf(logging, fmt, ap);
|
logging->vappendPrintf(fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ void Logging::appendPrintf(const char *fmt, ...) {
|
||||||
efiAssertVoid(CUSTOM_ERR_6607, getRemainingStack(chThdGetSelfX()) > 128, "lowstck#4");
|
efiAssertVoid(CUSTOM_ERR_6607, getRemainingStack(chThdGetSelfX()) > 128, "lowstck#4");
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
vappendPrintf(this, fmt, ap);
|
vappendPrintf(fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,7 +255,7 @@ void printMsg(Logging *logger, const char *fmt, ...) {
|
||||||
|
|
||||||
va_list ap;
|
va_list ap;
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
vappendPrintf(logger, fmt, ap);
|
logger->vappendPrintf(fmt, ap);
|
||||||
va_end(ap);
|
va_end(ap);
|
||||||
|
|
||||||
append(logger, DELIMETER);
|
append(logger, DELIMETER);
|
||||||
|
@ -263,31 +263,6 @@ void printMsg(Logging *logger, const char *fmt, ...) {
|
||||||
resetLogging(logger);
|
resetLogging(logger);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* this whole method is executed under syslock so that we can have multiple threads use the same shared buffer
|
|
||||||
* in order to reduce memory usage
|
|
||||||
*/
|
|
||||||
void scheduleMsg(Logging *logging, const char *fmt, ...) {
|
|
||||||
if (logging == NULL) {
|
|
||||||
warning(CUSTOM_ERR_LOGGING_NULL, "logging NULL");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int wasLocked = lockAnyContext();
|
|
||||||
resetLogging(logging); // todo: is 'reset' really needed here?
|
|
||||||
appendMsgPrefix(logging);
|
|
||||||
|
|
||||||
va_list ap;
|
|
||||||
va_start(ap, fmt);
|
|
||||||
vappendPrintf(logging, fmt, ap);
|
|
||||||
va_end(ap);
|
|
||||||
|
|
||||||
appendMsgPostfix(logging);
|
|
||||||
scheduleLogging(logging);
|
|
||||||
if (!wasLocked) {
|
|
||||||
unlockAnyContext();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t remainingSize(Logging *logging) {
|
uint32_t remainingSize(Logging *logging) {
|
||||||
return logging->bufferSize - loggingSize(logging);
|
return logging->bufferSize - loggingSize(logging);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ public:
|
||||||
Logging();
|
Logging();
|
||||||
Logging(const char *name, char *buffer, int bufferSize);
|
Logging(const char *name, char *buffer, int bufferSize);
|
||||||
void initLoggingExt(const char *name, char *buffer, int bufferSize);
|
void initLoggingExt(const char *name, char *buffer, int bufferSize);
|
||||||
|
void vappendPrintf(const char *fmt, va_list arg);
|
||||||
void append(const char *text);
|
void append(const char *text);
|
||||||
void appendFast(const char *text);
|
void appendFast(const char *text);
|
||||||
void appendPrintf(const char *fmt, ...);
|
void appendPrintf(const char *fmt, ...);
|
||||||
|
|
|
@ -128,4 +128,30 @@ void initLoggingCentral(void) {
|
||||||
accumulatedSize = 0;
|
accumulatedSize = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* this whole method is executed under syslock so that we can have multiple threads use the same shared buffer
|
||||||
|
* in order to reduce memory usage
|
||||||
|
*/
|
||||||
|
void scheduleMsg(Logging *logging, const char *fmt, ...) {
|
||||||
|
if (logging == NULL) {
|
||||||
|
warning(CUSTOM_ERR_LOGGING_NULL, "logging NULL");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
int wasLocked = lockAnyContext();
|
||||||
|
resetLogging(logging); // todo: is 'reset' really needed here?
|
||||||
|
appendMsgPrefix(logging);
|
||||||
|
|
||||||
|
va_list ap;
|
||||||
|
va_start(ap, fmt);
|
||||||
|
logging->vappendPrintf(fmt, ap);
|
||||||
|
va_end(ap);
|
||||||
|
|
||||||
|
appendMsgPostfix(logging);
|
||||||
|
scheduleLogging(logging);
|
||||||
|
if (!wasLocked) {
|
||||||
|
unlockAnyContext();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif /* EFI_UNIT_TEST */
|
#endif /* EFI_UNIT_TEST */
|
||||||
|
|
Loading…
Reference in New Issue