mirror of
https://gitea.osmocom.org/sim-card/simtrace2.git
synced 2026-03-16 21:28:33 +03:00
This also removes the actual queuing code from req_ctx, and leaves this to the caller. Only tw out of the existing states actually required the ordering requirement enforced by the qeue, and in the future we will need to have per-endpoint queues anyway. Both means it is better to manage queues outside the req_ctx, and leve that as a pure memory allocator.
61 lines
1.5 KiB
C
61 lines
1.5 KiB
C
#pragma once
|
|
|
|
#define RCTX_SIZE_LARGE 960
|
|
#define RCTX_SIZE_SMALL 320
|
|
#define MAX_HDRSIZE sizeof(struct openpcd_hdr)
|
|
|
|
#include <stdint.h>
|
|
#include "linuxlist.h"
|
|
|
|
#define __ramfunc
|
|
|
|
enum req_ctx_state {
|
|
/* free to be allocated */
|
|
RCTX_S_FREE,
|
|
|
|
/* USB -> UART */
|
|
/* In USB driver, waiting for data from host */
|
|
RCTX_S_USB_RX_BUSY,
|
|
/* somewhere in the main loop */
|
|
RCTX_S_MAIN_PROCESSING,
|
|
/* pending (in queue) for transmission on UART */
|
|
RCTX_S_UART_TX_PENDING,
|
|
/* currently in active transmission on UART */
|
|
RCTX_S_UART_TX_BUSY,
|
|
|
|
/* UART -> USB */
|
|
/* currently in active reception on UART */
|
|
RCTX_S_UART_RX_BUSY,
|
|
/* pending (in queue) for transmission over USB to host */
|
|
RCTX_S_USB_TX_PENDING,
|
|
/* currently in transmission over USB to host */
|
|
RCTX_S_USB_TX_BUSY,
|
|
|
|
/* number of states */
|
|
RCTX_STATE_COUNT
|
|
};
|
|
|
|
struct req_ctx {
|
|
/* if this req_ctx is on a queue... */
|
|
struct llist_head list;
|
|
uint32_t ep;
|
|
|
|
/* enum req_ctx_state */
|
|
volatile uint32_t state;
|
|
/* size of th 'data' buffer */
|
|
uint16_t size;
|
|
/* total number of used bytes in buffer */
|
|
uint16_t tot_len;
|
|
/* index into the buffer, user specific */
|
|
uint16_t idx;
|
|
/* actual data buffer */
|
|
uint8_t *data;
|
|
};
|
|
|
|
extern struct req_ctx __ramfunc *req_ctx_find_get(int large, uint32_t old_state, uint32_t new_state);
|
|
extern struct req_ctx *req_ctx_find_busy(void);
|
|
extern void req_ctx_set_state(struct req_ctx *ctx, uint32_t new_state);
|
|
extern void req_ctx_put(struct req_ctx *ctx);
|
|
extern uint8_t req_ctx_num(struct req_ctx *ctx);
|
|
unsigned int req_ctx_count(uint32_t state);
|