tooth logger uses big buffer (#4883)

* big buffer

* mostly hooked up big buffer

* bad merge

* s

* sneak preview of trigger scope

* s

* constness

* channel limits

* s

* unnecessary

* efilib

* TcpServerSandbox

* includes fix

* binary format

* tooth logger uses big buffer

* dead config
This commit is contained in:
Matthew Kennedy 2022-12-10 14:17:15 -08:00 committed by GitHub
parent 994ee2f22f
commit 2a372b6da1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 6 deletions

View File

@ -75,8 +75,9 @@ void DisableToothLogger() {
#else // not EFI_UNIT_TEST
static constexpr size_t bufferCount = 4;
static constexpr size_t entriesPerBuffer = COMPOSITE_PACKET_COUNT / bufferCount;
static constexpr size_t entriesPerBuffer = 250;
static constexpr size_t totalEntryCount = BIG_BUFFER_SIZE / sizeof(composite_logger_s);
static constexpr size_t bufferCount = totalEntryCount / entriesPerBuffer;
struct CompositeBuffer {
composite_logger_s buffer[entriesPerBuffer];
@ -84,7 +85,7 @@ struct CompositeBuffer {
Timer startTime;
};
static CompositeBuffer buffers[bufferCount] CCM_OPTIONAL;
static CompositeBuffer* buffers = nullptr;
static chibios_rt::Mailbox<CompositeBuffer*, bufferCount> freeBuffers CCM_OPTIONAL;
static chibios_rt::Mailbox<CompositeBuffer*, bufferCount> filledBuffers CCM_OPTIONAL;
@ -96,11 +97,20 @@ static void setToothLogReady(bool value) {
#endif // EFI_TUNER_STUDIO
}
static BigBufferHandle bufferHandle;
void EnableToothLogger() {
chibios_rt::CriticalSectionLocker csl;
bufferHandle = getBigBuffer(BigBufferUser::ToothLogger);
if (!bufferHandle) {
return;
}
buffers = bufferHandle.get<CompositeBuffer>();
// Reset all buffers
for (size_t i = 0; i < efi::size(buffers); i++) {
for (size_t i = 0; i < bufferCount; i++) {
buffers[i].nextIdx = 0;
}
@ -112,7 +122,7 @@ void EnableToothLogger() {
while (MSG_TIMEOUT != filledBuffers.fetchI(&dummy)) ;
// Put all buffers in the free list
for (size_t i = 0; i < efi::size(buffers); i++) {
for (size_t i = 0; i < bufferCount; i++) {
freeBuffers.postI(&buffers[i]);
}
@ -126,6 +136,12 @@ void EnableToothLogger() {
}
void DisableToothLogger() {
chibios_rt::CriticalSectionLocker csl;
// Release the big buffer for another user
bufferHandle = {};
buffers = nullptr;
ToothLoggerEnabled = false;
setToothLogReady(false);
}

View File

@ -139,7 +139,6 @@ struct_no_prefix engine_configuration_s
#define TOOTH_PACKET_SIZE 2
#define TOOTH_DATA_LENGTH @@TOOTH_PACKET_SIZE@@*@@TOOTH_PACKET_COUNT@@
#define COMPOSITE_PACKET_COUNT 1000
#define COMPOSITE_PACKET_SIZE 5
#define MAP_ANGLE_SIZE 8