2021-08-04 02:32:40 +00:00
|
|
|
// Copyright 2015-2021 Mobilinkd LLC <rob@mobilinkd.com>
|
2018-07-30 02:34:53 +00:00
|
|
|
// All rights reserved.
|
|
|
|
|
|
|
|
#include "HdlcFrame.hpp"
|
2019-06-23 02:53:34 +00:00
|
|
|
#include "Log.h"
|
2021-02-22 02:48:09 +00:00
|
|
|
#include "main.h"
|
2019-06-23 02:53:34 +00:00
|
|
|
#include "cmsis_os.h"
|
2018-07-30 02:34:53 +00:00
|
|
|
|
|
|
|
namespace mobilinkd { namespace tnc { namespace hdlc {
|
|
|
|
|
|
|
|
FrameSegmentPool frameSegmentPool __attribute__((section(".bss2")));
|
|
|
|
|
|
|
|
IoFramePool& ioFramePool() {
|
|
|
|
static IoFramePool pool;
|
|
|
|
return pool;
|
|
|
|
}
|
|
|
|
|
|
|
|
void release(IoFrame* frame)
|
|
|
|
{
|
|
|
|
ioFramePool().release(frame);
|
|
|
|
}
|
|
|
|
|
2019-06-23 02:53:34 +00:00
|
|
|
IoFrame* acquire()
|
|
|
|
{
|
|
|
|
auto result = ioFramePool().acquire();
|
|
|
|
if (result == nullptr) CxxErrorHandler();
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
IoFrame* acquire_wait()
|
|
|
|
{
|
|
|
|
IoFrame* result = nullptr;
|
|
|
|
while ((result = ioFramePool().acquire()) == nullptr) {
|
|
|
|
osThreadYield();
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2018-07-30 02:34:53 +00:00
|
|
|
}}} // mobilinkd::tnc::hdlc
|