39#ifndef PROTOCORE_PREEMPT_QUEUE_H
40#define PROTOCORE_PREEMPT_QUEUE_H
44#if PROTOCORE_ENABLE_PREEMPT_QUEUE
54 PROTOCORE_PQ_LANE_USER = 0,
55 PROTOCORE_PQ_LANE_DMA,
56 PROTOCORE_PQ_LANE_FORWARD,
57 PROTOCORE_PQ_LANE_DEVICE,
58 PROTOCORE_PQ_LANE_COUNT);
65typedef void (*protocore_pq_handler)(
const void *item,
void *ctx);
75 protocore_pq_handler handler;
86 uint32_t timeout_ticks;
113 protocore_pq_lane lane;
114 const protocore_pq_config *cfg;
115 PqPostArgs post_args;
122extern PreemptQueueVars PreemptQueueV;
127 void (*
const post_from_isr)(uint8_t *work);
128 void (*
const post_urgent)(uint8_t *work);
129 void (*
const high_water)(uint8_t *work);
130 void (*
const priority)(
const uint8_t *work);
131 void (*
const running)(uint8_t *work);
132 void (*
const start)(uint8_t *work);
133 void (*
const post)(uint8_t *work);
134 void (*
const drain)(
const uint8_t *work);
135 void (*
const stop)(uint8_t *work);
140void protocore_preempt_queue_post_from_isr(uint8_t *work);
141void protocore_preempt_queue_post_urgent(uint8_t *work);
142void protocore_preempt_queue_high_water(uint8_t *work);
143void protocore_preempt_queue_priority(
const uint8_t *work);
144void protocore_preempt_queue_running(uint8_t *work);
145void protocore_preempt_queue_start(uint8_t *work);
146void protocore_preempt_queue_post(uint8_t *work);
147void protocore_preempt_queue_drain(
const uint8_t *work);
148void protocore_preempt_queue_stop(uint8_t *work);
154static const PreemptQueueNs PreemptQueue __attribute__((unused)) = {
155 .post_from_isr = protocore_preempt_queue_post_from_isr,
156 .post_urgent = protocore_preempt_queue_post_urgent,
157 .high_water = protocore_preempt_queue_high_water,
158 .priority = protocore_preempt_queue_priority,
159 .running = protocore_preempt_queue_running,
160 .start = protocore_preempt_queue_start,
161 .post = protocore_preempt_queue_post,
162 .drain = protocore_preempt_queue_drain,
163 .stop = protocore_preempt_queue_stop,
175uint8_t *protocore_preempt_queue_span(
void);
180EMBED_INLINE embed_bool protocore_pq_start(
const protocore_pq_config *cfg)
182 PreemptQueueV.lane = PROTOCORE_PQ_LANE_USER;
183 PreemptQueueV.cfg = cfg;
184 PreemptQueue.start(protocore_preempt_queue_span());
185 return PreemptQueueV.ok;
188EMBED_INLINE embed_bool protocore_pq_post(
const void *item, uint32_t timeout_ticks)
190 PreemptQueueV.lane = PROTOCORE_PQ_LANE_USER;
191 PreemptQueueV.post_args.item = item;
192 PreemptQueueV.post_args.timeout_ticks = timeout_ticks;
193 PreemptQueue.post(protocore_preempt_queue_span());
194 return PreemptQueueV.ok;
197EMBED_INLINE embed_bool protocore_pq_post_urgent(
const void *item, uint32_t timeout_ticks)
199 PreemptQueueV.lane = PROTOCORE_PQ_LANE_USER;
200 PreemptQueueV.post_args.item = item;
201 PreemptQueueV.post_args.timeout_ticks = timeout_ticks;
202 PreemptQueue.post_urgent(protocore_preempt_queue_span());
203 return PreemptQueueV.ok;
206EMBED_INLINE embed_bool protocore_pq_post_from_isr(
const void *item)
208 PreemptQueueV.lane = PROTOCORE_PQ_LANE_USER;
209 PreemptQueueV.post_args.item = item;
210 PreemptQueue.post_from_isr(protocore_preempt_queue_span());
211 return PreemptQueueV.ok;
214EMBED_INLINE
void protocore_pq_drain(
void)
216 PreemptQueueV.lane = PROTOCORE_PQ_LANE_USER;
217 PreemptQueue.drain(protocore_preempt_queue_span());
220EMBED_INLINE
void protocore_pq_stop(
void)
222 PreemptQueueV.lane = PROTOCORE_PQ_LANE_USER;
223 PreemptQueue.stop(protocore_preempt_queue_span());
226EMBED_INLINE embed_bool protocore_pq_running(
void)
228 PreemptQueueV.lane = PROTOCORE_PQ_LANE_USER;
229 PreemptQueue.running(protocore_preempt_queue_span());
230 return PreemptQueueV.ok;
233EMBED_INLINE
size_t protocore_pq_high_water(
void)
235 PreemptQueueV.lane = PROTOCORE_PQ_LANE_USER;
236 PreemptQueue.high_water(protocore_preempt_queue_span());
237 return PreemptQueueV.n;
EMBED_ENUM_BYTE(ProtoConn, PROTO_NONE=0, PROTO_HTTP=1, PROTO_TELNET=2, PROTO_SSH=3, PROTO_MODBUS=4, PROTO_OPCUA=5, PROTO_SSH_RFWD=6, PROTO_RELAY=7, PROTO_BRIDGE=8, PROTO_NTRIP_CASTER=9, PROTO_MESH=10, PROTO_UDP=11,)
Application protocol spoken on a listener port or connection slot.